From c9adfcf2d555d08c434a79f9b217022a6783c171 Mon Sep 17 00:00:00 2001
From: Pietro Incardona <you@example.com>
Date: Sun, 28 Nov 2021 20:40:26 +0100
Subject: [PATCH] Fixing GPU example

---
 example/SparseGrid/1_gray_scott_3d_sparse_gpu/Makefile     | 3 ++-
 example/SparseGrid/2_gray_scott_3d_sparse_gpu_opt/Makefile | 3 ++-
 example/SparseGrid/3_gray_scott_3d_sparse_gpu_cs/Makefile  | 4 +++-
 .../SparseGrid/3_gray_scott_3d_sparse_gpu_cs_opt/Makefile  | 3 ++-
 .../6_gray_scott_3d_sparse_gpu_opt_weak_scal/Makefile      | 4 +++-
 .../7_gray_scott_3d_sparse_gpu_sphere_expanding/Makefile   | 3 ++-
 example/SparseGrid/8_filling_benchmark_gpu/Makefile        | 3 ++-
 example/Vector/3_molecular_dynamic_gpu/Makefile            | 3 ++-
 example/Vector/7_SPH_dlb_gpu/Makefile                      | 3 ++-
 example/Vector/7_SPH_dlb_gpu_more_opt/Makefile             | 6 ++++--
 example/Vector/7_SPH_dlb_gpu_opt/Makefile                  | 3 ++-
 example/Vector/9_gpu_cuda_interop/Makefile                 | 4 +++-
 install                                                    | 7 ++++---
 13 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/example/SparseGrid/1_gray_scott_3d_sparse_gpu/Makefile b/example/SparseGrid/1_gray_scott_3d_sparse_gpu/Makefile
index 584d57a65..980116ccd 100644
--- a/example/SparseGrid/1_gray_scott_3d_sparse_gpu/Makefile
+++ b/example/SparseGrid/1_gray_scott_3d_sparse_gpu/Makefile
@@ -15,12 +15,13 @@ else
                 INCLUDE_PATH_NVCC=
                 CUDA_CC_LINK=mpic++
                 CUDA_OPTIONS=
+		LIBS_SELECT=$(LIBS)
         else
                 CUDA_CC=nvcc -ccbin=mpic++
                 CUDA_CC_LINK=nvcc -ccbin=mpic++
                 CUDA_OPTIONS=-use_fast_math  -arch=sm_61 -lineinfo
+		LIBS_SELECT=$(LIBS_NVCC)
         endif
-        LIBS_SELECT=$(LIBS)
 endif
 
 
diff --git a/example/SparseGrid/2_gray_scott_3d_sparse_gpu_opt/Makefile b/example/SparseGrid/2_gray_scott_3d_sparse_gpu_opt/Makefile
index 7e018d4c1..4650f84db 100644
--- a/example/SparseGrid/2_gray_scott_3d_sparse_gpu_opt/Makefile
+++ b/example/SparseGrid/2_gray_scott_3d_sparse_gpu_opt/Makefile
@@ -15,12 +15,13 @@ else
                 INCLUDE_PATH_NVCC=
                 CUDA_CC_LINK=mpic++
                 CUDA_OPTIONS=
+		LIBS_SELECT=$(LIBS)
         else
                 CUDA_CC=nvcc -ccbin=mpic++
                 CUDA_CC_LINK=nvcc -ccbin=mpic++
                 CUDA_OPTIONS=-use_fast_math  -arch=sm_61 -lineinfo
+		LIBS_SELECT=$(LIBS_NVCC)
         endif
-        LIBS_SELECT=$(LIBS)
 endif
 
 
diff --git a/example/SparseGrid/3_gray_scott_3d_sparse_gpu_cs/Makefile b/example/SparseGrid/3_gray_scott_3d_sparse_gpu_cs/Makefile
index 5fde3c84c..52d3e5efa 100644
--- a/example/SparseGrid/3_gray_scott_3d_sparse_gpu_cs/Makefile
+++ b/example/SparseGrid/3_gray_scott_3d_sparse_gpu_cs/Makefile
@@ -12,9 +12,11 @@ else
         	CUDA_CC=mpic++ -x c++ $(INCLUDE_PATH)
         	INCLUDE_PATH_NVCC=
         	CUDA_CC_LINK=mpic++
