Skip to content

Instantly share code, notes, and snippets.

View sandeepkumar-skb's full-sized avatar
:octocat:
Get comfortable being uncomfortable

Sandeep Kumar Behera sandeepkumar-skb

:octocat:
Get comfortable being uncomfortable
View GitHub Profile
@sandeepkumar-skb
sandeepkumar-skb / py_multiprocess_computeB.py
Last active March 31, 2021 03:49
This is a multiprocessing example speeding up a compute bound problem.
import multiprocessing as mp
import time as time
def square():
for i in range(1000000):
x = pow(i, 2)
if __name__ == "__main__":
num_iter = 10
start = time.time()
@sandeepkumar-skb
sandeepkumar-skb / py_thread_compute_bound.py
Created March 31, 2021 03:34
This python threading example demonstrates python threading in compute bound situation.
import threading
import time as time
def square():
for i in range(1000000):
x = pow(i, 2)
if __name__ == "__main__":
num_iter = 10
start = time.time()
#include <iostream>
#include <chrono>
#define BLOCK_SIZE 256
inline void gpuAssert(cudaError_t err, const char *file, int line)
{
if (err != cudaSuccess){
printf("%s in %s at line %d\n", cudaGetErrorString(err), file, line);
exit(EXIT_FAILURE);
#include <cuda.h>
#include <stdio.h>
#define BLOCK_SIZE 32
#define NUM_REPS 100
inline void gpuAssert(cudaError_t err, const char *file, int line)
{
if (err != cudaSuccess){
printf("%s in %s at line %d\n", cudaGetErrorString(err), file, line);
exit(EXIT_FAILURE);
#include <cooperative_groups.h>
#include <algorithm>
#include <cuda.h>
#include<stdio.h>
using namespace cooperative_groups;
inline void gpuAssert(cudaError_t err, const char *file, int line)
{
if (err != cudaSuccess){
#include <stdio.h>
#include <chrono>
#include <iostream>
#define BLOCK_SIZE 128
inline void gpuAssert(cudaError_t err, const char *file, int line)
{
if (err != cudaSuccess){
printf("%s in %s at line %d\n", cudaGetErrorString(err), __FILE__, __LINE__);
#include <stdio.h>
#include <iostream>
#include <chrono>
#define BLOCK_SIZE 256
#define GRID_SIZE 72 //Turing Titan RTX
#define OUT_SIZE 256
inline void gpuAssert(cudaError_t err, const char *file, int line)
{
@sandeepkumar-skb
sandeepkumar-skb / conv_bn_folding.py
Last active January 10, 2021 21:17
Folding BN into convolution
import torch
import torch.nn as nn
import copy
import torchvision.models as models
class BN_Folder():
def fold(self, model):
mymodel = copy.deepcopy(model)
mymodel.eval()
#include "omp.h"
#include <thread>
#include <iostream>
#include <vector>
#include <chrono>
void doNothing(){
int count =0;
for (int i=0; i<1000; ++i)
@mkolod
mkolod / redirect_streams_and_cuda_checks.cu
Last active September 27, 2020 04:12
Redirect Streams and CUDA checks
#include <csignal>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <unistd.h>
#include <limits.h>
#include <iostream>
#include <sstream>
#include <stdexcept>