为什么我得到 "dynamic initialization is not supported for a __constant__ variable"?

Why I am getting "dynamic initialization is not supported for a __constant__ variable"?

我有以下结构:

enum BoundSide { right, left, top, bottom, back, front };

template<typename T, size_t D>
using vec = array<T,D>;

//fpr short and static Vector Fields like c_i
template<typename T, size_t D, size_t Q>
using vec_set = vec<vec<T, D>, Q>;

template<typename T, size_t D>
struct VELOCITY_BOUND_DEV;

template<typename T>
struct VELOCITY_BOUND_DEV<T, 2>
{
  BoundSide side;
  int center{};
  int width{};
  T u_w;        //velocity
};


template<typename T, int D, int Q>
struct SimDomain_dev 
{
  vec_set<T, D, Q> c;       //discrete velocity-set
  vec<T, Q> w;          //discrete weights
  vec<grid_size_t, D> gridDim_L;

  VELOCITY_BOUND_DEV<T, D> bound;
}

我这样声明了一个 __constant__ 变量:

template<typename T, int D, int Q>
__constant__ SimDomain_dev<T, D, Q> sd_dev;

然后我将数据从临时主机变量复制到设备变量,如下所示:

 cudaMemcpyToSymbol(sd_dev<T, D, SimDomain<T, D>::Q>, &sd_temp,0, sizeof(SimDomain_dev<T,D, SimDomain<T, D>::Q>))

vecvec_set中的Class数组是一个容器-class,它在设备端工作(有效)。

那么,为什么我会收到错误消息“__constant__ 变量不支持动态初始化”?

int center{};
int width{};

初始化centerwidth,另外,根据vecvec_set的定义方式,它们可能有自己的构造函数。