Skip to content

Commit

Permalink
Merge branch 'main' into jrhemstad-patch-13
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhemstad committed Dec 4, 2023
2 parents e5e18ec + 1570b18 commit 807e2ac
Show file tree
Hide file tree
Showing 96 changed files with 10,000 additions and 9,580 deletions.
14 changes: 14 additions & 0 deletions .github/problem-matchers/problem-matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"problemMatcher": [
{
"owner": "nvcc",
"pattern": [
{
"regexp": "^\\/home\\/coder\\/(.+):(\\d+):(\\d+): (\\w+): \"(.+)\"$",
"severity": 4,
"message": 5
}
]
}
]
}
1 change: 0 additions & 1 deletion .github/workflows/build-and-test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,4 @@ jobs:
runner: linux-${{inputs.cpu}}-gpu-v100-latest-1
image: ${{inputs.container_image}}
command: |
nvidia-smi
${{ inputs.test_script }}
83 changes: 83 additions & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Deploy CCCL pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v3

# Build helper image for Thrust/CUB
- name: Build helper image
run: |
bash ./docs/make_env.bash "cccl:docs"
# Build top level docs for CCCL
- name: Build landing page
uses: actions/jekyll-build-pages@v1
with:
source: ./docs/jekyll
destination: ./_site

