How to dynamically allocate arrays inside a kernel?

后端 未结 5 1776
耶瑟儿~
耶瑟儿~ 2020-12-13 00:42

I need to dynamically allocate some arrays inside the kernel function. How can a I do that?

My code is something like that:

__global__ func(float *gr         


        
5条回答
  •  渐次进展
    2020-12-13 01:22

    If the value of n and nn were known before the kernel is called, then why not cudaMalloc the memory on host side and pass in the device memory pointer to the kernel?

提交回复
热议问题