__constant__ memory qualifier problem 1>cuda_code.cu(20): error: memory qualif

Hi All,

Hope someone can help, got a strange annoying error that just appearing, was working earlier, but not anymore after making some changes to some classes.

1>cuda_code.cu(20): error: memory qualifier on data member is not allowed

Here’s the relevant code:

#include "Normal.cuh"

#include "World.cuh"

__constant__ Camera cam;

Camera class:

#ifndef __CAMERA__

#define __CAMERA__

struct Camera{


  Point3D lookat, eye;

  float  ra;

  Vector3D  u, v, w;

  Vector3D  up;

  float   exposure_time;

  float  d, zoom;


	__device__ void set_d(const float d2)


  d = d2;


	__device__ void set_zoom(const float zoom2)


  zoom = zoom2;


	__device__ void set_eye(const float x, const float y, const float z)


  eye.x = x; eye.y = y; eye.z = z;



Don’t know if this is the problem, but I tried removing it and error still occurs.

class World{

	ViewPlane    vp;

	RGBColour    background_color;

	vector<Sphere*>	objects;	

	Camera*    	camera_ptr;

Anyone has a similar error or knows why this might be happening?

Thanks in advance,



What are the Point3 and Vector3 objects like?


Here’s the code for the Point and Vector structs:

#ifndef __POINT3D__

#define __POINT3D__

struct Point3D {

    struct { float x, y, z; };

    __device__ Point3D() {}

    __device__ Point3D(const float a, const float b, const float c) : x(a), y(b), z(c) {}

    __device__ Point3D operator+(const Point3D rhs) const { return Point3D(x+rhs.x, y+rhs.y, z+rhs.z); }

    __device__ Vector3D operator-(const Point3D rhs) const { return Vector3D(x-rhs.x, y-rhs.y, z-rhs.z); }

    __device__ Point3D operator+(const float rhs) const { return Point3D(x+rhs, y+rhs, z+rhs); }

    __device__ Point3D operator-(const float rhs) const { return Point3D(x-rhs, y-rhs, z-rhs); }

    __device__ Point3D operator*(const float rhs) const { return Point3D(x*rhs, y*rhs, z*rhs); }

    __device__ Point3D operator/(const float rhs) const { return Point3D(x/rhs, y/rhs, z/rhs); }

  __device__ _inline Point3D operator+ (const Vector3D& v) const 


  	return (Point3D(x + v.x, y + v.y, z + v.z));


  __device__ float   d_squared(const Point3D& p) const 


  	return ((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y)	+	(z - p.z) * (z - p.z));


  __device__ float   distance(const Point3D& p) const 


  	return (sqrt((x - p.x) * (x - p.x)+ (y - p.y) * (y - p.y)+	(z - p.z) * (z - p.z)));




#ifndef __VECTOR3D__

#define __VECTOR3D__

struct Vector3D {

	struct{float x,y,z;};

    __device__ Vector3D() {}

    __device__ Vector3D(const float a, const float b, const float c) : x(a), y(b), z(c) {}

    __device__ Vector3D(const float a) : x(a), y(a), z(a) {}

  __device__ Vector3D operator=(const Vector3D &v) const { return Vector3D(v.x,v.y,v.z); }

    __device__ Vector3D operator+(const Vector3D &v) const { return Vector3D(x+v.x,y+v.y,z+v.z); }

    __device__ Vector3D operator-(const Vector3D &v) const { return Vector3D(x-v.x,y-v.y,z-v.z); }

    __device__ Vector3D operator-() const { return Vector3D(-x,-y,-z); }

    __device__ Vector3D operator*(const float d) const { return Vector3D(x*d,y*d,z*d); }

    __device__ Vector3D operator^(const Vector3D &v) const { return Vector3D(y*v.z-z*v.y,z*v.x-x*v.z,x*v.y-y*v.x); }

  __device__ float operator* (const Vector3D& v) const 


  	return (x * v.x + y * v.y + z * v.z);


  __device__ Vector3D operator/ (const double a) const 


  	return (Vector3D(x / a, y / a, z / a));	



    __device__ Vector3D normalize() const { return *this * (1.f/sqrtf(magsqr())); }

    __device__ float norm() const { return sqrtf(magsqr()); }

    __device__ float dot(const Vector3D &v) const { return x*v.x+y*v.y+z*v.z; }

    __device__ float magsqr() const { return dot(*this); }


__device__ Vector3D operator* (const double a, const Vector3D& v) 


	return (Vector3D(a * v.x, a * v.y, a * v.z));	




Fixed it, did some noobish things like declaring classes instead of structs in the cuda code and some other syntactical errors lol

:D it’s good that it’s fixed

CUDA has broke my back a few times, we’re the karate kids of disciplined code now …