Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions ci/common/build.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#! /usr/bin/env bash

# Copyright (c) 2018-2020 NVIDIA Corporation
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Released under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.

################################################################################
# Thrust and CUB build script for gpuCI
################################################################################

set -e

# Logger function for build status output
function logger() {
echo -e "\n>>>> ${@}\n"
}

################################################################################
# VARIABLES - Set up bash and environmental variables.
################################################################################

# Get the variables the Docker container set up for us: ${CXX}, ${CUDACXX}, etc.
source /etc/cccl.bashrc

# Set path and build parallel level
export PATH=/usr/local/cuda/bin:${PATH}

# Set home to the job's workspace.
export HOME=${WORKSPACE}

# 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}'"

if [ "${BUILD_MODE}" == "branch" ]; then
# Post-commit build.
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_INCLUDE_CUB_CMAKE=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_ENABLE_MULTICONFIG=ON"
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=LARGE"
else
# Pre-commit build.
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_DISABLE_ARCH_BY_DEFAULT=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_ENABLE_COMPUTE_50=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_ENABLE_COMPUTE_60=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_ENABLE_COMPUTE_70=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_ENABLE_COMPUTE_80=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_INCLUDE_CUB_CMAKE=ON"
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_ENABLE_MULTICONFIG=ON"
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"
fi

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things to be aware of:

  1. This only supports a single target.
  2. This won't work with configuration metatargets because of the trailing $

fi

################################################################################
# ENVIRONMENT - Configure and print out information about the environment.
################################################################################

logger "Get environment..."
env

logger "Check versions..."
${CXX} --version
${CUDACXX} --version

################################################################################
# BUILD - Build Thrust and CUB examples and tests.
################################################################################

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

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

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

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

74 changes: 74 additions & 0 deletions ci/common/determine_build_parallelism.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#! /usr/bin/env bash

# Copyright (c) 2018-2020 NVIDIA Corporation
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# 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_CPUS=$(sysctl -n hw.logicalcpu_max)
export PHYSICAL_CPUS=$(sysctl -n hw.physicalcpu_max)
else
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_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.
if [ ${MEM_BOUND_THREADS} -lt ${CPU_BOUND_THREADS} ]; then
export PARLLEL_LEVEL=${MEM_BOUND_THREADS}
else
export PARLLEL_LEVEL=${CPU_BOUND_THREADS}
fi

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

68 changes: 10 additions & 58 deletions ci/cpu/build.bash
Original file line number Diff line number Diff line change
@@ -1,67 +1,19 @@
#!/usr/bin/env bash
# Copyright (c) 2018-2020 NVIDIA Corporation

#################################
# Thrust CPU-only script for CI #
#################################

set -e

# Logger function for build status output
function logger() {
echo -e "\n>>>> ${@}\n"
}

# Set path and build parallel level
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.
cd ${WORKSPACE}

# If it's a nightly build, append current YYMMDD to version.
if [[ "${BUILD_MODE}" = "branch" ]] ; then
export VERSION_SUFFIX=`date +%y%m%d`
fi

# The Docker image sets up `c++` and `cu++`.
CMAKE_FLAGS="-DCMAKE_CXX_COMPILER=c++ -DCMAKE_CUDA_COMPILER=cu++"
#! /usr/bin/env bash

# If it's a nightly build, build all configurations.
if [[ "${BUILD_MODE}" = "branch" ]] ; then
CMAKE_FLAGS="${CMAKE_FLAGS} -DTHRUST_MULTICONFIG_WORKLOAD=FULL"
fi

################################################################################
# SETUP - Check environment.
################################################################################

logger "Get env..."
env

logger "Check versions..."
c++ --version
cu++ --version
# Copyright (c) 2018-2020 NVIDIA Corporation
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Released under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.

################################################################################
# BUILD - Build Thrust examples and tests.
# Thrust and CUB build script for gpuCI (CPU-only)
################################################################################

mkdir build
cd build

logger "Configure Thrust..."
cmake ${CMAKE_OPTIONS} ..
SCRIPT_PATH=$(cd $(dirname ${0}); pwd -P)

logger "Build Thrust..."
cmake --build . -j
REPOSITORY_PATH=$(realpath ${SCRIPT_PATH}/../..)

################################################################################
# TEST - Run Thrust CPU-only examples and tests.
################################################################################
export PARALLEL_LEVEL=4

logger "Test Thrust (CPU-only)..."
ctest -E "^cub|^thrust.*cuda"
source ${REPOSITORY_PATH}/ci/common/build.bash

19 changes: 19 additions & 0 deletions ci/gpu/build.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /usr/bin/env bash

# Copyright (c) 2018-2020 NVIDIA Corporation
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Released under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.

################################################################################
# Thrust and CUB build script for gpuCI (heterogeneous)
################################################################################

SCRIPT_PATH=$(cd $(dirname ${0}); pwd -P)

REPOSITORY_PATH=$(realpath ${SCRIPT_PATH}/../..)

export PARALLEL_LEVEL=4

source ${REPOSITORY_PATH}/ci/common/build.bash

Loading