From 156456a6bc807e9083b39319eb0d38f1b4ebc520 Mon Sep 17 00:00:00 2001 From: Witold Baryluk Date: Thu, 14 Mar 2024 02:30:36 +0100 Subject: [PATCH] build system cleanups Make everything consistent. Make it work on hipcc not installed in /opt, i.e. on Debian with Debian packages. Properly use condition, #!, and other factors. Remove code that does nothing. Add .gitignores as needed. --- .../BinomialOption/.gitignore | 1 + .../BinomialOption/Makefile | 28 ++---- .../BitonicSort/.gitignore | 1 + .../BitonicSort/Makefile | 28 ++---- .../FastWalshTransform/.gitignore | 1 + .../FastWalshTransform/Makefile | 28 ++---- .../FloydWarshall/.gitignore | 1 + .../FloydWarshall/Makefile | 28 ++---- .../HelloWorld/.gitignore | 1 + HIP-Examples-Applications/HelloWorld/Makefile | 28 ++---- .../Histogram/.gitignore | 1 + HIP-Examples-Applications/Histogram/Makefile | 28 ++---- .../MatrixMultiplication/.gitignore | 1 + .../MatrixMultiplication/Makefile | 28 ++---- .../PrefixSum/.gitignore | 1 + HIP-Examples-Applications/PrefixSum/Makefile | 28 ++---- .../RecursiveGaussian/.gitignore | 1 + .../RecursiveGaussian/Makefile | 28 ++---- .../SimpleConvolution/.gitignore | 1 + .../SimpleConvolution/Makefile | 28 ++---- HIP-Examples-Applications/dct/.gitignore | 1 + HIP-Examples-Applications/dct/Makefile | 30 ++---- .../dwtHaar1D/.gitignore | 1 + HIP-Examples-Applications/dwtHaar1D/Makefile | 30 ++---- add4/.gitignore | 1 + add4/Makefile | 22 ++--- add4/buildit.sh | 2 - add4/runhip.sh | 8 -- common/hip.all.make | 2 - common/hip.prologue.make | 93 ------------------- cuda-stream/.gitignore | 2 + cuda-stream/Makefile | 15 ++- cuda-stream/Makefile.titan | 12 ++- gpu-burn/.gitignore | 1 + gpu-burn/Makefile | 10 +- mini-nbody/cuda/shmoo-cuda-nbody-block.sh | 14 +-- mini-nbody/cuda/shmoo-cuda-nbody-ftz.sh | 14 +-- mini-nbody/cuda/shmoo-cuda-nbody-orig.sh | 14 +-- mini-nbody/cuda/shmoo-cuda-nbody-soa.sh | 14 +-- mini-nbody/cuda/shmoo-cuda-nbody-unroll.sh | 14 +-- mini-nbody/hip/.gitignore | 3 + mini-nbody/hip/HIP-nbody-block.sh | 51 ++++------ mini-nbody/hip/HIP-nbody-orig.sh | 48 ++++------ mini-nbody/hip/HIP-nbody-soa.sh | 51 ++++------ mini-nbody/mic/shmoo-mic-nbody-align.sh | 23 +---- mini-nbody/mic/shmoo-mic-nbody-block.sh | 23 +---- mini-nbody/mic/shmoo-mic-nbody-ftz.sh | 23 +---- mini-nbody/mic/shmoo-mic-nbody-orig.sh | 23 +---- mini-nbody/mic/shmoo-mic-nbody-soa.sh | 23 +---- mini-nbody/shmoo-cpu-nbody.sh | 13 +-- openmp-helloworld/.gitignore | 2 + openmp-helloworld/Makefile | 26 ++---- reduction/.gitignore | 1 + reduction/Makefile | 9 +- reduction/run.sh | 15 ++- rtm8/.gitignore | 3 + rtm8/Makefile | 39 ++++++-- rtm8/README.md | 15 +-- rtm8/build_cuda.sh | 7 -- rtm8/build_fortran.sh | 8 -- rtm8/build_hip.sh | 22 ----- strided-access/.gitignore | 1 + strided-access/Makefile | 15 ++- test_all.sh | 71 ++++++++------ vectorAdd/.gitignore | 1 + vectorAdd/Makefile | 29 ++---- 66 files changed, 357 insertions(+), 778 deletions(-) create mode 100644 HIP-Examples-Applications/BinomialOption/.gitignore create mode 100644 HIP-Examples-Applications/BitonicSort/.gitignore create mode 100644 HIP-Examples-Applications/FastWalshTransform/.gitignore create mode 100644 HIP-Examples-Applications/FloydWarshall/.gitignore create mode 100644 HIP-Examples-Applications/HelloWorld/.gitignore create mode 100644 HIP-Examples-Applications/Histogram/.gitignore create mode 100644 HIP-Examples-Applications/MatrixMultiplication/.gitignore create mode 100644 HIP-Examples-Applications/PrefixSum/.gitignore create mode 100644 HIP-Examples-Applications/RecursiveGaussian/.gitignore create mode 100644 HIP-Examples-Applications/SimpleConvolution/.gitignore create mode 100644 HIP-Examples-Applications/dct/.gitignore create mode 100644 HIP-Examples-Applications/dwtHaar1D/.gitignore create mode 100644 add4/.gitignore delete mode 100755 add4/buildit.sh delete mode 100755 add4/runhip.sh delete mode 100644 common/hip.all.make delete mode 100644 common/hip.prologue.make create mode 100644 cuda-stream/.gitignore create mode 100644 gpu-burn/.gitignore create mode 100644 mini-nbody/hip/.gitignore create mode 100644 openmp-helloworld/.gitignore create mode 100644 reduction/.gitignore create mode 100644 rtm8/.gitignore delete mode 100755 rtm8/build_cuda.sh delete mode 100755 rtm8/build_fortran.sh delete mode 100755 rtm8/build_hip.sh create mode 100644 strided-access/.gitignore create mode 100644 vectorAdd/.gitignore diff --git a/HIP-Examples-Applications/BinomialOption/.gitignore b/HIP-Examples-Applications/BinomialOption/.gitignore new file mode 100644 index 0000000..e6a620c --- /dev/null +++ b/HIP-Examples-Applications/BinomialOption/.gitignore @@ -0,0 +1 @@ +BinomialOption diff --git a/HIP-Examples-Applications/BinomialOption/Makefile b/HIP-Examples-Applications/BinomialOption/Makefile index 39097c5..30e4ff2 100644 --- a/HIP-Examples-Applications/BinomialOption/Makefile +++ b/HIP-Examples-Applications/BinomialOption/Makefile @@ -1,29 +1,13 @@ HIP_PATH?= $(wildcard /opt/rocm) HIPCC=$(HIP_PATH)/bin/hipcc -SOURCES = BinomialOption.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -EXECUTABLE=./BinomialOption +BinomialOption: BinomialOption.cpp ../include/HIPUtil.hpp ../include/SDKUtil.hpp + $(HIPCC) -o $@ BinomialOption.cpp .PHONY: test +test: BinomialOption + $(shell pwd)/BinomialOption - -all: $(EXECUTABLE) test - -CXXFLAGS =-g -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - +.PHONY: clean clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o + rm -vf BinomialOption *.o diff --git a/HIP-Examples-Applications/BitonicSort/.gitignore b/HIP-Examples-Applications/BitonicSort/.gitignore new file mode 100644 index 0000000..b2a6847 --- /dev/null +++ b/HIP-Examples-Applications/BitonicSort/.gitignore @@ -0,0 +1 @@ +BitonicSort diff --git a/HIP-Examples-Applications/BitonicSort/Makefile b/HIP-Examples-Applications/BitonicSort/Makefile index 3c73cca..88220dd 100644 --- a/HIP-Examples-Applications/BitonicSort/Makefile +++ b/HIP-Examples-Applications/BitonicSort/Makefile @@ -1,29 +1,13 @@ HIP_PATH?= $(wildcard /opt/rocm) HIPCC=$(HIP_PATH)/bin/hipcc -SOURCES = BitonicSort.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -EXECUTABLE=./BitonicSort +BitonicSort: BitonicSort.cpp ../include/HIPUtil.hpp ../include/SDKUtil.hpp + $(HIPCC) -o $@ BitonicSort.cpp .PHONY: test +test: BitonicSort + $(shell pwd)/BitonicSort - -all: $(EXECUTABLE) test - -CXXFLAGS =-g -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - +.PHONY: clean clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o + rm -vf BitonicSort *.o diff --git a/HIP-Examples-Applications/FastWalshTransform/.gitignore b/HIP-Examples-Applications/FastWalshTransform/.gitignore new file mode 100644 index 0000000..95d06d7 --- /dev/null +++ b/HIP-Examples-Applications/FastWalshTransform/.gitignore @@ -0,0 +1 @@ +FastWalshTransform diff --git a/HIP-Examples-Applications/FastWalshTransform/Makefile b/HIP-Examples-Applications/FastWalshTransform/Makefile index 2fa7613..273fb23 100644 --- a/HIP-Examples-Applications/FastWalshTransform/Makefile +++ b/HIP-Examples-Applications/FastWalshTransform/Makefile @@ -1,29 +1,13 @@ HIP_PATH?= $(wildcard /opt/rocm) HIPCC=$(HIP_PATH)/bin/hipcc -SOURCES = FastWalshTransform.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -EXECUTABLE=./FastWalshTransform +FastWalshTransform: FastWalshTransform.cpp ../include/HIPUtil.hpp ../include/SDKUtil.hpp + $(HIPCC) -o $@ FastWalshTransform.cpp .PHONY: test +test: FastWalshTransform + $(shell pwd)/FastWalshTransform - -all: $(EXECUTABLE) test - -CXXFLAGS =-g -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - +.PHONY: clean clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o + rm -vf FastWalshTransform *.o diff --git a/HIP-Examples-Applications/FloydWarshall/.gitignore b/HIP-Examples-Applications/FloydWarshall/.gitignore new file mode 100644 index 0000000..70b28c9 --- /dev/null +++ b/HIP-Examples-Applications/FloydWarshall/.gitignore @@ -0,0 +1 @@ +FloydWarshall diff --git a/HIP-Examples-Applications/FloydWarshall/Makefile b/HIP-Examples-Applications/FloydWarshall/Makefile index e474103..99c3bc3 100644 --- a/HIP-Examples-Applications/FloydWarshall/Makefile +++ b/HIP-Examples-Applications/FloydWarshall/Makefile @@ -1,29 +1,13 @@ HIP_PATH?= $(wildcard /opt/rocm) HIPCC=$(HIP_PATH)/bin/hipcc -SOURCES = FloydWarshall.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -EXECUTABLE=./FloydWarshall +FloydWarshall: FloydWarshall.cpp ../include/HIPUtil.hpp ../include/SDKUtil.hpp + $(HIPCC) -o $@ FloydWarshall.cpp .PHONY: test +test: FloydWarshall + $(shell pwd)/FloydWarshall - -all: $(EXECUTABLE) test - -CXXFLAGS =-g -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - +.PHONY: clean clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o + rm -vf FloydWarshall *.o diff --git a/HIP-Examples-Applications/HelloWorld/.gitignore b/HIP-Examples-Applications/HelloWorld/.gitignore new file mode 100644 index 0000000..3da1ec2 --- /dev/null +++ b/HIP-Examples-Applications/HelloWorld/.gitignore @@ -0,0 +1 @@ +HelloWorld diff --git a/HIP-Examples-Applications/HelloWorld/Makefile b/HIP-Examples-Applications/HelloWorld/Makefile index 860906c..fd78c18 100644 --- a/HIP-Examples-Applications/HelloWorld/Makefile +++ b/HIP-Examples-Applications/HelloWorld/Makefile @@ -1,29 +1,13 @@ HIP_PATH?= $(wildcard /opt/rocm) HIPCC=$(HIP_PATH)/bin/hipcc -SOURCES = HelloWorld.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -EXECUTABLE=./HelloWorld +HelloWorld: HelloWorld.cpp + $(HIPCC) -o $@ HelloWorld.cpp .PHONY: test +test: HelloWorld + $(shell pwd)/HelloWorld - -all: $(EXECUTABLE) test - -CXXFLAGS =-g -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - +.PHONY: clean clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o + rm -vf HelloWorld *.o diff --git a/HIP-Examples-Applications/Histogram/.gitignore b/HIP-Examples-Applications/Histogram/.gitignore new file mode 100644 index 0000000..0e3bbbf --- /dev/null +++ b/HIP-Examples-Applications/Histogram/.gitignore @@ -0,0 +1 @@ +Histogram diff --git a/HIP-Examples-Applications/Histogram/Makefile b/HIP-Examples-Applications/Histogram/Makefile index 9da8a88..0e95d4b 100644 --- a/HIP-Examples-Applications/Histogram/Makefile +++ b/HIP-Examples-Applications/Histogram/Makefile @@ -1,29 +1,13 @@ HIP_PATH?= $(wildcard /opt/rocm) HIPCC=$(HIP_PATH)/bin/hipcc -SOURCES = Histogram.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -EXECUTABLE=./Histogram +Histogram: Histogram.cpp Histogram.hpp ../include/HIPUtil.hpp ../include/SDKUtil.hpp + $(HIPCC) -o $@ Histogram.cpp .PHONY: test +test: Histogram + $(shell pwd)/Histogram - -all: $(EXECUTABLE) test - -CXXFLAGS =-g -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - +.PHONY: clean clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)src/*.o + rm -vf Histogram *.o diff --git a/HIP-Examples-Applications/MatrixMultiplication/.gitignore b/HIP-Examples-Applications/MatrixMultiplication/.gitignore new file mode 100644 index 0000000..5145b94 --- /dev/null +++ b/HIP-Examples-Applications/MatrixMultiplication/.gitignore @@ -0,0 +1 @@ +MatrixMultiplication diff --git a/HIP-Examples-Applications/MatrixMultiplication/Makefile b/HIP-Examples-Applications/MatrixMultiplication/Makefile index 97001ce..9b667e6 100644 --- a/HIP-Examples-Applications/MatrixMultiplication/Makefile +++ b/HIP-Examples-Applications/MatrixMultiplication/Makefile @@ -1,29 +1,13 @@ HIP_PATH?= $(wildcard /opt/rocm) HIPCC=$(HIP_PATH)/bin/hipcc -SOURCES = MatrixMultiplication.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -EXECUTABLE=./MatrixMultiplication +MatrixMultiplication: MatrixMultiplication.cpp ../include/HIPUtil.hpp ../include/SDKUtil.hpp + $(HIPCC) -o $@ MatrixMultiplication.cpp .PHONY: test +test: MatrixMultiplication + $(shell pwd)/MatrixMultiplication - -all: $(EXECUTABLE) test - -CXXFLAGS =-g -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - +.PHONY: clean clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o + rm -vf MatrixMultiplication *.o diff --git a/HIP-Examples-Applications/PrefixSum/.gitignore b/HIP-Examples-Applications/PrefixSum/.gitignore new file mode 100644 index 0000000..f9d16cf --- /dev/null +++ b/HIP-Examples-Applications/PrefixSum/.gitignore @@ -0,0 +1 @@ +PrefixSum diff --git a/HIP-Examples-Applications/PrefixSum/Makefile b/HIP-Examples-Applications/PrefixSum/Makefile index 52c0ead..77cc64a 100644 --- a/HIP-Examples-Applications/PrefixSum/Makefile +++ b/HIP-Examples-Applications/PrefixSum/Makefile @@ -1,29 +1,13 @@ HIP_PATH?= $(wildcard /opt/rocm) HIPCC=$(HIP_PATH)/bin/hipcc -SOURCES = PrefixSum.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -EXECUTABLE=./PrefixSum +PrefixSum: PrefixSum.cpp ../include/HIPUtil.hpp ../include/SDKUtil.hpp + $(HIPCC) -o $@ PrefixSum.cpp .PHONY: test +test: PrefixSum + $(shell pwd)/PrefixSum - -all: $(EXECUTABLE) test - -CXXFLAGS =-g -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - +.PHONY: clean clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o + rm -vf PrefixSum *.o diff --git a/HIP-Examples-Applications/RecursiveGaussian/.gitignore b/HIP-Examples-Applications/RecursiveGaussian/.gitignore new file mode 100644 index 0000000..df7f15e --- /dev/null +++ b/HIP-Examples-Applications/RecursiveGaussian/.gitignore @@ -0,0 +1 @@ +RecursiveGaussian diff --git a/HIP-Examples-Applications/RecursiveGaussian/Makefile b/HIP-Examples-Applications/RecursiveGaussian/Makefile index 6513c7f..7f47767 100644 --- a/HIP-Examples-Applications/RecursiveGaussian/Makefile +++ b/HIP-Examples-Applications/RecursiveGaussian/Makefile @@ -1,29 +1,13 @@ HIP_PATH?= $(wildcard /opt/rocm) HIPCC=$(HIP_PATH)/bin/hipcc -SOURCES = RecursiveGaussian.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -EXECUTABLE=./RecursiveGaussian +RecursiveGaussian: RecursiveGaussian.cpp RecursiveGaussian.hpp ../include/HIPUtil.hpp ../include/SDKUtil.hpp ../include/SDKBitMap.hpp + $(HIPCC) -o $@ RecursiveGaussian.cpp .PHONY: test +test: RecursiveGaussian + $(shell pwd)/RecursiveGaussian - -all: $(EXECUTABLE) test - -CXXFLAGS =-g -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - +.PHONY: clean clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o + rm -vf RecursiveGaussian *.o diff --git a/HIP-Examples-Applications/SimpleConvolution/.gitignore b/HIP-Examples-Applications/SimpleConvolution/.gitignore new file mode 100644 index 0000000..6c75cf9 --- /dev/null +++ b/HIP-Examples-Applications/SimpleConvolution/.gitignore @@ -0,0 +1 @@ +SimpleConvolution diff --git a/HIP-Examples-Applications/SimpleConvolution/Makefile b/HIP-Examples-Applications/SimpleConvolution/Makefile index a662187..b711738 100644 --- a/HIP-Examples-Applications/SimpleConvolution/Makefile +++ b/HIP-Examples-Applications/SimpleConvolution/Makefile @@ -1,29 +1,13 @@ HIP_PATH?= $(wildcard /opt/rocm) HIPCC=$(HIP_PATH)/bin/hipcc -SOURCES = SimpleConvolution.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -EXECUTABLE=./SimpleConvolution +SimpleConvolution: SimpleConvolution.cpp SimpleConvolution.hpp FilterCoeff.h ../include/HIPUtil.hpp ../include/SDKUtil.hpp + $(HIPCC) -o $@ SimpleConvolution.cpp .PHONY: test +test: SimpleConvolution + $(shell pwd)/SimpleConvolution - -all: $(EXECUTABLE) test - -CXXFLAGS =-g -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - +.PHONY: clean clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o + rm -vf SimpleConvolution *.o diff --git a/HIP-Examples-Applications/dct/.gitignore b/HIP-Examples-Applications/dct/.gitignore new file mode 100644 index 0000000..28ded9d --- /dev/null +++ b/HIP-Examples-Applications/dct/.gitignore @@ -0,0 +1 @@ +dct diff --git a/HIP-Examples-Applications/dct/Makefile b/HIP-Examples-Applications/dct/Makefile index 9375383..92751c0 100644 --- a/HIP-Examples-Applications/dct/Makefile +++ b/HIP-Examples-Applications/dct/Makefile @@ -1,27 +1,13 @@ -HIPCC=/opt/rocm/bin/hipcc +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc -SOURCES = dct.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -EXECUTABLE=./dct +dct: dct.cpp ../include/HIPUtil.hpp ../include/SDKUtil.hpp + $(HIPCC) -o $@ dct.cpp .PHONY: test +test: dct + $(shell pwd)/dct - -all: $(EXECUTABLE) test - -CXXFLAGS =-g -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - +.PHONY: clean clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) + rm -vf dct *.o diff --git a/HIP-Examples-Applications/dwtHaar1D/.gitignore b/HIP-Examples-Applications/dwtHaar1D/.gitignore new file mode 100644 index 0000000..35b8045 --- /dev/null +++ b/HIP-Examples-Applications/dwtHaar1D/.gitignore @@ -0,0 +1 @@ +dwtHaar1D diff --git a/HIP-Examples-Applications/dwtHaar1D/Makefile b/HIP-Examples-Applications/dwtHaar1D/Makefile index c975a19..efd9a29 100644 --- a/HIP-Examples-Applications/dwtHaar1D/Makefile +++ b/HIP-Examples-Applications/dwtHaar1D/Makefile @@ -1,27 +1,13 @@ -HIPCC=/opt/rocm/bin/hipcc +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc -SOURCES = dwtHaar1D.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -EXECUTABLE=./dwtHaar1D +dwtHaar1D: dwtHaar1D.cpp ../include/HIPUtil.hpp ../include/SDKUtil.hpp + $(HIPCC) -o $@ dwtHaar1D.cpp .PHONY: test +test: dwtHaar1D + $(shell pwd)/dwtHaar1D - -all: $(EXECUTABLE) test - -CXXFLAGS =-g -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - +.PHONY: clean clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) + rm -vf dwtHaar1D *.o diff --git a/add4/.gitignore b/add4/.gitignore new file mode 100644 index 0000000..d7dd2b7 --- /dev/null +++ b/add4/.gitignore @@ -0,0 +1 @@ +gpu-stream-hip diff --git a/add4/Makefile b/add4/Makefile index c320316..5b78e48 100644 --- a/add4/Makefile +++ b/add4/Makefile @@ -1,26 +1,26 @@ +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc + CXXFLAGS += -std=c++11 -O3 +.PHONY: all all: gpu-stream-hip common.o: common.cpp common.h Makefile -HIP_PATH?= $(wildcard /opt/rocm) - -HIPCC=$(HIP_PATH)/bin/hipcc - hip-stream.o : hip-stream.cpp $(HIPCC) $(CXXFLAGS) -c $< -o $@ gpu-stream-hip: hip-stream.o common.o Makefile -ifeq ($(shell which $(HIPCC) > /dev/null; echo $$?), 0) $(HIPCC) $(CXXFLAGS) common.o $< -lm -o $@ -else - $(error "Cannot find $(HIPCC), please install HIP toolkit") -endif +.PHONY: test +test: gpu-stream-hip + $(shell pwd)/gpu-stream-hip + $(shell pwd)/gpu-stream-hip --groups 256 --groupSize 256 + $(shell pwd)/gpu-stream-hip --float + $(shell pwd)/gpu-stream-hip --float --groups 256 --groupSize 256 .PHONY: clean - clean: - rm -f gpu-stream-hip *.o - + rm -vf gpu-stream-hip *.o diff --git a/add4/buildit.sh b/add4/buildit.sh deleted file mode 100755 index f7d0b57..0000000 --- a/add4/buildit.sh +++ /dev/null @@ -1,2 +0,0 @@ -make clean -make gpu-stream-hip diff --git a/add4/runhip.sh b/add4/runhip.sh deleted file mode 100755 index 2c41788..0000000 --- a/add4/runhip.sh +++ /dev/null @@ -1,8 +0,0 @@ -echo ./gpu-stream-hip -./gpu-stream-hip -echo ./gpu-stream-hip --groups 256 --groupSize 256 -./gpu-stream-hip --groups 256 --groupSize 256 -echo ./gpu-stream-hip --float -./gpu-stream-hip --float -echo ./gpu-stream-hip --float --groups 256 --groupSize 256 -./gpu-stream-hip --float --groups 256 --groupSize 256 diff --git a/common/hip.all.make b/common/hip.all.make deleted file mode 100644 index c6c8e5b..0000000 --- a/common/hip.all.make +++ /dev/null @@ -1,2 +0,0 @@ -include $(HIP_PATH)/examples/common/hip.prologue.make -include $(HIP_PATH)/examples/common/hip.epilogue.make diff --git a/common/hip.prologue.make b/common/hip.prologue.make deleted file mode 100644 index 9718293..0000000 --- a/common/hip.prologue.make +++ /dev/null @@ -1,93 +0,0 @@ -# This file is designed to be included at beginning of Makefile, right after setting HIP_PATH. -# Note: define $HIP_PATH before including this file. -# HIP_PATH should be relevant to the parent makefile -# -# It should not include any concrete makefile steps, so "make" still runs the first step in the Makefile. -# - -#------ -##Provide default if not already set: -HIP_PATH?=../.. -HIP_PLATFORM=$(shell $(HIP_PATH)/bin/hipconfig --compiler) - -# CUDA toolkit installation path -CUDA_DIR?=/usr/local/cuda-7.5 -# CUDA toolkit libraries -CUDA_LIB_DIR := $(CUDA_DIR)/lib -ifeq ($(shell uname -m), x86_64) - ifeq ($(shell if test -d $(CUDA_DIR)/lib64; then echo T; else echo F; fi), T) - CUDA_LIB_DIR := $(CUDA_DIR)/lib64 - endif -endif - -# Some samples mix openmp with gpu acceleration. -# Those unfortunately have to be compiled with gcc, not clang. -# nvcc (7.5) can handle openmp though. -# use OMPCC and OMP_FLAGS - -HIPCC=$(HIP_PATH)/bin/hipcc -HIPLD=$(HIP_PATH)/bin/hipcc - -#-- -# Set up automatic make of HIP cpp depenendencies -# TODO - this can be removed when HIP has a proper make structure. -#HIP_SOURCES = $(HIP_PATH)/src/hip_hcc.cpp - -HIPCC_FLAGS += -I../../common -# 'make dbg=1' enables HIPCC debugging and no opt switch. -ifeq ($(dbg),1) - HIPCC_FLAGS += -g - OMP_FLAGS += -g -else ifeq ($(opt),0) - HIPCC_FLAGS += -O0 - OMP_FLAGS += -O0 -else ifeq ($(opt),3) - HIPCC_FLAGS += -O3 - OMP_FLAGS += -O3 -else - HIPCC_FLAGS += -O2 - OMP_FLAGS += -O2 -endif - -ifeq ($(HIP_PLATFORM), nvcc) -OMPCC = gcc -OMP_FLAGS = $(HIPCC_FLAGS) -HIP_DEPS = - -else ifeq ($(HIP_PLATFORM), hcc) -#HIP_DEPS = $(HIP_SOURCES:.cpp=.o) -OMPCC = gcc -OMP_FLAGS += -fopenmp - -# Add dependencies to make hip_cc.o and other support files. -HSA_PATH ?= /opt/hsa -#HIP_SOURCES = $(HIP_PATH)/src/hip_hcc.cpp -#HIP_DEPS = $(HIP_SOURCES:.cpp=.o) -#$(HIP_DEPS): HIPCC_FLAGS += -I$(HSA_PATH)/include -%.o:: %.cpp - $(HIPCC) $(HIPCC_FLAGS) $< -c -o $@ -endif - - - - - - - - -#------ -# -#--- -# Rule for automatic HIPIFY call - assumes original cuda files are stored in local 'cusrc' directory. See kmeans. -#%.cu : cusrc/%.cu -# $(HIPIFY) $< > $@ -#%.cuh : cusrc/%.cuh -# $(HIPIFY) $< > $@ - - -KCFLAGS += $(OPT) -I$(HSA_PATH)/include -I$(HIP_PATH)/include -I$(GRID_LAUNCH_PATH) -I$(AM_PATH)/include - -%.o:: %.cpp - $(HIPCC) $(HIPCC_FLAGS) $< -c -o $@ - - diff --git a/cuda-stream/.gitignore b/cuda-stream/.gitignore new file mode 100644 index 0000000..5d54a5d --- /dev/null +++ b/cuda-stream/.gitignore @@ -0,0 +1,2 @@ +stream +stream_titan diff --git a/cuda-stream/Makefile b/cuda-stream/Makefile index dc8e0d7..635f9f1 100644 --- a/cuda-stream/Makefile +++ b/cuda-stream/Makefile @@ -1,18 +1,15 @@ HIP_PATH?= $(wildcard /opt/rocm) - HIPCC=$(HIP_PATH)/bin/hipcc CXXFLAGS += -std=c++11 -O3 stream: stream.cpp -ifeq ($(shell which $(HIPCC) > /dev/null; echo $$?), 0) - ${HIPCC} ${CXXFLAGS} -o $@ $^ -else - $(error "Cannot find $(HIPCC), please install HIP toolkit") -endif + ${HIPCC} ${CXXFLAGS} -o $@ $^ -.PHONY: clean +.PHONY: test +test: stream + $(shell pwd)/stream +.PHONY: clean clean: - rm -f stream *.o - + rm -vf stream *.o diff --git a/cuda-stream/Makefile.titan b/cuda-stream/Makefile.titan index afaba3e..81ea26c 100644 --- a/cuda-stream/Makefile.titan +++ b/cuda-stream/Makefile.titan @@ -1,9 +1,13 @@ CC=gcc ARCH=sm_35 -stream : stream.cpp - hipcc -std=c++11 -ccbin=$(CC) stream.cpp -arch=$(ARCH) -o stream +stream_titan: stream.cpp + hipcc -std=c++11 -ccbin=$(CC) -arch=$(ARCH) stream.cpp -o stream_titan +.PHONY: test +test: stream_titan + $(shell pwd)/stream_titan -clean : - rm -f stream +.PHONY: clean +clean: + rm -vf stream_titan diff --git a/gpu-burn/.gitignore b/gpu-burn/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/gpu-burn/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/gpu-burn/Makefile b/gpu-burn/Makefile index 8f361eb..3d87d87 100644 --- a/gpu-burn/Makefile +++ b/gpu-burn/Makefile @@ -1,12 +1,11 @@ HIP_PATH?= $(wildcard /opt/rocm) +HIPCC = $(HIP_PATH)/bin/hipcc HIP_PLATFORM = $(shell $(HIP_PATH)/bin/hipconfig --platform) - HIP_INCLUDE = -I${HIP_PATH}/../include BUILD_DIR ?= build -HIPCC = $(HIP_PATH)/bin/hipcc CPPFLAGS = -O3 LDFLAGS = -lm -lpthread @@ -27,11 +26,12 @@ ${GPUBURN_BIN}: ${GPUBURN_OBJ} ${BUILD_DIR}/%.o: %.cpp Makefile mkdir -p ${BUILD_DIR} - ${HIPCC} ${HIP_INCLUDE} ${CPPFLAGS} -c -o $@ $< + ${HIPCC} ${HIP_INCLUDE} ${CPPFLAGS} -c -o $@ $< run: itburn + itburn: - HCC_LAZYINIT=ON ${GPUBURN_BIN} + HCC_LAZYINIT=ON $(shell pwd)/${GPUBURN_BIN} clean: - rm -rf ${BUILD_DIR} + rm -vrf ${BUILD_DIR} diff --git a/mini-nbody/cuda/shmoo-cuda-nbody-block.sh b/mini-nbody/cuda/shmoo-cuda-nbody-block.sh index 0eb4825..5479000 100755 --- a/mini-nbody/cuda/shmoo-cuda-nbody-block.sh +++ b/mini-nbody/cuda/shmoo-cuda-nbody-block.sh @@ -1,14 +1,10 @@ -SRC=nbody-block.cu -EXE=nbody-block +#!/bin/bash -nvcc -arch=sm_35 -ftz=true -I../ -o $EXE $SRC -DSHMOO - -echo $EXE +nvcc -arch=sm_35 -ftz=true -I../ -DSHMOO -o nbody-block nbody-block.cu K=1024 -for i in {1..10} -do - ./$EXE $K +for i in {1..10}; do + echo "$(pwd)/nbody-block" $K + ./nbody-block $K K=$(($K*2)) done - diff --git a/mini-nbody/cuda/shmoo-cuda-nbody-ftz.sh b/mini-nbody/cuda/shmoo-cuda-nbody-ftz.sh index 8263feb..8961357 100755 --- a/mini-nbody/cuda/shmoo-cuda-nbody-ftz.sh +++ b/mini-nbody/cuda/shmoo-cuda-nbody-ftz.sh @@ -1,14 +1,10 @@ -SRC=nbody-soa.cu -EXE=nbody-ftz +#!/bin/bash -nvcc -arch=sm_35 -ftz=true -I../ -o $EXE $SRC -DSHMOO - -echo $EXE +nvcc -arch=sm_35 -ftz=true -I../ -DSHMOO -o nbody-ftz nbody-soa.cu K=1024 -for i in {1..10} -do - ./$EXE $K +for i in {1..10}; do + echo "$(pwd)/nbody-ftz" $K + ./nbody-ftz $K K=$(($K*2)) done - diff --git a/mini-nbody/cuda/shmoo-cuda-nbody-orig.sh b/mini-nbody/cuda/shmoo-cuda-nbody-orig.sh index a0d5b4c..6c8d7b7 100755 --- a/mini-nbody/cuda/shmoo-cuda-nbody-orig.sh +++ b/mini-nbody/cuda/shmoo-cuda-nbody-orig.sh @@ -1,14 +1,10 @@ -SRC=nbody-orig.cu -EXE=nbody-orig +#!/bin/bash -nvcc -arch=sm_35 -I../ -DSHMOO -o $EXE $SRC - -echo $EXE +nvcc -arch=sm_35 -I../ -DSHMOO -o nbody-orig nbody-orig.cu K=1024 -for i in {1..10} -do - ./$EXE $K +for i in {1..10}; do + echo "$(pwd)/nbody-orig" $K + ./nbody-orig $K K=$(($K*2)) done - diff --git a/mini-nbody/cuda/shmoo-cuda-nbody-soa.sh b/mini-nbody/cuda/shmoo-cuda-nbody-soa.sh index 5a6e5d7..647d002 100755 --- a/mini-nbody/cuda/shmoo-cuda-nbody-soa.sh +++ b/mini-nbody/cuda/shmoo-cuda-nbody-soa.sh @@ -1,14 +1,10 @@ -SRC=nbody-soa.cu -EXE=nbody-soa +#!/bin/bash -nvcc -arch=sm_35 -I../ -DSHMOO -o $EXE $SRC - -echo $EXE +nvcc -arch=sm_35 -I../ -DSHMOO -o nbody-soa nbody-soa.cu K=1024 -for i in {1..10} -do - ./$EXE $K +for i in {1..10}; do + echo "$(pwd)/nbody-soa" $K + ./nbody-soa $K K=$(($K*2)) done - diff --git a/mini-nbody/cuda/shmoo-cuda-nbody-unroll.sh b/mini-nbody/cuda/shmoo-cuda-nbody-unroll.sh index fb12c54..be6794a 100755 --- a/mini-nbody/cuda/shmoo-cuda-nbody-unroll.sh +++ b/mini-nbody/cuda/shmoo-cuda-nbody-unroll.sh @@ -1,14 +1,10 @@ -SRC=nbody-unroll.cu -EXE=nbody-unroll +#!/bin/bash -nvcc -arch=sm_35 -ftz=true -I../ -o $EXE $SRC -DSHMOO - -echo $EXE +nvcc -arch=sm_35 -ftz=true -I../ -DSHMOO -o nbody-unroll nbody-unroll.cu K=1024 -for i in {1..10} -do - ./$EXE $K +for i in {1..10}; do + echo "$(pwd)/nbody-unroll" $K + ./nbody-unroll $K K=$(($K*2)) done - diff --git a/mini-nbody/hip/.gitignore b/mini-nbody/hip/.gitignore new file mode 100644 index 0000000..4d913f8 --- /dev/null +++ b/mini-nbody/hip/.gitignore @@ -0,0 +1,3 @@ +nbody-block +nbody-orig +nbody-soa diff --git a/mini-nbody/hip/HIP-nbody-block.sh b/mini-nbody/hip/HIP-nbody-block.sh index 65640ab..5d8c670 100755 --- a/mini-nbody/hip/HIP-nbody-block.sh +++ b/mini-nbody/hip/HIP-nbody-block.sh @@ -1,40 +1,29 @@ -#Hipify the blocked cuda source code to hip compatible code -#hipify nbody-block.cu > nbody-block.cpp -#Manually add the first argument onto the kernel argument list -#void bodyForce(Body *p, float dt, int n) //before modification -#void bodyForce(hipLaunchParm lp, Body *p, float dt, int n) //after modification +#!/bin/bash -#compile the hipified source code into executable -if [ -f nbody-block ] -then - rm nbody-block -fi - -if [ -z "$HIP_PATH" ] -then - -if [ -d /opt/rocm/hip ] -then - HIP_PATH=/opt/rocm/hip -else - HIP_PATH=/opt/rocm +if ! [ -f nbody-block.cpp ]; then + echo "Hipify the blocked cuda source code to hip compatible code" + # Manually add the first argument onto the kernel argument list + hipify nbody-block.cu | sed -e 's/^void bodyForce\(Body /void bodyForce(hipLaunchParm lp, Body/' > nbody-block.cpp fi +HIPCC="$(command -v hipcc)" +if ! [ -x "${HIPCC}" ]; then + if [ -z "${HIP_PATH}" ]; then + if [ -d /opt/rocm/hip ]; then + HIP_PATH=/opt/rocm/hip + else + HIP_PATH=/opt/rocm + fi + HIPCC="${HIP_PATH}/bin/hipcc" + fi fi -echo hipcc -I../ -DSHMOO nbody-block.cpp -o nbody-block -$HIP_PATH/bin/hipcc -I../ -DSHMOO nbody-block.cpp -o nbody-block +echo hipcc -I../ -DSHMOO -o nbody-block nbody-block.cpp +"${HIPCC}" -I../ -DSHMOO -o nbody-block nbody-block.cpp -#To print our more details, remove DSHMOO flag -#hipcc -I../ nbody-block.cpp -o nbody-block - -#execute the program -EXE=nbody-block K=1024 -for i in {1..8} -do - echo ./$EXE $K - ./$EXE $K +for i in {1..8}; do + echo "$(pwd)/nbody-block" $K + ./nbody-block $K K=$(($K*2)) done - diff --git a/mini-nbody/hip/HIP-nbody-orig.sh b/mini-nbody/hip/HIP-nbody-orig.sh index 5cdfdca..d4c52b3 100755 --- a/mini-nbody/hip/HIP-nbody-orig.sh +++ b/mini-nbody/hip/HIP-nbody-orig.sh @@ -1,38 +1,28 @@ -#Hipify the original cuda source code to hip compatible code -#hipify nbody-orig.cu > nbody-orig.cpp +#!/bin/bash -#compile the hipified source code into executable -if [ -f nbody-orig ] -then - rm nbody-orig -fi - -if [ -z "$HIP_PATH" ] -then - -if [ -d /opt/rocm/hip ] -then - HIP_PATH=/opt/rocm/hip -else - HIP_PATH=/opt/rocm +if ! [ -f nbody-orig.cpp ]; then + echo "Hipify the original cuda source code to hip compatible code" + hipify nbody-orig.cu > nbody-orig.cpp fi +HIPCC="$(command -v hipcc)" +if ! [ -x "${HIPCC}" ]; then + if [ -z "${HIP_PATH}" ]; then + if [ -d /opt/rocm/hip ]; then + HIP_PATH=/opt/rocm/hip + else + HIP_PATH=/opt/rocm + fi + HIPCC="${HIP_PATH}/bin/hipcc" + fi fi -echo hipcc -I../ -DSHMOO nbody-orig.cpp -o nbody-orig -$HIP_PATH/bin/hipcc -I../ -DSHMOO nbody-orig.cpp -o nbody-orig +echo hipcc -I../ -DSHMOO -o nbody-orig nbody-orig.cpp +"${HIPCC}" -I../ -DSHMOO -o nbody-orig nbody-orig.cpp -#To print our more details, remove flag -#hipcc -I../ nbody-orig.cpp -o nbody-orig - -#execute the program - -EXE=nbody-orig K=1024 -for i in {1..10} -do - echo ./$EXE $K - ./$EXE $K +for i in {1..10}; do + echo "$(pwd)/nbody-orig" $K + ./nbody-orig $K K=$(($K*2)) done - diff --git a/mini-nbody/hip/HIP-nbody-soa.sh b/mini-nbody/hip/HIP-nbody-soa.sh index e7861fd..cb15071 100755 --- a/mini-nbody/hip/HIP-nbody-soa.sh +++ b/mini-nbody/hip/HIP-nbody-soa.sh @@ -1,40 +1,29 @@ -#Hipify the soa cuda source code to hip compatible code -#hipify nbody-soa.cu > nbody-soa.cpp -#Manually add the first argument onto the kernel argument list -#void bodyForce(Body *p, float dt, int n) //before modification -#void bodyForce(hipLaunchParm lp, Body *p, float dt, int n) //after modification +#!/bin/bash -#compile the hipified source code into executable -if [ -f nbody-soa ] -then - rm nbody-soa -fi - -if [ -z "$HIP_PATH" ] -then - -if [ -d /opt/rocm/hip ] -then - HIP_PATH=/opt/rocm/hip -else - HIP_PATH=/opt/rocm +if ! [ -f nbody-soa.cpp ]; then + echo "Hipify the original cuda source code to hip compatible code" + # Manually add the first argument onto the kernel argument list + hipify nbody-soa.cu | sed -e 's/^void bodyForce\(Body /void bodyForce(hipLaunchParm lp, Body/' > nbody-soa.cpp fi +HIPCC="$(command -v hipcc)" +if ! [ -x "${HIPCC}" ]; then + if [ -z "${HIP_PATH}" ]; then + if [ -d /opt/rocm/hip ]; then + HIP_PATH=/opt/rocm/hip + else + HIP_PATH=/opt/rocm + fi + HIPCC="${HIP_PATH}/bin/hipcc" + fi fi -echo hipcc -I../ -DSHMOO nbody-soa.cpp -o nbody-soa -$HIP_PATH/bin/hipcc -I../ -DSHMOO nbody-soa.cpp -o nbody-soa +echo hipcc -I../ -DSHMOO -o nbody-soa nbody-soa.cpp +"${HIPCC}" -I../ -DSHMOO -o nbody-soa nbody-soa.cpp -#To print our more details, remove DSHMOO flag -#hipcc -I../ nbody-soa.cpp -o nbody-soa - -#execute the program -EXE=nbody-soa K=1024 -for i in {1..8} -do - echo ./$EXE $K - ./$EXE $K +for i in {1..8}; do + echo "$(pwd)/nbody-soa" $K + ./nbody-soa $K K=$(($K*2)) done - diff --git a/mini-nbody/mic/shmoo-mic-nbody-align.sh b/mini-nbody/mic/shmoo-mic-nbody-align.sh index 83f40ca..e8af2f4 100755 --- a/mini-nbody/mic/shmoo-mic-nbody-align.sh +++ b/mini-nbody/mic/shmoo-mic-nbody-align.sh @@ -1,23 +1,10 @@ -SRC=nbody-align.c -EXE=nbody-align-mic -MICROOT=/shared/apps/rhel-6.2/intel/ics-2013/composerxe/lib/mic -MIC=mic0 -if [ $# -gt 0 ] - then - MIC=$1 -fi +#!/bin/bash -icc -std=c99 -openmp -mmic -fimf-domain-exclusion=8 -DSHMOO -I../ -o $EXE $SRC - -scp $EXE $MIC:~/ -scp $MICROOT/libiomp5.so $MIC:~/ - -echo $EXE +icc -std=c99 -openmp -mmic -fimf-domain-exclusion=8 -DSHMOO -I../ -o nbody-align-mic nbody-align.c K=1024 -for i in {1..10} -do - ssh $MIC "export LD_LIBRARY_PATH=~/:$LD_LIBRARY_PATH; ./$EXE $K" +for i in {1..10}; do + echo "$(pwd)/nbody-align-mic" $K + ./nbody-align-mic $K K=$(($K*2)) done - diff --git a/mini-nbody/mic/shmoo-mic-nbody-block.sh b/mini-nbody/mic/shmoo-mic-nbody-block.sh index 28d2869..97a1493 100755 --- a/mini-nbody/mic/shmoo-mic-nbody-block.sh +++ b/mini-nbody/mic/shmoo-mic-nbody-block.sh @@ -1,23 +1,10 @@ -SRC=nbody-block.c -EXE=nbody-block-mic -MICROOT=/shared/apps/rhel-6.2/intel/ics-2013/composerxe/lib/mic -MIC=mic0 -if [ $# -gt 0 ] - then - MIC=$1 -fi +#!/bin/bash -icc -std=c99 -openmp -mmic -fimf-domain-exclusion=8 -DSHMOO -I../ -o $EXE $SRC - -scp $EXE $MIC:~/ -scp $MICROOT/libiomp5.so $MIC:~/ - -echo $EXE +icc -std=c99 -openmp -mmic -fimf-domain-exclusion=8 -DSHMOO -I../ -o nbody-block-mic nbody-block.c K=1024 -for i in {1..10} -do - ssh $MIC "export LD_LIBRARY_PATH=~/:$LD_LIBRARY_PATH; ./$EXE $K" +for i in {1..10}; do + echo "$(pwd)/nbody-block-mic" $K + ./nbody-block-mic $K K=$(($K*2)) done - diff --git a/mini-nbody/mic/shmoo-mic-nbody-ftz.sh b/mini-nbody/mic/shmoo-mic-nbody-ftz.sh index 256d00a..4d2db9e 100755 --- a/mini-nbody/mic/shmoo-mic-nbody-ftz.sh +++ b/mini-nbody/mic/shmoo-mic-nbody-ftz.sh @@ -1,23 +1,10 @@ -SRC=nbody-soa.c -EXE=nbody-ftz-mic -MICROOT=/shared/apps/rhel-6.2/intel/ics-2013/composerxe/lib/mic -MIC=mic0 -if [ $# -gt 0 ] - then - MIC=$1 -fi +#!/bin/bash -icc -std=c99 -openmp -mmic -fimf-domain-exclusion=8 -DSHMOO -I../ -o $EXE $SRC - -scp $EXE $MIC:~/ -scp $MICROOT/libiomp5.so $MIC:~/ - -echo $EXE +icc -std=c99 -openmp -mmic -fimf-domain-exclusion=8 -DSHMOO -I../ -o nbody-ftz-mic nbody-soa.c K=1024 -for i in {1..10} -do - ssh $MIC "export LD_LIBRARY_PATH=~/:$LD_LIBRARY_PATH; ./$EXE $K" +for i in {1..10}; do + echo "$(pwd)/nbody-ftz-mic" $K + ./nbody-ftz-mic $K K=$(($K*2)) done - diff --git a/mini-nbody/mic/shmoo-mic-nbody-orig.sh b/mini-nbody/mic/shmoo-mic-nbody-orig.sh index 4f010d0..4b0f3f5 100755 --- a/mini-nbody/mic/shmoo-mic-nbody-orig.sh +++ b/mini-nbody/mic/shmoo-mic-nbody-orig.sh @@ -1,23 +1,10 @@ -SRC=../nbody-orig.c -EXE=nbody-orig-mic -MICROOT=/shared/apps/rhel-6.2/intel/ics-2013/composerxe/lib/mic -MIC=mic0 -if [ $# -gt 0 ] - then - MIC=$1 -fi +#!/bin/bash -icc -std=c99 -openmp -mmic -DSHMOO -o $EXE $SRC - -scp $EXE $MIC:~/ -scp $MICROOT/libiomp5.so $MIC:~/ - -echo $EXE +icc -std=c99 -openmp -mmic -DSHMOO -o nbody-orig-mic ../nbody-orig.c K=1024 -for i in {1..10} -do - ssh $MIC "export LD_LIBRARY_PATH=~/:$LD_LIBRARY_PATH; ./$EXE $K" +for i in {1..10}; do + echo "$(pwd)/nbody-orig-mic" $K + ./nbody-orig-mic $K K=$(($K*2)) done - diff --git a/mini-nbody/mic/shmoo-mic-nbody-soa.sh b/mini-nbody/mic/shmoo-mic-nbody-soa.sh index f50674c..76910a7 100755 --- a/mini-nbody/mic/shmoo-mic-nbody-soa.sh +++ b/mini-nbody/mic/shmoo-mic-nbody-soa.sh @@ -1,23 +1,10 @@ -SRC=nbody-soa.c -EXE=nbody-soa-mic -MICROOT=/shared/apps/rhel-6.2/intel/ics-2013/composerxe/lib/mic -MIC=mic0 -if [ $# -gt 0 ] - then - MIC=$1 -fi +#!/bin/bash -icc -std=c99 -openmp -mmic -DSHMOO -I../ -o $EXE $SRC - -scp $EXE $MIC:~/ -scp $MICROOT/libiomp5.so $MIC:~/ - -echo $EXE +icc -std=c99 -openmp -mmic -DSHMOO -I../ -o nbody-soa-mic nbody-soa.c K=1024 -for i in {1..10} -do - ssh $MIC "export LD_LIBRARY_PATH=~/:$LD_LIBRARY_PATH; ./$EXE $K" +for i in {1..10}; do + echo "$(pwd)/nbody-soa-mic" $K + ./nbody-soa-mic $K K=$(($K*2)) done - diff --git a/mini-nbody/shmoo-cpu-nbody.sh b/mini-nbody/shmoo-cpu-nbody.sh index a06358f..aadde80 100755 --- a/mini-nbody/shmoo-cpu-nbody.sh +++ b/mini-nbody/shmoo-cpu-nbody.sh @@ -1,13 +1,10 @@ -SRC=nbody.c -EXE=nbody -gcc -std=c99 -O3 -fopenmp -DSHMOO -o $EXE $SRC -lm +#!/bin/bash -echo $EXE +gcc -std=c99 -O3 -fopenmp -DSHMOO -o nbody nbody.c -lm K=1024 -for i in {1..10} -do - ./$EXE $K +for i in {1..10}; do + echo "$(pwd)/nbody" $K + ./nbody $K K=$(($K*2)) done - diff --git a/openmp-helloworld/.gitignore b/openmp-helloworld/.gitignore new file mode 100644 index 0000000..087c181 --- /dev/null +++ b/openmp-helloworld/.gitignore @@ -0,0 +1,2 @@ +build/ +openmp_helloworld diff --git a/openmp-helloworld/Makefile b/openmp-helloworld/Makefile index 585fb00..119d9b3 100644 --- a/openmp-helloworld/Makefile +++ b/openmp-helloworld/Makefile @@ -1,27 +1,15 @@ HIP_PATH?= $(wildcard /opt/rocm) HIPCC=$(HIP_PATH)/bin/hipcc -CXX=$(HIPCC) -CXXFLAGS =-fopenmp +CXXFLAGS:=-fopenmp -SOURCES = openmp_helloworld.cpp - -EXECUTABLE=./openmp_helloworld.exe +openmp_helloworld: openmp_helloworld.cpp + $(HIPCC) $(CXXFLAGS) -o $@ $^ .PHONY: test +test: openmp_helloworld + $(shell pwd)/openmp_helloworld - -all: $(EXECUTABLE) test - - -$(EXECUTABLE): - $(CXX) $(CXXFLAGS) $(SOURCES) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - +.PHONY: clean clean: - rm -f $(EXECUTABLE) *.o - + rm -f openmp_helloworld *.o diff --git a/reduction/.gitignore b/reduction/.gitignore new file mode 100644 index 0000000..a2401ba --- /dev/null +++ b/reduction/.gitignore @@ -0,0 +1 @@ +reduction diff --git a/reduction/Makefile b/reduction/Makefile index dad6ff1..fd6fe4f 100644 --- a/reduction/Makefile +++ b/reduction/Makefile @@ -4,13 +4,8 @@ HIPCC=$(HIP_PATH)/bin/hipcc CXXFLAGS += -std=c++11 -O3 reduction: reduction.cpp -ifeq ($(shell which $(HIPCC) > /dev/null; echo $$?), 0) - ${HIPCC} ${CXXFLAGS} -o $@ $^ -else - $(error "Cannot find $(HIPCC), please install HIP toolkit") -endif + ${HIPCC} ${CXXFLAGS} -o $@ $^ .PHONY: clean - clean: - rm -f reduction *.o + rm -vf reduction *.o diff --git a/reduction/run.sh b/reduction/run.sh index 9e96097..143b5be 100755 --- a/reduction/run.sh +++ b/reduction/run.sh @@ -1,10 +1,9 @@ -#execute the program -EXE=reduction -K=1024*1024*4 -for i in {1..8} -do - echo ./$EXE $K - ./$EXE $K +#!/bin/bash + +K=$((1024*1024*4)) +for i in {1..8}; do + echo + echo "$(pwd)/reduction" $K + ./reduction $K K=$(($K*2)) done - diff --git a/rtm8/.gitignore b/rtm8/.gitignore new file mode 100644 index 0000000..c29d568 --- /dev/null +++ b/rtm8/.gitignore @@ -0,0 +1,3 @@ +rtm8_hip +rtm8_cuda +rtm8_fotran diff --git a/rtm8/Makefile b/rtm8/Makefile index a61fcba..4f5ee99 100644 --- a/rtm8/Makefile +++ b/rtm8/Makefile @@ -3,14 +3,37 @@ HIPCC=$(HIP_PATH)/bin/hipcc CXXFLAGS += -std=c++11 -O3 -rtm8: rtm8.cpp -ifeq ($(shell which $(HIPCC) > /dev/null; echo $$?), 0) - ${HIPCC} ${CXXFLAGS} -o $@ $^ -else - $(error "Cannot find $(HIPCC), please install HIP toolkit") -endif +rtm8_hip: rtm8.cpp + ${HIPCC} ${CXXFLAGS} -o $@ $^ -.PHONY: clean +rtm8_cuda: rtm8.cu + nvcc -O3 rtm8.cu -o rtm8_cuda + + +FC:=gfortran +FCFLAGS:=-02 + +mysecond.o: mysecond.c + $(CC) $(CFLAGS) -DUNDERSCORE -c -o mysecond.o mysecond.c + +rtm8_fortran: rtm8.f mysecond.o + $(FC) $(FCFLAGS) -o $@ rtm8.f mysecond.o +.PHONY: test +test: run_hip + +.PHONY: run_hip +run_hip: rtm8_hip + $(shell pwd)/rtm8_hip + +.PHONY: run_cuda +run_cuda: rtm8_cuda + $(shell pwd)/rtm8_cuda + +.PHONY: run_fortran +run_fortran: rtm8_fortran + $(shell pwd)/rtm8_fortran + +.PHONY: clean clean: - rm -f rtm8 *.o + rm -vf rtm8_hip rtm8_cuda rtm8_fortran *.o diff --git a/rtm8/README.md b/rtm8/README.md index 9230350..5828db7 100644 --- a/rtm8/README.md +++ b/rtm8/README.md @@ -1,10 +1,11 @@ -rtm8 is an example ported from an Fortran algorithm contributed by Morton, Scott from HESS company. +rtm8 is an example ported from an Fortran algorithm contributed by +Morton, Scott from HESS company. + The original Fortran version: - ./build_fortran.sh - ./rtm8_fortran + make run_fortran + The HIP version: - ./build_hip.sh - ./rtm8_hip + make run_hip + The CUDA version: - ./build_cuda.sh - ./rtm8_cuda + make run_cuda diff --git a/rtm8/build_cuda.sh b/rtm8/build_cuda.sh deleted file mode 100755 index 562031a..0000000 --- a/rtm8/build_cuda.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -if [ -f "rtm8_cuda" ] -then - rm rtm8_cuda -fi -echo "nvcc -O3 rtm8.cpp -o rtm8_cuda" -nvcc -O3 rtm8.cu -o rtm8_cuda diff --git a/rtm8/build_fortran.sh b/rtm8/build_fortran.sh deleted file mode 100755 index 6996202..0000000 --- a/rtm8/build_fortran.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -if [ -f "rtm8_fortran" ] -then - rm rtm8_fortran -fi -gfortran -c rtm8.f -gcc -c -DUNDERSCORE mysecond.c -gfortran -o rtm8_fortran rtm8.o mysecond.o diff --git a/rtm8/build_hip.sh b/rtm8/build_hip.sh deleted file mode 100755 index 07b64ea..0000000 --- a/rtm8/build_hip.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -if [ -z "$HIP_PATH" ] -then - -if [ -d /opt/rocm/hip ] -then - HIP_PATH=/opt/rocm/hip -else - HIP_PATH=/opt/rocm -fi - -fi - -if [ -f "rtm8_hip" ] -then - rm rtm8_hip -fi - -echo "hipcc -std=c++11 -O3 -o rtm8_hip rtm8.cpp" -$HIP_PATH/bin/hipcc -std=c++11 -O3 -o rtm8_hip rtm8.cpp - diff --git a/strided-access/.gitignore b/strided-access/.gitignore new file mode 100644 index 0000000..fe7cd6d --- /dev/null +++ b/strided-access/.gitignore @@ -0,0 +1 @@ +strided-access diff --git a/strided-access/Makefile b/strided-access/Makefile index 550e074..19938cb 100644 --- a/strided-access/Makefile +++ b/strided-access/Makefile @@ -3,14 +3,13 @@ HIPCC=$(HIP_PATH)/bin/hipcc CXXFLAGS += -std=c++11 -O3 -strided-access: benchmark-hip.cpp -ifeq ($(shell which $(HIPCC) > /dev/null; echo $$?), 0) - ${HIPCC} ${CXXFLAGS} -o $@ $^ -else - $(error "Cannot find $(HIPCC), please install HIP toolkit") -endif +strided-access: benchmark-hip.cpp benchmark-utils.hpp + ${HIPCC} ${CXXFLAGS} -o $@ benchmark-hip.cpp -.PHONY: clean +.PHONY: test +test: strided-access + $(shell pwd)/strided-access +.PHONY: clean clean: - rm -f strided-access *.o + rm -vf strided-access *.o diff --git a/test_all.sh b/test_all.sh index 0dff1c8..adc5cb1 100755 --- a/test_all.sh +++ b/test_all.sh @@ -2,84 +2,95 @@ : ${HIP_PLATFORM:="hcc"} -# vector_add echo echo "==== vectorAdd ====" +( cd vectorAdd make clean -make -cd .. +make test +) -# gpu-burn echo echo "==== gpu-burn ====" +( cd gpu-burn make clean -make -./build/gpuburn-hip -t 5 -cd .. +make && ./build/gpuburn-hip -t 5 +) -# strided-access echo echo "==== strided-access ====" +( cd strided-access make clean -make -./strided-access -cd .. +make test +) -# rtm8 echo echo "==== rtm8 ====" +( cd rtm8 -./build_hip.sh -./rtm8_hip -cd .. +make clean +make test +) -# reduction echo echo "==== reduction ====" +( cd reduction make clean -make +make reduction ./run.sh -cd .. +) -# mini-nbody echo echo "==== mini-nbody ====" +( cd mini-nbody/hip ./HIP-nbody-orig.sh ./HIP-nbody-soa.sh ./HIP-nbody-block.sh -cd ../.. +) -# add4 echo echo "==== add4 ====" +( cd add4 -./buildit.sh -./runhip.sh -cd .. +make clean +make test +) -# cuda-stream echo echo "==== cuda-stream ====" +( cd cuda-stream make clean -make -./stream -cd .. +make test +) -# openmp-helloworld echo echo "==== OpenMP Hello World ====" +( cd openmp-helloworld mkdir -p build cd build cmake .. make ./test_openmp_helloworld -cd ../.. +) +echo +echo "==== HIP-Examples-Applications ====" +( +cd HIP-Examples-Applications +for SUBDIR in BinomialOption BitonicSort dct dwtHaar1D FastWalshTransform FloydWarshall HelloWorld Histogram MatrixMultiplication PrefixSum RecursiveGaussian SimpleConvolution; do + echo + echo "==== HIP-Examples-Applications/${SUBDIR} ====" + ( + cd "${SUBDIR}" + make clean + make test + ) +done +) diff --git a/vectorAdd/.gitignore b/vectorAdd/.gitignore new file mode 100644 index 0000000..90201cc --- /dev/null +++ b/vectorAdd/.gitignore @@ -0,0 +1 @@ +vectoradd diff --git a/vectorAdd/Makefile b/vectorAdd/Makefile index a412c3d..92b48b5 100644 --- a/vectorAdd/Makefile +++ b/vectorAdd/Makefile @@ -1,30 +1,15 @@ HIP_PATH?= $(wildcard /opt/rocm) HIPCC=$(HIP_PATH)/bin/hipcc -SOURCES = vectoradd_hip.cpp -OBJECTS = $(SOURCES:.cpp=.o) +CXXFLAGS += -std=c++11 -O2 -EXECUTABLE=./vectoradd_hip.exe +vectoradd: vectoradd_hip.cpp + $(HIPCC) ${CXXFLAGS} -o $@ $^ .PHONY: test +test: vectoradd + $(shell pwd)/vectoradd - -all: $(EXECUTABLE) test - -CXXFLAGS =-g - -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - +.PHONY: clean clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o + rm -vf vectoradd *.o