Skip to content

Instantly share code, notes, and snippets.

@srivathsanmurali
srivathsanmurali / blogs.md
Last active March 26, 2018 11:49
A list of cool blogs I like
@srivathsanmurali
srivathsanmurali / interestingGitRepos.md
Last active October 18, 2017 11:53
Interesting git repos
@srivathsanmurali
srivathsanmurali / dynamicParallelismCMAKE.md
Last active August 12, 2024 15:47
Compileing CUDA with dynamic parllelism using CMAKE

Dynamic parallelism using CUDA and CMAKE

Requirements:

  • compute_35 or higher cards. I am using Pascal (compute_61)

CMAKE MAGIC

  • set(CUDA_SEPARABLE_COMPILATION TRUE)
  • list(APPEND CUDA_NVCC_FLAGS -gencode arch=compute_61,code=sm_51;)
  • target_link_libraries(yourCudaLib ${CUDA_cudadevrt_LIBRARY}
@srivathsanmurali
srivathsanmurali / llvmOpenmp.nix
Created April 26, 2017 15:02
Openmp package from llvm. Provides libomp. Can be used to comile openmp with clang. use -fopenmp flag.
with import <nixpkgs> {};
stdenv.mkDerivation rec {
name = "openmp-${version}";
version = "24.6.17";
src = fetchgit {
url = "http://llvm.org/git/openmp";
rev = "81a7c91728a2c763d6ecbb9374a0bbf413e43ac4";
#date: "2017-04-25T19:04:07+00:00";
sha256 = "06641656wckpg4va1fn1dz3b6irr525vw699qallhf095h16gskm";
@srivathsanmurali
srivathsanmurali / random.hpp
Created April 12, 2017 08:48
A simple random number generator that is thread safe using C++11 random engines. Random number generator engines are not thread safe. Using thread_local, initializes an engine per thread.
#include <random>
float randFloat(float low, float high) {
thread_local static std::random_device rd;
thread_local static std::mt19937 rng(rd());
thread_local std::uniform_real_distribution<float> urd;
return urd(rng, decltype(urd)::param_type{low,high});
}
@srivathsanmurali
srivathsanmurali / wordHistogram.py
Created November 28, 2016 19:34
Quick python script to find the histogram of words used in the a text file.
#!/usr/bin/python
import sys
import json
from collections import OrderedDict
from operator import itemgetter
def getWordMap(filename):
wordMap = dict()
totalWords = 0