diff --git a/third_party/Makefile b/third_party/Makefile index 2a09f5990..3de1b697c 100755 --- a/third_party/Makefile +++ b/third_party/Makefile @@ -9,9 +9,16 @@ RCCL_HOME ?= /opt/rocm/rccl HPCX_HOME ?= /opt/hpcx ROCM_PATH ?= /opt/rocm +OS_SKU ?= $(shell sort -r /etc/*-release | gawk 'match($$0, /^ID=(.*)$$/, a) { print toupper(a[1]); exit }') + CUDA_VER ?= $(shell nvcc --version | grep 'release' | awk '{print $$6}' | cut -c2- | cut -d '.' -f1-2) +ifeq ($(OS_SKU), AZURELINUX) +ROCBLAS_BRANCH ?= rocm-$(shell rpm -qa | grep 'rocm-dev-' | head -1 | awk -F'-' '{print $$3}' | cut -d '.' -f1-3) +HIPBLASLT_BRANCH ?= rocm-$(shell rpm -qa | grep 'rocm-dev-' | head -1 | awk -F'-' '{print $$3}' | cut -d '.' -f1-3) +else ROCBLAS_BRANCH ?= rocm-$(shell dpkg -l | grep 'rocm-dev ' | awk '{print $$3}' | cut -d '.' -f1-3) HIPBLASLT_BRANCH ?= rocm-$(shell dpkg -l | grep 'rocm-dev ' | awk '{print $$3}' | cut -d '.' -f1-3) +endif ROCM_VER ?= $(shell hipconfig -R | grep -oP '\d+\.\d+\.\d+' || echo "0.0.0") NUM_MAKE_JOBS ?= $(shell nproc --ignore=2) @@ -195,7 +202,7 @@ ifneq (,$(wildcard hpl-tests/Makefile)) tar xzf hpl-2.3.tar.gz && \ cp Make.Linux_zen3 hpl-2.3 && \ cp Make.Linux_zen4 hpl-2.3 && \ - make all + make OS_SKU=$(OS_SKU) all cp -v ./hpl-tests/hpl-2.3/bin/Linux_zen3/xhpl $(SB_MICRO_PATH)/bin/xhpl_z3 cp -v ./hpl-tests/hpl-2.3/bin/Linux_zen4/xhpl $(SB_MICRO_PATH)/bin/xhpl_z4 cp -v ./hpl-tests/hpl_run.sh $(SB_MICRO_PATH)/bin/ @@ -208,7 +215,7 @@ cpu_stream: sb_micro_path ifneq (,$(wildcard stream-tests/Makefile)) cd ./stream-tests && \ wget https://www.cs.virginia.edu/stream/FTP/Code/stream.c && \ - make all + make OS_SKU=$(OS_SKU) all cp -v ./stream-tests/stream* $(SB_MICRO_PATH)/bin/ endif @@ -225,13 +232,13 @@ directx_amf_encoding_latency: # Install requirements for Megatron-LM megatron_lm: cd Megatron && \ - apt install -y python3-mpi4py && \ + { [ "$(OS_SKU)" = "AZURELINUX" ] || apt install -y python3-mpi4py; } && \ python -m pip install --no-cache-dir -r requirements.txt # Install requirements for Megatron-DeepSpeed megatron_deepspeed: cd Megatron && \ - apt install -y python3-mpi4py && \ + { [ "$(OS_SKU)" = "AZURELINUX" ] || apt install -y python3-mpi4py; } && \ python -m pip install --no-cache-dir -r requirements.txt && \ python -m pip install DeepSpeed diff --git a/third_party/hpl-tests/Makefile b/third_party/hpl-tests/Makefile index ae7855f3f..fcafd5151 100644 --- a/third_party/hpl-tests/Makefile +++ b/third_party/hpl-tests/Makefile @@ -1,22 +1,38 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT license. +# OS_SKU is inherited from parent Makefile, but provide fallback if run independently +OS_SKU ?= $(shell sort -r /etc/*-release | gawk 'match($$0, /^ID=(.*)$$/, a) { print toupper(a[1]); exit }') + +# Dynamically find AMD software paths +ifeq ($(OS_SKU), AZURELINUX) +BLIS_PATH := $(shell find /opt -path "*/amd-blis" 2>/dev/null | head -1) +BLIS_LIB := $(shell find /opt -name "libblis-mt.so" 2>/dev/null | head -1) +AOCC_PATH := $(shell find /opt -path "*/aocc-compiler*/bin/clang" 2>/dev/null | head -1) +endif all: ZEN3 ZEN4 CONFIGURE CONFIGURE: cp ./hpl-2.3/setup/Make.Linux_ATHLON_CBLAS ./hpl-2.3/Make.Linux_zen3 - sed -i 's/.*ARCH .*=.*/ARCH =$$(arch)/' ./hpl-2.3/Make.Linux_zen3 - sed -i 's/.*TOPdir .*=.*/TOPdir = ..\/..\/../' ./hpl-2.3/Make.Linux_zen3 + sed -i 's/.*ARCH .*=.*/ARCH =$$(arch)/' ./hpl-2.3/Make.Linux_zen3 + sed -i 's/.*TOPdir .*=.*/TOPdir = ..\/..\/../' ./hpl-2.3/Make.Linux_zen3 sed -i 's/.*MPdir .*=.*/MPdir = $$(omp)/' ./hpl-2.3/Make.Linux_zen3 sed -i 's/.*MPinc .*=.*/MPinc = -I$$(MPdir)\/include/' ./hpl-2.3/Make.Linux_zen3 sed -i 's/.*MPlib .*=.*/MPlib = $$(MPdir)\/lib\/libmpi.so/' ./hpl-2.3/Make.Linux_zen3 +ifeq ($(OS_SKU), AZURELINUX) + sed -i 's|.*LAdir .*=.*|LAdir = $(BLIS_PATH)|' ./hpl-2.3/Make.Linux_zen3 + sed -i 's|.*LAlib .*=.*|LAlib = $(BLIS_LIB)|' ./hpl-2.3/Make.Linux_zen3 + sed -i 's|.*CC .*=.*|CC = $(AOCC_PATH)|' ./hpl-2.3/Make.Linux_zen3 + sed -i 's|.*LINKER .*=.*|LINKER = $(AOCC_PATH)|' ./hpl-2.3/Make.Linux_zen3 +else sed -i 's/.*LAdir .*=.*/LAdir = \/opt\/AMD\/amd-blis/' ./hpl-2.3/Make.Linux_zen3 - sed -i 's/LAinc .*=/LAinc = -I$$(LAdir)\/lib\/include/' ./hpl-2.3/Make.Linux_zen3 sed -i 's/.*LAlib .*=.*/LAlib = $$(LAdir)\/lib\/LP64\/libblis-mt.so/' ./hpl-2.3/Make.Linux_zen3 - sed -i 's/.*CC .*=.*/CC = \/opt\/AMD\/aocc-compiler-4.0.0\/bin\/clang/' ./hpl-2.3/Make.Linux_zen3 + sed -i 's/.*CC .*=.*/CC = \/opt\/AMD\/aocc-compiler-4.0.0\/bin\/clang/' ./hpl-2.3/Make.Linux_zen3 + sed -i 's/.*LINKER .*=.*/LINKER = \/opt\/AMD\/aocc-compiler-4.0.0\/bin\/clang/' ./hpl-2.3/Make.Linux_zen3 +endif + sed -i 's/LAinc .*=/LAinc = -I$$(LAdir)\/lib\/include/' ./hpl-2.3/Make.Linux_zen3 sed -i 's/.*CCFLAGS .*=.*/CCFLAGS = $$(HPL_DEFS) -march=znver3 -fomit-frame-pointer -O3 -funroll-loops/' ./hpl-2.3/Make.Linux_zen3 - sed -i 's/.*LINKER .*=.*/LINKER = \/opt\/AMD\/aocc-compiler-4.0.0\/bin\/clang/' ./hpl-2.3/Make.Linux_zen3 cp ./hpl-2.3/Make.Linux_zen3 ./hpl-2.3/Make.Linux_zen4 sed -i 's/.*CCFLAGS .*=.*/CCFLAGS = $$(HPL_DEFS) -march=znver4 -fomit-frame-pointer -O3 -funroll-loops/' ./hpl-2.3/Make.Linux_zen4 ZEN3: CONFIGURE diff --git a/third_party/stream-tests/Makefile b/third_party/stream-tests/Makefile index d72d3ade7..356787df5 100644 --- a/third_party/stream-tests/Makefile +++ b/third_party/stream-tests/Makefile @@ -1,6 +1,9 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT license. +# OS_SKU is inherited from parent Makefile, but provide fallback if run independently +OS_SKU ?= $(shell sort -r /etc/*-release | gawk 'match($$0, /^ID=(.*)$$/, a) { print toupper(a[1]); exit }') + GENFLAGS := -DSTREAM_ARRAY_SIZE=120000000 ZEN3FLAGS := -DSTREAM_ARRAY_SIZE=400000000 -march=znver3 ZEN4FLAGS := -DSTREAM_ARRAY_SIZE=800000000 -march=znver4 @@ -23,8 +26,16 @@ ifeq ($(ARCH), aarch64) endif # AMD AOCC clang present? add ZEN3 and ZEN4 -ifneq ("$(wildcard /opt/AMD/aocc-compiler-4.0.0/bin/clang)","") - CC := /opt/AMD/aocc-compiler-4.0.0/bin/clang +# Find AOCC compiler installation +ifeq ($(OS_SKU), AZURELINUX) +AOCC_CLANG := $(shell find /opt -path "*/aocc-compiler*/bin/clang" 2>/dev/null | head -1) +else +AOCC_CLANG := $(wildcard /opt/AMD/aocc-compiler-4.0.0/bin/clang) +endif + +# Configure compiler if AOCC is found +ifneq ($(AOCC_CLANG),) + CC := $(AOCC_CLANG) CFLAGS := -Ofast -mcmodel=large -mavx2 -ffp-contract=fast -lomp -fopenmp \ -fnt-store=aggressive -DNTIMES=10 ALL_TARGETS += ZEN3 ZEN4