與cuda 3.5兼容的舊源代碼與新的cuda版本不兼容,例如, 7.5。例如,將舊的cuda代碼移植到7.5
cuda_runtime_api.cc: In function ‘cudaError_t cudaMemcpyToSymbol(const char*, const void*, size_t, size_t, cudaMemcpyKind)’:
cuda_runtime_api.cc:556:141: error: declaration of C function ‘cudaError_t cudaMemcpyToSymbol(const char*, const void*, size_t, size_t, cudaMemcpyKind)’ conflicts with
__host__ cudaError_t CUDARTAPI cudaMemcpyToSymbol(const char *symbol, const void *src, size_t count, size_t offset, enum cudaMemcpyKind kind)
^
In file included from cuda_runtime_api.cc:155:0:
/usr/local/cuda/include/cuda_runtime_api.h:4335:39: error: previous declaration ‘cudaError_t cudaMemcpyToSymbol(const void*, const void*, size_t, size_t, cudaMemcpyKind)’ here
extern __host__ cudaError_t CUDARTAPI cudaMemcpyToSymbol(const void *symbol, const void *src, size_t count, size_t offset __dv(0), enum cudaMemcpyKind kind __dv(cudaMemcpyHostToDevice));
所以說,代碼中的cudaMemcpyToSymbol()與7.5實現不兼容。源代碼是
__host__ cudaError_t CUDARTAPI cudaMemcpyToSymbol(const char *symbol, const void *src, size_t count, size_t offset, enum cudaMemcpyKind kind)
{....}
和7.5版本的/usr/local/cuda/include/cuda_runtime_api.h是
extern __host__ cudaError_t CUDARTAPI cudaMemcpyToSymbol(const void *symbol, const void *src, size_t count, size_t offset __dv(0), enum cudaMemcpyKind kind __dv(cudaMemcpyHostToDevice));
我該如何解決呢?
更新:錯誤文件中的cuda_runtime_api.cc
指向用戶定義的錯誤文件here。
[email protected]:~/gem5-gpu/benchmarks/libcuda$ g++ -std=c++0x -O3 -g -Wall -fPIC -DCUDART_VERSION=7050 -I./ -I/usr/local/cuda/include -I../../gem5/util/m5 -c cuda_runtime_api.cc -o cuda_runtime_api.o
cuda_runtime_api.cc: In function ‘cudaError_t cudaMemcpyToSymbol(const char*, const void*, size_t, size_t, cudaMemcpyKind)’:
cuda_runtime_api.cc:556:143: error: declaration of C function ‘cudaError_t cudaMemcpyToSymbol(const char*, const void*, size_t, size_t, cudaMemcpyKind)’ conflicts with
__host__ cudaError_t CUDARTAPI cudaMemcpyToSymbol(const char *symbol, const void *src, size_t count, size_t offset , enum cudaMemcpyKind kind)
^
In file included from cuda_runtime_api.cc:155:0:
/usr/local/cuda/include/cuda_runtime_api.h:4335:39: error: previous declaration ‘cudaError_t cudaMemcpyToSymbol(const void*, const void*, size_t, size_t, cudaMemcpyKind)’ here
extern __host__ cudaError_t CUDARTAPI cudaMemcpyToSymbol(const void *symbol, const void *src, size_t count, size_t offset __dv(0), enum cudaMemcpyKind kind __dv(cudaMemcpyHostToDevice));
^
而是提供在ASCII符號的名稱,只需通過符號本身。 –
對不起,我不明白。如果你的意思是我必須將'const char * symbol'改爲'const void * symbol',那麼這不起作用 – mahmood
而不是通過\t「a」,只需傳遞'a'即可。 –