close

參考 http://devblogs.nvidia.com/parallelforall/using-shared-memory-cuda-cc/

關於更多shared memory的用法請參考上述網址

 

這裡針對在compile time還不知道需要宣告的shared memory大小時如何寫

在kernel function中

宣告shared memory的前面加上extern 

(關於extern的說明,請參考http://openhome.cc/Gossip/CGossip/Scope.html  )

如:

 extern __shared__ float tmpLine[];

 

在host 中呼叫此kernel function時,除了原本的 grid size, block size外

須加上第三個變數

如:

computeByRow <<< gridSize,blockSize,sizeOfSharedMemory >>> (...);

(sizeOfSharedMemory需指定資料型態,如sizeof(float)*N)

 

 

arrow
arrow
    文章標籤
    cuda shared memory dynamic
    全站熱搜

    holmes310524 發表在 痞客邦 留言(0) 人氣()