Hello, I have three questions whose answers I couldn’t find on the documentation or the forum.
I read about how I could pass the size of a dynamically allocated array stored in shared memory as a template parameter.
However I need to dynamically allocate two arrays in shared memory with different lengths. How do I go about doing this?
My second question deals with simple structs and whether their member variables are stored in registers or in the local memory. I have a struct with a minimal number of primitive member fields which are used frequently by the kernel. How can I make sure that these fields are stored in registers rather than the slow local memory? Does the “register” keyword do anything? I’ve heard that modern compilers ignore it even in regular c++.
Finally, one of my kernels needs a small array of numbers as an argument. I pass the array through constant memory but my kernel is invoked frequently and the copy to constant memory has quite some overhead. I could also copy the array to global memory but I do not expect the performance to be any different.
Is there any way I can pass the contents of the array “by value” avoiding a memcopy? I can’t put the values in a struct because I don’t know the size of the array a-priori.
I would really appreciate your knowledge on these issues.