Hi,
I have 2 ways to create a method to get back a result... but which one is the best, in term of memory and performance ?
MyData t;
myFunction(&t);
void myFunction(MyData* data) { .... data.val = 10; ... }
or
MyData t = myFunction();
MyData myFunction() { MyData data; data.val = 10; return data; }
By example, in the first version, I think that we avoid the creation of 2 MyData, but it really depend of the compiler optimization.
viewon01,
AFAIK,the functions are inlined in openCL.Therefore its better to have smaller functions.The second method would create a variable everytime it is called,so more memory cycles are needed.Also code length increases largely if myfunc is called many times.
Thanks
So, if everything is inlined, maybe it is better to use this version ?
And use reference and not pointers ?
MyData t;
myFunction(t);
void myFunction(MyData& data) { .... data.val = 10; ... }
hi viewon01,
AFAIK references should not be available im openCL.And the code do not build on my system.
😞
It should be a good way to optimize the code. Except if the compiler is really good it alread avoid to create a pointer and directly use the 'memory block' !
Yes.But it is not mentioned in the spec.and hence the implementor is not forced to provide this functionality.