Hi,
I have a struct I get an "invalid memory object" (-38) error code when I try to set a device vector containing this struct type as kernel argument.
//test.h
struct myTestStruct
{
float dhv;
float dinvv;
};
//in global scope
BOOST_COMPUTE_ADAPT_STRUCT(myTestStruct,myTestStruct,(dhv,dinvv))
//other.cpp
//kernel
const char kernel
_cl[] = BOOST_COMPUTE_STRINGIZE_SOURCE(__kernel void test(const
__global myTestStruct* input){});
//host code
compute::vector<myTestStruct> arr(1);
compute::type_definition<myTestStruct>() + "\n" + kernel
_cl
;
//then I am building the program and create a corresponding kernel
{...}
kernel.set_arg(0,arr); //ERRORCODE: -38; invalid memory object
Am I doing anything wrong?
Strangely though, I have another struct that I am adapting in the same way and am passing as a kernel argument inside a vector as well, and for that one I don't get any error. That struct contains float and int members only (about 20).
That vector also contains a lot more entries than just 1 but otherwise I am using the exact same procedure.
I am not sure why it works for one struct but not the other.
Btw. this is the cl program code built (grabbed via debugging) and passed as kernel constructor argument:
typedef struct __attribute__((packed)) {
float dhv;
float dinvv;
} myTestStruct;
__kernel void test(const __global myTestStruct* input) { }
Looks fine to me. Any ideas? :-/
Thanks
P.S.: I tried to use boost::compute::float_ as member types too (and some other vector datatypes like boost::compute::float2_) but with the same outcome.