+		LIBS_SELECT=$(LIBS)
 	else
         	CUDA_CC=nvcc -ccbin=mpic++
         	CUDA_CC_LINK=nvcc -ccbin=mpic++
+		LIBS_SELECT=$(LIBS_NVCC)
 	endif
 endif
 
@@ -31,7 +33,7 @@ OBJ = main.o
 	$(CUDA_CC) $(OPT) -O3 -g -c --std=c++14 -o $@ $< $(INCLUDE_PATH_NVCC)
 
 gray_scott_sparse_gpu: $(OBJ)
-	$(CUDA_CC_LINK) -o $@ $^ $(LIBS_PATH) $(LIBS)
+	$(CUDA_CC_LINK) -o $@ $^ $(LIBS_PATH) $(LIBS_SELECT)
 
 all: gray_scott_sparse_gpu
 
diff --git a/example/SparseGrid/3_gray_scott_3d_sparse_gpu_cs_opt/Makefile b/example/SparseGrid/3_gray_scott_3d_sparse_gpu_cs_opt/Makefile
index 8cb8a8b16..e5be131c8 100644
--- a/example/SparseGrid/3_gray_scott_3d_sparse_gpu_cs_opt/Makefile
+++ b/example/SparseGrid/3_gray_scott_3d_sparse_gpu_cs_opt/Makefile
@@ -16,12 +16,13 @@ else
                 INCLUDE_PATH_NVCC=
                 CUDA_CC_LINK=mpic++
                 CUDA_OPTIONS=
+		LIBS_SELECT=$(LIBS)
         else
                 CUDA_CC=nvcc -ccbin=mpic++
                 CUDA_CC_LINK=nvcc -ccbin=mpic++
                 CUDA_OPTIONS=-use_fast_math  -arch=sm_61 -lineinfo
+		LIBS_SELECT=$(LIBS_NVCC)
         endif
-        LIBS_SELECT=$(LIBS)
 endif
 
 
diff --git a/example/SparseGrid/6_gray_scott_3d_sparse_gpu_opt_weak_scal/Makefile b/example/SparseGrid/6_gray_scott_3d_sparse_gpu_opt_weak_scal/Makefile
index 25e2b3240..bf5a053d6 100644
--- a/example/SparseGrid/6_gray_scott_3d_sparse_gpu_opt_weak_scal/Makefile
+++ b/example/SparseGrid/6_gray_scott_3d_sparse_gpu_opt_weak_scal/Makefile
@@ -12,9 +12,11 @@ else
         	CUDA_CC=mpic++ -x c++ $(INCLUDE_PATH)
         	INCLUDE_PATH_NVCC=
         	CUDA_CC_LINK=mpic++
+		LIBS_SELECT=$(LIBS)
 	else
         	CUDA_CC=nvcc -ccbin=mpic++
         	CUDA_CC_LINK=nvcc -ccbin=mpic++
+		LIBS_SELECT=$(LIBS_NVCC)
 	endif
 endif
 
@@ -31,7 +33,7 @@ OBJ = main.o
 	$(CUDA_CC) -O3 $(OPT) -g -c --std=c++14 -o $@ $< $(INCLUDE_PATH_NVCC)
 
 gray_scott_sparse_gpu: $(OBJ)
-	$(CUDA_CC_LINK) -o $@ $^ $(LIBS_PATH) $(LIBS)
+	$(CUDA_CC_LINK) -o $@ $^ $(LIBS_PATH) $(LIBS_SELECT)
 
 all: gray_scott_sparse_gpu
 
diff --git a/example/SparseGrid/7_gray_scott_3d_sparse_gpu_sphere_expanding/Makefile b/example/SparseGrid/7_gray_scott_3d_sparse_gpu_sphere_expanding/Makefile
index 8cb8a8b16..e5be131c8 100644
--- a/example/SparseGrid/7_gray_scott_3d_sparse_gpu_sphere_expanding/Makefile
+++ b/example/SparseGrid/7_gray_scott_3d_sparse_gpu_sphere_expanding/Makefile
@@ -16,12 +16,13 @@ else
                 INCLUDE_PATH_NVCC=
                 CUDA_CC_LINK=mpic++
                 CUDA_OPTIONS=
+		LIBS_SELECT=$(LIBS)
         else
                 CUDA_CC=nvcc -ccbin=mpic++
                 CUDA_CC_LINK=nvcc -ccbin=mpic++
                 CUDA_OPTIONS=-use_fast_math  -arch=sm_61 -lineinfo
+		LIBS_SELECT=$(LIBS_NVCC)
         endif
-        LIBS_SELECT=$(LIBS)
 endif
 
 
diff --git a/example/SparseGrid/8_filling_benchmark_gpu/Makefile b/example/SparseGrid/8_filling_benchmark_gpu/Makefile
index 872e123da..d83c4dc78 100644
--- a/example/SparseGrid/8_filling_benchmark_gpu/Makefile
+++ b/example/SparseGrid/8_filling_benchmark_gpu/Makefile
@@ -15,12 +15,13 @@ else
                 INCLUDE_PATH_NVCC=
                 CUDA_CC_LINK=mpic++
                 CUDA_OPTIONS=
+		LIBS_SELECT=$(LIBS)
         else
                 CUDA_CC=nvcc -ccbin=mpic++
                 CUDA_CC_LINK=nvcc -ccbin=mpic++
                 CUDA_OPTIONS=-use_fast_math  -arch=sm_61 -lineinfo
+		LIBS_SELECT=$(LIBS_NVCC)
         endif
-        LIBS_SELECT=$(LIBS)
 endif
 
 
diff --git a/example/Vector/3_molecular_dynamic_gpu/Makefile b/example/Vector/3_molecular_dynamic_gpu/Makefile
index 09de80fcb..6eaa07254 100644
--- a/example/Vector/3_molecular_dynamic_gpu/Makefile
+++ b/example/Vector/3_molecular_dynamic_gpu/Makefile
@@ -14,11 +14,12 @@ else
         	CUDA_CC=mpic++ -x c++ $(INCLUDE_PATH)
         	INCLUDE_PATH_NVCC=
        		CUDA_CC_LINK=mpic++
+		LIBS_SELECT=$(LIBS)
 	else
         	CUDA_CC=nvcc -ccbin=mpic++
         	CUDA_CC_LINK=nvcc -ccbin=mpic++
+		LIBS_SELECT=$(LIBS_NVCC)
 	endif
-	LIBS_SELECT=$(LIBS)
 endif
 
 CC=mpic++
diff --git a/example/Vector/7_SPH_dlb_gpu/Makefile b/example/Vector/7_SPH_dlb_gpu/Makefile
index 5b81687f4..f08386940 100644
--- a/example/Vector/7_SPH_dlb_gpu/Makefile
+++ b/example/Vector/7_SPH_dlb_gpu/Makefile
@@ -24,11 +24,12 @@ else
                 	CUDA_CC=mpic++ -x c++ $(INCLUDE_PATH)
                 	INCLUDE_PATH_NVCC=
                 	CUDA_CC_LINK=mpic++
+			LIBS_SELECT=$(LIBS)
         	else
                 	CUDA_CC=nvcc -ccbin=mpic++
                 	CUDA_CC_LINK=nvcc -ccbin=mpic++
+			LIBS_SELECT=$(LIBS_NVCC)
         	endif
-		LIBS_SELECT=$(LIBS)
 	endif
 endif
 
diff --git a/example/Vector/7_SPH_dlb_gpu_more_opt/Makefile b/example/Vector/7_SPH_dlb_gpu_more_opt/Makefile
index e91b646cd..5162d1b64 100644
--- a/example/Vector/7_SPH_dlb_gpu_more_opt/Makefile
+++ b/example/Vector/7_SPH_dlb_gpu_more_opt/Makefile
@@ -15,10 +15,12 @@ else
         	INCLUDE_PATH_NVCC=
         	CUDA_CC_LINK=mpic++
 		CUDA_OPTIONS=
+		LIBS_SELECT=$(LIBS)
 	else
         	CUDA_CC=nvcc -ccbin=mpic++
         	CUDA_CC_LINK=nvcc -ccbin=mpic++
 		CUDA_OPTIONS=-use_fast_math  -arch=sm_61 -lineinfo
+		LIBS_SELECT=$(LIBS_NVCC)
 	endif
 endif
 
@@ -46,10 +48,10 @@ sph_dlb_test: sph_dlb
 	$(CC) -O3 $(OPT) -g -c --std=c++14 -o $@ $< $(INCLUDE_PATH)
 
 sph_dlb: $(OBJ)
-	$(CUDA_CC_LINK) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS)
+	$(CUDA_CC_LINK) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS_SELECT)
 
 sph_dlb2: $(OBJ)
-	$(CUDA_CC_LINK) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS)
+	$(CUDA_CC_LINK) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS_SELECT)
 
 all: sph_dlb
 
diff --git a/example/Vector/7_SPH_dlb_gpu_opt/Makefile b/example/Vector/7_SPH_dlb_gpu_opt/Makefile
index 4bef27170..6a4ece9f6 100644
--- a/example/Vector/7_SPH_dlb_gpu_opt/Makefile
+++ b/example/Vector/7_SPH_dlb_gpu_opt/Makefile
@@ -23,12 +23,13 @@ else
                 	INCLUDE_PATH_NVCC=
                 	CUDA_CC_LINK=mpic++
 			CUDA_OPTIONS=
+			LIBS_SELECT=$(LIBS)
         	else
                 	CUDA_CC=nvcc -ccbin=mpic++
                 	CUDA_CC_LINK=nvcc -ccbin=mpic++
 			CUDA_OPTIONS=-use_fast_math  -arch=sm_61 -lineinfo
+			LIBS_SELECT=$(LIBS_NVCC)
         	endif
-		LIBS_SELECT=$(LIBS)
 	endif
 endif
 
diff --git a/example/Vector/9_gpu_cuda_interop/Makefile b/example/Vector/9_gpu_cuda_interop/Makefile
index 0f90d34d7..2a520f46b 100644
--- a/example/Vector/9_gpu_cuda_interop/Makefile
+++ b/example/Vector/9_gpu_cuda_interop/Makefile
@@ -10,10 +10,12 @@ else
         	INCLUDE_PATH_NVCC=
         	CUDA_CC_LINK=mpic++
         	CUDA_OPTIONS=
+		LIBS_SELECT=$(LIBS)
 	else
         	CUDA_CC=nvcc -ccbin=mpic++
         	CUDA_CC_LINK=nvcc -ccbin=mpic++
         	CUDA_OPTIONS=-use_fast_math  -arch=sm_61 -lineinfo
+		LIBS_SELECT=$(LIBS_NVCC)
 	endif
 endif
 
@@ -28,7 +30,7 @@ gpu_interop:
 	$(CUDA_CC) -O3 $(OPT) -g -c --std=c++14 -o $@ $< $(INCLUDE_PATH)
 
 gpu_interop: $(OBJ)
-	$(CUDA_CC_LINK) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS)
+	$(CUDA_CC_LINK) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS_SELECT)
 
 all: gpu_interop
 
diff --git a/install b/install
index 91591d5e9..494ed4a4f 100755
--- a/install
+++ b/install
@@ -461,12 +461,13 @@ elif [ -d "$i_dir/HDF5/lib64" ]; then
 fi
 
 echo "INCLUDE_PATH=$mpi_include_dirs $cuda_include_dirs -Wno-deprecated-declarations $openmp_flags  -I.  -I$install_base/openfpm_numerics/include -I$install_base/openfpm_pdata/include/config -I$install_base/openfpm_pdata/include -I$install_base/openfpm_data/include -I$install_base/openfpm_vcluster/include -I$install_base/openfpm_io/include -I$install_base/openfpm_devices/include -I$i_dir/VCDEVEL/include  -I$i_dir/METIS/include -I$i_dir/PARMETIS/include -I$i_dir/BOOST/include -I$i_dir/HDF5/include -I$i_dir/LIBHILBERT/include  $lin_alg_inc -I$i_dir/BLITZ/include -I$i_dir/ALGOIM/include" > example.mk
-echo "LIBS_PATH=$mpi_libs $openmp_flags -L$install_base/openfpm_devices/lib -L$install_base/openfpm_pdata/lib  -L$install_base/openfpm_vcluster/lib -L$i_dir/VCDEVEL/lib  -L$i_dir/METIS/lib -L$i_dir/PARMETIS/lib  -L$i_dir/BOOST/lib $hdf5_lib_dir -L$i_dir/LIBHILBERT/lib  $lin_alg_dir " >> example.mk
+echo "LIBS_PATH=$mpi_libs -L$install_base/openfpm_devices/lib -L$install_base/openfpm_pdata/lib  -L$install_base/openfpm_vcluster/lib -L$i_dir/VCDEVEL/lib  -L$i_dir/METIS/lib -L$i_dir/PARMETIS/lib  -L$i_dir/BOOST/lib $hdf5_lib_dir -L$i_dir/LIBHILBERT/lib  $lin_alg_dir " >> example.mk
 if [ x"$cuda_on_cpu" == x"YES" ]; then
    echo "CUDA_ON_CPU=YES" >> example.mk
 fi
-echo "LIBS=$mpi_libs -lvcluster -lofpm_pdata -lofpmmemory -lparmetis -lmetis -lboost_iostreams -lboost_program_options -lhdf5 -llibhilbert -lVc  $(cat cuda_lib) $lin_alg_lib -ldl -lboost_filesystem -lboost_system $optional_boost" >> example.mk
-echo "INCLUDE_PATH_NVCC=-Xcompiler="-Wno-deprecated-declarations" $(cat openmp_flags) "$(cat cuda_options)" $mpi_include_dirs -I. -I$install_base/openfpm_numerics/include -I$install_base/openfpm_pdata/include/config -I$install_base/openfpm_pdata/include -I$install_base/openfpm_data/include -I$install_base/openfpm_vcluster/include -I$install_base/openfpm_io/include -I$install_base/openfpm_devices/include -I$i_dir/METIS/include -I$i_dir/PARMETIS/include -I$i_dir/BOOST/include -I$i_dir/HDF5/include -I$i_dir/LIBHILBERT/include  $lin_alg_inc -I$i_dir/BLITZ/include -I$i_dir/ALGOIM/include" >> example.mk
+echo "LIBS=$openmp_flags $mpi_libs -lvcluster -lofpm_pdata -lofpmmemory -lparmetis -lmetis -lboost_iostreams -lboost_program_options -lhdf5 -llibhilbert -lVc  $(cat cuda_lib) $lin_alg_lib -ldl -lboost_filesystem -lboost_system $optional_boost" >> example.mk
+echo "LIBS_NVCC=-Xcompiler=$openmp_flags $mpi_libs -lvcluster -lofpm_pdata -lofpmmemory -lparmetis -lmetis -lboost_iostreams -lboost_program_options -lhdf5 -llibhilbert -lVc  $(cat cuda_lib) $lin_alg_lib -ldl -lboost_filesystem -lboost_system $optional_boost" >> example.mk
+echo "INCLUDE_PATH_NVCC=-Xcompiler="-Wno-deprecated-declarations" -Xcompiler=$(cat openmp_flags) "$(cat cuda_options)" $mpi_include_dirs -I. -I$install_base/openfpm_numerics/include -I$install_base/openfpm_pdata/include/config -I$install_base/openfpm_pdata/include -I$install_base/openfpm_data/include -I$install_base/openfpm_vcluster/include -I$install_base/openfpm_io/include -I$install_base/openfpm_devices/include -I$i_dir/METIS/include -I$i_dir/PARMETIS/include -I$i_dir/BOOST/include -I$i_dir/HDF5/include -I$i_dir/LIBHILBERT/include  $lin_alg_inc -I$i_dir/BLITZ/include -I$i_dir/ALGOIM/include" >> example.mk
 cp example.mk src/example.mk
 cp example.mk example/example.mk
 
-- 
GitLab