Skip to content

Commit

Permalink
add script for oss build and add dev signature as suffix (NVIDIA#38)
Browse files Browse the repository at this point in the history
Summary:

See title.

Differential Revision: D51420806
  • Loading branch information
minsii authored and facebook-github-bot committed Nov 17, 2023
1 parent 404d73f commit c2d112a
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
53 changes: 53 additions & 0 deletions maint/oss_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
set -x

hash=""
# guess default DEV_SIGNATURE
is_git=$(git rev-parse --is-inside-work-tree)
if [ $is_git ]; then
hash="git-"$(git rev-parse --short HEAD)
fi

BUILDDIR=${BUILDDIR:=/tmp/nccl-exp/2.18.3/build}
NVCC_ARCH=${NVCC_ARCH:="a100,h100"}
CUDA_HOME=${CUDA_HOME:="/usr/local/cuda"}
# TODO: automatically get hg id or git hash
DEV_SIGNATURE=${DEV_SIGNATURE:="$hash"}

echo "BUILDDIR=${BUILDDIR}"
echo "NVCC_ARCH=${NVCC_ARCH}"
echo "CUDA_HOME=${CUDA_HOME}"
echo "DEV_SIGNATURE=${DEV_SIGNATURE}"

IFS=',' read -ra arch_array <<< "$NVCC_ARCH"
arch_gencode=""
for arch in "${arch_array[@]}"
do
case "$arch" in
"p100")
arch_gencode="$arch_gencode -gencode=arch=compute_60,code=sm_60"
;;
"v100")
arch_gencode="$arch_gencode -gencode=arch=compute_70,code=sm_70"
;;
"a100")
arch_gencode="$arch_gencode -gencode=arch=compute_80,code=sm_80"
;;
"h100")
arch_gencode="$arch_gencode -gencode=arch=compute_90,code=sm_90"
;;
esac
done

echo "NVCC_GENCODE=$arch_gencode"

# build libnccl
export BUILDDIR=$BUILDDIR
make src.clean && make -j src.build NVCC_GENCODE="$arch_gencode" CUDA_HOME="$CUDA_HOME" DEV_SIGNATURE="$DEV_SIGNATURE"

# sanity check
pushd examples
export NCCL_HOME=$BUILDDIR
make clean && make all
NCCL_DEBUG=WARN LD_LIBRARY_PATH=$BUILDDIR/lib $BUILDDIR/examples/HelloWorld
popd
1 change: 1 addition & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ $(INCDIR)/nccl.h : nccl.h.in ../makefiles/version.mk
-e "s/\$${nccl:Patch}/$(NCCL_PATCH)/g" \
-e "s/\$${nccl:Suffix}/$(NCCL_SUFFIX)/g" \
-e "s/\$${nccl:Version}/$(NCCL_VERSION)/g" \
-e "s/\$${nccl:DevSignature}/$(DEV_SIGNATURE)/g" \
$< > $@

$(LIBDIR)/$(LIBTARGET): $(LIBOBJ) $(DEVICELIB)
Expand Down
2 changes: 1 addition & 1 deletion src/nccl.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#define NCCL_MAJOR ${nccl:Major}
#define NCCL_MINOR ${nccl:Minor}
#define NCCL_PATCH ${nccl:Patch}
#define NCCL_SUFFIX "${nccl:Suffix}"
#define NCCL_SUFFIX "${nccl:Suffix} ${nccl:DevSignature}"
#define IS_NCCL_EXP

#define NCCL_VERSION_CODE ${nccl:Version}
Expand Down

0 comments on commit c2d112a

Please sign in to comment.