Hi all!
I’m trying to use C operator in my cuda-function.
extern "C"
struct Tensor2Gen
{
double a[9];
Tensor2Gen& operator=(short i)
{
for (int i=0; i<9; i++) a[i] = i;
return *this;
}; //strange error occures here
...
Here is cuda-function:
__device__ void cudaClearValues(Particle &p){
...
//p.tDeformation = 0; //Tensor2Gen field. In this way function doesn't work
for (int i=0; i<9; i++)
p.tDeformation.a[i] = 0; //this way is acceptable :)
...
How can I solve my problem? I’m going to use lots of operators in the future.
Try following code
extern "C"
struct Tensor2Gen{
double a[9];
__device__ __host__ Tensor2Gen& operator=(short i)
{
for (int i=0; i<9; i++) a[i] = i;
return *this;
}; //strange error occures here...
};
I tried that, but catch the following:
...MyTensor.hpp(85) : error C2146: syntax error : missing ';' before identifier '__host__'
...MyTensor.hpp(85) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
...MyTensor.hpp(85) : error C2146: syntax error : missing ';' before identifier 'Tensor2Gen'
...MyTensor.hpp(85) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
By the way, I didn’t change extension of the file(Not sure if it matters).
It seems that I solved problem by including
#include <cuda_runtime.h>