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).
External Image Enjoy it.
I have try to respect cuda style (note the << and >> operator for the memory transfert)
Cuda.zip (24 KB)