I have a cuda project containing the following files
Header File:
Declarations.h
Main File:
main.cpp:
#include "Declarations.h"
And Kernel File:
Kernel.cu:
#include "Declarations.h"
In main.cpp
, I have float K1[3*3]
which I want to copy to GPU constant memory.
To do so, I declared __constant__ float K1_d[3*3];
in Declarations.h
and In main.cpp
I did
checkCudaErrors( cudaMemcpyToSymbol(&K1_d, &K1, 9*sizeof(float)) );
When running the code I got the following error: CUDA error at c:\users\xxx\test.cpp:241 code=13(cudaErrorInvalidSymbol) "cudaMemcpyToSymbol(&K1, &K1_inv, 9*sizeof(float))"
I tried to copy one variable, for example, I declared in the header file
__constant__ float N;
And did:checkCudaErrors( cudaMemcpyToSymbol(&N, &K1_inv[0], sizeof(float)) );
I got the same error message of the macro chechCudaErrors.
How to transer variables to constant memory in CUDA?`