The EMData class and CUDA

The EMData class can be converted to a CUDA device pointer or alternatively bound to a CUDA texture using single function calls.

Accessing the CUDA device pointer

This can be done with a single function call:

   1 EMData* e = new EMData(64,64,64);
   2 e->process_inplace("testimage.noise.gauss",Dict());
   3 float* cuda_data = e->get_cuda_data();

Binding to a CUDA texture

The way in which texture binding occurs is likely to change. What we have right now is a stop gap - the design will evolve as we fully integrate EMAN2 and CUDA. However, the syntax used is not like to substantially change. The main failings in the current implementation is that there is no control over the name of the texture that you bind to, and also that there are only 2 textures (one 2D and one 3D).

Binding to a CUDA texture can be done with a single function call:

   1 EMData* e = new EMData(64,64,64);
   2 e->process_inplace("testimage.noise.gauss",Dict());
   3 e->bind_cuda_texture();

Presently there are two global CUDA textures call tex2d (2D) and tex (3D) - the texture with the correct dimensionality will be bound automatically.

CUDA has two filter modes for textures, namely cudaFilterModeLinear and cudaFilterModePoint. The former mode makes use of basic interpolation whereas the latter finds the nearest point.By default cudaFilterModeLinear is used when you call bind_cuda_texture but you can use cudaFilterModePoint by supplying a flag, eg:

   1 // Make the bound texture use the filter mode cudaFilterModePoint
   2 e->bind_cuda_texture(false);

Eman2UsingCudaFrom (last edited 2009-03-05 18:27:56 by DavidWoolford)