CL_INVALID_ARG_SIZE When using Custom Types

Hello:)

I’ve got a CL_INVALID_ARG_SIZE when trying to call clSetKernel for a custom type, here is what I’m doing:

cl_mem currentList = clCreateBuffer(context, CL_MEM_READ_ONLY, sizeof(Event) * 1100, NULL, &err);

and then:

err= clSetKernelArg(kernel, 2,sizeof(cl_mem), (void*)&currentList);

Here my GPU Side strct as well as CPU Side:

typedef struct Event {

	int time;

	short origId;

	int out; 

	short dirty; 

}Event;
typedef struct Event {

				cl_int time;

	cl_short origId;

	cl_int out;

	cl_short dirty;

}Event;

Thank you for your help

It may be a problem related to memory alignment: http://en.wikipedia.org/wiki/Data_structur…_structs_on_x86

Try a structure like this:

typedef struct Event {

	int time;

	int out;

	short origId;

	short dirty; 

}Event;

Thank you for warning me about memory alignment, I didn’t remenber it at all:\ Looking for NVIDIA Guide I saw how to make the right alignment for performance purposes. But in this case, the problem was me… I was totally dumb…because I changed the kernel function, but I’ve forgotten to change Kernel name in CPU side… So it accepted some arguments because they were the same, but others not and then I was trying to pass an Array to an integer… Of course I got a INVALID_ARGS_SIZE… now everything makes sense.

Thanks for your help:) Hope that it could help some people that made the same mistake.