Cuda 3.0 problems: structs and context from type Upgraded to Cuda 3.0 from 3.0beta and problems appe


I just updated from 3.0beta to 3.0 and now face two problems:

  1. I get an error message of CL_INVALID_ARG_SIZE in my program for passing a structure to the kernel. The struct is defined as:

GPU side
typedef struct{
float t,dt,tout,tmax,tstep;
int nstep;

CPU side
typedef struct{
cl_float t,dt,tout,tmax,tstep;
cl_int nstep;

I set the 0th kernel argument as:

cl_stepData stepData; // defined globally in the class

clSetKernelArg(my_kernel, 0, sizeof(cl_stepData), (void*)&stepDataCL);

What did I do wrong? It worked fine with 3.0beta…

  1. In my “Cuda 3.0beta version” of my program I used clCreateContextFromType to create my context. In 3.0, I get an error stating that there are not devices of the specified type (CL_DEVICE_TYPE_GPU). It also worked in Cuda 3.0beta. I changed the code to use clCreateContext instead and I now get no error in this part of the program. Any idea why clCreateContextFromType does not seem to work in Cuda 3.0?

Best Regards,

Hi again!

I tried to replace the new display driver (195.36.15) with the old one from cuda 3.0beta1 (195.17-beta) and my program runs fine. Very strange!

Best Regards,


for your ‘clCreateContextFromType’ you have now to pass information about your platform (see release note of 3.0 version). like this:


cl_platform_id platforms[3];

unsigned int numPlatforms;

    ciErrNum = clGetPlatformIDs(3,platforms,&numPlatforms);

if (ciErrNum != CL_SUCCESS)


	std::cerr << "Error " << ciErrNum << " :int clGetPlatformIDs call !!!\n" << std::endl;

	return -1;


cl_context_properties properties[] = { CL_CONTEXT_PLATFORM, (intptr_t)platforms[0], 0 };

hContext = clCreateContextFromType(properties, CL_DEVICE_TYPE_GPU, 0, 0, &ciErrNum);

if (ciErrNum != CL_SUCCESS)


	std::cerr << "Error " << ciErrNum << " : Failed to create OpenCL context!\n" << std::endl;

	return -1;


After, I have an error when i try to pass a kernel argument witch type is a struct… (error -51: CL_INVALID_ARG_SIZE)

[codebox]typedef struct


cl_double ah2o, nh2o;

cl_double ao3,  no3; 

cl_double ao2,  no2,  po2;

cl_double aco2, nco2, pco2;

cl_double ach4, nch4, pch4;

cl_double ano2, nno2, pno2;

cl_double aco,  nco,  pco;

cl_double a0u, a1u, a2u ;

cl_double a0s, a1s, a2s, a3s;

cl_double a0T, a1T, a2T, a3T;

cl_double taur,sr;

cl_double a0taup, a1taup ;

cl_double wo, gc;

cl_double a0P,a1P,a2P,a3P;

cl_double a4P,a5P;

cl_double Resa1,Resa2;

cl_double Resa3,Resa4;

cl_double Resr1, Resr2, Resr3;

cl_double Rest1,Rest2;

cl_double Rest3,Rest4;

} cl_coef_atmos ;

typedef struct {

cl_float tetas;

cl_float tetav;

cl_float phis;

cl_float phiv;

cl_float uh2o;

cl_float uo3;

cl_float taup550;

cl_float pression;

cl_float taup;

cl_float ra;

cl_float tg;

cl_float ttetas;

cl_float ttetav;

cl_float s;

cl_coef_atmos *ca;

} cl_smac_param;

clSetKernelArg(hKernel, 3, sizeof(smac_param), (void *)&smac);[/codebox]

If someone have an idea…


Thanks! I never read the release notes, nice somebody does… ;)

I also get the error when passing a struct to a kernel and would very much like to know why it does not work anymore.

Hi again!

Did you ever solve this problem? I didn’t and would still like to hear a solution…

Yes, I use a buffer to transfert my structure to the GPU memory.

But I have a problem when I try to use a structure which include a pointer to another structure…