If I remove -shared I get this:
# mpicxx \-std=c\+\+11 \-D\_\_CUDA\_ARCH\_\_=350 \-E \-x c\+\+ \-DCUDA\_DOUBLE\_MATH\_FUNCTIONS \-\-std=c\+\+11 \-fopenmp \-O3 \-D\_\_CUDA\_PREC\_DIV \-D\_\_CUDA\_PREC\_SQRT \-I"\.\./\.\./lib/kokkos/core/src" \-I"\.\./\.\./lib/kokkos/containers/src" \-I"\.\./\.\./lib/kokkos/algorithms/src" \-I"\.\./\.\./lib/kokkos/linalg/src" \-I"\.\./" "\-I/opt/cuda\-7\.0/bin/\.\.//include" \-m64 \-g \-gdwarf\-2 "/tmp/tmpxft\_0001ae4d\_00000000\-4\_kokkos\_depend\.cudafe1\.cpp" > "/tmp/tmpxft\_0001ae4d\_00000000\-14\_kokkos\_depend\.ii" \# mpicxx -std=c++11 -c -x c++ --std=c++11 -fopenmp -O3
-I"../../lib/kokkos/core/src" -I"../../lib/kokkos/containers/src"
-I"../../lib/kokkos/algorithms/src" -I"../../lib/kokkos/linalg/src"
-I"../" "-I/opt/cuda-7.0/bin/..//include" -fpreprocessed -m64 -g
-gdwarf-2 -o "kokkos_depend.o"
"/tmp/tmpxft_0001ae4d_00000000-14_kokkos_depend.ii"
/usr/local/bin/ld: -f may not be used without -shared
collect2: error: ld returned 1 exit statuswhich is why I tried adding it.
which doesn't make sense. so the problem is something else. so you
have to ask yourself, why is ld complaining about a -f flag? or rather
what other flag, starts with -f. this requires a little digging, but
as it turns out, the problem is that when you compile with mpicxx, the
KOKKOS settings will divert *all* code to be compiled with nvcc and
then have nvcc pass the C++ code to the underlying gcc. however, since
nvcc is derived from the open64 compiler, it requires a different
syntax for compiler flags than gcc. the ultimate culprit is that
KOKKOS by default compiles with OpenMP enabled (together with CUDA)
and that puts the -fopenmp flag into the command line. for individual
file compilations, this is protected by -Xcompiler, but for the linker
it is not. hence the error message.\
thus the proper solution is the following change.
diff --git a/lib/kokkos/Makefile.lammps b/lib/kokkos/Makefile.lammps
index dd2af5c..00b55f4 100755
--- a/lib/kokkos/Makefile.lammps
+++ b/lib/kokkos/Makefile.lammps
@@ -111,11 +111,12 @@ SRC_KOKKOS += \(wildcard
(KOKKOS_PATH)/core/src/OpenMP/*.cpp)
KOKKOS_HEADERS += \(wildcard (KOKKOS_PATH)/core/src/OpenMP/*.hpp)
ifeq ($(CUDA), yes)
KOKKOS_INC += -Xcompiler -fopenmp
+KOKKOS_LINK += -Xcompiler -fopenmp
else
KOKKOS_INC += -fopenmp
-endif
KOKKOS_LINK += -fopenmp
endif
+endif
ifeq (\(HWLOC\),yes\) KOKKOS\_INC \+= \-DKOKKOS\_HAVE\_HWLOC \-I(HWLOC_PATH)/include
or to use OMP=no when compiling with CUDA=yes
axel.