How to use shared memory between kernel call of CUDA?

后端 未结 3 812
眼角桃花
眼角桃花 2021-01-24 09:43

I want to use shared memory between kernel call of one kernel. Can I use shared memory between kernel call?

相关标签:
3条回答
  • 2021-01-24 10:11

    No, you can't. Shared memory has thread block life-cycle. A variable stored in it can be accessible by all the threads belonging to one group during one __global__ function invocation.

    0 讨论(0)
  • 2021-01-24 10:23

    Take a try of page-locked memory, but the speed should be much slower than graphic memory. cudaHostAlloc (void **ptr, size_t size, cudaHostAllocMapped); then send the ptr to the kernel code.

    0 讨论(0)
  • 2021-01-24 10:28

    Previously you could do it in a non-standard way where you would have a unique id for each shared memory block and the next kernel would check the id and therefore carry out required processing on this shared memory block. This was hard to implement as you needed to ensure full occupancy for each kernel and deal with various corner cases. In addition, without formal support you coulf not rely on compatibility across compute device and cuda versions.

    0 讨论(0)
提交回复
热议问题