【发布时间】:2015-01-18 10:41:30
【问题描述】:
我不明白为什么在编译我的代码时会收到错误 dynamic initialization is not supported for __device__, __constant__, __shared__ variables。
我的代码看起来像
wrapper.cu
#include "../Params.hpp"
__constant__ Params cparams;
void wrapperFunction(uint& a)
{
Params ab;
a = 20;
}
Params.hpp
#include "Utils.hpp"
typedef struct Params
{
vectorTypef a;
} Params;
Utils.hpp
#include "Vec2.hpp"
typedef unsigned int uint;
typedef Vec2<float> vectorTypef;
Vec2.hpp
template <typename T>
class Vec2
{
public:
Vec2(){ x = 0.0; y = 0.0;}
T x, y;
};
使用命令使用 cmake 构建
CUDA_ADD_EXECUTABLE(test main.cpp cudasrc/wrapper.cu
【问题讨论】: