From 1b7efe6171ba30b4c8196d46fc3a89110226fec3 Mon Sep 17 00:00:00 2001 From: Henry Li Date: Mon, 10 Nov 2025 16:09:34 -0800 Subject: [PATCH 1/4] dynamically query aocc clang path --- third_party/stream-tests/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/third_party/stream-tests/Makefile b/third_party/stream-tests/Makefile index d72d3ade7..a6c1f880b 100644 --- a/third_party/stream-tests/Makefile +++ b/third_party/stream-tests/Makefile @@ -23,8 +23,10 @@ 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 +# Dynamically find AOCC compiler installation +AOCC_CLANG := $(shell find /opt -path "*/aocc-compiler*/bin/clang" 2>/dev/null | head -1) +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 From 436e385f0513f16e12deca9d84f59c193f6b8c46 Mon Sep 17 00:00:00 2001 From: Henry Li Date: Mon, 10 Nov 2025 16:29:25 -0800 Subject: [PATCH 2/4] modify hpl-tests makefile to use dynamic path --- third_party/hpl-tests/Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/third_party/hpl-tests/Makefile b/third_party/hpl-tests/Makefile index ae7855f3f..46be4e0f0 100644 --- a/third_party/hpl-tests/Makefile +++ b/third_party/hpl-tests/Makefile @@ -1,6 +1,10 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT license. +# Dynamically find AMD software paths +BLIS_PATH := $(shell find /opt -path "*/amd-blis" 2>/dev/null | head -1) +BLIS_LIB := $(shell find /opt -name "libblis-mt.so" -path "*/lib_LP64/*" 2>/dev/null | head -1) +AOCC_PATH := $(shell find /opt -path "*/aocc-compiler*/bin/clang" 2>/dev/null | head -1) all: ZEN3 ZEN4 CONFIGURE @@ -11,12 +15,12 @@ CONFIGURE: 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 - sed -i 's/.*LAdir .*=.*/LAdir = \/opt\/AMD\/amd-blis/' ./hpl-2.3/Make.Linux_zen3 + sed -i 's|.*LAdir .*=.*|LAdir = $(BLIS_PATH)|' ./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|.*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/.*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 + sed -i 's|.*LINKER .*=.*|LINKER = $(AOCC_PATH)|' ./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 From 7ff0a63f1e78b41ebdd2d026ebcdebd3f8f8a046 Mon Sep 17 00:00:00 2001 From: Henry Li Date: Tue, 11 Nov 2025 00:37:01 -0800 Subject: [PATCH 3/4] add OS SKU checking in third_party Makefile --- third_party/Makefile | 11 +++++++++-- third_party/hpl-tests/Makefile | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/third_party/Makefile b/third_party/Makefile index 2a09f5990..3715f727d 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) @@ -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 46be4e0f0..5bef335d7 100644 --- a/third_party/hpl-tests/Makefile +++ b/third_party/hpl-tests/Makefile @@ -3,7 +3,7 @@ # Dynamically find AMD software paths BLIS_PATH := $(shell find /opt -path "*/amd-blis" 2>/dev/null | head -1) -BLIS_LIB := $(shell find /opt -name "libblis-mt.so" -path "*/lib_LP64/*" 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) all: ZEN3 ZEN4 CONFIGURE From 8b45e47dca3f6a86e22a1b79e76a6064d1d1a96f Mon Sep 17 00:00:00 2001 From: Henry Li Date: Wed, 19 Nov 2025 23:23:46 -0800 Subject: [PATCH 4/4] scope changes for Azure Linux only --- third_party/Makefile | 4 ++-- third_party/hpl-tests/Makefile | 22 +++++++++++++++++----- third_party/stream-tests/Makefile | 11 ++++++++++- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/third_party/Makefile b/third_party/Makefile index 3715f727d..3de1b697c 100755 --- a/third_party/Makefile +++ b/third_party/Makefile @@ -202,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/ @@ -215,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 diff --git a/third_party/hpl-tests/Makefile b/third_party/hpl-tests/Makefile index 5bef335d7..fcafd5151 100644 --- a/third_party/hpl-tests/Makefile +++ b/third_party/hpl-tests/Makefile @@ -1,26 +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/LAinc .*=/LAinc = -I$$(LAdir)\/lib\/include/' ./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|.*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/.*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/.*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 = $(AOCC_PATH)|' ./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 a6c1f880b..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,14 @@ ifeq ($(ARCH), aarch64) endif # AMD AOCC clang present? add ZEN3 and ZEN4 -# Dynamically find AOCC compiler installation +# 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 \