本文介绍了cudaMemcpyToSymbol与cudaMemcpy为什么它仍然在(cudaMemcpyToSymbol)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如其他问题所述,根据链接,您不能再为此函数使用符号名称。现在该功能消失了,什么时候想要使用 cudaMemCpy ?你什么时候想使用它?什么是权衡或利益?

As stated by other questions and according to the link, you can no longer use the symbol name for this function. Now that the feature is gone, when would ever want to use this over cudaMemCpy? When would you ever want to use it at all? What is the tradeoff or benefit?

http://developer.download.nvidia.com/compute/cuda/4_1/rel/toolkit/docs/online/group_CUDART_MEMORY_gf268fa2004636b6926fdcd3189152a14.html

推荐答案

简而言之,因为 cudaMemcpy 作为 cudaMemcpyToSymbol ,无需额外的API调用。考虑一个常数内存数组:

In short, because cudaMemcpy can't do the same thing as cudaMemcpyToSymbol without an additional API call. Consider a constant memory array:

__constant__ float coeffs[8];

要使用 cudaMemcpyToSymbol ,只是做

cudaMemcpyToSymbol(coeffs, hostData, 8*sizeof(float));

要使用 cudaMemcpy

float *dcoeffs;
cudaGetSymbolAddress((void **)&dcoeffs, coeffs);
cudaMemcpy(dcoeffs, hostData, 8*sizeof(float), cudaMemcpyHostToDevice);

直接调用 cudaMemcpy

[标准免责声明:所有使用浏览器编写的代码,无需访问文档或编译器,自行承担风险]

[standard disclaimer: all code written in browser without access to documentation or compiler, use at own risk]

这篇关于cudaMemcpyToSymbol与cudaMemcpy为什么它仍然在(cudaMemcpyToSymbol)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-13 06:47