Skip to content

Instantly share code, notes, and snippets.

@nariaki3551
Created May 4, 2025 03:47
Show Gist options
  • Save nariaki3551/c36f1da96c7ce71317d092461c24450a to your computer and use it in GitHub Desktop.
Save nariaki3551/c36f1da96c7ce71317d092461c24450a to your computer and use it in GitHub Desktop.
# ==== Environment and Defaults ====
USE_CUDA ?= 1
CUDA_DIR ?= /usr/local/cuda
HPCX_DIR ?= /opt/hpcx-v2.22.1-gcc-doca_ofed-ubuntu22.04-cuda12-x86_64
CUDA_FLAGS = -I$(CUDA_DIR)/include -L$(CUDA_DIR)/lib64 -lcudart
NVCC_GENCODE ?= -gencode=arch=compute_70,code=sm_70
MPI_HOME ?= /usr
PREFIX ?= /usr/local
export LD_LIBRARY_PATH := $(PREFIX)/lib:$(LD_LIBRARY_PATH)
.PHONY: all clean
all: build_ompi
# ==== Clone and Init ====
init_ompi:
if [ ! -d "ompi" ]; then \
git clone https://github.com/open-mpi/ompi.git; \
fi
cd ompi && git checkout v5.0.7
init_ucx:
if [ ! -d "ucx" ]; then \
git clone https://github.com/openucx/ucx.git; \
fi
cd ucx && git checkout v1.18.1
init_ucc:
if [ ! -d "ucc" ]; then \
git clone https://github.com/openucx/ucc.git; \
fi
cd ucc && git checkout v1.3.0
# ==== Submodule Updates ====
update_submodules_ompi: init_ompi
cd ompi && git submodule update --init --recursive
update_submodules_ucx: init_ucx
cd ucx && git submodule update --init --recursive
update_submodules_ucc: init_ucc
cd ucc && git submodule update --init --recursive
# ==== Build 3rd-Party Libraries ====
build_libevent: init_ompi
cd ompi/3rd-party && \
tar -xf libevent-2.1.12-stable-ompi.tar.gz && \
cd libevent-2.1.12-stable-ompi && \
./configure --prefix=$(PREFIX) && make -j && make install
build_hwloc: init_ompi
cd ompi/3rd-party && \
tar -xf hwloc-2.7.1.tar.gz && \
cd hwloc-2.7.1 && \
./configure --prefix=$(PREFIX) && make -j && make install
build_openpmix: update_submodules_ompi build_libevent build_hwloc
cd ompi/3rd-party/openpmix && \
./autogen.pl && \
./configure \
--prefix=$(PREFIX) \
--with-libevent=$(PREFIX) \
--with-hwloc=$(PREFIX) \
--enable-devel-headers && \
make -j && make install
build_prrte: update_submodules_ompi build_libevent build_hwloc build_openpmix
cd ompi/3rd-party/prrte && \
./autogen.pl && \
CPPFLAGS="-I$(PREFIX)/include/pmix" \
./configure \
--prefix=$(PREFIX) \
--with-libevent=$(PREFIX) \
--with-hwloc=$(PREFIX) \
--with-pmix=$(PREFIX) && \
make -j && make install
# ==== Build UCX ====
build_ucx: update_submodules_ucx
cd ucx && ./autogen.sh
ifeq ($(USE_CUDA), 1)
cd ucx && \
./contrib/configure-release \
--prefix=$(PREFIX) \
--with-cuda=$(CUDA_DIR) \
--enable-mt
else
cd ucx && \
./contrib/configure-release \
--prefix=$(PREFIX) \
--enable-mt
endif
cd ucx && make -j && make install
# ==== Build UCC ====
build_ucc: update_submodules_ucc build_ucx
cd ucc && ./autogen.sh
ifeq ($(USE_CUDA), 1)
cd ucc && \
./configure \
--prefix=$(PREFIX) \
--with-ucx=$(PREFIX) \
--with-tls=all \
--with-cuda=$(CUDA_DIR) \
--with-nvcc-gencode=$(NVCC_GENCODE) \
--with-sharp=$(HPCX_DIR)/sharp
else
cd ucc && \
./configure \
--prefix=$(PREFIX) \
--with-ucx=$(PREFIX) \
--with-tls=all
endif
cd ucc && make -j && make install
# ==== Build OMPI ====
build_ompi: update_submodules_ompi build_libevent build_hwloc build_openpmix build_prrte build_ucx build_ucc
cd ompi && ./autogen.pl
ifeq ($(USE_CUDA), 1)
cd ompi && \
CPPFLAGS="-I$(PREFIX)/include/pmix" \
./configure \
--prefix=$(PREFIX) \
--with-libevent=$(PREFIX) \
--with-hwloc=$(PREFIX) \
--with-pmix=$(PREFIX) \
--with-prrte=$(PREFIX) \
--with-ucx=$(PREFIX) \
--with-ucc=$(PREFIX) \
--with-cuda=$(CUDA_DIR) \
--with-cuda-libdir=$(CUDA_DIR)/lib64/stubs \
$(DEBUG_FLAGS)
else
cd ompi && \
CPPFLAGS="-I$(PREFIX)/include/pmix" \
./configure \
--prefix=$(PREFIX) \
--with-libevent=$(PREFIX) \
--with-hwloc=$(PREFIX) \
--with-pmix=$(PREFIX) \
--with-prrte=$(PREFIX)
endif
cd ompi && make -j && make install
# ==== Clean ====
clean:
rm -rf ompi ucx ucc
rm -rf $(PREFIX)/lib/* $(PREFIX)/include/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment