In the past the small CUDA demonstrations I have built have been reworkings of the cppIntegration project.
I have recently updated the CUDA runtimes libraries and include files and the new cppIntegration project works fine.
However there is a problem when I create my own “.cu” source file containing just the code for the host side, not the kernel, however I imagine it might affect that too.
“Expression must have class type”
This is strange seeing as I have included the directories of the “inc” folder and getting desperate I added all directories of the “vector_types.h” file.
I know that the inclusion of the vector types header file is the problem because it wont let me access .x property of a float3 type.
i then found out that cutil_inline.h doesn’t work either…
[codebox]
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <vector_types.h>
#include <windows.h>
#include <actual_kernel.cu>
#include <cutil_inline.h>
using namespace std;
//global void randompos_kernel(float3* devicevbodata, float pos1, float pos2, float pos3)//the actual kernel, ignore this bit
extern “C” void launch_kernel(float3* myvbodata)
{
float3* devicevbo;
cudaMalloc((void **) &devicevbo, sizeof(float3));
cudaMemcpy(devicevbo, myvbodata, sizeof(float3), cudaMemcpyHostToDevice);
cout << "data copied to the GPU" << endl;
cout << devicevbo.x << endl; //** cannot access the .x because the float3 type does not exist in this context so cannot be mapped to the gpu from above...
float pos1 = (float) rand()/RAND_MAX;
float pos2 = (float) rand()/RAND_MAX;
float pos3 = (float) rand()/RAND_MAX;
randompos_kernel<<< 1, 1>>>(devicevbo, pos1, pos2, pos3);
cout << "kernel launched:" << endl; //<< devicevbo[0].x << " " << devicevbo[0].y<< endl;
bool successful = cudaMemcpy(myvbodata, devicevbo, sizeof(float3), cudaMemcpyDeviceToHost);
if (successful != TRUE)
{
cout << "error" << endl;
}
else
{
cout << myvbodata.x << endl;
}
// cout << “we got this far” << endl;
// cout << *myvbo.x << " " << *devicevbo.x << endl;
// cout << *myvbo.y << " " << *devicevbo.y << endl;
// cout << *myvbo.z << " " << *devicevbo.z << endl;
Sleep(100);
cudaFree(devicevbo);
}
[/codebox]
This is frustrating as I thought that the directory inclusion happened automatically and even when I’ve added all directories this STILL fails…
Advice please!