From 06c027d8a33e744ed04a91a52825dbfc04866ac2 Mon Sep 17 00:00:00 2001 From: divyegala Date: Thu, 13 Apr 2023 11:36:32 -0700 Subject: [PATCH 1/4] add ability to pass a filename for generating build metrics --- build.sh | 37 ++++++++++++++----- conda/recipes/libraft/build_libraft.sh | 2 +- .../recipes/libraft/build_libraft_nn_bench.sh | 2 +- conda/recipes/libraft/build_libraft_tests.sh | 2 +- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/build.sh b/build.sh index 270c75de93..e4bfdbaf2f 100755 --- a/build.sh +++ b/build.sh @@ -18,8 +18,8 @@ ARGS=$* # scripts, and that this script resides in the repo dir! REPODIR=$(cd $(dirname $0); pwd) -VALIDARGS="clean libraft pylibraft raft-dask docs tests template bench-prims bench-ann clean --uninstall -v -g -n --compile-lib --allgpuarch --no-nvtx --show_depr_warn --build-metrics --incl-cache-stats --time -h" -HELP="$0 [ ...] [ ...] [--cmake-args=\"\"] [--cache-tool=] [--limit-tests=] [--limit-bench-prims=] [--limit-bench-ann=] +VALIDARGS="clean libraft pylibraft raft-dask docs tests template bench-prims bench-ann clean --uninstall -v -g -n --compile-lib --allgpuarch --no-nvtx --show_depr_warn --incl-cache-stats --time -h" +HELP="$0 [ ...] [ ...] [--cmake-args=\"\"] [--cache-tool=] [--limit-tests=] [--limit-bench-prims=] [--limit-bench-ann=] [--build-metrics=] where is: clean - remove all existing build artifacts and configuration (start over) libraft - build the raft C++ code only. Also builds the C-wrapper library @@ -45,7 +45,7 @@ HELP="$0 [ ...] [ ...] [--cmake-args=\"\"] [--cache-tool=\\\" - pass arbitrary list of CMake configuration options (escape all quotes in argument) --cache-tool= - pass the build cache tool (eg: ccache, sccache, distcc) that will be used @@ -73,7 +73,7 @@ BUILD_PRIMS_BENCH=OFF BUILD_ANN_BENCH=OFF COMPILE_LIBRARY=OFF INSTALL_TARGET=install -BUILD_REPORT_METRICS=OFF +BUILD_REPORT_METRICS="" BUILD_REPORT_INCL_CACHE_STATS=OFF TEST_TARGETS="CLUSTER_TEST;CORE_TEST;DISTANCE_TEST;LABEL_TEST;LINALG_TEST;MATRIX_TEST;RANDOM_TEST;SOLVERS_TEST;SPARSE_TEST;SPARSE_DIST_TEST;SPARSE_NEIGHBORS_TEST;NEIGHBORS_TEST;STATS_TEST;UTILS_TEST" @@ -189,6 +189,25 @@ function limitAnnBench { fi } +function buildMetrics { + # Check for multiple build-metrics options + if [[ $(echo $ARGS | { grep -Eo "\-\-build\-metrics" || true; } | wc -l ) -gt 1 ]]; then + echo "Multiple --build-metrics options were provided, please provide only one: ${ARGS}" + exit 1 + fi + # Check for cache tool option + if [[ -n $(echo $ARGS | { grep -E "\-\-build\-metrics" || true; } ) ]]; then + # There are possible weird edge cases that may cause this regex filter to output nothing and fail silently + # the true pipe will catch any weird edge cases that may happen and will cause the program to fall back + # on the invalid option error + BUILD_REPORT_METRICS=$(echo $ARGS | sed -e 's/.*--build-metrics=//' -e 's/ .*//') + if [[ -n ${BUILD_REPORT_METRICS} ]]; then + # Remove the full BUILD_REPORT_METRICS argument from list of args so that it passes validArgs function + ARGS=${ARGS//--build-metrics=$BUILD_REPORT_METRICS/} + fi + fi +} + if hasArg -h || hasArg --help; then echo "${HELP}" exit 0 @@ -201,6 +220,7 @@ if (( ${NUMARGS} != 0 )); then limitTests limitBench limitAnnBench + buildMetrics for a in ${ARGS}; do if ! (echo " ${VALIDARGS} " | grep -q " ${a} "); then echo "Invalid option: ${a}" @@ -339,9 +359,6 @@ fi if hasArg clean; then CLEAN=1 fi -if hasArg --build-metrics; then - BUILD_REPORT_METRICS=ON -fi if hasArg --incl-cache-stats; then BUILD_REPORT_INCL_CACHE_STATS=ON fi @@ -422,7 +439,7 @@ if (( ${NUMARGS} == 0 )) || hasArg libraft || hasArg docs || hasArg tests || has compile_end=$(date +%s) compile_total=$(( compile_end - compile_start )) - if [[ "$BUILD_REPORT_METRICS" == "ON" && -f "${LIBRAFT_BUILD_DIR}/.ninja_log" ]]; then + if [[ -n "$BUILD_REPORT_METRICS" && -f "${LIBRAFT_BUILD_DIR}/.ninja_log" ]]; then if ! rapids-build-metrics-reporter.py 2> /dev/null && [ ! -f rapids-build-metrics-reporter.py ]; then echo "Downloading rapids-build-metrics-reporter.py" curl -sO https://raw.githubusercontent.com/rapidsai/build-metrics-reporter/v1/rapids-build-metrics-reporter.py @@ -454,13 +471,13 @@ if (( ${NUMARGS} == 0 )) || hasArg libraft || hasArg docs || hasArg tests || has MSG="${MSG}
libraft.so size: $LIBRAFT_FS" fi BMR_DIR=${RAPIDS_ARTIFACTS_DIR:-"${LIBRAFT_BUILD_DIR}"} - echo "The HTML report can be found at [${BMR_DIR}/ninja_log.html]. In CI, this report" + echo "The HTML report can be found at [${BMR_DIR}/${BUILD_REPORT_METRICS}.html]. In CI, this report" echo "will also be uploaded to the appropriate subdirectory of https://downloads.rapids.ai/ci/raft/, and" echo "the entire URL can be found in \"conda-cpp-build\" runs under the task \"Upload additional artifacts\"" mkdir -p ${BMR_DIR} MSG_OUTFILE="$(mktemp)" echo "$MSG" > "${MSG_OUTFILE}" - PATH=".:$PATH" python rapids-build-metrics-reporter.py ${LIBRAFT_BUILD_DIR}/.ninja_log --fmt html --msg "${MSG_OUTFILE}" > ${BMR_DIR}/ninja_log.html + PATH=".:$PATH" python rapids-build-metrics-reporter.py ${LIBRAFT_BUILD_DIR}/.ninja_log --fmt html --msg "${MSG_OUTFILE}" > ${BMR_DIR}/${BUILD_REPORT_METRICS}.html cp ${LIBRAFT_BUILD_DIR}/.ninja_log ${BMR_DIR}/ninja.log fi fi diff --git a/conda/recipes/libraft/build_libraft.sh b/conda/recipes/libraft/build_libraft.sh index 2bf9b428cb..7d4173e8bb 100644 --- a/conda/recipes/libraft/build_libraft.sh +++ b/conda/recipes/libraft/build_libraft.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash # Copyright (c) 2022-2023, NVIDIA CORPORATION. -./build.sh libraft --allgpuarch --compile-lib --build-metrics --incl-cache-stats --no-nvtx +./build.sh libraft --allgpuarch --compile-lib --build-metrics=compile_lib --incl-cache-stats --no-nvtx diff --git a/conda/recipes/libraft/build_libraft_nn_bench.sh b/conda/recipes/libraft/build_libraft_nn_bench.sh index dc6250f0f4..861fafca43 100644 --- a/conda/recipes/libraft/build_libraft_nn_bench.sh +++ b/conda/recipes/libraft/build_libraft_nn_bench.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash # Copyright (c) 2023, NVIDIA CORPORATION. -./build.sh tests bench-ann --allgpuarch --no-nvtx +./build.sh tests bench-ann --allgpuarch --no-nvtx --build-metrics=bench_ann --incl-cache-stats cmake --install cpp/build --component ann_bench diff --git a/conda/recipes/libraft/build_libraft_tests.sh b/conda/recipes/libraft/build_libraft_tests.sh index cc28f93fb8..05a2b59eb0 100644 --- a/conda/recipes/libraft/build_libraft_tests.sh +++ b/conda/recipes/libraft/build_libraft_tests.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash # Copyright (c) 2022-2023, NVIDIA CORPORATION. -./build.sh tests bench-prims --allgpuarch --no-nvtx +./build.sh tests bench-prims --allgpuarch --no-nvtx --build-metrics=tests_bench_prims --incl-cache-stats cmake --install cpp/build --component testing From bbb3e78146530f261f5a7036d9723161703c0d9c Mon Sep 17 00:00:00 2001 From: divyegala Date: Thu, 13 Apr 2023 12:43:27 -0700 Subject: [PATCH 2/4] provide list of ann bench targets --- build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index e4bfdbaf2f..6dcf63290c 100755 --- a/build.sh +++ b/build.sh @@ -78,6 +78,7 @@ BUILD_REPORT_INCL_CACHE_STATS=OFF TEST_TARGETS="CLUSTER_TEST;CORE_TEST;DISTANCE_TEST;LABEL_TEST;LINALG_TEST;MATRIX_TEST;RANDOM_TEST;SOLVERS_TEST;SPARSE_TEST;SPARSE_DIST_TEST;SPARSE_NEIGHBORS_TEST;NEIGHBORS_TEST;STATS_TEST;UTILS_TEST" BENCH_TARGETS="CLUSTER_BENCH;NEIGHBORS_BENCH;DISTANCE_BENCH;LINALG_BENCH;MATRIX_BENCH;SPARSE_BENCH;RANDOM_BENCH" +ANN_BENCH_TARGETS="HNSWLIB;RAFT_IVF_PQ;FAISS_IVF_FLAT;GGNN" CACHE_ARGS="" NVTX=ON @@ -195,7 +196,7 @@ function buildMetrics { echo "Multiple --build-metrics options were provided, please provide only one: ${ARGS}" exit 1 fi - # Check for cache tool option + # Check for build-metrics option if [[ -n $(echo $ARGS | { grep -E "\-\-build\-metrics" || true; } ) ]]; then # There are possible weird edge cases that may cause this regex filter to output nothing and fail silently # the true pipe will catch any weird edge cases that may happen and will cause the program to fall back From 44a5067063f9f6ba59d06cf07873774803c36665 Mon Sep 17 00:00:00 2001 From: divyegala Date: Thu, 13 Apr 2023 13:01:26 -0700 Subject: [PATCH 3/4] correct ann bench targets --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 6dcf63290c..6b4be77196 100755 --- a/build.sh +++ b/build.sh @@ -78,7 +78,7 @@ BUILD_REPORT_INCL_CACHE_STATS=OFF TEST_TARGETS="CLUSTER_TEST;CORE_TEST;DISTANCE_TEST;LABEL_TEST;LINALG_TEST;MATRIX_TEST;RANDOM_TEST;SOLVERS_TEST;SPARSE_TEST;SPARSE_DIST_TEST;SPARSE_NEIGHBORS_TEST;NEIGHBORS_TEST;STATS_TEST;UTILS_TEST" BENCH_TARGETS="CLUSTER_BENCH;NEIGHBORS_BENCH;DISTANCE_BENCH;LINALG_BENCH;MATRIX_BENCH;SPARSE_BENCH;RANDOM_BENCH" -ANN_BENCH_TARGETS="HNSWLIB;RAFT_IVF_PQ;FAISS_IVF_FLAT;GGNN" +ANN_BENCH_TARGETS="HNSWLIB_ANN_BENCH;RAFT_IVF_PQ_ANN_BENCH;FAISS_IVF_FLAT_ANN_BENCH;GGNN_ANN_BENCH" CACHE_ARGS="" NVTX=ON From 0f29c6a9c621e3675c26ad89442e643c49103c05 Mon Sep 17 00:00:00 2001 From: divyegala Date: Thu, 13 Apr 2023 13:04:57 -0700 Subject: [PATCH 4/4] remove building test in ann bench --- build.sh | 1 - conda/recipes/libraft/build_libraft_nn_bench.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 6b4be77196..039f0ed6a5 100755 --- a/build.sh +++ b/build.sh @@ -78,7 +78,6 @@ BUILD_REPORT_INCL_CACHE_STATS=OFF TEST_TARGETS="CLUSTER_TEST;CORE_TEST;DISTANCE_TEST;LABEL_TEST;LINALG_TEST;MATRIX_TEST;RANDOM_TEST;SOLVERS_TEST;SPARSE_TEST;SPARSE_DIST_TEST;SPARSE_NEIGHBORS_TEST;NEIGHBORS_TEST;STATS_TEST;UTILS_TEST" BENCH_TARGETS="CLUSTER_BENCH;NEIGHBORS_BENCH;DISTANCE_BENCH;LINALG_BENCH;MATRIX_BENCH;SPARSE_BENCH;RANDOM_BENCH" -ANN_BENCH_TARGETS="HNSWLIB_ANN_BENCH;RAFT_IVF_PQ_ANN_BENCH;FAISS_IVF_FLAT_ANN_BENCH;GGNN_ANN_BENCH" CACHE_ARGS="" NVTX=ON diff --git a/conda/recipes/libraft/build_libraft_nn_bench.sh b/conda/recipes/libraft/build_libraft_nn_bench.sh index 861fafca43..00078792a1 100644 --- a/conda/recipes/libraft/build_libraft_nn_bench.sh +++ b/conda/recipes/libraft/build_libraft_nn_bench.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash # Copyright (c) 2023, NVIDIA CORPORATION. -./build.sh tests bench-ann --allgpuarch --no-nvtx --build-metrics=bench_ann --incl-cache-stats +./build.sh bench-ann --allgpuarch --no-nvtx --build-metrics=bench_ann --incl-cache-stats cmake --install cpp/build --component ann_bench