From 11372c90049b6dbcfd786656e819118d79a41107 Mon Sep 17 00:00:00 2001 From: Satyanvesh Dittakavi Date: Wed, 8 Mar 2023 11:40:23 +0000 Subject: [PATCH 1/2] SWDEV-385161 - Remove env vars such as HIP_PATH, HSA_PATH etc --- .../BinomialOption/Makefile | 11 +---------- .../BitonicSort/Makefile | 11 +---------- .../FastWalshTransform/Makefile | 11 +---------- .../FloydWarshall/Makefile | 11 +---------- HIP-Examples-Applications/HelloWorld/Makefile | 9 +-------- HIP-Examples-Applications/Histogram/Makefile | 11 +---------- .../MatrixMultiplication/Makefile | 11 +---------- HIP-Examples-Applications/PrefixSum/Makefile | 11 +---------- .../RecursiveGaussian/Makefile | 11 +---------- .../SimpleConvolution/Makefile | 11 +---------- HIP-Examples-Applications/dct/Makefile | 11 +---------- HIP-Examples-Applications/dwtHaar1D/Makefile | 11 +---------- add4/Makefile | 6 +----- common/hip.all.make | 4 ++-- common/hip.prologue.make | 19 +++++-------------- cuda-stream/Makefile | 6 +----- gpu-burn/Makefile | 13 +++---------- mini-nbody/hip/HIP-nbody-block.sh | 15 +-------------- mini-nbody/hip/HIP-nbody-orig.sh | 15 +-------------- mini-nbody/hip/HIP-nbody-soa.sh | 15 +-------------- openmp-helloworld/Makefile | 7 +------ reduction/Makefile | 6 +----- rtm8/Makefile | 6 +----- rtm8/build_hip.sh | 16 +--------------- strided-access/Makefile | 6 +----- vectorAdd/Makefile | 10 +--------- 26 files changed, 33 insertions(+), 241 deletions(-) diff --git a/HIP-Examples-Applications/BinomialOption/Makefile b/HIP-Examples-Applications/BinomialOption/Makefile index 2f11d87..ea6f2dd 100644 --- a/HIP-Examples-Applications/BinomialOption/Makefile +++ b/HIP-Examples-Applications/BinomialOption/Makefile @@ -1,11 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc +HIPCC=/opt/rocm/bin/hipcc SOURCES = BinomialOption.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -32,5 +25,3 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/HIP-Examples-Applications/BitonicSort/Makefile b/HIP-Examples-Applications/BitonicSort/Makefile index 6c62bad..6582c83 100644 --- a/HIP-Examples-Applications/BitonicSort/Makefile +++ b/HIP-Examples-Applications/BitonicSort/Makefile @@ -1,11 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc +HIPCC=/opt/rocm/bin/hipcc SOURCES = BitonicSort.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -32,5 +25,3 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/HIP-Examples-Applications/FastWalshTransform/Makefile b/HIP-Examples-Applications/FastWalshTransform/Makefile index ee7c21a..f2ccb83 100644 --- a/HIP-Examples-Applications/FastWalshTransform/Makefile +++ b/HIP-Examples-Applications/FastWalshTransform/Makefile @@ -1,11 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc +HIPCC=/opt/rocm/bin/hipcc SOURCES = FastWalshTransform.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -32,5 +25,3 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/HIP-Examples-Applications/FloydWarshall/Makefile b/HIP-Examples-Applications/FloydWarshall/Makefile index 30a5f98..4a8f1bc 100644 --- a/HIP-Examples-Applications/FloydWarshall/Makefile +++ b/HIP-Examples-Applications/FloydWarshall/Makefile @@ -1,11 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc +HIPCC=/opt/rocm/bin/hipcc SOURCES = FloydWarshall.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -32,5 +25,3 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/HIP-Examples-Applications/HelloWorld/Makefile b/HIP-Examples-Applications/HelloWorld/Makefile index 216762a..c366ebe 100644 --- a/HIP-Examples-Applications/HelloWorld/Makefile +++ b/HIP-Examples-Applications/HelloWorld/Makefile @@ -1,9 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc +HIPCC=/opt/rocm/bin/hipcc TARGET=hcc @@ -32,5 +27,3 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/HIP-Examples-Applications/Histogram/Makefile b/HIP-Examples-Applications/Histogram/Makefile index 836b6d0..ce0361d 100644 --- a/HIP-Examples-Applications/Histogram/Makefile +++ b/HIP-Examples-Applications/Histogram/Makefile @@ -1,11 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc +HIPCC=/opt/rocm/bin/hipcc SOURCES = Histogram.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -32,5 +25,3 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/HIP-Examples-Applications/MatrixMultiplication/Makefile b/HIP-Examples-Applications/MatrixMultiplication/Makefile index 8b89dd4..418c447 100644 --- a/HIP-Examples-Applications/MatrixMultiplication/Makefile +++ b/HIP-Examples-Applications/MatrixMultiplication/Makefile @@ -1,11 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc +HIPCC=/opt/rocm/bin/hipcc SOURCES = MatrixMultiplication.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -32,5 +25,3 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/HIP-Examples-Applications/PrefixSum/Makefile b/HIP-Examples-Applications/PrefixSum/Makefile index 2119cb5..4967cea 100644 --- a/HIP-Examples-Applications/PrefixSum/Makefile +++ b/HIP-Examples-Applications/PrefixSum/Makefile @@ -1,11 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc +HIPCC=/opt/rocm/bin/hipcc SOURCES = PrefixSum.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -32,5 +25,3 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/HIP-Examples-Applications/RecursiveGaussian/Makefile b/HIP-Examples-Applications/RecursiveGaussian/Makefile index defa4c9..7a34e3c 100644 --- a/HIP-Examples-Applications/RecursiveGaussian/Makefile +++ b/HIP-Examples-Applications/RecursiveGaussian/Makefile @@ -1,11 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc +HIPCC=/opt/rocm/bin/hipcc SOURCES = RecursiveGaussian.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -32,5 +25,3 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/HIP-Examples-Applications/SimpleConvolution/Makefile b/HIP-Examples-Applications/SimpleConvolution/Makefile index b8099e7..7306a43 100644 --- a/HIP-Examples-Applications/SimpleConvolution/Makefile +++ b/HIP-Examples-Applications/SimpleConvolution/Makefile @@ -1,11 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc +HIPCC=/opt/rocm/bin/hipcc SOURCES = SimpleConvolution.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -32,5 +25,3 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/HIP-Examples-Applications/dct/Makefile b/HIP-Examples-Applications/dct/Makefile index 03a48a4..9375383 100644 --- a/HIP-Examples-Applications/dct/Makefile +++ b/HIP-Examples-Applications/dct/Makefile @@ -1,11 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc +HIPCC=/opt/rocm/bin/hipcc SOURCES = dct.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -32,5 +25,3 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/HIP-Examples-Applications/dwtHaar1D/Makefile b/HIP-Examples-Applications/dwtHaar1D/Makefile index b196ca3..c975a19 100644 --- a/HIP-Examples-Applications/dwtHaar1D/Makefile +++ b/HIP-Examples-Applications/dwtHaar1D/Makefile @@ -1,11 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc +HIPCC=/opt/rocm/bin/hipcc SOURCES = dwtHaar1D.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -32,5 +25,3 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/add4/Makefile b/add4/Makefile index a0c6826..f6fb705 100644 --- a/add4/Makefile +++ b/add4/Makefile @@ -4,11 +4,7 @@ all: gpu-stream-hip common.o: common.cpp common.h Makefile -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=/opt/rocm -endif -HIPCC=$(HIP_PATH)/bin/hipcc +HIPCC=/opt/rocm/bin/hipcc hip-stream.o : hip-stream.cpp $(HIPCC) $(CXXFLAGS) -c $< -o $@ diff --git a/common/hip.all.make b/common/hip.all.make index c6c8e5b..32d5fb7 100644 --- a/common/hip.all.make +++ b/common/hip.all.make @@ -1,2 +1,2 @@ -include $(HIP_PATH)/examples/common/hip.prologue.make -include $(HIP_PATH)/examples/common/hip.epilogue.make +include /opt/rocm/hip/examples/common/hip.prologue.make +include /opt/rocm/hip/examples/common/hip.epilogue.make diff --git a/common/hip.prologue.make b/common/hip.prologue.make index 2ce0db1..041e91b 100644 --- a/common/hip.prologue.make +++ b/common/hip.prologue.make @@ -1,14 +1,11 @@ -# 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 +# This file is designed to be included at beginning of 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) +HIP_PLATFORM=$(shell /opt/rocm/bin/hipconfig --compiler) # CUDA toolkit installation path CUDA_DIR?=/usr/local/cuda-7.5 @@ -25,13 +22,11 @@ endif # nvcc (7.5) can handle openmp though. # use OMPCC and OMP_FLAGS -HIPCC=$(HIP_PATH)/bin/hipcc -HIPLD=$(HIP_PATH)/bin/hipcc +HIPCC=/opt/rocm/bin/hipcc +HIPLD=/opt/rocm/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. @@ -55,15 +50,11 @@ 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 @@ -85,7 +76,7 @@ endif # $(HIPIFY) $< > $@ -KCFLAGS += $(OPT) -I$(HSA_PATH)/include -I$(HIP_PATH)/include -I$(GRID_LAUNCH_PATH) -I$(AM_PATH)/include +KCFLAGS += $(OPT) -I/opt/rocm/include -I/opt/rocm/hip/include -I$(GRID_LAUNCH_PATH) -I$(AM_PATH)/include %.o:: %.cpp $(HIPCC) $(HIPCC_FLAGS) $< -c -o $@ diff --git a/cuda-stream/Makefile b/cuda-stream/Makefile index fceec7d..170f4bc 100644 --- a/cuda-stream/Makefile +++ b/cuda-stream/Makefile @@ -1,8 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=/opt/rocm -endif -HIPCC=$(HIP_PATH)/bin/hipcc +HIPCC=/opt/rocm/bin/hipcc CXXFLAGS += -std=c++11 -O3 diff --git a/gpu-burn/Makefile b/gpu-burn/Makefile index 1419588..6f1c4a6 100644 --- a/gpu-burn/Makefile +++ b/gpu-burn/Makefile @@ -1,15 +1,8 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=/opt/rocm -endif - - -HCC_PATH ?= /opt/rocm/hcc -HIP_PLATFORM = $(shell $(HIP_PATH)/bin/hipconfig --platform) -HIP_INCLUDE = -I${HIP_PATH}/include -I${HCC_PATH}/include +HIP_PLATFORM = $(shell /opt/rocm/bin/hipconfig --platform) +HIP_INCLUDE = -I/opt/rocm/include BUILD_DIR ?= build -HIPCC = ${HIP_PATH}/bin/hipcc +HIPCC = /opt/rocm/bin/hipcc CPPFLAGS = -O3 LDFLAGS = -lm -lpthread diff --git a/mini-nbody/hip/HIP-nbody-block.sh b/mini-nbody/hip/HIP-nbody-block.sh index 65640ab..8b5c3d1 100755 --- a/mini-nbody/hip/HIP-nbody-block.sh +++ b/mini-nbody/hip/HIP-nbody-block.sh @@ -10,20 +10,8 @@ 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 -fi - -fi - echo hipcc -I../ -DSHMOO nbody-block.cpp -o nbody-block -$HIP_PATH/bin/hipcc -I../ -DSHMOO nbody-block.cpp -o nbody-block +/opt/rocm/bin/hipcc -I../ -DSHMOO nbody-block.cpp -o nbody-block #To print our more details, remove DSHMOO flag #hipcc -I../ nbody-block.cpp -o nbody-block @@ -37,4 +25,3 @@ do ./$EXE $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..4345423 100755 --- a/mini-nbody/hip/HIP-nbody-orig.sh +++ b/mini-nbody/hip/HIP-nbody-orig.sh @@ -7,20 +7,8 @@ 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 -fi - -fi - echo hipcc -I../ -DSHMOO nbody-orig.cpp -o nbody-orig -$HIP_PATH/bin/hipcc -I../ -DSHMOO nbody-orig.cpp -o nbody-orig +/opt/rocm/bin/hipcc -I../ -DSHMOO nbody-orig.cpp -o nbody-orig #To print our more details, remove flag #hipcc -I../ nbody-orig.cpp -o nbody-orig @@ -35,4 +23,3 @@ do ./$EXE $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..1b6f4f2 100755 --- a/mini-nbody/hip/HIP-nbody-soa.sh +++ b/mini-nbody/hip/HIP-nbody-soa.sh @@ -10,20 +10,8 @@ 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 -fi - -fi - echo hipcc -I../ -DSHMOO nbody-soa.cpp -o nbody-soa -$HIP_PATH/bin/hipcc -I../ -DSHMOO nbody-soa.cpp -o nbody-soa +/opt/rocm/bin/hipcc -I../ -DSHMOO nbody-soa.cpp -o nbody-soa #To print our more details, remove DSHMOO flag #hipcc -I../ nbody-soa.cpp -o nbody-soa @@ -37,4 +25,3 @@ do ./$EXE $K K=$(($K*2)) done - diff --git a/openmp-helloworld/Makefile b/openmp-helloworld/Makefile index f048d26..325b4be 100644 --- a/openmp-helloworld/Makefile +++ b/openmp-helloworld/Makefile @@ -1,9 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=/opt/rocm -endif - -HIPCC=$(HIP_PATH)/bin/hipcc +HIPCC=/opt/rocm/bin/hipcc CXX=$(HIPCC) CXXFLAGS =-fopenmp diff --git a/reduction/Makefile b/reduction/Makefile index d040156..b66d71b 100644 --- a/reduction/Makefile +++ b/reduction/Makefile @@ -1,8 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=/opt/rocm -endif -HIPCC=$(HIP_PATH)/bin/hipcc +HIPCC=/opt/rocm/bin/hipcc CXXFLAGS += -std=c++11 -O3 diff --git a/rtm8/Makefile b/rtm8/Makefile index f0d89ab..fba11d6 100644 --- a/rtm8/Makefile +++ b/rtm8/Makefile @@ -1,8 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=/opt/rocm -endif -HIPCC=$(HIP_PATH)/bin/hipcc +HIPCC=/opt/rocm/bin/hipcc CXXFLAGS += -std=c++11 -O3 diff --git a/rtm8/build_hip.sh b/rtm8/build_hip.sh index 4ccaa42..86f4871 100755 --- a/rtm8/build_hip.sh +++ b/rtm8/build_hip.sh @@ -1,24 +1,10 @@ #!/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 - -echo "Using HIP_PATH=$HIP_PATH" - 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 +/opt/rocm/bin/hipcc -std=c++11 -O3 -o rtm8_hip rtm8.cpp diff --git a/strided-access/Makefile b/strided-access/Makefile index 46fe9b8..3610177 100644 --- a/strided-access/Makefile +++ b/strided-access/Makefile @@ -1,8 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=/opt/rocm -endif -HIPCC=$(HIP_PATH)/bin/hipcc +HIPCC=/opt/rocm/bin/hipcc CXXFLAGS += -std=c++11 -O3 diff --git a/vectorAdd/Makefile b/vectorAdd/Makefile index 9ec3970..d650f3b 100644 --- a/vectorAdd/Makefile +++ b/vectorAdd/Makefile @@ -1,9 +1,4 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=/opt/rocm -endif - -HIPCC=$(HIP_PATH)/bin/hipcc +HIPCC=/opt/rocm/bin/hipcc TARGET=hcc @@ -33,6 +28,3 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - - From 8aa123cfd60b0000cc2a33b7ee703e5357b86e2a Mon Sep 17 00:00:00 2001 From: Satyanvesh Dittakavi Date: Thu, 9 Mar 2023 14:20:40 +0000 Subject: [PATCH 2/2] SWDEV-385161 - Deprecate/Remove env vars such as HIP_PATH, HSA_PATH etc. --- .../BinomialOption/Makefile | 4 +++- .../BitonicSort/Makefile | 4 +++- .../FastWalshTransform/Makefile | 4 +++- .../FloydWarshall/Makefile | 4 +++- HIP-Examples-Applications/HelloWorld/Makefile | 6 +++--- HIP-Examples-Applications/Histogram/Makefile | 4 +++- .../MatrixMultiplication/Makefile | 4 +++- HIP-Examples-Applications/PrefixSum/Makefile | 4 +++- .../RecursiveGaussian/Makefile | 4 +++- .../SimpleConvolution/Makefile | 4 +++- add4/Makefile | 4 +++- common/hip.all.make | 4 ++-- common/hip.prologue.make | 19 ++++++++++++++----- cuda-stream/Makefile | 4 +++- gpu-burn/Makefile | 8 +++++--- mini-nbody/hip/HIP-nbody-block.sh | 15 ++++++++++++++- mini-nbody/hip/HIP-nbody-orig.sh | 15 ++++++++++++++- mini-nbody/hip/HIP-nbody-soa.sh | 15 ++++++++++++++- openmp-helloworld/Makefile | 4 +++- reduction/Makefile | 4 ++-- rtm8/Makefile | 4 ++-- rtm8/build_hip.sh | 14 +++++++++++++- strided-access/Makefile | 4 ++-- vectorAdd/Makefile | 6 +++--- 24 files changed, 124 insertions(+), 38 deletions(-) diff --git a/HIP-Examples-Applications/BinomialOption/Makefile b/HIP-Examples-Applications/BinomialOption/Makefile index ea6f2dd..39097c5 100644 --- a/HIP-Examples-Applications/BinomialOption/Makefile +++ b/HIP-Examples-Applications/BinomialOption/Makefile @@ -1,4 +1,5 @@ -HIPCC=/opt/rocm/bin/hipcc +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc SOURCES = BinomialOption.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -25,3 +26,4 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) + rm -f $(HIP_PATH)/src/*.o diff --git a/HIP-Examples-Applications/BitonicSort/Makefile b/HIP-Examples-Applications/BitonicSort/Makefile index 6582c83..3c73cca 100644 --- a/HIP-Examples-Applications/BitonicSort/Makefile +++ b/HIP-Examples-Applications/BitonicSort/Makefile @@ -1,4 +1,5 @@ -HIPCC=/opt/rocm/bin/hipcc +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc SOURCES = BitonicSort.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -25,3 +26,4 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) + rm -f $(HIP_PATH)/src/*.o diff --git a/HIP-Examples-Applications/FastWalshTransform/Makefile b/HIP-Examples-Applications/FastWalshTransform/Makefile index f2ccb83..2fa7613 100644 --- a/HIP-Examples-Applications/FastWalshTransform/Makefile +++ b/HIP-Examples-Applications/FastWalshTransform/Makefile @@ -1,4 +1,5 @@ -HIPCC=/opt/rocm/bin/hipcc +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc SOURCES = FastWalshTransform.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -25,3 +26,4 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) + rm -f $(HIP_PATH)/src/*.o diff --git a/HIP-Examples-Applications/FloydWarshall/Makefile b/HIP-Examples-Applications/FloydWarshall/Makefile index 4a8f1bc..e474103 100644 --- a/HIP-Examples-Applications/FloydWarshall/Makefile +++ b/HIP-Examples-Applications/FloydWarshall/Makefile @@ -1,4 +1,5 @@ -HIPCC=/opt/rocm/bin/hipcc +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc SOURCES = FloydWarshall.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -25,3 +26,4 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) + rm -f $(HIP_PATH)/src/*.o diff --git a/HIP-Examples-Applications/HelloWorld/Makefile b/HIP-Examples-Applications/HelloWorld/Makefile index c366ebe..860906c 100644 --- a/HIP-Examples-Applications/HelloWorld/Makefile +++ b/HIP-Examples-Applications/HelloWorld/Makefile @@ -1,6 +1,5 @@ -HIPCC=/opt/rocm/bin/hipcc - -TARGET=hcc +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc SOURCES = HelloWorld.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -27,3 +26,4 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) + rm -f $(HIP_PATH)/src/*.o diff --git a/HIP-Examples-Applications/Histogram/Makefile b/HIP-Examples-Applications/Histogram/Makefile index ce0361d..9da8a88 100644 --- a/HIP-Examples-Applications/Histogram/Makefile +++ b/HIP-Examples-Applications/Histogram/Makefile @@ -1,4 +1,5 @@ -HIPCC=/opt/rocm/bin/hipcc +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc SOURCES = Histogram.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -25,3 +26,4 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) + rm -f $(HIP_PATH)src/*.o diff --git a/HIP-Examples-Applications/MatrixMultiplication/Makefile b/HIP-Examples-Applications/MatrixMultiplication/Makefile index 418c447..97001ce 100644 --- a/HIP-Examples-Applications/MatrixMultiplication/Makefile +++ b/HIP-Examples-Applications/MatrixMultiplication/Makefile @@ -1,4 +1,5 @@ -HIPCC=/opt/rocm/bin/hipcc +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc SOURCES = MatrixMultiplication.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -25,3 +26,4 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) + rm -f $(HIP_PATH)/src/*.o diff --git a/HIP-Examples-Applications/PrefixSum/Makefile b/HIP-Examples-Applications/PrefixSum/Makefile index 4967cea..52c0ead 100644 --- a/HIP-Examples-Applications/PrefixSum/Makefile +++ b/HIP-Examples-Applications/PrefixSum/Makefile @@ -1,4 +1,5 @@ -HIPCC=/opt/rocm/bin/hipcc +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc SOURCES = PrefixSum.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -25,3 +26,4 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) + rm -f $(HIP_PATH)/src/*.o diff --git a/HIP-Examples-Applications/RecursiveGaussian/Makefile b/HIP-Examples-Applications/RecursiveGaussian/Makefile index 7a34e3c..6513c7f 100644 --- a/HIP-Examples-Applications/RecursiveGaussian/Makefile +++ b/HIP-Examples-Applications/RecursiveGaussian/Makefile @@ -1,4 +1,5 @@ -HIPCC=/opt/rocm/bin/hipcc +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc SOURCES = RecursiveGaussian.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -25,3 +26,4 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) + rm -f $(HIP_PATH)/src/*.o diff --git a/HIP-Examples-Applications/SimpleConvolution/Makefile b/HIP-Examples-Applications/SimpleConvolution/Makefile index 7306a43..a662187 100644 --- a/HIP-Examples-Applications/SimpleConvolution/Makefile +++ b/HIP-Examples-Applications/SimpleConvolution/Makefile @@ -1,4 +1,5 @@ -HIPCC=/opt/rocm/bin/hipcc +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc SOURCES = SimpleConvolution.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -25,3 +26,4 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) + rm -f $(HIP_PATH)/src/*.o diff --git a/add4/Makefile b/add4/Makefile index f6fb705..c320316 100644 --- a/add4/Makefile +++ b/add4/Makefile @@ -4,7 +4,9 @@ all: gpu-stream-hip common.o: common.cpp common.h Makefile -HIPCC=/opt/rocm/bin/hipcc +HIP_PATH?= $(wildcard /opt/rocm) + +HIPCC=$(HIP_PATH)/bin/hipcc hip-stream.o : hip-stream.cpp $(HIPCC) $(CXXFLAGS) -c $< -o $@ diff --git a/common/hip.all.make b/common/hip.all.make index 32d5fb7..c6c8e5b 100644 --- a/common/hip.all.make +++ b/common/hip.all.make @@ -1,2 +1,2 @@ -include /opt/rocm/hip/examples/common/hip.prologue.make -include /opt/rocm/hip/examples/common/hip.epilogue.make +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 index 041e91b..9718293 100644 --- a/common/hip.prologue.make +++ b/common/hip.prologue.make @@ -1,11 +1,14 @@ -# This file is designed to be included at beginning of Makefile. +# 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_PLATFORM=$(shell /opt/rocm/bin/hipconfig --compiler) +HIP_PATH?=../.. +HIP_PLATFORM=$(shell $(HIP_PATH)/bin/hipconfig --compiler) # CUDA toolkit installation path CUDA_DIR?=/usr/local/cuda-7.5 @@ -22,11 +25,13 @@ endif # nvcc (7.5) can handle openmp though. # use OMPCC and OMP_FLAGS -HIPCC=/opt/rocm/bin/hipcc -HIPLD=/opt/rocm/bin/hipcc +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. @@ -50,11 +55,15 @@ 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 @@ -76,7 +85,7 @@ endif # $(HIPIFY) $< > $@ -KCFLAGS += $(OPT) -I/opt/rocm/include -I/opt/rocm/hip/include -I$(GRID_LAUNCH_PATH) -I$(AM_PATH)/include +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/Makefile b/cuda-stream/Makefile index 170f4bc..dc8e0d7 100644 --- a/cuda-stream/Makefile +++ b/cuda-stream/Makefile @@ -1,4 +1,6 @@ -HIPCC=/opt/rocm/bin/hipcc +HIP_PATH?= $(wildcard /opt/rocm) + +HIPCC=$(HIP_PATH)/bin/hipcc CXXFLAGS += -std=c++11 -O3 diff --git a/gpu-burn/Makefile b/gpu-burn/Makefile index 6f1c4a6..68c4d34 100644 --- a/gpu-burn/Makefile +++ b/gpu-burn/Makefile @@ -1,8 +1,10 @@ -HIP_PLATFORM = $(shell /opt/rocm/bin/hipconfig --platform) -HIP_INCLUDE = -I/opt/rocm/include +HIP_PATH?= $(wildcard /opt/rocm) + +HIP_PLATFORM = $(shell $(HIP_PATH)/bin/hipconfig --platform) +HIP_INCLUDE = -I$(HIP_PATH)/include BUILD_DIR ?= build -HIPCC = /opt/rocm/bin/hipcc +HIPCC = $(HIP_PATH)/bin/hipcc CPPFLAGS = -O3 LDFLAGS = -lm -lpthread diff --git a/mini-nbody/hip/HIP-nbody-block.sh b/mini-nbody/hip/HIP-nbody-block.sh index 8b5c3d1..65640ab 100755 --- a/mini-nbody/hip/HIP-nbody-block.sh +++ b/mini-nbody/hip/HIP-nbody-block.sh @@ -10,8 +10,20 @@ 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 +fi + +fi + echo hipcc -I../ -DSHMOO nbody-block.cpp -o nbody-block -/opt/rocm/bin/hipcc -I../ -DSHMOO nbody-block.cpp -o nbody-block +$HIP_PATH/bin/hipcc -I../ -DSHMOO nbody-block.cpp -o nbody-block #To print our more details, remove DSHMOO flag #hipcc -I../ nbody-block.cpp -o nbody-block @@ -25,3 +37,4 @@ do ./$EXE $K K=$(($K*2)) done + diff --git a/mini-nbody/hip/HIP-nbody-orig.sh b/mini-nbody/hip/HIP-nbody-orig.sh index 4345423..5cdfdca 100755 --- a/mini-nbody/hip/HIP-nbody-orig.sh +++ b/mini-nbody/hip/HIP-nbody-orig.sh @@ -7,8 +7,20 @@ 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 +fi + +fi + echo hipcc -I../ -DSHMOO nbody-orig.cpp -o nbody-orig -/opt/rocm/bin/hipcc -I../ -DSHMOO nbody-orig.cpp -o nbody-orig +$HIP_PATH/bin/hipcc -I../ -DSHMOO nbody-orig.cpp -o nbody-orig #To print our more details, remove flag #hipcc -I../ nbody-orig.cpp -o nbody-orig @@ -23,3 +35,4 @@ do ./$EXE $K K=$(($K*2)) done + diff --git a/mini-nbody/hip/HIP-nbody-soa.sh b/mini-nbody/hip/HIP-nbody-soa.sh index 1b6f4f2..e7861fd 100755 --- a/mini-nbody/hip/HIP-nbody-soa.sh +++ b/mini-nbody/hip/HIP-nbody-soa.sh @@ -10,8 +10,20 @@ 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 +fi + +fi + echo hipcc -I../ -DSHMOO nbody-soa.cpp -o nbody-soa -/opt/rocm/bin/hipcc -I../ -DSHMOO nbody-soa.cpp -o nbody-soa +$HIP_PATH/bin/hipcc -I../ -DSHMOO nbody-soa.cpp -o nbody-soa #To print our more details, remove DSHMOO flag #hipcc -I../ nbody-soa.cpp -o nbody-soa @@ -25,3 +37,4 @@ do ./$EXE $K K=$(($K*2)) done + diff --git a/openmp-helloworld/Makefile b/openmp-helloworld/Makefile index 325b4be..585fb00 100644 --- a/openmp-helloworld/Makefile +++ b/openmp-helloworld/Makefile @@ -1,4 +1,6 @@ -HIPCC=/opt/rocm/bin/hipcc +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc + CXX=$(HIPCC) CXXFLAGS =-fopenmp diff --git a/reduction/Makefile b/reduction/Makefile index b66d71b..dad6ff1 100644 --- a/reduction/Makefile +++ b/reduction/Makefile @@ -1,4 +1,5 @@ -HIPCC=/opt/rocm/bin/hipcc +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc CXXFLAGS += -std=c++11 -O3 @@ -13,4 +14,3 @@ endif clean: rm -f reduction *.o - diff --git a/rtm8/Makefile b/rtm8/Makefile index fba11d6..a61fcba 100644 --- a/rtm8/Makefile +++ b/rtm8/Makefile @@ -1,4 +1,5 @@ -HIPCC=/opt/rocm/bin/hipcc +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc CXXFLAGS += -std=c++11 -O3 @@ -13,4 +14,3 @@ endif clean: rm -f rtm8 *.o - diff --git a/rtm8/build_hip.sh b/rtm8/build_hip.sh index 86f4871..07b64ea 100755 --- a/rtm8/build_hip.sh +++ b/rtm8/build_hip.sh @@ -1,10 +1,22 @@ #!/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" -/opt/rocm/bin/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/Makefile b/strided-access/Makefile index 3610177..550e074 100644 --- a/strided-access/Makefile +++ b/strided-access/Makefile @@ -1,4 +1,5 @@ -HIPCC=/opt/rocm/bin/hipcc +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc CXXFLAGS += -std=c++11 -O3 @@ -13,4 +14,3 @@ endif clean: rm -f strided-access *.o - diff --git a/vectorAdd/Makefile b/vectorAdd/Makefile index d650f3b..a412c3d 100644 --- a/vectorAdd/Makefile +++ b/vectorAdd/Makefile @@ -1,6 +1,5 @@ -HIPCC=/opt/rocm/bin/hipcc - -TARGET=hcc +HIP_PATH?= $(wildcard /opt/rocm) +HIPCC=$(HIP_PATH)/bin/hipcc SOURCES = vectoradd_hip.cpp OBJECTS = $(SOURCES:.cpp=.o) @@ -28,3 +27,4 @@ test: $(EXECUTABLE) clean: rm -f $(EXECUTABLE) rm -f $(OBJECTS) + rm -f $(HIP_PATH)/src/*.o