A general C++ CUDA integration framework example I present a simple C++ integration

HI everybody,

I want to introduce you my little framework to manage CUDA in my C++ program.

And I hope I will motivate another person to help me to do the same with texture and cuda Array.

Here the following code I can use in a C++ program (It’s pleasant is’nt it !)

//--| Initialiaze Cuda librairie

	cuda_lib::InitCudaLibrary();

	//--| Create a host and device memory interface

	cuda_lib::gpu_vector<float> device_mem;

	cuda_lib::cpu_vector<float> host_mem;

	//--| Allocate memory

	host_mem.Allocate(10,true,1.0);

	device_mem.Allocate(10);

	//--| Affect data to the cpu vector

	cout<<endl;

	for(int i=0;i<10;++i)

  cout<<" "<<host_mem[i];

	try

	{

  //--| Transfert CPU data to GPU data

  device_mem<<host_mem;

 //--| Test a little computation : (vector+=4)

  cuda_lib::CallKernelFloat(device_mem.GetDeviceMemoryPointer(),device_mem.GetSize());

 //--| Transfert GPU data to CPU data

  device_mem>>host_mem;

 //--| Display the result :

  cout<<endl;

  for(int i=0;i<10;++i)

  cout<<" "<<host_mem[i];

	}

	catch(exception & e)

	{

  cout<<endl<<"Exception : "<< e.what()<<endl;

  int i=0; cin>>i;

	}

	cuda_lib::CloseCudaLibrary();

If you want take a look (attachments or link) :

go on : THe example code

I wait all your comment and some help to manage with succes a CPP framework to use texture (I have done some test but without success).

:w00t: Enjoy it.

I have try to respect cuda style (note the << and >> operator for the memory transfert)
Cuda.zip (24 KB)

NICE

Can’t believe I haven’t come across this before. That syntax looks very nice and Boost-like.

Any news of the project?

If you are interestes in something similar. We are developing a CUDA Template library at our institute. Everybody is welcome to share some ideas and collaborate. Therefore we started a SF project:
https://sourceforge.net/projects/cudatemplates

Best Regards,
Manuel Werlberger

https://sourceforge.net/projects/cudatemplates?abmode=1

The cudatemplate URL gets redirected to URL above and says “Invalid project”

ok? It doesn’t do that for me??

Manuel

Invalid project for me too :( Looks like interesting work!

Ok. Strange.

You can go to http://www.gpu4vision.org . In the download section there is a link to the CUDA templates which links towards SF.

Also a search for cuda in SF brings up the link http://sourceforge.net/projects/cudatemplates/

If it still does not work, please post here again.

Best regards,
Manuel