From 6401ef2e17925736cf1db0dae1c9ee82789f0cfb Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Wed, 20 Mar 2024 03:29:40 +0000 Subject: [PATCH 01/22] updates for libcudf examples cmake files --- cpp/examples/build.sh | 3 ++- cpp/examples/fetch_dependencies.cmake | 25 ++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/cpp/examples/build.sh b/cpp/examples/build.sh index 001cdeec694..aca73d6d158 100755 --- a/cpp/examples/build.sh +++ b/cpp/examples/build.sh @@ -10,6 +10,7 @@ PARALLEL_LEVEL=${PARALLEL_LEVEL:-4} # Root of examples EXAMPLES_DIR=$(dirname "$(realpath "$0")") LIB_BUILD_DIR=${LIB_BUILD_DIR:-$(readlink -f "${EXAMPLES_DIR}/../build")} +RAPIDS_ARCHS='70;80' # TODO: more generic one needed ################################################################################ # Add individual libcudf examples build scripts down below @@ -20,7 +21,7 @@ build_example() { build_dir="${example_dir}/build" # Configure - cmake -S ${example_dir} -B ${build_dir} -Dcudf_ROOT="${LIB_BUILD_DIR}" + cmake -S ${example_dir} -B ${build_dir} -Dcudf_ROOT="${LIB_BUILD_DIR}" -DCMAKE_CUDA_ARCHITECTURES="${RAPIDS_ARCHS}" # Build cmake --build ${build_dir} -j${PARALLEL_LEVEL} } diff --git a/cpp/examples/fetch_dependencies.cmake b/cpp/examples/fetch_dependencies.cmake index e4c11bbdeca..53b96e5526c 100644 --- a/cpp/examples/fetch_dependencies.cmake +++ b/cpp/examples/fetch_dependencies.cmake @@ -19,12 +19,19 @@ file( ) include(${CMAKE_BINARY_DIR}/cmake/get_cpm.cmake) -set(CUDF_TAG branch-24.06) -CPMFindPackage( - NAME cudf GIT_REPOSITORY https://github.com/rapidsai/cudf - GIT_TAG ${CUDF_TAG} - GIT_SHALLOW - TRUE - SOURCE_SUBDIR - cpp -) +# try to find an already built libcudf and use it. +find_package(cudf HINTS ${cudf_ROOT}/latest) + +# build it via CPM +if (NOT cudf_FOUND) + set(CUDF_TAG branch-24.06) + + CPMFindPackage( + NAME cudf GIT_REPOSITORY https://github.com/rapidsai/cudf + GIT_TAG ${CUDF_TAG} + GIT_SHALLOW + TRUE + SOURCE_SUBDIR + cpp + ) +endif() From 360d78ae0108a8fae7e18c94d01e9e8332816c3e Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Wed, 20 Mar 2024 22:16:21 +0000 Subject: [PATCH 02/22] Applying suggested fixes --- cpp/examples/basic/CMakeLists.txt | 4 +++- cpp/examples/build.sh | 5 ++--- cpp/examples/fetch_dependencies.cmake | 28 +++++++++++------------- cpp/examples/nested_types/CMakeLists.txt | 4 +++- cpp/examples/set_cuda_architecture.cmake | 24 ++++++++++++++++++++ cpp/examples/strings/CMakeLists.txt | 4 +++- 6 files changed, 48 insertions(+), 21 deletions(-) create mode 100644 cpp/examples/set_cuda_architecture.cmake diff --git a/cpp/examples/basic/CMakeLists.txt b/cpp/examples/basic/CMakeLists.txt index 759a43b5627..2ac66baf60c 100644 --- a/cpp/examples/basic/CMakeLists.txt +++ b/cpp/examples/basic/CMakeLists.txt @@ -1,7 +1,9 @@ -# Copyright (c) 2020-2023, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. cmake_minimum_required(VERSION 3.26.4) +include(../set_cuda_architecture.cmake) + project( basic_example VERSION 0.0.1 diff --git a/cpp/examples/build.sh b/cpp/examples/build.sh index aca73d6d158..147b45eda7c 100755 --- a/cpp/examples/build.sh +++ b/cpp/examples/build.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2021-2023, NVIDIA CORPORATION. +# Copyright (c) 2021-2024, NVIDIA CORPORATION. # libcudf examples build script @@ -10,7 +10,6 @@ PARALLEL_LEVEL=${PARALLEL_LEVEL:-4} # Root of examples EXAMPLES_DIR=$(dirname "$(realpath "$0")") LIB_BUILD_DIR=${LIB_BUILD_DIR:-$(readlink -f "${EXAMPLES_DIR}/../build")} -RAPIDS_ARCHS='70;80' # TODO: more generic one needed ################################################################################ # Add individual libcudf examples build scripts down below @@ -21,7 +20,7 @@ build_example() { build_dir="${example_dir}/build" # Configure - cmake -S ${example_dir} -B ${build_dir} -Dcudf_ROOT="${LIB_BUILD_DIR}" -DCMAKE_CUDA_ARCHITECTURES="${RAPIDS_ARCHS}" + cmake -S ${example_dir} -B ${build_dir} -Dcudf_ROOT="${LIB_BUILD_DIR}" -DCUDF_TAG=branch-24.06 # Build cmake --build ${build_dir} -j${PARALLEL_LEVEL} } diff --git a/cpp/examples/fetch_dependencies.cmake b/cpp/examples/fetch_dependencies.cmake index 53b96e5526c..04f68380ffd 100644 --- a/cpp/examples/fetch_dependencies.cmake +++ b/cpp/examples/fetch_dependencies.cmake @@ -11,7 +11,7 @@ # or implied. See the License for the specific language governing permissions and limitations under # the License. # ============================================================================= -set(CPM_DOWNLOAD_VERSION v0.35.3) +set(CPM_DOWNLOAD_VERSION v0.38.5) file( DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/download/${CPM_DOWNLOAD_VERSION}/get_cpm.cmake @@ -19,19 +19,17 @@ file( ) include(${CMAKE_BINARY_DIR}/cmake/get_cpm.cmake) -# try to find an already built libcudf and use it. -find_package(cudf HINTS ${cudf_ROOT}/latest) +# allow using local packages if already installed +set(CPM_USE_LOCAL_PACKAGES ON) -# build it via CPM -if (NOT cudf_FOUND) - set(CUDF_TAG branch-24.06) - - CPMFindPackage( - NAME cudf GIT_REPOSITORY https://github.com/rapidsai/cudf - GIT_TAG ${CUDF_TAG} - GIT_SHALLOW - TRUE - SOURCE_SUBDIR - cpp +# find or build it via CPM +CPMFindPackage( + NAME cudf + FIND_PACKAGE_ARGUMENTS "HINTS ${cudf_ROOT}/latest" + GIT_REPOSITORY https://github.com/rapidsai/cudf + GIT_TAG ${CUDF_TAG} + GIT_SHALLOW + TRUE + SOURCE_SUBDIR + cpp ) -endif() diff --git a/cpp/examples/nested_types/CMakeLists.txt b/cpp/examples/nested_types/CMakeLists.txt index cb9430db237..c82a46026af 100644 --- a/cpp/examples/nested_types/CMakeLists.txt +++ b/cpp/examples/nested_types/CMakeLists.txt @@ -1,7 +1,9 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, NVIDIA CORPORATION. cmake_minimum_required(VERSION 3.26.4) +include(../set_cuda_architecture.cmake) + project( nested_types VERSION 0.0.1 diff --git a/cpp/examples/set_cuda_architecture.cmake b/cpp/examples/set_cuda_architecture.cmake new file mode 100644 index 00000000000..cfc64bb65d2 --- /dev/null +++ b/cpp/examples/set_cuda_architecture.cmake @@ -0,0 +1,24 @@ +# ============================================================================= +# Copyright (c) 2023-2024, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= +if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/basic_example_RAPIDS.cmake) + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/${CUDF_TAG}/RAPIDS.cmake + ${CMAKE_CURRENT_BINARY_DIR}/basic_example_RAPIDS.cmake) +endif() +include(${CMAKE_CURRENT_BINARY_DIR}/basic_example_RAPIDS.cmake) + +include(rapids-cuda) + +# initialize cuda architectures +rapids_cuda_init_architectures(basic_examples) +rapids_cuda_set_architectures(RAPIDS) diff --git a/cpp/examples/strings/CMakeLists.txt b/cpp/examples/strings/CMakeLists.txt index c90fa9dde16..9207d1246f8 100644 --- a/cpp/examples/strings/CMakeLists.txt +++ b/cpp/examples/strings/CMakeLists.txt @@ -1,7 +1,9 @@ -# Copyright (c) 2022-2023, NVIDIA CORPORATION. +# Copyright (c) 2022-2024, NVIDIA CORPORATION. cmake_minimum_required(VERSION 3.26.4) +include(../set_cuda_architecture.cmake) + project( strings_examples VERSION 0.0.1 From 24149bb8fc646f089c3229d0110c59578f416a8d Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Fri, 22 Mar 2024 20:10:41 +0000 Subject: [PATCH 03/22] reverting CUDF_TAG to fetch_dependencies and handle in set_cuda_arch --- cpp/examples/build.sh | 4 ++-- cpp/examples/fetch_dependencies.cmake | 1 + cpp/examples/set_cuda_architecture.cmake | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cpp/examples/build.sh b/cpp/examples/build.sh index 147b45eda7c..001cdeec694 100755 --- a/cpp/examples/build.sh +++ b/cpp/examples/build.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2021-2024, NVIDIA CORPORATION. +# Copyright (c) 2021-2023, NVIDIA CORPORATION. # libcudf examples build script @@ -20,7 +20,7 @@ build_example() { build_dir="${example_dir}/build" # Configure - cmake -S ${example_dir} -B ${build_dir} -Dcudf_ROOT="${LIB_BUILD_DIR}" -DCUDF_TAG=branch-24.06 + cmake -S ${example_dir} -B ${build_dir} -Dcudf_ROOT="${LIB_BUILD_DIR}" # Build cmake --build ${build_dir} -j${PARALLEL_LEVEL} } diff --git a/cpp/examples/fetch_dependencies.cmake b/cpp/examples/fetch_dependencies.cmake index 04f68380ffd..c6d93b5722f 100644 --- a/cpp/examples/fetch_dependencies.cmake +++ b/cpp/examples/fetch_dependencies.cmake @@ -21,6 +21,7 @@ include(${CMAKE_BINARY_DIR}/cmake/get_cpm.cmake) # allow using local packages if already installed set(CPM_USE_LOCAL_PACKAGES ON) +set(CUDF_TAG branch-24.06) # find or build it via CPM CPMFindPackage( diff --git a/cpp/examples/set_cuda_architecture.cmake b/cpp/examples/set_cuda_architecture.cmake index cfc64bb65d2..f6295089772 100644 --- a/cpp/examples/set_cuda_architecture.cmake +++ b/cpp/examples/set_cuda_architecture.cmake @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2023-2024, NVIDIA CORPORATION. +# Copyright (c) 2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except # in compliance with the License. You may obtain a copy of the License at @@ -11,6 +11,10 @@ # or implied. See the License for the specific language governing permissions and limitations under # the License. # ============================================================================= + +# get the CUDF_TAG from fetch_dependencies.cmake (remove all whitespace & parse line: set(CUDF_TAG ..)) +execute_process(COMMAND bash -c "sed '/^$/d;s/[[:blank:]]//g' ./fetch_dependencies.cmake | grep 'set(CUDF_TAG' | sed 's/.*CUDF_TAG//' | sed 's/.$//'" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE CUDF_TAG) + if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/basic_example_RAPIDS.cmake) file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/${CUDF_TAG}/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/basic_example_RAPIDS.cmake) From 90bd8b091cf76b2ff597c4b8904441c2895bc547 Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Fri, 22 Mar 2024 22:20:13 +0000 Subject: [PATCH 04/22] Adding CI artifacts to build and run libcudf examples --- ci/run_cudf_examples.sh | 23 +++++++++++++++++++++++ ci/test_cpp.sh | 6 ++++++ ci/test_cpp_common.sh | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 ci/run_cudf_examples.sh diff --git a/ci/run_cudf_examples.sh b/ci/run_cudf_examples.sh new file mode 100644 index 00000000000..45654e8b5f8 --- /dev/null +++ b/ci/run_cudf_examples.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Copyright (c) 2024, NVIDIA CORPORATION. + +set -uo pipefail + +EXITCODE=0 +trap "EXITCODE=1" ERR + +# Support customizing the ctests' install location +cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/examples/libcudf/"; + +cp ./basic/4stock_5day.csv ./basic/build +compute-sanitizer --tool memcheck ./basic/build/basic_example + +cp ./nested_types/example.json ./nested_types/build +compute-sanitizer --tool memcheck ./nested_types/build/deduplication + +cp ./strings/names.csv ./strings/build +compute-sanitizer --tool memcheck ./strings/build/custom_optimized ./strings/build/names.csv +compute-sanitizer --tool memcheck ./strings/build/custom_prealloc ./strings/build/names.csv +compute-sanitizer --tool memcheck ./strings/build/custom_with_malloc ./strings/build/names.csv + +exit ${EXITCODE} \ No newline at end of file diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 995c8d7d71f..7865849bb74 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -17,6 +17,12 @@ rapids-logger "Run libcudf gtests" ./ci/run_cudf_ctests.sh -j20 SUITEERROR=$? +if (( ${SUITEERROR} == 0 )); then + rapids-logger "Run libcudf examples" + ./ci/run_cudf_examples.sh + SUITEERROR=$? +fi + if (( ${SUITEERROR} == 0 )); then rapids-logger "Run libcudf_kafka gtests" ./ci/run_cudf_kafka_ctests.sh -j20 diff --git a/ci/test_cpp_common.sh b/ci/test_cpp_common.sh index 163d381c1d4..b1143a7ccb5 100644 --- a/ci/test_cpp_common.sh +++ b/ci/test_cpp_common.sh @@ -31,7 +31,7 @@ rapids-print-env rapids-mamba-retry install \ --channel "${CPP_CHANNEL}" \ - libcudf libcudf_kafka libcudf-tests + libcudf libcudf_kafka libcudf-tests libcudf-example rapids-logger "Check GPU usage" nvidia-smi From 28ed85bca15319e5045b4383ff7dce921ebf773a Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Mon, 1 Apr 2024 21:23:07 +0000 Subject: [PATCH 05/22] set cuda_architectures in each example --- ci/run_cudf_examples.sh | 2 +- ci/test_cpp_common.sh | 2 +- cpp/examples/basic/CMakeLists.txt | 4 ++++ cpp/examples/nested_types/CMakeLists.txt | 4 ++++ cpp/examples/set_cuda_architecture.cmake | 4 ---- cpp/examples/strings/CMakeLists.txt | 4 ++++ 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ci/run_cudf_examples.sh b/ci/run_cudf_examples.sh index 45654e8b5f8..8bca213250e 100644 --- a/ci/run_cudf_examples.sh +++ b/ci/run_cudf_examples.sh @@ -20,4 +20,4 @@ compute-sanitizer --tool memcheck ./strings/build/custom_optimized ./strings/bui compute-sanitizer --tool memcheck ./strings/build/custom_prealloc ./strings/build/names.csv compute-sanitizer --tool memcheck ./strings/build/custom_with_malloc ./strings/build/names.csv -exit ${EXITCODE} \ No newline at end of file +exit ${EXITCODE} diff --git a/ci/test_cpp_common.sh b/ci/test_cpp_common.sh index b1143a7ccb5..fa180facbd6 100644 --- a/ci/test_cpp_common.sh +++ b/ci/test_cpp_common.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2022-2023, NVIDIA CORPORATION. +# Copyright (c) 2022-2024, NVIDIA CORPORATION. set -euo pipefail diff --git a/cpp/examples/basic/CMakeLists.txt b/cpp/examples/basic/CMakeLists.txt index 2ac66baf60c..4df86825600 100644 --- a/cpp/examples/basic/CMakeLists.txt +++ b/cpp/examples/basic/CMakeLists.txt @@ -4,6 +4,10 @@ cmake_minimum_required(VERSION 3.26.4) include(../set_cuda_architecture.cmake) +# initialize cuda architecture +rapids_cuda_init_architectures(basic_example) +rapids_cuda_set_architectures(RAPIDS) + project( basic_example VERSION 0.0.1 diff --git a/cpp/examples/nested_types/CMakeLists.txt b/cpp/examples/nested_types/CMakeLists.txt index c82a46026af..5ebb3798a9f 100644 --- a/cpp/examples/nested_types/CMakeLists.txt +++ b/cpp/examples/nested_types/CMakeLists.txt @@ -4,6 +4,10 @@ cmake_minimum_required(VERSION 3.26.4) include(../set_cuda_architecture.cmake) +# initialize cuda architecture +rapids_cuda_init_architectures(nested_types) +rapids_cuda_set_architectures(RAPIDS) + project( nested_types VERSION 0.0.1 diff --git a/cpp/examples/set_cuda_architecture.cmake b/cpp/examples/set_cuda_architecture.cmake index f6295089772..28bdda82737 100644 --- a/cpp/examples/set_cuda_architecture.cmake +++ b/cpp/examples/set_cuda_architecture.cmake @@ -22,7 +22,3 @@ endif() include(${CMAKE_CURRENT_BINARY_DIR}/basic_example_RAPIDS.cmake) include(rapids-cuda) - -# initialize cuda architectures -rapids_cuda_init_architectures(basic_examples) -rapids_cuda_set_architectures(RAPIDS) diff --git a/cpp/examples/strings/CMakeLists.txt b/cpp/examples/strings/CMakeLists.txt index 9207d1246f8..c67ee076e5d 100644 --- a/cpp/examples/strings/CMakeLists.txt +++ b/cpp/examples/strings/CMakeLists.txt @@ -4,6 +4,10 @@ cmake_minimum_required(VERSION 3.26.4) include(../set_cuda_architecture.cmake) +# initialize cuda architecture +rapids_cuda_init_architectures(strings_examples) +rapids_cuda_set_architectures(RAPIDS) + project( strings_examples VERSION 0.0.1 From 0f44faf77d236e2101f45f90f19f5b3c3f78d5e9 Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Mon, 8 Apr 2024 21:00:52 +0000 Subject: [PATCH 06/22] updates from cmake-format --- cpp/examples/fetch_dependencies.cmake | 5 ++--- cpp/examples/set_cuda_architecture.cmake | 14 +++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cpp/examples/fetch_dependencies.cmake b/cpp/examples/fetch_dependencies.cmake index c6d93b5722f..819a7565ecf 100644 --- a/cpp/examples/fetch_dependencies.cmake +++ b/cpp/examples/fetch_dependencies.cmake @@ -26,11 +26,10 @@ set(CUDF_TAG branch-24.06) # find or build it via CPM CPMFindPackage( NAME cudf - FIND_PACKAGE_ARGUMENTS "HINTS ${cudf_ROOT}/latest" - GIT_REPOSITORY https://github.com/rapidsai/cudf + FIND_PACKAGE_ARGUMENTS "HINTS ${cudf_ROOT}/latest" GIT_REPOSITORY https://github.com/rapidsai/cudf GIT_TAG ${CUDF_TAG} GIT_SHALLOW TRUE SOURCE_SUBDIR cpp - ) +) diff --git a/cpp/examples/set_cuda_architecture.cmake b/cpp/examples/set_cuda_architecture.cmake index 28bdda82737..a6ad25d08d4 100644 --- a/cpp/examples/set_cuda_architecture.cmake +++ b/cpp/examples/set_cuda_architecture.cmake @@ -12,12 +12,20 @@ # the License. # ============================================================================= -# get the CUDF_TAG from fetch_dependencies.cmake (remove all whitespace & parse line: set(CUDF_TAG ..)) -execute_process(COMMAND bash -c "sed '/^$/d;s/[[:blank:]]//g' ./fetch_dependencies.cmake | grep 'set(CUDF_TAG' | sed 's/.*CUDF_TAG//' | sed 's/.$//'" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE CUDF_TAG) +# get the CUDF_TAG from fetch_dependencies.cmake (remove all whitespace & parse line: set(CUDF_TAG +# ..)) +execute_process( + COMMAND + bash -c + "sed '/^$/d;s/[[:blank:]]//g' ./fetch_dependencies.cmake | grep 'set(CUDF_TAG' | sed 's/.*CUDF_TAG//' | sed 's/.$//'" + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE CUDF_TAG +) if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/basic_example_RAPIDS.cmake) file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/${CUDF_TAG}/RAPIDS.cmake - ${CMAKE_CURRENT_BINARY_DIR}/basic_example_RAPIDS.cmake) + ${CMAKE_CURRENT_BINARY_DIR}/basic_example_RAPIDS.cmake + ) endif() include(${CMAKE_CURRENT_BINARY_DIR}/basic_example_RAPIDS.cmake) From aafd3be74835357b824fb02690425c433e605055 Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Thu, 11 Apr 2024 20:26:54 +0000 Subject: [PATCH 07/22] add working directory variable to avoid mishandled sed --- cpp/examples/set_cuda_architecture.cmake | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cpp/examples/set_cuda_architecture.cmake b/cpp/examples/set_cuda_architecture.cmake index a6ad25d08d4..31605eae4d0 100644 --- a/cpp/examples/set_cuda_architecture.cmake +++ b/cpp/examples/set_cuda_architecture.cmake @@ -20,13 +20,18 @@ execute_process( "sed '/^$/d;s/[[:blank:]]//g' ./fetch_dependencies.cmake | grep 'set(CUDF_TAG' | sed 's/.*CUDF_TAG//' | sed 's/.$//'" OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE CUDF_TAG + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} ) -if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/basic_example_RAPIDS.cmake) +if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/libcudf_cpp_examples_RAPIDS.cmake) file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/${CUDF_TAG}/RAPIDS.cmake - ${CMAKE_CURRENT_BINARY_DIR}/basic_example_RAPIDS.cmake + ${CMAKE_CURRENT_BINARY_DIR}/libcudf_cpp_examples_RAPIDS.cmake ) endif() -include(${CMAKE_CURRENT_BINARY_DIR}/basic_example_RAPIDS.cmake) +include(${CMAKE_CURRENT_BINARY_DIR}/libcudf_cpp_examples_RAPIDS.cmake) +include(rapids-cmake) +include(rapids-cpm) include(rapids-cuda) +include(rapids-export) +include(rapids-find) From ee0100a01d475839d5cf7ceedb7fabbb606e0868 Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Fri, 12 Apr 2024 19:33:30 +0000 Subject: [PATCH 08/22] update file permissions for ci to run --- ci/run_cudf_examples.sh | 0 ci/test_cpp_common.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 ci/run_cudf_examples.sh mode change 100644 => 100755 ci/test_cpp_common.sh diff --git a/ci/run_cudf_examples.sh b/ci/run_cudf_examples.sh old mode 100644 new mode 100755 diff --git a/ci/test_cpp_common.sh b/ci/test_cpp_common.sh old mode 100644 new mode 100755 From 9a65213498aa99d85ef3e04a9c3291cdb5e2fa4f Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Tue, 16 Apr 2024 00:54:04 +0000 Subject: [PATCH 09/22] adding more CI artifacts for examples --- ci/run_cudf_examples.sh | 15 ++++++--------- .../recipes/libcudf/install_libcudf_example.sh | 1 + conda/recipes/libcudf/meta.yaml | 2 +- cpp/examples/basic/CMakeLists.txt | 9 ++++++++- cpp/examples/build.sh | 6 ++++++ cpp/examples/nested_types/CMakeLists.txt | 8 ++++++++ cpp/examples/strings/CMakeLists.txt | 17 ++++++++++++++++- 7 files changed, 46 insertions(+), 12 deletions(-) diff --git a/ci/run_cudf_examples.sh b/ci/run_cudf_examples.sh index 8bca213250e..a7ee6cc4207 100755 --- a/ci/run_cudf_examples.sh +++ b/ci/run_cudf_examples.sh @@ -6,18 +6,15 @@ set -uo pipefail EXITCODE=0 trap "EXITCODE=1" ERR -# Support customizing the ctests' install location +# Support customizing the examples' install location cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/examples/libcudf/"; -cp ./basic/4stock_5day.csv ./basic/build -compute-sanitizer --tool memcheck ./basic/build/basic_example +compute-sanitizer --tool memcheck basic_example -cp ./nested_types/example.json ./nested_types/build -compute-sanitizer --tool memcheck ./nested_types/build/deduplication +compute-sanitizer --tool memcheck deduplication -cp ./strings/names.csv ./strings/build -compute-sanitizer --tool memcheck ./strings/build/custom_optimized ./strings/build/names.csv -compute-sanitizer --tool memcheck ./strings/build/custom_prealloc ./strings/build/names.csv -compute-sanitizer --tool memcheck ./strings/build/custom_with_malloc ./strings/build/names.csv +compute-sanitizer --tool memcheck ./strings/build/custom_optimized names.csv +compute-sanitizer --tool memcheck ./strings/build/custom_prealloc names.csv +compute-sanitizer --tool memcheck ./strings/build/custom_with_malloc names.csv exit ${EXITCODE} diff --git a/conda/recipes/libcudf/install_libcudf_example.sh b/conda/recipes/libcudf/install_libcudf_example.sh index e249688a03b..0d9fcaad18d 100644 --- a/conda/recipes/libcudf/install_libcudf_example.sh +++ b/conda/recipes/libcudf/install_libcudf_example.sh @@ -1,4 +1,5 @@ #!/bin/bash # Copyright (c) 2018-2022, NVIDIA CORPORATION. +export CMAKE_INSTALL_PREFIX=${CONDA_PREFIX} ./cpp/examples/build.sh diff --git a/conda/recipes/libcudf/meta.yaml b/conda/recipes/libcudf/meta.yaml index 63eb83084dd..8258fe16715 100644 --- a/conda/recipes/libcudf/meta.yaml +++ b/conda/recipes/libcudf/meta.yaml @@ -195,7 +195,7 @@ outputs: license: Apache-2.0 license_family: APACHE license_file: LICENSE - summary: libcudf_example library + summary: libcudf executable examples - name: libcudf-tests version: {{ version }} script: install_libcudf_tests.sh diff --git a/cpp/examples/basic/CMakeLists.txt b/cpp/examples/basic/CMakeLists.txt index 4df86825600..03784975d26 100644 --- a/cpp/examples/basic/CMakeLists.txt +++ b/cpp/examples/basic/CMakeLists.txt @@ -15,8 +15,15 @@ project( ) include(../fetch_dependencies.cmake) - # Configure your project here add_executable(basic_example src/process_csv.cpp) target_link_libraries(basic_example PRIVATE cudf::cudf) target_compile_features(basic_example PRIVATE cxx_std_17) + +# Install the example only if CMAKE_INSTALL_PREFIX is set +if (NOT $ENV{CMAKE_INSTALL_PREFIX} STREQUAL "") + # set the CMAKE_INSTALL_PREFIX to the environment variable value + set(CMAKE_INSTALL_PREFIX "$ENV{CMAKE_INSTALL_PREFIX}" CACHE STRING "Force CMAKE_INSTALL_PREFIX to environment variable" FORCE) + install(TARGETS basic_example DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) + install(FILES ${CMAKE_CURRENT_LIST_DIR}/4stock_5day.csv DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) +endif() \ No newline at end of file diff --git a/cpp/examples/build.sh b/cpp/examples/build.sh index 001cdeec694..40083912ec6 100755 --- a/cpp/examples/build.sh +++ b/cpp/examples/build.sh @@ -23,6 +23,12 @@ build_example() { cmake -S ${example_dir} -B ${build_dir} -Dcudf_ROOT="${LIB_BUILD_DIR}" # Build cmake --build ${build_dir} -j${PARALLEL_LEVEL} + + # Install only if CMAKE_INSTALL_PREFIX is set + if [[ -n "${CMAKE_INSTALL_PREFIX}" ]]; then + echo "Setting prefix = ${CMAKE_INSTALL_PREFIX}" + cmake --install ${build_dir} --prefix /home/coder/testing/basic + fi } build_example basic diff --git a/cpp/examples/nested_types/CMakeLists.txt b/cpp/examples/nested_types/CMakeLists.txt index 5ebb3798a9f..bf4df6e8949 100644 --- a/cpp/examples/nested_types/CMakeLists.txt +++ b/cpp/examples/nested_types/CMakeLists.txt @@ -20,3 +20,11 @@ include(../fetch_dependencies.cmake) add_executable(deduplication deduplication.cpp) target_link_libraries(deduplication PRIVATE cudf::cudf) target_compile_features(deduplication PRIVATE cxx_std_17) + +# Install the example only if CMAKE_INSTALL_PREFIX is set +if (NOT $ENV{CMAKE_INSTALL_PREFIX} STREQUAL "") + # set the CMAKE_INSTALL_PREFIX to the environment variable value + set(CMAKE_INSTALL_PREFIX "$ENV{CMAKE_INSTALL_PREFIX}" CACHE STRING "Force CMAKE_INSTALL_PREFIX to environment variable" FORCE) + install(TARGETS deduplication DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) + install(FILES ${CMAKE_CURRENT_LIST_DIR}/example.json DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) +endif() \ No newline at end of file diff --git a/cpp/examples/strings/CMakeLists.txt b/cpp/examples/strings/CMakeLists.txt index c67ee076e5d..d4708013459 100644 --- a/cpp/examples/strings/CMakeLists.txt +++ b/cpp/examples/strings/CMakeLists.txt @@ -18,22 +18,37 @@ include(../fetch_dependencies.cmake) list(APPEND CUDF_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr) -# add_executable(libcudf_apis libcudf_apis.cpp) target_compile_features(libcudf_apis PRIVATE cxx_std_17) target_link_libraries(libcudf_apis PRIVATE cudf::cudf nvToolsExt) +# Install the example only if CMAKE_INSTALL_PREFIX is set +if (NOT $ENV{CMAKE_INSTALL_PREFIX} STREQUAL "") + # set the CMAKE_INSTALL_PREFIX to the environment variable value + set(CMAKE_INSTALL_PREFIX "$ENV{CMAKE_INSTALL_PREFIX}" CACHE STRING "Force CMAKE_INSTALL_PREFIX to environment variable" FORCE) + install(TARGETS libcudf_apis DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) + install(FILES ${CMAKE_CURRENT_LIST_DIR}/names.csv DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) +endif() add_executable(custom_with_malloc custom_with_malloc.cu) target_compile_features(custom_with_malloc PRIVATE cxx_std_17) target_compile_options(custom_with_malloc PRIVATE "$<$:${CUDF_CUDA_FLAGS}>") target_link_libraries(custom_with_malloc PRIVATE cudf::cudf nvToolsExt) +if (NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "") + install(TARGETS custom_with_malloc DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) +endif() add_executable(custom_prealloc custom_prealloc.cu) target_compile_features(custom_prealloc PRIVATE cxx_std_17) target_compile_options(custom_prealloc PRIVATE "$<$:${CUDF_CUDA_FLAGS}>") target_link_libraries(custom_prealloc PRIVATE cudf::cudf nvToolsExt) +if (NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "") + install(TARGETS custom_prealloc DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) +endif() add_executable(custom_optimized custom_optimized.cu) target_compile_features(custom_optimized PRIVATE cxx_std_17) target_compile_options(custom_optimized PRIVATE "$<$:${CUDF_CUDA_FLAGS}>") target_link_libraries(custom_optimized PRIVATE cudf::cudf nvToolsExt) +if (NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "") + install(TARGETS custom_optimized DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) +endif() \ No newline at end of file From 137017674ef2bb32ec4e7755cc782d2ad97ce40f Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Tue, 16 Apr 2024 00:56:45 +0000 Subject: [PATCH 10/22] minor pre-commit fixes --- .../libcudf/install_libcudf_example.sh | 2 +- cpp/examples/basic/CMakeLists.txt | 13 +++++++++---- cpp/examples/build.sh | 2 +- cpp/examples/nested_types/CMakeLists.txt | 13 +++++++++---- cpp/examples/strings/CMakeLists.txt | 19 ++++++++++++------- 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/conda/recipes/libcudf/install_libcudf_example.sh b/conda/recipes/libcudf/install_libcudf_example.sh index 0d9fcaad18d..1e07b231954 100644 --- a/conda/recipes/libcudf/install_libcudf_example.sh +++ b/conda/recipes/libcudf/install_libcudf_example.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2018-2022, NVIDIA CORPORATION. +# Copyright (c) 2018-2024, NVIDIA CORPORATION. export CMAKE_INSTALL_PREFIX=${CONDA_PREFIX} ./cpp/examples/build.sh diff --git a/cpp/examples/basic/CMakeLists.txt b/cpp/examples/basic/CMakeLists.txt index 03784975d26..6cb11028ce4 100644 --- a/cpp/examples/basic/CMakeLists.txt +++ b/cpp/examples/basic/CMakeLists.txt @@ -21,9 +21,14 @@ target_link_libraries(basic_example PRIVATE cudf::cudf) target_compile_features(basic_example PRIVATE cxx_std_17) # Install the example only if CMAKE_INSTALL_PREFIX is set -if (NOT $ENV{CMAKE_INSTALL_PREFIX} STREQUAL "") +if(NOT $ENV{CMAKE_INSTALL_PREFIX} STREQUAL "") # set the CMAKE_INSTALL_PREFIX to the environment variable value - set(CMAKE_INSTALL_PREFIX "$ENV{CMAKE_INSTALL_PREFIX}" CACHE STRING "Force CMAKE_INSTALL_PREFIX to environment variable" FORCE) + set(CMAKE_INSTALL_PREFIX + "$ENV{CMAKE_INSTALL_PREFIX}" + CACHE STRING "Force CMAKE_INSTALL_PREFIX to environment variable" FORCE + ) install(TARGETS basic_example DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) - install(FILES ${CMAKE_CURRENT_LIST_DIR}/4stock_5day.csv DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) -endif() \ No newline at end of file + install(FILES ${CMAKE_CURRENT_LIST_DIR}/4stock_5day.csv + DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf + ) +endif() diff --git a/cpp/examples/build.sh b/cpp/examples/build.sh index 44c0060878e..1817fc9dd51 100755 --- a/cpp/examples/build.sh +++ b/cpp/examples/build.sh @@ -25,7 +25,7 @@ build_example() { cmake -S ${example_dir} -B ${build_dir} -Dcudf_ROOT="${LIB_BUILD_DIR}" # Build cmake --build ${build_dir} -j${PARALLEL_LEVEL} - + # Install only if CMAKE_INSTALL_PREFIX is set if [[ -n "${CMAKE_INSTALL_PREFIX}" ]]; then echo "Setting prefix = ${CMAKE_INSTALL_PREFIX}" diff --git a/cpp/examples/nested_types/CMakeLists.txt b/cpp/examples/nested_types/CMakeLists.txt index bf4df6e8949..3a576627e3f 100644 --- a/cpp/examples/nested_types/CMakeLists.txt +++ b/cpp/examples/nested_types/CMakeLists.txt @@ -22,9 +22,14 @@ target_link_libraries(deduplication PRIVATE cudf::cudf) target_compile_features(deduplication PRIVATE cxx_std_17) # Install the example only if CMAKE_INSTALL_PREFIX is set -if (NOT $ENV{CMAKE_INSTALL_PREFIX} STREQUAL "") +if(NOT $ENV{CMAKE_INSTALL_PREFIX} STREQUAL "") # set the CMAKE_INSTALL_PREFIX to the environment variable value - set(CMAKE_INSTALL_PREFIX "$ENV{CMAKE_INSTALL_PREFIX}" CACHE STRING "Force CMAKE_INSTALL_PREFIX to environment variable" FORCE) + set(CMAKE_INSTALL_PREFIX + "$ENV{CMAKE_INSTALL_PREFIX}" + CACHE STRING "Force CMAKE_INSTALL_PREFIX to environment variable" FORCE + ) install(TARGETS deduplication DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) - install(FILES ${CMAKE_CURRENT_LIST_DIR}/example.json DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) -endif() \ No newline at end of file + install(FILES ${CMAKE_CURRENT_LIST_DIR}/example.json + DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf + ) +endif() diff --git a/cpp/examples/strings/CMakeLists.txt b/cpp/examples/strings/CMakeLists.txt index d4708013459..8fbaa020855 100644 --- a/cpp/examples/strings/CMakeLists.txt +++ b/cpp/examples/strings/CMakeLists.txt @@ -22,18 +22,23 @@ add_executable(libcudf_apis libcudf_apis.cpp) target_compile_features(libcudf_apis PRIVATE cxx_std_17) target_link_libraries(libcudf_apis PRIVATE cudf::cudf nvToolsExt) # Install the example only if CMAKE_INSTALL_PREFIX is set -if (NOT $ENV{CMAKE_INSTALL_PREFIX} STREQUAL "") +if(NOT $ENV{CMAKE_INSTALL_PREFIX} STREQUAL "") # set the CMAKE_INSTALL_PREFIX to the environment variable value - set(CMAKE_INSTALL_PREFIX "$ENV{CMAKE_INSTALL_PREFIX}" CACHE STRING "Force CMAKE_INSTALL_PREFIX to environment variable" FORCE) + set(CMAKE_INSTALL_PREFIX + "$ENV{CMAKE_INSTALL_PREFIX}" + CACHE STRING "Force CMAKE_INSTALL_PREFIX to environment variable" FORCE + ) install(TARGETS libcudf_apis DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) - install(FILES ${CMAKE_CURRENT_LIST_DIR}/names.csv DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) + install(FILES ${CMAKE_CURRENT_LIST_DIR}/names.csv + DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf + ) endif() add_executable(custom_with_malloc custom_with_malloc.cu) target_compile_features(custom_with_malloc PRIVATE cxx_std_17) target_compile_options(custom_with_malloc PRIVATE "$<$:${CUDF_CUDA_FLAGS}>") target_link_libraries(custom_with_malloc PRIVATE cudf::cudf nvToolsExt) -if (NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "") +if(NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "") install(TARGETS custom_with_malloc DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) endif() @@ -41,7 +46,7 @@ add_executable(custom_prealloc custom_prealloc.cu) target_compile_features(custom_prealloc PRIVATE cxx_std_17) target_compile_options(custom_prealloc PRIVATE "$<$:${CUDF_CUDA_FLAGS}>") target_link_libraries(custom_prealloc PRIVATE cudf::cudf nvToolsExt) -if (NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "") +if(NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "") install(TARGETS custom_prealloc DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) endif() @@ -49,6 +54,6 @@ add_executable(custom_optimized custom_optimized.cu) target_compile_features(custom_optimized PRIVATE cxx_std_17) target_compile_options(custom_optimized PRIVATE "$<$:${CUDF_CUDA_FLAGS}>") target_link_libraries(custom_optimized PRIVATE cudf::cudf nvToolsExt) -if (NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "") +if(NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "") install(TARGETS custom_optimized DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) -endif() \ No newline at end of file +endif() From bc00b9eb85e3cae13eb319ed26b79a655ecf8eb1 Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Tue, 16 Apr 2024 01:46:59 +0000 Subject: [PATCH 11/22] handle CMAKE_INSTALL_PREFIX in examples build --- conda/recipes/libcudf/install_libcudf_example.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/conda/recipes/libcudf/install_libcudf_example.sh b/conda/recipes/libcudf/install_libcudf_example.sh index 1e07b231954..952a80590ab 100644 --- a/conda/recipes/libcudf/install_libcudf_example.sh +++ b/conda/recipes/libcudf/install_libcudf_example.sh @@ -1,5 +1,14 @@ #!/bin/bash # Copyright (c) 2018-2024, NVIDIA CORPORATION. -export CMAKE_INSTALL_PREFIX=${CONDA_PREFIX} -./cpp/examples/build.sh +# store old CMAKE_INSTALL_PREFIX if set +CMAKE_INSTALL_PREFIX_OLD=${CMAKE_INSTALL_PREFIX} + +# set CMAKE_INSTALL_PREFIX to $CONDA_PREFIX +export CMAKE_INSTALL_PREFIX=${CONDA_PREFIX:-/usr} + +# build and install libcudf examples +. ./cpp/examples/build.sh + +# set CMAKE_INSTALL_PREFIX to the original one +export CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX_OLD} \ No newline at end of file From 74aa66ace6b16e6e11fd9956c9faf8875e938002 Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Tue, 16 Apr 2024 02:26:43 +0000 Subject: [PATCH 12/22] test CI with default CMAKE_INSTALL_PREFIX --- conda/recipes/libcudf/install_libcudf_example.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/conda/recipes/libcudf/install_libcudf_example.sh b/conda/recipes/libcudf/install_libcudf_example.sh index 1e07b231954..9071caff21f 100644 --- a/conda/recipes/libcudf/install_libcudf_example.sh +++ b/conda/recipes/libcudf/install_libcudf_example.sh @@ -1,5 +1,14 @@ #!/bin/bash # Copyright (c) 2018-2024, NVIDIA CORPORATION. -export CMAKE_INSTALL_PREFIX=${CONDA_PREFIX} -./cpp/examples/build.sh +# store old CMAKE_INSTALL_PREFIX if set +#CMAKE_INSTALL_PREFIX_OLD=${CMAKE_INSTALL_PREFIX} + +# set CMAKE_INSTALL_PREFIX to $CONDA_PREFIX +#export CMAKE_INSTALL_PREFIX=${CMAKE_PREFIX_PATH} + +# build and install libcudf examples +. ./cpp/examples/build.sh + +# set CMAKE_INSTALL_PREFIX to the original one +#export CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX_OLD} From 0ac6f61f457b424c134a35a1e2fea382b29ffeb6 Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Tue, 16 Apr 2024 02:34:45 +0000 Subject: [PATCH 13/22] minor pre-commit fix --- conda/recipes/libcudf/install_libcudf_example.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda/recipes/libcudf/install_libcudf_example.sh b/conda/recipes/libcudf/install_libcudf_example.sh index 53cb820c836..9071caff21f 100644 --- a/conda/recipes/libcudf/install_libcudf_example.sh +++ b/conda/recipes/libcudf/install_libcudf_example.sh @@ -11,4 +11,4 @@ . ./cpp/examples/build.sh # set CMAKE_INSTALL_PREFIX to the original one -#export CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX_OLD} \ No newline at end of file +#export CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX_OLD} From 3e18bf3b4a78306a6066d1578bdca110a3cee638 Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Tue, 16 Apr 2024 02:55:16 +0000 Subject: [PATCH 14/22] revert custom install prefix and test CI. --- conda/recipes/libcudf/install_libcudf_example.sh | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/conda/recipes/libcudf/install_libcudf_example.sh b/conda/recipes/libcudf/install_libcudf_example.sh index 9071caff21f..294e4fdcf06 100644 --- a/conda/recipes/libcudf/install_libcudf_example.sh +++ b/conda/recipes/libcudf/install_libcudf_example.sh @@ -1,14 +1,5 @@ #!/bin/bash # Copyright (c) 2018-2024, NVIDIA CORPORATION. -# store old CMAKE_INSTALL_PREFIX if set -#CMAKE_INSTALL_PREFIX_OLD=${CMAKE_INSTALL_PREFIX} - -# set CMAKE_INSTALL_PREFIX to $CONDA_PREFIX -#export CMAKE_INSTALL_PREFIX=${CMAKE_PREFIX_PATH} - # build and install libcudf examples -. ./cpp/examples/build.sh - -# set CMAKE_INSTALL_PREFIX to the original one -#export CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX_OLD} +./cpp/examples/build.sh From fa3bf0009be4119b61f556e11204c71beef3f673 Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Tue, 16 Apr 2024 03:14:30 +0000 Subject: [PATCH 15/22] Use $PREFIX as CMAKE_INSTALL_PREFIX --- conda/recipes/libcudf/install_libcudf_example.sh | 2 ++ cpp/examples/build.sh | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/conda/recipes/libcudf/install_libcudf_example.sh b/conda/recipes/libcudf/install_libcudf_example.sh index 294e4fdcf06..6e8fa8968e2 100644 --- a/conda/recipes/libcudf/install_libcudf_example.sh +++ b/conda/recipes/libcudf/install_libcudf_example.sh @@ -1,5 +1,7 @@ #!/bin/bash # Copyright (c) 2018-2024, NVIDIA CORPORATION. +export CMAKE_INSTALL_PREFIX=${PREFIX} + # build and install libcudf examples ./cpp/examples/build.sh diff --git a/cpp/examples/build.sh b/cpp/examples/build.sh index 1817fc9dd51..98463a767d1 100755 --- a/cpp/examples/build.sh +++ b/cpp/examples/build.sh @@ -28,8 +28,7 @@ build_example() { # Install only if CMAKE_INSTALL_PREFIX is set if [[ -n "${CMAKE_INSTALL_PREFIX}" ]]; then - echo "Setting prefix = ${CMAKE_INSTALL_PREFIX}" - cmake --install ${build_dir} --prefix /home/coder/testing/basic + cmake --install ${build_dir} fi } From 1cbde691540aa300ee451ef0b359c89dcb0b3f4d Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Tue, 16 Apr 2024 04:23:08 +0000 Subject: [PATCH 16/22] minor fix for paths --- ci/run_cudf_examples.sh | 6 +++--- cpp/examples/fetch_dependencies.cmake | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ci/run_cudf_examples.sh b/ci/run_cudf_examples.sh index a7ee6cc4207..71af6446748 100755 --- a/ci/run_cudf_examples.sh +++ b/ci/run_cudf_examples.sh @@ -13,8 +13,8 @@ compute-sanitizer --tool memcheck basic_example compute-sanitizer --tool memcheck deduplication -compute-sanitizer --tool memcheck ./strings/build/custom_optimized names.csv -compute-sanitizer --tool memcheck ./strings/build/custom_prealloc names.csv -compute-sanitizer --tool memcheck ./strings/build/custom_with_malloc names.csv +compute-sanitizer --tool memcheck custom_optimized names.csv +compute-sanitizer --tool memcheck custom_prealloc names.csv +compute-sanitizer --tool memcheck custom_with_malloc names.csv exit ${EXITCODE} diff --git a/cpp/examples/fetch_dependencies.cmake b/cpp/examples/fetch_dependencies.cmake index 819a7565ecf..6241c177d9e 100644 --- a/cpp/examples/fetch_dependencies.cmake +++ b/cpp/examples/fetch_dependencies.cmake @@ -19,8 +19,6 @@ file( ) include(${CMAKE_BINARY_DIR}/cmake/get_cpm.cmake) -# allow using local packages if already installed -set(CPM_USE_LOCAL_PACKAGES ON) set(CUDF_TAG branch-24.06) # find or build it via CPM From 9d8bf765abcb68e98179e45a87989d3c563ab1db Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Tue, 16 Apr 2024 04:30:44 +0000 Subject: [PATCH 17/22] update install logic and fix for default behavior --- cpp/examples/basic/CMakeLists.txt | 11 ++++++----- cpp/examples/build.sh | 2 +- cpp/examples/nested_types/CMakeLists.txt | 11 ++++++----- cpp/examples/strings/CMakeLists.txt | 24 ++++++++++-------------- 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/cpp/examples/basic/CMakeLists.txt b/cpp/examples/basic/CMakeLists.txt index 6cb11028ce4..4bb80839814 100644 --- a/cpp/examples/basic/CMakeLists.txt +++ b/cpp/examples/basic/CMakeLists.txt @@ -20,15 +20,16 @@ add_executable(basic_example src/process_csv.cpp) target_link_libraries(basic_example PRIVATE cudf::cudf) target_compile_features(basic_example PRIVATE cxx_std_17) -# Install the example only if CMAKE_INSTALL_PREFIX is set +# Force set CMAKE_INSTALL_PREFIX from environment variable if(NOT $ENV{CMAKE_INSTALL_PREFIX} STREQUAL "") # set the CMAKE_INSTALL_PREFIX to the environment variable value set(CMAKE_INSTALL_PREFIX "$ENV{CMAKE_INSTALL_PREFIX}" CACHE STRING "Force CMAKE_INSTALL_PREFIX to environment variable" FORCE ) - install(TARGETS basic_example DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) - install(FILES ${CMAKE_CURRENT_LIST_DIR}/4stock_5day.csv - DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf - ) endif() + +install(TARGETS basic_example DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) +install(FILES ${CMAKE_CURRENT_LIST_DIR}/4stock_5day.csv + DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf +) diff --git a/cpp/examples/build.sh b/cpp/examples/build.sh index 98463a767d1..26b8ac058f3 100755 --- a/cpp/examples/build.sh +++ b/cpp/examples/build.sh @@ -27,7 +27,7 @@ build_example() { cmake --build ${build_dir} -j${PARALLEL_LEVEL} # Install only if CMAKE_INSTALL_PREFIX is set - if [[ -n "${CMAKE_INSTALL_PREFIX}" ]]; then + if [[ -n "${CMAKE_INSTALL_PREFIX:-""}" ]]; then cmake --install ${build_dir} fi } diff --git a/cpp/examples/nested_types/CMakeLists.txt b/cpp/examples/nested_types/CMakeLists.txt index 3a576627e3f..65f8e0e7c08 100644 --- a/cpp/examples/nested_types/CMakeLists.txt +++ b/cpp/examples/nested_types/CMakeLists.txt @@ -21,15 +21,16 @@ add_executable(deduplication deduplication.cpp) target_link_libraries(deduplication PRIVATE cudf::cudf) target_compile_features(deduplication PRIVATE cxx_std_17) -# Install the example only if CMAKE_INSTALL_PREFIX is set +# Force set CMAKE_INSTALL_PREFIX from environment variable if(NOT $ENV{CMAKE_INSTALL_PREFIX} STREQUAL "") # set the CMAKE_INSTALL_PREFIX to the environment variable value set(CMAKE_INSTALL_PREFIX "$ENV{CMAKE_INSTALL_PREFIX}" CACHE STRING "Force CMAKE_INSTALL_PREFIX to environment variable" FORCE ) - install(TARGETS deduplication DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) - install(FILES ${CMAKE_CURRENT_LIST_DIR}/example.json - DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf - ) endif() + +install(TARGETS deduplication DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) +install(FILES ${CMAKE_CURRENT_LIST_DIR}/example.json + DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf +) diff --git a/cpp/examples/strings/CMakeLists.txt b/cpp/examples/strings/CMakeLists.txt index 8fbaa020855..559b0b33c02 100644 --- a/cpp/examples/strings/CMakeLists.txt +++ b/cpp/examples/strings/CMakeLists.txt @@ -21,39 +21,35 @@ list(APPEND CUDF_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr) add_executable(libcudf_apis libcudf_apis.cpp) target_compile_features(libcudf_apis PRIVATE cxx_std_17) target_link_libraries(libcudf_apis PRIVATE cudf::cudf nvToolsExt) -# Install the example only if CMAKE_INSTALL_PREFIX is set + +# Force set CMAKE_INSTALL_PREFIX from environment variable if(NOT $ENV{CMAKE_INSTALL_PREFIX} STREQUAL "") # set the CMAKE_INSTALL_PREFIX to the environment variable value set(CMAKE_INSTALL_PREFIX "$ENV{CMAKE_INSTALL_PREFIX}" CACHE STRING "Force CMAKE_INSTALL_PREFIX to environment variable" FORCE ) - install(TARGETS libcudf_apis DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) - install(FILES ${CMAKE_CURRENT_LIST_DIR}/names.csv - DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf - ) endif() +install(TARGETS libcudf_apis DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) +install(FILES ${CMAKE_CURRENT_LIST_DIR}/names.csv + DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf +) + add_executable(custom_with_malloc custom_with_malloc.cu) target_compile_features(custom_with_malloc PRIVATE cxx_std_17) target_compile_options(custom_with_malloc PRIVATE "$<$:${CUDF_CUDA_FLAGS}>") target_link_libraries(custom_with_malloc PRIVATE cudf::cudf nvToolsExt) -if(NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "") - install(TARGETS custom_with_malloc DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) -endif() +install(TARGETS custom_with_malloc DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) add_executable(custom_prealloc custom_prealloc.cu) target_compile_features(custom_prealloc PRIVATE cxx_std_17) target_compile_options(custom_prealloc PRIVATE "$<$:${CUDF_CUDA_FLAGS}>") target_link_libraries(custom_prealloc PRIVATE cudf::cudf nvToolsExt) -if(NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "") - install(TARGETS custom_prealloc DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) -endif() +install(TARGETS custom_prealloc DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) add_executable(custom_optimized custom_optimized.cu) target_compile_features(custom_optimized PRIVATE cxx_std_17) target_compile_options(custom_optimized PRIVATE "$<$:${CUDF_CUDA_FLAGS}>") target_link_libraries(custom_optimized PRIVATE cudf::cudf nvToolsExt) -if(NOT ${CMAKE_INSTALL_PREFIX} STREQUAL "") - install(TARGETS custom_optimized DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) -endif() +install(TARGETS custom_optimized DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) From ad3f6a6c15e4ed58453aaa5c1c3b9ef7b4f68f61 Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Tue, 16 Apr 2024 19:10:03 +0000 Subject: [PATCH 18/22] incorporting suggested changes from reviews --- ci/release/update-version.sh | 2 +- .../libcudf/install_libcudf_example.sh | 4 +-- conda/recipes/libcudf/meta.yaml | 2 +- cpp/examples/basic/CMakeLists.txt | 15 ++------- cpp/examples/build.sh | 24 +++++++++++--- cpp/examples/fetch_dependencies.cmake | 5 +-- cpp/examples/nested_types/CMakeLists.txt | 15 ++------- cpp/examples/set_cuda_architecture.cmake | 11 +------ cpp/examples/strings/CMakeLists.txt | 33 ++++++++++--------- cpp/examples/versions.cmake | 15 +++++++++ 10 files changed, 63 insertions(+), 63 deletions(-) create mode 100644 cpp/examples/versions.cmake diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 7cacdfd39c3..99f9c698217 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -70,7 +70,7 @@ sed_runner "s/version == ${CURRENT_SHORT_TAG}/version == ${NEXT_SHORT_TAG}/g" RE sed_runner "s/cudf=${CURRENT_SHORT_TAG}/cudf=${NEXT_SHORT_TAG}/g" README.md # Libcudf examples update -sed_runner "s/CUDF_TAG branch-${CURRENT_SHORT_TAG}/CUDF_TAG branch-${NEXT_SHORT_TAG}/" cpp/examples/fetch_dependencies.cmake +sed_runner "s/CUDF_TAG branch-${CURRENT_SHORT_TAG}/CUDF_TAG branch-${NEXT_SHORT_TAG}/" cpp/examples/versions.cmake # CI files for FILE in .github/workflows/*.yaml; do diff --git a/conda/recipes/libcudf/install_libcudf_example.sh b/conda/recipes/libcudf/install_libcudf_example.sh index 6e8fa8968e2..1a52dec99e3 100644 --- a/conda/recipes/libcudf/install_libcudf_example.sh +++ b/conda/recipes/libcudf/install_libcudf_example.sh @@ -1,7 +1,5 @@ #!/bin/bash # Copyright (c) 2018-2024, NVIDIA CORPORATION. -export CMAKE_INSTALL_PREFIX=${PREFIX} - # build and install libcudf examples -./cpp/examples/build.sh +./cpp/examples/build.sh --install diff --git a/conda/recipes/libcudf/meta.yaml b/conda/recipes/libcudf/meta.yaml index 8258fe16715..3af0b7885c3 100644 --- a/conda/recipes/libcudf/meta.yaml +++ b/conda/recipes/libcudf/meta.yaml @@ -195,7 +195,7 @@ outputs: license: Apache-2.0 license_family: APACHE license_file: LICENSE - summary: libcudf executable examples + summary: libcudf example executables - name: libcudf-tests version: {{ version }} script: install_libcudf_tests.sh diff --git a/cpp/examples/basic/CMakeLists.txt b/cpp/examples/basic/CMakeLists.txt index 4bb80839814..3a7b218dda5 100644 --- a/cpp/examples/basic/CMakeLists.txt +++ b/cpp/examples/basic/CMakeLists.txt @@ -20,16 +20,5 @@ add_executable(basic_example src/process_csv.cpp) target_link_libraries(basic_example PRIVATE cudf::cudf) target_compile_features(basic_example PRIVATE cxx_std_17) -# Force set CMAKE_INSTALL_PREFIX from environment variable -if(NOT $ENV{CMAKE_INSTALL_PREFIX} STREQUAL "") - # set the CMAKE_INSTALL_PREFIX to the environment variable value - set(CMAKE_INSTALL_PREFIX - "$ENV{CMAKE_INSTALL_PREFIX}" - CACHE STRING "Force CMAKE_INSTALL_PREFIX to environment variable" FORCE - ) -endif() - -install(TARGETS basic_example DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) -install(FILES ${CMAKE_CURRENT_LIST_DIR}/4stock_5day.csv - DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf -) +install(TARGETS basic_example DESTINATION bin/examples/libcudf) +install(FILES ${CMAKE_CURRENT_LIST_DIR}/4stock_5day.csv DESTINATION bin/examples/libcudf) diff --git a/cpp/examples/build.sh b/cpp/examples/build.sh index 26b8ac058f3..425e76111ad 100755 --- a/cpp/examples/build.sh +++ b/cpp/examples/build.sh @@ -8,6 +8,23 @@ set -euo pipefail # Parallelism control PARALLEL_LEVEL=${PARALLEL_LEVEL:-4} +# Installation disabled by default +INSTALL_EXAMPLES=false + +# Check for -i or --install flags to enable installation +ARGS=$(getopt -o i --long install -- "$@") +eval set -- "$ARGS" +while [ : ]; do + case "$1" in + -i | --install) + INSTALL_EXAMPLES=true + shift + ;; + --) shift; + break + ;; + esac +done # Root of examples EXAMPLES_DIR=$(dirname "$(realpath "$0")") @@ -25,10 +42,9 @@ build_example() { cmake -S ${example_dir} -B ${build_dir} -Dcudf_ROOT="${LIB_BUILD_DIR}" # Build cmake --build ${build_dir} -j${PARALLEL_LEVEL} - - # Install only if CMAKE_INSTALL_PREFIX is set - if [[ -n "${CMAKE_INSTALL_PREFIX:-""}" ]]; then - cmake --install ${build_dir} + # Install if needed + if [ "$INSTALL_EXAMPLES" = true ]; then + cmake --install ${build_dir} --prefix ${INSTALL_PREFIX:-${PREFIX:-${CONDA_PREFIX:-${example_dir}/install}}} fi } diff --git a/cpp/examples/fetch_dependencies.cmake b/cpp/examples/fetch_dependencies.cmake index 6241c177d9e..9246416d0c1 100644 --- a/cpp/examples/fetch_dependencies.cmake +++ b/cpp/examples/fetch_dependencies.cmake @@ -11,6 +11,9 @@ # or implied. See the License for the specific language governing permissions and limitations under # the License. # ============================================================================= + +include(${CMAKE_CURRENT_LIST_DIR}/versions.cmake) + set(CPM_DOWNLOAD_VERSION v0.38.5) file( DOWNLOAD @@ -19,8 +22,6 @@ file( ) include(${CMAKE_BINARY_DIR}/cmake/get_cpm.cmake) -set(CUDF_TAG branch-24.06) - # find or build it via CPM CPMFindPackage( NAME cudf diff --git a/cpp/examples/nested_types/CMakeLists.txt b/cpp/examples/nested_types/CMakeLists.txt index 65f8e0e7c08..8a900f6b5ae 100644 --- a/cpp/examples/nested_types/CMakeLists.txt +++ b/cpp/examples/nested_types/CMakeLists.txt @@ -21,16 +21,5 @@ add_executable(deduplication deduplication.cpp) target_link_libraries(deduplication PRIVATE cudf::cudf) target_compile_features(deduplication PRIVATE cxx_std_17) -# Force set CMAKE_INSTALL_PREFIX from environment variable -if(NOT $ENV{CMAKE_INSTALL_PREFIX} STREQUAL "") - # set the CMAKE_INSTALL_PREFIX to the environment variable value - set(CMAKE_INSTALL_PREFIX - "$ENV{CMAKE_INSTALL_PREFIX}" - CACHE STRING "Force CMAKE_INSTALL_PREFIX to environment variable" FORCE - ) -endif() - -install(TARGETS deduplication DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) -install(FILES ${CMAKE_CURRENT_LIST_DIR}/example.json - DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf -) +install(TARGETS deduplication DESTINATION bin/examples/libcudf) +install(FILES ${CMAKE_CURRENT_LIST_DIR}/example.json DESTINATION bin/examples/libcudf) diff --git a/cpp/examples/set_cuda_architecture.cmake b/cpp/examples/set_cuda_architecture.cmake index 31605eae4d0..bed6cd2f357 100644 --- a/cpp/examples/set_cuda_architecture.cmake +++ b/cpp/examples/set_cuda_architecture.cmake @@ -12,16 +12,7 @@ # the License. # ============================================================================= -# get the CUDF_TAG from fetch_dependencies.cmake (remove all whitespace & parse line: set(CUDF_TAG -# ..)) -execute_process( - COMMAND - bash -c - "sed '/^$/d;s/[[:blank:]]//g' ./fetch_dependencies.cmake | grep 'set(CUDF_TAG' | sed 's/.*CUDF_TAG//' | sed 's/.$//'" - OUTPUT_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE CUDF_TAG - WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} -) +include(${CMAKE_CURRENT_LIST_DIR}/versions.cmake) if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/libcudf_cpp_examples_RAPIDS.cmake) file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/${CUDF_TAG}/RAPIDS.cmake diff --git a/cpp/examples/strings/CMakeLists.txt b/cpp/examples/strings/CMakeLists.txt index 559b0b33c02..a632ab1a01c 100644 --- a/cpp/examples/strings/CMakeLists.txt +++ b/cpp/examples/strings/CMakeLists.txt @@ -21,35 +21,36 @@ list(APPEND CUDF_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr) add_executable(libcudf_apis libcudf_apis.cpp) target_compile_features(libcudf_apis PRIVATE cxx_std_17) target_link_libraries(libcudf_apis PRIVATE cudf::cudf nvToolsExt) - -# Force set CMAKE_INSTALL_PREFIX from environment variable -if(NOT $ENV{CMAKE_INSTALL_PREFIX} STREQUAL "") - # set the CMAKE_INSTALL_PREFIX to the environment variable value - set(CMAKE_INSTALL_PREFIX - "$ENV{CMAKE_INSTALL_PREFIX}" - CACHE STRING "Force CMAKE_INSTALL_PREFIX to environment variable" FORCE - ) -endif() - -install(TARGETS libcudf_apis DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) -install(FILES ${CMAKE_CURRENT_LIST_DIR}/names.csv - DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf +install( + TARGETS libcudf_apis + DESTINATION DESTINATION + bin/examples/libcudf ) add_executable(custom_with_malloc custom_with_malloc.cu) target_compile_features(custom_with_malloc PRIVATE cxx_std_17) target_compile_options(custom_with_malloc PRIVATE "$<$:${CUDF_CUDA_FLAGS}>") target_link_libraries(custom_with_malloc PRIVATE cudf::cudf nvToolsExt) -install(TARGETS custom_with_malloc DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) +install(TARGETS custom_with_malloc DESTINATION bin/examples/libcudf) add_executable(custom_prealloc custom_prealloc.cu) target_compile_features(custom_prealloc PRIVATE cxx_std_17) target_compile_options(custom_prealloc PRIVATE "$<$:${CUDF_CUDA_FLAGS}>") target_link_libraries(custom_prealloc PRIVATE cudf::cudf nvToolsExt) -install(TARGETS custom_prealloc DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) +install( + TARGETS custom_prealloc + DESTINATION DESTINATION + bin/examples/libcudf +) add_executable(custom_optimized custom_optimized.cu) target_compile_features(custom_optimized PRIVATE cxx_std_17) target_compile_options(custom_optimized PRIVATE "$<$:${CUDF_CUDA_FLAGS}>") target_link_libraries(custom_optimized PRIVATE cudf::cudf nvToolsExt) -install(TARGETS custom_optimized DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/examples/libcudf) +install( + TARGETS custom_optimized + DESTINATION DESTINATION + bin/examples/libcudf +) + +install(FILES ${CMAKE_CURRENT_LIST_DIR}/names.csv DESTINATION bin/examples/libcudf) diff --git a/cpp/examples/versions.cmake b/cpp/examples/versions.cmake new file mode 100644 index 00000000000..9fd6f478ebb --- /dev/null +++ b/cpp/examples/versions.cmake @@ -0,0 +1,15 @@ +# ============================================================================= +# Copyright (c) 2024, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(CUDF_TAG branch-24.06) \ No newline at end of file From 00d1e2b8c9a6a1743a674e10b630ffb08e2f5cd1 Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Tue, 16 Apr 2024 19:14:28 +0000 Subject: [PATCH 19/22] pre-commit eol --- cpp/examples/versions.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/examples/versions.cmake b/cpp/examples/versions.cmake index 9fd6f478ebb..dff66b4d7d8 100644 --- a/cpp/examples/versions.cmake +++ b/cpp/examples/versions.cmake @@ -12,4 +12,4 @@ # the License. # ============================================================================= -set(CUDF_TAG branch-24.06) \ No newline at end of file +set(CUDF_TAG branch-24.06) From 72089ac8ea821e71fb2fd6c5f75606c6a7fd8c54 Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Wed, 17 Apr 2024 03:54:40 +0000 Subject: [PATCH 20/22] apply reviewer suggestions --- .gitignore | 1 + cpp/examples/basic/CMakeLists.txt | 1 + cpp/examples/build.sh | 7 ++++++- cpp/examples/fetch_dependencies.cmake | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 471d4100458..313bb1c3789 100644 --- a/.gitignore +++ b/.gitignore @@ -78,6 +78,7 @@ CMakeFiles/ Debug build/ cpp/build/ +cpp/examples/*/install/ cpp/include/cudf/ipc_generated/*.h cpp/thirdparty/googletest/ diff --git a/cpp/examples/basic/CMakeLists.txt b/cpp/examples/basic/CMakeLists.txt index 3a7b218dda5..a3fe699667a 100644 --- a/cpp/examples/basic/CMakeLists.txt +++ b/cpp/examples/basic/CMakeLists.txt @@ -15,6 +15,7 @@ project( ) include(../fetch_dependencies.cmake) + # Configure your project here add_executable(basic_example src/process_csv.cpp) target_link_libraries(basic_example PRIVATE cudf::cudf) diff --git a/cpp/examples/build.sh b/cpp/examples/build.sh index 425e76111ad..5f79b006b25 100755 --- a/cpp/examples/build.sh +++ b/cpp/examples/build.sh @@ -30,6 +30,11 @@ done EXAMPLES_DIR=$(dirname "$(realpath "$0")") LIB_BUILD_DIR=${LIB_BUILD_DIR:-$(readlink -f "${EXAMPLES_DIR}/../build")} +# Setup default install prefix if conda build +if [ "${CONDA_BUILD:-"0"}" == "1" ]; then + INSTALL_PREFIX="${INSTALL_PREFIX:-${PREFIX}}" +fi + ################################################################################ # Add individual libcudf examples build scripts down below @@ -44,7 +49,7 @@ build_example() { cmake --build ${build_dir} -j${PARALLEL_LEVEL} # Install if needed if [ "$INSTALL_EXAMPLES" = true ]; then - cmake --install ${build_dir} --prefix ${INSTALL_PREFIX:-${PREFIX:-${CONDA_PREFIX:-${example_dir}/install}}} + cmake --install ${build_dir} --prefix ${INSTALL_PREFIX:-${example_dir}/install} fi } diff --git a/cpp/examples/fetch_dependencies.cmake b/cpp/examples/fetch_dependencies.cmake index 9246416d0c1..36d52b1a794 100644 --- a/cpp/examples/fetch_dependencies.cmake +++ b/cpp/examples/fetch_dependencies.cmake @@ -25,7 +25,7 @@ include(${CMAKE_BINARY_DIR}/cmake/get_cpm.cmake) # find or build it via CPM CPMFindPackage( NAME cudf - FIND_PACKAGE_ARGUMENTS "HINTS ${cudf_ROOT}/latest" GIT_REPOSITORY https://github.com/rapidsai/cudf + FIND_PACKAGE_ARGUMENTS "HINTS ${cudf_ROOT} ${cudf_ROOT}/latest" GIT_REPOSITORY https://github.com/rapidsai/cudf GIT_TAG ${CUDF_TAG} GIT_SHALLOW TRUE From c088772d8504a0422145c11383e9bfb2eb581b54 Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Wed, 17 Apr 2024 03:57:25 +0000 Subject: [PATCH 21/22] minor improvements --- cpp/examples/build.sh | 2 +- cpp/examples/fetch_dependencies.cmake | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cpp/examples/build.sh b/cpp/examples/build.sh index 5f79b006b25..ba57b758f03 100755 --- a/cpp/examples/build.sh +++ b/cpp/examples/build.sh @@ -31,7 +31,7 @@ EXAMPLES_DIR=$(dirname "$(realpath "$0")") LIB_BUILD_DIR=${LIB_BUILD_DIR:-$(readlink -f "${EXAMPLES_DIR}/../build")} # Setup default install prefix if conda build -if [ "${CONDA_BUILD:-"0"}" == "1" ]; then +if [ "${CONDA_BUILD:-"0"}" == "1" ]; then INSTALL_PREFIX="${INSTALL_PREFIX:-${PREFIX}}" fi diff --git a/cpp/examples/fetch_dependencies.cmake b/cpp/examples/fetch_dependencies.cmake index 36d52b1a794..a2e71c78c89 100644 --- a/cpp/examples/fetch_dependencies.cmake +++ b/cpp/examples/fetch_dependencies.cmake @@ -25,7 +25,8 @@ include(${CMAKE_BINARY_DIR}/cmake/get_cpm.cmake) # find or build it via CPM CPMFindPackage( NAME cudf - FIND_PACKAGE_ARGUMENTS "HINTS ${cudf_ROOT} ${cudf_ROOT}/latest" GIT_REPOSITORY https://github.com/rapidsai/cudf + FIND_PACKAGE_ARGUMENTS "HINTS ${cudf_ROOT} ${cudf_ROOT}/latest" GIT_REPOSITORY + https://github.com/rapidsai/cudf GIT_TAG ${CUDF_TAG} GIT_SHALLOW TRUE From 996367d61ae67936ad0e3bc3ac821dabefd7538e Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb Date: Wed, 17 Apr 2024 18:36:41 +0000 Subject: [PATCH 22/22] minor improvements and add default LIB_BUILD_DIR --- cpp/examples/build.sh | 7 +++++-- cpp/examples/fetch_dependencies.cmake | 2 +- cpp/examples/strings/CMakeLists.txt | 18 +++--------------- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/cpp/examples/build.sh b/cpp/examples/build.sh index ba57b758f03..9802c876930 100755 --- a/cpp/examples/build.sh +++ b/cpp/examples/build.sh @@ -28,13 +28,16 @@ done # Root of examples EXAMPLES_DIR=$(dirname "$(realpath "$0")") -LIB_BUILD_DIR=${LIB_BUILD_DIR:-$(readlink -f "${EXAMPLES_DIR}/../build")} -# Setup default install prefix if conda build +# Set up default libcudf build directory and install prefix if conda build if [ "${CONDA_BUILD:-"0"}" == "1" ]; then + LIB_BUILD_DIR="${LIB_BUILD_DIR:-${SRC_DIR/cpp/build}}" INSTALL_PREFIX="${INSTALL_PREFIX:-${PREFIX}}" fi +# libcudf build directory +LIB_BUILD_DIR=${LIB_BUILD_DIR:-$(readlink -f "${EXAMPLES_DIR}/../build")} + ################################################################################ # Add individual libcudf examples build scripts down below diff --git a/cpp/examples/fetch_dependencies.cmake b/cpp/examples/fetch_dependencies.cmake index a2e71c78c89..851405caf55 100644 --- a/cpp/examples/fetch_dependencies.cmake +++ b/cpp/examples/fetch_dependencies.cmake @@ -25,7 +25,7 @@ include(${CMAKE_BINARY_DIR}/cmake/get_cpm.cmake) # find or build it via CPM CPMFindPackage( NAME cudf - FIND_PACKAGE_ARGUMENTS "HINTS ${cudf_ROOT} ${cudf_ROOT}/latest" GIT_REPOSITORY + FIND_PACKAGE_ARGUMENTS "PATHS ${cudf_ROOT} ${cudf_ROOT}/latest" GIT_REPOSITORY https://github.com/rapidsai/cudf GIT_TAG ${CUDF_TAG} GIT_SHALLOW diff --git a/cpp/examples/strings/CMakeLists.txt b/cpp/examples/strings/CMakeLists.txt index a632ab1a01c..a5654870544 100644 --- a/cpp/examples/strings/CMakeLists.txt +++ b/cpp/examples/strings/CMakeLists.txt @@ -21,11 +21,7 @@ list(APPEND CUDF_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr) add_executable(libcudf_apis libcudf_apis.cpp) target_compile_features(libcudf_apis PRIVATE cxx_std_17) target_link_libraries(libcudf_apis PRIVATE cudf::cudf nvToolsExt) -install( - TARGETS libcudf_apis - DESTINATION DESTINATION - bin/examples/libcudf -) +install(TARGETS libcudf_apis DESTINATION bin/examples/libcudf) add_executable(custom_with_malloc custom_with_malloc.cu) target_compile_features(custom_with_malloc PRIVATE cxx_std_17) @@ -37,20 +33,12 @@ add_executable(custom_prealloc custom_prealloc.cu) target_compile_features(custom_prealloc PRIVATE cxx_std_17) target_compile_options(custom_prealloc PRIVATE "$<$:${CUDF_CUDA_FLAGS}>") target_link_libraries(custom_prealloc PRIVATE cudf::cudf nvToolsExt) -install( - TARGETS custom_prealloc - DESTINATION DESTINATION - bin/examples/libcudf -) +install(TARGETS custom_prealloc DESTINATION bin/examples/libcudf) add_executable(custom_optimized custom_optimized.cu) target_compile_features(custom_optimized PRIVATE cxx_std_17) target_compile_options(custom_optimized PRIVATE "$<$:${CUDF_CUDA_FLAGS}>") target_link_libraries(custom_optimized PRIVATE cudf::cudf nvToolsExt) -install( - TARGETS custom_optimized - DESTINATION DESTINATION - bin/examples/libcudf -) +install(TARGETS custom_optimized DESTINATION bin/examples/libcudf) install(FILES ${CMAKE_CURRENT_LIST_DIR}/names.csv DESTINATION bin/examples/libcudf)