2025-04-23 15:44:56 -04:00
# Copyright (c) 2019-2025 Advanced Micro Devices, Inc. All rights reserved.
2022-08-04 13:38:41 -04:00
HIP_PATH ?= $( wildcard /opt/rocm)
2020-02-03 22:06:44 +00:00
ifeq (, $( HIP_PATH ) )
HIP_PATH = ../../..
endif
HIPCC = $( HIP_PATH) /bin/hipcc
2025-08-26 10:11:38 -04:00
.DEFAULT_GOAL := all
2020-02-03 22:06:44 +00:00
EXE = topo_expl
2025-06-27 15:29:37 -05:00
CXXFLAGS = -g -ffunction-sections -fdata-sections -Wl,--gc-sections -fgpu-rdc -Iinclude -Ihipify_rccl/include -Ihipify_rccl/include/plugin -Ihipify_rccl/device/include -Ihipify_rccl/graph -I/opt/rocm/include/ -DTOPO_EXPL -DENABLE_TRACE -DENABLE_LL128 -DNVTX_NO_IMPL -DRCCL_EXPOSE_STATIC -lpthread
2020-02-03 22:06:44 +00:00
2023-01-06 07:29:40 -08:00
files = $( EXE) .cpp model.cpp utils.cpp hipify_rccl/graph/topo.cc hipify_rccl/graph/rings.cc hipify_rccl/graph/paths.cc hipify_rccl/graph/trees.cc ../../src/misc/param.cc \
2025-04-23 15:44:56 -04:00
hipify_rccl/graph/search.cc hipify_rccl/graph/connect.cc hipify_rccl/graph/tuning.cc hipify_rccl/graph/xml.cc ../../src/misc/nvmlwrap_stub.cc hipify_rccl/graph/rome_models.cc hipify_rccl/graph/archinfo.cc \
2025-05-05 15:26:29 -04:00
hipify_rccl/collectives.cc hipify_rccl/register.cc hipify_rccl/enqueue.cc ../../src/rccl_wrap.cc
2020-02-03 22:06:44 +00:00
2025-08-26 10:11:38 -04:00
FMT_DIR := third_party/fmt
FMT_INCLUDE := $( FMT_DIR) /include
FMT_HEADER := $( FMT_INCLUDE) /fmt/format.h
FMT_GIT := https://github.com/fmtlib/fmt.git
# Probe for <fmt/format.h> using a portable pipe (no <<< here-string)
HAVE_FMT := $( shell echo '#include <fmt/format.h>' | \
$( HIPCC) -xc++ -std= c++17 -E - >/dev/null 2>& 1 && echo yes || echo no)
ifeq ( $( HAVE_FMT ) ,no)
CXXFLAGS += -I$( FMT_INCLUDE)
NEED_FMT := 1
endif
ifeq ( $( NEED_FMT ) ,1)
$(FMT_HEADER) :
rm -rf third_party/fmt
@echo ">>> fmt not found; cloning $( FMT_GIT) ..."
@mkdir -p $( dir $( FMT_DIR))
@git clone --depth= 1 $( FMT_GIT) $( FMT_DIR)
else
$(FMT_HEADER) :
endif
# ---------------------------------------------------------------------------
all : $( FMT_HEADER ) hipify $( EXE )
2020-02-03 22:06:44 +00:00
$(EXE) : $( files )
$( HIPCC) $( CXXFLAGS) $^ -o $@
2023-01-06 07:29:40 -08:00
hipify :
2023-06-06 08:41:38 -07:00
rm -rf hipify_rccl
2025-04-23 15:44:56 -04:00
mkdir -p hipify_rccl/device/include hipify_rccl/include/network/unpack
2023-02-04 01:43:38 +00:00
cp -a ../../src/include/ hipify_rccl/
cp -a ../../src/graph/ hipify_rccl/
2025-04-23 15:44:56 -04:00
cp -a ../../src/device/*.h hipify_rccl/device/include
cp -a ../../src/device/network/unpack/*.h hipify_rccl/include/network/unpack
cp -a ../../src/enqueue.cc hipify_rccl/
2025-05-05 15:26:29 -04:00
cp -a ../../src/register/register.cc hipify_rccl/
2025-04-23 15:44:56 -04:00
cp -a ../../src/collectives.cc hipify_rccl/
cp -a ../../src/misc/archinfo.cc hipify_rccl/graph/
2023-01-06 07:29:40 -08:00
hipify-perl -inplace -quiet-warnings hipify_rccl/include/*.h
2025-08-28 15:45:42 -05:00
hipify-perl -inplace -quiet-warnings hipify_rccl/include/latency_profiler/*.h
2025-06-27 15:29:37 -05:00
hipify-perl -inplace -quiet-warnings hipify_rccl/include/plugin/*.h
2025-08-26 10:11:38 -04:00
hipify-perl -inplace -quiet-warnings hipify_rccl/include/latency_profiler/*.h
2025-04-23 15:44:56 -04:00
hipify-perl -inplace -quiet-warnings hipify_rccl/device/include/*.h
2025-08-26 10:11:38 -04:00
sed -i "s/template<typename T, typename RedOp>/template<typename T, typename RedOp, int USE_ACC, int COLL_UNROLL>/g" "hipify_rccl/device/include/common.h"
sed -i "s/\\(struct RunWorkBatch<ncclFunc[^>]*\\)>*/\\1, USE_ACC, COLL_UNROLL>/" "hipify_rccl/device/include/common.h"
2023-01-06 07:29:40 -08:00
hipify-perl -inplace -quiet-warnings hipify_rccl/graph/*
2025-04-23 15:44:56 -04:00
hipify-perl -inplace -quiet-warnings hipify_rccl/include/network/unpack/*
hipify-perl -inplace -quiet-warnings hipify_rccl/*.cc
2023-01-06 07:29:40 -08:00
2020-02-03 22:06:44 +00:00
clean :
2025-08-26 10:11:38 -04:00
rm -rf hipify_rccl third_party
2025-06-27 15:29:37 -05:00
rm -f *.o $( EXE)