Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
gpuCI:
Browse files Browse the repository at this point in the history
- Make the build directory, not the repository root, the starting directory
  in containers.
- Turn off C++17 mode for now until we have an easy way to say "use it if the
  compiler supports it" - see #1321.
- Make invocation with a specific test target work as intended.
- `ci/local/build.bash`: Don't print out build parallelism information if
  invoking in shell only mode.
  • Loading branch information
brycelelbach committed Oct 20, 2020
1 parent 8d2921b commit 42ae146
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 21 deletions.
27 changes: 19 additions & 8 deletions ci/common/build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ export PATH=/usr/local/cuda/bin:${PATH}
# Set home to the job's workspace.
export HOME=${WORKSPACE}

# Switch to project root; also root of repo checkout.
# Switch to the build directory.
cd ${WORKSPACE}
mkdir -p build
cd build

# The Docker image sets up `${CXX}` and `${CUDACXX}`.
CMAKE_FLAGS="-G Ninja -DCMAKE_CXX_COMPILER='${CXX}' -DCMAKE_CUDA_COMPILER='${CUDACXX}'"
Expand All @@ -42,6 +44,7 @@ if [ "${BUILD_MODE}" == "branch" ]; then
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_MULTICONFIG_ENABLE_DIALECT_CPP11=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_IGNORE_DEPRECATED_CPP_11=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_MULTICONFIG_ENABLE_DIALECT_CPP14=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_MULTICONFIG_ENABLE_DIALECT_CPP17=OFF"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_MULTICONFIG_ENABLE_SYSTEM_CPP=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_MULTICONFIG_ENABLE_SYSTEM_TBB=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_MULTICONFIG_ENABLE_SYSTEM_OMP=ON"
Expand All @@ -59,17 +62,28 @@ else
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_MULTICONFIG_ENABLE_DIALECT_CPP11=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_IGNORE_DEPRECATED_CPP_11=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_MULTICONFIG_ENABLE_DIALECT_CPP14=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_MULTICONFIG_ENABLE_DIALECT_CPP17=OFF"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_MULTICONFIG_ENABLE_SYSTEM_CPP=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_MULTICONFIG_ENABLE_SYSTEM_TBB=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_MULTICONFIG_ENABLE_SYSTEM_OMP=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_MULTICONFIG_ENABLE_SYSTEM_CUDA=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_MULTICONFIG_WORKLOAD=SMALL"
fi

CMAKE_BUILD_FLAGS="-j${PARALLEL_LEVEL}"

if [ ! -z "${@}" ]; then
CMAKE_BUILD_FLAGS="${CMAKE_BUILD_FLAGS} -- ${@}"
fi

CTEST_FLAGS=""

if [ "${BUILD_TYPE}" == "cpu" ]; then
CTEST_FLAGS="${CTEST_FLAGS} -E '^cub|^thrust.*cuda'"
CTEST_FLAGS="${CTEST_FLAGS} -E ^cub|^thrust.*cuda"
fi

if [ ! -z "${@}" ]; then
CTEST_FLAGS="${CTEST_FLAGS} -R ^${@}$"
fi

################################################################################
Expand All @@ -87,19 +101,16 @@ ${CUDACXX} --version
# BUILD - Build Thrust and CUB examples and tests.
################################################################################

mkdir -p build
cd build

logger "Configure Thrust and CUB..."
cmake ${CMAKE_FLAGS} ..
cmake .. ${CMAKE_FLAGS}

logger "Build Thrust and CUB..."
cmake --build . -j${PARALLEL_LEVEL} "${@}"
cmake --build . ${CMAKE_BUILD_FLAGS}

################################################################################
# TEST - Run Thrust and CUB examples and tests.
################################################################################

logger "Test Thrust and CUB..."
ctest ${CTEST_FLAGS} "${@}"
ctest ${CTEST_FLAGS}

61 changes: 50 additions & 11 deletions ci/common/determine_build_parallelism.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,55 @@
# Released under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.

function usage {
echo "Usage: ${0} [flags...]"
echo
echo "Examine the system topology to determine a reasonable amount of build"
echo "parallelism."
echo
echo "Exported variables:"
echo " $${LOGICAL_CPUS} : Logical processors (e.g. hyperthreads)."
echo " $${PHYSICAL_CPUS} : Physical processors (e.g. cores)."
echo " $${TOTAL_MEM_KB} : Total system memory."
echo " $${CPU_BOUND_THREADS} : # of build threads constrained by processors."
echo " $${MEM_BOUND_THREADS} : # of build threads constrained by memory."
echo " $${PARLLEL_LEVEL} : Determined # of build threads."
echo
echo "-h, -help, --help"
echo " Print this message."
echo
echo "-q, --quiet"
echo " Print nothing and only export variables."

exit -3
}

QUIET=0

while test ${#} != 0
do
case "${1}" in
-h) ;&
-help) ;&
--help) usage ;;
-q) ;&
--quiet) QUIET=1 ;;
esac
shift
done

# https://stackoverflow.com/a/23378780
if [ $(uname) == "Darwin" ]; then
export LOGICAL_CPU_COUNT=$(sysctl -n hw.logicalcpu_max)
export PHYSICAL_CPU_COUNT=$(sysctl -n hw.physicalcpu_max)
export LOGICAL_CPUS=$(sysctl -n hw.logicalcpu_max)
export PHYSICAL_CPUS=$(sysctl -n hw.physicalcpu_max)
else
export LOGICAL_CPU_COUNT=$(lscpu -p | egrep -v '^#' | wc -l)
export PHYSICAL_CPU_COUNT=$(lscpu -p | egrep -v '^#' | sort -u -t, -k 2,4 | wc -l)
export LOGICAL_CPUS=$(lscpu -p | egrep -v '^#' | wc -l)
export PHYSICAL_CPUS=$(lscpu -p | egrep -v '^#' | sort -u -t, -k 2,4 | wc -l)
fi

export TOTAL_MEM_KB=`grep MemTotal /proc/meminfo | awk '{print $2}'`

export CPU_BOUND_THREADS=$((${PHYSICAL_CPU_COUNT} * 2)) # 2 Build Threads / Core
export CPU_BOUND_THREADS=$((${PHYSICAL_CPUS} * 2)) # 2 Build Threads / Core
export MEM_BOUND_THREADS=$((${TOTAL_MEM_KB} / (2 * 1000 * 1000))) # 2 GB / Build Thread

# Pick the smaller of the two as the default.
Expand All @@ -26,10 +63,12 @@ else
export PARLLEL_LEVEL=${CPU_BOUND_THREADS}
fi

echo "Logical CPU Count: ${LOGICAL_CPU_COUNT} [threads]"
echo "Physical CPU Count: ${PHYSICAL_CPU_COUNT} [cores]"
echo "Total Mem: ${TOTAL_MEM_KB} [kb]"
echo "CPU Bound Jobs: ${CPU_BOUND_THREADS}"
echo "Mem Bound Jobs: ${MEM_BOUND_THREADS}"
echo "Parallel Level: ${PARLLEL_LEVEL} [threads]"
if [ "${QUIET}" == 0 ]; then
echo "Logical CPUs: ${LOGICAL_CPUS} [threads]"
echo "Physical CPUs: ${PHYSICAL_CPUS} [cores]"
echo "Total Mem: ${TOTAL_MEM_KB} [kb]"
echo "CPU Bound Threads: ${CPU_BOUND_THREADS} [threads]"
echo "Mem Bound Threads: ${MEM_BOUND_THREADS} [threads]"
echo "Parallel Level: ${PARLLEL_LEVEL} [threads]"
fi

8 changes: 6 additions & 2 deletions ci/local/build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ if [ "${NVIDIA_DOCKER_INSTALLED}" == 0 ]; then
exit -4
fi

source ${REPOSITORY_PATH}/ci/common/determine_build_parallelism.bash
if [ "${SHELL_ONLY}" != 0 ]; then
DETERMINE_PARALLELISM_FLAGS=--quiet
fi
source ${REPOSITORY_PATH}/ci/common/determine_build_parallelism.bash \
${DETERMINE_PARALLELISM_FLAGS}

if [ "${LOCAL_IMAGE}" == 0 ]; then
docker pull "${IMAGE}"
Expand All @@ -191,6 +195,6 @@ docker run --rm -it ${GPU_OPTS} \
-e "WORKSPACE=${REPOSITORY_PATH_IN_CONTAINER}" \
-e "BUILD_TYPE=gpu" \
-e "PARALLEL_LEVEL=${PARALLEL_LEVEL}" \
-w "${REPOSITORY_PATH_IN_CONTAINER}" \
-w "${BUILD_PATH_IN_CONTAINER}" \
"${IMAGE}" bash -c "${COMMAND}"

0 comments on commit 42ae146

Please sign in to comment.