Modular code section


One of my kernels is a few lines long mathmatical function. This function which consists of small vector operations is likely to change a lot. Rebuilding the program for each change here is very inconvienient, however having written a few pixel/vertex-shaders in HLSL in conjunction with D3D, I remember those were exactly what I would need here. To have something like .fx files would be priceless here. As this is not D3D I’m wonder whether or not CUDA have something which work the same way as those .fx files. Does anyone know? Performance is not so much of an issue here.

I’m also interested in knowing how I can find out if there is a CUDA compatible device present in the machine, is there a function I can call to find out?

Thank you so much for your help! :wub:


The CUT_DEVICE_INIT macro in the cutil.h file uses cudaGetDeviceCount to get the number of devices (returns 0 if there are none I guess). And you also can get the properties of each device with cudaGetDeviceProperties. The documentation gives this example:

int deviceCount; 


int device; for (device = 0; device < deviceCount; ++device) 


   cudaDeviceProp deviceProp; 

   cudaGetDeviceProperties(&deviceProp, device); 


As for your first question I’m not sure if it is possible. I haven’t found anything suggesting something like that in the documentation.

It’s possible to get function pointer to device functions.
You can also generate a .h containing a name-pointer array or something automatically from .cubin.
Maybe a CUDAfx would come in handy.