CUDA C++ Linking error undefined reference threadIdx.x -


hello trying parallelize lattice boltzmann solver on cuda. somehow getting error while linking object files together. objects compiles without error.

lbmsolver.o: in function >lbmsolver::calcmoments_gpu(lbmuniformgrid2d::lbmgridnode**, int)': tmpxft_00004b33_00000000-3_lbmsolver.cudafe1.cpp:(.text+0x939): undefined >reference toblockdim' tmpxft_00004b33_00000000-3_lbmsolver.cudafe1.cpp:(.text+0x93f): undefined >reference blockidx' tmpxft_00004b33_00000000-3_lbmsolver.cudafe1.cpp:(.text+0x948): undefined >reference tothreadidx' tmpxft_00004b33_00000000-3_lbmsolver.cudafe1.cpp:(.text+0x953): undefined >reference blockdim' tmpxft_00004b33_00000000-3_lbmsolver.cudafe1.cpp:(.text+0x959): undefined >reference toblockidx' tmpxft_00004b33_00000000-3_lbmsolver.cudafe1.cpp:(.text+0x962): undefined >reference `threadidx'

here makefile:

objs = main.o lbmsolver.o lbmuniformgrid2d.o lbmboundaryconditions.o   writevtk.o cc = g++ nvcc = nvcc cflags = -wall -c  lflags = -wall xcompiler = -xcompiler "-wall" nvcflags = -c -g -g -ccbin=$(cc) $(xcompiler) nvlflags = -g -g -ccbin=$(cc) $(xcompiler)   main : $(objs)     $(nvcc) $(nvlflags) $(objs) -o main   main.o : main.cu lbmsolver.h writevtk.h     $(nvcc) $(nvcflags) main.cu  lbmsolver.o : lbmsolver.cu lbmsolver.h lbmuniformgrid2d.h lbmboundaryconditions.h     $(nvcc) $(nvcflags) lbmsolver.cu  lbmboundaryconditions.o : lbmboundaryconditions.cu lbmboundaryconditions.h lbmsolver.h     $(nvcc) $(nvcflags) lbmboundaryconditions.cu  lbmuniformgrid2d.o : lbmuniformgrid2d.cpp lbmuniformgrid2d.h     $(cc) $(cflags) lbmuniformgrid2d.cpp  writevtk.o : writevtk.h writevtk.cpp     $(cc) $(cflags) writevtk.cpp  clean_obj:      \rm *.o main 

function , headerfile gives error:

#pragma once #include "lbmuniformgrid2d.h" #include <cuda.h>  #ifdef __cudacc__ #define cuda_hostdev __host__ __device__ #else #define cuda_hostdev #endif  class lbmsolver{ ... cuda_hostdev void calcmoments_gpu(lbmuniformgrid2d::lbmgridnode **field, int nx);  __host__ __device__ void lbmsolver::calcmoments_gpu(lbmuniformgrid2d::lbmgridnode **field, int nx){     int x = blockdim.x * blockidx.x + threadidx.x;     int y = blockdim.y * blockidx.y + threadidx.y;      lbmuniformgrid2d::lbmgridnode *node;     node = field[x+y*nx];     calc_rho_gpu(node);     calc_ux_gpu(node);     calc_uy_gpu(node);     calc_v_gpu(node); } 

you cannot define function containing device code __host__, because device specific features not supported in host code. remove , things compile correctly.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -