From b94595201659f1d6d373050628c02c4b0ead57f5 Mon Sep 17 00:00:00 2001 From: Lourens Veen Date: Tue, 31 Oct 2023 15:28:45 +0100 Subject: [PATCH 1/4] Make test Makefile pick up the environment --- testCodes/Makefile | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/testCodes/Makefile b/testCodes/Makefile index 3d9324f..10bff4d 100644 --- a/testCodes/Makefile +++ b/testCodes/Makefile @@ -1,7 +1,4 @@ -CXX = g++ -CC = gcc -LD = g++ -F90 = ifort +CXX ?= g++ .SUFFIXES: .o .cpp .ptx .cu @@ -10,12 +7,12 @@ SAPLIB2 = sapporo SAPLIB = lib$(SAPLIB2).a -CUDA_TK = /usr/local/cuda +CUDA_TK ?= /usr/local/cuda -OFLAGS = -g -O3 -Wall -fopenmp -Wextra -Wstrict-aliasing=2 -fopenmp -CXXFLAGS = -fPIC $(OFLAGS) -I$(CUDA_TK)/include +OFLAGS = -g -O3 -Wall -Wextra -Wstrict-aliasing=2 -fopenmp +CXXFLAGS += -fPIC -fopenmp $(OFLAGS) -I$(CUDA_TK)/include -LDFLAGS = -lcuda -fopenmp -L$(CUDA_TK)/lib64 +LDFLAGS += -lcuda -fopenmp -L$(CUDA_TK)/lib64 INCLUDEPATH = $(SAPPOROPATH)/include CXXFLAGS += -I$(INCLUDEPATH) -I./ -I $(SAPPOROPATH) @@ -34,31 +31,31 @@ kernels: ln -s $(SAPPOROPATH)/CUDAKernels/ CUDA/ #$(PROG): $(OBJ) -# $(LD) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -lsapporo +# $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -lsapporo test_gravity_block_cuda : test_gravity_block.o - $(LD) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) + $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) test_gravity_block_g5_cuda: test_gravity_block_g5.o - $(LD) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) + $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) test_gravity_block_6th_cuda : test_gravity_block_6th.o - $(LD) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) + $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) test_performance_rangeN_cuda : test_performance_rangeN.o - $(LD) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) + $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) test_performance_blockStep_cuda : test_performance_blockStep.o - $(LD) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) + $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) test_performance_rangeN_6th_cuda : test_performance_rangeN_6th.o - $(LD) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) + $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) test_performance_rangeN_g5_cuda : test_performance_rangeN_g5.o - $(LD) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) + $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) test_integrator_cuda : test_integrator.o - $(LD) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) + $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIBG6) $(LDFLAGS) %.o: $(SRCPATH)/%.cpp From c0552c3a94b947fad7232483d1a415424a7a6429 Mon Sep 17 00:00:00 2001 From: Lourens Veen Date: Tue, 31 Oct 2023 15:32:29 +0100 Subject: [PATCH 2/4] Fix symlinking error on repeated builds --- testCodes/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testCodes/Makefile b/testCodes/Makefile index 10bff4d..f14ae8a 100644 --- a/testCodes/Makefile +++ b/testCodes/Makefile @@ -28,7 +28,7 @@ all: $(OBJ) $(PROG) kernels kernels: - ln -s $(SAPPOROPATH)/CUDAKernels/ CUDA/ + rm -f CUDA && ln -s $(SAPPOROPATH)/CUDAKernels CUDA #$(PROG): $(OBJ) # $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -lsapporo @@ -63,7 +63,7 @@ test_integrator_cuda : test_integrator.o clean: - /bin/rm -rf *.o *.ptx *.a $(PROG) + /bin/rm -rf *.o *.ptx *.a $(PROG) CUDA $(OBJ): $(SAPPOROPATH)/$(SAPLIB) From a31cfb77164a975749a8352bcb6afb25211051cf Mon Sep 17 00:00:00 2001 From: Lourens Veen Date: Tue, 31 Oct 2023 11:27:46 +0100 Subject: [PATCH 3/4] Add .gitignore for the test directory --- testCodes/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 testCodes/.gitignore diff --git a/testCodes/.gitignore b/testCodes/.gitignore new file mode 100644 index 0000000..bd0f7ea --- /dev/null +++ b/testCodes/.gitignore @@ -0,0 +1,2 @@ +test_* +CUDA From 11353e6fa69c3c3c69b5c74846c8f8debb58a3fa Mon Sep 17 00:00:00 2001 From: Lourens Veen Date: Thu, 2 Nov 2023 17:15:44 +0100 Subject: [PATCH 4/4] Also update the OpenCL test makefile --- testCodes/Makefile_ocl | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/testCodes/Makefile_ocl b/testCodes/Makefile_ocl index 9a50894..f5a3bf2 100644 --- a/testCodes/Makefile_ocl +++ b/testCodes/Makefile_ocl @@ -1,7 +1,4 @@ -CXX = g++ -CC = gcc -LD = g++ -F90 = ifort +CXX ?= g++ .SUFFIXES: .o .cpp .ptx .cu @@ -9,13 +6,13 @@ SAPPOROPATH=../lib/ SAPLIB2 = sapporo_ocl SAPLIB = lib$(SAPLIB2).a -CUDA_TK = /usr/local/cuda +CUDA_TK ?= /usr/local/cuda #CUDA_TK = /opt/AMDAPP/ -OFLAGS = -g -O3 -Wall -Wextra -Wstrict-aliasing=2 -fopenmp -CXXFLAGS = -fPIC $(OFLAGS) -D_OCL_ +OFLAGS = -g -O3 -Wall -Wextra -Wstrict-aliasing=2 -fopenmp +CXXFLAGS += -fPIC -fopenmp $(OFLAGS) -D_OCL_ -LDFLAGS = -lOpenCL -fopenmp +LDFLAGS += -lOpenCL -fopenmp INCLUDEPATH = $(SAPPOROPATH)/include CXXFLAGS += -I$(INCLUDEPATH) -I./ -I $(SAPPOROPATH) -I$(CUDA_TK)/include @@ -33,28 +30,28 @@ kernels: ln -s $(SAPPOROPATH)/OpenCLKernels OpenCL test_gravity_block_ocl : test_gravity_block_ocl.o - $(LD) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) + $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) test_gravity_block_g5_ocl: test_gravity_block_g5_ocl.o - $(LD) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) + $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) test_gravity_block_6th_ocl : test_gravity_block_6th_ocl.o - $(LD) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) + $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) test_performance_rangeN_ocl : test_performance_rangeN_ocl.o - $(LD) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) + $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) test_performance_blockStep_ocl : test_performance_blockStep_ocl.o - $(LD) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) + $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) test_performance_rangeN_6th_ocl : test_performance_rangeN_6th_ocl.o - $(LD) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) + $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) test_performance_rangeN_g5_ocl : test_performance_rangeN_g5_ocl.o - $(LD) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) + $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) test_integrator_ocl : test_integrator_ocl.o - $(LD) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) + $(CXX) $(LDFLAGS) $^ -o $@ -L $(SAPPOROPATH) -l$(SAPLIB2) $(LDFLAGS) %_ocl.o: $(SRCPATH)/%.cpp $(CXX) $(CXXFLAGS) -c $< -o $@