# CUB
- name: Build CUB docs
run: |
bash ./docs/build_docs.bash "cccl:docs" /cccl/cub/docs/gen_docs.bash
sudo mkdir -p ./_site/cub
sudo cp -rf ./cub/docs/_build/docs/CUB/latest/* ./_site/cub
# Libcudacxx
- name: Build libcudacxx docs
uses: actions/jekyll-build-pages@v1
with:
source: ./libcudacxx/docs
destination: ./_site/libcudacxx

# Thrust
- name: Build Thrust markdown in Docker
run: bash ./docs/build_docs.bash "cccl:docs" /cccl/thrust/docs/build_docs_locally.bash

- name: Build Thrust docs
uses: actions/jekyll-build-pages@v1
with:
source: ./thrust/build_docs/github_pages
destination: ./_site/thrust

# Upload build artifacts
- name: Upload artifact
uses: actions/upload-pages-artifact@v2

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
22 changes: 17 additions & 5 deletions .github/workflows/run-as-coder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,30 @@ jobs:
run: |
cp -R cccl /home/coder/cccl
chown -R coder:coder /home/coder/
- name: Add NVCC problem matcher
run: |
echo "::add-matcher::cccl/.github/problem-matchers/problem-matcher.json"
- name: Configure credentials and environment variables for sccache
uses: ./cccl/.github/actions/configure_cccl_sccache
- name: Run command
shell: su coder {0}
run: |
set -exo pipefail
set -eo pipefail
cd ~/cccl
echo -e "\e[1;34mRunning as 'coder' user in $(pwd):\e[0m"
echo -e "\e[1;34m${{inputs.command}}\e[0m"
eval "${{inputs.command}}" || exit_code=$?
if [ ! -z "$exit_code" ]; then
echo "::error::Error! To checkout the corresponding code and reproduce locally, run the following commands:"
echo "git clone --branch $GITHUB_REF_NAME --single-branch --recurse-submodules https://github.com/$GITHUB_REPOSITORY.git && cd $(echo $GITHUB_REPOSITORY | cut -d'/' -f2) && git checkout $GITHUB_SHA"
echo "docker run --rm -it --gpus all --pull=always --volume \$PWD:/repo --workdir /repo ${{ inputs.image }} ${{inputs.command}}"
exit $exit_code
echo -e "::group::️❗ \e[1;31mInstructions to Reproduce CI Failure Locally\e[0m"
echo "::error:: To replicate this failure locally, follow the steps below:"
echo "1. Clone the repository, and navigate to the correct branch and commit:"
echo " git clone --branch $GITHUB_REF_NAME --single-branch https://github.com/$GITHUB_REPOSITORY.git && cd $(echo $GITHUB_REPOSITORY | cut -d'/' -f2) && git checkout $GITHUB_SHA"
echo ""
echo "2. Run the failed command inside the same Docker container used by the CI:"
echo " docker run --rm -it --gpus all --pull=always --volume \$PWD:/repo --workdir /repo ${{ inputs.image }} ${{inputs.command}}"
echo ""
echo "For additional information, see:"
echo " - DevContainer Documentation: https://github.com/NVIDIA/cccl/blob/main/.devcontainer/README.md"
echo " - Continuous Integration (CI) Overview: https://github.com/NVIDIA/cccl/blob/main/ci-overview.md"
fi
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/NVIDIA/cccl?quickstart=1&devcontainer_path=.devcontainer%2Fdevcontainer.json)

|[Contributor Guide](https://github.com/NVIDIA/cccl/blob/main/CONTRIBUTING.md)|[Dev Containers](https://github.com/NVIDIA/cccl/blob/main/.devcontainer/README.md)|[Discord](https://discord.gg/nvidiadeveloper)|[Godbolt](https://godbolt.org/z/x4G73af9a)|[GitHub Project](https://github.com/orgs/NVIDIA/projects/6)|[libcudacxx Docs](https://nvidia.github.io/libcudacxx/)|[Thrust Docs](https://nvidia.github.io/thrust/)|[CUB Docs](https://nvlabs.github.io/cub/)|
|[Contributor Guide](https://github.com/NVIDIA/cccl/blob/main/CONTRIBUTING.md)|[Dev Containers](https://github.com/NVIDIA/cccl/blob/main/.devcontainer/README.md)|[Discord](https://discord.gg/nvidiadeveloper)|[Godbolt](https://godbolt.org/z/x4G73af9a)|[GitHub Project](https://github.com/orgs/NVIDIA/projects/6)|[libcudacxx Docs](https://nvidia.github.io/cccl/libcudacxx/)|[Thrust Docs](https://nvidia.github.io/cccl/thrust/)|[CUB Docs](https://nvidia.github.io/cccl/cub/)|
|-|-|-|-|-|-|-|-|

# CUDA C++ Core Libraries (CCCL)
Expand Down
198 changes: 161 additions & 37 deletions ci/build_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ function usage {
# Copy the args into a temporary array, since we will modify them and
# the parent script may still need them.
args=("$@")
echo "Args: ${args[@]}"
while [ "${#args[@]}" -ne 0 ]; do
case "${args[0]}" in
-v | --verbose) VERBOSE=1; args=("${args[@]:1}");;
Expand Down Expand Up @@ -90,7 +89,6 @@ export CTEST_PARALLEL_LEVEL="1"
export CXX="${HOST_COMPILER}"
export CUDACXX="${CUDA_COMPILER}"
export CUDAHOSTCXX="${HOST_COMPILER}"

export CXX_STANDARD

# Print "ARG=${ARG}" for all args.
Expand All @@ -107,67 +105,193 @@ function print_var_values() {
done
}

echo "========================================"
echo "pwd=$(pwd)"
print_var_values \
BUILD_DIR \
CXX_STANDARD \
CXX \
CUDACXX \
CUDAHOSTCXX \
NVCC_VERSION \
CMAKE_BUILD_PARALLEL_LEVEL \
CTEST_PARALLEL_LEVEL \
CCCL_BUILD_INFIX \
GLOBAL_CMAKE_OPTIONS
echo "========================================"
echo
echo "========================================"
echo "Current commit is:"
git log -1 || echo "Not a repository"
echo "========================================"
echo
# begin_group: Start a named section of log output, possibly with color.
# Usage: begin_group "Group Name" [Color]
# Group Name: A string specifying the name of the group.
# Color (optional): ANSI color code to set text color. Default is blue (1;34).
function begin_group() {
# See options for colors here: https://gist.github.com/JBlond/2fea43a3049b38287e5e9cefc87b2124
local blue="34"
local name="${1:-}"
local color="${2:-$blue}"

if [ -n "${GITHUB_ACTIONS:-}" ]; then
echo -e "::group::\e[${color}m${name}\e[0m"
else
echo -e "\e[${color}m================== ${name} ======================\e[0m"
fi
}

# end_group: End a named section of log output and print status based on exit status.
# Usage: end_group "Group Name" [Exit Status]
# Group Name: A string specifying the name of the group.
# Exit Status (optional): The exit status of the command run within the group. Default is 0.
function end_group() {
local name="${1:-}"
local build_status="${2:-0}"
local duration="${3:-}"
local red="31"
local blue="34"

if [ -n "${GITHUB_ACTIONS:-}" ]; then
echo "::endgroup::"

if [ "$build_status" -ne 0 ]; then
echo -e "::error::\e[${red}m ${name} - Failed (⬆️ click above for full log ⬆️)\e[0m"
fi
else
if [ "$build_status" -ne 0 ]; then
echo -e "\e[${red}m================== End ${name} - Failed${duration:+ - Duration: ${duration}s} ==================\e[0m"
else
echo -e "\e[${blue}m================== End ${name} - Success${duration:+ - Duration: ${duration}s} ==================\n\e[0m"
fi
fi
}

declare -A command_durations

# Runs a command within a named group, handles the exit status, and prints appropriate messages based on the result.
# Usage: run_command "Group Name" command [arguments...]
function run_command() {
local group_name="${1:-}"
shift
local command=("$@")
local status

begin_group "$group_name"
set +e
local start_time=$(date +%s)
"${command[@]}"
status=$?
local end_time=$(date +%s)
set -e
local duration=$((end_time - start_time))
end_group "$group_name" $status $duration
command_durations["$group_name"]=$duration
return $status
}

function string_width() {
local str="$1"
echo "$str" | awk '{print length}'
}

function print_time_summary() {
local max_length=0
local group

# Find the longest group name for formatting
for group in "${!command_durations[@]}"; do
local group_length=$(echo "$group" | awk '{print length}')
if [ "$group_length" -gt "$max_length" ]; then
max_length=$group_length
fi
done

echo "Time Summary:"
for group in "${!command_durations[@]}"; do
printf "%-${max_length}s : %s seconds\n" "$group" "${command_durations[$group]}"
done

# Clear the array of timing info
declare -gA command_durations=()
}


print_environment_details() {
begin_group "⚙️ Environment Details"

echo "pwd=$(pwd)"

print_var_values \
BUILD_DIR \
CXX_STANDARD \
CXX \
CUDACXX \
CUDAHOSTCXX \
NVCC_VERSION \
CMAKE_BUILD_PARALLEL_LEVEL \
CTEST_PARALLEL_LEVEL \
CCCL_BUILD_INFIX \
GLOBAL_CMAKE_OPTIONS

echo "Current commit is:"
git log -1 || echo "Not a repository"

if command -v nvidia-smi &> /dev/null; then
nvidia-smi
else
echo "nvidia-smi not found"
fi

end_group "⚙️ Environment Details"
}


function configure_preset()
{
local BUILD_NAME=$1
local PRESET=$2
local CMAKE_OPTIONS=$3
local GROUP_NAME="🛠️ CMake Configure ${BUILD_NAME}"

pushd .. > /dev/null

cmake --preset=$PRESET --log-level=VERBOSE $GLOBAL_CMAKE_OPTIONS $CMAKE_OPTIONS
echo "$BUILD_NAME configure complete."

run_command "$GROUP_NAME" cmake --preset=$PRESET --log-level=VERBOSE $GLOBAL_CMAKE_OPTIONS $CMAKE_OPTIONS
status=$?
popd > /dev/null
return $status
}

function build_preset()
{
function build_preset() {
local BUILD_NAME=$1
local PRESET=$2
local green="1;32"
local red="1;31"
local GROUP_NAME="🏗️ Build ${BUILD_NAME}"

source "./sccache_stats.sh" "start"
pushd .. > /dev/null

cmake --build --preset=$PRESET -v
echo "$BUILD_NAME build complete."

pushd .. > /dev/null
run_command "$GROUP_NAME" cmake --build --preset=$PRESET -v
status=$?
popd > /dev/null
source "./sccache_stats.sh" "end"

minimal_sccache_stats=$(source "./sccache_stats.sh" "end")

# Only print detailed stats in actions workflow
if [ -n "${GITHUB_ACTIONS:-}" ]; then
begin_group "💲 sccache stats"
echo "${minimal_sccache_stats}"
sccache -s
end_group

begin_group "🥷 ninja build times"
echo "The "weighted" time is the elapsed time of each build step divided by the number
of tasks that were running in parallel. This makes it an excellent approximation
of how "important" a slow step was. A link that is entirely or mostly serialized
will have a weighted time that is the same or similar to its elapsed time. A
compile that runs in parallel with 999 other compiles will have a weighted time
that is tiny."
./ninja_summary.py -C ${BUILD_DIR}/${PRESET}
end_group
else
echo $minimal_sccache_stats
fi

return $status
}

function test_preset()
{
local BUILD_NAME=$1
local PRESET=$2
local GROUP_NAME="🚀 Test ${BUILD_NAME}"

pushd .. > /dev/null

ctest --preset=$PRESET
echo "$BUILD_NAME testing complete."

run_command "$GROUP_NAME" ctest --preset=$PRESET
status=$?
popd > /dev/null
return $status
}

function configure_and_build_preset()
Expand Down
Loading

0 comments on commit 807e2ac

Please sign in to comment.