I’m trying use pointer to a struct in shared memory but I don’t know how to setting memory size for each block since their size differ between blocks, something like:
struct reg{
int *val;
int sizeval;
};
__shared__ reg data;
__global__ void kernel1(){
//initialize data for each block
}
__global__ void kernel2(){
//use same data pointer here but when I try use *val gets memory error
}
int main(){
kernel1<<< nblocks, nthreads >>>();
kernel2<<< nblocks, nthreads >>>(); //here I need the size of shared memory to data
//but how can pass size per block?
}
There is a way to pass different size to shared memory or allocate data as static in kernel1() and use same variable in kernel2()?