Including glm.hpp inside .cu file with #define GLM_FORCE_CUDA defined before and compiling with nvcc causes compilation error:
glm\glm\detail\_vectorize.hpp(74): error : calling a __host__ function from a __host__ __device__ function is not allowed
I am trying to call glm::dot from inside a kernel:
__global__ void kernel(cudaSurfaceObject_t _surfobj, int max_x, int max_y)
{
int i = threadIdx.x + blockIdx.x * blockDim.x;
int j = threadIdx.y + blockIdx.y * blockDim.y;
if ((i >= max_x) || (j >= max_y)) return;
glm::vec2 uv = { (float(i) / max_x) ,(float(j) / max_y) };
uv.x *= ((float)max_x / (float)max_y);
uv.x = uv.x * 2.f - ((float)max_x / (float)max_y);
uv.y = uv.y * 2.f - 1.f;
glm::vec3 rayDirection(uv.x, uv.y, -1.0f);
glm::vec3 rayOrigin(0.0f, 0.0f, 2.0f);
uchar4 color = { 0,0,0,255 };
float radius = 0.5f;
float a = dot(rayDirection, rayDirection);
float b = 2.0f * dot(rayOrigin, rayDirection);
float c = dot(rayOrigin, rayOrigin) - radius * radius;
float discriminant = b * b - 4.0f * a * c;
if (discriminant < 0.0f)
{
surf2Dwrite(color, _surfobj, i * 4, j);
return;
}
color={255,0,0,255};
surf2Dwrite(color, _surfobj, i * 4, j);
}
If disabling the warning,
Calling glm::dot() or vec3 * vec3 operations inside kernel causes cudaError=700 IllegalAccessError with Nsight debugger pointing to ln74, _vectorize.hpp :
I also get host and device annotation ignore warnings:
warning #20012-D: __host__ annotation is ignored on a function("vec") that is explicitly defaulted on its first declaration
__device__ annotation is ignored on a function("vec") that is explicitly defaulted on its first declaration
and
__device__ annotation is ignored on a function("mat") that is explicitly defaulted on its first declaration
__host__ annotation is ignored on a function("mat") that is explicitly defaulted on its first declaration
GLM: v1.0.1
Visual Studio 2022
Windows 10, GTX 1650
CUDA: v12.0
Including
glm.hpp
inside .cu file with#define GLM_FORCE_CUDA
defined before and compiling with nvcc causes compilation error:glm\glm\detail\_vectorize.hpp(74): error : calling a __host__ function from a __host__ __device__ function is not allowed
inclusion snippet:
I am trying to call glm::dot from inside a kernel:
If disabling the warning, Calling glm::dot() or vec3 * vec3 operations inside kernel causes cudaError=700 IllegalAccessError with Nsight debugger pointing to ln74, _vectorize.hpp :
detailed error output:
I also get host and device annotation ignore warnings:
and
for all types in
detail/
folderPlease help.