Powered By:
Android Advice
 

Archive for January, 2012

Allocating 2D Arrays in Cuda

January 21, 2012

Allocating 2D arrays in CUDA can be a little confusing at first. There are a couple of mistakes you may make while trying to allocate your first 2D array. Wrong Way #1: int rowCount = 10; float** d_array=0; // array on device cudaMalloc(d_array, rowCount*sizeof(float*)); for(int i = 0 ; i < rowCount ; i++) { [...]

Tags:
Posted in CUDA, Programming No Comments »

Cuda CUDA_ERROR_INVALID_CONTEXT when calling cuMemGetInfo

January 16, 2012

Problem Calling cuMemGetInfo returns the result 201 (CUDA_ERROR_INVALID_CONTEXT) Cause The most common cause is that a context has not been initialised on the current host thread. Solution In your host application before calling cuMemGetInfo make a once off call to create a context. For an example of this see my post CUDA Get Amount of [...]

Posted in CUDA, Problem-Cause-Solution, Programming No Comments »

CUDA Get Amount of Free Global Device Memory

January 14, 2012

There are three steps: 1. Add includes/ .h files 2. create a cuda context 3. query the memory on the device Below is an example of the code required to get the amount of free and total global memory on a cuda device: #include <iostream> // to output to the console #include <cuda.h> // to [...]

Tags: ,
Posted in CUDA, Programming No Comments »