kokkos / kokkos-tutorials

Tutorials for the Kokkos C++ Performance Portability Programming Ecosystem
https://kokkos.org
Other
298 stars 100 forks source link

Clang compile failure without `__host__ __device__` #98

Closed PhilipDeegan closed 5 months ago

PhilipDeegan commented 5 months ago

https://github.com/kokkos/kokkos-tutorials/blob/c181dd5839c20db34cde178f9921281afa789ab9/Exercises/tools_minimd/neighbor.cpp#L844

[2/3] Building CXX object CMakeFiles/miniMD.dir/neighbor.cpp.o
FAILED: CMakeFiles/miniMD.dir/neighbor.cpp.o 
/usr/bin/clang++-18 -DKOKKOS_DEPENDENCE -I/io/kokkos-tutorials/Exercises/tools_minimd/build/_deps/kokkos-build -I/io/kokkos-tutorials/Exercises/tools_minimd/build/_deps/kokkos-build/core/src -I/io/kokkos-tutorials/Exercises/tools_minimd/build/dep/kokkos/core/src -I/io/kokkos-tutorials/Exercises/tools_minimd/build/dep/kokkos/core/src/../../tpls/desul/include -I/io/kokkos-tutorials/Exercises/tools_minimd/build/_deps/kokkos-build/containers/src -I/io/kokkos-tutorials/Exercises/tools_minimd/build/dep/kokkos/containers/src -I/io/kokkos-tutorials/Exercises/tools_minimd/build/_deps/kokkos-build/algorithms/src -I/io/kokkos-tutorials/Exercises/tools_minimd/build/dep/kokkos/algorithms/src -I/io/kokkos-tutorials/Exercises/tools_minimd/build/_deps/kokkos-build/simd/src -I/io/kokkos-tutorials/Exercises/tools_minimd/build/dep/kokkos/simd/src -I/io/kokkos-tutorials/Exercises/tools_minimd/MPI-Stubs -isystem /usr/local/cuda/include -O2 -g -DNDEBUG -x cuda --cuda-gpu-arch=sm_80 -MD -MT CMakeFiles/miniMD.dir/neighbor.cpp.o -MF CMakeFiles/miniMD.dir/neighbor.cpp.o.d -o CMakeFiles/miniMD.dir/neighbor.cpp.o -c /io/kokkos-tutorials/Exercises/tools_minimd/neighbor.cpp
/io/kokkos-tutorials/Exercises/tools_minimd/neighbor.cpp:844:21: error: __host__ function 'bindist' cannot overload __host__ __device__ function 'bindist'
  844 | MMD_float Neighbor::bindist(int i, int j, int k) // __host__ __device__
      |                     ^
/io/kokkos-tutorials/Exercises/tools_minimd/neighbor.h:134:15: note: previous declaration is here
  134 |     MMD_float bindist(int, int, int);   // distance between binx
      |               ^
1 error generated when compiling for sm_80.
masterleinad commented 5 months ago

@PhilipDeegan Are you willing to fix this?

PhilipDeegan commented 5 months ago

yes, but I tried the same macro as on the header definition, but it doesn't work, is there another macro?

PhilipDeegan commented 5 months ago

KOKKOS_FUNCTION works

masterleinad commented 5 months ago

KOKKOS_INLINE_FUNCTION shouldn't be used if the implementation is in a *.cpp file anyway.