I need to use an array of structs in constant memory for my kernel where the actual size of the array is not known until runtime. As answered in Correct way to use __constant__ memory on CUDA?, I realized that constant memory is allocated during compilation time so the array needs to be declared as:
__constant__ SKY_GRID_TYPE const_patch_grid_lat[5];
where the size is already defined. But because the actual size I need depends on other calculations done during runtime, it seems like I cannot use constant memory.
That answer above suggests instead to use texture memory which it says "can be set dynamically and are cached." However, the data type I need in my memory is an array of struct and according to Structure in Texture memory on CUDA, it seems like texture memory only supports CUDA built in types.
So is there maybe a workaround this? Constant memory would have been perfect for my array of struct but the size is determined dynamically so it doesn't work. Texture memory would have worked but it does not allow anything but CUDA built in types. Is there anything else I could use or some clever way to get around this?