This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/** | |
* A dummy cuda asynchronous function | |
*/ | |
__global__ void fillContents(int N, int* output) | |
{ | |
int correctIndex = threadIdx.x * N; | |
for(int i = correctIndex; i < N; i++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* API to report the memory usage of the GPU | |
*/ | |
static void reportMemStatus() { | |
// show memory usage of GPU | |
size_t free_byte; | |
size_t total_byte; | |
size_t malloc_byte; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define MALLOC_LIMIT 1024*1024*1024 //1 GB | |
//eliminate calling cudaDeviceSetLimit multiple times | |
bool IsMallocSet = false; | |
/** | |
* API to set the malloc limit of GPU | |
*/ | |
static void setMallocLimit() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdio.h" | |
//enable error check | |
#define CUDA_ERROR_CHECK | |
//check the synchronous function call errorcode 'err' if it is a cudaSuccess | |
#define CudaSafeCall( err ) __cudaSafeCall( err, __FILE__, __LINE__ ) | |
//check if any error happened during asynchronous execution of Cuda kernel __global__ function | |
#define CudaCheckError() __cudaCheckError( __FILE__, __LINE__ ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'torch'; | |
require 'math' | |
require 'io' | |
require 'cutorch'; | |
require 'cunn'; | |
opt = 'DOUBLE' -- FLOAT / DOUBLE / CUDA | |
----------------------------------------------------------- |
NewerOlder