From 5ab6b875799bfc2505f0ecc0c107cd7b9234820d Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Thu, 16 Sep 2021 16:34:09 -0400 Subject: [PATCH 001/675] DOC v21.12 Updates --- CHANGELOG.md | 4 ++++ CMakeLists.txt | 2 +- doxygen/Doxyfile | 2 +- python/docs/conf.py | 6 +++--- python/setup.py | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0c6ee2db..5fa07d2a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# RMM 21.12.00 (Date TBD) + +Please see https://github.com/rapidsai/rmm/releases/tag/v21.12.00a for the latest changes to this development branch. + # RMM 21.10.00 (Date TBD) Please see https://github.com/rapidsai/rmm/releases/tag/v21.10.00a for the latest changes to this development branch. diff --git a/CMakeLists.txt b/CMakeLists.txt index b699db058..37bf49ba6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ include(rapids-find) project( RMM - VERSION 21.10.00 + VERSION 21.12.00 LANGUAGES CXX) # Write the version header diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 998d0bb70..c082eef6a 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "RMM" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 21.10 +PROJECT_NUMBER = 21.12 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/python/docs/conf.py b/python/docs/conf.py index c71035327..4af533fd3 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -19,7 +19,7 @@ author = "NVIDIA" # The full version, including alpha/beta/rc tags -release = "21.10.00" +release = "21.12.00" # -- General configuration --------------------------------------------------- @@ -69,9 +69,9 @@ # built documents. # # The short X.Y version. -version = "21.10" +version = "21.12" # The full version, including alpha/beta/rc tags. -release = "21.10.00" +release = "21.12.00" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/python/setup.py b/python/setup.py index 8101ba2ef..3f8203acb 100644 --- a/python/setup.py +++ b/python/setup.py @@ -189,7 +189,7 @@ def get_cuda_version_from_header(cuda_include_dir): setup( name="rmm", - version="21.10.00", + version="21.12.00", description="rmm - RAPIDS Memory Manager", url="https://github.com/rapidsai/rmm", author="NVIDIA Corporation", From b51269028b5dae4dcb8f9a1df54cea0f65074168 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 20 Sep 2021 20:22:19 -0400 Subject: [PATCH 002/675] Keep rapids cmake version in sync (#876) Make sure we keep the rapids-cmake and rmm cal version in sync when we make a new rmm version, we need to also bump the rapids-cmake version at the same time. Otherwise we will get the previous releases dependencies by mistake. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/876 --- CMakeLists.txt | 2 +- ci/release/update-version.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37bf49ba6..4bf884542 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-21.10/RAPIDS.cmake +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-21.12/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 7338a70c1..bf31c981a 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -30,10 +30,11 @@ function sed_runner() { } sed_runner 's/'" VERSION .*"'/'" VERSION ${NEXT_FULL_TAG}"'/g' CMakeLists.txt +sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' CMakeLists.txt sed_runner 's/version=.*/version=\"'"${NEXT_FULL_TAG}"'\",/g' python/setup.py sed_runner 's/'"PROJECT_NUMBER = .*"'/'"PROJECT_NUMBER = ${NEXT_SHORT_TAG}"'/g' doxygen/Doxyfile sed_runner 's/'"version =.*"'/'"version = \"${NEXT_SHORT_TAG}\""'/g' python/docs/conf.py -sed_runner 's/'"release =.*"'/'"release = \"${NEXT_FULL_TAG}\""'/g' python/docs/conf.py \ No newline at end of file +sed_runner 's/'"release =.*"'/'"release = \"${NEXT_FULL_TAG}\""'/g' python/docs/conf.py From 210e2a1a184e0e816d7fe5eacd130da05586a2cb Mon Sep 17 00:00:00 2001 From: Paul Taylor Date: Fri, 8 Oct 2021 15:39:20 -0500 Subject: [PATCH 003/675] Add spdlog to install export set (#886) This PR installs `spdlog` when `rmm` is installed. Authors: - Paul Taylor (https://github.com/trxcllnt) Approvers: - Robert Maynard (https://github.com/robertmaynard) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/886 --- cmake/thirdparty/get_spdlog.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmake/thirdparty/get_spdlog.cmake b/cmake/thirdparty/get_spdlog.cmake index b10763d5f..e816bff35 100644 --- a/cmake/thirdparty/get_spdlog.cmake +++ b/cmake/thirdparty/get_spdlog.cmake @@ -16,13 +16,12 @@ function(find_and_configure_spdlog) include(${rapids-cmake-dir}/cpm/spdlog.cmake) - rapids_cpm_spdlog() + rapids_cpm_spdlog(INSTALL_EXPORT_SET rmm-exports) if(spdlog_ADDED) install(TARGETS spdlog_header_only EXPORT rmm-exports) else() rapids_export_package(BUILD spdlog rmm-exports) - rapids_export_package(INSTALL spdlog rmm-exports) endif() endfunction() From c781527db4ec62168ca483febf2c1dcc15e16aa2 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 13 Oct 2021 12:28:30 +1100 Subject: [PATCH 004/675] Fix return value docs for supports_get_mem_info (#884) Fixes #880 Fixes the documentation of return value of `supports_get_mem_info` in several memory resources. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Rong Ou (https://github.com/rongou) - Conor Hoekstra (https://github.com/codereport) URL: https://github.com/rapidsai/rmm/pull/884 --- include/rmm/mr/device/binning_memory_resource.hpp | 2 +- include/rmm/mr/device/cuda_async_memory_resource.hpp | 2 +- include/rmm/mr/device/fixed_size_memory_resource.hpp | 2 +- include/rmm/mr/device/managed_memory_resource.hpp | 2 +- include/rmm/mr/device/owning_wrapper.hpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/rmm/mr/device/binning_memory_resource.hpp b/include/rmm/mr/device/binning_memory_resource.hpp index 5d4b156c8..fa8a9aa7c 100644 --- a/include/rmm/mr/device/binning_memory_resource.hpp +++ b/include/rmm/mr/device/binning_memory_resource.hpp @@ -104,7 +104,7 @@ class binning_memory_resource final : public device_memory_resource { /** * @brief Query whether the resource supports the get_mem_info API. * - * @return bool true if the resource supports get_mem_info, false otherwise. + * @return false */ [[nodiscard]] bool supports_get_mem_info() const noexcept override { return false; } diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 9111a2da3..a2d8c8567 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -124,7 +124,7 @@ class cuda_async_memory_resource final : public device_memory_resource { /** * @brief Query whether the resource supports the get_mem_info API. * - * @return true + * @return false */ [[nodiscard]] bool supports_get_mem_info() const noexcept override { return false; } diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index 4c29881fb..1a91a7060 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -100,7 +100,7 @@ class fixed_size_memory_resource /** * @brief Query whether the resource supports the get_mem_info API. * - * @return bool true if the resource supports get_mem_info, false otherwise. + * @return false */ [[nodiscard]] bool supports_get_mem_info() const noexcept override { return false; } diff --git a/include/rmm/mr/device/managed_memory_resource.hpp b/include/rmm/mr/device/managed_memory_resource.hpp index 7cce644be..a2be418c7 100644 --- a/include/rmm/mr/device/managed_memory_resource.hpp +++ b/include/rmm/mr/device/managed_memory_resource.hpp @@ -47,7 +47,7 @@ class managed_memory_resource final : public device_memory_resource { /** * @brief Query whether the resource supports the get_mem_info API. * - * @return bool true if the resource supports get_mem_info, false otherwise. + * @return true */ [[nodiscard]] bool supports_get_mem_info() const noexcept override { return true; } diff --git a/include/rmm/mr/device/owning_wrapper.hpp b/include/rmm/mr/device/owning_wrapper.hpp index 977ae0c11..d7c7b8c46 100644 --- a/include/rmm/mr/device/owning_wrapper.hpp +++ b/include/rmm/mr/device/owning_wrapper.hpp @@ -138,7 +138,7 @@ class owning_wrapper : public device_memory_resource { /** * @brief Query whether the resource supports the get_mem_info API. * - * @return true if the upstream resource supports get_mem_info, false otherwise. + * @return true if the wrapped resource supports get_mem_info, false otherwise. */ [[nodiscard]] bool supports_get_mem_info() const noexcept override { From fcf92c527670bb1579d2669ee48d9fccb4a1792a Mon Sep 17 00:00:00 2001 From: Rong Ou Date: Mon, 25 Oct 2021 22:43:16 -0700 Subject: [PATCH 005/675] Throw `rmm::out_of_memory` when we know for sure (#894) When RMM fails to allocate a buffer, it currently throws a `rmm::bad_alloc` exception, which a user might want to catch, spill some GPU buffers, and try again. But that exception covers all error conditions, catching it blindly may hide some other more serious CUDA errors, making the code hard to debug. Adding a more specific `rmm::out_of_memory` exception and throwing it when we are certain we are running out of memory, so that it can be caught to trigger spilling. Authors: - Rong Ou (https://github.com/rongou) Approvers: - Mark Harris (https://github.com/harrism) - Jake Hemstad (https://github.com/jrhemstad) URL: https://github.com/rapidsai/rmm/pull/894 --- include/rmm/detail/error.hpp | 35 +++++++++++++++++++ .../rmm/mr/device/arena_memory_resource.hpp | 2 +- .../mr/device/cuda_async_memory_resource.hpp | 3 +- .../rmm/mr/device/cuda_memory_resource.hpp | 2 +- .../detail/stream_ordered_memory_resource.hpp | 2 +- .../mr/device/limiting_resource_adaptor.hpp | 2 +- .../rmm/mr/device/managed_memory_resource.hpp | 2 +- .../rmm/mr/device/pool_memory_resource.hpp | 2 +- tests/mr/device/limiting_mr_tests.cpp | 4 +-- tests/mr/device/mr_multithreaded_tests.cpp | 3 ++ tests/mr/device/mr_test.hpp | 2 +- tests/mr/device/pool_mr_tests.cpp | 2 +- tests/mr/device/thrust_allocator_tests.cu | 4 +++ 13 files changed, 53 insertions(+), 12 deletions(-) diff --git a/include/rmm/detail/error.hpp b/include/rmm/detail/error.hpp index 1f550f75e..89cbcd916 100644 --- a/include/rmm/detail/error.hpp +++ b/include/rmm/detail/error.hpp @@ -60,6 +60,16 @@ class bad_alloc : public std::bad_alloc { std::string _what; }; +/** + * @brief Exception thrown when RMM runs out of memory + * + * This error should only be thrown when we know for sure a resource is out of memory. + */ +class out_of_memory : public bad_alloc { + public: + using bad_alloc::bad_alloc; +}; + /** * @brief Exception thrown when attempting to access outside of a defined range * @@ -167,6 +177,31 @@ class out_of_range : public std::out_of_range { } while (0) #define RMM_CUDA_TRY_1(_call) RMM_CUDA_TRY_2(_call, rmm::cuda_error) +/** + * @brief Error checking macro for CUDA memory allocation calls. + * + * Invokes a CUDA memory allocation function call. If the call does not return + * `cudaSuccess`, invokes cudaGetLastError() to clear the error and throws an + * exception detailing the CUDA error that occurred + * + * Defaults to throwing `rmm::bad_alloc`, but when `cudaErrorMemoryAllocation` is returned, + * `rmm::out_of_memory` is thrown instead. + */ +#define RMM_CUDA_TRY_ALLOC(_call) \ + do { \ + cudaError_t const error = (_call); \ + if (cudaSuccess != error) { \ + cudaGetLastError(); \ + auto const msg = std::string{"CUDA error at: "} + __FILE__ + ":" + RMM_STRINGIFY(__LINE__) + \ + ": " + cudaGetErrorName(error) + " " + cudaGetErrorString(error); \ + if (cudaErrorMemoryAllocation == error) { \ + throw rmm::out_of_memory{msg}; \ + } else { \ + throw rmm::bad_alloc{msg}; \ + } \ + } \ + } while (0) + /** * @brief Error checking macro similar to `assert` for CUDA runtime API calls * diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index ce8737225..c9954a507 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -154,7 +154,7 @@ class arena_memory_resource final : public device_memory_resource { pointer = arena.allocate(bytes); if (pointer == nullptr) { if (dump_log_on_failure_) { dump_memory_log(bytes); } - RMM_FAIL("Maximum pool size exceeded", rmm::bad_alloc); + RMM_FAIL("Maximum pool size exceeded", rmm::out_of_memory); } } diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index a2d8c8567..949a4d940 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -148,8 +148,7 @@ class cuda_async_memory_resource final : public device_memory_resource { void* ptr{nullptr}; #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT if (bytes > 0) { - RMM_CUDA_TRY(cudaMallocFromPoolAsync(&ptr, bytes, pool_handle(), stream.value()), - rmm::bad_alloc); + RMM_CUDA_TRY_ALLOC(cudaMallocFromPoolAsync(&ptr, bytes, pool_handle(), stream.value())); } #else (void)bytes; diff --git a/include/rmm/mr/device/cuda_memory_resource.hpp b/include/rmm/mr/device/cuda_memory_resource.hpp index b5b3d87df..800d0b62c 100644 --- a/include/rmm/mr/device/cuda_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_memory_resource.hpp @@ -67,7 +67,7 @@ class cuda_memory_resource final : public device_memory_resource { void* do_allocate(std::size_t bytes, cuda_stream_view) override { void* ptr{nullptr}; - RMM_CUDA_TRY(cudaMalloc(&ptr, bytes), rmm::bad_alloc); + RMM_CUDA_TRY_ALLOC(cudaMalloc(&ptr, bytes)); return ptr; } diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index 2a726377d..43da17d0f 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -208,7 +208,7 @@ class stream_ordered_memory_resource : public crtp, public device_ size = rmm::detail::align_up(size, rmm::detail::CUDA_ALLOCATION_ALIGNMENT); RMM_EXPECTS(size <= this->underlying().get_maximum_allocation_size(), - rmm::bad_alloc, + rmm::out_of_memory, "Maximum allocation size exceeded"); auto const block = this->underlying().get_block(size, stream_event); diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index 05b45ce31..cdcee0857 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -140,7 +140,7 @@ class limiting_resource_adaptor final : public device_memory_resource { } allocated_bytes_ -= proposed_size; - RMM_FAIL("Exceeded memory limit", rmm::bad_alloc); + RMM_FAIL("Exceeded memory limit", rmm::out_of_memory); } /** diff --git a/include/rmm/mr/device/managed_memory_resource.hpp b/include/rmm/mr/device/managed_memory_resource.hpp index a2be418c7..1bc917e0e 100644 --- a/include/rmm/mr/device/managed_memory_resource.hpp +++ b/include/rmm/mr/device/managed_memory_resource.hpp @@ -71,7 +71,7 @@ class managed_memory_resource final : public device_memory_resource { if (bytes == 0) { return nullptr; } void* ptr{nullptr}; - RMM_CUDA_TRY(cudaMallocManaged(&ptr, bytes), rmm::bad_alloc); + RMM_CUDA_TRY_ALLOC(cudaMallocManaged(&ptr, bytes)); return ptr; } diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 526852355..5a4d6fc1e 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -180,7 +180,7 @@ class pool_memory_resource final RMM_LOG_ERROR("[A][Stream {}][Upstream {}B][FAILURE maximum pool size exceeded]", fmt::ptr(stream.value()), min_size); - RMM_FAIL("Maximum pool size exceeded", rmm::bad_alloc); + RMM_FAIL("Maximum pool size exceeded", rmm::out_of_memory); } /** diff --git a/tests/mr/device/limiting_mr_tests.cpp b/tests/mr/device/limiting_mr_tests.cpp index 3bc643abc..80c49104f 100644 --- a/tests/mr/device/limiting_mr_tests.cpp +++ b/tests/mr/device/limiting_mr_tests.cpp @@ -38,7 +38,7 @@ TEST(LimitingTest, TooBig) { auto const max_size{5_MiB}; Limiting_adaptor mr{rmm::mr::get_current_device_resource(), max_size}; - EXPECT_THROW(mr.allocate(max_size + 1), rmm::bad_alloc); + EXPECT_THROW(mr.allocate(max_size + 1), rmm::out_of_memory); } TEST(LimitingTest, UnderLimitDueToFrees) @@ -83,7 +83,7 @@ TEST(LimitingTest, OverLimit) EXPECT_EQ(mr.get_allocated_bytes(), allocated_bytes); EXPECT_EQ(mr.get_allocation_limit() - mr.get_allocated_bytes(), max_size - allocated_bytes); auto const size2{3_MiB}; - EXPECT_THROW(mr.allocate(size2), rmm::bad_alloc); + EXPECT_THROW(mr.allocate(size2), rmm::out_of_memory); EXPECT_EQ(mr.get_allocated_bytes(), allocated_bytes); EXPECT_EQ(mr.get_allocation_limit() - mr.get_allocated_bytes(), max_size - allocated_bytes); mr.deallocate(ptr1, 4_MiB); diff --git a/tests/mr/device/mr_multithreaded_tests.cpp b/tests/mr/device/mr_multithreaded_tests.cpp index 838035d9f..38c34d93f 100644 --- a/tests/mr/device/mr_multithreaded_tests.cpp +++ b/tests/mr/device/mr_multithreaded_tests.cpp @@ -37,6 +37,9 @@ struct mr_test_mt : public mr_test { INSTANTIATE_TEST_CASE_P(MultiThreadResourceTests, mr_test_mt, ::testing::Values(mr_factory{"CUDA", &make_cuda}, +#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT + mr_factory{"CUDA_Async", &make_cuda_async}, +#endif mr_factory{"Managed", &make_managed}, mr_factory{"Pool", &make_pool}, mr_factory{"Arena", &make_arena}, diff --git a/tests/mr/device/mr_test.hpp b/tests/mr/device/mr_test.hpp index 4bef2b54e..7635901c8 100644 --- a/tests/mr/device/mr_test.hpp +++ b/tests/mr/device/mr_test.hpp @@ -128,7 +128,7 @@ inline void test_various_allocations(rmm::mr::device_memory_resource* mr, cuda_s // should fail to allocate too much { void* ptr{nullptr}; - EXPECT_THROW(ptr = mr->allocate(1_PiB, stream), rmm::bad_alloc); + EXPECT_THROW(ptr = mr->allocate(1_PiB, stream), rmm::out_of_memory); EXPECT_EQ(nullptr, ptr); } } diff --git a/tests/mr/device/pool_mr_tests.cpp b/tests/mr/device/pool_mr_tests.cpp index 9f2020785..ca8888a52 100644 --- a/tests/mr/device/pool_mr_tests.cpp +++ b/tests/mr/device/pool_mr_tests.cpp @@ -86,7 +86,7 @@ TEST(PoolTest, ForceGrowth) EXPECT_NO_THROW(mr.allocate(1000)); EXPECT_NO_THROW(mr.allocate(4000)); EXPECT_NO_THROW(mr.allocate(500)); - EXPECT_THROW(mr.allocate(2000), rmm::bad_alloc); // too much + EXPECT_THROW(mr.allocate(2000), rmm::out_of_memory); // too much } TEST(PoolTest, DeletedStream) diff --git a/tests/mr/device/thrust_allocator_tests.cu b/tests/mr/device/thrust_allocator_tests.cu index eabdfe143..c80f3d9e2 100644 --- a/tests/mr/device/thrust_allocator_tests.cu +++ b/tests/mr/device/thrust_allocator_tests.cu @@ -37,8 +37,12 @@ TEST_P(allocator_test, first) INSTANTIATE_TEST_CASE_P(ThrustAllocatorTests, allocator_test, ::testing::Values(mr_factory{"CUDA", &make_cuda}, +#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT + mr_factory{"CUDA_Async", &make_cuda_async}, +#endif mr_factory{"Managed", &make_managed}, mr_factory{"Pool", &make_pool}, + mr_factory{"Arena", &make_arena}, mr_factory{"Binning", &make_binning}), [](auto const& info) { return info.param.name; }); From 0fbe3574f2cb80b054dd7bc53185746b8d8eb951 Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Tue, 26 Oct 2021 23:19:19 +0200 Subject: [PATCH 006/675] Out-of-memory callback resource adaptor (#892) This PR implements a new resource adaptor that calls a callback function when an allocation fails. The idea being that the callback function can free up memory (e.g. by spilling) and ask rmm to retry the allocation. ```c++ /** * @brief Resource that uses `Upstream` to allocate memory and calls `callback` * when allocations throws `std::bad_alloc`. * * An instance of this resource can be constructed with an existing, upstream * resource in order to satisfy allocation requests. * * The callback function takes an allocation size and a closure and returns * whether to retry the allocation or throw `std::bad_alloc`. * * @tparam Upstream Type of the upstream resource used for * allocation/deallocation. */ template class oom_callback_resource_adaptor final : public device_memory_resource ``` This is motivated by the fairly primitive spilling in Dask. Currently, Dask and Dask-CUDA has no way of handling OOM errors other then restarting tasks or workers. Instead they spill preemptively based on some very conservative memory thresholds. For instance, most workflows in Dask-CUDA starts spilling when half the GPU memory is in use. This PR makes it possible for projects like Dask and Dask-CUDA to trigger spilling on demand instead of preemptively. cc. @jrhemstad @shwina Authors: - Mads R. B. Kristensen (https://github.com/madsbk) Approvers: - Ashwin Srinath (https://github.com/shwina) - Jake Hemstad (https://github.com/jrhemstad) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/892 --- include/rmm/device_uvector.hpp | 2 +- .../failure_callback_resource_adaptor.hpp | 217 ++++++++++++++++++ python/rmm/_lib/__init__.pxd | 13 ++ python/rmm/_lib/__init__.py | 14 +- python/rmm/_lib/device_uvector.pxd | 12 + python/rmm/_lib/memory_resource.pxd | 17 +- python/rmm/_lib/memory_resource.pyx | 66 +++++- python/rmm/mr.py | 16 +- python/rmm/tests/test_rmm.py | 34 ++- tests/CMakeLists.txt | 5 +- tests/mr/device/failure_callback_mr_tests.cpp | 54 +++++ 11 files changed, 443 insertions(+), 7 deletions(-) create mode 100644 include/rmm/mr/device/failure_callback_resource_adaptor.hpp create mode 100644 tests/mr/device/failure_callback_mr_tests.cpp diff --git a/include/rmm/device_uvector.hpp b/include/rmm/device_uvector.hpp index b4b12c824..5457b664c 100644 --- a/include/rmm/device_uvector.hpp +++ b/include/rmm/device_uvector.hpp @@ -39,7 +39,7 @@ namespace rmm { * `thrust::uninitialized_fill`. * * Example: - * @code + * @code{c++} * rmm::mr::device_memory_resource * mr = new my_custom_resource(); * rmm::cuda_stream_view s{}; * diff --git a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp new file mode 100644 index 000000000..d3f8e5b7a --- /dev/null +++ b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2020-2021, 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. + */ +#pragma once + +#include +#include + +#include +#include + +namespace rmm::mr { + +/** + * @brief Callback function type used by failure_callback_resource_adaptor + * + * The resource adaptor calls this function when a memory allocation throws a + * `std::bad_alloc` exception. The function decides whether the resource adaptor + * should try to allocate the memory again or re-throw the `std::bad_alloc` + * exception. + * + * The callback function signature is: + * `bool failure_callback_t(std::size_t bytes, void* callback_arg)` + * + * The callback function will be passed two parameters: `bytes` is the size of the + * failed memory allocation, and `arg` is the extra argument passed to the constructor + * of the `failure_callback_resource_adaptor`. The callback function returns a Boolean + * where true means to retry the memory allocation and false means to throw a + * `rmm::bad_alloc` exception. + */ +using failure_callback_t = std::function; + +/** + * @brief A device memory resource that calls a callback function when allocations + * throws `std::bad_alloc`. + * + * An instance of this resource must be constructed with an existing, upstream + * resource in order to satisfy allocation requests. + * + * The callback function takes an allocation size and a callback argument and returns + * a bool representing whether to retry the allocation (true) or throw `std::bad_alloc` + * (false). + * + * When implementing a callback function for allocation retry, care must be taken to + * avoid an infinite loop. In the following example, we make sure to only retry the allocation + * once: + * + * @code{c++} + * using failure_callback_adaptor = + * rmm::mr::failure_callback_resource_adaptor; + * + * bool failure_handler(std::size_t bytes, void* arg) + * { + * bool& retried = *reinterpret_cast(arg); + * if (!retried) { + * retried = true; + * return true; // First time we request an allocation retry + * } else { + * return false; // Second time we let the adaptor throw std::bad_alloc + * } + * } + * + * int main() + * { + * bool retried{false}; + * failure_callback_adaptor mr{ + * rmm::mr::get_current_device_resource(), failure_handler, &retried + * }; + * rmm::mr::set_current_device_resource(&mr); + * } + * @endcode + * + * @tparam Upstream The type of the upstream resource used for allocation/deallocation. + */ +template +class failure_callback_resource_adaptor final : public device_memory_resource { + public: + /** + * @brief Construct a new `failure_callback_resource_adaptor` using `upstream` to satisfy + * allocation requests. + * + * @throws `rmm::logic_error` if `upstream == nullptr` + * + * @param upstream The resource used for allocating/deallocating device memory + * @param callback Callback function @see failure_callback_t + * @param callback_arg Extra argument passed to `callback` + */ + failure_callback_resource_adaptor(Upstream* upstream, + failure_callback_t callback, + void* callback_arg) + : upstream_{upstream}, callback_{callback}, callback_arg_{callback_arg} + { + RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); + } + + failure_callback_resource_adaptor() = delete; + ~failure_callback_resource_adaptor() override = default; + failure_callback_resource_adaptor(failure_callback_resource_adaptor const&) = delete; + failure_callback_resource_adaptor& operator=(failure_callback_resource_adaptor const&) = delete; + failure_callback_resource_adaptor(failure_callback_resource_adaptor&&) noexcept = default; + failure_callback_resource_adaptor& operator=(failure_callback_resource_adaptor&&) noexcept = + default; + + /** + * @brief Return pointer to the upstream resource. + * + * @return Upstream* Pointer to the upstream resource. + */ + Upstream* get_upstream() const noexcept { return upstream_; } + + /** + * @brief Checks whether the upstream resource supports streams. + * + * @return true The upstream resource supports streams + * @return false The upstream resource does not support streams. + */ + bool supports_streams() const noexcept override { return upstream_->supports_streams(); } + + /** + * @brief Query whether the resource supports the get_mem_info API. + * + * @return bool true if the upstream resource supports get_mem_info, false otherwise. + */ + bool supports_get_mem_info() const noexcept override + { + return upstream_->supports_get_mem_info(); + } + + private: + /** + * @brief Allocates memory of size at least `bytes` using the upstream + * resource. + * + * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled + * by the upstream resource. + * + * @param bytes The size, in bytes, of the allocation + * @param stream Stream on which to perform the allocation + * @return void* Pointer to the newly allocated memory + */ + void* do_allocate(std::size_t bytes, cuda_stream_view stream) override + { + void* ret; + + while (true) { + try { + ret = upstream_->allocate(bytes, stream); + break; + } catch (std::bad_alloc const& e) { + if (!callback_(bytes, callback_arg_)) { throw; } + } + } + return ret; + } + + /** + * @brief Free allocation of size `bytes` pointed to by `ptr` + * + * @throws Nothing. + * + * @param ptr Pointer to be deallocated + * @param bytes Size of the allocation + * @param stream Stream on which to perform the deallocation + */ + void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override + { + upstream_->deallocate(ptr, bytes, stream); + } + + /** + * @brief Compare the upstream resource to another. + * + * @throws Nothing. + * + * @param other The other resource to compare to + * @return true If the two resources are equivalent + * @return false If the two resources are not equal + */ + bool do_is_equal(device_memory_resource const& other) const noexcept override + { + if (this == &other) { return true; } + auto cast = dynamic_cast const*>(&other); + return cast != nullptr ? upstream_->is_equal(*cast->get_upstream()) + : upstream_->is_equal(other); + } + + /** + * @brief Get free and available memory from upstream resource. + * + * @throws `rmm::cuda_error` if unable to retrieve memory info. + * + * @param stream Stream on which to get the mem info. + * @return std::pair contaiing free_size and total_size of memory + */ + std::pair do_get_mem_info(cuda_stream_view stream) const override + { + return upstream_->get_mem_info(stream); + } + + Upstream* upstream_; // the upstream resource used for satisfying allocation requests + failure_callback_t callback_; + void* callback_arg_; +}; + +} // namespace rmm::mr diff --git a/python/rmm/_lib/__init__.pxd b/python/rmm/_lib/__init__.pxd index e69de29bb..46753baa3 100644 --- a/python/rmm/_lib/__init__.pxd +++ b/python/rmm/_lib/__init__.pxd @@ -0,0 +1,13 @@ +# Copyright (c) 2019-2020, 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. diff --git a/python/rmm/_lib/__init__.py b/python/rmm/_lib/__init__.py index 2638f6976..0b8672ef6 100644 --- a/python/rmm/_lib/__init__.py +++ b/python/rmm/_lib/__init__.py @@ -1,3 +1,15 @@ -# Copyright (c) 2019-2020, NVIDIA CORPORATION. +# Copyright (c) 2019-2021, 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. from .device_buffer import DeviceBuffer diff --git a/python/rmm/_lib/device_uvector.pxd b/python/rmm/_lib/device_uvector.pxd index d47edc83e..582f19fe7 100644 --- a/python/rmm/_lib/device_uvector.pxd +++ b/python/rmm/_lib/device_uvector.pxd @@ -1,4 +1,16 @@ # Copyright (c) 2021, 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. from rmm._lib.cuda_stream_view cimport cuda_stream_view from rmm._lib.device_buffer cimport device_buffer diff --git a/python/rmm/_lib/memory_resource.pxd b/python/rmm/_lib/memory_resource.pxd index e690b5ed6..3a71fd500 100644 --- a/python/rmm/_lib/memory_resource.pxd +++ b/python/rmm/_lib/memory_resource.pxd @@ -1,4 +1,16 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2021, 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. from libc.stdint cimport int8_t from libcpp.memory cimport shared_ptr @@ -56,4 +68,7 @@ cdef class StatisticsResourceAdaptor(UpstreamResourceAdaptor): cdef class TrackingResourceAdaptor(UpstreamResourceAdaptor): pass +cdef class FailureCallbackResourceAdaptor(UpstreamResourceAdaptor): + cdef object _callback + cpdef DeviceMemoryResource get_current_device_resource() diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 23038c703..d7711ed8a 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -1,4 +1,17 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2021, 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. + import os import warnings from collections import defaultdict @@ -111,6 +124,19 @@ cdef extern from "rmm/mr/device/tracking_resource_adaptor.hpp" \ string get_outstanding_allocations_str() except + void log_outstanding_allocations() except + +cdef extern from "rmm/mr/device/failure_callback_resource_adaptor.hpp" \ + namespace "rmm::mr" nogil: + ctypedef bool (*failure_callback_t)(size_t, void*) + cdef cppclass failure_callback_resource_adaptor[Upstream]( + device_memory_resource + ): + failure_callback_resource_adaptor( + Upstream* upstream_mr, + failure_callback_t callback, + void* callback_arg + ) except + + + cdef extern from "rmm/mr/device/per_device_resource.hpp" namespace "rmm" nogil: cdef cppclass cuda_device_id: @@ -601,6 +627,44 @@ cdef class TrackingResourceAdaptor(UpstreamResourceAdaptor): self.c_obj.get()))[0].log_outstanding_allocations() +cdef bool _oom_callback_function(size_t bytes, void *callback_arg) with gil: + return (callback_arg)(bytes) + + +cdef class FailureCallbackResourceAdaptor(UpstreamResourceAdaptor): + + def __cinit__( + self, + DeviceMemoryResource upstream_mr, + object callback, + ): + self._callback = callback + self.c_obj.reset( + new failure_callback_resource_adaptor[device_memory_resource]( + upstream_mr.get_mr(), + _oom_callback_function, + callback + ) + ) + + def __init__( + self, + DeviceMemoryResource upstream_mr, + object callback, + ): + """ + Memory resource that call callback when memory allocation fails. + + Parameters + ---------- + upstream : DeviceMemoryResource + The upstream memory resource. + callback : callable + Function called when memory allocation fails. + """ + pass + + # Global per-device memory resources; dict of int:DeviceMemoryResource cdef _per_device_mrs = defaultdict(CudaMemoryResource) diff --git a/python/rmm/mr.py b/python/rmm/mr.py index 607ab12c3..eaa9705eb 100644 --- a/python/rmm/mr.py +++ b/python/rmm/mr.py @@ -1,9 +1,22 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2021, 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. from rmm._lib.memory_resource import ( BinningMemoryResource, CudaAsyncMemoryResource, CudaMemoryResource, DeviceMemoryResource, + FailureCallbackResourceAdaptor, FixedSizeMemoryResource, LoggingResourceAdaptor, ManagedMemoryResource, @@ -35,6 +48,7 @@ "PoolMemoryResource", "StatisticsResourceAdaptor", "TrackingResourceAdaptor", + "FailureCallbackResourceAdaptor", "_flush_logs", "_initialize", "set_per_device_resource", diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index 4b516cfb3..96b36017b 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -1,4 +1,17 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2021, 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. + import gc import os import sys @@ -659,3 +672,22 @@ def test_tracking_resource_adaptor(): # make sure the allocations string is now empty assert len(mr2.get_outstanding_allocations_str()) == 0 assert len(mr.get_outstanding_allocations_str()) == 0 + + +def test_failure_callback_resource_adaptor(): + retried = [False] + + def callback(nbytes: int) -> bool: + if retried[0]: + return False + else: + retried[0] = True + return True + + cuda_mr = rmm.mr.CudaMemoryResource() + mr = rmm.mr.FailureCallbackResourceAdaptor(cuda_mr, callback) + rmm.mr.set_current_device_resource(mr) + + with pytest.raises(MemoryError): + rmm.DeviceBuffer(size=int(1e11)) + assert retried[0] diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 78c0c94a6..59ff832fe 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2018-2020, NVIDIA CORPORATION. +# Copyright (c) 2018-2021, 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 @@ -82,6 +82,9 @@ ConfigureTest(STATISTICS_TEST mr/device/statistics_mr_tests.cpp) # tracking adaptor tests ConfigureTest(TRACKING_TEST mr/device/tracking_mr_tests.cpp) +# out-of-memory callback adaptor tests +ConfigureTest(FAILURE_CALLBACK_TEST mr/device/failure_callback_mr_tests.cpp) + # aligned adaptor tests ConfigureTest(ALIGNED_TEST mr/device/aligned_mr_tests.cpp) diff --git a/tests/mr/device/failure_callback_mr_tests.cpp b/tests/mr/device/failure_callback_mr_tests.cpp new file mode 100644 index 000000000..ef4553c1c --- /dev/null +++ b/tests/mr/device/failure_callback_mr_tests.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2021, 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. + */ + +#include "../../byte_literals.hpp" + +#include +#include +#include +#include + +#include + +namespace rmm::test { +namespace { + +using failure_callback_adaptor = + rmm::mr::failure_callback_resource_adaptor; + +bool failure_handler(std::size_t bytes, void* arg) +{ + bool& retried = *reinterpret_cast(arg); + if (!retried) { + retried = true; + return true; // First time we request an allocation retry + } else { + return false; // Second time we let the adaptor throw std::bad_alloc + } +} + +TEST(FailureCallbackTest, RetryAllocationOnce) +{ + bool retried{false}; + failure_callback_adaptor mr{rmm::mr::get_current_device_resource(), failure_handler, &retried}; + rmm::mr::set_current_device_resource(&mr); + EXPECT_EQ(retried, false); + EXPECT_THROW(mr.allocate(512_GiB), std::bad_alloc); + EXPECT_EQ(retried, true); +} + +} // namespace +} // namespace rmm::test From c07f1c8a38394bd60dea28a8bbaad439172e6f29 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Thu, 28 Oct 2021 06:10:00 +1100 Subject: [PATCH 007/675] Fix variable names in logging macro calls (#897) Fixes #896 . When variable names were changed to satisfy clang-tidy improvements, these were missed because the macros are compiled out unless higher logging levels are enabled on the compiler command line. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Rong Ou (https://github.com/rongou) - Conor Hoekstra (https://github.com/codereport) URL: https://github.com/rapidsai/rmm/pull/897 --- .../rmm/mr/device/detail/stream_ordered_memory_resource.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index 43da17d0f..6990a2aa6 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -198,7 +198,7 @@ class stream_ordered_memory_resource : public crtp, public device_ */ void* do_allocate(std::size_t size, cuda_stream_view stream) override { - RMM_LOG_TRACE("[A][stream {:p}][{}B]", fmt::ptr(stream.value()), bytes); + RMM_LOG_TRACE("[A][stream {:p}][{}B]", fmt::ptr(stream.value()), size); if (size <= 0) { return nullptr; } @@ -214,7 +214,7 @@ class stream_ordered_memory_resource : public crtp, public device_ RMM_LOG_TRACE("[A][stream {:p}][{}B][{:p}]", fmt::ptr(stream_event.stream), - bytes, + size, fmt::ptr(block.pointer())); log_summary_trace(); @@ -233,7 +233,7 @@ class stream_ordered_memory_resource : public crtp, public device_ */ void do_deallocate(void* ptr, std::size_t size, cuda_stream_view stream) override { - RMM_LOG_TRACE("[D][stream {:p}][{}B][{:p}]", fmt::ptr(stream.value()), bytes, p); + RMM_LOG_TRACE("[D][stream {:p}][{}B][{:p}]", fmt::ptr(stream.value()), size, ptr); if (size <= 0 || ptr == nullptr) { return; } From d8c3fb7e8fb7dde1f274b165be73d77492bea732 Mon Sep 17 00:00:00 2001 From: Ashwin Srinath <3190405+shwina@users.noreply.github.com> Date: Mon, 1 Nov 2021 17:27:37 -0400 Subject: [PATCH 008/675] Replace `to_device()` in docs with `DeviceBuffer.to_device()` (#902) Fixes #668 Authors: - Ashwin Srinath (https://github.com/shwina) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/902 --- python/docs/basics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/docs/basics.md b/python/docs/basics.md index f731c231e..4299e077e 100644 --- a/python/docs/basics.md +++ b/python/docs/basics.md @@ -54,7 +54,7 @@ DeviceBuffers can also be created by copying data from host memory: >>> import rmm >>> import numpy as np >>> a = np.array([1, 2, 3], dtype='float64') ->>> buf = rmm.to_device(a.tobytes()) +>>> buf = rmm.DeviceBuffer.to_device(a.view("int8")) # to_device expects an 8-bit type or `bytes` >>> buf.size 24 ``` From ef1981dbbf73cea7baacf2685d3a201d455aeb68 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 3 Nov 2021 08:40:06 -0400 Subject: [PATCH 009/675] Provide ./build.sh flag to control CUDA async malloc support (#901) This allows rmm to be built with CUDA 11.2 but removes the runtime requirement of CUDA 11.2+, allowing for execution with older CUDA 11.X runtimes. Authors: - Robert Maynard (https://github.com/robertmaynard) - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) - Rong Ou (https://github.com/rongou) - Conor Hoekstra (https://github.com/codereport) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/901 --- benchmarks/CMakeLists.txt | 4 ++++ build.sh | 22 +++++++++++++------ .../mr/device/cuda_async_memory_resource.hpp | 2 ++ python/setup.py | 8 +++++++ tests/CMakeLists.txt | 3 +++ 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 0a9dbe428..fc5579727 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -41,6 +41,10 @@ function(ConfigureBench BENCH_NAME) target_compile_definitions(${BENCH_NAME} PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM) endif() + if(DEFINED CUDA_MALLOC_ASYNC_SUPPORT AND NOT CUDA_MALLOC_ASYNC_SUPPORT) + target_compile_definitions(${TEST_NAME} PUBLIC "RMM_DISABLE_CUDA_MALLOC_ASYNC") + endif() + target_compile_options(${BENCH_NAME} PUBLIC $<$:-Wall -Werror -Wno-error=deprecated-declarations>) if(DISABLE_DEPRECATION_WARNING) diff --git a/build.sh b/build.sh index f197f2016..9d6b98ffc 100755 --- a/build.sh +++ b/build.sh @@ -18,8 +18,8 @@ ARGS=$* # script, and that this script resides in the repo dir! REPODIR=$(cd $(dirname $0); pwd) -VALIDARGS="clean librmm rmm -v -g -n -s --ptds -h" -HELP="$0 [clean] [librmm] [rmm] [-v] [-g] [-n] [-s] [--ptds] [--cmake-args=\"\"] [-h] +VALIDARGS="clean librmm rmm -v -g -n -s --ptds --no-cudamallocasync -h" +HELP="$0 [clean] [librmm] [rmm] [-v] [-g] [-n] [-s] [--ptds] [--no-cudamallocasync] [--cmake-args=\"\"] [-h] clean - remove all existing build artifacts and configuration (start over) librmm - build and install the librmm C++ code rmm - build and install the rmm Python package @@ -28,6 +28,7 @@ HELP="$0 [clean] [librmm] [rmm] [-v] [-g] [-n] [-s] [--ptds] [--cmake-args=\"\\\" - pass arbitrary list of CMake configuration options (escape all quotes in argument) -h - print this text @@ -43,6 +44,7 @@ BUILD_TYPE=Release INSTALL_TARGET=install CUDA_STATIC_RUNTIME=OFF PER_THREAD_DEFAULT_STREAM=OFF +CUDA_MALLOC_ASYNC_SUPPORT=ON RAN_CMAKE=0 # Set defaults for vars that may not have been defined externally @@ -88,6 +90,7 @@ function ensureCMakeRan { -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \ -DCUDA_STATIC_RUNTIME="${CUDA_STATIC_RUNTIME}" \ -DPER_THREAD_DEFAULT_STREAM="${PER_THREAD_DEFAULT_STREAM}" \ + -DCUDA_MALLOC_ASYNC_SUPPORT="${CUDA_MALLOC_ASYNC_SUPPORT}" \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ ${CMAKE_ARGS} RAN_CMAKE=1 @@ -128,6 +131,9 @@ fi if hasArg --ptds; then PER_THREAD_DEFAULT_STREAM=ON fi +if hasArg --no-cudamallocasync; then + CUDA_MALLOC_ASYNC_SUPPORT=OFF +fi # If clean given, run it prior to any other steps if hasArg clean; then @@ -159,14 +165,16 @@ fi if (( NUMARGS == 0 )) || hasArg rmm; then cd "${REPODIR}/python" export INSTALL_PREFIX - if [[ ${INSTALL_TARGET} != "" ]]; then - echo "building rmm..." + echo "building rmm..." + if [[ ${CUDA_MALLOC_ASYNC_SUPPORT} == OFF ]]; then + python setup.py build_ext_no_async --inplace + else python setup.py build_ext --inplace + fi + + if [[ ${INSTALL_TARGET} != "" ]]; then echo "installing rmm..." python setup.py install --single-version-externally-managed --record=record.txt - else - echo "building rmm..." - python setup.py build_ext --inplace fi fi diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 949a4d940..eb4e758c4 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -29,8 +29,10 @@ #include #if CUDART_VERSION >= 11020 // 11.2 introduced cudaMallocAsync +#ifndef RMM_DISABLE_CUDA_MALLOC_ASYNC #define RMM_CUDA_MALLOC_ASYNC_SUPPORT #endif +#endif namespace rmm::mr { diff --git a/python/setup.py b/python/setup.py index dbcfe1062..8edaf4c31 100644 --- a/python/setup.py +++ b/python/setup.py @@ -213,9 +213,17 @@ def finalize_options(self): setuptools.command.build_ext.build_ext.finalize_options(self) +class build_ext_no_async(build_ext_no_debug): + def build_extensions(self): + # Disable async support + self.compiler.compiler_so.append("-DRMM_DISABLE_CUDA_MALLOC_ASYNC") + super().build_extensions() + + cmdclass = dict() cmdclass.update(versioneer.get_cmdclass()) cmdclass["build_ext"] = build_ext_no_debug +cmdclass["build_ext_no_async"] = build_ext_no_async setup( name="rmm", diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 59ff832fe..529d70f10 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -31,6 +31,9 @@ function(ConfigureTestInternal TEST_NAME) CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}") target_compile_definitions(${TEST_NAME} PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") + if(DEFINED CUDA_MALLOC_ASYNC_SUPPORT AND NOT CUDA_MALLOC_ASYNC_SUPPORT) + target_compile_definitions(${TEST_NAME} PUBLIC "RMM_DISABLE_CUDA_MALLOC_ASYNC") + endif() target_compile_options(${TEST_NAME} PUBLIC $<$:-Wall -Werror -Wno-error=deprecated-declarations>) From 2473156ecc0c31f9c8e1f3ac63626359514c66b5 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Thu, 4 Nov 2021 09:10:11 -0400 Subject: [PATCH 010/675] Update `conda` recipes for Enhanced Compatibility effort (#893) This PR updates the `conda` recipe build strings and `cudatoolkit` version specifications as part of the Enhanced Compatibility efforts. ### `rmm` Changes The build strings in the `conda` recipe have been updated to only include the major CUDA version (i.e. `librmm-21.12.00a-cuda11_gc781527_12.tar.bz2`) and the `cudatoolkit` version specifications will now be formatted like `cudatoolkit >=x,=11,<12.0a0`). Moving forward, we'll build the packages with a single CUDA version (i.e. `11.5`) and test them in environments with different CUDA versions (i.e. `11.0`, `11.2`, `11.4`, etc.). ### `librmm` Changes A `conda_build_config.yaml` file has been added to the `librmm` recipe folder so that two variants of `librmm` are built: one with and one without `cudaMallocAsync` support. A new environment variable, `BUILD_FLAGS`, is passed through to `conda/recipes/librmm/build.sh` and is set according to the `cudaMallocAsync` variant value in the recipe. Finally, a build string modifier of either `no_cma` or `has_cma` is appended to the build string which is used to determine which package should be installed in `ci/gpu/build.sh`. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Jordan Jacobelli (https://github.com/Ethyling) URL: https://github.com/rapidsai/rmm/pull/893 --- ci/gpu/build.sh | 17 +++++++++++------ conda/recipes/librmm/build.sh | 2 +- conda/recipes/librmm/conda_build_config.yaml | 3 +++ conda/recipes/librmm/meta.yaml | 12 ++++++++++-- conda/recipes/rmm/meta.yaml | 5 +++-- 5 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 conda/recipes/librmm/conda_build_config.yaml diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 3132222af..8a312ad9f 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -23,7 +23,9 @@ export HOME=$WORKSPACE cd $WORKSPACE # Determine CUDA release version -export CUDA_REL=${CUDA_VERSION%.*} +export CUDA_MAJOR_VER=$(echo "${CUDA_VERSION}" | cut -f 1 -d.) +export CUDA_MINOR_VER=$(echo "${CUDA_VERSION}" | cut -f 2 -d.) +export CUDA_REL="${CUDA_MAJOR_VER}.${CUDA_MINOR_VER}" # Get latest tag and number of commits since tag export GIT_DESCRIBE_TAG=`git describe --abbrev=0 --tags` @@ -46,7 +48,7 @@ gpuci_mamba_retry install -y \ "cudatoolkit=$CUDA_REL" \ "rapids-build-env=${MINOR_VERSION}.*" -# https://docs.rapids.ai/maintainers/depmgmt/ +# https://docs.rapids.ai/maintainers/depmgmt/ # conda remove --force rapids-build-env # gpuci_mamba_retry install "your-pkg=1.0.0" @@ -110,18 +112,21 @@ else done cd $WORKSPACE/python - - CONDA_FILE=`find $WORKSPACE/ci/artifacts/rmm/cpu/conda-bld/ -name "librmm*.tar.bz2"` + + CONDA_FILE=`find $WORKSPACE/ci/artifacts/rmm/cpu/conda-bld/ -name "librmm*no_cma*.tar.bz2"` + if [[ "$CUDA_MAJOR_VER" -ge 11 ]] && [[ "$CUDA_MINOR_VER" -ge 2 ]]; then + CONDA_FILE=`find $WORKSPACE/ci/artifacts/rmm/cpu/conda-bld/ -name "librmm*has_cma*.tar.bz2"` + fi CONDA_FILE=`basename "$CONDA_FILE" .tar.bz2` #get filename without extension CONDA_FILE=${CONDA_FILE//-/=} #convert to conda install gpuci_logger "Installing $CONDA_FILE" gpuci_mamba_retry install -c $WORKSPACE/ci/artifacts/rmm/cpu/conda-bld/ "$CONDA_FILE" export LIBRMM_BUILD_DIR="$WORKSPACE/ci/artifacts/rmm/cpu/conda_work/build" - + gpuci_logger "Building rmm" "$WORKSPACE/build.sh" -v rmm - + gpuci_logger "pytest rmm" py.test --cache-clear --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term exitcode=$? diff --git a/conda/recipes/librmm/build.sh b/conda/recipes/librmm/build.sh index 2c75e4624..eeb757f8c 100644 --- a/conda/recipes/librmm/build.sh +++ b/conda/recipes/librmm/build.sh @@ -1,4 +1,4 @@ # Copyright (c) 2018-2019, NVIDIA CORPORATION. # This assumes the script is executed from the root of the repo directory -./build.sh -v clean librmm --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" +./build.sh -v clean librmm --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" ${BUILD_FLAGS} diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml new file mode 100644 index 000000000..fcbbfef87 --- /dev/null +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -0,0 +1,3 @@ +cudaMallocAsync: + - has_cma + - no_cma diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 68588a973..c4e74bec4 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -2,6 +2,9 @@ {% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} {% set cuda_version='.'.join(environ.get('CUDA', '9.2').split('.')[:2]) %} +{% set cuda_major=cuda_version.split('.')[0] %} +{% set build_flags="" if cudaMallocAsync == "has_cma" else "--no-cudamallocasync" %} + package: name: librmm version: {{ version }} @@ -11,7 +14,7 @@ source: build: number: {{ GIT_DESCRIBE_NUMBER }} - string: cuda{{ cuda_version }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }}_{{ cudaMallocAsync }} script_env: - CC - CXX @@ -25,6 +28,7 @@ build: - CMAKE_C_COMPILER_LAUNCHER - CMAKE_CXX_COMPILER_LAUNCHER - CMAKE_CUDA_COMPILER_LAUNCHER + - BUILD_FLAGS="{{ build_flags }}" run_exports: - {{ pin_subpackage("librmm", max_pin="x.x") }} @@ -34,8 +38,12 @@ requirements: host: - cudatoolkit {{ cuda_version }}.* run: - - {{ pin_compatible('cudatoolkit', max_pin='x.x') }} - spdlog>=1.8.5,<1.9 +{% if cudaMallocAsync == "has_cma" %} + - {{ pin_compatible('cudatoolkit', max_pin='x', lower_bound='11.2') }} # cudatoolkit >=11.2,<12.0.0 +{% else %} + - {{ pin_compatible('cudatoolkit', upper_bound='11.2', lower_bound='11.0') }} # cudatoolkit >=11.0,<11.2 +{% endif %} test: commands: diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 8f3b8cbfc..dbb8789a7 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -3,6 +3,7 @@ {% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} {% set py_version=environ.get('CONDA_PY', 35) %} {% set cuda_version='.'.join(environ.get('CUDA', '10.1').split('.')[:2]) %} +{% set cuda_major=cuda_version.split('.')[0] %} package: name: rmm @@ -13,7 +14,7 @@ source: build: number: {{ GIT_DESCRIBE_NUMBER }} - string: cuda_{{ cuda_version }}_py{{ py_version }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + string: cuda_{{ cuda_major }}_py{{ py_version }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} script_env: - RMM_BUILD_NO_GPU_TEST - VERSION_SUFFIX @@ -33,7 +34,7 @@ requirements: - python - numba >=0.49 - numpy - - {{ pin_compatible('cudatoolkit', max_pin='x.x') }} + - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} test: commands: From c735dd611c73145b7dd6d8fbf83511fd3c20fee8 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Thu, 4 Nov 2021 10:01:29 -0400 Subject: [PATCH 011/675] DOC v22.02 Updates --- CHANGELOG.md | 4 ++++ CMakeLists.txt | 4 ++-- doxygen/Doxyfile | 2 +- python/docs/conf.py | 6 +++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fa07d2a2..464c94e69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# RMM 22.02.00 (Date TBD) + +Please see https://github.com/rapidsai/rmm/releases/tag/v22.02.00a for the latest changes to this development branch. + # RMM 21.12.00 (Date TBD) Please see https://github.com/rapidsai/rmm/releases/tag/v21.12.00a for the latest changes to this development branch. diff --git a/CMakeLists.txt b/CMakeLists.txt index 8326635f4..718ae72a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-21.12/RAPIDS.cmake +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.02/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) @@ -25,7 +25,7 @@ include(rapids-find) project( RMM - VERSION 21.12.00 + VERSION 22.02.00 LANGUAGES CXX) # Write the version header diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index c082eef6a..622bb9175 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "RMM" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 21.12 +PROJECT_NUMBER = 22.02 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/python/docs/conf.py b/python/docs/conf.py index 4af533fd3..c08b50a72 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -19,7 +19,7 @@ author = "NVIDIA" # The full version, including alpha/beta/rc tags -release = "21.12.00" +release = "22.02.00" # -- General configuration --------------------------------------------------- @@ -69,9 +69,9 @@ # built documents. # # The short X.Y version. -version = "21.12" +version = "22.02" # The full version, including alpha/beta/rc tags. -release = "21.12.00" +release = "22.02.00" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. From 11be49c96e88e32e04c27e414184920cbd826aa4 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 4 Nov 2021 12:58:35 -0400 Subject: [PATCH 012/675] Use spdlog/fmt/ostr.h as it supports external fmt library (#907) Fixes #904 Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Jake Hemstad (https://github.com/jrhemstad) - Rong Ou (https://github.com/rongou) URL: https://github.com/rapidsai/rmm/pull/907 --- include/rmm/mr/device/arena_memory_resource.hpp | 2 +- include/rmm/mr/device/detail/arena.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index c9954a507..d0a19da76 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include diff --git a/include/rmm/mr/device/detail/arena.hpp b/include/rmm/mr/device/detail/arena.hpp index 0d2bb319a..44ae8f88e 100644 --- a/include/rmm/mr/device/detail/arena.hpp +++ b/include/rmm/mr/device/detail/arena.hpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include From 76ae62207bd083dfd43b7f755f2934458dd7d8bc Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Fri, 5 Nov 2021 04:26:42 -0400 Subject: [PATCH 013/675] Fix `librmm` uploads (#909) After merging #893, there are now 2 `librmm` `conda` packages being published instead of 1. Therefore the upload script needs to be updated accordingly. Skipping CI since the upload script isn't run on PRs anyway. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Jordan Jacobelli (https://github.com/Ethyling) URL: https://github.com/rapidsai/rmm/pull/909 --- ci/cpu/upload.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ci/cpu/upload.sh b/ci/cpu/upload.sh index fc01b308b..a3a2d4620 100644 --- a/ci/cpu/upload.sh +++ b/ci/cpu/upload.sh @@ -29,8 +29,8 @@ fi gpuci_logger "Get conda file output locations" -export LIBRMM_FILE=`conda build conda/recipes/librmm --output` -export RMM_FILE=`conda build conda/recipes/rmm --python=$PYTHON --output` +export LIBRMM_FILES=$(conda build conda/recipes/librmm --output) +export RMM_FILE=$(conda build conda/recipes/rmm --python=$PYTHON --output) ################################################################################ # UPLOAD - Conda packages @@ -39,10 +39,12 @@ export RMM_FILE=`conda build conda/recipes/rmm --python=$PYTHON --output` gpuci_logger "Starting conda uploads" if [[ "$BUILD_LIBRMM" == "1" && "$UPLOAD_LIBRMM" == "1" ]]; then - test -e ${LIBRMM_FILE} - echo "Upload librmm" - echo ${LIBRMM_FILE} - gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${LIBRMM_FILE} --no-progress + while read -r LIBRMM_FILE; do + test -e ${LIBRMM_FILE} + echo "Upload librmm" + echo ${LIBRMM_FILE} + gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${LIBRMM_FILE} --no-progress + done <<< "${LIBRMM_FILES}" fi if [[ "$BUILD_RMM" == "1" && "$UPLOAD_RMM" == "1" ]]; then From 728a1176bc767cf0c940bf1b8f48154feabea047 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Tue, 9 Nov 2021 16:54:25 +1100 Subject: [PATCH 014/675] Parameterize exception type caught by failure_callback_resource_adaptor (#898) #892 added `failure_callback_resource_adaptor` which provides the ability to respond to memory allocation failures. However, it was hard-coded to catch (and rethrow) `std::bad_alloc` exceptions. This PR makes the type of exception the adaptor catches a template parameter, to provide greater flexibility. The default exception type is now `rmm::out_of_memory` since we expect this to be the common use case. Also a few changes to fix clang-tidy warnings. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Rong Ou (https://github.com/rongou) - Mads R. B. Kristensen (https://github.com/madsbk) - Jake Hemstad (https://github.com/jrhemstad) URL: https://github.com/rapidsai/rmm/pull/898 --- .../failure_callback_resource_adaptor.hpp | 54 +++++++------ tests/mr/device/failure_callback_mr_tests.cpp | 77 +++++++++++++++++-- 2 files changed, 100 insertions(+), 31 deletions(-) diff --git a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp index d3f8e5b7a..b4e497868 100644 --- a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp +++ b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp @@ -20,42 +20,40 @@ #include #include +#include namespace rmm::mr { /** * @brief Callback function type used by failure_callback_resource_adaptor * - * The resource adaptor calls this function when a memory allocation throws a - * `std::bad_alloc` exception. The function decides whether the resource adaptor - * should try to allocate the memory again or re-throw the `std::bad_alloc` - * exception. + * The resource adaptor calls this function when a memory allocation throws a specified exception + * type. The function decides whether the resource adaptor should try to allocate the memory again + * or re-throw the exception. * * The callback function signature is: * `bool failure_callback_t(std::size_t bytes, void* callback_arg)` * - * The callback function will be passed two parameters: `bytes` is the size of the - * failed memory allocation, and `arg` is the extra argument passed to the constructor - * of the `failure_callback_resource_adaptor`. The callback function returns a Boolean - * where true means to retry the memory allocation and false means to throw a - * `rmm::bad_alloc` exception. + * The callback function is passed two parameters: `bytes` is the size of the failed memory + * allocation and `arg` is the extra argument passed to the constructor of the + * `failure_callback_resource_adaptor`. The callback function returns a Boolean where true means to + * retry the memory allocation and false means to re-throw the exception. */ using failure_callback_t = std::function; /** * @brief A device memory resource that calls a callback function when allocations - * throws `std::bad_alloc`. + * throw a specified exception type. * * An instance of this resource must be constructed with an existing, upstream * resource in order to satisfy allocation requests. * * The callback function takes an allocation size and a callback argument and returns - * a bool representing whether to retry the allocation (true) or throw `std::bad_alloc` + * a bool representing whether to retry the allocation (true) or re-throw the caught exception * (false). * - * When implementing a callback function for allocation retry, care must be taken to - * avoid an infinite loop. In the following example, we make sure to only retry the allocation - * once: + * When implementing a callback function for allocation retry, care must be taken to avoid an + * infinite loop. The following example makes sure to only retry the allocation once: * * @code{c++} * using failure_callback_adaptor = @@ -67,9 +65,8 @@ using failure_callback_t = std::function; * if (!retried) { * retried = true; * return true; // First time we request an allocation retry - * } else { - * return false; // Second time we let the adaptor throw std::bad_alloc * } + * return false; // Second time we let the adaptor throw std::bad_alloc * } * * int main() @@ -83,10 +80,13 @@ using failure_callback_t = std::function; * @endcode * * @tparam Upstream The type of the upstream resource used for allocation/deallocation. + * @tparam ExceptionType The type of exception that this adaptor should respond to */ -template +template class failure_callback_resource_adaptor final : public device_memory_resource { public: + using exception_type = ExceptionType; ///< The type of exception this object catches/throws + /** * @brief Construct a new `failure_callback_resource_adaptor` using `upstream` to satisfy * allocation requests. @@ -100,7 +100,7 @@ class failure_callback_resource_adaptor final : public device_memory_resource { failure_callback_resource_adaptor(Upstream* upstream, failure_callback_t callback, void* callback_arg) - : upstream_{upstream}, callback_{callback}, callback_arg_{callback_arg} + : upstream_{upstream}, callback_{std::move(callback)}, callback_arg_{callback_arg} { RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); } @@ -126,14 +126,17 @@ class failure_callback_resource_adaptor final : public device_memory_resource { * @return true The upstream resource supports streams * @return false The upstream resource does not support streams. */ - bool supports_streams() const noexcept override { return upstream_->supports_streams(); } + [[nodiscard]] bool supports_streams() const noexcept override + { + return upstream_->supports_streams(); + } /** * @brief Query whether the resource supports the get_mem_info API. * * @return bool true if the upstream resource supports get_mem_info, false otherwise. */ - bool supports_get_mem_info() const noexcept override + [[nodiscard]] bool supports_get_mem_info() const noexcept override { return upstream_->supports_get_mem_info(); } @@ -143,7 +146,7 @@ class failure_callback_resource_adaptor final : public device_memory_resource { * @brief Allocates memory of size at least `bytes` using the upstream * resource. * - * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled + * @throws `exception_type` if the requested allocation could not be fulfilled * by the upstream resource. * * @param bytes The size, in bytes, of the allocation @@ -152,13 +155,13 @@ class failure_callback_resource_adaptor final : public device_memory_resource { */ void* do_allocate(std::size_t bytes, cuda_stream_view stream) override { - void* ret; + void* ret{}; while (true) { try { ret = upstream_->allocate(bytes, stream); break; - } catch (std::bad_alloc const& e) { + } catch (exception_type const& e) { if (!callback_(bytes, callback_arg_)) { throw; } } } @@ -188,7 +191,7 @@ class failure_callback_resource_adaptor final : public device_memory_resource { * @return true If the two resources are equivalent * @return false If the two resources are not equal */ - bool do_is_equal(device_memory_resource const& other) const noexcept override + [[nodiscard]] bool do_is_equal(device_memory_resource const& other) const noexcept override { if (this == &other) { return true; } auto cast = dynamic_cast const*>(&other); @@ -204,7 +207,8 @@ class failure_callback_resource_adaptor final : public device_memory_resource { * @param stream Stream on which to get the mem info. * @return std::pair contaiing free_size and total_size of memory */ - std::pair do_get_mem_info(cuda_stream_view stream) const override + [[nodiscard]] std::pair do_get_mem_info( + cuda_stream_view stream) const override { return upstream_->get_mem_info(stream); } diff --git a/tests/mr/device/failure_callback_mr_tests.cpp b/tests/mr/device/failure_callback_mr_tests.cpp index ef4553c1c..bb5484c69 100644 --- a/tests/mr/device/failure_callback_mr_tests.cpp +++ b/tests/mr/device/failure_callback_mr_tests.cpp @@ -15,6 +15,8 @@ */ #include "../../byte_literals.hpp" +#include "rmm/cuda_stream_view.hpp" +#include "rmm/mr/device/device_memory_resource.hpp" #include #include @@ -26,29 +28,92 @@ namespace rmm::test { namespace { +template using failure_callback_adaptor = - rmm::mr::failure_callback_resource_adaptor; + rmm::mr::failure_callback_resource_adaptor; -bool failure_handler(std::size_t bytes, void* arg) +bool failure_handler(std::size_t /*bytes*/, void* arg) { + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) bool& retried = *reinterpret_cast(arg); if (!retried) { retried = true; return true; // First time we request an allocation retry - } else { - return false; // Second time we let the adaptor throw std::bad_alloc } + return false; // Second time we let the adaptor throw std::bad_alloc } TEST(FailureCallbackTest, RetryAllocationOnce) { bool retried{false}; - failure_callback_adaptor mr{rmm::mr::get_current_device_resource(), failure_handler, &retried}; - rmm::mr::set_current_device_resource(&mr); + failure_callback_adaptor<> mr{rmm::mr::get_current_device_resource(), failure_handler, &retried}; EXPECT_EQ(retried, false); EXPECT_THROW(mr.allocate(512_GiB), std::bad_alloc); EXPECT_EQ(retried, true); } +template +class always_throw_memory_resource final : public mr::device_memory_resource { + private: + void* do_allocate(std::size_t bytes, cuda_stream_view stream) override + { + throw ExceptionType{"foo"}; + } + void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override{}; + [[nodiscard]] std::pair do_get_mem_info( + cuda_stream_view stream) const override + { + return {0, 0}; + } + + [[nodiscard]] bool supports_streams() const noexcept override { return false; } + [[nodiscard]] bool supports_get_mem_info() const noexcept override { return false; } +}; + +TEST(FailureCallbackTest, DifferentExceptionTypes) +{ + always_throw_memory_resource bad_alloc_mr; + always_throw_memory_resource oom_mr; + + EXPECT_THROW(bad_alloc_mr.allocate(1_MiB), rmm::bad_alloc); + EXPECT_THROW(oom_mr.allocate(1_MiB), rmm::out_of_memory); + + // Wrap a bad_alloc-catching callback adaptor around an MR that always throws bad_alloc: + // Should retry once and then re-throw bad_alloc + { + bool retried{false}; + failure_callback_adaptor bad_alloc_callback_mr{ + &bad_alloc_mr, failure_handler, &retried}; + + EXPECT_EQ(retried, false); + EXPECT_THROW(bad_alloc_callback_mr.allocate(1_MiB), rmm::bad_alloc); + EXPECT_EQ(retried, true); + } + + // Wrap a out_of_memory-catching callback adaptor around an MR that always throws out_of_memory: + // Should retry once and then re-throw out_of_memory + { + bool retried{false}; + + failure_callback_adaptor oom_callback_mr{ + &oom_mr, failure_handler, &retried}; + EXPECT_EQ(retried, false); + EXPECT_THROW(oom_callback_mr.allocate(1_MiB), rmm::out_of_memory); + EXPECT_EQ(retried, true); + } + + // Wrap a out_of_memory-catching callback adaptor around an MR that always throws bad_alloc: + // Should not catch the bad_alloc exception + { + bool retried{false}; + + failure_callback_adaptor oom_callback_mr{ + &bad_alloc_mr, failure_handler, &retried}; + EXPECT_EQ(retried, false); + EXPECT_THROW(oom_callback_mr.allocate(1_MiB), rmm::bad_alloc); // bad_alloc passes through + EXPECT_EQ(retried, false); // Does not catch / retry on anything except OOM + } +} + } // namespace } // namespace rmm::test From 59d6f3483eca9027cca3e18d9765b0c36306ecb0 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 10 Nov 2021 00:46:10 +1100 Subject: [PATCH 015/675] C++ code coverage support (#905) Adds a cmake option (`CODE_COVERAGE`) to compile a build with relevant options to GCC and NVCC to generate code coverage profiling. This can then be used with coverage tools like `gcovr` or coveralls to generate a detailed coverage summary (e.g. in HTML, JSON, XML, etc.). Also adds a gcovr.cfg with basic options and a conda dependency on gcovr. ~Finally, it adds some explicit template instantiations in test files to ensure all template class methods are included in coverage analysis (so coverage % isn't artificially high).~ (reserved for future PR) Instructions for generating code coverage ``` mkdir -p /build/debug && cd build/debug cmake .. -DCMAKE_BUILD_TYPE=Debug -DCODE_COVERAGE=ON make ctest ## or ninja cd covr -r . -j 12 -o build/debug/coverage/ build/debug/tests/CMakeFiles/ ``` Note that parallel building should not be used, because `--keep` is used with .cu files. With rapids-compose, just set build type to Debug in .env, then ``` build-rmm-cpp -DCODE_COVERAGE=ON test-rmm-cpp covr -r . -j 12 -o build/debug/coverage/ build/debug/tests/CMakeFiles/ ``` Then open `build/debug/coverage/coverage_details.html`. It looks like this: ![image](https://user-images.githubusercontent.com/783069/140244835-28ae15e5-0520-435c-b3ee-e9f14847c3f8.png) Summary of changes required to get good coverage analysis: * Compile with `--coverage,-fprofile-abs-path,-fkeep-inline-functions,-fno-elide-constructors` and link with `--coverage`. * Compile CUDA code `--keep` (otherwise gcov gets errors finding NVCC's deleted intermediate-stage files) * ~Explicitly instantiate template classes at least once in test source files. This ensures any unused methods in these classes get shown as not covered by tests.~ Reserved for a future PR to improve code coverage. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Rong Ou (https://github.com/rongou) - Robert Maynard (https://github.com/robertmaynard) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/905 --- conda/environments/rmm_dev_cuda10.1.yml | 1 + conda/environments/rmm_dev_cuda10.2.yml | 1 + conda/environments/rmm_dev_cuda11.0.yml | 1 + gcovr.cfg | 4 +++ tests/CMakeLists.txt | 34 ++++++++++++++++++++++++- 5 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 gcovr.cfg diff --git a/conda/environments/rmm_dev_cuda10.1.yml b/conda/environments/rmm_dev_cuda10.1.yml index 4b7895949..f5186ea9e 100644 --- a/conda/environments/rmm_dev_cuda10.1.yml +++ b/conda/environments/rmm_dev_cuda10.1.yml @@ -18,3 +18,4 @@ dependencies: - cudatoolkit=10.1 - spdlog>=1.8.5,<1.9 - cython>=0.29,<0.30 +- gcovr>=5.0 diff --git a/conda/environments/rmm_dev_cuda10.2.yml b/conda/environments/rmm_dev_cuda10.2.yml index f291088b5..a96a88889 100644 --- a/conda/environments/rmm_dev_cuda10.2.yml +++ b/conda/environments/rmm_dev_cuda10.2.yml @@ -18,3 +18,4 @@ dependencies: - cudatoolkit=10.2 - spdlog>=1.8.5,<1.9 - cython>=0.29,<0.30 +- gcovr>=5.0 diff --git a/conda/environments/rmm_dev_cuda11.0.yml b/conda/environments/rmm_dev_cuda11.0.yml index b6d0f8900..605f9d7f1 100644 --- a/conda/environments/rmm_dev_cuda11.0.yml +++ b/conda/environments/rmm_dev_cuda11.0.yml @@ -18,3 +18,4 @@ dependencies: - cudatoolkit=11.0 - spdlog>=1.8.5,<1.9 - cython>=0.29,<0.30 +- gcovr>=5.0 diff --git a/gcovr.cfg b/gcovr.cfg new file mode 100644 index 000000000..227d8b194 --- /dev/null +++ b/gcovr.cfg @@ -0,0 +1,4 @@ +exclude=build/.* +exclude=tests/.* +html=yes +html-details=yes diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 529d70f10..6da87eb70 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -14,8 +14,13 @@ # Build options option(DISABLE_DEPRECATION_WARNING "Disable warnings generated from deprecated declarations." OFF) +option(CODE_COVERAGE "Enable generating code coverage with gcov." OFF) -# compiler function +if(CODE_COVERAGE) + if(NOT (CMAKE_BUILD_TYPE STREQUAL "Debug")) + message(WARNING "Generating code coverage for optimised (non-Debug) builds not recommended") + endif() +endif() # This function takes in a test name and test source and handles setting all of the associated # properties and linking to build the test @@ -44,6 +49,33 @@ function(ConfigureTestInternal TEST_NAME) PUBLIC $<$:-Wno-deprecated-declarations>) endif() + if(CODE_COVERAGE) + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + + set(KEEP_DIR ${CMAKE_CURRENT_BINARY_DIR}/tmp) + make_directory(${KEEP_DIR}) + target_compile_options(${TEST_NAME} PUBLIC $<$:--keep + --keep-dir=${KEEP_DIR}>) + target_compile_options( + ${TEST_NAME} + PUBLIC + $<$:-Xcompiler=--coverage,-fprofile-abs-path,-fkeep-inline-functions,-fno-elide-constructors> + ) + target_compile_options( + ${TEST_NAME} PUBLIC $<$:--coverage -fprofile-abs-path + -fkeep-inline-functions -fno-elide-constructors>) + target_link_options(${TEST_NAME} PRIVATE --coverage) + target_link_libraries(${TEST_NAME} gcov) + endif() + + # Add coverage-generated files to clean target + list(APPEND COVERAGE_CLEAN_FILES "**/*.gcno" "**/*.gcda") + set_property( + TARGET ${TEST_NAME} + APPEND + PROPERTY ADDITIONAL_CLEAN_FILES ${COVERAGE_CLEAN_FILES}) + endif() + add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME}) endfunction() From 880211456df15ac0fe1372fc6d6f2400bde50ce3 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Tue, 9 Nov 2021 12:23:50 -0500 Subject: [PATCH 016/675] Update recipes for Enhanced Compatibility (#910) This PR tweaks the changes from #893 and #909 so that `rmm` produces two packages (`has_cma` and `no_cma`) instead of `librmm`. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Jordan Jacobelli (https://github.com/Ethyling) URL: https://github.com/rapidsai/rmm/pull/910 --- ci/cpu/upload.sh | 24 +++++++++---------- ci/gpu/build.sh | 5 +--- conda/recipes/librmm/build.sh | 2 +- conda/recipes/librmm/meta.yaml | 10 ++------ conda/recipes/rmm/build.sh | 7 +++++- .../{librmm => rmm}/conda_build_config.yaml | 0 conda/recipes/rmm/meta.yaml | 8 +++++-- 7 files changed, 28 insertions(+), 28 deletions(-) rename conda/recipes/{librmm => rmm}/conda_build_config.yaml (100%) diff --git a/ci/cpu/upload.sh b/ci/cpu/upload.sh index a3a2d4620..49d716c17 100644 --- a/ci/cpu/upload.sh +++ b/ci/cpu/upload.sh @@ -29,8 +29,8 @@ fi gpuci_logger "Get conda file output locations" -export LIBRMM_FILES=$(conda build conda/recipes/librmm --output) -export RMM_FILE=$(conda build conda/recipes/rmm --python=$PYTHON --output) +export LIBRMM_FILE=$(conda build conda/recipes/librmm --output) +export RMM_FILES=$(conda build conda/recipes/rmm --python=$PYTHON --output) ################################################################################ # UPLOAD - Conda packages @@ -39,18 +39,18 @@ export RMM_FILE=$(conda build conda/recipes/rmm --python=$PYTHON --output) gpuci_logger "Starting conda uploads" if [[ "$BUILD_LIBRMM" == "1" && "$UPLOAD_LIBRMM" == "1" ]]; then - while read -r LIBRMM_FILE; do - test -e ${LIBRMM_FILE} - echo "Upload librmm" - echo ${LIBRMM_FILE} - gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${LIBRMM_FILE} --no-progress - done <<< "${LIBRMM_FILES}" + test -e ${LIBRMM_FILE} + echo "Upload librmm" + echo ${LIBRMM_FILE} + gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${LIBRMM_FILE} --no-progress fi if [[ "$BUILD_RMM" == "1" && "$UPLOAD_RMM" == "1" ]]; then - test -e ${RMM_FILE} - echo "Upload rmm" - echo ${RMM_FILE} - gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${RMM_FILE} --no-progress + while read -r RMM_FILE; do + test -e ${RMM_FILE} + echo "Upload rmm" + echo ${RMM_FILE} + gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${RMM_FILE} --no-progress + done <<< "${RMM_FILES}" fi diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 8a312ad9f..e7239042e 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -113,10 +113,7 @@ else cd $WORKSPACE/python - CONDA_FILE=`find $WORKSPACE/ci/artifacts/rmm/cpu/conda-bld/ -name "librmm*no_cma*.tar.bz2"` - if [[ "$CUDA_MAJOR_VER" -ge 11 ]] && [[ "$CUDA_MINOR_VER" -ge 2 ]]; then - CONDA_FILE=`find $WORKSPACE/ci/artifacts/rmm/cpu/conda-bld/ -name "librmm*has_cma*.tar.bz2"` - fi + CONDA_FILE=`find $WORKSPACE/ci/artifacts/rmm/cpu/conda-bld/ -name "librmm*.tar.bz2"` CONDA_FILE=`basename "$CONDA_FILE" .tar.bz2` #get filename without extension CONDA_FILE=${CONDA_FILE//-/=} #convert to conda install gpuci_logger "Installing $CONDA_FILE" diff --git a/conda/recipes/librmm/build.sh b/conda/recipes/librmm/build.sh index eeb757f8c..2c75e4624 100644 --- a/conda/recipes/librmm/build.sh +++ b/conda/recipes/librmm/build.sh @@ -1,4 +1,4 @@ # Copyright (c) 2018-2019, NVIDIA CORPORATION. # This assumes the script is executed from the root of the repo directory -./build.sh -v clean librmm --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" ${BUILD_FLAGS} +./build.sh -v clean librmm --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index c4e74bec4..e54a7edd7 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -3,7 +3,6 @@ {% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} {% set cuda_version='.'.join(environ.get('CUDA', '9.2').split('.')[:2]) %} {% set cuda_major=cuda_version.split('.')[0] %} -{% set build_flags="" if cudaMallocAsync == "has_cma" else "--no-cudamallocasync" %} package: name: librmm @@ -14,7 +13,7 @@ source: build: number: {{ GIT_DESCRIBE_NUMBER }} - string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }}_{{ cudaMallocAsync }} + string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} script_env: - CC - CXX @@ -28,7 +27,6 @@ build: - CMAKE_C_COMPILER_LAUNCHER - CMAKE_CXX_COMPILER_LAUNCHER - CMAKE_CUDA_COMPILER_LAUNCHER - - BUILD_FLAGS="{{ build_flags }}" run_exports: - {{ pin_subpackage("librmm", max_pin="x.x") }} @@ -39,11 +37,7 @@ requirements: - cudatoolkit {{ cuda_version }}.* run: - spdlog>=1.8.5,<1.9 -{% if cudaMallocAsync == "has_cma" %} - - {{ pin_compatible('cudatoolkit', max_pin='x', lower_bound='11.2') }} # cudatoolkit >=11.2,<12.0.0 -{% else %} - - {{ pin_compatible('cudatoolkit', upper_bound='11.2', lower_bound='11.0') }} # cudatoolkit >=11.0,<11.2 -{% endif %} + - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} test: commands: diff --git a/conda/recipes/rmm/build.sh b/conda/recipes/rmm/build.sh index d2c672e69..08990c36e 100644 --- a/conda/recipes/rmm/build.sh +++ b/conda/recipes/rmm/build.sh @@ -1,4 +1,9 @@ # Copyright (c) 2018-2019, NVIDIA CORPORATION. # Script assumes the script is executed from the root of the repo directory -./build.sh -v clean rmm +BUILD_FLAGS="" +if [ "${cudaMallocAsync}" == "no_cma" ]; then + BUILD_FLAGS="${BUILD_FLAGS} --no-cudamallocasync" +fi + +./build.sh -v clean rmm ${BUILD_FLAGS} diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/rmm/conda_build_config.yaml similarity index 100% rename from conda/recipes/librmm/conda_build_config.yaml rename to conda/recipes/rmm/conda_build_config.yaml diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index dbb8789a7..fd32170df 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -14,7 +14,7 @@ source: build: number: {{ GIT_DESCRIBE_NUMBER }} - string: cuda_{{ cuda_major }}_py{{ py_version }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + string: cuda{{ cuda_major }}_py{{ py_version }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }}_{{ cudaMallocAsync }} script_env: - RMM_BUILD_NO_GPU_TEST - VERSION_SUFFIX @@ -34,7 +34,11 @@ requirements: - python - numba >=0.49 - numpy - - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} +{% if cudaMallocAsync == "has_cma" %} + - {{ pin_compatible('cudatoolkit', max_pin='x', lower_bound='11.2') }} # cudatoolkit >=11.2,<12.0.0 +{% else %} + - {{ pin_compatible('cudatoolkit', upper_bound='11.2', lower_bound='11.0') }} # cudatoolkit >=11.0,<11.2 +{% endif %} test: commands: From 72d9e69778d7fa1e203b72dabbef20834bf4cb24 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Tue, 9 Nov 2021 13:44:04 -0500 Subject: [PATCH 017/675] Backport #886 to `branch-21.10` (#911) This PR backports #886 to `branch-21.10` in order to install `spdlog` when `rmm` is installed. --- cmake/thirdparty/get_spdlog.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmake/thirdparty/get_spdlog.cmake b/cmake/thirdparty/get_spdlog.cmake index b10763d5f..e816bff35 100644 --- a/cmake/thirdparty/get_spdlog.cmake +++ b/cmake/thirdparty/get_spdlog.cmake @@ -16,13 +16,12 @@ function(find_and_configure_spdlog) include(${rapids-cmake-dir}/cpm/spdlog.cmake) - rapids_cpm_spdlog() + rapids_cpm_spdlog(INSTALL_EXPORT_SET rmm-exports) if(spdlog_ADDED) install(TARGETS spdlog_header_only EXPORT rmm-exports) else() rapids_export_package(BUILD spdlog rmm-exports) - rapids_export_package(INSTALL spdlog rmm-exports) endif() endfunction() From c504f23d5a694872d2c818f37b55a49cf1845e9a Mon Sep 17 00:00:00 2001 From: fkallen <37172449+fkallen@users.noreply.github.com> Date: Wed, 10 Nov 2021 22:30:08 +0100 Subject: [PATCH 018/675] Add functions to query the stream of device_uvector and device_scalar (#887) closes #885 Authors: - https://github.com/fkallen Approvers: - Rong Ou (https://github.com/rongou) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/887 --- include/rmm/device_buffer.hpp | 11 +++++------ include/rmm/device_scalar.hpp | 12 +++++++++++- include/rmm/device_uvector.hpp | 22 +++++++++++++++++++--- tests/device_buffer_tests.cu | 12 ++++++++++++ tests/device_scalar_tests.cpp | 12 ++++++++++++ tests/device_uvector_tests.cpp | 13 +++++++++++++ 6 files changed, 72 insertions(+), 10 deletions(-) diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index ee8e4e927..48e1fc6b3 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -344,12 +344,11 @@ class device_buffer { /** * @brief Sets the stream to be used for deallocation * - * If no other rmm::device_buffer method that allocates or copies memory is - * called after this call with a different stream argument, then @p stream - * will be used for deallocation in the `rmm::device_buffer destructor. - * Otherwise, if another rmm::device_buffer method with a stream parameter is - * called after this, the later stream parameter will be stored and used in - * the destructor. + * If no other rmm::device_buffer method that allocates memory is called + * after this call with a different stream argument, then @p stream + * will be used for deallocation in the `rmm::device_uvector destructor. + * However, if either of `resize()` or `shrink_to_fit()` is called after this, + * the later stream parameter will be stored and used in the destructor. */ void set_stream(cuda_stream_view stream) noexcept { _stream = stream; } diff --git a/include/rmm/device_scalar.hpp b/include/rmm/device_scalar.hpp index 099abc08e..e476b2d87 100644 --- a/include/rmm/device_scalar.hpp +++ b/include/rmm/device_scalar.hpp @@ -186,7 +186,7 @@ class device_scalar { * * @throws `rmm::cuda_error` if copying `host_value` to device memory fails. * - * @param v The host value which will be copied to device + * @param value The host value which will be copied to device * @param stream CUDA stream on which to perform the copy */ void set_value_async(value_type const& value, cuda_stream_view stream) @@ -240,6 +240,16 @@ class device_scalar { return static_cast(_storage.data()); } + /** + * @brief Returns stream most recently specified for allocation/deallocation + */ + [[nodiscard]] cuda_stream_view stream() const noexcept { return _storage.stream(); } + + /** + * @brief Sets the stream to be used for deallocation + */ + void set_stream(cuda_stream_view stream) noexcept { _storage.set_stream(stream); } + private: rmm::device_uvector _storage; }; diff --git a/include/rmm/device_uvector.hpp b/include/rmm/device_uvector.hpp index 5457b664c..ff1220ec3 100644 --- a/include/rmm/device_uvector.hpp +++ b/include/rmm/device_uvector.hpp @@ -200,8 +200,8 @@ class device_uvector { * @throws rmm::out_of_range exception if `element_index >= size()` * * @param element_index Index of the target element - * @param v The value to copy to the specified element - * @param s The stream on which to perform the copy + * @param value The value to copy to the specified element + * @param stream The stream on which to perform the copy */ void set_element_async(std::size_t element_index, value_type const& value, @@ -251,7 +251,7 @@ class device_uvector { * @throws rmm::out_of_range exception if `element_index >= size()` * * @param element_index Index of the target element - * @param s The stream on which to perform the copy + * @param stream The stream on which to perform the copy */ void set_element_to_zero_async(std::size_t element_index, cuda_stream_view stream) { @@ -504,6 +504,22 @@ class device_uvector { return _storage.memory_resource(); } + /** + * @brief Returns stream most recently specified for allocation/deallocation + */ + [[nodiscard]] cuda_stream_view stream() const noexcept { return _storage.stream(); } + + /** + * @brief Sets the stream to be used for deallocation + * + * If no other rmm::device_uvector method that allocates memory is called + * after this call with a different stream argument, then @p stream + * will be used for deallocation in the `rmm::device_uvector destructor. + * However, if either of `resize()` or `shrink_to_fit()` is called after this, + * the later stream parameter will be stored and used in the destructor. + */ + void set_stream(cuda_stream_view stream) noexcept { _storage.set_stream(stream); } + private: device_buffer _storage{}; ///< Device memory storage for vector elements diff --git a/tests/device_buffer_tests.cu b/tests/device_buffer_tests.cu index 2f8d34bad..2d69eec8f 100644 --- a/tests/device_buffer_tests.cu +++ b/tests/device_buffer_tests.cu @@ -450,3 +450,15 @@ TYPED_TEST(DeviceBufferTest, ResizeBigger) // Resizing bigger means the data should point to a new allocation EXPECT_NE(old_data, buff.data()); } + +TYPED_TEST(DeviceBufferTest, SetGetStream) +{ + rmm::device_buffer buff(this->size, rmm::cuda_stream_default, &this->mr); + + EXPECT_EQ(buff.stream(), rmm::cuda_stream_default); + + rmm::cuda_stream_view const otherstream{cudaStreamPerThread}; + buff.set_stream(otherstream); + + EXPECT_EQ(buff.stream(), otherstream); +} diff --git a/tests/device_scalar_tests.cpp b/tests/device_scalar_tests.cpp index 63c471094..8b71af648 100644 --- a/tests/device_scalar_tests.cpp +++ b/tests/device_scalar_tests.cpp @@ -123,3 +123,15 @@ TYPED_TEST(DeviceScalarTest, SetValueToZero) scalar.set_value_to_zero_async(this->stream); EXPECT_EQ(TypeParam{0}, scalar.value(this->stream)); } + +TYPED_TEST(DeviceScalarTest, SetGetStream) +{ + rmm::device_scalar scalar(this->value, this->stream, this->mr); + + EXPECT_EQ(scalar.stream(), this->stream); + + rmm::cuda_stream_view const otherstream{cudaStreamPerThread}; + scalar.set_stream(otherstream); + + EXPECT_EQ(scalar.stream(), otherstream); +} diff --git a/tests/device_uvector_tests.cpp b/tests/device_uvector_tests.cpp index dce2cbbf6..f724b3906 100644 --- a/tests/device_uvector_tests.cpp +++ b/tests/device_uvector_tests.cpp @@ -207,3 +207,16 @@ TYPED_TEST(TypedUVectorTest, FrontBackElement) EXPECT_EQ(first, vec.front_element(this->stream())); EXPECT_EQ(last, vec.back_element(this->stream())); } + +TYPED_TEST(TypedUVectorTest, SetGetStream) +{ + auto const size{12345}; + rmm::device_uvector vec(size, this->stream()); + + EXPECT_EQ(vec.stream(), this->stream()); + + rmm::cuda_stream_view const otherstream{cudaStreamPerThread}; + vec.set_stream(otherstream); + + EXPECT_EQ(vec.stream(), otherstream); +} From bbfb0119a2e70ece729628810976f0e03e9935d9 Mon Sep 17 00:00:00 2001 From: Rong Ou Date: Wed, 10 Nov 2021 15:20:16 -0800 Subject: [PATCH 019/675] suppress spurious clang-tidy warnings in debug macros (#914) Getting these clang-tidy warnings in debug build: ```console /home/rou/src/rmm/include/rmm/cuda_stream.hpp:86:5: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay] RMM_LOGGING_ASSERT(is_valid()); ^ /home/rou/src/rmm/include/rmm/detail/error.hpp:260:7: note: expanded from macro 'RMM_LOGGING_ASSERT' assert(success); \ ^ /usr/include/assert.h:95:51: note: expanded from macro 'assert' : __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION)) ^ /usr/include/assert.h:129:30: note: expanded from macro '__ASSERT_FUNCTION' # define __ASSERT_FUNCTION __extension__ __PRETTY_FUNCTION__ ^ ``` Looks to be a pending issue with clang-tidy: https://reviews.llvm.org/D88833 Authors: - Rong Ou (https://github.com/rongou) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/914 --- include/rmm/detail/error.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/rmm/detail/error.hpp b/include/rmm/detail/error.hpp index 89cbcd916..1e3605861 100644 --- a/include/rmm/detail/error.hpp +++ b/include/rmm/detail/error.hpp @@ -240,6 +240,7 @@ class out_of_range : public std::out_of_range { std::cerr << "CUDA Error detected. " << cudaGetErrorName(status__) << " " \ << cudaGetErrorString(status__) << std::endl; \ } \ + /* NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay) */ \ assert(status__ == cudaSuccess); \ } while (0) #endif @@ -257,6 +258,7 @@ class out_of_range : public std::out_of_range { RMM_LOG_CRITICAL( \ "[" __FILE__ ":" RMM_STRINGIFY(__LINE__) "] Assertion " RMM_STRINGIFY(_expr) " failed."); \ rmm::logger().flush(); \ + /* NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay) */ \ assert(success); \ } \ } while (0) From 597d37144db09245d9d870748b2dbd43144c1605 Mon Sep 17 00:00:00 2001 From: GALI PREM SAGAR Date: Thu, 18 Nov 2021 11:42:38 -0600 Subject: [PATCH 020/675] upgrade clang to 11.1.0 (#921) --- conda/environments/rmm_dev_cuda10.1.yml | 4 ++-- conda/environments/rmm_dev_cuda10.2.yml | 4 ++-- conda/environments/rmm_dev_cuda11.0.yml | 4 ++-- scripts/run-clang-format.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/conda/environments/rmm_dev_cuda10.1.yml b/conda/environments/rmm_dev_cuda10.1.yml index f5186ea9e..caccd9541 100644 --- a/conda/environments/rmm_dev_cuda10.1.yml +++ b/conda/environments/rmm_dev_cuda10.1.yml @@ -3,8 +3,8 @@ channels: - rapidsai - conda-forge dependencies: -- clang=11.0.0 -- clang-tools=11.0.0 +- clang=11.1.0 +- clang-tools=11.1.0 - cmake>=3.20.1 - cmake-format=0.6.11 - flake8=3.8.3 diff --git a/conda/environments/rmm_dev_cuda10.2.yml b/conda/environments/rmm_dev_cuda10.2.yml index a96a88889..348418014 100644 --- a/conda/environments/rmm_dev_cuda10.2.yml +++ b/conda/environments/rmm_dev_cuda10.2.yml @@ -3,8 +3,8 @@ channels: - rapidsai - conda-forge dependencies: -- clang=11.0.0 -- clang-tools=11.0.0 +- clang=11.1.0 +- clang-tools=11.1.0 - cmake>=3.20.1 - cmake-format=0.6.11 - flake8=3.8.3 diff --git a/conda/environments/rmm_dev_cuda11.0.yml b/conda/environments/rmm_dev_cuda11.0.yml index 605f9d7f1..8fbe42e4b 100644 --- a/conda/environments/rmm_dev_cuda11.0.yml +++ b/conda/environments/rmm_dev_cuda11.0.yml @@ -3,8 +3,8 @@ channels: - rapidsai - conda-forge dependencies: -- clang=11.0.0 -- clang-tools=11.0.0 +- clang=11.1.0 +- clang-tools=11.1.0 - cmake>=3.20.1 - cmake-format=0.6.11 - flake8=3.8.3 diff --git a/scripts/run-clang-format.py b/scripts/run-clang-format.py index 5014e0bca..6c4370742 100755 --- a/scripts/run-clang-format.py +++ b/scripts/run-clang-format.py @@ -22,7 +22,7 @@ import sys import tempfile -EXPECTED_VERSION = "11.0.0" +EXPECTED_VERSION = "11.1.0" VERSION_REGEX = re.compile(r"clang-format version ([0-9.]+)") # NOTE: populate this list with more top-level dirs as we add more of them # to the rmm repo From 27715b19470441c2f1b0de268b6ae8b5354d35d1 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 18 Nov 2021 12:47:16 -0800 Subject: [PATCH 021/675] Simplify CMake linting with cmake-format (#913) This PR adds a script to find the cmake-format-rapids-cmake.json file in a standard location and run the cmake-format or cmake-lint programs with that config file. The script fails gracefully when the file cannot be found and is therefore suitable for use as a pre-commit hook in scenarios where no build directory (containing the config file) exists yet. A corresponding pre-commit configuration is added here as well, replacing the old cmake-format hook which did not use the rapids-cmake config file. Resolves #903. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Mark Harris (https://github.com/harrism) - Robert Maynard (https://github.com/robertmaynard) - Rong Ou (https://github.com/rongou) URL: https://github.com/rapidsai/rmm/pull/913 --- .pre-commit-config.yaml | 30 ++++++++++------ scripts/run-cmake-format.sh | 72 +++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 11 deletions(-) create mode 100755 scripts/run-cmake-format.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2323a247a..a50c645ba 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,18 +25,26 @@ repos: name: flake8-cython args: ["--config=python/.flake8.cython"] types: [cython] - - repo: https://github.com/cheshirekow/cmake-format-precommit - rev: v0.6.11 + - repo: local hooks: - - id: cmake-format - name: cmake-format - args: ["--config-files", "cmake/config.json", "--in-place", "--"] - types: [file] # override `types: [cmake]` - files: \.(cmake(\.in)?)$|CMakeLists\.txt - - id: cmake-lint - args: ["--config-files", "cmake/config.json", "--"] - types: [file] # override `types: [cmake]` - files: \.(cmake(\.in)?)$|CMakeLists\.txt + - id: cmake-format + name: cmake-format + entry: ./scripts/run-cmake-format.sh cmake-format + language: python + types: [cmake] + # Note that pre-commit autoupdate does not update the versions + # of dependencies, so we'll have to update this manually. + additional_dependencies: + - cmake-format==0.6.11 + - id: cmake-lint + name: cmake-lint + entry: ./scripts/run-cmake-format.sh cmake-lint + language: python + types: [cmake] + # Note that pre-commit autoupdate does not update the versions + # of dependencies, so we'll have to update this manually. + additional_dependencies: + - cmake-format==0.6.11 default_language_version: python: python3 diff --git a/scripts/run-cmake-format.sh b/scripts/run-cmake-format.sh new file mode 100755 index 000000000..6175a9dc8 --- /dev/null +++ b/scripts/run-cmake-format.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +# This script is a wrapper for cmakelang that may be used with pre-commit. The +# wrapping is necessary because RAPIDS libraries split configuration for +# cmakelang linters between a local config file and a second config file that's +# shared across all of RAPIDS via rapids-cmake. In order to keep it up to date +# this file is only maintained in one place (the rapids-cmake repo) and +# pulled down during builds. We need a way to invoke CMake linting commands +# without causing pre-commit failures (which could block local commits or CI), +# while also being sufficiently flexible to allow users to maintain the config +# file independently of a build directory. +# +# This script provides the minimal functionality to enable those use cases. It +# searches in a number of predefined locations for the rapids-cmake config file +# and exits gracefully if the file is not found. If a user wishes to specify a +# config file at a nonstandard location, they may do so by setting the +# environment variable RAPIDS_CMAKE_FORMAT_FILE. +# +# This script can be invoked directly anywhere within the project repository. +# Alternatively, it may be invoked as a pre-commit hook via +# `pre-commit run (cmake-format)|(cmake-lint)`. +# +# Usage: +# bash run-cmake-format.sh {cmake-format,cmake-lint} infile [infile ...] + +status=0 +if [ -z ${RMM_ROOT:+PLACEHOLDER} ]; then + RMM_BUILD_DIR=$(git rev-parse --show-toplevel 2>&1)/build + status=$? +else + RMM_BUILD_DIR=${RMM_ROOT} +fi + +if ! [ ${status} -eq 0 ]; then + if [[ ${RMM_BUILD_DIR} == *"not a git repository"* ]]; then + echo "This script must be run inside the rmm repository, or the RMM_ROOT environment variable must be set." + else + echo "Script failed with unknown error attempting to determine project root:" + echo ${RMM_BUILD_DIR} + fi + exit 1 +fi + +DEFAULT_FORMAT_FILE_LOCATIONS=( + "${RMM_BUILD_DIR}/_deps/rapids-cmake-src/cmake-format-rapids-cmake.json" +) + +if [ -z ${RAPIDS_CMAKE_FORMAT_FILE:+PLACEHOLDER} ]; then + for file_path in ${DEFAULT_FORMAT_FILE_LOCATIONS[@]}; do + if [ -f ${file_path} ]; then + RAPIDS_CMAKE_FORMAT_FILE=${file_path} + break + fi + done +fi + +if [ -z ${RAPIDS_CMAKE_FORMAT_FILE:+PLACEHOLDER} ]; then + echo "The rapids-cmake cmake-format configuration file was not found at any of the default search locations: " + echo "" + ( IFS=$'\n'; echo "${DEFAULT_FORMAT_FILE_LOCATIONS[*]}" ) + echo "" + echo "Try setting the environment variable RAPIDS_CMAKE_FORMAT_FILE to the path to the config file." + exit 0 +else + echo "Using format file ${RAPIDS_CMAKE_FORMAT_FILE}" +fi + +if [[ $1 == "cmake-format" ]]; then + cmake-format -i --config-files cmake/config.json ${RAPIDS_CMAKE_FORMAT_FILE} -- ${@:2} +elif [[ $1 == "cmake-lint" ]]; then + cmake-lint --config-files cmake/config.json ${RAPIDS_CMAKE_FORMAT_FILE} -- ${@:2} +fi From ae27a572b08c2022fd428751b644579f4b5eec95 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Fri, 19 Nov 2021 14:26:26 -0500 Subject: [PATCH 022/675] update changelog --- CHANGELOG.md | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0c6ee2db..393ea8447 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,38 @@ -# RMM 21.10.00 (Date TBD) +# RMM 21.10.00 (7 Oct 2021) -Please see https://github.com/rapidsai/rmm/releases/tag/v21.10.00a for the latest changes to this development branch. +## 🚨 Breaking Changes + +- Delete cuda_async_memory_resource copy/move ctors/operators ([#860](https://github.com/rapidsai/rmm/pull/860)) [@jrhemstad](https://github.com/jrhemstad) + +## 🐛 Bug Fixes + +- Fix parameter name in asserts ([#875](https://github.com/rapidsai/rmm/pull/875)) [@vyasr](https://github.com/vyasr) +- Disallow zero-size stream pools ([#873](https://github.com/rapidsai/rmm/pull/873)) [@harrism](https://github.com/harrism) +- Correct namespace usage in host memory resources ([#872](https://github.com/rapidsai/rmm/pull/872)) [@divyegala](https://github.com/divyegala) +- fix race condition in limiting resource adapter ([#869](https://github.com/rapidsai/rmm/pull/869)) [@rongou](https://github.com/rongou) +- Install the right cudatoolkit in the conda env in gpu/build.sh ([#864](https://github.com/rapidsai/rmm/pull/864)) [@shwina](https://github.com/shwina) +- Disable copy/move ctors and operator= from free_list classes ([#862](https://github.com/rapidsai/rmm/pull/862)) [@harrism](https://github.com/harrism) +- Delete cuda_async_memory_resource copy/move ctors/operators ([#860](https://github.com/rapidsai/rmm/pull/860)) [@jrhemstad](https://github.com/jrhemstad) +- Improve concurrency of stream_ordered_memory_resource by stealing less ([#851](https://github.com/rapidsai/rmm/pull/851)) [@harrism](https://github.com/harrism) +- Use the new RAPIDS.cmake to fetch rapids-cmake ([#838](https://github.com/rapidsai/rmm/pull/838)) [@robertmaynard](https://github.com/robertmaynard) + +## 📖 Documentation + +- Forward-merge branch-21.08 to branch-21.10 ([#846](https://github.com/rapidsai/rmm/pull/846)) [@jakirkham](https://github.com/jakirkham) + +## 🛠️ Improvements + +- Forward-merge `branch-21.08` into `branch-21.10` ([#877](https://github.com/rapidsai/rmm/pull/877)) [@ajschmidt8](https://github.com/ajschmidt8) +- Add .clang-tidy and fix clang-tidy warnings ([#857](https://github.com/rapidsai/rmm/pull/857)) [@harrism](https://github.com/harrism) +- Update to use rapids-cmake 21.10 pre-configured packages ([#854](https://github.com/rapidsai/rmm/pull/854)) [@robertmaynard](https://github.com/robertmaynard) +- Clean up: use std::size_t, include cstddef and aligned.hpp where missing ([#852](https://github.com/rapidsai/rmm/pull/852)) [@harrism](https://github.com/harrism) +- tweak the arena mr to reduce fragmentation ([#845](https://github.com/rapidsai/rmm/pull/845)) [@rongou](https://github.com/rongou) +- Fix transitive include in cuda_device header ([#843](https://github.com/rapidsai/rmm/pull/843)) [@wphicks](https://github.com/wphicks) +- Refactor cmake style ([#842](https://github.com/rapidsai/rmm/pull/842)) [@robertmaynard](https://github.com/robertmaynard) +- add multi stream allocations benchmark. ([#841](https://github.com/rapidsai/rmm/pull/841)) [@cwharris](https://github.com/cwharris) +- Enforce default visibility for `get_map`. ([#833](https://github.com/rapidsai/rmm/pull/833)) [@trivialfis](https://github.com/trivialfis) +- ENH Replace gpuci_conda_retry with gpuci_mamba_retry ([#823](https://github.com/rapidsai/rmm/pull/823)) [@dillon-cullinan](https://github.com/dillon-cullinan) +- Execution policy class ([#816](https://github.com/rapidsai/rmm/pull/816)) [@viclafargue](https://github.com/viclafargue) # RMM 21.08.00 (4 Aug 2021) From 5c32d5acca6233ef7ffbcbf387c3d0f1cc64235a Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Tue, 30 Nov 2021 14:11:14 -0500 Subject: [PATCH 023/675] Remove `setup.py` from `update-release.sh` script (#926) Since `setup.py` [uses versioneer](https://github.com/rapidsai/rmm/blob/91dd10e55688295f654f619f6da7e62dc4c7a403/python/setup.py#L230), this PR removes the line from `update-release.sh` that updates `setup.py`. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - https://github.com/jakirkham - Mark Sadang (https://github.com/msadang) URL: https://github.com/rapidsai/rmm/pull/926 --- ci/release/update-version.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index bf31c981a..6b7342961 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -32,8 +32,6 @@ function sed_runner() { sed_runner 's/'" VERSION .*"'/'" VERSION ${NEXT_FULL_TAG}"'/g' CMakeLists.txt sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' CMakeLists.txt -sed_runner 's/version=.*/version=\"'"${NEXT_FULL_TAG}"'\",/g' python/setup.py - sed_runner 's/'"PROJECT_NUMBER = .*"'/'"PROJECT_NUMBER = ${NEXT_SHORT_TAG}"'/g' doxygen/Doxyfile sed_runner 's/'"version =.*"'/'"version = \"${NEXT_SHORT_TAG}\""'/g' python/docs/conf.py From d52c36568196c5beb4040b80b9ae930ea6202667 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 1 Dec 2021 21:41:20 +1100 Subject: [PATCH 024/675] Improve C++ Test Coverage (#920) Now that #905 added C++ code coverage support, this PR improves test coverage. Much of the improvement comes from adding a new `adaptor_test.cpp` which generically tests the common functions of all 7 adaptor types. Small test additions improve coverage of many other files as well. At least one typo bug was uncovered and fixed. If you build with `-DCODE_COVERAGE=ON -DRMM_LOGGING_LEVEL=TRACE`, overall code coverage is now 99.5% and all but one file has 100% coverage. That one file, arena.hpp is undergoing work concurrent to this PR, and improvement to 100% requires additional testing that might be best undertaken by @rongou, so I will leave it. ![image](https://user-images.githubusercontent.com/783069/143160783-aecda008-2d7d-4ceb-8982-34bb1a35174c.png) Authors: - Mark Harris (https://github.com/harrism) Approvers: - Robert Maynard (https://github.com/robertmaynard) - Rong Ou (https://github.com/rongou) - Jake Hemstad (https://github.com/jrhemstad) URL: https://github.com/rapidsai/rmm/pull/920 --- gcovr.cfg | 3 + include/rmm/detail/error.hpp | 5 +- include/rmm/detail/stack_trace.hpp | 43 +++-- include/rmm/logger.hpp | 4 +- .../rmm/mr/device/arena_memory_resource.hpp | 1 + include/rmm/mr/device/detail/arena.hpp | 5 +- .../mr/device/detail/coalescing_free_list.hpp | 21 ++- include/rmm/mr/device/detail/free_list.hpp | 7 + .../detail/stream_ordered_memory_resource.hpp | 2 + .../mr/device/fixed_size_memory_resource.hpp | 8 +- .../mr/device/logging_resource_adaptor.hpp | 29 +++- .../rmm/mr/device/pool_memory_resource.hpp | 14 +- .../device/thread_safe_resource_adaptor.hpp | 5 +- tests/CMakeLists.txt | 21 +-- tests/cuda_stream_tests.cpp | 37 +++++ tests/device_buffer_tests.cu | 6 + tests/device_scalar_tests.cpp | 17 ++ tests/device_uvector_tests.cpp | 28 ++++ tests/logger_tests.cpp | 4 +- tests/mr/device/adaptor_tests.cpp | 153 ++++++++++++++++++ tests/mr/device/arena_mr_tests.cpp | 97 +++++++++++ tests/mr/device/binning_mr_tests.cpp | 46 ++++++ tests/mr/device/limiting_mr_tests.cpp | 9 ++ tests/mr/device/mr_test.hpp | 10 ++ tests/mr/device/mr_tests.cpp | 86 ++++++---- tests/mr/device/pool_mr_tests.cpp | 38 ++++- tests/mr/device/thrust_allocator_tests.cu | 12 ++ tests/mr/device/tracking_mr_tests.cpp | 27 ++++ 28 files changed, 641 insertions(+), 97 deletions(-) create mode 100644 tests/mr/device/adaptor_tests.cpp create mode 100644 tests/mr/device/arena_mr_tests.cpp create mode 100644 tests/mr/device/binning_mr_tests.cpp diff --git a/gcovr.cfg b/gcovr.cfg index 227d8b194..3868d8a12 100644 --- a/gcovr.cfg +++ b/gcovr.cfg @@ -1,4 +1,7 @@ exclude=build/.* exclude=tests/.* +exclude=benchmarks/.* html=yes html-details=yes +sort-percentage=yes +exclude-throw-branches=yes diff --git a/include/rmm/detail/error.hpp b/include/rmm/detail/error.hpp index 1e3605861..709fac238 100644 --- a/include/rmm/detail/error.hpp +++ b/include/rmm/detail/error.hpp @@ -52,7 +52,7 @@ struct cuda_error : public std::runtime_error { class bad_alloc : public std::bad_alloc { public: bad_alloc(const char* msg) : _what{std::string{std::bad_alloc::what()} + ": " + msg} {} - bad_alloc(std::string const& msg) : bad_alloc(msg.c_str()) {} + bad_alloc(std::string const& msg) : bad_alloc{msg.c_str()} {} [[nodiscard]] const char* what() const noexcept override { return _what.c_str(); } @@ -67,7 +67,8 @@ class bad_alloc : public std::bad_alloc { */ class out_of_memory : public bad_alloc { public: - using bad_alloc::bad_alloc; + out_of_memory(const char* msg) : bad_alloc{std::string{"out_of_memory: "} + msg} {} + out_of_memory(std::string const& msg) : out_of_memory{msg.c_str()} {} }; /** diff --git a/include/rmm/detail/stack_trace.hpp b/include/rmm/detail/stack_trace.hpp index 1f76af0a4..082cef02e 100644 --- a/include/rmm/detail/stack_trace.hpp +++ b/include/rmm/detail/stack_trace.hpp @@ -16,6 +16,8 @@ #pragma once +#include + // execinfo is a linux-only library, so stack traces will only be available on // linux systems. #if (defined(__GNUC__) && !defined(__MINGW32__) && !defined(__MINGW64__)) @@ -64,32 +66,29 @@ class stack_trace { backtrace_symbols(trace.stack_ptrs.data(), static_cast(trace.stack_ptrs.size())), &::free); - if (strings == nullptr) { - os << "But no stack trace could be found!" << std::endl; - } else { - // Iterate over the stack pointers converting to a string - for (std::size_t i = 0; i < trace.stack_ptrs.size(); ++i) { - // Leading index - os << "#" << i << " in "; + RMM_EXPECTS(strings != nullptr, "Unexpected null stack trace symbols"); + // Iterate over the stack pointers converting to a string + for (std::size_t i = 0; i < trace.stack_ptrs.size(); ++i) { + // Leading index + os << "#" << i << " in "; - auto const str = [&] { - Dl_info info; - if (dladdr(trace.stack_ptrs[i], &info) != 0) { - int status = -1; // Demangle the name. This can occasionally fail + auto const str = [&] { + Dl_info info; + if (dladdr(trace.stack_ptrs[i], &info) != 0) { + int status = -1; // Demangle the name. This can occasionally fail - std::unique_ptr demangled( - abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status), &::free); - // If it fails, fallback to the dli_name. - if (status == 0 or (info.dli_sname != nullptr)) { - auto const* name = status == 0 ? demangled.get() : info.dli_sname; - return name + std::string(" from ") + info.dli_fname; - } + std::unique_ptr demangled( + abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status), &::free); + // If it fails, fallback to the dli_name. + if (status == 0 or (info.dli_sname != nullptr)) { + auto const* name = status == 0 ? demangled.get() : info.dli_sname; + return name + std::string(" from ") + info.dli_fname; } - return std::string(strings.get()[i]); - }(); + } + return std::string(strings.get()[i]); + }(); - os << str << std::endl; - } + os << str << std::endl; } #else os << "stack traces disabled" << std::endl; diff --git a/include/rmm/logger.hpp b/include/rmm/logger.hpp index 43d4b6ea3..8109eb888 100644 --- a/include/rmm/logger.hpp +++ b/include/rmm/logger.hpp @@ -77,8 +77,8 @@ struct bytes { friend std::ostream& operator<<(std::ostream& os, bytes const& value) { - static std::array const units{ - "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"}; + static std::array units{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"}; + int index = 0; auto size = static_cast(value.value); while (size > 1024) { diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index d0a19da76..a44466623 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -280,6 +280,7 @@ class arena_memory_resource final : public device_memory_resource { stream_arena.second.dump_memory_log(logger_); } } + logger_->flush(); } /** diff --git a/include/rmm/mr/device/detail/arena.hpp b/include/rmm/mr/device/detail/arena.hpp index 44ae8f88e..cda5a73ad 100644 --- a/include/rmm/mr/device/detail/arena.hpp +++ b/include/rmm/mr/device/detail/arena.hpp @@ -177,8 +177,9 @@ constexpr std::size_t align_down(std::size_t value) noexcept */ inline block first_fit(std::set& free_blocks, std::size_t size) { - auto const iter = std::find_if( - free_blocks.cbegin(), free_blocks.cend(), [size](auto const& blk) { return blk.fits(size); }); + auto fits = [size](auto const& blk) { return blk.fits(size); }; + + auto const iter = std::find_if(free_blocks.cbegin(), free_blocks.cend(), fits); if (iter == free_blocks.cend()) { return {}; } // Remove the block from the free_list. diff --git a/include/rmm/mr/device/detail/coalescing_free_list.hpp b/include/rmm/mr/device/detail/coalescing_free_list.hpp index 39e1e389e..8c5db7b02 100644 --- a/include/rmm/mr/device/detail/coalescing_free_list.hpp +++ b/include/rmm/mr/device/detail/coalescing_free_list.hpp @@ -16,6 +16,7 @@ #pragma once +#include #include #include @@ -122,6 +123,7 @@ struct block : public block_base { return fits(bytes) && (size() < blk.size() || blk.size() < bytes); } +#ifdef RMM_DEBUG_PRINT /** * @brief Print this block. For debugging. */ @@ -129,18 +131,21 @@ struct block : public block_base { { std::cout << fmt::format("{} {} B", fmt::ptr(pointer()), size()) << std::endl; } +#endif private: std::size_t size_bytes{}; ///< Size in bytes bool head{}; ///< Indicates whether ptr was allocated from the heap }; +#ifdef RMM_DEBUG_PRINT /// Print block on an ostream inline std::ostream& operator<<(std::ostream& out, const block& blk) { out << fmt::format("{} {} B\n", fmt::ptr(blk.pointer()), blk.size()); return out; } +#endif /** * @brief Comparator for block types based on pointer address. @@ -217,9 +222,9 @@ struct coalescing_free_list : free_list { */ void insert(free_list&& other) { - std::for_each(std::make_move_iterator(other.begin()), - std::make_move_iterator(other.end()), - [this](block_type&& block) { this->insert(block); }); + using std::make_move_iterator; + auto inserter = [this](block_type&& block) { this->insert(block); }; + std::for_each(make_move_iterator(other.begin()), make_move_iterator(other.end()), inserter); } /** @@ -233,10 +238,10 @@ struct coalescing_free_list : free_list { block_type get_block(std::size_t size) { // find best fit block - auto const iter = - std::min_element(cbegin(), cend(), [size](block_type const& lhs, block_type const& rhs) { - return lhs.is_better_fit(size, rhs); - }); + auto finder = [size](block_type const& lhs, block_type const& rhs) { + return lhs.is_better_fit(size, rhs); + }; + auto const iter = std::min_element(cbegin(), cend(), finder); if (iter != cend() && iter->fits(size)) { // Remove the block from the free_list and return it. @@ -248,6 +253,7 @@ struct coalescing_free_list : free_list { return block_type{}; // not found } +#ifdef RMM_DEBUG_PRINT /** * @brief Print all blocks in the free_list. */ @@ -256,6 +262,7 @@ struct coalescing_free_list : free_list { std::cout << size() << '\n'; std::for_each(cbegin(), cend(), [](auto const iter) { iter.print(); }); } +#endif }; // coalescing_free_list } // namespace rmm::mr::detail diff --git a/include/rmm/mr/device/detail/free_list.hpp b/include/rmm/mr/device/detail/free_list.hpp index 1e8623431..baf8732a4 100644 --- a/include/rmm/mr/device/detail/free_list.hpp +++ b/include/rmm/mr/device/detail/free_list.hpp @@ -32,16 +32,21 @@ struct block_base { [[nodiscard]] inline void* pointer() const { return ptr; } /// Returns true if this block is valid (non-null), false otherwise [[nodiscard]] inline bool is_valid() const { return pointer() != nullptr; } + +#ifdef RMM_DEBUG_PRINT /// Prints the block to stdout inline void print() const { std::cout << pointer(); } +#endif }; +#ifdef RMM_DEBUG_PRINT /// Print block_base on an ostream inline std::ostream& operator<<(std::ostream& out, const block_base& block) { out << block.pointer(); return out; } +#endif /** * @brief Base class defining an interface for a list of free memory blocks. @@ -115,6 +120,7 @@ class free_list { */ void clear() noexcept { blocks.clear(); } +#ifdef RMM_DEBUG_PRINT /** * @brief Print all blocks in the free_list. */ @@ -125,6 +131,7 @@ class free_list { std::cout << block << std::endl; } } +#endif protected: /** diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index 6990a2aa6..50495cb17 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -159,6 +159,7 @@ class stream_ordered_memory_resource : public crtp, public device_ stream_free_blocks_[get_event(stream)].insert(std::move(blocks)); } +#ifdef RMM_DEBUG_PRINT void print_free_blocks() const { std::cout << "stream free blocks: "; @@ -170,6 +171,7 @@ class stream_ordered_memory_resource : public crtp, public device_ } std::cout << std::endl; } +#endif /** * @brief Get the mutex object diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index 1a91a7060..59b0b59b8 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -158,7 +158,7 @@ class fixed_size_memory_resource */ free_list blocks_from_upstream(cuda_stream_view stream) { - void* ptr = upstream_mr_->allocate(upstream_chunk_size_, stream); + void* ptr = get_upstream()->allocate(upstream_chunk_size_, stream); block_type block{ptr}; upstream_blocks_.push_back(block); @@ -230,16 +230,17 @@ class fixed_size_memory_resource lock_guard lock(this->get_mutex()); for (auto block : upstream_blocks_) { - upstream_mr_->deallocate(block.pointer(), upstream_chunk_size_); + get_upstream()->deallocate(block.pointer(), upstream_chunk_size_); } upstream_blocks_.clear(); } +#ifdef RMM_DEBUG_PRINT void print() { lock_guard lock(this->get_mutex()); - auto const [free, total] = upstream_mr_->get_mem_info(0); + auto const [free, total] = get_upstream()->get_mem_info(rmm::cuda_stream_default); std::cout << "GPU free memory: " << free << " total: " << total << "\n"; std::cout << "upstream_blocks: " << upstream_blocks_.size() << "\n"; @@ -253,6 +254,7 @@ class fixed_size_memory_resource this->print_free_blocks(); } +#endif /** * @brief Get the largest available block size and total free size in the specified free list diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 26448f887..f583e31b9 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -27,6 +27,7 @@ #include #include #include +#include namespace rmm::mr { /** @@ -67,10 +68,7 @@ class logging_resource_adaptor final : public device_memory_resource { logging_resource_adaptor(Upstream* upstream, std::string const& filename = get_default_filename(), bool auto_flush = false) - : logger_{std::make_shared( - "RMM", - std::make_shared(filename, true /*truncate file*/))}, - upstream_{upstream} + : logger_{make_logger(filename)}, upstream_{upstream} { RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); @@ -92,9 +90,7 @@ class logging_resource_adaptor final : public device_memory_resource { * performance. */ logging_resource_adaptor(Upstream* upstream, std::ostream& stream, bool auto_flush = false) - : logger_{std::make_shared( - "RMM", std::make_shared(stream))}, - upstream_{upstream} + : logger_{make_logger(stream)}, upstream_{upstream} { RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); @@ -104,7 +100,7 @@ class logging_resource_adaptor final : public device_memory_resource { logging_resource_adaptor(Upstream* upstream, spdlog::sinks_init_list sinks, bool auto_flush = false) - : logger_{std::make_shared("RMM", sinks)}, upstream_{upstream} + : logger_{make_logger(sinks)}, upstream_{upstream} { RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); @@ -177,6 +173,23 @@ class logging_resource_adaptor final : public device_memory_resource { return std::string{filename}; } + static auto make_logger(std::ostream& stream) + { + return std::make_shared( + "RMM", std::make_shared(stream)); + } + + static auto make_logger(std::string const& filename) + { + return std::make_shared( + "RMM", std::make_shared(filename, true /*truncate file*/)); + } + + static auto make_logger(spdlog::sinks_init_list sinks) + { + return std::make_shared("RMM", sinks); + } + /** * @brief Initialize the logger. */ diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 5a4d6fc1e..b48b3b311 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -256,9 +256,9 @@ class pool_memory_resource final { if (maximum_pool_size_.has_value()) { auto const unaligned_remaining = maximum_pool_size_.value() - pool_size(); - auto const remaining = - rmm::detail::align_up(unaligned_remaining, rmm::detail::CUDA_ALLOCATION_ALIGNMENT); - auto const aligned_size = rmm::detail::align_up(size, rmm::detail::CUDA_ALLOCATION_ALIGNMENT); + using rmm::detail::align_up; + auto const remaining = align_up(unaligned_remaining, rmm::detail::CUDA_ALLOCATION_ALIGNMENT); + auto const aligned_size = align_up(size, rmm::detail::CUDA_ALLOCATION_ALIGNMENT); return (aligned_size <= remaining) ? std::max(aligned_size, remaining / 2) : 0; } return std::max(size, pool_size()); @@ -278,7 +278,7 @@ class pool_memory_resource final if (size == 0) { return {}; } try { - void* ptr = upstream_mr_->allocate(size, stream); + void* ptr = get_upstream()->allocate(size, stream); return thrust::optional{ *upstream_blocks_.emplace(static_cast(ptr), size, true).first}; } catch (std::exception const& e) { @@ -356,7 +356,7 @@ class pool_memory_resource final lock_guard lock(this->get_mutex()); for (auto block : upstream_blocks_) { - upstream_mr_->deallocate(block.pointer(), block.size()); + get_upstream()->deallocate(block.pointer(), block.size()); } upstream_blocks_.clear(); #ifdef RMM_POOL_TRACK_ALLOCATIONS @@ -366,6 +366,7 @@ class pool_memory_resource final current_pool_size_ = 0; } +#ifdef RMM_DEBUG_PRINT /** * @brief Print debugging information about all blocks in the pool. * @@ -376,7 +377,7 @@ class pool_memory_resource final { lock_guard lock(this->get_mutex()); - auto const [free, total] = upstream_mr_->get_mem_info(0); + auto const [free, total] = upstream_mr_->get_mem_info(rmm::cuda_stream_default); std::cout << "GPU free memory: " << free << " total: " << total << "\n"; std::cout << "upstream_blocks: " << upstream_blocks_.size() << "\n"; @@ -396,6 +397,7 @@ class pool_memory_resource final this->print_free_blocks(); } +#endif /** * @brief Get the largest available block size and total free size in the specified free list diff --git a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp index b1f898c5e..340ffa43d 100644 --- a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp +++ b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp @@ -76,7 +76,10 @@ class thread_safe_resource_adaptor final : public device_memory_resource { * * @return bool true if the upstream resource supports get_mem_info, false otherwise. */ - bool supports_get_mem_info() const noexcept override { return upstream_->supports_streams(); } + bool supports_get_mem_info() const noexcept override + { + return upstream_->supports_get_mem_info(); + } private: /** diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6da87eb70..1a8ca6cb8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,12 +16,6 @@ option(DISABLE_DEPRECATION_WARNING "Disable warnings generated from deprecated declarations." OFF) option(CODE_COVERAGE "Enable generating code coverage with gcov." OFF) -if(CODE_COVERAGE) - if(NOT (CMAKE_BUILD_TYPE STREQUAL "Debug")) - message(WARNING "Generating code coverage for optimised (non-Debug) builds not recommended") - endif() -endif() - # This function takes in a test name and test source and handles setting all of the associated # properties and linking to build the test function(ConfigureTestInternal TEST_NAME) @@ -59,10 +53,10 @@ function(ConfigureTestInternal TEST_NAME) target_compile_options( ${TEST_NAME} PUBLIC - $<$:-Xcompiler=--coverage,-fprofile-abs-path,-fkeep-inline-functions,-fno-elide-constructors> - ) + $<$:-O0 + -Xcompiler=--coverage,-fprofile-abs-path,-fkeep-inline-functions,-fno-elide-constructors>) target_compile_options( - ${TEST_NAME} PUBLIC $<$:--coverage -fprofile-abs-path + ${TEST_NAME} PUBLIC $<$:-O0 --coverage -fprofile-abs-path -fkeep-inline-functions -fno-elide-constructors>) target_link_options(${TEST_NAME} PRIVATE --coverage) target_link_libraries(${TEST_NAME} gcov) @@ -96,6 +90,9 @@ endfunction() # device mr tests ConfigureTest(DEVICE_MR_TEST mr/device/mr_tests.cpp mr/device/mr_multithreaded_tests.cpp) +# general adaptor tests +ConfigureTest(ADAPTOR_TEST mr/device/adaptor_tests.cpp) + # pool mr tests ConfigureTest(POOL_MR_TEST mr/device/pool_mr_tests.cpp) @@ -143,3 +140,9 @@ ConfigureTest(LOGGER_TEST logger_tests.cpp) # uvector tests ConfigureTest(DEVICE_UVECTOR_TEST device_uvector_tests.cpp) + +# arena MR tests +ConfigureTest(ARENA_MR_TEST mr/device/arena_mr_tests.cpp) + +# binning MR tests +ConfigureTest(BINNING_MR_TEST mr/device/binning_mr_tests.cpp) diff --git a/tests/cuda_stream_tests.cpp b/tests/cuda_stream_tests.cpp index f801226c6..f1b6569c5 100644 --- a/tests/cuda_stream_tests.cpp +++ b/tests/cuda_stream_tests.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -40,6 +41,8 @@ TEST_F(CudaStreamTest, Equality) rmm::device_buffer buff{}; EXPECT_EQ(buff.stream(), view_default); + + EXPECT_NE(static_cast(stream_a), rmm::cuda_stream_default.value()); } TEST_F(CudaStreamTest, MoveConstructor) @@ -51,3 +54,37 @@ TEST_F(CudaStreamTest, MoveConstructor) EXPECT_FALSE(stream_a.is_valid()); // Any other operations on stream_a are UB, may segfault EXPECT_EQ(stream_b, view_a); } + +TEST_F(CudaStreamTest, TestSyncNoThrow) +{ + rmm::cuda_stream stream_a; +// Cannot test this in debug mode because it will cause an assertion. +// But need this test to get full code coverage +#ifdef NDEBUG + cudaStreamDestroy(static_cast(stream_a)); +#endif + EXPECT_NO_THROW(stream_a.synchronize_no_throw()); +} + +TEST_F(CudaStreamTest, TestStreamViewOstream) +{ + rmm::cuda_stream stream_a; + rmm::cuda_stream_view view(stream_a); + + std::ostringstream oss; + + oss << view; + + std::ostringstream oss_expected; + + oss_expected << stream_a.value(); + + EXPECT_EQ(oss.str(), oss_expected.str()); +} + +// Without this we don't get test coverage of ~stream_view, presumably because it is elided +TEST_F(CudaStreamTest, TestStreamViewDestructor) +{ + auto view = std::make_shared(rmm::cuda_stream_per_thread); + view->synchronize(); +} diff --git a/tests/device_buffer_tests.cu b/tests/device_buffer_tests.cu index 2d69eec8f..fd772cfea 100644 --- a/tests/device_buffer_tests.cu +++ b/tests/device_buffer_tests.cu @@ -56,6 +56,12 @@ using resources = ::testing::Typessize, rmm::cuda_stream_view{}); diff --git a/tests/device_scalar_tests.cpp b/tests/device_scalar_tests.cpp index 8b71af648..fd92f7d6e 100644 --- a/tests/device_scalar_tests.cpp +++ b/tests/device_scalar_tests.cpp @@ -28,6 +28,9 @@ #include #include +// explicit instantiation for test coverage purposes +template class rmm::device_scalar; + template struct DeviceScalarTest : public ::testing::Test { std::default_random_engine generator{}; @@ -68,6 +71,12 @@ using Types = ::testing::Types scalar{this->stream, this->mr}; + EXPECT_NE(nullptr, scalar.data()); +} + TYPED_TEST(DeviceScalarTest, InitialValue) { rmm::device_scalar scalar{this->value, this->stream, this->mr}; @@ -75,6 +84,14 @@ TYPED_TEST(DeviceScalarTest, InitialValue) EXPECT_EQ(this->value, scalar.value(this->stream)); } +// test const version of data() +TYPED_TEST(DeviceScalarTest, ConstPtrData) +{ + rmm::device_scalar const scalar{this->value, this->stream, this->mr}; + auto const* data = scalar.data(); + EXPECT_NE(nullptr, data); +} + TYPED_TEST(DeviceScalarTest, CopyCtor) { rmm::device_scalar scalar{this->value, this->stream, this->mr}; diff --git a/tests/device_uvector_tests.cpp b/tests/device_uvector_tests.cpp index f724b3906..539dd2c26 100644 --- a/tests/device_uvector_tests.cpp +++ b/tests/device_uvector_tests.cpp @@ -20,6 +20,10 @@ #include #include +#include + +// explicit instantiation for test coverage purposes. +template class rmm::device_uvector; template struct TypedUVectorTest : ::testing::Test { @@ -30,6 +34,12 @@ using TestTypes = ::testing::Types; TYPED_TEST_CASE(TypedUVectorTest, TestTypes); +TYPED_TEST(TypedUVectorTest, MemoryResource) +{ + rmm::device_uvector vec(128, this->stream()); + EXPECT_EQ(vec.memory_resource(), rmm::mr::get_current_device_resource()); +} + TYPED_TEST(TypedUVectorTest, ZeroSizeConstructor) { rmm::device_uvector vec(0, this->stream()); @@ -220,3 +230,21 @@ TYPED_TEST(TypedUVectorTest, SetGetStream) EXPECT_EQ(vec.stream(), otherstream); } + +TYPED_TEST(TypedUVectorTest, Iterators) +{ + auto const size{12345}; + rmm::device_uvector vec(size, this->stream()); + + EXPECT_EQ(vec.begin(), vec.data()); + EXPECT_EQ(vec.cbegin(), vec.data()); + + auto const* const_begin = std::as_const(vec).begin(); + EXPECT_EQ(const_begin, vec.cbegin()); + + EXPECT_EQ(std::distance(vec.begin(), vec.end()), vec.size()); + EXPECT_EQ(std::distance(vec.cbegin(), vec.cend()), vec.size()); + + auto const* const_end = std::as_const(vec).end(); + EXPECT_EQ(const_end, vec.cend()); +} diff --git a/tests/logger_tests.cpp b/tests/logger_tests.cpp index e0663e84b..1b8356ac7 100644 --- a/tests/logger_tests.cpp +++ b/tests/logger_tests.cpp @@ -15,13 +15,15 @@ */ #include + #include #include -#include #include #include +#include + class raii_restore_env { public: raii_restore_env(char const* name) : name_(name) diff --git a/tests/mr/device/adaptor_tests.cpp b/tests/mr/device/adaptor_tests.cpp new file mode 100644 index 000000000..44c14240b --- /dev/null +++ b/tests/mr/device/adaptor_tests.cpp @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2021, 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. + */ + +#include "../../byte_literals.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +using cuda_mr = rmm::mr::cuda_memory_resource; +using rmm::mr::aligned_resource_adaptor; +using rmm::mr::failure_callback_resource_adaptor; +using rmm::mr::limiting_resource_adaptor; +using rmm::mr::logging_resource_adaptor; +using rmm::mr::statistics_resource_adaptor; +using rmm::mr::thread_safe_resource_adaptor; +using rmm::mr::tracking_resource_adaptor; +using owning_wrapper = rmm::mr::owning_wrapper, cuda_mr>; + +// explicit instantiations for test coverage purposes +template class rmm::mr::aligned_resource_adaptor; +template class rmm::mr::failure_callback_resource_adaptor; +template class rmm::mr::limiting_resource_adaptor; +template class rmm::mr::logging_resource_adaptor; +template class rmm::mr::statistics_resource_adaptor; +template class rmm::mr::thread_safe_resource_adaptor; +template class rmm::mr::tracking_resource_adaptor; + +namespace rmm::test { + +using adaptors = ::testing::Types, + failure_callback_resource_adaptor, + limiting_resource_adaptor, + logging_resource_adaptor, + owning_wrapper, + statistics_resource_adaptor, + thread_safe_resource_adaptor, + tracking_resource_adaptor>; + +template +struct AdaptorTest : public ::testing::Test { + using adaptor_type = MemoryResourceType; + cuda_mr cuda{}; + std::shared_ptr mr; + + AdaptorTest() : mr{make_adaptor(&cuda)} {} + + auto make_adaptor(cuda_mr* upstream) + { + if constexpr (std::is_same_v>) { + return std::make_shared( + upstream, [](std::size_t bytes, void* arg) { return false; }, nullptr); + } else if constexpr (std::is_same_v>) { + return std::make_shared(upstream, 64_MiB); + } else if constexpr (std::is_same_v>) { + return std::make_shared(upstream, "rmm_adaptor_test_log.txt"); + } else if constexpr (std::is_same_v) { + return mr::make_owning_wrapper(std::make_shared()); + } else { + return std::make_shared(upstream); + } + } +}; + +TYPED_TEST_CASE(AdaptorTest, adaptors); + +TYPED_TEST(AdaptorTest, NullUpstream) +{ + if constexpr (not std::is_same_v) { + EXPECT_THROW(this->make_adaptor(nullptr), rmm::logic_error); + } +} + +TYPED_TEST(AdaptorTest, Equality) +{ + EXPECT_TRUE(this->mr->is_equal(*this->mr)); + + { + auto other_mr = this->make_adaptor(&this->cuda); + EXPECT_TRUE(this->mr->is_equal(*other_mr)); + } + + { + rmm::mr::device_memory_resource* device_mr = &this->cuda; + auto other_mr = aligned_resource_adaptor{device_mr}; + EXPECT_FALSE(this->mr->is_equal(other_mr)); + } +} + +TYPED_TEST(AdaptorTest, GetUpstream) +{ + if constexpr (std::is_same_v) { + EXPECT_TRUE(this->mr->wrapped().get_upstream()->is_equal(this->cuda)); + } else { + EXPECT_TRUE(this->mr->get_upstream()->is_equal(this->cuda)); + } +} + +TYPED_TEST(AdaptorTest, SupportsStreams) +{ + EXPECT_EQ(this->mr->supports_streams(), this->cuda.supports_streams()); +} + +TYPED_TEST(AdaptorTest, MemInfo) +{ + EXPECT_EQ(this->mr->supports_get_mem_info(), this->cuda.supports_get_mem_info()); + + auto [free, total] = this->mr->get_mem_info(rmm::cuda_stream_default); + + if (this->mr->supports_get_mem_info()) { + EXPECT_NE(total, 0); + } else { + EXPECT_EQ(free, 0); + EXPECT_EQ(total, 0); + } +} + +TYPED_TEST(AdaptorTest, AllocFree) +{ + void* ptr{nullptr}; + EXPECT_NO_THROW(ptr = this->mr->allocate(1024)); + EXPECT_NE(ptr, nullptr); + EXPECT_NO_THROW(this->mr->deallocate(ptr, 1024)); +} + +} // namespace rmm::test diff --git a/tests/mr/device/arena_mr_tests.cpp b/tests/mr/device/arena_mr_tests.cpp new file mode 100644 index 000000000..b668a0707 --- /dev/null +++ b/tests/mr/device/arena_mr_tests.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2021, 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. + */ + +#include "../../byte_literals.hpp" +#include "rmm/cuda_stream_view.hpp" + +#include + +#include +#include +#include +#include + +#include + +#include + +namespace rmm::test { + +namespace { +using cuda_mr = rmm::mr::cuda_memory_resource; +using arena_mr = rmm::mr::arena_memory_resource; + +TEST(ArenaTest, ThrowOnNullUpstream) +{ + auto construct_nullptr = []() { arena_mr mr{nullptr}; }; + EXPECT_THROW(construct_nullptr(), rmm::logic_error); +} + +TEST(ArenaTest, ThrowMaxLessThanInitial) +{ + // Make sure first argument is enough larger than the second that alignment rounding doesn't + // make them equal + auto max_less_than_initial = []() { + const auto initial{4_MiB}; + const auto maximum{2_MiB}; + cuda_mr cuda; + arena_mr mr{&cuda, initial, maximum}; + }; + EXPECT_THROW(max_less_than_initial(), rmm::logic_error); +} + +TEST(ArenaTest, DumpLogOnFailure) +{ + cuda_mr cuda; + arena_mr mr{&cuda, 1_MiB, 4_MiB, true}; + + { // make the log interesting + std::vector threads; + std::size_t num_threads{4}; + threads.reserve(num_threads); + for (std::size_t i = 0; i < num_threads; ++i) { + threads.emplace_back(std::thread([&] { + void* ptr = mr.allocate(32_KiB); + mr.deallocate(ptr, 32_KiB); + })); + } + + for (auto& thread : threads) { + thread.join(); + } + } + + EXPECT_THROW(mr.allocate(8_MiB), rmm::out_of_memory); + + struct stat file_status { + }; + EXPECT_EQ(stat("rmm_arena_memory_dump.log", &file_status), 0); + EXPECT_GE(file_status.st_size, 0); +} + +TEST(ArenaTest, FeatureSupport) +{ + cuda_mr cuda; + arena_mr mr{&cuda, 1_MiB, 4_MiB}; + EXPECT_TRUE(mr.supports_streams()); + EXPECT_FALSE(mr.supports_get_mem_info()); + auto [free, total] = mr.get_mem_info(rmm::cuda_stream_default); + EXPECT_EQ(free, 0); + EXPECT_EQ(total, 0); +} + +} // namespace +} // namespace rmm::test diff --git a/tests/mr/device/binning_mr_tests.cpp b/tests/mr/device/binning_mr_tests.cpp new file mode 100644 index 000000000..68fc66322 --- /dev/null +++ b/tests/mr/device/binning_mr_tests.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021, 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. + */ + +#include +#include + +#include + +// explicit instantiation for test coverage purposes +template class rmm::mr::binning_memory_resource; + +namespace rmm::test { + +using cuda_mr = rmm::mr::cuda_memory_resource; +using binning_mr = rmm::mr::binning_memory_resource; + +TEST(BinningTest, ThrowOnNullUpstream) +{ + auto construct_nullptr = []() { binning_mr mr{nullptr}; }; + EXPECT_THROW(construct_nullptr(), rmm::logic_error); +} + +TEST(BinningTest, ExplicitBinMR) +{ + cuda_mr cuda{}; + binning_mr mr{&cuda}; + mr.add_bin(1024, &cuda); + auto* ptr = mr.allocate(512); + EXPECT_NE(ptr, nullptr); + mr.deallocate(ptr, 512); +} + +} // namespace rmm::test diff --git a/tests/mr/device/limiting_mr_tests.cpp b/tests/mr/device/limiting_mr_tests.cpp index 80c49104f..777ce9428 100644 --- a/tests/mr/device/limiting_mr_tests.cpp +++ b/tests/mr/device/limiting_mr_tests.cpp @@ -41,6 +41,15 @@ TEST(LimitingTest, TooBig) EXPECT_THROW(mr.allocate(max_size + 1), rmm::out_of_memory); } +TEST(LimitingTest, UpstreamFailure) +{ + auto const max_size_1{2_MiB}; + auto const max_size_2{5_MiB}; + Limiting_adaptor mr1{rmm::mr::get_current_device_resource(), max_size_1}; + Limiting_adaptor mr2{&mr1, max_size_2}; + EXPECT_THROW(mr2.allocate(4_MiB), rmm::out_of_memory); +} + TEST(LimitingTest, UnderLimitDueToFrees) { auto const max_size{10_MiB}; diff --git a/tests/mr/device/mr_test.hpp b/tests/mr/device/mr_test.hpp index 7635901c8..684701fb8 100644 --- a/tests/mr/device/mr_test.hpp +++ b/tests/mr/device/mr_test.hpp @@ -130,6 +130,13 @@ inline void test_various_allocations(rmm::mr::device_memory_resource* mr, cuda_s void* ptr{nullptr}; EXPECT_THROW(ptr = mr->allocate(1_PiB, stream), rmm::out_of_memory); EXPECT_EQ(nullptr, ptr); + + // test e.what(); + try { + ptr = mr->allocate(1_PiB, stream); + } catch (rmm::out_of_memory const& e) { + EXPECT_NE(std::string{e.what()}.find("out_of_memory"), std::string::npos); + } } } @@ -233,6 +240,9 @@ struct mr_test : public ::testing::TestWithParam { rmm::cuda_stream stream{}; }; +struct mr_allocation_test : public mr_test { +}; + /// MR factory functions inline auto make_cuda() { return std::make_shared(); } diff --git a/tests/mr/device/mr_tests.cpp b/tests/mr/device/mr_tests.cpp index f1248dbc0..f6141e90f 100644 --- a/tests/mr/device/mr_tests.cpp +++ b/tests/mr/device/mr_tests.cpp @@ -28,6 +28,20 @@ INSTANTIATE_TEST_SUITE_P(ResourceTests, ::testing::Values(mr_factory{"CUDA", &make_cuda}, #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT mr_factory{"CUDA_Async", &make_cuda_async}, +#endif + mr_factory{"Managed", &make_managed}, + mr_factory{"Pool", &make_pool}, + mr_factory{"Arena", &make_arena}, + mr_factory{"Binning", &make_binning}, + mr_factory{"Fixed_Size", &make_fixed_size}), + [](auto const& info) { return info.param.name; }); + +// Leave out fixed-size MR here because it can't handle the dynamic allocation sizes +INSTANTIATE_TEST_SUITE_P(ResourceAllocationTests, + mr_allocation_test, + ::testing::Values(mr_factory{"CUDA", &make_cuda}, +#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT + mr_factory{"CUDA_Async", &make_cuda_async}, #endif mr_factory{"Managed", &make_managed}, mr_factory{"Pool", &make_pool}, @@ -71,12 +85,40 @@ TEST_P(mr_test, SetCurrentDeviceResource) TEST_P(mr_test, SelfEquality) { EXPECT_TRUE(this->mr->is_equal(*this->mr)); } -TEST_P(mr_test, AllocateDefaultStream) +TEST_P(mr_test, SupportsStreams) { - test_various_allocations(this->mr.get(), cuda_stream_view{}); + if (this->mr->is_equal(rmm::mr::cuda_memory_resource{}) || + this->mr->is_equal(rmm::mr::managed_memory_resource{})) { + EXPECT_FALSE(this->mr->supports_streams()); + } else { + EXPECT_TRUE(this->mr->supports_streams()); + } } -TEST_P(mr_test, AllocateOnStream) { test_various_allocations(this->mr.get(), this->stream); } +TEST_P(mr_test, GetMemInfo) +{ + if (this->mr->supports_get_mem_info()) { + const auto allocation_size{16 * 256}; + { + auto const [free, total] = this->mr->get_mem_info(rmm::cuda_stream_view{}); + EXPECT_TRUE(free >= allocation_size); + } + + void* ptr{nullptr}; + ptr = this->mr->allocate(allocation_size); + + { + auto const [free, total] = this->mr->get_mem_info(rmm::cuda_stream_view{}); + EXPECT_TRUE(free >= allocation_size); + } + + this->mr->deallocate(ptr, allocation_size); + } else { + auto const [free, total] = this->mr->get_mem_info(rmm::cuda_stream_view{}); + EXPECT_EQ(free, 0); + EXPECT_EQ(total, 0); + } +} // Simple reproducer for https://github.com/rapidsai/rmm/issues/861 TEST_P(mr_test, AllocationsAreDifferentDefaultStream) @@ -89,42 +131,32 @@ TEST_P(mr_test, AllocationsAreDifferent) concurrent_allocations_are_different(this->mr.get(), this->stream); } -TEST_P(mr_test, RandomAllocations) { test_random_allocations(this->mr.get()); } +TEST_P(mr_allocation_test, AllocateDefaultStream) +{ + test_various_allocations(this->mr.get(), cuda_stream_view{}); +} -TEST_P(mr_test, RandomAllocationsStream) +TEST_P(mr_allocation_test, AllocateOnStream) +{ + test_various_allocations(this->mr.get(), this->stream); +} + +TEST_P(mr_allocation_test, RandomAllocations) { test_random_allocations(this->mr.get()); } + +TEST_P(mr_allocation_test, RandomAllocationsStream) { test_random_allocations(this->mr.get(), default_num_allocations, default_max_size, this->stream); } -TEST_P(mr_test, MixedRandomAllocationFree) +TEST_P(mr_allocation_test, MixedRandomAllocationFree) { test_mixed_random_allocation_free(this->mr.get(), default_max_size, cuda_stream_view{}); } -TEST_P(mr_test, MixedRandomAllocationFreeStream) +TEST_P(mr_allocation_test, MixedRandomAllocationFreeStream) { test_mixed_random_allocation_free(this->mr.get(), default_max_size, this->stream); } -TEST_P(mr_test, GetMemInfo) -{ - if (this->mr->supports_get_mem_info()) { - const auto allocation_size{16 * 256}; - { - auto const [free, total] = this->mr->get_mem_info(rmm::cuda_stream_view{}); - EXPECT_TRUE(free >= allocation_size); - } - - void* ptr{nullptr}; - ptr = this->mr->allocate(allocation_size); - - { - auto const [free, total] = this->mr->get_mem_info(rmm::cuda_stream_view{}); - EXPECT_TRUE(free >= allocation_size); - } - - this->mr->deallocate(ptr, allocation_size); - } -} } // namespace } // namespace rmm::test diff --git a/tests/mr/device/pool_mr_tests.cpp b/tests/mr/device/pool_mr_tests.cpp index ca8888a52..c4622075e 100644 --- a/tests/mr/device/pool_mr_tests.cpp +++ b/tests/mr/device/pool_mr_tests.cpp @@ -26,6 +26,9 @@ #include +// explicit instantiation for test coverage purposes +template class rmm::mr::pool_memory_resource; + namespace rmm::test { namespace { using cuda_mr = rmm::mr::cuda_memory_resource; @@ -80,13 +83,25 @@ TEST(PoolTest, TwoLargeBuffers) TEST(PoolTest, ForceGrowth) { cuda_mr cuda; - auto const max_size{6000}; - limiting_mr limiter{&cuda, max_size}; - pool_mr mr{&limiter, 0}; - EXPECT_NO_THROW(mr.allocate(1000)); - EXPECT_NO_THROW(mr.allocate(4000)); - EXPECT_NO_THROW(mr.allocate(500)); - EXPECT_THROW(mr.allocate(2000), rmm::out_of_memory); // too much + { + auto const max_size{6000}; + limiting_mr limiter{&cuda, max_size}; + pool_mr mr{&limiter, 0}; + EXPECT_NO_THROW(mr.allocate(1000)); + EXPECT_NO_THROW(mr.allocate(4000)); + EXPECT_NO_THROW(mr.allocate(500)); + EXPECT_THROW(mr.allocate(2000), rmm::out_of_memory); // too much + } + { + // with max pool size + auto const max_size{6000}; + limiting_mr limiter{&cuda, max_size}; + pool_mr mr{&limiter, 0, 8192}; + EXPECT_NO_THROW(mr.allocate(1000)); + EXPECT_THROW(mr.allocate(4000), rmm::out_of_memory); // too much + EXPECT_NO_THROW(mr.allocate(500)); + EXPECT_NO_THROW(mr.allocate(2000)); // fits + } } TEST(PoolTest, DeletedStream) @@ -126,5 +141,14 @@ TEST(PoolTest, NonAlignedPoolSize) rmm::logic_error); } +TEST(PoolTest, UpstreamDoesntSupportMemInfo) +{ + cuda_mr cuda; + pool_mr mr1(&cuda); + pool_mr mr2(&mr1); + auto* ptr = mr2.allocate(1024); + mr2.deallocate(ptr, 1024); +} + } // namespace } // namespace rmm::test diff --git a/tests/mr/device/thrust_allocator_tests.cu b/tests/mr/device/thrust_allocator_tests.cu index c80f3d9e2..e0d467595 100644 --- a/tests/mr/device/thrust_allocator_tests.cu +++ b/tests/mr/device/thrust_allocator_tests.cu @@ -16,11 +16,16 @@ #include "mr_test.hpp" +#include #include +#include #include #include +// explicit instantiation for test coverage purposes +template class rmm::mr::thrust_allocator; + namespace rmm::test { namespace { @@ -34,6 +39,13 @@ TEST_P(allocator_test, first) EXPECT_EQ(num_ints, thrust::reduce(ints.begin(), ints.end())); } +TEST_P(allocator_test, defaults) +{ + rmm::mr::thrust_allocator allocator(rmm::cuda_stream_default); + EXPECT_EQ(allocator.stream(), rmm::cuda_stream_default); + EXPECT_EQ(allocator.resource(), rmm::mr::get_current_device_resource()); +} + INSTANTIATE_TEST_CASE_P(ThrustAllocatorTests, allocator_test, ::testing::Values(mr_factory{"CUDA", &make_cuda}, diff --git a/tests/mr/device/tracking_mr_tests.cpp b/tests/mr/device/tracking_mr_tests.cpp index 5926cbf62..ff84e784e 100644 --- a/tests/mr/device/tracking_mr_tests.cpp +++ b/tests/mr/device/tracking_mr_tests.cpp @@ -23,6 +23,8 @@ #include +#include + namespace rmm::test { namespace { @@ -197,5 +199,30 @@ TEST(TrackingTest, DeallocWrongBytes) EXPECT_EQ(mr.get_allocated_bytes(), 0); } +TEST(TrackingTest, LogOutstandingAllocations) +{ + std::ostringstream oss; + auto oss_sink = std::make_shared(oss); + rmm::logger().sinks().push_back(oss_sink); + auto old_level = rmm::logger().level(); + + tracking_adaptor mr{rmm::mr::get_current_device_resource()}; + std::vector allocations; + for (std::size_t i = 0; i < num_allocations; ++i) { + allocations.push_back(mr.allocate(ten_MiB)); + } + + rmm::logger().set_level(spdlog::level::debug); + mr.log_outstanding_allocations(); + EXPECT_NE(oss.str().find("Outstanding Allocations"), std::string::npos); + + for (auto& allocation : allocations) { + mr.deallocate(allocation, ten_MiB); + } + + rmm::logger().set_level(old_level); + rmm::logger().sinks().pop_back(); +} + } // namespace } // namespace rmm::test From bd5aa5d9046eeb492ab412307c00644f622e3de6 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Tue, 7 Dec 2021 09:09:11 +1100 Subject: [PATCH 025/675] Fix failing tracking test (#929) Fixes #928. #920 introduced a new test for the `tracking_resource_adaptor::log_outstanding_allocations`, but that function only logs when `SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_DEBUG`, so the test needs to be gated on that condition as well. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Rong Ou (https://github.com/rongou) - Vyas Ramasubramani (https://github.com/vyasr) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/929 --- tests/mr/device/tracking_mr_tests.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/mr/device/tracking_mr_tests.cpp b/tests/mr/device/tracking_mr_tests.cpp index ff84e784e..e804cf0ea 100644 --- a/tests/mr/device/tracking_mr_tests.cpp +++ b/tests/mr/device/tracking_mr_tests.cpp @@ -213,8 +213,11 @@ TEST(TrackingTest, LogOutstandingAllocations) } rmm::logger().set_level(spdlog::level::debug); - mr.log_outstanding_allocations(); + EXPECT_NO_THROW(mr.log_outstanding_allocations()); + +#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_DEBUG EXPECT_NE(oss.str().find("Outstanding Allocations"), std::string::npos); +#endif for (auto& allocation : allocations) { mr.deallocate(allocation, ten_MiB); From edc21bb9d594d70f2870f36deb6cee8510dc1c1c Mon Sep 17 00:00:00 2001 From: Conor Hoekstra <36027403+codereport@users.noreply.github.com> Date: Tue, 14 Dec 2021 17:27:41 -0500 Subject: [PATCH 026/675] Remove `IncludeCategories` from `.clang-format` (#933) It was recently noticed that the `IncludeCategories`: ``` IncludeCategories: - Regex: '^' Priority: 2 - Regex: '^<.*\.h>' Priority: 1 - Regex: '^<.*' Priority: 2 - Regex: '.*' Priority: 3 ``` In the `.clang-format` are not really necessary as `ext` has no meaning in RAPIDS. This PR removes these. Authors: - Conor Hoekstra (https://github.com/codereport) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/933 --- .clang-format | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.clang-format b/.clang-format index 0c05436e9..6019a6f3d 100644 --- a/.clang-format +++ b/.clang-format @@ -72,15 +72,6 @@ ForEachMacros: - Q_FOREACH - BOOST_FOREACH IncludeBlocks: Preserve -IncludeCategories: - - Regex: '^' - Priority: 2 - - Regex: '^<.*\.h>' - Priority: 1 - - Regex: '^<.*' - Priority: 2 - - Regex: '.*' - Priority: 3 IncludeIsMainRegex: '([-_](test|unittest))?$' IndentCaseLabels: true IndentPPDirectives: None From cd5f806eaa3eb5e11606e43d2fcaddc86d07f102 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 15 Dec 2021 09:55:42 +1100 Subject: [PATCH 027/675] Fix failing stream test with a debug-only death test (#934) Fixes #932. Adds a debug-build-only death test for `cuda_stream::synchronize_no_throw` and adds a likely never to fail trivial test of the function in all builds. This way we get coverage of the function in all builds, and can safely test its assertion in debug builds. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Rong Ou (https://github.com/rongou) - Conor Hoekstra (https://github.com/codereport) URL: https://github.com/rapidsai/rmm/pull/934 --- tests/cuda_stream_tests.cpp | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/tests/cuda_stream_tests.cpp b/tests/cuda_stream_tests.cpp index f1b6569c5..76423e403 100644 --- a/tests/cuda_stream_tests.cpp +++ b/tests/cuda_stream_tests.cpp @@ -21,6 +21,7 @@ #include +#include #include struct CudaStreamTest : public ::testing::Test { @@ -55,17 +56,6 @@ TEST_F(CudaStreamTest, MoveConstructor) EXPECT_EQ(stream_b, view_a); } -TEST_F(CudaStreamTest, TestSyncNoThrow) -{ - rmm::cuda_stream stream_a; -// Cannot test this in debug mode because it will cause an assertion. -// But need this test to get full code coverage -#ifdef NDEBUG - cudaStreamDestroy(static_cast(stream_a)); -#endif - EXPECT_NO_THROW(stream_a.synchronize_no_throw()); -} - TEST_F(CudaStreamTest, TestStreamViewOstream) { rmm::cuda_stream stream_a; @@ -88,3 +78,24 @@ TEST_F(CudaStreamTest, TestStreamViewDestructor) auto view = std::make_shared(rmm::cuda_stream_per_thread); view->synchronize(); } + +TEST_F(CudaStreamTest, TestSyncNoThrow) +{ + rmm::cuda_stream stream_a; + EXPECT_NO_THROW(stream_a.synchronize_no_throw()); +} + +#ifndef NDEBUG +using CudaStreamDeathTest = CudaStreamTest; + +TEST_F(CudaStreamDeathTest, TestSyncNoThrow) +{ + auto test = []() { + rmm::cuda_stream stream_a; + cudaStreamDestroy(static_cast(stream_a)); + // should assert here or in `~cuda_stream()` + stream_a.synchronize_no_throw(); + }; + EXPECT_DEATH(test(), "Assertion"); +} +#endif From 846d638c938b515fafd4115215f245b8c1a000a5 Mon Sep 17 00:00:00 2001 From: Jordan Jacobelli Date: Thu, 16 Dec 2021 14:57:06 +0100 Subject: [PATCH 028/675] Fix imports tests syntax (#935) Fix imports tests syntax Authors: - Jordan Jacobelli (https://github.com/Ethyling) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/935 --- conda/recipes/rmm/meta.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index fd32170df..a38da35fd 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -41,8 +41,8 @@ requirements: {% endif %} test: - commands: - - python -c "import rmm" + imports: + - rmm about: home: http://rapids.ai/ From 69dd29ab1a58d63d66799a08eb453e4358a3bf2c Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Fri, 17 Dec 2021 17:06:46 -0500 Subject: [PATCH 029/675] update changelog --- CHANGELOG.md | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c3aa26a5..41df83b32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,36 @@ -# RMM 21.12.00 (Date TBD) +# RMM 21.12.00 (9 Dec 2021) -Please see https://github.com/rapidsai/rmm/releases/tag/v21.12.00a for the latest changes to this development branch. +## 🚨 Breaking Changes + +- Parameterize exception type caught by failure_callback_resource_adaptor ([#898](https://github.com/rapidsai/rmm/pull/898)) [@harrism](https://github.com/harrism) + +## 🐛 Bug Fixes + +- Update recipes for Enhanced Compatibility ([#910](https://github.com/rapidsai/rmm/pull/910)) [@ajschmidt8](https://github.com/ajschmidt8) +- Fix `librmm` uploads ([#909](https://github.com/rapidsai/rmm/pull/909)) [@ajschmidt8](https://github.com/ajschmidt8) +- Use spdlog/fmt/ostr.h as it supports external fmt library ([#907](https://github.com/rapidsai/rmm/pull/907)) [@robertmaynard](https://github.com/robertmaynard) +- Fix variable names in logging macro calls ([#897](https://github.com/rapidsai/rmm/pull/897)) [@harrism](https://github.com/harrism) +- Keep rapids cmake version in sync ([#876](https://github.com/rapidsai/rmm/pull/876)) [@robertmaynard](https://github.com/robertmaynard) + +## 📖 Documentation + +- Replace `to_device()` in docs with `DeviceBuffer.to_device()` ([#902](https://github.com/rapidsai/rmm/pull/902)) [@shwina](https://github.com/shwina) +- Fix return value docs for supports_get_mem_info ([#884](https://github.com/rapidsai/rmm/pull/884)) [@harrism](https://github.com/harrism) + +## 🚀 New Features + +- Out-of-memory callback resource adaptor ([#892](https://github.com/rapidsai/rmm/pull/892)) [@madsbk](https://github.com/madsbk) + +## 🛠️ Improvements + +- suppress spurious clang-tidy warnings in debug macros ([#914](https://github.com/rapidsai/rmm/pull/914)) [@rongou](https://github.com/rongou) +- C++ code coverage support ([#905](https://github.com/rapidsai/rmm/pull/905)) [@harrism](https://github.com/harrism) +- Provide ./build.sh flag to control CUDA async malloc support ([#901](https://github.com/rapidsai/rmm/pull/901)) [@robertmaynard](https://github.com/robertmaynard) +- Parameterize exception type caught by failure_callback_resource_adaptor ([#898](https://github.com/rapidsai/rmm/pull/898)) [@harrism](https://github.com/harrism) +- Throw `rmm::out_of_memory` when we know for sure ([#894](https://github.com/rapidsai/rmm/pull/894)) [@rongou](https://github.com/rongou) +- Update `conda` recipes for Enhanced Compatibility effort ([#893](https://github.com/rapidsai/rmm/pull/893)) [@ajschmidt8](https://github.com/ajschmidt8) +- Add functions to query the stream of device_uvector and device_scalar ([#887](https://github.com/rapidsai/rmm/pull/887)) [@fkallen](https://github.com/fkallen) +- Add spdlog to install export set ([#886](https://github.com/rapidsai/rmm/pull/886)) [@trxcllnt](https://github.com/trxcllnt) # RMM 21.10.00 (7 Oct 2021) From 8c5ed6aa7bee45c05e2c632f43b7171d790fd546 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 5 Jan 2022 13:23:45 -0500 Subject: [PATCH 030/675] Headers that use `std::thread` now include (#938) Fixes #937 Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Keith Kraus (https://github.com/kkraus14) - Jake Hemstad (https://github.com/jrhemstad) - Conor Hoekstra (https://github.com/codereport) - Rong Ou (https://github.com/rongou) URL: https://github.com/rapidsai/rmm/pull/938 --- include/rmm/mr/device/arena_memory_resource.hpp | 1 + tests/mr/device/arena_mr_tests.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index a44466623..b6f15f36f 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -28,6 +28,7 @@ #include #include #include +#include namespace rmm::mr { diff --git a/tests/mr/device/arena_mr_tests.cpp b/tests/mr/device/arena_mr_tests.cpp index b668a0707..d9499802d 100644 --- a/tests/mr/device/arena_mr_tests.cpp +++ b/tests/mr/device/arena_mr_tests.cpp @@ -28,6 +28,9 @@ #include +#include +#include + namespace rmm::test { namespace { From 5a239d214666dc2c3bc997742f8614956d1df61d Mon Sep 17 00:00:00 2001 From: Victor Lafargue Date: Wed, 5 Jan 2022 19:59:30 +0100 Subject: [PATCH 031/675] Fix for `DeviceBuffer` (#931) `DeviceBuffer` deallocation sometimes fails with a segfault. I wasn't able to create a minimal reproducer for now. However, a possible source for the problem is the way Cython releases the memory. Indeed the DeviceBuffer's `DeviceMemoryResource` appears to be sometimes released before the `device_buffer`. This causes a segfault in the the `device_buffer` deconstructor as the device memory resource pointer is set to null. The code of this PR seems to fix the issue. It makes use of a holder class that seem to allow proper ordering of the class members destructions. Authors: - Victor Lafargue (https://github.com/viclafargue) Approvers: - Ashwin Srinath (https://github.com/shwina) URL: https://github.com/rapidsai/rmm/pull/931 --- python/rmm/_lib/device_buffer.pyx | 5 +++++ python/rmm/tests/test_rmm.py | 27 ++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/python/rmm/_lib/device_buffer.pyx b/python/rmm/_lib/device_buffer.pyx index cbe0bdb33..ece2f911f 100644 --- a/python/rmm/_lib/device_buffer.pyx +++ b/python/rmm/_lib/device_buffer.pyx @@ -37,6 +37,11 @@ from rmm._lib.lib cimport ( from rmm._lib.memory_resource cimport get_current_device_resource +# The DeviceMemoryResource attribute could be released prematurely +# by the gc if the DeviceBuffer is in a reference cycle. Removing +# the tp_clear function with the no_gc_clear decoration prevents that. +# See https://github.com/rapidsai/rmm/pull/931 for details. +@cython.no_gc_clear cdef class DeviceBuffer: def __cinit__(self, *, diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index 96b36017b..c82c306c7 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -492,7 +492,8 @@ def test_rmm_enable_disable_logging(dtype, nelem, alloc, tmpdir): def test_mr_devicebuffer_lifetime(): # Test ensures MR/Stream lifetime is longer than DeviceBuffer. Even if all # references go out of scope - # Create new Pool MR + # It is necessary to verify that it also works when using an upstream : + # here a Pool MR with the current MR as upstream rmm.mr.set_current_device_resource( rmm.mr.PoolMemoryResource(rmm.mr.get_current_device_resource()) ) @@ -691,3 +692,27 @@ def callback(nbytes: int) -> bool: with pytest.raises(MemoryError): rmm.DeviceBuffer(size=int(1e11)) assert retried[0] + + +def test_dev_buf_circle_ref_dealloc(): + rmm.mr.set_current_device_resource(rmm.mr.CudaMemoryResource()) + + dbuf1 = rmm.DeviceBuffer(size=1_000_000) + + # Make dbuf1 part of a reference cycle: + l1 = [dbuf1] + l1.append(l1) + + # due to the reference cycle, the device buffer doesn't actually get + # cleaned up until later, when we invoke `gc.collect()`: + del dbuf1, l1 + + rmm.mr.set_current_device_resource(rmm.mr.CudaMemoryResource()) + + # by now, the only remaining reference to the *original* memory + # resource should be in `dbuf1`. However, the cyclic garbage collector + # will eliminate that reference when it clears the object via its + # `tp_clear` method. Later, when `tp_dealloc` attemps to actually + # deallocate `dbuf1` (which needs the MR alive), a segfault occurs. + + gc.collect() From ea807e8c4fbd9fb6eaf524db1299ed8275f66a90 Mon Sep 17 00:00:00 2001 From: Rong Ou Date: Tue, 11 Jan 2022 20:26:42 -0800 Subject: [PATCH 032/675] Improve the Arena allocator to reduce memory fragmentation (#916) Currently the arena allocator divides GPU memory into a global arena and per-thread arenas. For smaller allocations, a per-thread arena allocates large chunks of memory (superblocks) from the global arena and divides them up for individual allocations. However, when deallocating from another arena (producer/consumer pattern), or when we run out of memory and return everything to the global arena, the superblock boundaries are broken. Overtime, this could cause the memory to get more and more fragmented. This PR makes superblocks concrete objects, not just virtual boundaries, and the only units of exchange between the global arena and per-thread arenas. This should make the allocator more resistant to memory fragmentation, especially for long running processes under constant memory pressure. Other notable changes: * The allocator now allocates a fixed but configurable amount of memory from CUDA. This introduces less fragmentation comparing to growing the pool size gradually. * Switched to C++17 `std::shared_mutex`. * Added a bunch of unit tests. fixes #919 fixes #906 Authors: - Rong Ou (https://github.com/rongou) Approvers: - Jake Hemstad (https://github.com/jrhemstad) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/916 --- .../random_allocations/random_allocations.cpp | 6 +- .../rmm/mr/device/arena_memory_resource.hpp | 145 ++- include/rmm/mr/device/detail/arena.hpp | 1005 +++++++++++------ tests/mr/device/arena_mr_tests.cpp | 528 ++++++++- 4 files changed, 1281 insertions(+), 403 deletions(-) diff --git a/benchmarks/random_allocations/random_allocations.cpp b/benchmarks/random_allocations/random_allocations.cpp index 828561dd1..470442830 100644 --- a/benchmarks/random_allocations/random_allocations.cpp +++ b/benchmarks/random_allocations/random_allocations.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -170,7 +170,9 @@ inline auto make_pool() inline auto make_arena() { - return rmm::mr::make_owning_wrapper(make_cuda()); + auto free = rmm::detail::available_device_memory().first; + constexpr auto reserve{64UL << 20}; // Leave some space for CUDA overhead. + return rmm::mr::make_owning_wrapper(make_cuda(), free - reserve); } inline auto make_binning() diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index b6f15f36f..f1b4e40c4 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,26 +78,21 @@ class arena_memory_resource final : public device_memory_resource { * @brief Construct an `arena_memory_resource`. * * @throws rmm::logic_error if `upstream_mr == nullptr`. - * @throws rmm::logic_error if `initial_size` is neither the default nor aligned to a multiple of - * 256 bytes. - * @throws rmm::logic_error if `maximum_size` is neither the default nor aligned to a multiple of - * 256 bytes. * - * @param upstream_mr The memory resource from which to allocate blocks for the pool - * @param initial_size Minimum size, in bytes, of the initial global arena. Defaults to half of - * the available memory on the current device. - * @param maximum_size Maximum size, in bytes, that the global arena can grow to. Defaults to all - * of the available memory on the current device. + * @param upstream_mr The memory resource from which to allocate blocks for the global arena. + * @param arena_size Size in bytes of the global arena. Defaults to half of the available memory + * on the current device. + * @param dump_log_on_failure If true, dump memory log when running out of memory. */ explicit arena_memory_resource(Upstream* upstream_mr, - std::size_t initial_size = global_arena::default_initial_size, - std::size_t maximum_size = global_arena::default_maximum_size, - bool dump_log_on_failure = false) - : global_arena_{upstream_mr, initial_size, maximum_size}, - dump_log_on_failure_{dump_log_on_failure} + std::optional arena_size = std::nullopt, + bool dump_log_on_failure = false) + : global_arena_{upstream_mr, arena_size}, dump_log_on_failure_{dump_log_on_failure} { if (dump_log_on_failure_) { logger_ = spdlog::basic_logger_mt("arena_memory_dump", "rmm_arena_memory_dump.log"); + // Set the level to `debug` for more detailed output. + logger_->set_level(spdlog::level::info); } } @@ -125,17 +120,15 @@ class arena_memory_resource final : public device_memory_resource { bool supports_get_mem_info() const noexcept override { return false; } private: - using global_arena = detail::arena::global_arena; - using arena = detail::arena::arena; - using read_lock = std::shared_lock; - using write_lock = std::lock_guard; + using global_arena = rmm::mr::detail::arena::global_arena; + using arena = rmm::mr::detail::arena::arena; /** * @brief Allocates memory of size at least `bytes`. * * The returned pointer has at least 256-byte alignment. * - * @throws `std::bad_alloc` if the requested allocation could not be fulfilled. + * @throws `rmm::out_of_memory` if no more memory is available for the requested size. * * @param bytes The size in bytes of the allocation. * @param stream The stream to associate this allocation with. @@ -144,22 +137,43 @@ class arena_memory_resource final : public device_memory_resource { void* do_allocate(std::size_t bytes, cuda_stream_view stream) override { if (bytes <= 0) { return nullptr; } +#ifdef RMM_ARENA_USE_SIZE_CLASSES + bytes = rmm::mr::detail::arena::align_to_size_class(bytes); +#else + bytes = rmm::detail::align_up(bytes, rmm::detail::CUDA_ALLOCATION_ALIGNMENT); +#endif + auto& arena = get_arena(stream); - bytes = detail::arena::align_up(bytes); - auto& arena = get_arena(stream); - void* pointer = arena.allocate(bytes); + { + std::shared_lock lock(mtx_); + void* pointer = arena.allocate(bytes); + if (pointer != nullptr) { return pointer; } + } - if (pointer == nullptr) { - write_lock lock(mtx_); + { + std::unique_lock lock(mtx_); defragment(); - pointer = arena.allocate(bytes); + void* pointer = arena.allocate(bytes); if (pointer == nullptr) { if (dump_log_on_failure_) { dump_memory_log(bytes); } RMM_FAIL("Maximum pool size exceeded", rmm::out_of_memory); } + return pointer; } + } - return pointer; + /** + * @brief Defragment memory by returning all superblocks to the global arena. + */ + void defragment() + { + RMM_CUDA_TRY(cudaDeviceSynchronize()); + for (auto& thread_arena : thread_arenas_) { + thread_arena.second->clean(); + } + for (auto& stream_arena : stream_arenas_) { + stream_arena.second.clean(); + } } /** @@ -167,29 +181,56 @@ class arena_memory_resource final : public device_memory_resource { * * @param ptr Pointer to be deallocated. * @param bytes The size in bytes of the allocation. This must be equal to the - * value of `bytes` that was passed to the `allocate` call that returned `p`. + * value of `bytes` that was passed to the `allocate` call that returned `ptr`. * @param stream Stream on which to perform deallocation. */ void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override { if (ptr == nullptr || bytes <= 0) { return; } +#ifdef RMM_ARENA_USE_SIZE_CLASSES + bytes = rmm::mr::detail::arena::align_to_size_class(bytes); +#else + bytes = rmm::detail::align_up(bytes, rmm::detail::CUDA_ALLOCATION_ALIGNMENT); +#endif + auto& arena = get_arena(stream); + + { + std::shared_lock lock(mtx_); + // If the memory being freed does not belong to the arena, the following will return false. + if (arena.deallocate(ptr, bytes, stream)) { return; } + } + + { + // Since we are returning this memory to another stream, we need to make sure the current + // stream is caught up. + stream.synchronize_no_throw(); - bytes = detail::arena::align_up(bytes); - get_arena(stream).deallocate(ptr, bytes, stream); + std::unique_lock lock(mtx_); + deallocate_from_other_arena(ptr, bytes, stream); + } } /** - * @brief Defragment memory by returning all free blocks to the global arena. + * @brief Deallocate memory pointed to by `ptr` that was allocated in a different arena. + * + * @param ptr Pointer to be deallocated. + * @param bytes The size in bytes of the allocation. This must be equal to the + * value of `bytes` that was passed to the `allocate` call that returned `ptr`. + * @param stream Stream on which to perform deallocation. */ - void defragment() + void deallocate_from_other_arena(void* ptr, std::size_t bytes, cuda_stream_view stream) { - RMM_CUDA_TRY(cudaDeviceSynchronize()); - for (auto& thread_arena : thread_arenas_) { - thread_arena.second->clean(); - } - for (auto& stream_arena : stream_arenas_) { - stream_arena.second.clean(); + if (use_per_thread_arena(stream)) { + for (auto const& thread_arena : thread_arenas_) { + if (thread_arena.second->deallocate(ptr, bytes)) { return; } + } + } else { + for (auto& stream_arena : stream_arenas_) { + if (stream_arena.second.deallocate(ptr, bytes)) { return; } + } } + + if (!global_arena_.deallocate(ptr, bytes)) { RMM_FAIL("allocation not found"); } } /** @@ -213,12 +254,12 @@ class arena_memory_resource final : public device_memory_resource { { auto const thread_id = std::this_thread::get_id(); { - read_lock lock(mtx_); + std::shared_lock lock(map_mtx_); auto const iter = thread_arenas_.find(thread_id); if (iter != thread_arenas_.end()) { return *iter->second; } } { - write_lock lock(mtx_); + std::unique_lock lock(map_mtx_); auto thread_arena = std::make_shared(global_arena_); thread_arenas_.emplace(thread_id, thread_arena); thread_local detail::arena::arena_cleaner cleaner{thread_arena}; @@ -235,12 +276,12 @@ class arena_memory_resource final : public device_memory_resource { { RMM_LOGGING_ASSERT(!use_per_thread_arena(stream)); { - read_lock lock(mtx_); + std::shared_lock lock(map_mtx_); auto const iter = stream_arenas_.find(stream.value()); if (iter != stream_arenas_.end()) { return iter->second; } } { - write_lock lock(mtx_); + std::unique_lock lock(map_mtx_); stream_arenas_.emplace(stream.value(), global_arena_); return stream_arenas_.at(stream.value()); } @@ -269,18 +310,6 @@ class arena_memory_resource final : public device_memory_resource { logger_->info("**************************************************"); logger_->info("Global arena:"); global_arena_.dump_memory_log(logger_); - logger_->info("Per-thread arenas:"); - for (auto const& thread_arena : thread_arenas_) { - logger_->info(" Thread {}:", thread_arena.first); - thread_arena.second->dump_memory_log(logger_); - } - if (!stream_arenas_.empty()) { - logger_->info("Per-stream arenas:"); - for (auto const& stream_arena : stream_arenas_) { - logger_->info(" Stream {}:", static_cast(stream_arena.first)); - stream_arena.second.dump_memory_log(logger_); - } - } logger_->flush(); } @@ -304,11 +333,13 @@ class arena_memory_resource final : public device_memory_resource { /// Implementation note: for small sizes, map is more efficient than unordered_map. std::map stream_arenas_; /// If true, dump memory information to log on allocation failure. - bool dump_log_on_failure_; + bool dump_log_on_failure_{}; /// The logger for memory dump. std::shared_ptr logger_{}; - /// Mutex for read and write locks. - mutable std::shared_timed_mutex mtx_; + /// Mutex for read and write locks on arena maps. + mutable std::shared_mutex map_mtx_; + /// Mutex for shared and unique locks on the mr. + mutable std::shared_mutex mtx_; }; } // namespace rmm::mr diff --git a/include/rmm/mr/device/detail/arena.hpp b/include/rmm/mr/device/detail/arena.hpp index cda5a73ad..c0e5df377 100644 --- a/include/rmm/mr/device/detail/arena.hpp +++ b/include/rmm/mr/device/detail/arena.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -32,216 +33,455 @@ #include #include #include +#include #include -#include namespace rmm::mr::detail::arena { -/// Minimum size of a superblock (256 KiB). -constexpr std::size_t minimum_superblock_size = 1U << 18U; - /** - * @brief Represents a chunk of memory that can be allocated and deallocated. + * @brief Align up to nearest size class. * - * A block bigger than a certain size is called a "superblock". + * @param[in] value value to align. + * @return Return the aligned value. */ -class block { - public: - /** - * @brief Construct a default block. - */ - block() = default; +inline std::size_t align_to_size_class(std::size_t value) noexcept +{ + // See http://jemalloc.net/jemalloc.3.html. + // NOLINTBEGIN(readability-magic-numbers,cppcoreguidelines-avoid-magic-numbers) + static std::array size_classes{ + // clang-format off + // Spacing 256: + 256UL, 512UL, 768UL, 1024UL, 1280UL, 1536UL, 1792UL, 2048UL, + // Spacing 512: + 2560UL, 3072UL, 3584UL, 4096UL, + // Spacing 1 KiB: + 5UL << 10, 6UL << 10, 7UL << 10, 8UL << 10, + // Spacing 2 KiB: + 10UL << 10, 12UL << 10, 14UL << 10, 16UL << 10, + // Spacing 4 KiB: + 20UL << 10, 24UL << 10, 28UL << 10, 32UL << 10, + // Spacing 8 KiB: + 40UL << 10, 48UL << 10, 54UL << 10, 64UL << 10, + // Spacing 16 KiB: + 80UL << 10, 96UL << 10, 112UL << 10, 128UL << 10, + // Spacing 32 KiB: + 160UL << 10, 192UL << 10, 224UL << 10, 256UL << 10, + // Spacing 64 KiB: + 320UL << 10, 384UL << 10, 448UL << 10, 512UL << 10, + // Spacing 128 KiB: + 640UL << 10, 768UL << 10, 896UL << 10, 1UL << 20, + // Spacing 256 KiB: + 1280UL << 10, 1536UL << 10, 1792UL << 10, 2UL << 20, + // Spacing 512 KiB: + 2560UL << 10, 3UL << 20, 3584UL << 10, 4UL << 20, + // Spacing 1 MiB: + 5UL << 20, 6UL << 20, 7UL << 20, 8UL << 20, + // Spacing 2 MiB: + 10UL << 20, 12UL << 20, 14UL << 20, 16UL << 20, + // Spacing 4 MiB: + 20UL << 20, 24UL << 20, 28UL << 20, 32UL << 20, + // Spacing 8 MiB: + 40UL << 20, 48UL << 20, 56UL << 20, 64UL << 20, + // Spacing 16 MiB: + 80UL << 20, 96UL << 20, 112UL << 20, 128UL << 20, + // Spacing 32 MiB: + 160UL << 20, 192UL << 20, 224UL << 20, 256UL << 20, + // Spacing 64 MiB: + 320UL << 20, 384UL << 20, 448UL << 20, 512UL << 20, + // Spacing 128 MiB: + 640UL << 20, 768UL << 20, 896UL << 20, 1UL << 30, + // Spacing 256 MiB: + 1280UL << 20, 1536UL << 20, 1792UL << 20, 2UL << 30, + // Spacing 512 MiB: + 2560UL << 20, 3UL << 30, 3584UL << 20, 4UL << 30, + // Spacing 1 GiB: + 5UL << 30, 6UL << 30, 7UL << 30, 8UL << 30, + // Spacing 2 GiB: + 10UL << 30, 12UL << 30, 14UL << 30, 16UL << 30, + // Spacing 4 GiB: + 20UL << 30, 24UL << 30, 28UL << 30, 32UL << 30, + // Spacing 8 GiB: + 40UL << 30, 48UL << 30, 56UL << 30, 64UL << 30, + // Spacing 16 GiB: + 80UL << 30, 96UL << 30, 112UL << 30, 128UL << 30, + // Spacing 32 Gib: + 160UL << 30, 192UL << 30, 224UL << 30, 256UL << 30, + // Catch all: + std::numeric_limits::max() + // clang-format on + }; + // NOLINTEND(readability-magic-numbers,cppcoreguidelines-avoid-magic-numbers) + + auto* bound = std::lower_bound(size_classes.begin(), size_classes.end(), value); + RMM_LOGGING_ASSERT(bound != size_classes.end()); + return *bound; +} +/** + * @brief Represents a contiguous region of memory. + */ +class byte_span { + public: /** - * @brief Construct a block given a pointer and size. - * - * @param pointer The address for the beginning of the block. - * @param size The size of the block. + * @brief Construct a default span. */ - block(char* pointer, std::size_t size) : pointer_(pointer), size_(size) {} + byte_span() = default; /** - * @brief Construct a block given a void pointer and size. + * @brief Construct a span given a pointer and size. * - * @param pointer The address for the beginning of the block. - * @param size The size of the block. + * @param pointer The address for the beginning of the span. + * @param size The size of the span. */ - block(void* pointer, std::size_t size) : pointer_(static_cast(pointer)), size_(size) {} + byte_span(void* pointer, std::size_t size) : pointer_{static_cast(pointer)}, size_{size} + { + RMM_LOGGING_ASSERT(pointer != nullptr); + RMM_LOGGING_ASSERT(size > 0); + } /// Returns the underlying pointer. - [[nodiscard]] void* pointer() const { return pointer_; } + [[nodiscard]] char* pointer() const { return pointer_; } - /// Returns the size of the block. + /// Returns the size of the span. [[nodiscard]] std::size_t size() const { return size_; } - /// Returns true if this block is valid (non-null), false otherwise. - [[nodiscard]] bool is_valid() const { return pointer_ != nullptr; } + /// Returns the end of the span. + [[nodiscard]] char* end() const + { + return pointer_ + size_; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) + } + + /// Returns true if this span is valid (non-null), false otherwise. + [[nodiscard]] bool is_valid() const { return pointer_ != nullptr && size_ > 0; } + + /// Used by std::set to compare spans. + bool operator<(byte_span const& span) const + { + RMM_LOGGING_ASSERT(span.is_valid()); + return pointer_ < span.pointer_; + } - /// Returns true if this block is a superblock, false otherwise. - [[nodiscard]] bool is_superblock() const { return size_ >= minimum_superblock_size; } + private: + char* pointer_{}; ///< Raw memory pointer. + std::size_t size_{}; ///< Size in bytes. +}; + +/// Calculate the total size of a set of spans. +template +inline auto total_memory_size(std::set const& spans) +{ + return std::accumulate( + spans.cbegin(), spans.cend(), std::size_t{}, [](auto const& lhs, auto const& rhs) { + return lhs + rhs.size(); + }); +} + +/** + * @brief Represents a chunk of memory that can be allocated and deallocated. + */ +class block final : public byte_span { + public: + using byte_span::byte_span; /** - * @brief Verifies whether this block can be merged to the beginning of block b. + * @brief Is this block large enough to fit `bytes` bytes? * - * @param b The block to check for contiguity. - * @return true Returns true if this block's `pointer` + `size` == `b.ptr`, and `not b.is_head`, - false otherwise. + * @param bytes The size in bytes to check for fit. + * @return true if this block is at least `bytes` bytes. */ - [[nodiscard]] bool is_contiguous_before(block const& blk) const + [[nodiscard]] bool fits(std::size_t bytes) const { - // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - return pointer_ + size_ == blk.pointer_; + RMM_LOGGING_ASSERT(is_valid()); + RMM_LOGGING_ASSERT(bytes > 0); + return size() >= bytes; } /** - * @brief Is this block large enough to fit `sz` bytes? + * @brief Verifies whether this block can be merged to the beginning of block blk. * - * @param size The size in bytes to check for fit. - * @return true if this block is at least `sz` bytes. + * @param blk The block to check for contiguity. + * @return true Returns true if this block's `pointer` + `size` == `blk.pointer`. */ - [[nodiscard]] bool fits(std::size_t size) const { return size_ >= size; } + [[nodiscard]] bool is_contiguous_before(block const& blk) const + { + RMM_LOGGING_ASSERT(is_valid()); + RMM_LOGGING_ASSERT(blk.is_valid()); + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + return pointer() + size() == blk.pointer(); + } /** * @brief Split this block into two by the given size. * - * @param size The size in bytes of the first block. - * @return std::pair A pair of blocks split by sz. + * @param bytes The size in bytes of the first block. + * @return std::pair A pair of blocks split by bytes. */ - [[nodiscard]] std::pair split(std::size_t size) const + [[nodiscard]] std::pair split(std::size_t bytes) const { - RMM_LOGGING_ASSERT(size_ >= size); + RMM_LOGGING_ASSERT(is_valid()); + RMM_LOGGING_ASSERT(size() > bytes); // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - if (size_ > size) { return {{pointer_, size}, {pointer_ + size, size_ - size}}; } - return {*this, {}}; + return {{pointer(), bytes}, {pointer() + bytes, size() - bytes}}; } /** * @brief Coalesce two contiguous blocks into one. * - * `this->is_contiguous_before(b)` must be true. + * `this->is_contiguous_before(blk)` must be true. * - * @param b block to merge. + * @param blk block to merge. * @return block The merged block. */ [[nodiscard]] block merge(block const& blk) const { RMM_LOGGING_ASSERT(is_contiguous_before(blk)); - return {pointer_, size_ + blk.size_}; + return {pointer(), size() + blk.size()}; } - - /// Used by std::set to compare blocks. - bool operator<(block const& blk) const { return pointer_ < blk.pointer_; } - - private: - char* pointer_{}; ///< Raw memory pointer. - std::size_t size_{}; ///< Size in bytes. }; -inline bool block_size_compare(block lhs, block rhs) { return lhs.size() < rhs.size(); } - -/** - * @brief Align up to the allocation alignment. - * - * @param[in] v value to align - * @return Return the aligned value - */ -constexpr std::size_t align_up(std::size_t value) noexcept +/// Comparison function for block sizes. +inline bool block_size_compare(block const& lhs, block const& rhs) { - return rmm::detail::align_up(value, rmm::detail::CUDA_ALLOCATION_ALIGNMENT); + RMM_LOGGING_ASSERT(lhs.is_valid()); + RMM_LOGGING_ASSERT(rhs.is_valid()); + return lhs.size() < rhs.size(); } /** - * @brief Align down to the allocation alignment. - * - * @param[in] v value to align - * @return Return the aligned value + * @brief Represents a large chunk of memory that is exchanged between the global arena and + * per-thread arenas. */ -constexpr std::size_t align_down(std::size_t value) noexcept -{ - return rmm::detail::align_down(value, rmm::detail::CUDA_ALLOCATION_ALIGNMENT); -} +class superblock final : public byte_span { + public: + /// Minimum size of a superblock (1 MiB). + static constexpr std::size_t minimum_size{1UL << 20}; + /// Maximum size of a superblock (1 TiB), as a sanity check. + static constexpr std::size_t maximum_size{1UL << 40}; -/** - * @brief Get the first free block of at least `size` bytes. - * - * Address-ordered first-fit has shown to perform slightly better than best-fit when it comes to - * memory fragmentation, and slightly cheaper to implement. It is also used by some popular - * allocators such as jemalloc. - * - * \see Johnstone, M. S., & Wilson, P. R. (1998). The memory fragmentation problem: Solved?. ACM - * Sigplan Notices, 34(3), 26-36. - * - * @param free_blocks The address-ordered set of free blocks. - * @param size The number of bytes to allocate. - * @return block A block of memory of at least `size` bytes, or an empty block if not found. - */ -inline block first_fit(std::set& free_blocks, std::size_t size) -{ - auto fits = [size](auto const& blk) { return blk.fits(size); }; + /** + * @brief Construct a default superblock. + */ + superblock() = default; - auto const iter = std::find_if(free_blocks.cbegin(), free_blocks.cend(), fits); + /** + * @brief Construct a superblock given a pointer and size. + * + * @param pointer The address for the beginning of the superblock. + * @param size The size of the superblock. + */ + superblock(void* pointer, std::size_t size) : byte_span{pointer, size} + { + RMM_LOGGING_ASSERT(size >= minimum_size); + RMM_LOGGING_ASSERT(size <= maximum_size); + free_blocks_.emplace(pointer, size); + } - if (iter == free_blocks.cend()) { return {}; } - // Remove the block from the free_list. - auto const blk = *iter; - auto const next = free_blocks.erase(iter); + // Disable copy semantics. + superblock(superblock const&) = delete; + superblock& operator=(superblock const&) = delete; + // Allow move semantics. + superblock(superblock&&) noexcept = default; + superblock& operator=(superblock&&) noexcept = default; - if (blk.size() > size) { - // Split the block and put the remainder back. - auto const split = blk.split(size); - free_blocks.insert(next, split.second); - return split.first; + ~superblock() = default; + + /** + * @brief Is this superblock empty? + * + * @return true if this superblock is empty. + */ + [[nodiscard]] bool empty() const + { + RMM_LOGGING_ASSERT(is_valid()); + return free_blocks_.size() == 1 && free_blocks_.cbegin()->size() == size(); } - return blk; -} -/** - * @brief Coalesce the given block with other free blocks. - * - * @param free_blocks The address-ordered set of free blocks. - * @param b The block to coalesce. - * @return block The coalesced block. - */ -inline block coalesce_block(std::set& free_blocks, block const& blk) + /** + * @brief Return the number of free blocks. + * + * @return the number of free blocks. + */ + [[nodiscard]] std::size_t free_blocks() const + { + RMM_LOGGING_ASSERT(is_valid()); + return free_blocks_.size(); + } + + /** + * @brief Whether this superblock contains the given block. + * + * @param blk The block to search for. + * @return true if the given block belongs to this superblock. + */ + [[nodiscard]] bool contains(block const& blk) const + { + RMM_LOGGING_ASSERT(is_valid()); + RMM_LOGGING_ASSERT(blk.is_valid()); + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + return pointer() <= blk.pointer() && pointer() + size() >= blk.pointer() + blk.size(); + } + + /** + * @brief Can this superblock fit `bytes` bytes? + * + * @param bytes The size in bytes to check for fit. + * @return true if this superblock can fit `bytes` bytes. + */ + [[nodiscard]] bool fits(std::size_t bytes) const + { + RMM_LOGGING_ASSERT(is_valid()); + return std::any_of(free_blocks_.cbegin(), free_blocks_.cend(), [bytes](auto const& blk) { + return blk.fits(bytes); + }); + } + + /** + * @brief Verifies whether this superblock can be merged to the beginning of superblock s. + * + * @param s The superblock to check for contiguity. + * @return true Returns true if both superblocks are empty and this superblock's + * `pointer` + `size` == `s.ptr`. + */ + [[nodiscard]] bool is_contiguous_before(superblock const& sblk) const + { + RMM_LOGGING_ASSERT(is_valid()); + RMM_LOGGING_ASSERT(sblk.is_valid()); + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + return empty() && sblk.empty() && pointer() + size() == sblk.pointer(); + } + + /** + * @brief Split this superblock into two by the given size. + * + * @param bytes The size in bytes of the first block. + * @return superblock_pair A pair of superblocks split by bytes. + */ + [[nodiscard]] std::pair split(std::size_t bytes) const + { + RMM_LOGGING_ASSERT(is_valid()); + RMM_LOGGING_ASSERT(empty() && bytes >= minimum_size && size() >= bytes + minimum_size); + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + return {superblock{pointer(), bytes}, superblock{pointer() + bytes, size() - bytes}}; + } + + /** + * @brief Coalesce two contiguous superblocks into one. + * + * `this->is_contiguous_before(s)` must be true. + * + * @param sblk superblock to merge. + * @return block The merged block. + */ + [[nodiscard]] superblock merge(superblock const& sblk) const + { + RMM_LOGGING_ASSERT(is_contiguous_before(sblk)); + return {pointer(), size() + sblk.size()}; + } + + /** + * @brief Get the first free block of at least `size` bytes. + * + * @param size The number of bytes to allocate. + * @return block A block of memory of at least `size` bytes, or an empty block if not found. + */ + block first_fit(std::size_t size) + { + RMM_LOGGING_ASSERT(is_valid()); + RMM_LOGGING_ASSERT(size > 0); + + auto fits = [size](auto const& blk) { return blk.fits(size); }; + auto const iter = std::find_if(free_blocks_.cbegin(), free_blocks_.cend(), fits); + if (iter == free_blocks_.cend()) { return {}; } + + // Remove the block from the free list. + auto const blk = *iter; + auto const next = free_blocks_.erase(iter); + + if (blk.size() > size) { + // Split the block and put the remainder back. + auto const split = blk.split(size); + free_blocks_.insert(next, split.second); + return split.first; + } + return blk; + } + + /** + * @brief Coalesce the given block with other free blocks. + * + * @param blk The block to coalesce. + */ + void coalesce(block const& blk) // NOLINT(readability-function-cognitive-complexity) + { + RMM_LOGGING_ASSERT(is_valid()); + RMM_LOGGING_ASSERT(blk.is_valid()); + RMM_LOGGING_ASSERT(contains(blk)); + + // Find the right place (in ascending address order) to insert the block. + auto const next = free_blocks_.lower_bound(blk); + auto const previous = next == free_blocks_.cbegin() ? next : std::prev(next); + + // Coalesce with neighboring blocks. + bool const merge_prev = previous != free_blocks_.cend() && previous->is_contiguous_before(blk); + bool const merge_next = next != free_blocks_.cend() && blk.is_contiguous_before(*next); + + if (merge_prev && merge_next) { + auto const merged = previous->merge(blk).merge(*next); + free_blocks_.erase(previous); + auto const iter = free_blocks_.erase(next); + free_blocks_.insert(iter, merged); + } else if (merge_prev) { + auto const merged = previous->merge(blk); + auto const iter = free_blocks_.erase(previous); + free_blocks_.insert(iter, merged); + } else if (merge_next) { + auto const merged = blk.merge(*next); + auto const iter = free_blocks_.erase(next); + free_blocks_.insert(iter, merged); + } else { + free_blocks_.insert(next, blk); + } + } + + /** + * @brief Find the total free block size. + * @return the total free block size. + */ + [[nodiscard]] std::size_t total_free_size() const { return total_memory_size(free_blocks_); } + + /** + * @brief Find the max free block size. + * @return the max free block size. + */ + [[nodiscard]] std::size_t max_free_size() const + { + if (free_blocks_.empty()) { return 0; } + return std::max_element(free_blocks_.cbegin(), free_blocks_.cend(), block_size_compare)->size(); + } + + private: + /// Address-ordered set of free blocks. + std::set free_blocks_{}; +}; + +/// Calculate the total free size of a set of superblocks. +inline auto total_free_size(std::set const& superblocks) { - if (!blk.is_valid()) { return blk; } - - // Find the right place (in ascending address order) to insert the block. - auto const next = free_blocks.lower_bound(blk); - auto const previous = next == free_blocks.cbegin() ? next : std::prev(next); - - // Coalesce with neighboring blocks. - bool const merge_prev = previous->is_contiguous_before(blk); - bool const merge_next = next != free_blocks.cend() && blk.is_contiguous_before(*next); - - block merged{}; - if (merge_prev && merge_next) { - merged = previous->merge(blk).merge(*next); - free_blocks.erase(previous); - auto const iter = free_blocks.erase(next); - free_blocks.insert(iter, merged); - } else if (merge_prev) { - merged = previous->merge(blk); - auto const iter = free_blocks.erase(previous); - free_blocks.insert(iter, merged); - } else if (merge_next) { - merged = blk.merge(*next); - auto const iter = free_blocks.erase(next); - free_blocks.insert(iter, merged); - } else { - free_blocks.emplace(blk); - merged = blk; - } - return merged; + return std::accumulate( + superblocks.cbegin(), superblocks.cend(), std::size_t{}, [](auto const& lhs, auto const& rhs) { + return lhs + rhs.total_free_size(); + }); } -template -inline auto total_block_size(T const& blocks) +/// Find the max free size from a set of superblocks. +inline auto max_free_size(std::set const& superblocks) { - return std::accumulate(blocks.cbegin(), blocks.cend(), std::size_t{}, [](auto lhs, auto rhs) { - return lhs + rhs.size(); - }); -} + std::size_t size{}; + for (auto const& sblk : superblocks) { + size = std::max(size, sblk.max_free_size()); + } + return size; +}; /** * @brief The global arena for allocating memory from the upstream memory resource. @@ -254,51 +494,24 @@ inline auto total_block_size(T const& blocks) template class global_arena final { public: - /// The default initial size for the global arena. - static constexpr std::size_t default_initial_size = std::numeric_limits::max(); - /// The default maximum size for the global arena. - static constexpr std::size_t default_maximum_size = std::numeric_limits::max(); - /// Reserved memory that should not be allocated (64 MiB). - static constexpr std::size_t reserved_size = 1U << 26U; - /** * @brief Construct a global arena. * * @throws rmm::logic_error if `upstream_mr == nullptr`. - * @throws rmm::logic_error if `initial_size` is neither the default nor aligned to a multiple of - * 256 bytes. - * @throws rmm::logic_error if `maximum_size` is neither the default nor aligned to a multiple of - * 256 bytes. * * @param upstream_mr The memory resource from which to allocate blocks for the pool - * @param initial_size Minimum size, in bytes, of the initial global arena. Defaults to half of - * the available memory on the current device. - * @param maximum_size Maximum size, in bytes, that the global arena can grow to. Defaults to all - * of the available memory on the current device. + * @param arena_size Size in bytes of the global arena. Defaults to half of the available memory + * on the current device. */ - global_arena(Upstream* upstream_mr, std::size_t initial_size, std::size_t maximum_size) - : upstream_mr_{upstream_mr}, maximum_size_{maximum_size} + global_arena(Upstream* upstream_mr, std::optional arena_size) + : upstream_mr_{upstream_mr} { RMM_EXPECTS(nullptr != upstream_mr_, "Unexpected null upstream pointer."); - RMM_EXPECTS(initial_size == default_initial_size || initial_size == align_up(initial_size), - "Error, Initial arena size required to be a multiple of 256 bytes"); - RMM_EXPECTS(maximum_size_ == default_maximum_size || maximum_size_ == align_up(maximum_size_), - "Error, Maximum arena size required to be a multiple of 256 bytes"); - - if (initial_size == default_initial_size || maximum_size == default_maximum_size) { - std::size_t free{}; - std::size_t total{}; - RMM_CUDA_TRY(cudaMemGetInfo(&free, &total)); - if (initial_size == default_initial_size) { - initial_size = align_up(std::min(free, total / 2)); - } - if (maximum_size_ == default_maximum_size) { - maximum_size_ = align_down(free) - reserved_size; - } - } - RMM_EXPECTS(initial_size <= maximum_size_, "Initial arena size exceeds the maximum pool size!"); - - free_blocks_.emplace(expand_arena(initial_size)); + auto const size = rmm::detail::align_down(arena_size.value_or(default_size()), + rmm::detail::CUDA_ALLOCATION_ALIGNMENT); + RMM_EXPECTS(size >= superblock::minimum_size, + "Arena size smaller than minimum superblock size."); + initialize(size); } // Disable copy (and move) semantics. @@ -313,48 +526,120 @@ class global_arena final { */ ~global_arena() { - lock_guard lock(mtx_); - for (auto const& blk : upstream_blocks_) { - upstream_mr_->deallocate(blk.pointer(), blk.size()); - } + std::lock_guard lock(mtx_); + upstream_mr_->deallocate(upstream_block_.pointer(), upstream_block_.size()); + } + + /** + * @brief Should allocation of `size` bytes be handled by the global arena directly? + * + * @param size The size in bytes of the allocation. + * @return bool True if the allocation should be handled by the global arena. + */ + bool handles(std::size_t size) const { return size > superblock::minimum_size; } + + /** + * @brief Acquire a superblock that can fit a block of the given size. + * + * @param size The size in bytes of the allocation. + * @return superblock The acquired superblock. + */ + superblock acquire(std::size_t size) + { + // Superblocks should only be acquired if the size is not directly handled by the global arena. + RMM_LOGGING_ASSERT(!handles(size)); + std::lock_guard lock(mtx_); + return first_fit(size); + } + + /** + * @brief Release a superblock. + * + * @param s Superblock to be released. + */ + void release(superblock&& sblk) + { + RMM_LOGGING_ASSERT(sblk.is_valid()); + std::lock_guard lock(mtx_); + coalesce(std::move(sblk)); } /** - * @brief Allocates memory of size at least `bytes`. + * @brief Release a set of superblocks from a dying arena. * - * @throws `std::bad_alloc` if the requested allocation could not be fulfilled. + * @param superblocks The set of superblocks. + */ + void release(std::set& superblocks) + { + std::lock_guard lock(mtx_); + while (!superblocks.empty()) { + auto sblk = std::move(superblocks.extract(superblocks.cbegin()).value()); + RMM_LOGGING_ASSERT(sblk.is_valid()); + coalesce(std::move(sblk)); + } + } + + /** + * @brief Allocate a large block directly. * - * @param bytes The size in bytes of the allocation. + * @param size The size in bytes of the allocation. * @return void* Pointer to the newly allocated memory. */ - block allocate(std::size_t bytes) + void* allocate(std::size_t size) { - lock_guard lock(mtx_); - return get_block(bytes); + RMM_LOGGING_ASSERT(handles(size)); + std::lock_guard lock(mtx_); + auto sblk = first_fit(size); + if (sblk.is_valid()) { + auto blk = sblk.first_fit(size); + superblocks_.insert(std::move(sblk)); + return blk.pointer(); + } + return nullptr; } /** - * @brief Deallocate memory pointed to by `blk`. + * @brief Deallocate memory pointed to by `ptr`. * - * @param blk Block to be deallocated. + * @param ptr Pointer to be deallocated. + * @param size The size in bytes of the allocation. This must be equal to the value of `size` + * that was passed to the `allocate` call that returned `p`. + * @param stream Stream on which to perform deallocation. + * @return bool true if the allocation is found, false otherwise. */ - void deallocate(block const& blk) + bool deallocate(void* ptr, std::size_t size, cuda_stream_view stream) { - lock_guard lock(mtx_); - coalesce_block(free_blocks_, blk); + RMM_LOGGING_ASSERT(handles(size)); + stream.synchronize_no_throw(); + return deallocate(ptr, size); } /** - * @brief Deallocate a set of free blocks from a dying arena. + * @brief Deallocate memory pointed to by `ptr`. * - * @param free_blocks The set of free blocks. + * @param ptr Pointer to be deallocated. + * @param bytes The size in bytes of the allocation. This must be equal to the + * value of `bytes` that was passed to the `allocate` call that returned `ptr`. + * @return bool true if the allocation is found, false otherwise. */ - void deallocate(std::set const& free_blocks) + bool deallocate(void* ptr, std::size_t bytes) { - lock_guard lock(mtx_); - for (auto const& blk : free_blocks) { - coalesce_block(free_blocks_, blk); + std::lock_guard lock(mtx_); + + block const blk{ptr, bytes}; + auto const iter = std::find_if(superblocks_.cbegin(), + superblocks_.cend(), + [&](auto const& sblk) { return sblk.contains(blk); }); + if (iter == superblocks_.cend()) { return false; } + + auto sblk = std::move(superblocks_.extract(iter).value()); + sblk.coalesce(blk); + if (sblk.empty()) { + coalesce(std::move(sblk)); + } else { + superblocks_.insert(std::move(sblk)); } + return true; } /** @@ -364,86 +649,136 @@ class global_arena final { */ void dump_memory_log(std::shared_ptr const& logger) const { - lock_guard lock(mtx_); - - logger->info(" Maximum size: {}", rmm::detail::bytes{maximum_size_}); - logger->info(" Current size: {}", rmm::detail::bytes{current_size_}); - - logger->info(" # free blocks: {}", free_blocks_.size()); - if (!free_blocks_.empty()) { - logger->info(" Total size of free blocks: {}", - rmm::detail::bytes{total_block_size(free_blocks_)}); - auto const largest_free = - *std::max_element(free_blocks_.begin(), free_blocks_.end(), block_size_compare); - logger->info(" Size of largest free block: {}", rmm::detail::bytes{largest_free.size()}); + std::lock_guard lock(mtx_); + + logger->info(" Arena size: {}", rmm::detail::bytes{upstream_block_.size()}); + logger->info(" # superblocks: {}", superblocks_.size()); + if (!superblocks_.empty()) { + logger->debug(" Total size of superblocks: {}", + rmm::detail::bytes{total_memory_size(superblocks_)}); + auto const total_free = total_free_size(superblocks_); + auto const max_free = max_free_size(superblocks_); + auto const fragmentation = (1 - max_free / static_cast(total_free)) * 100; + logger->info(" Total free memory: {}", rmm::detail::bytes{total_free}); + logger->info(" Largest block of free memory: {}", rmm::detail::bytes{max_free}); + logger->info(" Fragmentation: {:.2f}%", fragmentation); + + auto index = 0; + char* prev_end{}; + for (auto const& sblk : superblocks_) { + if (prev_end == nullptr) { prev_end = sblk.pointer(); } + logger->debug( + " Superblock {}: start={}, end={}, size={}, empty={}, # free blocks={}, max free={}, " + "gap={}", + index, + fmt::ptr(sblk.pointer()), + fmt::ptr(sblk.end()), + rmm::detail::bytes{sblk.size()}, + sblk.empty(), + sblk.free_blocks(), + rmm::detail::bytes{sblk.max_free_size()}, + rmm::detail::bytes{static_cast(sblk.pointer() - prev_end)}); + prev_end = sblk.end(); + index++; + } } - - logger->info(" # upstream blocks={}", upstream_blocks_.size()); - logger->info(" Total size of upstream blocks: {}", - rmm::detail::bytes{total_block_size(upstream_blocks_)}); } private: - using lock_guard = std::lock_guard; + /** + * @brief Default size of the global arena if unspecified. + * @return the default global arena size. + */ + constexpr std::size_t default_size() const + { + auto const [free, total] = rmm::detail::available_device_memory(); + return free / 2; + } /** - * @brief Get an available memory block of at least `size` bytes. + * @brief Allocate space from upstream to initialize the arena. * - * @param size The number of bytes to allocate. - * @return block A block of memory of at least `size` bytes. + * @param size The size to allocate. */ - block get_block(std::size_t size) + void initialize(std::size_t size) { - // Find the first-fit free block. - auto const blk = first_fit(free_blocks_, size); - if (blk.is_valid()) { return blk; } - - // No existing larger blocks available, so grow the arena. - auto const upstream_block = expand_arena(size_to_grow(size)); - coalesce_block(free_blocks_, upstream_block); - return first_fit(free_blocks_, size); + upstream_block_ = {upstream_mr_->allocate(size), size}; + superblocks_.emplace(upstream_block_.pointer(), size); } /** - * @brief Get the size to grow the global arena given the requested `size` bytes. + * @brief Get the first superblock that can fit a block of at least `size` bytes. + * + * Address-ordered first-fit has shown to perform slightly better than best-fit when it comes to + * memory fragmentation, and slightly cheaper to implement. It is also used by some popular + * allocators such as jemalloc. * - * This simply grows the global arena to the maximum size. + * \see Johnstone, M. S., & Wilson, P. R. (1998). The memory fragmentation problem: Solved?. ACM + * Sigplan Notices, 34(3), 26-36. * - * @param size The number of bytes required. - * @return size The size for the arena to grow, or 0 if no more memory. + * @param size The number of bytes to allocate. + * @param minimum_size The minimum size of the superblock required. + * @return superblock A superblock that can fit at least `size` bytes, or empty if not found. */ - constexpr std::size_t size_to_grow(std::size_t size) const + superblock first_fit(std::size_t size) { - if (current_size_ + size > maximum_size_) { return 0; } - return maximum_size_ - current_size_; + auto const iter = std::find_if(superblocks_.cbegin(), + superblocks_.cend(), + [=](auto const& sblk) { return sblk.fits(size); }); + if (iter == superblocks_.cend()) { return {}; } + + auto sblk = std::move(superblocks_.extract(iter).value()); + auto const min_size = std::max(superblock::minimum_size, size); + if (sblk.empty() && sblk.size() >= min_size + superblock::minimum_size) { + // Split the superblock and put the remainder back. + auto [head, tail] = sblk.split(min_size); + superblocks_.insert(std::move(tail)); + return std::move(head); + } + return sblk; } /** - * @brief Allocate space from upstream to supply the arena and return a sufficiently sized block. + * @brief Coalesce the given superblock with other empty superblocks. * - * @param size The minimum size to allocate. - * @return block A block of at least `size` bytes. + * @param sblk The superblock to coalesce. */ - block expand_arena(std::size_t size) + void coalesce(superblock&& sblk) { - if (size > 0) { - upstream_blocks_.push_back({upstream_mr_->allocate(size), size}); - current_size_ += size; - return upstream_blocks_.back(); + RMM_LOGGING_ASSERT(sblk.is_valid()); + + // Find the right place (in ascending address order) to insert the block. + auto const next = superblocks_.lower_bound(sblk); + auto const previous = next == superblocks_.cbegin() ? next : std::prev(next); + + // Coalesce with neighboring blocks. + bool const merge_prev = previous != superblocks_.cend() && previous->is_contiguous_before(sblk); + bool const merge_next = next != superblocks_.cend() && sblk.is_contiguous_before(*next); + + if (merge_prev && merge_next) { + auto prev_sb = std::move(superblocks_.extract(previous).value()); + auto next_sb = std::move(superblocks_.extract(next).value()); + auto merged = prev_sb.merge(sblk).merge(next_sb); + superblocks_.insert(std::move(merged)); + } else if (merge_prev) { + auto prev_sb = std::move(superblocks_.extract(previous).value()); + auto merged = prev_sb.merge(sblk); + superblocks_.insert(std::move(merged)); + } else if (merge_next) { + auto next_sb = std::move(superblocks_.extract(next).value()); + auto merged = sblk.merge(next_sb); + superblocks_.insert(std::move(merged)); + } else { + superblocks_.insert(std::move(sblk)); } - return {}; } /// The upstream resource to allocate memory from. Upstream* upstream_mr_; - /// The maximum size the global arena can grow to. - std::size_t maximum_size_; - /// The current size of the global arena. - std::size_t current_size_{}; - /// Address-ordered set of free blocks. - std::set free_blocks_; - /// Blocks allocated from upstream so that they can be quickly freed. - std::vector upstream_blocks_; + /// Block allocated from upstream so that it can be quickly freed. + block upstream_block_; + /// Address-ordered set of superblocks. + std::set superblocks_; /// Mutex for exclusive lock. mutable std::mutex mtx_; }; @@ -452,7 +787,7 @@ class global_arena final { * @brief An arena for allocating memory for a thread. * * An arena is a per-thread or per-non-default-stream memory pool. It allocates - * superblocks from the global arena, and return them when the superblocks become empty. + * superblocks from the global arena, and returns them when the superblocks become empty. * * @tparam Upstream Memory resource to use for allocating the global arena. Implements * rmm::mr::device_memory_resource interface. @@ -467,78 +802,81 @@ class arena { */ explicit arena(global_arena& global_arena) : global_arena_{global_arena} {} - ~arena() = default; - // Disable copy (and move) semantics. arena(arena const&) = delete; arena& operator=(arena const&) = delete; arena(arena&&) noexcept = delete; arena& operator=(arena&&) noexcept = delete; + ~arena() = default; + /** - * @brief Allocates memory of size at least `bytes`. - * - * @throws `std::bad_alloc` if the requested allocation could not be fulfilled. + * @brief Allocates memory of size at least `size` bytes. * - * @param bytes The size in bytes of the allocation. + * @param size The size in bytes of the allocation. * @return void* Pointer to the newly allocated memory. */ - void* allocate(std::size_t bytes) + void* allocate(std::size_t size) { - lock_guard lock(mtx_); - auto const blk = get_block(bytes); - return blk.pointer(); + if (global_arena_.handles(size)) { return global_arena_.allocate(size); } + std::lock_guard lock(mtx_); + return get_block(size).pointer(); } /** * @brief Deallocate memory pointed to by `ptr`, and possibly return superblocks to upstream. * * @param ptr Pointer to be deallocated. - * @param bytes The size in bytes of the allocation. This must be equal to the value of `bytes` + * @param size The size in bytes of the allocation. This must be equal to the value of `size` * that was passed to the `allocate` call that returned `p`. * @param stream Stream on which to perform deallocation. + * @return bool true if the allocation is found, false otherwise. */ - void deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) + bool deallocate(void* ptr, std::size_t size, cuda_stream_view stream) { - lock_guard lock(mtx_); - block const blk{ptr, bytes}; - auto const merged = coalesce_block(free_blocks_, blk); - shrink_arena(merged, stream); + if (global_arena_.handles(size) && global_arena_.deallocate(ptr, size, stream)) { return true; } + return deallocate(ptr, size); } /** - * @brief Clean the arena and deallocate free blocks from the global arena. + * @brief Deallocate memory pointed to by `ptr`, and possibly return superblocks to upstream. + * + * @param ptr Pointer to be deallocated. + * @param size The size in bytes of the allocation. This must be equal to the value of `size` + * that was passed to the `allocate` call that returned `p`. + * @return bool true if the allocation is found, false otherwise. + */ + bool deallocate(void* ptr, std::size_t size) + { + std::lock_guard lock(mtx_); + return deallocate_from_superblock({ptr, size}); + } + + /** + * @brief Clean the arena and release all superblocks to the global arena. */ void clean() { - lock_guard lock(mtx_); - global_arena_.deallocate(free_blocks_); - free_blocks_.clear(); + std::lock_guard lock(mtx_); + global_arena_.release(superblocks_); + superblocks_.clear(); } /** - * Dump memory to log. - * - * @param logger the spdlog logger to use + * @brief Defragment the arena and release empty superblock to the global arena. */ - void dump_memory_log(std::shared_ptr const& logger) const + void defragment() { - lock_guard lock(mtx_); - logger->info(" # free blocks: {}", free_blocks_.size()); - if (!free_blocks_.empty()) { - logger->info(" Total size of free blocks: {}", - rmm::detail::bytes{total_block_size(free_blocks_)}); - auto const largest_free = - *std::max_element(free_blocks_.begin(), free_blocks_.end(), block_size_compare); - logger->info(" Size of largest free block: {}", rmm::detail::bytes{largest_free.size()}); + std::lock_guard lock(mtx_); + while (true) { + auto const iter = std::find_if( + superblocks_.cbegin(), superblocks_.cend(), [](auto const& sblk) { return sblk.empty(); }); + if (iter == superblocks_.cend()) { return; } + global_arena_.release(std::move(superblocks_.extract(iter).value())); } } private: - using lock_guard = std::lock_guard; - /// Maximum number of free blocks to keep. - static constexpr int max_free_blocks = 16; - /** * @brief Get an available memory block of at least `size` bytes. * @@ -547,51 +885,82 @@ class arena { */ block get_block(std::size_t size) { - if (size < minimum_superblock_size) { - // Find the first-fit free block. - auto const blk = first_fit(free_blocks_, size); - if (blk.is_valid()) { return blk; } - } + // Find the first-fit free block. + auto const blk = first_fit(size); + if (blk.is_valid()) { return blk; } // No existing larger blocks available, so grow the arena and obtain a superblock. - auto const superblock = expand_arena(size); - if (superblock.is_valid()) { - coalesce_block(free_blocks_, superblock); - return first_fit(free_blocks_, size); - } - return superblock; + return expand_arena(size); } /** - * @brief Allocate space from upstream to supply the arena and return a superblock. + * @brief Get the first free block of at least `size` bytes. * - * @return A superblock. + * Address-ordered first-fit has shown to perform slightly better than best-fit when it comes to + * memory fragmentation, and slightly cheaper to implement. It is also used by some popular + * allocators such as jemalloc. + * + * \see Johnstone, M. S., & Wilson, P. R. (1998). The memory fragmentation problem: Solved?. ACM + * Sigplan Notices, 34(3), 26-36. + * + * @param size The number of bytes to allocate. + * @return block A block of memory of at least `size` bytes, or an empty block if not found. */ - block expand_arena(std::size_t size) + block first_fit(std::size_t size) + { + auto const iter = std::find_if(superblocks_.cbegin(), + superblocks_.cend(), + [size](auto const& sblk) { return sblk.fits(size); }); + if (iter == superblocks_.cend()) { return {}; } + + auto sblk = std::move(superblocks_.extract(iter).value()); + auto const blk = sblk.first_fit(size); + superblocks_.insert(std::move(sblk)); + return blk; + } + + /** + * @brief Deallocate a block from the superblock it belongs to. + * + * @param blk The block to deallocate. + * @param stream The stream to use for deallocation. + * @return true if the block is found. + */ + bool deallocate_from_superblock(block const& blk) { - auto const superblock_size = std::max(size, minimum_superblock_size); - return global_arena_.allocate(superblock_size); + auto const iter = std::find_if(superblocks_.cbegin(), + superblocks_.cend(), + [&](auto const& sblk) { return sblk.contains(blk); }); + if (iter == superblocks_.cend()) { return false; } + + auto sblk = std::move(superblocks_.extract(iter).value()); + sblk.coalesce(blk); + superblocks_.insert(std::move(sblk)); + return true; } /** - * @brief Shrink this arena by returning free superblocks to upstream. + * @brief Allocate space from upstream to supply the arena and return a block. * - * @param blk The block that can be used to shrink the arena. - * @param stream Stream on which to perform shrinking. + * @param size The number of bytes to allocate. + * @return block A block of memory of at least `size` bytes. */ - void shrink_arena(block const& blk, cuda_stream_view stream) + block expand_arena(std::size_t size) { - if (blk.is_superblock() || free_blocks_.size() > max_free_blocks) { - stream.synchronize_no_throw(); - global_arena_.deallocate(blk); - free_blocks_.erase(blk); + auto sblk = global_arena_.acquire(size); + if (sblk.is_valid()) { + RMM_LOGGING_ASSERT(sblk.size() >= superblock::minimum_size); + auto const blk = sblk.first_fit(size); + superblocks_.insert(std::move(sblk)); + return blk; } + return {}; } /// The global arena to allocate superblocks from. global_arena& global_arena_; - /// Free blocks. - std::set free_blocks_; + /// Acquired superblocks. + std::set superblocks_; /// Mutex for exclusive lock. mutable std::mutex mtx_; }; diff --git a/tests/mr/device/arena_mr_tests.cpp b/tests/mr/device/arena_mr_tests.cpp index d9499802d..b86e2457c 100644 --- a/tests/mr/device/arena_mr_tests.cpp +++ b/tests/mr/device/arena_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,51 +15,527 @@ */ #include "../../byte_literals.hpp" -#include "rmm/cuda_stream_view.hpp" - -#include - +#include +#include +#include #include #include -#include +#include #include +#include #include +#include #include #include #include namespace rmm::test { - namespace { -using cuda_mr = rmm::mr::cuda_memory_resource; -using arena_mr = rmm::mr::arena_memory_resource; -TEST(ArenaTest, ThrowOnNullUpstream) +class mock_memory_resource { + public: + MOCK_METHOD(void*, allocate, (std::size_t)); + MOCK_METHOD(void, deallocate, (void*, std::size_t)); +}; + +using rmm::mr::detail::arena::block; +using rmm::mr::detail::arena::byte_span; +using rmm::mr::detail::arena::superblock; +using global_arena = rmm::mr::detail::arena::global_arena; +using arena = rmm::mr::detail::arena::arena; +using arena_mr = rmm::mr::arena_memory_resource; +using ::testing::Return; + +// NOLINTBEGIN(cppcoreguidelines-pro-type-reinterpret-cast,performance-no-int-to-ptr) +auto const fake_address = reinterpret_cast(1_KiB); +auto const fake_address2 = reinterpret_cast(2_KiB); +auto const fake_address3 = reinterpret_cast(superblock::minimum_size); +auto const fake_address4 = reinterpret_cast(superblock::minimum_size * 2); +// NOLINTEND(cppcoreguidelines-pro-type-reinterpret-cast,performance-no-int-to-ptr) + +struct ArenaTest : public ::testing::Test { + void SetUp() override + { + EXPECT_CALL(mock_mr, allocate(arena_size)).WillOnce(Return(fake_address3)); + EXPECT_CALL(mock_mr, deallocate(fake_address3, arena_size)); + global = std::make_unique(&mock_mr, arena_size); + per_thread = std::make_unique(*global); + } + + std::size_t arena_size{superblock::minimum_size * 4}; + mock_memory_resource mock_mr{}; + std::unique_ptr global{}; + std::unique_ptr per_thread{}; +}; + +/** + * Test align_to_size_class. + */ +TEST_F(ArenaTest, AlignToSizeClass) // NOLINT +{ + using rmm::mr::detail::arena::align_to_size_class; + EXPECT_EQ(align_to_size_class(8), 256); + EXPECT_EQ(align_to_size_class(256), 256); + EXPECT_EQ(align_to_size_class(264), 512); + EXPECT_EQ(align_to_size_class(512), 512); + EXPECT_EQ(align_to_size_class(17_KiB), 20_KiB); + EXPECT_EQ(align_to_size_class(13_MiB), 14_MiB); + EXPECT_EQ(align_to_size_class(2500_MiB), 2560_MiB); + EXPECT_EQ(align_to_size_class(128_GiB), 128_GiB); + EXPECT_EQ(align_to_size_class(1_PiB), std::numeric_limits::max()); +} + +/** + * Test byte_span. + */ + +TEST_F(ArenaTest, ByteSpan) // NOLINT +{ + byte_span const span{}; + EXPECT_FALSE(span.is_valid()); + byte_span const span2{fake_address, 256}; + EXPECT_TRUE(span2.is_valid()); +} + +/** + * Test block. + */ + +TEST_F(ArenaTest, BlockFits) // NOLINT +{ + block const blk{fake_address, 1_KiB}; + EXPECT_TRUE(blk.fits(1_KiB)); + EXPECT_FALSE(blk.fits(1_KiB + 1)); +} + +TEST_F(ArenaTest, BlockIsContiguousBefore) // NOLINT +{ + block const blk{fake_address, 1_KiB}; + block const blk2{fake_address2, 256}; + EXPECT_TRUE(blk.is_contiguous_before(blk2)); + block const blk3{fake_address, 512}; + block const blk4{fake_address2, 1_KiB}; + EXPECT_FALSE(blk3.is_contiguous_before(blk4)); +} + +TEST_F(ArenaTest, BlockSplit) // NOLINT +{ + block const blk{fake_address, 2_KiB}; + auto const [head, tail] = blk.split(1_KiB); + EXPECT_EQ(head.pointer(), fake_address); + EXPECT_EQ(head.size(), 1_KiB); + EXPECT_EQ(tail.pointer(), fake_address2); + EXPECT_EQ(tail.size(), 1_KiB); +} + +TEST_F(ArenaTest, BlockMerge) // NOLINT +{ + block const blk{fake_address, 1_KiB}; + block const blk2{fake_address2, 1_KiB}; + auto const merged = blk.merge(blk2); + EXPECT_EQ(merged.pointer(), fake_address); + EXPECT_EQ(merged.size(), 2_KiB); +} + +/** + * Test superblock. + */ + +TEST_F(ArenaTest, SuperblockEmpty) // NOLINT +{ + superblock sblk{fake_address3, superblock::minimum_size}; + EXPECT_TRUE(sblk.empty()); + sblk.first_fit(256); + EXPECT_FALSE(sblk.empty()); +} + +TEST_F(ArenaTest, SuperblockContains) // NOLINT +{ + superblock const sblk{fake_address3, superblock::minimum_size}; + block const blk{fake_address, 2_KiB}; + EXPECT_FALSE(sblk.contains(blk)); + block const blk2{fake_address3, 1_KiB}; + EXPECT_TRUE(sblk.contains(blk2)); + block const blk3{fake_address3, superblock::minimum_size + 1}; + EXPECT_FALSE(sblk.contains(blk3)); + block const blk4{fake_address3, superblock::minimum_size}; + EXPECT_TRUE(sblk.contains(blk4)); + block const blk5{fake_address4, 256}; + EXPECT_FALSE(sblk.contains(blk5)); +} + +TEST_F(ArenaTest, SuperblockFits) // NOLINT +{ + superblock sblk{fake_address3, superblock::minimum_size}; + EXPECT_TRUE(sblk.fits(superblock::minimum_size)); + EXPECT_FALSE(sblk.fits(superblock::minimum_size + 1)); + + auto const blk = sblk.first_fit(superblock::minimum_size / 4); + sblk.first_fit(superblock::minimum_size / 4); + sblk.coalesce(blk); + EXPECT_TRUE(sblk.fits(superblock::minimum_size / 2)); + EXPECT_FALSE(sblk.fits(superblock::minimum_size / 2 + 1)); +} + +TEST_F(ArenaTest, SuperblockIsContiguousBefore) // NOLINT +{ + superblock sblk{fake_address3, superblock::minimum_size}; + superblock sb2{fake_address4, superblock::minimum_size}; + EXPECT_TRUE(sblk.is_contiguous_before(sb2)); + + auto const blk = sblk.first_fit(256); + EXPECT_FALSE(sblk.is_contiguous_before(sb2)); + sblk.coalesce(blk); + EXPECT_TRUE(sblk.is_contiguous_before(sb2)); + + auto const blk2 = sb2.first_fit(1_KiB); + EXPECT_FALSE(sblk.is_contiguous_before(sb2)); + sb2.coalesce(blk2); + EXPECT_TRUE(sblk.is_contiguous_before(sb2)); +} + +TEST_F(ArenaTest, SuperblockSplit) // NOLINT +{ + superblock sblk{fake_address3, superblock::minimum_size * 2}; + auto const [head, tail] = sblk.split(superblock::minimum_size); + EXPECT_EQ(head.pointer(), fake_address3); + EXPECT_EQ(head.size(), superblock::minimum_size); + EXPECT_TRUE(head.empty()); + EXPECT_EQ(tail.pointer(), fake_address4); + EXPECT_EQ(tail.size(), superblock::minimum_size); + EXPECT_TRUE(tail.empty()); +} + +TEST_F(ArenaTest, SuperblockMerge) // NOLINT +{ + superblock sblk{fake_address3, superblock::minimum_size}; + superblock sb2{fake_address4, superblock::minimum_size}; + auto const merged = sblk.merge(sb2); + EXPECT_EQ(merged.pointer(), fake_address3); + EXPECT_EQ(merged.size(), superblock::minimum_size * 2); + EXPECT_TRUE(merged.empty()); +} + +TEST_F(ArenaTest, SuperblockFirstFit) // NOLINT +{ + superblock sblk{fake_address3, superblock::minimum_size}; + auto const blk = sblk.first_fit(1_KiB); + EXPECT_EQ(blk.pointer(), fake_address3); + EXPECT_EQ(blk.size(), 1_KiB); + auto const blk2 = sblk.first_fit(2_KiB); + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + EXPECT_EQ(blk2.pointer(), static_cast(fake_address3) + 1_KiB); + EXPECT_EQ(blk2.size(), 2_KiB); + sblk.coalesce(blk); + auto const blk3 = sblk.first_fit(512); + EXPECT_EQ(blk3.pointer(), fake_address3); + EXPECT_EQ(blk3.size(), 512); +} + +TEST_F(ArenaTest, SuperblockCoalesceAfterFull) // NOLINT +{ + superblock sblk{fake_address3, superblock::minimum_size}; + auto const blk = sblk.first_fit(superblock::minimum_size / 2); + sblk.first_fit(superblock::minimum_size / 2); + sblk.coalesce(blk); + EXPECT_TRUE(sblk.first_fit(superblock::minimum_size / 2).is_valid()); +} + +TEST_F(ArenaTest, SuperblockCoalesceMergeNext) // NOLINT +{ + superblock sblk{fake_address3, superblock::minimum_size}; + auto const blk = sblk.first_fit(superblock::minimum_size / 2); + sblk.coalesce(blk); + EXPECT_TRUE(sblk.first_fit(superblock::minimum_size).is_valid()); +} + +TEST_F(ArenaTest, SuperblockCoalesceMergePrevious) // NOLINT +{ + superblock sblk{fake_address3, superblock::minimum_size}; + auto const blk = sblk.first_fit(1_KiB); + auto const blk2 = sblk.first_fit(1_KiB); + sblk.first_fit(1_KiB); + sblk.coalesce(blk); + sblk.coalesce(blk2); + auto const blk3 = sblk.first_fit(2_KiB); + EXPECT_EQ(blk3.pointer(), fake_address3); +} + +TEST_F(ArenaTest, SuperblockCoalesceMergePreviousAndNext) // NOLINT +{ + superblock sblk{fake_address3, superblock::minimum_size}; + auto const blk = sblk.first_fit(1_KiB); + auto const blk2 = sblk.first_fit(1_KiB); + sblk.coalesce(blk); + sblk.coalesce(blk2); + EXPECT_TRUE(sblk.first_fit(superblock::minimum_size).is_valid()); +} + +TEST_F(ArenaTest, SuperblockMaxFreeSize) // NOLINT +{ + superblock sblk{fake_address3, superblock::minimum_size}; + auto const blk = sblk.first_fit(superblock::minimum_size / 4); + sblk.first_fit(superblock::minimum_size / 4); + sblk.coalesce(blk); + EXPECT_EQ(sblk.max_free_size(), superblock::minimum_size / 2); +} + +TEST_F(ArenaTest, SuperblockMaxFreeSizeWhenFull) // NOLINT +{ + superblock sblk{fake_address3, superblock::minimum_size}; + sblk.first_fit(superblock::minimum_size); + EXPECT_EQ(sblk.max_free_size(), 0); +} + +/** + * Test global_arena. + */ + +TEST_F(ArenaTest, GlobalArenaNullUpstream) // NOLINT +{ + auto construct_nullptr = []() { global_arena global{nullptr, std::nullopt}; }; + EXPECT_THROW(construct_nullptr(), rmm::logic_error); // NOLINT(cppcoreguidelines-avoid-goto) +} + +TEST_F(ArenaTest, GlobalArenaAcquire) // NOLINT +{ + auto const sblk = global->acquire(256); + EXPECT_EQ(sblk.pointer(), fake_address3); + EXPECT_EQ(sblk.size(), superblock::minimum_size); + EXPECT_TRUE(sblk.empty()); + + auto const sb2 = global->acquire(1_KiB); + EXPECT_EQ(sb2.pointer(), fake_address4); + EXPECT_EQ(sb2.size(), superblock::minimum_size); + EXPECT_TRUE(sb2.empty()); + + global->acquire(512); + global->acquire(512); + EXPECT_FALSE(global->acquire(512).is_valid()); +} + +TEST_F(ArenaTest, GlobalArenaReleaseMergeNext) // NOLINT +{ + auto sblk = global->acquire(256); + global->release(std::move(sblk)); + auto* ptr = global->allocate(arena_size); + EXPECT_EQ(ptr, fake_address3); +} + +TEST_F(ArenaTest, GlobalArenaReleaseMergePrevious) // NOLINT +{ + auto sblk = global->acquire(256); + auto sb2 = global->acquire(1_KiB); + global->acquire(512); + global->release(std::move(sblk)); + global->release(std::move(sb2)); + auto* ptr = global->allocate(superblock::minimum_size * 2); + EXPECT_EQ(ptr, fake_address3); +} + +TEST_F(ArenaTest, GlobalArenaReleaseMergePreviousAndNext) // NOLINT +{ + auto sblk = global->acquire(256); + auto sb2 = global->acquire(1_KiB); + auto sb3 = global->acquire(512); + global->release(std::move(sblk)); + global->release(std::move(sb3)); + global->release(std::move(sb2)); + auto* ptr = global->allocate(arena_size); + EXPECT_EQ(ptr, fake_address3); +} + +TEST_F(ArenaTest, GlobalArenaReleaseMultiple) // NOLINT +{ + std::set superblocks{}; + auto sblk = global->acquire(256); + superblocks.insert(std::move(sblk)); + auto sb2 = global->acquire(1_KiB); + superblocks.insert(std::move(sb2)); + auto sb3 = global->acquire(512); + superblocks.insert(std::move(sb3)); + global->release(superblocks); + auto* ptr = global->allocate(arena_size); + EXPECT_EQ(ptr, fake_address3); +} + +TEST_F(ArenaTest, GlobalArenaAllocate) // NOLINT +{ + auto* ptr = global->allocate(superblock::minimum_size * 2); + EXPECT_EQ(ptr, fake_address3); +} + +TEST_F(ArenaTest, GlobalArenaAllocateExtraLarge) // NOLINT +{ + EXPECT_EQ(global->allocate(1_PiB), nullptr); + EXPECT_EQ(global->allocate(1_PiB), nullptr); +} + +TEST_F(ArenaTest, GlobalArenaDeallocate) // NOLINT +{ + auto* ptr = global->allocate(superblock::minimum_size * 2); + EXPECT_EQ(ptr, fake_address3); + global->deallocate(ptr, superblock::minimum_size * 2, {}); + ptr = global->allocate(superblock::minimum_size * 2); + EXPECT_EQ(ptr, fake_address3); +} + +TEST_F(ArenaTest, GlobalArenaDeallocateAlignUp) // NOLINT +{ + auto* ptr = global->allocate(superblock::minimum_size + 256); + auto* ptr2 = global->allocate(superblock::minimum_size + 512); + global->deallocate(ptr, superblock::minimum_size + 256, {}); + global->deallocate(ptr2, superblock::minimum_size + 512, {}); + EXPECT_EQ(global->allocate(arena_size), fake_address3); +} + +TEST_F(ArenaTest, GlobalArenaDeallocateFromOtherArena) // NOLINT +{ + auto sblk = global->acquire(512); + auto const blk = sblk.first_fit(512); + auto const blk2 = sblk.first_fit(1024); + global->release(std::move(sblk)); + global->deallocate(blk.pointer(), blk.size()); + global->deallocate(blk2.pointer(), blk2.size()); + EXPECT_EQ(global->allocate(arena_size), fake_address3); +} + +/** + * Test arena. + */ + +TEST_F(ArenaTest, ArenaAllocate) // NOLINT +{ + EXPECT_EQ(per_thread->allocate(superblock::minimum_size), fake_address3); + EXPECT_EQ(per_thread->allocate(256), fake_address4); +} + +TEST_F(ArenaTest, ArenaDeallocate) // NOLINT +{ + auto* ptr = per_thread->allocate(superblock::minimum_size); + per_thread->deallocate(ptr, superblock::minimum_size, {}); + auto* ptr2 = per_thread->allocate(256); + per_thread->deallocate(ptr2, 256, {}); + EXPECT_EQ(per_thread->allocate(superblock::minimum_size), fake_address3); +} + +TEST_F(ArenaTest, ArenaDeallocateMergePrevious) // NOLINT +{ + auto* ptr = per_thread->allocate(256); + auto* ptr2 = per_thread->allocate(256); + per_thread->allocate(256); + per_thread->deallocate(ptr, 256, {}); + per_thread->deallocate(ptr2, 256, {}); + EXPECT_EQ(per_thread->allocate(512), fake_address3); +} + +TEST_F(ArenaTest, ArenaDeallocateMergeNext) // NOLINT +{ + auto* ptr = per_thread->allocate(256); + auto* ptr2 = per_thread->allocate(256); + per_thread->allocate(256); + per_thread->deallocate(ptr2, 256, {}); + per_thread->deallocate(ptr, 256, {}); + EXPECT_EQ(per_thread->allocate(512), fake_address3); +} + +TEST_F(ArenaTest, ArenaDeallocateMergePreviousAndNext) // NOLINT +{ + auto* ptr = per_thread->allocate(256); + auto* ptr2 = per_thread->allocate(256); + per_thread->deallocate(ptr, 256, {}); + per_thread->deallocate(ptr2, 256, {}); + EXPECT_EQ(per_thread->allocate(2_KiB), fake_address3); +} + +TEST_F(ArenaTest, ArenaDefragment) // NOLINT +{ + std::vector pointers; + std::size_t num_pointers{4}; + for (std::size_t i = 0; i < num_pointers; i++) { + pointers.push_back(per_thread->allocate(superblock::minimum_size)); + } + for (auto* ptr : pointers) { + per_thread->deallocate(ptr, superblock::minimum_size, {}); + } + EXPECT_EQ(global->allocate(arena_size), nullptr); + per_thread->defragment(); + EXPECT_EQ(global->allocate(arena_size), fake_address3); +} + +/** + * Test arena_memory_resource. + */ + +TEST_F(ArenaTest, ThrowOnNullUpstream) // NOLINT { auto construct_nullptr = []() { arena_mr mr{nullptr}; }; + // NOLINTNEXTLINE(cppcoreguidelines-avoid-goto) EXPECT_THROW(construct_nullptr(), rmm::logic_error); } -TEST(ArenaTest, ThrowMaxLessThanInitial) +TEST_F(ArenaTest, SizeSmallerThanSuperblockSize) // NOLINT { - // Make sure first argument is enough larger than the second that alignment rounding doesn't - // make them equal - auto max_less_than_initial = []() { - const auto initial{4_MiB}; - const auto maximum{2_MiB}; - cuda_mr cuda; - arena_mr mr{&cuda, initial, maximum}; - }; - EXPECT_THROW(max_less_than_initial(), rmm::logic_error); + auto construct_small = []() { arena_mr mr{rmm::mr::get_current_device_resource(), 256}; }; + // NOLINTNEXTLINE(cppcoreguidelines-avoid-goto) + EXPECT_THROW(construct_small(), rmm::logic_error); +} + +TEST_F(ArenaTest, AllocateNinetyPercent) // NOLINT +{ + EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) + auto const free = rmm::detail::available_device_memory().first; + auto const ninety_percent = + rmm::detail::align_up(static_cast(static_cast(free) * 0.9), + rmm::detail::CUDA_ALLOCATION_ALIGNMENT); + arena_mr mr(rmm::mr::get_current_device_resource(), ninety_percent); + }()); +} + +TEST_F(ArenaTest, SmallMediumLarge) // NOLINT +{ + EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) + arena_mr mr(rmm::mr::get_current_device_resource()); + auto* small = mr.allocate(256); + auto* medium = mr.allocate(64_MiB); + auto const free = rmm::detail::available_device_memory().first; + auto* large = mr.allocate(free / 3); + mr.deallocate(small, 256); + mr.deallocate(medium, 64_MiB); + mr.deallocate(large, free / 3); + }()); +} + +TEST_F(ArenaTest, Defragment) // NOLINT +{ + EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) + auto const arena_size = superblock::minimum_size * 4; + arena_mr mr(rmm::mr::get_current_device_resource(), arena_size); + std::vector threads; + std::size_t num_threads{4}; + threads.reserve(num_threads); + for (std::size_t i = 0; i < num_threads; ++i) { + threads.emplace_back(std::thread([&] { + cuda_stream stream{}; + void* ptr = mr.allocate(32_KiB, stream); + mr.deallocate(ptr, 32_KiB, stream); + })); + } + for (auto& thread : threads) { + thread.join(); + } + + auto* ptr = mr.allocate(arena_size); + mr.deallocate(ptr, arena_size); + }()); } -TEST(ArenaTest, DumpLogOnFailure) +TEST_F(ArenaTest, DumpLogOnFailure) // NOLINT { - cuda_mr cuda; - arena_mr mr{&cuda, 1_MiB, 4_MiB, true}; + arena_mr mr{rmm::mr::get_current_device_resource(), 1_MiB, true}; { // make the log interesting std::vector threads; @@ -77,6 +553,7 @@ TEST(ArenaTest, DumpLogOnFailure) } } + // NOLINTNEXTLINE(cppcoreguidelines-avoid-goto) EXPECT_THROW(mr.allocate(8_MiB), rmm::out_of_memory); struct stat file_status { @@ -85,10 +562,9 @@ TEST(ArenaTest, DumpLogOnFailure) EXPECT_GE(file_status.st_size, 0); } -TEST(ArenaTest, FeatureSupport) +TEST_F(ArenaTest, FeatureSupport) // NOLINT { - cuda_mr cuda; - arena_mr mr{&cuda, 1_MiB, 4_MiB}; + arena_mr mr{rmm::mr::get_current_device_resource(), 1_MiB}; EXPECT_TRUE(mr.supports_streams()); EXPECT_FALSE(mr.supports_get_mem_info()); auto [free, total] = mr.get_mem_info(rmm::cuda_stream_default); From 5584a0ccdb4d8d68df96eb6e8121a3baa4f4e168 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Thu, 13 Jan 2022 10:01:58 +1100 Subject: [PATCH 033/675] Temporarily disable warnings for unknown pragmas (#942) CUB 1.15 has uses an unprotected `#pragma nv_exec_check_disable` which makes includes of thrust headers from .cpp files fail if `-Werror` is enabled (or warn if it is not set) This PR is a temporary workaround. It just adds -Wno-unknown-pragmas to the command line for building benchmark .cpp files. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Robert Maynard (https://github.com/robertmaynard) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/942 --- benchmarks/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index fc5579727..9f7a0d304 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -45,8 +45,9 @@ function(ConfigureBench BENCH_NAME) target_compile_definitions(${TEST_NAME} PUBLIC "RMM_DISABLE_CUDA_MALLOC_ASYNC") endif() - target_compile_options(${BENCH_NAME} PUBLIC $<$:-Wall -Werror - -Wno-error=deprecated-declarations>) + target_compile_options( + ${BENCH_NAME} PUBLIC $<$:-Wall -Werror + -Wno-error=deprecated-declarations -Wno-unknown-pragmas>) if(DISABLE_DEPRECATION_WARNING) target_compile_options( ${BENCH_NAME} PUBLIC $<$:-Xcompiler=-Wno-deprecated-declarations>) From 4045e1e365a293dbc624e0cb3636a3fed21c7418 Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Thu, 13 Jan 2022 10:37:36 -0500 Subject: [PATCH 034/675] DOC --- CHANGELOG.md | 4 ++++ CMakeLists.txt | 4 ++-- doxygen/Doxyfile | 2 +- python/docs/conf.py | 6 +++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e319e1160..4a4955300 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# RMM 22.04.00 (Date TBD) + +Please see https://github.com/rapidsai/rmm/releases/tag/v22.04.00a for the latest changes to this development branch. + # RMM 22.02.00 (Date TBD) Please see https://github.com/rapidsai/rmm/releases/tag/v22.02.00a for the latest changes to this development branch. diff --git a/CMakeLists.txt b/CMakeLists.txt index 718ae72a6..425f3e8da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.02/RAPIDS.cmake +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.04/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) @@ -25,7 +25,7 @@ include(rapids-find) project( RMM - VERSION 22.02.00 + VERSION 22.04.00 LANGUAGES CXX) # Write the version header diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 622bb9175..4540def1f 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "RMM" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 22.02 +PROJECT_NUMBER = 22.04 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/python/docs/conf.py b/python/docs/conf.py index c08b50a72..5c88dcb2b 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -19,7 +19,7 @@ author = "NVIDIA" # The full version, including alpha/beta/rc tags -release = "22.02.00" +release = "22.04.00" # -- General configuration --------------------------------------------------- @@ -69,9 +69,9 @@ # built documents. # # The short X.Y version. -version = "22.02" +version = "22.04" # The full version, including alpha/beta/rc tags. -release = "22.02.00" +release = "22.04.00" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. From d94bdfd060c8c54379d01c21b8386492f36c9fd1 Mon Sep 17 00:00:00 2001 From: Ashwin Srinath <3190405+shwina@users.noreply.github.com> Date: Wed, 19 Jan 2022 10:28:10 -0500 Subject: [PATCH 035/675] Replace use of custom CUDA bindings with CUDA-Python (#930) This PR removes many of the custom CUDA bindings we wrote in RMM to support calls to the driver/runtime APIs from Python in downstream libraries (cudf, cuml, cugraph). We should now use [CUDA Python](https://github.com/NVIDIA/CUDA-Python) instead. However, the module `rmm._cuda.gpu` is not being removed. It _has_ been converted from an extension module (`.pyx`) to a regular `.py` module. This module contains high-level wrappers around raw CUDA bindings, with some niceties like converting errors to exceptions with the appropriate error message. Reimplementing that functionality in each downstream library would be a bad idea. When CUDA Python rolls its own higher-level API, we can remove the `gpu` module as well. One API change worth mentioning here is to the function `rmm._cuda.gpu.getDeviceAttribute`. Previously, the API accepted a `cudaDeviceAttr`, a type defined as part of RMM's custom CUDA bindings. The API has now changed to accept a `cudaDeviceAttr` defined in CUDA-Python. This requires changes in downstream libraries that use this API. I am marking this PR _non-breaking_ as it does not affect the user-facing API. It does cause breakages in downstream libraries that are currently relying on internal APIs (from the `rmm._cuda` module). Authors: - Ashwin Srinath (https://github.com/shwina) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Bradley Dice (https://github.com/bdice) - https://github.com/jakirkham URL: https://github.com/rapidsai/rmm/pull/930 --- conda/environments/rmm_dev_cuda10.2.yml | 21 - conda/environments/rmm_dev_cuda11.0.yml | 21 - ..._dev_cuda10.1.yml => rmm_dev_cuda11.5.yml} | 3 +- conda/recipes/rmm/meta.yaml | 2 + python/rmm/_cuda/10.1/gpu.pxi | 396 ----------------- python/rmm/_cuda/10.2/gpu.pxi | 400 ----------------- python/rmm/_cuda/11.x/gpu.pxi | 406 ------------------ python/rmm/_cuda/{gpu.pyx => gpu.py} | 111 ++--- python/rmm/_cuda/stream.pxd | 2 +- python/rmm/_cuda/stream.pyx | 2 +- python/rmm/_lib/cuda_stream.pxd | 2 +- python/rmm/_lib/cuda_stream.pyx | 1 + python/rmm/_lib/cuda_stream_view.pxd | 3 +- python/rmm/_lib/device_buffer.pyx | 19 +- python/rmm/_lib/lib.pxd | 20 - python/rmm/_lib/memory_resource.pyx | 6 +- python/setup.py | 40 +- 17 files changed, 57 insertions(+), 1398 deletions(-) delete mode 100644 conda/environments/rmm_dev_cuda10.2.yml delete mode 100644 conda/environments/rmm_dev_cuda11.0.yml rename conda/environments/{rmm_dev_cuda10.1.yml => rmm_dev_cuda11.5.yml} (86%) delete mode 100644 python/rmm/_cuda/10.1/gpu.pxi delete mode 100644 python/rmm/_cuda/10.2/gpu.pxi delete mode 100644 python/rmm/_cuda/11.x/gpu.pxi rename python/rmm/_cuda/{gpu.pyx => gpu.py} (55%) diff --git a/conda/environments/rmm_dev_cuda10.2.yml b/conda/environments/rmm_dev_cuda10.2.yml deleted file mode 100644 index 348418014..000000000 --- a/conda/environments/rmm_dev_cuda10.2.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: rmm_dev -channels: -- rapidsai -- conda-forge -dependencies: -- clang=11.1.0 -- clang-tools=11.1.0 -- cmake>=3.20.1 -- cmake-format=0.6.11 -- flake8=3.8.3 -- black=19.10 -- isort=5.6.4 -- python>=3.7,<3.9 -- numba>=0.49 -- numpy -- cffi>=1.10.0 -- pytest -- cudatoolkit=10.2 -- spdlog>=1.8.5,<1.9 -- cython>=0.29,<0.30 -- gcovr>=5.0 diff --git a/conda/environments/rmm_dev_cuda11.0.yml b/conda/environments/rmm_dev_cuda11.0.yml deleted file mode 100644 index 8fbe42e4b..000000000 --- a/conda/environments/rmm_dev_cuda11.0.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: rmm_dev -channels: -- rapidsai -- conda-forge -dependencies: -- clang=11.1.0 -- clang-tools=11.1.0 -- cmake>=3.20.1 -- cmake-format=0.6.11 -- flake8=3.8.3 -- black=19.10 -- isort=5.6.4 -- python>=3.7,<3.9 -- numba>=0.49 -- numpy -- cffi>=1.10.0 -- pytest -- cudatoolkit=11.0 -- spdlog>=1.8.5,<1.9 -- cython>=0.29,<0.30 -- gcovr>=5.0 diff --git a/conda/environments/rmm_dev_cuda10.1.yml b/conda/environments/rmm_dev_cuda11.5.yml similarity index 86% rename from conda/environments/rmm_dev_cuda10.1.yml rename to conda/environments/rmm_dev_cuda11.5.yml index caccd9541..549aca8d5 100644 --- a/conda/environments/rmm_dev_cuda10.1.yml +++ b/conda/environments/rmm_dev_cuda11.5.yml @@ -15,7 +15,8 @@ dependencies: - numpy - cffi>=1.10.0 - pytest -- cudatoolkit=10.1 +- cudatoolkit=11.5 - spdlog>=1.8.5,<1.9 - cython>=0.29,<0.30 - gcovr>=5.0 +- cuda-python>=11.5,<12.0 diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index a38da35fd..ce1ecec07 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -30,6 +30,7 @@ requirements: - cython >=0.29,<0.30 - spdlog>=1.8.5,<2.0.0a0 - cudatoolkit {{ cuda_version }}.* + - cuda-python >=11.5,<12.0 run: - python - numba >=0.49 @@ -39,6 +40,7 @@ requirements: {% else %} - {{ pin_compatible('cudatoolkit', upper_bound='11.2', lower_bound='11.0') }} # cudatoolkit >=11.0,<11.2 {% endif %} + - cuda-python >=11.5,<12.0 test: imports: diff --git a/python/rmm/_cuda/10.1/gpu.pxi b/python/rmm/_cuda/10.1/gpu.pxi deleted file mode 100644 index ab6569711..000000000 --- a/python/rmm/_cuda/10.1/gpu.pxi +++ /dev/null @@ -1,396 +0,0 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. -# For CUDA 10.1 - -cdef extern from "cuda.h" nogil: - cpdef enum cudaDeviceAttr: - cudaDevAttrMaxThreadsPerBlock = 1 - cudaDevAttrMaxBlockDimX = 2 - cudaDevAttrMaxBlockDimY = 3 - cudaDevAttrMaxBlockDimZ = 4 - cudaDevAttrMaxGridDimX = 5 - cudaDevAttrMaxGridDimY = 6 - cudaDevAttrMaxGridDimZ = 7 - cudaDevAttrMaxSharedMemoryPerBlock = 8 - cudaDevAttrTotalConstantMemory = 9 - cudaDevAttrWarpSize = 10 - cudaDevAttrMaxPitch = 11 - cudaDevAttrMaxRegistersPerBlock = 12 - cudaDevAttrClockRate = 13 - cudaDevAttrTextureAlignment = 14 - cudaDevAttrGpuOverlap = 15 - cudaDevAttrMultiProcessorCount = 16 - cudaDevAttrKernelExecTimeout = 17 - cudaDevAttrIntegrated = 18 - cudaDevAttrCanMapHostMemory = 19 - cudaDevAttrComputeMode = 20 - cudaDevAttrMaxTexture1DWidth = 21 - cudaDevAttrMaxTexture2DWidth = 22 - cudaDevAttrMaxTexture2DHeight = 23 - cudaDevAttrMaxTexture3DWidth = 24 - cudaDevAttrMaxTexture3DHeight = 25 - cudaDevAttrMaxTexture3DDepth = 26 - cudaDevAttrMaxTexture2DLayeredWidth = 27 - cudaDevAttrMaxTexture2DLayeredHeight = 28 - cudaDevAttrMaxTexture2DLayeredLayers = 29 - cudaDevAttrSurfaceAlignment = 30 - cudaDevAttrConcurrentKernels = 31 - cudaDevAttrEccEnabled = 32 - cudaDevAttrPciBusId = 33 - cudaDevAttrPciDeviceId = 34 - cudaDevAttrTccDriver = 35 - cudaDevAttrMemoryClockRate = 36 - cudaDevAttrGlobalMemoryBusWidth = 37 - cudaDevAttrL2CacheSize = 38 - cudaDevAttrMaxThreadsPerMultiProcessor = 39 - cudaDevAttrAsyncEngineCount = 40 - cudaDevAttrUnifiedAddressing = 41 - cudaDevAttrMaxTexture1DLayeredWidth = 42 - cudaDevAttrMaxTexture1DLayeredLayers = 43 - cudaDevAttrMaxTexture2DGatherWidth = 45 - cudaDevAttrMaxTexture2DGatherHeight = 46 - cudaDevAttrMaxTexture3DWidthAlt = 47 - cudaDevAttrMaxTexture3DHeightAlt = 48 - cudaDevAttrMaxTexture3DDepthAlt = 49 - cudaDevAttrPciDomainId = 50 - cudaDevAttrTexturePitchAlignment = 51 - cudaDevAttrMaxTextureCubemapWidth = 52 - cudaDevAttrMaxTextureCubemapLayeredWidth = 53 - cudaDevAttrMaxTextureCubemapLayeredLayers = 54 - cudaDevAttrMaxSurface1DWidth = 55 - cudaDevAttrMaxSurface2DWidth = 56 - cudaDevAttrMaxSurface2DHeight = 57 - cudaDevAttrMaxSurface3DWidth = 58 - cudaDevAttrMaxSurface3DHeight = 59 - cudaDevAttrMaxSurface3DDepth = 60 - cudaDevAttrMaxSurface1DLayeredWidth = 61 - cudaDevAttrMaxSurface1DLayeredLayers = 62 - cudaDevAttrMaxSurface2DLayeredWidth = 63 - cudaDevAttrMaxSurface2DLayeredHeight = 64 - cudaDevAttrMaxSurface2DLayeredLayers = 65 - cudaDevAttrMaxSurfaceCubemapWidth = 66 - cudaDevAttrMaxSurfaceCubemapLayeredWidth = 67 - cudaDevAttrMaxSurfaceCubemapLayeredLayers = 68 - cudaDevAttrMaxTexture1DLinearWidth = 69 - cudaDevAttrMaxTexture2DLinearWidth = 70 - cudaDevAttrMaxTexture2DLinearHeight = 71 - cudaDevAttrMaxTexture2DLinearPitch = 72 - cudaDevAttrMaxTexture2DMipmappedWidth = 73 - cudaDevAttrMaxTexture2DMipmappedHeight = 74 - cudaDevAttrComputeCapabilityMajor = 75 - cudaDevAttrComputeCapabilityMinor = 76 - cudaDevAttrMaxTexture1DMipmappedWidth = 77 - cudaDevAttrStreamPrioritiesSupported = 78 - cudaDevAttrGlobalL1CacheSupported = 79 - cudaDevAttrLocalL1CacheSupported = 80 - cudaDevAttrMaxSharedMemoryPerMultiprocessor = 81 - cudaDevAttrMaxRegistersPerMultiprocessor = 82 - cudaDevAttrManagedMemory = 83 - cudaDevAttrIsMultiGpuBoard = 84 - cudaDevAttrMultiGpuBoardGroupID = 85 - cudaDevAttrHostNativeAtomicSupported = 86 - cudaDevAttrSingleToDoublePrecisionPerfRatio = 87 - cudaDevAttrPageableMemoryAccess = 88 - cudaDevAttrConcurrentManagedAccess = 89 - cudaDevAttrComputePreemptionSupported = 90 - cudaDevAttrCanUseHostPointerForRegisteredMem = 91 - cudaDevAttrReserved92 = 92 - cudaDevAttrReserved93 = 93 - cudaDevAttrReserved94 = 94 - cudaDevAttrCooperativeLaunch = 95 - cudaDevAttrCooperativeMultiDeviceLaunch = 96 - cudaDevAttrMaxSharedMemoryPerBlockOptin = 97 - cudaDevAttrCanFlushRemoteWrites = 98 - cudaDevAttrHostRegisterSupported = 99 - cudaDevAttrPageableMemoryAccessUsesHostPageTables = 100 - cudaDevAttrDirectManagedMemAccessFromHost = 101 - - cpdef enum cudaError: - cudaSuccess = 0 - cudaErrorInvalidValue = 1 - cudaErrorMemoryAllocation = 2 - cudaErrorInitializationError = 3 - cudaErrorCudartUnloading = 4 - cudaErrorProfilerDisabled = 5 - cudaErrorProfilerNotInitialized = 6 - cudaErrorProfilerAlreadyStarted = 7 - cudaErrorProfilerAlreadyStopped = 8 - cudaErrorInvalidConfiguration = 9 - cudaErrorInvalidPitchValue = 12 - cudaErrorInvalidSymbol = 13 - cudaErrorInvalidHostPointer = 16 - cudaErrorInvalidDevicePointer = 17 - cudaErrorInvalidTexture = 18 - cudaErrorInvalidTextureBinding = 19 - cudaErrorInvalidChannelDescriptor = 20 - cudaErrorInvalidMemcpyDirection = 21 - cudaErrorAddressOfConstant = 22 - cudaErrorTextureFetchFailed = 23 - cudaErrorTextureNotBound = 24 - cudaErrorSynchronizationError = 25 - cudaErrorInvalidFilterSetting = 26 - cudaErrorInvalidNormSetting = 27 - cudaErrorMixedDeviceExecution = 28 - cudaErrorNotYetImplemented = 31 - cudaErrorMemoryValueTooLarge = 32 - cudaErrorInsufficientDriver = 35 - cudaErrorInvalidSurface = 37 - cudaErrorDuplicateVariableName = 43 - cudaErrorDuplicateTextureName = 44 - cudaErrorDuplicateSurfaceName = 45 - cudaErrorDevicesUnavailable = 46 - cudaErrorIncompatibleDriverContext = 49 - cudaErrorMissingConfiguration = 52 - cudaErrorPriorLaunchFailure = 53 - cudaErrorLaunchMaxDepthExceeded = 65 - cudaErrorLaunchFileScopedTex = 66 - cudaErrorLaunchFileScopedSurf = 67 - cudaErrorSyncDepthExceeded = 68 - cudaErrorLaunchPendingCountExceeded = 69 - cudaErrorInvalidDeviceFunction = 98 - cudaErrorNoDevice = 100 - cudaErrorInvalidDevice = 101 - cudaErrorStartupFailure = 127 - cudaErrorInvalidKernelImage = 200 - cudaErrorDeviceUninitilialized = 201 - cudaErrorMapBufferObjectFailed = 205 - cudaErrorUnmapBufferObjectFailed = 206 - cudaErrorArrayIsMapped = 207 - cudaErrorAlreadyMapped = 208 - cudaErrorNoKernelImageForDevice = 209 - cudaErrorAlreadyAcquired = 210 - cudaErrorNotMapped = 211 - cudaErrorNotMappedAsArray = 212 - cudaErrorNotMappedAsPointer = 213 - cudaErrorECCUncorrectable = 214 - cudaErrorUnsupportedLimit = 215 - cudaErrorDeviceAlreadyInUse = 216 - cudaErrorPeerAccessUnsupported = 217 - cudaErrorInvalidPtx = 218 - cudaErrorInvalidGraphicsContext = 219 - cudaErrorNvlinkUncorrectable = 220 - cudaErrorJitCompilerNotFound = 221 - cudaErrorInvalidSource = 300 - cudaErrorFileNotFound = 301 - cudaErrorSharedObjectSymbolNotFound = 302 - cudaErrorSharedObjectInitFailed = 303 - cudaErrorOperatingSystem = 304 - cudaErrorInvalidResourceHandle = 400 - cudaErrorIllegalState = 401 - cudaErrorSymbolNotFound = 500 - cudaErrorNotReady = 600 - cudaErrorIllegalAddress = 700 - cudaErrorLaunchOutOfResources = 701 - cudaErrorLaunchTimeout = 702 - cudaErrorLaunchIncompatibleTexturing = 703 - cudaErrorPeerAccessAlreadyEnabled = 704 - cudaErrorPeerAccessNotEnabled = 705 - cudaErrorSetOnActiveProcess = 708 - cudaErrorContextIsDestroyed = 709 - cudaErrorAssert = 710 - cudaErrorTooManyPeers = 711 - cudaErrorHostMemoryAlreadyRegistered = 712 - cudaErrorHostMemoryNotRegistered = 713 - cudaErrorHardwareStackError = 714 - cudaErrorIllegalInstruction = 715 - cudaErrorMisalignedAddress = 716 - cudaErrorInvalidAddressSpace = 717 - cudaErrorInvalidPc = 718 - cudaErrorLaunchFailure = 719 - cudaErrorCooperativeLaunchTooLarge = 720 - cudaErrorNotPermitted = 800 - cudaErrorNotSupported = 801 - cudaErrorSystemNotReady = 802 - cudaErrorSystemDriverMismatch = 803 - cudaErrorCompatNotSupportedOnDevice = 804 - cudaErrorStreamCaptureUnsupported = 900 - cudaErrorStreamCaptureInvalidated = 901 - cudaErrorStreamCaptureMerge = 902 - cudaErrorStreamCaptureUnmatched = 903 - cudaErrorStreamCaptureUnjoined = 904 - cudaErrorStreamCaptureIsolation = 905 - cudaErrorStreamCaptureImplicit = 906 - cudaErrorCapturedEvent = 907 - cudaErrorStreamCaptureWrongThread = 908 - cudaErrorUnknown = 999 - cudaErrorApiFailureBase = 10000 - - ctypedef cudaError cudaError_t - - ctypedef enum CUresult: - CUDA_SUCCESS = 0 - CUDA_ERROR_INVALID_VALUE = 1 - CUDA_ERROR_OUT_OF_MEMORY = 2 - CUDA_ERROR_NOT_INITIALIZED = 3 - CUDA_ERROR_DEINITIALIZED = 4 - CUDA_ERROR_PROFILER_DISABLED = 5 - CUDA_ERROR_PROFILER_NOT_INITIALIZED = 6 - CUDA_ERROR_PROFILER_ALREADY_STARTED = 7 - CUDA_ERROR_PROFILER_ALREADY_STOPPED = 8 - CUDA_ERROR_NO_DEVICE = 100 - CUDA_ERROR_INVALID_DEVICE = 101 - CUDA_ERROR_INVALID_IMAGE = 200 - CUDA_ERROR_INVALID_CONTEXT = 201 - CUDA_ERROR_CONTEXT_ALREADY_CURRENT = 202 - CUDA_ERROR_MAP_FAILED = 205 - CUDA_ERROR_UNMAP_FAILED = 206 - CUDA_ERROR_ARRAY_IS_MAPPED = 207 - CUDA_ERROR_ALREADY_MAPPED = 208 - CUDA_ERROR_NO_BINARY_FOR_GPU = 209 - CUDA_ERROR_ALREADY_ACQUIRED = 210 - CUDA_ERROR_NOT_MAPPED = 211 - CUDA_ERROR_NOT_MAPPED_AS_ARRAY = 212 - CUDA_ERROR_NOT_MAPPED_AS_POINTER = 213 - CUDA_ERROR_ECC_UNCORRECTABLE = 214 - CUDA_ERROR_UNSUPPORTED_LIMIT = 215 - CUDA_ERROR_CONTEXT_ALREADY_IN_USE = 216 - CUDA_ERROR_PEER_ACCESS_UNSUPPORTED = 217 - CUDA_ERROR_INVALID_PTX = 218 - CUDA_ERROR_INVALID_GRAPHICS_CONTEXT = 219 - CUDA_ERROR_NVLINK_UNCORRECTABLE = 220 - CUDA_ERROR_JIT_COMPILER_NOT_FOUND = 221 - CUDA_ERROR_INVALID_SOURCE = 300 - CUDA_ERROR_FILE_NOT_FOUND = 301 - CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND = 302 - CUDA_ERROR_SHARED_OBJECT_INIT_FAILED = 303 - CUDA_ERROR_OPERATING_SYSTEM = 304 - CUDA_ERROR_INVALID_HANDLE = 400 - CUDA_ERROR_ILLEGAL_STATE = 401 - CUDA_ERROR_NOT_FOUND = 500 - CUDA_ERROR_NOT_READY = 600 - CUDA_ERROR_ILLEGAL_ADDRESS = 700 - CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES = 701 - CUDA_ERROR_LAUNCH_TIMEOUT = 702 - CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING = 703 - CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED = 704 - CUDA_ERROR_PEER_ACCESS_NOT_ENABLED = 705 - CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE = 708 - CUDA_ERROR_CONTEXT_IS_DESTROYED = 709 - CUDA_ERROR_ASSERT = 710 - CUDA_ERROR_TOO_MANY_PEERS = 711 - CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED = 712 - CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED = 713 - CUDA_ERROR_HARDWARE_STACK_ERROR = 714 - CUDA_ERROR_ILLEGAL_INSTRUCTION = 715 - CUDA_ERROR_MISALIGNED_ADDRESS = 716 - CUDA_ERROR_INVALID_ADDRESS_SPACE = 717 - CUDA_ERROR_INVALID_PC = 718 - CUDA_ERROR_LAUNCH_FAILED = 719 - CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE = 720 - CUDA_ERROR_NOT_PERMITTED = 800 - CUDA_ERROR_NOT_SUPPORTED = 801 - CUDA_ERROR_SYSTEM_NOT_READY = 802 - CUDA_ERROR_SYSTEM_DRIVER_MISMATCH = 803 - CUDA_ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE = 804 - CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED = 900 - CUDA_ERROR_STREAM_CAPTURE_INVALIDATED = 901 - CUDA_ERROR_STREAM_CAPTURE_MERGE = 902 - CUDA_ERROR_STREAM_CAPTURE_UNMATCHED = 903 - CUDA_ERROR_STREAM_CAPTURE_UNJOINED = 904 - CUDA_ERROR_STREAM_CAPTURE_ISOLATION = 905 - CUDA_ERROR_STREAM_CAPTURE_IMPLICIT = 906 - CUDA_ERROR_CAPTURED_EVENT = 907 - CUDA_ERROR_STREAM_CAPTURE_WRONG_THREAD = 908 - CUDA_ERROR_UNKNOWN = 999 - - ctypedef struct CUuuid_st: - char bytes[16] - - ctypedef CUuuid_st cudaUUID_t - - ctypedef struct cudaDeviceProp: - int ECCEnabled - int asyncEngineCount - int canMapHostMemory - int canUseHostPointerForRegisteredMem - int clockRate - int computeMode - int computePreemptionSupported - int concurrentKernels - int concurrentManagedAccess - int cooperativeLaunch - int cooperativeMultiDeviceLaunch - int deviceOverlap - int directManagedMemAccessFromHost - int globalL1CacheSupported - int hostNativeAtomicSupported - int integrated - int isMultiGpuBoard - int kernelExecTimeoutEnabled - int l2CacheSize - int localL1CacheSupported - char luid[8] - unsigned int luidDeviceNodeMask - int major - int managedMemory - int maxGridSize[3] - int maxSurface1D - int maxSurface1DLayered[2] - int maxSurface2D[2] - int maxSurface2DLayered[3] - int maxSurface3D[3] - int maxSurfaceCubemap - int maxSurfaceCubemapLayered[2] - int maxTexture1D - int maxTexture1DLayered[2] - int maxTexture1DLinear - int maxTexture1DMipmap - int maxTexture2D[2] - int maxTexture2DGather[2] - int maxTexture2DLayered[3] - int maxTexture2DLinear[3] - int maxTexture2DMipmap[2] - int maxTexture3D[3] - int maxTexture3DAlt[3] - int maxTextureCubemap - int maxTextureCubemapLayered[2] - int maxThreadsDim[3] - int maxThreadsPerBlock - int maxThreadsPerMultiProcessor - size_t memPitch - int memoryBusWidth - int memoryClockRate - int minor - int multiGpuBoardGroupID - int multiProcessorCount - char name[256] - int pageableMemoryAccess - int pageableMemoryAccessUsesHostPageTables - int pciBusID - int pciDeviceID - int pciDomainID - int regsPerBlock - int regsPerMultiprocessor - size_t sharedMemPerBlock - size_t sharedMemPerBlockOptin - size_t sharedMemPerMultiprocessor - int singleToDoublePrecisionPerfRatio - int streamPrioritiesSupported - size_t surfaceAlignment - int tccDriver - size_t textureAlignment - size_t texturePitchAlignment - size_t totalConstMem - size_t totalGlobalMem - int unifiedAddressing - cudaUUID_t uuid - int warpSize - - CUresult cuDeviceGetName(char* name, int length, int device) - - CUresult cuGetErrorName(CUresult error, const char** pStr) - CUresult cuGetErrorString(CUresult error, const char** pStr) - -cdef extern from "cuda_runtime_api.h" nogil: - - cudaError_t cudaDriverGetVersion(int* driverVersion) - cudaError_t cudaRuntimeGetVersion(int* runtimeVersion) - cudaError_t cudaGetDeviceCount(int* count) - cudaError_t cudaGetDevice(int* device) - cudaError_t cudaDeviceGetAttribute(int* value, - cudaDeviceAttr attr, - int device) - cudaError_t cudaGetDeviceProperties(cudaDeviceProp* prop, int device) - cudaError_t cudaSetDevice(int device) - - const char* cudaGetErrorString(cudaError_t error) - const char* cudaGetErrorName(cudaError_t error) diff --git a/python/rmm/_cuda/10.2/gpu.pxi b/python/rmm/_cuda/10.2/gpu.pxi deleted file mode 100644 index a3a19b642..000000000 --- a/python/rmm/_cuda/10.2/gpu.pxi +++ /dev/null @@ -1,400 +0,0 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. -# For CUDA 10.2 - -cdef extern from "cuda.h" nogil: - cpdef enum cudaDeviceAttr: - cudaDevAttrMaxThreadsPerBlock = 1 - cudaDevAttrMaxBlockDimX = 2 - cudaDevAttrMaxBlockDimY = 3 - cudaDevAttrMaxBlockDimZ = 4 - cudaDevAttrMaxGridDimX = 5 - cudaDevAttrMaxGridDimY = 6 - cudaDevAttrMaxGridDimZ = 7 - cudaDevAttrMaxSharedMemoryPerBlock = 8 - cudaDevAttrTotalConstantMemory = 9 - cudaDevAttrWarpSize = 10 - cudaDevAttrMaxPitch = 11 - cudaDevAttrMaxRegistersPerBlock = 12 - cudaDevAttrClockRate = 13 - cudaDevAttrTextureAlignment = 14 - cudaDevAttrGpuOverlap = 15 - cudaDevAttrMultiProcessorCount = 16 - cudaDevAttrKernelExecTimeout = 17 - cudaDevAttrIntegrated = 18 - cudaDevAttrCanMapHostMemory = 19 - cudaDevAttrComputeMode = 20 - cudaDevAttrMaxTexture1DWidth = 21 - cudaDevAttrMaxTexture2DWidth = 22 - cudaDevAttrMaxTexture2DHeight = 23 - cudaDevAttrMaxTexture3DWidth = 24 - cudaDevAttrMaxTexture3DHeight = 25 - cudaDevAttrMaxTexture3DDepth = 26 - cudaDevAttrMaxTexture2DLayeredWidth = 27 - cudaDevAttrMaxTexture2DLayeredHeight = 28 - cudaDevAttrMaxTexture2DLayeredLayers = 29 - cudaDevAttrSurfaceAlignment = 30 - cudaDevAttrConcurrentKernels = 31 - cudaDevAttrEccEnabled = 32 - cudaDevAttrPciBusId = 33 - cudaDevAttrPciDeviceId = 34 - cudaDevAttrTccDriver = 35 - cudaDevAttrMemoryClockRate = 36 - cudaDevAttrGlobalMemoryBusWidth = 37 - cudaDevAttrL2CacheSize = 38 - cudaDevAttrMaxThreadsPerMultiProcessor = 39 - cudaDevAttrAsyncEngineCount = 40 - cudaDevAttrUnifiedAddressing = 41 - cudaDevAttrMaxTexture1DLayeredWidth = 42 - cudaDevAttrMaxTexture1DLayeredLayers = 43 - cudaDevAttrMaxTexture2DGatherWidth = 45 - cudaDevAttrMaxTexture2DGatherHeight = 46 - cudaDevAttrMaxTexture3DWidthAlt = 47 - cudaDevAttrMaxTexture3DHeightAlt = 48 - cudaDevAttrMaxTexture3DDepthAlt = 49 - cudaDevAttrPciDomainId = 50 - cudaDevAttrTexturePitchAlignment = 51 - cudaDevAttrMaxTextureCubemapWidth = 52 - cudaDevAttrMaxTextureCubemapLayeredWidth = 53 - cudaDevAttrMaxTextureCubemapLayeredLayers = 54 - cudaDevAttrMaxSurface1DWidth = 55 - cudaDevAttrMaxSurface2DWidth = 56 - cudaDevAttrMaxSurface2DHeight = 57 - cudaDevAttrMaxSurface3DWidth = 58 - cudaDevAttrMaxSurface3DHeight = 59 - cudaDevAttrMaxSurface3DDepth = 60 - cudaDevAttrMaxSurface1DLayeredWidth = 61 - cudaDevAttrMaxSurface1DLayeredLayers = 62 - cudaDevAttrMaxSurface2DLayeredWidth = 63 - cudaDevAttrMaxSurface2DLayeredHeight = 64 - cudaDevAttrMaxSurface2DLayeredLayers = 65 - cudaDevAttrMaxSurfaceCubemapWidth = 66 - cudaDevAttrMaxSurfaceCubemapLayeredWidth = 67 - cudaDevAttrMaxSurfaceCubemapLayeredLayers = 68 - cudaDevAttrMaxTexture1DLinearWidth = 69 - cudaDevAttrMaxTexture2DLinearWidth = 70 - cudaDevAttrMaxTexture2DLinearHeight = 71 - cudaDevAttrMaxTexture2DLinearPitch = 72 - cudaDevAttrMaxTexture2DMipmappedWidth = 73 - cudaDevAttrMaxTexture2DMipmappedHeight = 74 - cudaDevAttrComputeCapabilityMajor = 75 - cudaDevAttrComputeCapabilityMinor = 76 - cudaDevAttrMaxTexture1DMipmappedWidth = 77 - cudaDevAttrStreamPrioritiesSupported = 78 - cudaDevAttrGlobalL1CacheSupported = 79 - cudaDevAttrLocalL1CacheSupported = 80 - cudaDevAttrMaxSharedMemoryPerMultiprocessor = 81 - cudaDevAttrMaxRegistersPerMultiprocessor = 82 - cudaDevAttrManagedMemory = 83 - cudaDevAttrIsMultiGpuBoard = 84 - cudaDevAttrMultiGpuBoardGroupID = 85 - cudaDevAttrHostNativeAtomicSupported = 86 - cudaDevAttrSingleToDoublePrecisionPerfRatio = 87 - cudaDevAttrPageableMemoryAccess = 88 - cudaDevAttrConcurrentManagedAccess = 89 - cudaDevAttrComputePreemptionSupported = 90 - cudaDevAttrCanUseHostPointerForRegisteredMem = 91 - cudaDevAttrReserved92 = 92 - cudaDevAttrReserved93 = 93 - cudaDevAttrReserved94 = 94 - cudaDevAttrCooperativeLaunch = 95 - cudaDevAttrCooperativeMultiDeviceLaunch = 96 - cudaDevAttrMaxSharedMemoryPerBlockOptin = 97 - cudaDevAttrCanFlushRemoteWrites = 98 - cudaDevAttrHostRegisterSupported = 99 - cudaDevAttrPageableMemoryAccessUsesHostPageTables = 100 - cudaDevAttrDirectManagedMemAccessFromHost = 101 - - cpdef enum cudaError: - cudaSuccess = 0 - cudaErrorInvalidValue = 1 - cudaErrorMemoryAllocation = 2 - cudaErrorInitializationError = 3 - cudaErrorCudartUnloading = 4 - cudaErrorProfilerDisabled = 5 - cudaErrorProfilerNotInitialized = 6 - cudaErrorProfilerAlreadyStarted = 7 - cudaErrorProfilerAlreadyStopped = 8 - cudaErrorInvalidConfiguration = 9 - cudaErrorInvalidPitchValue = 12 - cudaErrorInvalidSymbol = 13 - cudaErrorInvalidHostPointer = 16 - cudaErrorInvalidDevicePointer = 17 - cudaErrorInvalidTexture = 18 - cudaErrorInvalidTextureBinding = 19 - cudaErrorInvalidChannelDescriptor = 20 - cudaErrorInvalidMemcpyDirection = 21 - cudaErrorAddressOfConstant = 22 - cudaErrorTextureFetchFailed = 23 - cudaErrorTextureNotBound = 24 - cudaErrorSynchronizationError = 25 - cudaErrorInvalidFilterSetting = 26 - cudaErrorInvalidNormSetting = 27 - cudaErrorMixedDeviceExecution = 28 - cudaErrorNotYetImplemented = 31 - cudaErrorMemoryValueTooLarge = 32 - cudaErrorInsufficientDriver = 35 - cudaErrorInvalidSurface = 37 - cudaErrorDuplicateVariableName = 43 - cudaErrorDuplicateTextureName = 44 - cudaErrorDuplicateSurfaceName = 45 - cudaErrorDevicesUnavailable = 46 - cudaErrorIncompatibleDriverContext = 49 - cudaErrorMissingConfiguration = 52 - cudaErrorPriorLaunchFailure = 53 - cudaErrorLaunchMaxDepthExceeded = 65 - cudaErrorLaunchFileScopedTex = 66 - cudaErrorLaunchFileScopedSurf = 67 - cudaErrorSyncDepthExceeded = 68 - cudaErrorLaunchPendingCountExceeded = 69 - cudaErrorInvalidDeviceFunction = 98 - cudaErrorNoDevice = 100 - cudaErrorInvalidDevice = 101 - cudaErrorStartupFailure = 127 - cudaErrorInvalidKernelImage = 200 - cudaErrorDeviceUninitialized = 201 - cudaErrorMapBufferObjectFailed = 205 - cudaErrorUnmapBufferObjectFailed = 206 - cudaErrorArrayIsMapped = 207 - cudaErrorAlreadyMapped = 208 - cudaErrorNoKernelImageForDevice = 209 - cudaErrorAlreadyAcquired = 210 - cudaErrorNotMapped = 211 - cudaErrorNotMappedAsArray = 212 - cudaErrorNotMappedAsPointer = 213 - cudaErrorECCUncorrectable = 214 - cudaErrorUnsupportedLimit = 215 - cudaErrorDeviceAlreadyInUse = 216 - cudaErrorPeerAccessUnsupported = 217 - cudaErrorInvalidPtx = 218 - cudaErrorInvalidGraphicsContext = 219 - cudaErrorNvlinkUncorrectable = 220 - cudaErrorJitCompilerNotFound = 221 - cudaErrorInvalidSource = 300 - cudaErrorFileNotFound = 301 - cudaErrorSharedObjectSymbolNotFound = 302 - cudaErrorSharedObjectInitFailed = 303 - cudaErrorOperatingSystem = 304 - cudaErrorInvalidResourceHandle = 400 - cudaErrorIllegalState = 401 - cudaErrorSymbolNotFound = 500 - cudaErrorNotReady = 600 - cudaErrorIllegalAddress = 700 - cudaErrorLaunchOutOfResources = 701 - cudaErrorLaunchTimeout = 702 - cudaErrorLaunchIncompatibleTexturing = 703 - cudaErrorPeerAccessAlreadyEnabled = 704 - cudaErrorPeerAccessNotEnabled = 705 - cudaErrorSetOnActiveProcess = 708 - cudaErrorContextIsDestroyed = 709 - cudaErrorAssert = 710 - cudaErrorTooManyPeers = 711 - cudaErrorHostMemoryAlreadyRegistered = 712 - cudaErrorHostMemoryNotRegistered = 713 - cudaErrorHardwareStackError = 714 - cudaErrorIllegalInstruction = 715 - cudaErrorMisalignedAddress = 716 - cudaErrorInvalidAddressSpace = 717 - cudaErrorInvalidPc = 718 - cudaErrorLaunchFailure = 719 - cudaErrorCooperativeLaunchTooLarge = 720 - cudaErrorNotPermitted = 800 - cudaErrorNotSupported = 801 - cudaErrorSystemNotReady = 802 - cudaErrorSystemDriverMismatch = 803 - cudaErrorCompatNotSupportedOnDevice = 804 - cudaErrorStreamCaptureUnsupported = 900 - cudaErrorStreamCaptureInvalidated = 901 - cudaErrorStreamCaptureMerge = 902 - cudaErrorStreamCaptureUnmatched = 903 - cudaErrorStreamCaptureUnjoined = 904 - cudaErrorStreamCaptureIsolation = 905 - cudaErrorStreamCaptureImplicit = 906 - cudaErrorCapturedEvent = 907 - cudaErrorStreamCaptureWrongThread = 908 - cudaErrorTimeout = 909 - cudaErrorGraphExecUpdateFailure = 910 - cudaErrorUnknown = 999 - cudaErrorApiFailureBase = 10000 - - ctypedef cudaError cudaError_t - - ctypedef enum CUresult: - CUDA_SUCCESS = 0 - CUDA_ERROR_INVALID_VALUE = 1 - CUDA_ERROR_OUT_OF_MEMORY = 2 - CUDA_ERROR_NOT_INITIALIZED = 3 - CUDA_ERROR_DEINITIALIZED = 4 - CUDA_ERROR_PROFILER_DISABLED = 5 - CUDA_ERROR_PROFILER_NOT_INITIALIZED = 6 - CUDA_ERROR_PROFILER_ALREADY_STARTED = 7 - CUDA_ERROR_PROFILER_ALREADY_STOPPED = 8 - CUDA_ERROR_NO_DEVICE = 100 - CUDA_ERROR_INVALID_DEVICE = 101 - CUDA_ERROR_INVALID_IMAGE = 200 - CUDA_ERROR_INVALID_CONTEXT = 201 - CUDA_ERROR_CONTEXT_ALREADY_CURRENT = 202 - CUDA_ERROR_MAP_FAILED = 205 - CUDA_ERROR_UNMAP_FAILED = 206 - CUDA_ERROR_ARRAY_IS_MAPPED = 207 - CUDA_ERROR_ALREADY_MAPPED = 208 - CUDA_ERROR_NO_BINARY_FOR_GPU = 209 - CUDA_ERROR_ALREADY_ACQUIRED = 210 - CUDA_ERROR_NOT_MAPPED = 211 - CUDA_ERROR_NOT_MAPPED_AS_ARRAY = 212 - CUDA_ERROR_NOT_MAPPED_AS_POINTER = 213 - CUDA_ERROR_ECC_UNCORRECTABLE = 214 - CUDA_ERROR_UNSUPPORTED_LIMIT = 215 - CUDA_ERROR_CONTEXT_ALREADY_IN_USE = 216 - CUDA_ERROR_PEER_ACCESS_UNSUPPORTED = 217 - CUDA_ERROR_INVALID_PTX = 218 - CUDA_ERROR_INVALID_GRAPHICS_CONTEXT = 219 - CUDA_ERROR_NVLINK_UNCORRECTABLE = 220 - CUDA_ERROR_JIT_COMPILER_NOT_FOUND = 221 - CUDA_ERROR_INVALID_SOURCE = 300 - CUDA_ERROR_FILE_NOT_FOUND = 301 - CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND = 302 - CUDA_ERROR_SHARED_OBJECT_INIT_FAILED = 303 - CUDA_ERROR_OPERATING_SYSTEM = 304 - CUDA_ERROR_INVALID_HANDLE = 400 - CUDA_ERROR_ILLEGAL_STATE = 401 - CUDA_ERROR_NOT_FOUND = 500 - CUDA_ERROR_NOT_READY = 600 - CUDA_ERROR_ILLEGAL_ADDRESS = 700 - CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES = 701 - CUDA_ERROR_LAUNCH_TIMEOUT = 702 - CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING = 703 - CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED = 704 - CUDA_ERROR_PEER_ACCESS_NOT_ENABLED = 705 - CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE = 708 - CUDA_ERROR_CONTEXT_IS_DESTROYED = 709 - CUDA_ERROR_ASSERT = 710 - CUDA_ERROR_TOO_MANY_PEERS = 711 - CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED = 712 - CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED = 713 - CUDA_ERROR_HARDWARE_STACK_ERROR = 714 - CUDA_ERROR_ILLEGAL_INSTRUCTION = 715 - CUDA_ERROR_MISALIGNED_ADDRESS = 716 - CUDA_ERROR_INVALID_ADDRESS_SPACE = 717 - CUDA_ERROR_INVALID_PC = 718 - CUDA_ERROR_LAUNCH_FAILED = 719 - CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE = 720 - CUDA_ERROR_NOT_PERMITTED = 800 - CUDA_ERROR_NOT_SUPPORTED = 801 - CUDA_ERROR_SYSTEM_NOT_READY = 802 - CUDA_ERROR_SYSTEM_DRIVER_MISMATCH = 803 - CUDA_ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE = 804 - CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED = 900 - CUDA_ERROR_STREAM_CAPTURE_INVALIDATED = 901 - CUDA_ERROR_STREAM_CAPTURE_MERGE = 902 - CUDA_ERROR_STREAM_CAPTURE_UNMATCHED = 903 - CUDA_ERROR_STREAM_CAPTURE_UNJOINED = 904 - CUDA_ERROR_STREAM_CAPTURE_ISOLATION = 905 - CUDA_ERROR_STREAM_CAPTURE_IMPLICIT = 906 - CUDA_ERROR_CAPTURED_EVENT = 907 - CUDA_ERROR_STREAM_CAPTURE_WRONG_THREAD = 908 - CUDA_ERROR_TIMEOUT = 909 - CUDA_ERROR_GRAPH_EXEC_UPDATE_FAILURE = 910 - CUDA_ERROR_UNKNOWN = 999 - - ctypedef struct CUuuid_st: - char bytes[16] - - ctypedef CUuuid_st cudaUUID_t - - ctypedef struct cudaDeviceProp: - int ECCEnabled - int asyncEngineCount - int canMapHostMemory - int canUseHostPointerForRegisteredMem - int clockRate - int computeMode - int computePreemptionSupported - int concurrentKernels - int concurrentManagedAccess - int cooperativeLaunch - int cooperativeMultiDeviceLaunch - int deviceOverlap - int directManagedMemAccessFromHost - int globalL1CacheSupported - int hostNativeAtomicSupported - int integrated - int isMultiGpuBoard - int kernelExecTimeoutEnabled - int l2CacheSize - int localL1CacheSupported - char luid[8] - unsigned int luidDeviceNodeMask - int major - int managedMemory - int maxGridSize[3] - int maxSurface1D - int maxSurface1DLayered[2] - int maxSurface2D[2] - int maxSurface2DLayered[3] - int maxSurface3D[3] - int maxSurfaceCubemap - int maxSurfaceCubemapLayered[2] - int maxTexture1D - int maxTexture1DLayered[2] - int maxTexture1DLinear - int maxTexture1DMipmap - int maxTexture2D[2] - int maxTexture2DGather[2] - int maxTexture2DLayered[3] - int maxTexture2DLinear[3] - int maxTexture2DMipmap[2] - int maxTexture3D[3] - int maxTexture3DAlt[3] - int maxTextureCubemap - int maxTextureCubemapLayered[2] - int maxThreadsDim[3] - int maxThreadsPerBlock - int maxThreadsPerMultiProcessor - size_t memPitch - int memoryBusWidth - int memoryClockRate - int minor - int multiGpuBoardGroupID - int multiProcessorCount - char name[256] - int pageableMemoryAccess - int pageableMemoryAccessUsesHostPageTables - int pciBusID - int pciDeviceID - int pciDomainID - int regsPerBlock - int regsPerMultiprocessor - size_t sharedMemPerBlock - size_t sharedMemPerBlockOptin - size_t sharedMemPerMultiprocessor - int singleToDoublePrecisionPerfRatio - int streamPrioritiesSupported - size_t surfaceAlignment - int tccDriver - size_t textureAlignment - size_t texturePitchAlignment - size_t totalConstMem - size_t totalGlobalMem - int unifiedAddressing - cudaUUID_t uuid - int warpSize - - CUresult cuDeviceGetName(char* name, int length, int device) - - CUresult cuGetErrorName(CUresult error, const char** pStr) - CUresult cuGetErrorString(CUresult error, const char** pStr) - -cdef extern from "cuda_runtime_api.h" nogil: - - cudaError_t cudaDriverGetVersion(int* driverVersion) - cudaError_t cudaRuntimeGetVersion(int* runtimeVersion) - cudaError_t cudaGetDeviceCount(int* count) - cudaError_t cudaGetDevice(int* device) - cudaError_t cudaDeviceGetAttribute(int* value, - cudaDeviceAttr attr, - int device) - cudaError_t cudaGetDeviceProperties(cudaDeviceProp* prop, int device) - cudaError_t cudaSetDevice(int device) - - const char* cudaGetErrorString(cudaError_t error) - const char* cudaGetErrorName(cudaError_t error) diff --git a/python/rmm/_cuda/11.x/gpu.pxi b/python/rmm/_cuda/11.x/gpu.pxi deleted file mode 100644 index 856ff04e9..000000000 --- a/python/rmm/_cuda/11.x/gpu.pxi +++ /dev/null @@ -1,406 +0,0 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. -# For CUDA 11.0, 11.1 and 11.2 - -cdef extern from "cuda.h" nogil: - cpdef enum cudaDeviceAttr: - cudaDevAttrMaxThreadsPerBlock = 1 - cudaDevAttrMaxBlockDimX = 2 - cudaDevAttrMaxBlockDimY = 3 - cudaDevAttrMaxBlockDimZ = 4 - cudaDevAttrMaxGridDimX = 5 - cudaDevAttrMaxGridDimY = 6 - cudaDevAttrMaxGridDimZ = 7 - cudaDevAttrMaxSharedMemoryPerBlock = 8 - cudaDevAttrTotalConstantMemory = 9 - cudaDevAttrWarpSize = 10 - cudaDevAttrMaxPitch = 11 - cudaDevAttrMaxRegistersPerBlock = 12 - cudaDevAttrClockRate = 13 - cudaDevAttrTextureAlignment = 14 - cudaDevAttrGpuOverlap = 15 - cudaDevAttrMultiProcessorCount = 16 - cudaDevAttrKernelExecTimeout = 17 - cudaDevAttrIntegrated = 18 - cudaDevAttrCanMapHostMemory = 19 - cudaDevAttrComputeMode = 20 - cudaDevAttrMaxTexture1DWidth = 21 - cudaDevAttrMaxTexture2DWidth = 22 - cudaDevAttrMaxTexture2DHeight = 23 - cudaDevAttrMaxTexture3DWidth = 24 - cudaDevAttrMaxTexture3DHeight = 25 - cudaDevAttrMaxTexture3DDepth = 26 - cudaDevAttrMaxTexture2DLayeredWidth = 27 - cudaDevAttrMaxTexture2DLayeredHeight = 28 - cudaDevAttrMaxTexture2DLayeredLayers = 29 - cudaDevAttrSurfaceAlignment = 30 - cudaDevAttrConcurrentKernels = 31 - cudaDevAttrEccEnabled = 32 - cudaDevAttrPciBusId = 33 - cudaDevAttrPciDeviceId = 34 - cudaDevAttrTccDriver = 35 - cudaDevAttrMemoryClockRate = 36 - cudaDevAttrGlobalMemoryBusWidth = 37 - cudaDevAttrL2CacheSize = 38 - cudaDevAttrMaxThreadsPerMultiProcessor = 39 - cudaDevAttrAsyncEngineCount = 40 - cudaDevAttrUnifiedAddressing = 41 - cudaDevAttrMaxTexture1DLayeredWidth = 42 - cudaDevAttrMaxTexture1DLayeredLayers = 43 - cudaDevAttrMaxTexture2DGatherWidth = 45 - cudaDevAttrMaxTexture2DGatherHeight = 46 - cudaDevAttrMaxTexture3DWidthAlt = 47 - cudaDevAttrMaxTexture3DHeightAlt = 48 - cudaDevAttrMaxTexture3DDepthAlt = 49 - cudaDevAttrPciDomainId = 50 - cudaDevAttrTexturePitchAlignment = 51 - cudaDevAttrMaxTextureCubemapWidth = 52 - cudaDevAttrMaxTextureCubemapLayeredWidth = 53 - cudaDevAttrMaxTextureCubemapLayeredLayers = 54 - cudaDevAttrMaxSurface1DWidth = 55 - cudaDevAttrMaxSurface2DWidth = 56 - cudaDevAttrMaxSurface2DHeight = 57 - cudaDevAttrMaxSurface3DWidth = 58 - cudaDevAttrMaxSurface3DHeight = 59 - cudaDevAttrMaxSurface3DDepth = 60 - cudaDevAttrMaxSurface1DLayeredWidth = 61 - cudaDevAttrMaxSurface1DLayeredLayers = 62 - cudaDevAttrMaxSurface2DLayeredWidth = 63 - cudaDevAttrMaxSurface2DLayeredHeight = 64 - cudaDevAttrMaxSurface2DLayeredLayers = 65 - cudaDevAttrMaxSurfaceCubemapWidth = 66 - cudaDevAttrMaxSurfaceCubemapLayeredWidth = 67 - cudaDevAttrMaxSurfaceCubemapLayeredLayers = 68 - cudaDevAttrMaxTexture1DLinearWidth = 69 - cudaDevAttrMaxTexture2DLinearWidth = 70 - cudaDevAttrMaxTexture2DLinearHeight = 71 - cudaDevAttrMaxTexture2DLinearPitch = 72 - cudaDevAttrMaxTexture2DMipmappedWidth = 73 - cudaDevAttrMaxTexture2DMipmappedHeight = 74 - cudaDevAttrComputeCapabilityMajor = 75 - cudaDevAttrComputeCapabilityMinor = 76 - cudaDevAttrMaxTexture1DMipmappedWidth = 77 - cudaDevAttrStreamPrioritiesSupported = 78 - cudaDevAttrGlobalL1CacheSupported = 79 - cudaDevAttrLocalL1CacheSupported = 80 - cudaDevAttrMaxSharedMemoryPerMultiprocessor = 81 - cudaDevAttrMaxRegistersPerMultiprocessor = 82 - cudaDevAttrManagedMemory = 83 - cudaDevAttrIsMultiGpuBoard = 84 - cudaDevAttrMultiGpuBoardGroupID = 85 - cudaDevAttrHostNativeAtomicSupported = 86 - cudaDevAttrSingleToDoublePrecisionPerfRatio = 87 - cudaDevAttrPageableMemoryAccess = 88 - cudaDevAttrConcurrentManagedAccess = 89 - cudaDevAttrComputePreemptionSupported = 90 - cudaDevAttrCanUseHostPointerForRegisteredMem = 91 - cudaDevAttrReserved92 = 92 - cudaDevAttrReserved93 = 93 - cudaDevAttrReserved94 = 94 - cudaDevAttrCooperativeLaunch = 95 - cudaDevAttrCooperativeMultiDeviceLaunch = 96 - cudaDevAttrMaxSharedMemoryPerBlockOptin = 97 - cudaDevAttrCanFlushRemoteWrites = 98 - cudaDevAttrHostRegisterSupported = 99 - cudaDevAttrPageableMemoryAccessUsesHostPageTables = 100 - cudaDevAttrDirectManagedMemAccessFromHost = 101 - cudaDevAttrMaxBlocksPerMultiprocessor = 106 - cudaDevAttrReservedSharedMemoryPerBlock = 111 - - cpdef enum cudaError: - cudaSuccess = 0 - cudaErrorInvalidValue = 1 - cudaErrorMemoryAllocation = 2 - cudaErrorInitializationError = 3 - cudaErrorCudartUnloading = 4 - cudaErrorProfilerDisabled = 5 - cudaErrorProfilerNotInitialized = 6 - cudaErrorProfilerAlreadyStarted = 7 - cudaErrorProfilerAlreadyStopped = 8 - cudaErrorInvalidConfiguration = 9 - cudaErrorInvalidPitchValue = 12 - cudaErrorInvalidSymbol = 13 - cudaErrorInvalidHostPointer = 16 - cudaErrorInvalidDevicePointer = 17 - cudaErrorInvalidTexture = 18 - cudaErrorInvalidTextureBinding = 19 - cudaErrorInvalidChannelDescriptor = 20 - cudaErrorInvalidMemcpyDirection = 21 - cudaErrorAddressOfConstant = 22 - cudaErrorTextureFetchFailed = 23 - cudaErrorTextureNotBound = 24 - cudaErrorSynchronizationError = 25 - cudaErrorInvalidFilterSetting = 26 - cudaErrorInvalidNormSetting = 27 - cudaErrorMixedDeviceExecution = 28 - cudaErrorNotYetImplemented = 31 - cudaErrorMemoryValueTooLarge = 32 - cudaErrorInsufficientDriver = 35 - cudaErrorInvalidSurface = 37 - cudaErrorDuplicateVariableName = 43 - cudaErrorDuplicateTextureName = 44 - cudaErrorDuplicateSurfaceName = 45 - cudaErrorDevicesUnavailable = 46 - cudaErrorIncompatibleDriverContext = 49 - cudaErrorMissingConfiguration = 52 - cudaErrorPriorLaunchFailure = 53 - cudaErrorLaunchMaxDepthExceeded = 65 - cudaErrorLaunchFileScopedTex = 66 - cudaErrorLaunchFileScopedSurf = 67 - cudaErrorSyncDepthExceeded = 68 - cudaErrorLaunchPendingCountExceeded = 69 - cudaErrorInvalidDeviceFunction = 98 - cudaErrorNoDevice = 100 - cudaErrorInvalidDevice = 101 - cudaErrorStartupFailure = 127 - cudaErrorInvalidKernelImage = 200 - cudaErrorDeviceUninitialized = 201 - cudaErrorMapBufferObjectFailed = 205 - cudaErrorUnmapBufferObjectFailed = 206 - cudaErrorArrayIsMapped = 207 - cudaErrorAlreadyMapped = 208 - cudaErrorNoKernelImageForDevice = 209 - cudaErrorAlreadyAcquired = 210 - cudaErrorNotMapped = 211 - cudaErrorNotMappedAsArray = 212 - cudaErrorNotMappedAsPointer = 213 - cudaErrorECCUncorrectable = 214 - cudaErrorUnsupportedLimit = 215 - cudaErrorDeviceAlreadyInUse = 216 - cudaErrorPeerAccessUnsupported = 217 - cudaErrorInvalidPtx = 218 - cudaErrorInvalidGraphicsContext = 219 - cudaErrorNvlinkUncorrectable = 220 - cudaErrorJitCompilerNotFound = 221 - cudaErrorInvalidSource = 300 - cudaErrorFileNotFound = 301 - cudaErrorSharedObjectSymbolNotFound = 302 - cudaErrorSharedObjectInitFailed = 303 - cudaErrorOperatingSystem = 304 - cudaErrorInvalidResourceHandle = 400 - cudaErrorIllegalState = 401 - cudaErrorSymbolNotFound = 500 - cudaErrorNotReady = 600 - cudaErrorIllegalAddress = 700 - cudaErrorLaunchOutOfResources = 701 - cudaErrorLaunchTimeout = 702 - cudaErrorLaunchIncompatibleTexturing = 703 - cudaErrorPeerAccessAlreadyEnabled = 704 - cudaErrorPeerAccessNotEnabled = 705 - cudaErrorSetOnActiveProcess = 708 - cudaErrorContextIsDestroyed = 709 - cudaErrorAssert = 710 - cudaErrorTooManyPeers = 711 - cudaErrorHostMemoryAlreadyRegistered = 712 - cudaErrorHostMemoryNotRegistered = 713 - cudaErrorHardwareStackError = 714 - cudaErrorIllegalInstruction = 715 - cudaErrorMisalignedAddress = 716 - cudaErrorInvalidAddressSpace = 717 - cudaErrorInvalidPc = 718 - cudaErrorLaunchFailure = 719 - cudaErrorCooperativeLaunchTooLarge = 720 - cudaErrorNotPermitted = 800 - cudaErrorNotSupported = 801 - cudaErrorSystemNotReady = 802 - cudaErrorSystemDriverMismatch = 803 - cudaErrorCompatNotSupportedOnDevice = 804 - cudaErrorStreamCaptureUnsupported = 900 - cudaErrorStreamCaptureInvalidated = 901 - cudaErrorStreamCaptureMerge = 902 - cudaErrorStreamCaptureUnmatched = 903 - cudaErrorStreamCaptureUnjoined = 904 - cudaErrorStreamCaptureIsolation = 905 - cudaErrorStreamCaptureImplicit = 906 - cudaErrorCapturedEvent = 907 - cudaErrorStreamCaptureWrongThread = 908 - cudaErrorTimeout = 909 - cudaErrorGraphExecUpdateFailure = 910 - cudaErrorUnknown = 999 - cudaErrorApiFailureBase = 10000 - - ctypedef cudaError cudaError_t - - ctypedef enum CUresult: - CUDA_SUCCESS = 0 - CUDA_ERROR_INVALID_VALUE = 1 - CUDA_ERROR_OUT_OF_MEMORY = 2 - CUDA_ERROR_NOT_INITIALIZED = 3 - CUDA_ERROR_DEINITIALIZED = 4 - CUDA_ERROR_PROFILER_DISABLED = 5 - CUDA_ERROR_PROFILER_NOT_INITIALIZED = 6 - CUDA_ERROR_PROFILER_ALREADY_STARTED = 7 - CUDA_ERROR_PROFILER_ALREADY_STOPPED = 8 - CUDA_ERROR_NO_DEVICE = 100 - CUDA_ERROR_INVALID_DEVICE = 101 - CUDA_ERROR_INVALID_IMAGE = 200 - CUDA_ERROR_INVALID_CONTEXT = 201 - CUDA_ERROR_CONTEXT_ALREADY_CURRENT = 202 - CUDA_ERROR_MAP_FAILED = 205 - CUDA_ERROR_UNMAP_FAILED = 206 - CUDA_ERROR_ARRAY_IS_MAPPED = 207 - CUDA_ERROR_ALREADY_MAPPED = 208 - CUDA_ERROR_NO_BINARY_FOR_GPU = 209 - CUDA_ERROR_ALREADY_ACQUIRED = 210 - CUDA_ERROR_NOT_MAPPED = 211 - CUDA_ERROR_NOT_MAPPED_AS_ARRAY = 212 - CUDA_ERROR_NOT_MAPPED_AS_POINTER = 213 - CUDA_ERROR_ECC_UNCORRECTABLE = 214 - CUDA_ERROR_UNSUPPORTED_LIMIT = 215 - CUDA_ERROR_CONTEXT_ALREADY_IN_USE = 216 - CUDA_ERROR_PEER_ACCESS_UNSUPPORTED = 217 - CUDA_ERROR_INVALID_PTX = 218 - CUDA_ERROR_INVALID_GRAPHICS_CONTEXT = 219 - CUDA_ERROR_NVLINK_UNCORRECTABLE = 220 - CUDA_ERROR_JIT_COMPILER_NOT_FOUND = 221 - CUDA_ERROR_INVALID_SOURCE = 300 - CUDA_ERROR_FILE_NOT_FOUND = 301 - CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND = 302 - CUDA_ERROR_SHARED_OBJECT_INIT_FAILED = 303 - CUDA_ERROR_OPERATING_SYSTEM = 304 - CUDA_ERROR_INVALID_HANDLE = 400 - CUDA_ERROR_ILLEGAL_STATE = 401 - CUDA_ERROR_NOT_FOUND = 500 - CUDA_ERROR_NOT_READY = 600 - CUDA_ERROR_ILLEGAL_ADDRESS = 700 - CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES = 701 - CUDA_ERROR_LAUNCH_TIMEOUT = 702 - CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING = 703 - CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED = 704 - CUDA_ERROR_PEER_ACCESS_NOT_ENABLED = 705 - CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE = 708 - CUDA_ERROR_CONTEXT_IS_DESTROYED = 709 - CUDA_ERROR_ASSERT = 710 - CUDA_ERROR_TOO_MANY_PEERS = 711 - CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED = 712 - CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED = 713 - CUDA_ERROR_HARDWARE_STACK_ERROR = 714 - CUDA_ERROR_ILLEGAL_INSTRUCTION = 715 - CUDA_ERROR_MISALIGNED_ADDRESS = 716 - CUDA_ERROR_INVALID_ADDRESS_SPACE = 717 - CUDA_ERROR_INVALID_PC = 718 - CUDA_ERROR_LAUNCH_FAILED = 719 - CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE = 720 - CUDA_ERROR_NOT_PERMITTED = 800 - CUDA_ERROR_NOT_SUPPORTED = 801 - CUDA_ERROR_SYSTEM_NOT_READY = 802 - CUDA_ERROR_SYSTEM_DRIVER_MISMATCH = 803 - CUDA_ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE = 804 - CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED = 900 - CUDA_ERROR_STREAM_CAPTURE_INVALIDATED = 901 - CUDA_ERROR_STREAM_CAPTURE_MERGE = 902 - CUDA_ERROR_STREAM_CAPTURE_UNMATCHED = 903 - CUDA_ERROR_STREAM_CAPTURE_UNJOINED = 904 - CUDA_ERROR_STREAM_CAPTURE_ISOLATION = 905 - CUDA_ERROR_STREAM_CAPTURE_IMPLICIT = 906 - CUDA_ERROR_CAPTURED_EVENT = 907 - CUDA_ERROR_STREAM_CAPTURE_WRONG_THREAD = 908 - CUDA_ERROR_TIMEOUT = 909 - CUDA_ERROR_GRAPH_EXEC_UPDATE_FAILURE = 910 - CUDA_ERROR_UNKNOWN = 999 - - ctypedef struct CUuuid_st: - char bytes[16] - - ctypedef CUuuid_st cudaUUID_t - - ctypedef struct cudaDeviceProp: - int ECCEnabled - int asyncEngineCount - int canMapHostMemory - int canUseHostPointerForRegisteredMem - int clockRate - int computeMode - int computePreemptionSupported - int concurrentKernels - int concurrentManagedAccess - int cooperativeLaunch - int cooperativeMultiDeviceLaunch - int deviceOverlap - int directManagedMemAccessFromHost - int globalL1CacheSupported - int hostNativeAtomicSupported - int integrated - int isMultiGpuBoard - int kernelExecTimeoutEnabled - int l2CacheSize - int localL1CacheSupported - char luid[8] - unsigned int luidDeviceNodeMask - int major - int managedMemory - int maxGridSize[3] - int maxSurface1D - int maxSurface1DLayered[2] - int maxSurface2D[2] - int maxSurface2DLayered[3] - int maxSurface3D[3] - int maxSurfaceCubemap - int maxSurfaceCubemapLayered[2] - int maxTexture1D - int maxTexture1DLayered[2] - int maxTexture1DLinear - int maxTexture1DMipmap - int maxTexture2D[2] - int maxTexture2DGather[2] - int maxTexture2DLayered[3] - int maxTexture2DLinear[3] - int maxTexture2DMipmap[2] - int maxTexture3D[3] - int maxTexture3DAlt[3] - int maxTextureCubemap - int maxTextureCubemapLayered[2] - int maxThreadsDim[3] - int maxThreadsPerBlock - int maxThreadsPerMultiProcessor - size_t memPitch - int memoryBusWidth - int memoryClockRate - int minor - int multiGpuBoardGroupID - int multiProcessorCount - char name[256] - int pageableMemoryAccess - int pageableMemoryAccessUsesHostPageTables - int pciBusID - int pciDeviceID - int pciDomainID - int regsPerBlock - int regsPerMultiprocessor - size_t sharedMemPerBlock - size_t sharedMemPerBlockOptin - size_t sharedMemPerMultiprocessor - int singleToDoublePrecisionPerfRatio - int streamPrioritiesSupported - size_t surfaceAlignment - int tccDriver - size_t textureAlignment - size_t texturePitchAlignment - size_t totalConstMem - size_t totalGlobalMem - int unifiedAddressing - cudaUUID_t uuid - int warpSize - int accessPolicyMaxWindowSize - int maxBlocksPerMultiProcessor - int persistingL2CacheMaxSize - size_t reservedSharedMemPerBlock - - CUresult cuDeviceGetName(char* name, int length, int device) - - CUresult cuGetErrorName(CUresult error, const char** pStr) - CUresult cuGetErrorString(CUresult error, const char** pStr) - -cdef extern from "cuda_runtime_api.h" nogil: - - cudaError_t cudaDriverGetVersion(int* driverVersion) - cudaError_t cudaRuntimeGetVersion(int* runtimeVersion) - cudaError_t cudaGetDeviceCount(int* count) - cudaError_t cudaGetDevice(int* device) - cudaError_t cudaDeviceGetAttribute(int* value, - cudaDeviceAttr attr, - int device) - cudaError_t cudaGetDeviceProperties(cudaDeviceProp* prop, int device) - cudaError_t cudaSetDevice(int device) - - const char* cudaGetErrorString(cudaError_t error) - const char* cudaGetErrorName(cudaError_t error) diff --git a/python/rmm/_cuda/gpu.pyx b/python/rmm/_cuda/gpu.py similarity index 55% rename from python/rmm/_cuda/gpu.pyx rename to python/rmm/_cuda/gpu.py index f570df811..a1ce61564 100644 --- a/python/rmm/_cuda/gpu.pyx +++ b/python/rmm/_cuda/gpu.py @@ -1,59 +1,33 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -from rmm._cuda.gpu cimport ( - CUresult, - cudaDeviceAttr, - cudaDeviceGetAttribute, - cudaDeviceProp, - cudaDriverGetVersion, - cudaError, - cudaError_t, - cudaGetDeviceCount, - cudaGetDeviceProperties, - cudaGetErrorName, - cudaGetErrorString, - cudaRuntimeGetVersion, - cuDeviceGetName, - cuGetErrorName, - cuGetErrorString, -) - -from enum import IntEnum +from cuda import cuda, cudart class CUDARuntimeError(RuntimeError): - - def __init__(self, cudaError_t status): + def __init__(self, status: cudart.cudaError_t): self.status = status - cdef str name = cudaGetErrorName(status).decode() - cdef str msg = cudaGetErrorString(status).decode() + + _, name = cudart.cudaGetErrorName(status) + _, msg = cudart.cudaGetErrorString(status) + super(CUDARuntimeError, self).__init__( - '%s: %s' % (name, msg)) + f"{name.decode()}: {msg.decode()}" + ) def __reduce__(self): return (type(self), (self.status,)) class CUDADriverError(RuntimeError): - - def __init__(self, CUresult status): + def __init__(self, status: cuda.CUresult): self.status = status - cdef const char* name_cstr - cdef CUresult name_status = cuGetErrorName(status, &name_cstr) - if name_status != 0: - raise CUDADriverError(name_status) - - cdef const char* msg_cstr - cdef CUresult msg_status = cuGetErrorString(status, &msg_cstr) - if msg_status != 0: - raise CUDADriverError(msg_status) - - cdef str name = name_cstr.decode() - cdef str msg = msg_cstr.decode() + _, name = cuda.cuGetErrorName(status) + _, msg = cuda.cuGetErrorString(status) super(CUDADriverError, self).__init__( - '%s: %s' % (name, msg)) + f"{name.decode()}: {msg.decode()}" + ) def __reduce__(self): return (type(self), (self.status,)) @@ -69,9 +43,8 @@ def driverGetVersion(): This function automatically raises CUDARuntimeError with error message and status code. """ - cdef int version - cdef cudaError_t status = cudaDriverGetVersion(&version) - if status != cudaError.cudaSuccess: + status, version = cudart.cudaDriverGetVersion() + if status != cudart.cudaError_t.cudaSuccess: raise CUDARuntimeError(status) return version @@ -80,14 +53,13 @@ def getDevice(): """ Get the current CUDA device """ - cdef int current_device - cdef cudaError_t status = cudaGetDevice(¤t_device) - if status != cudaError.cudaSuccess: + status, device = cudart.cudaGetDevice() + if status != cudart.cudaError_t.cudaSuccess: raise CUDARuntimeError(status) - return current_device + return device -def setDevice(int device): +def setDevice(device: int): """ Set the current CUDA device Parameters @@ -95,9 +67,8 @@ def setDevice(int device): device : int The ID of the device to set as current """ - cdef cudaError_t status = cudaSetDevice(device) - - if status != cudaError.cudaSuccess: + (status,) = cudart.cudaSetDevice(device) + if status != cudart.cudaError_t.cudaSuccess: raise CUDARuntimeError(status) @@ -110,10 +81,8 @@ def runtimeGetVersion(): This function automatically raises CUDARuntimeError with error message and status code. """ - - cdef int version - cdef cudaError_t status = cudaRuntimeGetVersion(&version) - if status != cudaError.cudaSuccess: + status, version = cudart.cudaRuntimeGetVersion() + if status != cudart.cudaError_t.cudaSuccess: raise CUDARuntimeError(status) return version @@ -126,16 +95,13 @@ def getDeviceCount(): This function automatically raises CUDARuntimeError with error message and status code. """ - - cdef int count - cdef cudaError_t status = cudaGetDeviceCount(&count) - - if status != cudaError.cudaSuccess: + status, count = cudart.cudaGetDeviceCount() + if status != cudart.cudaError_t.cudaSuccess: raise CUDARuntimeError(status) return count -def getDeviceAttribute(cudaDeviceAttr attr, int device): +def getDeviceAttribute(attr: cudart.cudaDeviceAttr, device: int): """ Returns information about the device. @@ -149,15 +115,13 @@ def getDeviceAttribute(cudaDeviceAttr attr, int device): This function automatically raises CUDARuntimeError with error message and status code. """ - - cdef int value - cdef cudaError_t status = cudaDeviceGetAttribute(&value, attr, device) - if status != cudaError.cudaSuccess: + status, value = cudart.cudaDeviceGetAttribute(attr, device) + if status != cudart.cudaError_t.cudaSuccess: raise CUDARuntimeError(status) return value -def getDeviceProperties(int device): +def getDeviceProperties(device: int): """ Returns information about the compute-device. @@ -169,15 +133,13 @@ def getDeviceProperties(int device): This function automatically raises CUDARuntimeError with error message and status code. """ - - cdef cudaDeviceProp prop - cdef cudaError_t status = cudaGetDeviceProperties(&prop, device) - if status != cudaError.cudaSuccess: + status, prop = cudart.cudaGetDeviceProperties(device) + if status != cudart.cudaError_t.cudaSuccess: raise CUDARuntimeError(status) return prop -def deviceGetName(int device): +def deviceGetName(device: int): """ Returns an identifer string for the device. @@ -190,12 +152,7 @@ def deviceGetName(int device): and status code. """ - cdef char[256] device_name - cdef CUresult status = cuDeviceGetName( - device_name, - sizeof(device_name), - device - ) - if status != 0: + status, device_name = cuda.cuDeviceGetName(256, cuda.CUdevice(device)) + if status != cuda.CUresult.CUDA_SUCCESS: raise CUDADriverError(status) return device_name.decode() diff --git a/python/rmm/_cuda/stream.pxd b/python/rmm/_cuda/stream.pxd index 0806a7310..6aa4e0b24 100644 --- a/python/rmm/_cuda/stream.pxd +++ b/python/rmm/_cuda/stream.pxd @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +from cuda.ccudart cimport cudaStream_t from libc.stdint cimport uintptr_t from libcpp cimport bool from rmm._lib.cuda_stream_view cimport cuda_stream_view -from rmm._lib.lib cimport cudaStream_t cdef class Stream: diff --git a/python/rmm/_cuda/stream.pyx b/python/rmm/_cuda/stream.pyx index 4c9890d51..4f2ce26d0 100644 --- a/python/rmm/_cuda/stream.pyx +++ b/python/rmm/_cuda/stream.pyx @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from cuda.ccudart cimport cudaStream_t from libc.stdint cimport uintptr_t from libcpp cimport bool @@ -21,7 +22,6 @@ from rmm._lib.cuda_stream_view cimport ( cuda_stream_per_thread, cuda_stream_view, ) -from rmm._lib.lib cimport cudaStream_t from numba import cuda diff --git a/python/rmm/_lib/cuda_stream.pxd b/python/rmm/_lib/cuda_stream.pxd index 4eae4bc76..1eed1cefb 100644 --- a/python/rmm/_lib/cuda_stream.pxd +++ b/python/rmm/_lib/cuda_stream.pxd @@ -13,11 +13,11 @@ # limitations under the License. cimport cython +from cuda.ccudart cimport cudaStream_t from libcpp cimport bool from libcpp.memory cimport unique_ptr from rmm._lib.cuda_stream_view cimport cuda_stream_view -from rmm._lib.lib cimport cudaStream_t cdef extern from "rmm/cuda_stream.hpp" namespace "rmm" nogil: diff --git a/python/rmm/_lib/cuda_stream.pyx b/python/rmm/_lib/cuda_stream.pyx index 44ca6d75e..d93af2509 100644 --- a/python/rmm/_lib/cuda_stream.pyx +++ b/python/rmm/_lib/cuda_stream.pyx @@ -13,6 +13,7 @@ # limitations under the License. cimport cython +from cuda.ccudart cimport cudaStream_t from libc.stdint cimport uintptr_t from libcpp cimport bool diff --git a/python/rmm/_lib/cuda_stream_view.pxd b/python/rmm/_lib/cuda_stream_view.pxd index 7031a03ea..bf0d33c24 100644 --- a/python/rmm/_lib/cuda_stream_view.pxd +++ b/python/rmm/_lib/cuda_stream_view.pxd @@ -12,10 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +from cuda.ccudart cimport cudaStream_t from libcpp cimport bool -from rmm._lib.lib cimport cudaStream_t - cdef extern from "rmm/cuda_stream_view.hpp" namespace "rmm" nogil: cdef cppclass cuda_stream_view: diff --git a/python/rmm/_lib/device_buffer.pyx b/python/rmm/_lib/device_buffer.pyx index ece2f911f..bc761c29c 100644 --- a/python/rmm/_lib/device_buffer.pyx +++ b/python/rmm/_lib/device_buffer.pyx @@ -20,20 +20,20 @@ from libc.stdint cimport uintptr_t from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from rmm._cuda.gpu cimport cudaError, cudaError_t from rmm._cuda.stream cimport Stream from rmm._cuda.stream import DEFAULT_STREAM -from rmm._lib.lib cimport ( +cimport cuda.ccudart as ccudart +from cuda.ccudart cimport ( + cudaError, + cudaError_t, cudaMemcpyAsync, - cudaMemcpyDeviceToDevice, - cudaMemcpyDeviceToHost, - cudaMemcpyHostToDevice, cudaMemcpyKind, cudaStream_t, cudaStreamSynchronize, ) + from rmm._lib.memory_resource cimport get_current_device_resource @@ -78,7 +78,6 @@ cdef class DeviceBuffer: >>> db = rmm.DeviceBuffer(size=5) """ cdef const void* c_ptr - cdef cudaError_t err with nogil: c_ptr = ptr @@ -344,7 +343,7 @@ cpdef DeviceBuffer to_device(const unsigned char[::1] b, cdef void _copy_async(const void* src, void* dst, size_t count, - cudaMemcpyKind kind, + ccudart.cudaMemcpyKind kind, cuda_stream_view stream) nogil: """ Asynchronously copy data between host and/or device pointers @@ -403,7 +402,7 @@ cpdef void copy_ptr_to_host(uintptr_t db, with nogil: _copy_async(db, &hb[0], len(hb), - cudaMemcpyDeviceToHost, stream.view()) + cudaMemcpyKind.cudaMemcpyDeviceToHost, stream.view()) if stream.c_is_default(): stream.c_synchronize() @@ -447,7 +446,7 @@ cpdef void copy_host_to_ptr(const unsigned char[::1] hb, with nogil: _copy_async(&hb[0], db, len(hb), - cudaMemcpyHostToDevice, stream.view()) + cudaMemcpyKind.cudaMemcpyHostToDevice, stream.view()) if stream.c_is_default(): stream.c_synchronize() @@ -480,4 +479,4 @@ cpdef void copy_device_to_ptr(uintptr_t d_src, with nogil: _copy_async(d_src, d_dst, count, - cudaMemcpyDeviceToDevice, stream.view()) + cudaMemcpyKind.cudaMemcpyDeviceToDevice, stream.view()) diff --git a/python/rmm/_lib/lib.pxd b/python/rmm/_lib/lib.pxd index c06d69872..e35b672e4 100644 --- a/python/rmm/_lib/lib.pxd +++ b/python/rmm/_lib/lib.pxd @@ -17,24 +17,4 @@ from libcpp cimport bool from libcpp.utility cimport pair from libcpp.vector cimport vector -from rmm._cuda.gpu cimport cudaError_t - ctypedef pair[const char*, unsigned int] caller_pair - - -cdef extern from * nogil: - - ctypedef void* cudaStream_t "cudaStream_t" - - ctypedef enum cudaMemcpyKind "cudaMemcpyKind": - cudaMemcpyHostToHost = 0 - cudaMemcpyHostToDevice = 1 - cudaMemcpyDeviceToHost = 2 - cudaMemcpyDeviceToDevice = 3 - cudaMemcpyDefault = 4 - - cudaError_t cudaMemcpyAsync(void* dst, const void* src, size_t count, - cudaMemcpyKind kind) - cudaError_t cudaMemcpyAsync(void* dst, const void* src, size_t count, - cudaMemcpyKind kind, cudaStream_t stream) - cudaError_t cudaStreamSynchronize(cudaStream_t stream) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index d7711ed8a..16723a0a3 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -23,7 +23,9 @@ from libcpp.cast cimport dynamic_cast from libcpp.memory cimport make_shared, make_unique, shared_ptr, unique_ptr from libcpp.string cimport string -from rmm._cuda.gpu import CUDARuntimeError, cudaError, getDevice, setDevice +from cuda.cudart import cudaError_t + +from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice # NOTE: Keep extern declarations in .pyx file as much as possible to avoid @@ -705,7 +707,7 @@ cpdef void _initialize( try: original_device = getDevice() except CUDARuntimeError as e: - if e.status == cudaError.cudaErrorNoDevice: + if e.status == cudaError_t.cudaErrorNoDevice: warnings.warn(e.msg) else: raise e diff --git a/python/setup.py b/python/setup.py index 8edaf4c31..50888ab3c 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,6 +1,5 @@ # Copyright (c) 2019-2021, NVIDIA CORPORATION. -import filecmp import glob import os import re @@ -26,7 +25,7 @@ import versioneer -install_requires = ["numba", "cython"] +install_requires = ["numba", "cython", "cuda-python"] def get_cuda_version_from_header(cuda_include_dir): @@ -75,43 +74,6 @@ def get_cuda_version_from_header(cuda_include_dir): # use uninstalled headers in source tree rmm_include_dir = "../include" -# Preprocessor step to specify correct pxd file with -# valid symbols for specific version of CUDA. - -cwd = os.getcwd() -files_to_preprocess = ["gpu.pxd"] - -# The .pxi file is unchanged between some CUDA versions -# (e.g., 11.0 & 11.1), so we keep only a single copy -# of it -cuda_version_to_pxi_dir = { - "10.1": "10.1", - "10.2": "10.2", - "11": "11.x", -} - -for pxd_basename in files_to_preprocess: - pxi_basename = os.path.splitext(pxd_basename)[0] + ".pxi" - pxi_dir = cuda_version_to_pxi_dir.get(CUDA_VERSION) - if not pxi_dir: - # didn't get an exact match on major.minor version - see if - # we have a match on just the major version - pxi_dir = cuda_version_to_pxi_dir.get(CUDA_VERSION.split(".")[0]) - - if pxi_dir: - pxi_pathname = os.path.join(cwd, "rmm/_cuda", pxi_dir, pxi_basename,) - pxd_pathname = os.path.join(cwd, "rmm/_cuda", pxd_basename) - try: - if filecmp.cmp(pxi_pathname, pxd_pathname): - # files are the same, no need to copy - continue - except FileNotFoundError: - # pxd_pathname doesn't exist yet - pass - shutil.copyfile(pxi_pathname, pxd_pathname) - else: - raise TypeError(f"{CUDA_VERSION} is not supported.") - include_dirs = [ rmm_include_dir, os.path.dirname(sysconfig.get_path("include")), From d1d82b9cbdf8eba99fbf6d9992705e05b2d47ed7 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 19 Jan 2022 13:21:23 -0800 Subject: [PATCH 036/675] Use numba to get CUDA runtime version. (#946) This PR uses `numba` to fetch the CUDA runtime version, rather than cuda-python. The current [implementation](https://github.com/NVIDIA/cuda-python/blob/746b773c91e1ede708fe9a584b8cdb1c0f32b51d/cuda/_lib/ccudart/ccudart.pyx#L79-L82) of cuda-python's `cuda.cudart.cudaRuntimeGetVersion()` [hard-codes the runtime version](https://github.com/NVIDIA/cuda-python/blob/746b773c91e1ede708fe9a584b8cdb1c0f32b51d/cuda/_lib/ccudart/utils.pyx#L37), rather than querying the runtime for its version. This is a known limitation that may not be resolved in the near term. cc: @vzhurba01 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) - Ashwin Srinath (https://github.com/shwina) - https://github.com/jakirkham - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/946 --- python/rmm/_cuda/gpu.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/python/rmm/_cuda/gpu.py b/python/rmm/_cuda/gpu.py index a1ce61564..5dddaf54f 100644 --- a/python/rmm/_cuda/gpu.py +++ b/python/rmm/_cuda/gpu.py @@ -1,5 +1,6 @@ # Copyright (c) 2020, NVIDIA CORPORATION. +import numba.cuda from cuda import cuda, cudart @@ -78,13 +79,13 @@ def runtimeGetVersion(): The version is returned as (1000 major + 10 minor). For example, CUDA 9.2 would be represented by 9020. - This function automatically raises CUDARuntimeError with error message - and status code. + This calls numba.cuda.runtime.get_version() rather than cuda-python due to + current limitations in cuda-python. """ - status, version = cudart.cudaRuntimeGetVersion() - if status != cudart.cudaError_t.cudaSuccess: - raise CUDARuntimeError(status) - return version + # TODO: Replace this with `cuda.cudart.cudaRuntimeGetVersion()` when the + # limitation is fixed. + major, minor = numba.cuda.runtime.get_version() + return major * 1000 + minor * 10 def getDeviceCount(): From 11f1599210524868662fac8173b15de70318477c Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Thu, 20 Jan 2022 08:41:19 +1100 Subject: [PATCH 037/675] Build benchmarks in RMM CI (#941) Fixes #940 Adds options to build tests and benchmarks to build.sh, and uses them in ci/gpu/build.sh Authors: - Mark Harris (https://github.com/harrism) - Jordan Jacobelli (https://github.com/Ethyling) Approvers: - Jordan Jacobelli (https://github.com/Ethyling) - Robert Maynard (https://github.com/robertmaynard) URL: https://github.com/rapidsai/rmm/pull/941 --- build.sh | 36 ++++++++++++++++++++++------------ ci/gpu/build.sh | 2 +- conda/recipes/librmm/build.sh | 6 +++++- conda/recipes/librmm/meta.yaml | 1 + 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/build.sh b/build.sh index 9d6b98ffc..e04442344 100755 --- a/build.sh +++ b/build.sh @@ -18,19 +18,21 @@ ARGS=$* # script, and that this script resides in the repo dir! REPODIR=$(cd $(dirname $0); pwd) -VALIDARGS="clean librmm rmm -v -g -n -s --ptds --no-cudamallocasync -h" +VALIDARGS="clean librmm rmm -v -g -n -s --ptds --no-cudamallocasync -h tests benchmarks" HELP="$0 [clean] [librmm] [rmm] [-v] [-g] [-n] [-s] [--ptds] [--no-cudamallocasync] [--cmake-args=\"\"] [-h] - clean - remove all existing build artifacts and configuration (start over) - librmm - build and install the librmm C++ code - rmm - build and install the rmm Python package - -v - verbose build mode - -g - build for debug - -n - no install step - -s - statically link against cudart - --ptds - enable per-thread default stream - --no-cudamallocasync - disable CUDA malloc async support - --cmake-args=\\\"\\\" - pass arbitrary list of CMake configuration options (escape all quotes in argument) - -h - print this text + clean - remove all existing build artifacts and configuration (start over) + librmm - build and install the librmm C++ code + rmm - build and install the rmm Python package + benchmarks - build benchmarks + tests - build tests + -v - verbose build mode + -g - build for debug + -n - no install step + -s - statically link against cudart + --ptds - enable per-thread default stream + --no-cudamallocasync - disable CUDA malloc async support + --cmake-args=\\\"\\\" - pass arbitrary list of CMake configuration options (escape all quotes in argument) + -h - print this text default action (no args) is to build and install 'librmm' and 'rmm' targets " @@ -42,6 +44,8 @@ BUILD_DIRS="${LIBRMM_BUILD_DIR} ${RMM_BUILD_DIR}" VERBOSE_FLAG="" BUILD_TYPE=Release INSTALL_TARGET=install +BUILD_BENCHMARKS=OFF +BUILD_TESTS=OFF CUDA_STATIC_RUNTIME=OFF PER_THREAD_DEFAULT_STREAM=OFF CUDA_MALLOC_ASYNC_SUPPORT=ON @@ -92,6 +96,8 @@ function ensureCMakeRan { -DPER_THREAD_DEFAULT_STREAM="${PER_THREAD_DEFAULT_STREAM}" \ -DCUDA_MALLOC_ASYNC_SUPPORT="${CUDA_MALLOC_ASYNC_SUPPORT}" \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ + -DBUILD_TESTS=${BUILD_TESTS} \ + -DBUILD_BENCHMARKS=${BUILD_BENCHMARKS} \ ${CMAKE_ARGS} RAN_CMAKE=1 fi @@ -125,6 +131,12 @@ fi if hasArg -n; then INSTALL_TARGET="" fi +if hasArg benchmarks; then + BUILD_BENCHMARKS=ON +fi +if hasArg tests; then + BUILD_TESTS=ON +fi if hasArg -s; then CUDA_STATIC_RUNTIME=ON fi diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index e7239042e..3f8f1f175 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -68,7 +68,7 @@ if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then ################################################################################ gpuci_logger "Build and install librmm and rmm" - "$WORKSPACE/build.sh" -v clean librmm rmm + "$WORKSPACE/build.sh" -v clean librmm rmm benchmarks tests ################################################################################ # Test - librmm diff --git a/conda/recipes/librmm/build.sh b/conda/recipes/librmm/build.sh index 2c75e4624..2646dcb5e 100644 --- a/conda/recipes/librmm/build.sh +++ b/conda/recipes/librmm/build.sh @@ -1,4 +1,8 @@ # Copyright (c) 2018-2019, NVIDIA CORPORATION. # This assumes the script is executed from the root of the repo directory -./build.sh -v clean librmm --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" +if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then + ./build.sh -v clean librmm --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" +else + ./build.sh -v clean librmm tests benchmarks --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" +fi diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index e54a7edd7..9121885a6 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -27,6 +27,7 @@ build: - CMAKE_C_COMPILER_LAUNCHER - CMAKE_CXX_COMPILER_LAUNCHER - CMAKE_CUDA_COMPILER_LAUNCHER + - PROJECT_FLASH run_exports: - {{ pin_subpackage("librmm", max_pin="x.x") }} From 30eb83bd493b86b48865c7cff5727ddf795263bc Mon Sep 17 00:00:00 2001 From: Jordan Jacobelli Date: Thu, 20 Jan 2022 20:30:28 +0100 Subject: [PATCH 038/675] Prepare upload scripts for Python 3.7 removal (#952) As we will remove Python 3.7, we need to update the Python version in the upload scripts Authors: - Jordan Jacobelli (https://github.com/Ethyling) Approvers: - Sevag Hanssian (https://github.com/sevagh) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/952 --- ci/cpu/prebuild.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/cpu/prebuild.sh b/ci/cpu/prebuild.sh index 0a61b94a5..f2eb1ef70 100644 --- a/ci/cpu/prebuild.sh +++ b/ci/cpu/prebuild.sh @@ -4,7 +4,7 @@ export UPLOAD_RMM=1 #Build librmm once per CUDA -if [[ "$PYTHON" == "3.7" ]]; then +if [[ "$PYTHON" == "3.8" ]]; then export UPLOAD_LIBRMM=1 else export UPLOAD_LIBRMM=0 From a4f1d201c9e3c2d3f1376c592747d3dd3c4217fd Mon Sep 17 00:00:00 2001 From: Ray Douglass <3107146+raydouglass@users.noreply.github.com> Date: Thu, 27 Jan 2022 11:06:20 -0500 Subject: [PATCH 039/675] Always upload librmm (#960) Always upload both rmm & librmm packages Authors: - Ray Douglass (https://github.com/raydouglass) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Jordan Jacobelli (https://github.com/Ethyling) --- ci/cpu/prebuild.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ci/cpu/prebuild.sh b/ci/cpu/prebuild.sh index f2eb1ef70..e434ed550 100644 --- a/ci/cpu/prebuild.sh +++ b/ci/cpu/prebuild.sh @@ -1,14 +1,8 @@ #!/usr/bin/env bash -#Always upload RMM Python package +#Always upload RMM packages export UPLOAD_RMM=1 - -#Build librmm once per CUDA -if [[ "$PYTHON" == "3.8" ]]; then - export UPLOAD_LIBRMM=1 -else - export UPLOAD_LIBRMM=0 -fi +export UPLOAD_LIBRMM=1 if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then #If project flash is not activate, always build both From 81d523aabc2476e2db59532c4195dea50acf156e Mon Sep 17 00:00:00 2001 From: Ashwin Srinath <3190405+shwina@users.noreply.github.com> Date: Fri, 28 Jan 2022 15:35:28 -0500 Subject: [PATCH 040/675] Make `pool_memory_resource::pool_size()` public (#962) It's useful to know how much memory RMM has "to itself" at any given time. When using a `pool_memory_resource`, being able to query the current pool size is the only way to know that. This is to enable the use cases described in https://github.com/rapidsai/rmm/issues/956 (combined with a `CallbackMemoryResource`, for which I'll open a subsequent PR). Authors: - Ashwin Srinath (https://github.com/shwina) Approvers: - Rong Ou (https://github.com/rongou) - Mark Harris (https://github.com/harrism) - https://github.com/jakirkham URL: https://github.com/rapidsai/rmm/pull/962 --- include/rmm/mr/device/pool_memory_resource.hpp | 18 +++++++++--------- python/rmm/_lib/memory_resource.pyx | 6 ++++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index b48b3b311..c94e9e8c4 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -129,6 +129,15 @@ class pool_memory_resource final */ Upstream* get_upstream() const noexcept { return upstream_mr_; } + /** + * @brief Computes the size of the current pool + * + * Includes allocated as well as free memory. + * + * @return std::size_t The total size of the currently allocated pool. + */ + [[nodiscard]] std::size_t pool_size() const noexcept { return current_pool_size_; } + protected: using free_list = detail::coalescing_free_list; using block_type = free_list::block_type; @@ -338,15 +347,6 @@ class pool_memory_resource final #endif } - /** - * @brief Computes the size of the current pool - * - * Includes allocated as well as free memory. - * - * @return std::size_t The total size of the currently allocated pool. - */ - [[nodiscard]] std::size_t pool_size() const noexcept { return current_pool_size_; } - /** * @brief Free all memory allocated from the upstream memory_resource. * diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 16723a0a3..e02f1a3ae 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -66,6 +66,7 @@ cdef extern from "rmm/mr/device/pool_memory_resource.hpp" \ Upstream* upstream_mr, optional[size_t] initial_pool_size, optional[size_t] maximum_pool_size) except + + size_t pool_size() cdef extern from "rmm/mr/device/fixed_size_memory_resource.hpp" \ namespace "rmm::mr" nogil: @@ -299,6 +300,11 @@ cdef class PoolMemoryResource(UpstreamResourceAdaptor): """ pass + def pool_size(self): + cdef pool_memory_resource[device_memory_resource]* c_mr = ( + (self.get_mr()) + ) + return c_mr.pool_size() cdef class FixedSizeMemoryResource(UpstreamResourceAdaptor): def __cinit__( From 0515ca47bc6abdc4619a099976bdbf059cbde624 Mon Sep 17 00:00:00 2001 From: Alhad Deshpande <97085048+alhad-deshpande@users.noreply.github.com> Date: Wed, 2 Feb 2022 01:18:34 +0530 Subject: [PATCH 041/675] Added yml file for cudatoolkit version 11.6 (#964) Added yml file for cudatoolkit version11.6. No testcases required for this change. Authors: - Alhad Deshpande (https://github.com/alhad-deshpande) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/964 --- conda/environments/rmm_dev_cuda11.6.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 conda/environments/rmm_dev_cuda11.6.yml diff --git a/conda/environments/rmm_dev_cuda11.6.yml b/conda/environments/rmm_dev_cuda11.6.yml new file mode 100644 index 000000000..d8e2320a4 --- /dev/null +++ b/conda/environments/rmm_dev_cuda11.6.yml @@ -0,0 +1,22 @@ +name: rmm_dev +channels: +- rapidsai +- conda-forge +dependencies: +- clang=11.1.0 +- clang-tools=11.1.0 +- cmake>=3.20.1 +- cmake-format=0.6.11 +- flake8=3.8.3 +- black=19.10 +- isort=5.6.4 +- python>=3.7,<3.9 +- numba>=0.49 +- numpy +- cffi>=1.10.0 +- pytest +- cudatoolkit=11.6 +- spdlog>=1.8.5,<1.9 +- cython>=0.29,<0.30 +- gcovr>=5.0 +- cuda-python>=11.6,<12.0 From 602dbd4800dc620a975299b3dfb98d6d94da6703 Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Wed, 2 Feb 2022 10:48:08 -0500 Subject: [PATCH 042/675] update changelog --- CHANGELOG.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a593d571..840454156 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,25 @@ -# RMM 22.02.00 (Date TBD) +# RMM 22.02.00 (2 Feb 2022) -Please see https://github.com/rapidsai/rmm/releases/tag/v22.02.00a for the latest changes to this development branch. +## 🐛 Bug Fixes + +- Use numba to get CUDA untime vesion. ([#946](https://github.com/rapidsai/rmm/pull/946)) [@bdice](https://github.com/bdice) +- Tempoaily disable wanings fo unknown pagmas ([#942](https://github.com/rapidsai/rmm/pull/942)) [@haism](https://github.com/haism) +- Build benchmaks in RMM CI ([#941](https://github.com/rapidsai/rmm/pull/941)) [@haism](https://github.com/haism) +- Heades that use `std::thead` now include <thead> ([#938](https://github.com/rapidsai/rmm/pull/938)) [@obetmaynad](https://github.com/obetmaynad) +- Fix failing steam test with a debug-only death test ([#934](https://github.com/rapidsai/rmm/pull/934)) [@haism](https://github.com/haism) +- Pevent `DeviceBuffe` DeviceMemoyResouce pematue elease ([#931](https://github.com/rapidsai/rmm/pull/931)) [@viclafague](https://github.com/viclafague) +- Fix failing tacking test ([#929](https://github.com/rapidsai/rmm/pull/929)) [@haism](https://github.com/haism) + +## 🛠️ Impovements + +- Pepae upload scipts fo Python 3.7 emoval ([#952](https://github.com/rapidsai/rmm/pull/952)) [@Ethyling](https://github.com/Ethyling) +- Fix impots tests syntax ([#935](https://github.com/rapidsai/rmm/pull/935)) [@Ethyling](https://github.com/Ethyling) +- Remove `IncludeCategoies` fom `.clang-fomat` ([#933](https://github.com/rapidsai/rmm/pull/933)) [@codeepot](https://github.com/codeepot) +- Replace use of custom CUDA bindings with CUDA-Python ([#930](https://github.com/rapidsai/rmm/pull/930)) [@shwina](https://github.com/shwina) +- Remove `setup.py` fom `update-elease.sh` scipt ([#926](https://github.com/rapidsai/rmm/pull/926)) [@ajschmidt8](https://github.com/ajschmidt8) +- Impove C++ Test Coveage ([#920](https://github.com/rapidsai/rmm/pull/920)) [@haism](https://github.com/haism) +- Impove the Aena allocato to educe memoy fagmentation ([#916](https://github.com/rapidsai/rmm/pull/916)) [@ongou](https://github.com/ongou) +- Simplify CMake linting with cmake-fomat ([#913](https://github.com/rapidsai/rmm/pull/913)) [@vyas](https://github.com/vyas) # RMM 21.12.00 (9 Dec 2021) From dc2a5444b3d69cba7664f2e47e4ef7d7fbf4ab1c Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Thu, 3 Feb 2022 16:30:58 -0500 Subject: [PATCH 043/675] Replace `ccache` with `sccache` (#963) This PR replaces `ccache` with `sccache`. The reason for the replacement is to reduce the complexity involved in the CI backend to manually move around `ccache` tarballs. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Ray Douglass (https://github.com/raydouglass) - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/963 --- ci/cpu/build.sh | 19 +++++++++++++++---- ci/gpu/build.sh | 9 +++++++-- conda/recipes/librmm/meta.yaml | 8 +++++--- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/ci/cpu/build.sh b/ci/cpu/build.sh index 3d923b476..45d5776a3 100755 --- a/ci/cpu/build.sh +++ b/ci/cpu/build.sh @@ -9,6 +9,7 @@ set -e export PATH=/opt/conda/bin:/usr/local/cuda/bin:$PATH export PARALLEL_LEVEL=${PARALLEL_LEVEL:-4} export CMAKE_GENERATOR="Ninja" +export CONDA_BLD_DIR="$WORKSPACE/.conda-bld" # Set home to the job's workspace export HOME=$WORKSPACE @@ -25,6 +26,11 @@ if [[ "$BUILD_MODE" = "branch" && "$SOURCE_BRANCH" = branch-* ]] ; then export VERSION_SUFFIX=`date +%y%m%d` fi +# Set sccache as CMake compiler +export CMAKE_CUDA_COMPILER_LAUNCHER="sccache" +export CMAKE_CXX_COMPILER_LAUNCHER="sccache" +export CMAKE_C_COMPILER_LAUNCHER="sccache" + ################################################################################ # SETUP - Check environment ################################################################################ @@ -63,8 +69,12 @@ if [[ "$BUILD_LIBRMM" == "1" ]]; then if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then gpuci_conda_retry build conda/recipes/librmm --python=$PYTHON else - gpuci_conda_retry build --dirty --no-remove-work-dir conda/recipes/librmm + gpuci_conda_retry build --no-build-id --croot ${CONDA_BLD_DIR} --dirty --no-remove-work-dir conda/recipes/librmm + mkdir -p ${CONDA_BLD_DIR}/librmm + mv ${CONDA_BLD_DIR}/work/ ${CONDA_BLD_DIR}/librmm/work fi + gpuci_logger "sccache stats" + sccache --show-stats fi if [[ "$BUILD_RMM" == "1" ]]; then @@ -72,9 +82,10 @@ if [[ "$BUILD_RMM" == "1" ]]; then if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then gpuci_conda_retry build conda/recipes/rmm --python=$PYTHON else - gpuci_conda_retry build --dirty --no-remove-work-dir \ - -c $WORKSPACE/ci/artifacts/rmm/cpu/conda-bld/ conda/recipes/rmm - + gpuci_conda_retry build --no-build-id --croot ${CONDA_BLD_DIR} --dirty --no-remove-work-dir \ + -c $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ conda/recipes/rmm + mkdir -p ${CONDA_BLD_DIR}/rmm + mv ${CONDA_BLD_DIR}/work/ ${CONDA_BLD_DIR}/rmm/work fi fi diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 3f8f1f175..8a7a94e22 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -32,6 +32,11 @@ export GIT_DESCRIBE_TAG=`git describe --abbrev=0 --tags` export GIT_DESCRIBE_NUMBER=`git rev-list ${GIT_DESCRIBE_TAG}..HEAD --count` export MINOR_VERSION=`echo $GIT_DESCRIBE_TAG | grep -o -E '([0-9]+\.[0-9]+)'` +# Set sccache as CMake compiler +export CMAKE_CUDA_COMPILER_LAUNCHER="sccache" +export CMAKE_CXX_COMPILER_LAUNCHER="sccache" +export CMAKE_C_COMPILER_LAUNCHER="sccache" + ################################################################################ # SETUP - Check environment ################################################################################ @@ -113,11 +118,11 @@ else cd $WORKSPACE/python - CONDA_FILE=`find $WORKSPACE/ci/artifacts/rmm/cpu/conda-bld/ -name "librmm*.tar.bz2"` + CONDA_FILE=`find $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ -name "librmm*.tar.bz2"` CONDA_FILE=`basename "$CONDA_FILE" .tar.bz2` #get filename without extension CONDA_FILE=${CONDA_FILE//-/=} #convert to conda install gpuci_logger "Installing $CONDA_FILE" - gpuci_mamba_retry install -c $WORKSPACE/ci/artifacts/rmm/cpu/conda-bld/ "$CONDA_FILE" + gpuci_mamba_retry install -c $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ "$CONDA_FILE" export LIBRMM_BUILD_DIR="$WORKSPACE/ci/artifacts/rmm/cpu/conda_work/build" diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 9121885a6..19c5523f4 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -20,14 +20,16 @@ build: - CUDAHOSTCXX - PARALLEL_LEVEL - VERSION_SUFFIX - - CCACHE_DIR - - CCACHE_NOHASHDIR - - CCACHE_COMPILERCHECK - CMAKE_GENERATOR - CMAKE_C_COMPILER_LAUNCHER - CMAKE_CXX_COMPILER_LAUNCHER - CMAKE_CUDA_COMPILER_LAUNCHER - PROJECT_FLASH + - SCCACHE_S3_KEY_PREFIX=librmm-aarch64 # [aarch64] + - SCCACHE_S3_KEY_PREFIX=librmm-linux64 # [linux64] + - SCCACHE_BUCKET=rapids-sccache + - SCCACHE_REGION=us-west-2 + - SCCACHE_IDLE_TIMEOUT=32768 run_exports: - {{ pin_subpackage("librmm", max_pin="x.x") }} From 6e2821a0672f18505f34ffd04e801bafd371897e Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Fri, 4 Feb 2022 12:36:04 +1100 Subject: [PATCH 044/675] Fix comparison of async MRs with different underlying pools. (#965) Fixes #899 Adds a test that comparison of async MRs with different underlying cudaMempool handles returns false, and implements the correct behavior. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Jake Hemstad (https://github.com/jrhemstad) - Rong Ou (https://github.com/rongou) URL: https://github.com/rapidsai/rmm/pull/965 --- .../mr/device/cuda_async_memory_resource.hpp | 9 +++++++-- tests/mr/device/cuda_async_mr_tests.cpp | 17 +++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index eb4e758c4..70fef69b8 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -187,7 +187,12 @@ class cuda_async_memory_resource final : public device_memory_resource { */ [[nodiscard]] bool do_is_equal(device_memory_resource const& other) const noexcept override { - return dynamic_cast(&other) != nullptr; + auto const* async_mr = dynamic_cast(&other); +#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT + return (async_mr != nullptr) && (this->pool_handle() == async_mr->pool_handle()); +#else + return async_mr != nullptr; +#endif } /** diff --git a/tests/mr/device/cuda_async_mr_tests.cpp b/tests/mr/device/cuda_async_mr_tests.cpp index 4bf0c3d5b..1a2d0288b 100644 --- a/tests/mr/device/cuda_async_mr_tests.cpp +++ b/tests/mr/device/cuda_async_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ namespace { using cuda_async_mr = rmm::mr::cuda_async_memory_resource; -TEST(PoolTest, ThrowIfNotSupported) +TEST(AsyncMRTest, ThrowIfNotSupported) { auto construct_mr = []() { cuda_async_mr mr; }; #ifndef RMM_CUDA_MALLOC_ASYNC_SUPPORT @@ -35,7 +35,7 @@ TEST(PoolTest, ThrowIfNotSupported) } #if defined(RMM_CUDA_MALLOC_ASYNC_SUPPORT) -TEST(PoolTest, ExplicitInitialPoolSize) +TEST(AsyncMRTest, ExplicitInitialPoolSize) { const auto pool_init_size{100}; cuda_async_mr mr{pool_init_size}; @@ -44,7 +44,7 @@ TEST(PoolTest, ExplicitInitialPoolSize) RMM_CUDA_TRY(cudaDeviceSynchronize()); } -TEST(PoolTest, ExplicitReleaseThreshold) +TEST(AsyncMRTest, ExplicitReleaseThreshold) { const auto pool_init_size{100}; const auto pool_release_threshold{1000}; @@ -54,6 +54,15 @@ TEST(PoolTest, ExplicitReleaseThreshold) RMM_CUDA_TRY(cudaDeviceSynchronize()); } +TEST(AsyncMRTest, DifferentPoolsUnequal) +{ + const auto pool_init_size{100}; + const auto pool_release_threshold{1000}; + cuda_async_mr mr1{pool_init_size, pool_release_threshold}; + cuda_async_mr mr2{pool_init_size, pool_release_threshold}; + EXPECT_FALSE(mr1.is_equal(mr2)); +} + #endif } // namespace From 6bf6b911ce7cab9108ae181cb8128708b9be5392 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Fri, 4 Feb 2022 12:37:20 +1100 Subject: [PATCH 045/675] Add device_buffer::ssize() and device_uvector::ssize() (#966) Fixes #927. Adds signed size accessors (`ssize()`) to `rmm::device_buffer` and `rmm::device_uvector`. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Rong Ou (https://github.com/rongou) - Mike Wilson (https://github.com/hyperbolic2346) - Jake Hemstad (https://github.com/jrhemstad) URL: https://github.com/rapidsai/rmm/pull/966 --- include/rmm/device_buffer.hpp | 18 +++++++++++++----- include/rmm/device_uvector.hpp | 15 +++++++++++---- tests/device_buffer_tests.cu | 3 ++- tests/device_uvector_tests.cpp | 5 +++-- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index 48e1fc6b3..78f8ba184 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -285,7 +285,7 @@ class device_buffer { * Reallocates and copies on stream `stream` the contents of the device memory * allocation to reduce `capacity()` to `size()`. * - * If `size() == capacity()`, no allocations nor copies occur. + * If `size() == capacity()`, no allocations or copies occur. * * @throws rmm::bad_alloc If creating the new allocation fails * @throws rmm::cuda_error If the copy from the old to new allocation fails @@ -315,13 +315,21 @@ class device_buffer { void* data() noexcept { return _data; } /** - * @brief Returns size in bytes that was requested for the device memory - * allocation + * @brief Returns the number of bytes. */ [[nodiscard]] std::size_t size() const noexcept { return _size; } /** - * @brief Returns whether the size in bytes of the `device_buffer` is zero. + * @brief Returns the signed number of bytes. + */ + [[nodiscard]] std::int64_t ssize() const noexcept + { + assert(size() < std::numeric_limits::max() && "Size overflows signed integer"); + return static_cast(size()); + } + + /** + * @brief returns the number of bytes that can be held in currently allocated storage. * * If `is_empty() == true`, the `device_buffer` may still hold an allocation * if `capacity() > 0`. diff --git a/include/rmm/device_uvector.hpp b/include/rmm/device_uvector.hpp index ff1220ec3..57ef1149a 100644 --- a/include/rmm/device_uvector.hpp +++ b/include/rmm/device_uvector.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -480,12 +480,19 @@ class device_uvector { [[nodiscard]] const_iterator end() const noexcept { return cend(); } /** - * @brief Returns the number of elements in the vector. - * - * @return The number of elements. + * @brief Returns the number of elements. */ [[nodiscard]] std::size_t size() const noexcept { return bytes_to_elements(_storage.size()); } + /** + * @brief Returns the signed number of elements. + */ + [[nodiscard]] std::int64_t ssize() const noexcept + { + assert(size() < std::numeric_limits::max() && "Size overflows signed integer"); + return static_cast(size()); + } + /** * @brief Returns true if the vector contains no elements, i.e., `size() == 0`. * diff --git a/tests/device_buffer_tests.cu b/tests/device_buffer_tests.cu index fd772cfea..9cab76323 100644 --- a/tests/device_buffer_tests.cu +++ b/tests/device_buffer_tests.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,6 +67,7 @@ TYPED_TEST(DeviceBufferTest, DefaultMemoryResource) rmm::device_buffer buff(this->size, rmm::cuda_stream_view{}); EXPECT_NE(nullptr, buff.data()); EXPECT_EQ(this->size, buff.size()); + EXPECT_EQ(this->size, buff.ssize()); EXPECT_EQ(this->size, buff.capacity()); EXPECT_EQ(rmm::mr::get_current_device_resource(), buff.memory_resource()); EXPECT_EQ(rmm::cuda_stream_view{}, buff.stream()); diff --git a/tests/device_uvector_tests.cpp b/tests/device_uvector_tests.cpp index 539dd2c26..c1505bc0a 100644 --- a/tests/device_uvector_tests.cpp +++ b/tests/device_uvector_tests.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,8 @@ TYPED_TEST(TypedUVectorTest, NonZeroSizeConstructor) { auto const size{12345}; rmm::device_uvector vec(size, this->stream()); - EXPECT_EQ(vec.size(), 12345); + EXPECT_EQ(vec.size(), size); + EXPECT_EQ(vec.ssize(), size); EXPECT_NE(vec.data(), nullptr); EXPECT_EQ(vec.end(), vec.begin() + vec.size()); EXPECT_FALSE(vec.is_empty()); From 79f7e39ec89d4d9fdba46dd9f653cc7ccc523ef2 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Fri, 4 Feb 2022 13:30:47 -0600 Subject: [PATCH 046/675] Fix signed/unsigned comparison warning (#970) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After #966 builds with full warnings enabled as errors could fail with the following error: ``` /miniconda3/envs/cudf_dev/include/rmm/device_buffer.hpp: In member function ‘int64_t rmm::device_buffer::ssize() const’: /home/jlowe/miniconda3/envs/cudf_dev/include/rmm/device_buffer.hpp:327:19: error: comparison of integer expressions of different signedness: ‘std::size_t’ {aka ‘long unsigned int’} and ‘long int’ [-Werror=sign-compare] 327 | assert(size() < std::numeric_limits::max() && "Size overflows signed integer"); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors ``` This fixes the warning by casting the numerical limit to `std::size_t` before comparing. Authors: - Jason Lowe (https://github.com/jlowe) Approvers: - Jake Hemstad (https://github.com/jrhemstad) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/970 --- include/rmm/device_buffer.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index 78f8ba184..497d2cffe 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -324,7 +324,8 @@ class device_buffer { */ [[nodiscard]] std::int64_t ssize() const noexcept { - assert(size() < std::numeric_limits::max() && "Size overflows signed integer"); + assert(size() < static_cast(std::numeric_limits::max()) && + "Size overflows signed integer"); return static_cast(size()); } From 514f4b4570eaa7856fdb2a782ddd7417edd43199 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Mon, 7 Feb 2022 12:31:48 -0500 Subject: [PATCH 047/675] Add CMake `install` rules for tests (#969) This PR adds a CMake `install` rule for test and benchmark targets. This step is a prerequisite to being able to package tests/benchmarks in their own `conda` package, which will enable us to deprecate _Project Flash_. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Robert Maynard (https://github.com/robertmaynard) URL: https://github.com/rapidsai/rmm/pull/969 --- benchmarks/CMakeLists.txt | 8 +++++++- tests/CMakeLists.txt | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 9f7a0d304..61e420638 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -32,7 +32,8 @@ function(ConfigureBench BENCH_NAME) ${BENCH_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON RUNTIME_OUTPUT_DIRECTORY "$" - CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}") + CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}" + INSTALL_RPATH "\$ORIGIN/../../../lib") target_link_libraries(${BENCH_NAME} benchmark::benchmark pthread rmm) target_compile_definitions(${BENCH_NAME} PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") @@ -55,6 +56,11 @@ function(ConfigureBench BENCH_NAME) PUBLIC $<$:-Wno-deprecated-declarations>) endif() + install( + TARGETS ${BENCH_NAME} + COMPONENT testing + DESTINATION bin/benchmarks/librmm + EXCLUDE_FROM_ALL) endfunction(ConfigureBench) # random allocations benchmark diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1a8ca6cb8..69fbfb6aa 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -27,7 +27,8 @@ function(ConfigureTestInternal TEST_NAME) ${TEST_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON RUNTIME_OUTPUT_DIRECTORY "$" - CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}") + CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}" + INSTALL_RPATH "\$ORIGIN/../../../lib") target_compile_definitions(${TEST_NAME} PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") if(DEFINED CUDA_MALLOC_ASYNC_SUPPORT AND NOT CUDA_MALLOC_ASYNC_SUPPORT) @@ -71,6 +72,12 @@ function(ConfigureTestInternal TEST_NAME) endif() add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME}) + + install( + TARGETS ${TEST_NAME} + COMPONENT testing + DESTINATION bin/gtests/librmm + EXCLUDE_FROM_ALL) endfunction() # Wrapper around `ConfigureTestInternal` that builds tests both with and without per thread default From f2b1364e504bc0f924f0a12e6736289b3d01d9b8 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Tue, 8 Feb 2022 11:06:40 -0500 Subject: [PATCH 048/675] update changelog --- CHANGELOG.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 840454156..53e8834d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,24 +2,24 @@ ## 🐛 Bug Fixes -- Use numba to get CUDA untime vesion. ([#946](https://github.com/rapidsai/rmm/pull/946)) [@bdice](https://github.com/bdice) -- Tempoaily disable wanings fo unknown pagmas ([#942](https://github.com/rapidsai/rmm/pull/942)) [@haism](https://github.com/haism) -- Build benchmaks in RMM CI ([#941](https://github.com/rapidsai/rmm/pull/941)) [@haism](https://github.com/haism) -- Heades that use `std::thead` now include <thead> ([#938](https://github.com/rapidsai/rmm/pull/938)) [@obetmaynad](https://github.com/obetmaynad) -- Fix failing steam test with a debug-only death test ([#934](https://github.com/rapidsai/rmm/pull/934)) [@haism](https://github.com/haism) -- Pevent `DeviceBuffe` DeviceMemoyResouce pematue elease ([#931](https://github.com/rapidsai/rmm/pull/931)) [@viclafague](https://github.com/viclafague) -- Fix failing tacking test ([#929](https://github.com/rapidsai/rmm/pull/929)) [@haism](https://github.com/haism) - -## 🛠️ Impovements - -- Pepae upload scipts fo Python 3.7 emoval ([#952](https://github.com/rapidsai/rmm/pull/952)) [@Ethyling](https://github.com/Ethyling) -- Fix impots tests syntax ([#935](https://github.com/rapidsai/rmm/pull/935)) [@Ethyling](https://github.com/Ethyling) -- Remove `IncludeCategoies` fom `.clang-fomat` ([#933](https://github.com/rapidsai/rmm/pull/933)) [@codeepot](https://github.com/codeepot) +- Use numba to get CUDA runtime version. ([#946](https://github.com/rapidsai/rmm/pull/946)) [@bdice](https://github.com/bdice) +- Temporarily disable warnings for unknown pragmas ([#942](https://github.com/rapidsai/rmm/pull/942)) [@harrism](https://github.com/harrism) +- Build benchmarks in RMM CI ([#941](https://github.com/rapidsai/rmm/pull/941)) [@harrism](https://github.com/harrism) +- Headers that use `std::thread` now include <thread> ([#938](https://github.com/rapidsai/rmm/pull/938)) [@robertmaynard](https://github.com/robertmaynard) +- Fix failing stream test with a debug-only death test ([#934](https://github.com/rapidsai/rmm/pull/934)) [@harrism](https://github.com/harrism) +- Prevent `DeviceBuffer` DeviceMemoryResource premature release ([#931](https://github.com/rapidsai/rmm/pull/931)) [@viclafargue](https://github.com/viclafargue) +- Fix failing tracking test ([#929](https://github.com/rapidsai/rmm/pull/929)) [@harrism](https://github.com/harrism) + +## 🛠️ Improvements + +- Prepare upload scripts for Python 3.7 removal ([#952](https://github.com/rapidsai/rmm/pull/952)) [@Ethyling](https://github.com/Ethyling) +- Fix imports tests syntax ([#935](https://github.com/rapidsai/rmm/pull/935)) [@Ethyling](https://github.com/Ethyling) +- Remove `IncludeCategories` from `.clang-format` ([#933](https://github.com/rapidsai/rmm/pull/933)) [@codereport](https://github.com/codereport) - Replace use of custom CUDA bindings with CUDA-Python ([#930](https://github.com/rapidsai/rmm/pull/930)) [@shwina](https://github.com/shwina) -- Remove `setup.py` fom `update-elease.sh` scipt ([#926](https://github.com/rapidsai/rmm/pull/926)) [@ajschmidt8](https://github.com/ajschmidt8) -- Impove C++ Test Coveage ([#920](https://github.com/rapidsai/rmm/pull/920)) [@haism](https://github.com/haism) -- Impove the Aena allocato to educe memoy fagmentation ([#916](https://github.com/rapidsai/rmm/pull/916)) [@ongou](https://github.com/ongou) -- Simplify CMake linting with cmake-fomat ([#913](https://github.com/rapidsai/rmm/pull/913)) [@vyas](https://github.com/vyas) +- Remove `setup.py` from `update-release.sh` script ([#926](https://github.com/rapidsai/rmm/pull/926)) [@ajschmidt8](https://github.com/ajschmidt8) +- Improve C++ Test Coverage ([#920](https://github.com/rapidsai/rmm/pull/920)) [@harrism](https://github.com/harrism) +- Improve the Arena allocator to reduce memory fragmentation ([#916](https://github.com/rapidsai/rmm/pull/916)) [@rongou](https://github.com/rongou) +- Simplify CMake linting with cmake-format ([#913](https://github.com/rapidsai/rmm/pull/913)) [@vyasr](https://github.com/vyasr) # RMM 21.12.00 (9 Dec 2021) From beefcf64931c97ff88952c173952f7ceb507ee94 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Thu, 10 Feb 2022 10:53:07 -0500 Subject: [PATCH 049/675] Fix `conda` uploads (#974) This PR fixes an issue for our `conda` package uploads where the `rmm` recipe was erroring due to an unsatisfiable `librmm` dependency since the `librmm` packages hadn't been uploaded to Anaconda.org yet. Moving the `conda build... --output` commands inside the conditional statements should fix this. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Jake Awe (https://github.com/AyodeAwe) --- ci/cpu/upload.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ci/cpu/upload.sh b/ci/cpu/upload.sh index 49d716c17..0a07a9f2b 100644 --- a/ci/cpu/upload.sh +++ b/ci/cpu/upload.sh @@ -23,14 +23,6 @@ if [ -z "$MY_UPLOAD_KEY" ]; then return 0 fi -################################################################################ -# SETUP - Get conda file output locations -################################################################################ - -gpuci_logger "Get conda file output locations" - -export LIBRMM_FILE=$(conda build conda/recipes/librmm --output) -export RMM_FILES=$(conda build conda/recipes/rmm --python=$PYTHON --output) ################################################################################ # UPLOAD - Conda packages @@ -39,6 +31,7 @@ export RMM_FILES=$(conda build conda/recipes/rmm --python=$PYTHON --output) gpuci_logger "Starting conda uploads" if [[ "$BUILD_LIBRMM" == "1" && "$UPLOAD_LIBRMM" == "1" ]]; then + export LIBRMM_FILE=$(conda build conda/recipes/librmm --output) test -e ${LIBRMM_FILE} echo "Upload librmm" echo ${LIBRMM_FILE} @@ -46,6 +39,7 @@ if [[ "$BUILD_LIBRMM" == "1" && "$UPLOAD_LIBRMM" == "1" ]]; then fi if [[ "$BUILD_RMM" == "1" && "$UPLOAD_RMM" == "1" ]]; then + export RMM_FILES=$(conda build conda/recipes/rmm --python=$PYTHON --output) while read -r RMM_FILE; do test -e ${RMM_FILE} echo "Upload rmm" From 653f3316221ebfeaf230331ae00db9eff565dade Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Thu, 10 Feb 2022 13:40:59 -0600 Subject: [PATCH 050/675] update croot (#975) This PR updates the `conda build` command to use the correct build directory. Authors: - Jake Awe (https://github.com/AyodeAwe) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) --- ci/cpu/upload.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/cpu/upload.sh b/ci/cpu/upload.sh index 0a07a9f2b..b196dbb97 100644 --- a/ci/cpu/upload.sh +++ b/ci/cpu/upload.sh @@ -31,7 +31,7 @@ fi gpuci_logger "Starting conda uploads" if [[ "$BUILD_LIBRMM" == "1" && "$UPLOAD_LIBRMM" == "1" ]]; then - export LIBRMM_FILE=$(conda build conda/recipes/librmm --output) + export LIBRMM_FILE=$(conda build --croot ${CONDA_BLD_DIR} conda/recipes/librmm --output) test -e ${LIBRMM_FILE} echo "Upload librmm" echo ${LIBRMM_FILE} @@ -39,7 +39,7 @@ if [[ "$BUILD_LIBRMM" == "1" && "$UPLOAD_LIBRMM" == "1" ]]; then fi if [[ "$BUILD_RMM" == "1" && "$UPLOAD_RMM" == "1" ]]; then - export RMM_FILES=$(conda build conda/recipes/rmm --python=$PYTHON --output) + export RMM_FILES=$(conda build --croot ${CONDA_BLD_DIR} conda/recipes/rmm --python=$PYTHON --output) while read -r RMM_FILE; do test -e ${RMM_FILE} echo "Upload rmm" From f1e8a246b26fc28ea5618228d6abe25c4e9fcaad Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Tue, 15 Feb 2022 14:09:44 -0500 Subject: [PATCH 051/675] Update `librmm` recipe to output `librmm_tests` package (#978) This PR updates the `librmm` recipe to include a new output, `librmm_tests`. `librmm_tests` is a `conda` package that includes all of the binaries for `librmm`'s tests and benchmarks. This PR is a prerequisite for deprecating Project Flash. This also updates the CI scripts to use the new package for tests. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Jordan Jacobelli (https://github.com/Ethyling) URL: https://github.com/rapidsai/rmm/pull/978 --- ci/cpu/build.sh | 5 - ci/cpu/upload.sh | 14 +- ci/gpu/build.sh | 20 +-- conda/recipes/librmm/build.sh | 7 +- conda/recipes/librmm/install_librmm.sh | 3 + conda/recipes/librmm/install_librmm_tests.sh | 3 + conda/recipes/librmm/meta.yaml | 139 +++++++++++-------- 7 files changed, 100 insertions(+), 91 deletions(-) create mode 100644 conda/recipes/librmm/install_librmm.sh create mode 100644 conda/recipes/librmm/install_librmm_tests.sh diff --git a/ci/cpu/build.sh b/ci/cpu/build.sh index 45d5776a3..c042db739 100755 --- a/ci/cpu/build.sh +++ b/ci/cpu/build.sh @@ -26,11 +26,6 @@ if [[ "$BUILD_MODE" = "branch" && "$SOURCE_BRANCH" = branch-* ]] ; then export VERSION_SUFFIX=`date +%y%m%d` fi -# Set sccache as CMake compiler -export CMAKE_CUDA_COMPILER_LAUNCHER="sccache" -export CMAKE_CXX_COMPILER_LAUNCHER="sccache" -export CMAKE_C_COMPILER_LAUNCHER="sccache" - ################################################################################ # SETUP - Check environment ################################################################################ diff --git a/ci/cpu/upload.sh b/ci/cpu/upload.sh index b196dbb97..9bff2db31 100644 --- a/ci/cpu/upload.sh +++ b/ci/cpu/upload.sh @@ -31,19 +31,19 @@ fi gpuci_logger "Starting conda uploads" if [[ "$BUILD_LIBRMM" == "1" && "$UPLOAD_LIBRMM" == "1" ]]; then - export LIBRMM_FILE=$(conda build --croot ${CONDA_BLD_DIR} conda/recipes/librmm --output) - test -e ${LIBRMM_FILE} - echo "Upload librmm" - echo ${LIBRMM_FILE} - gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${LIBRMM_FILE} --no-progress + export LIBRMM_FILES=$(conda build --croot ${CONDA_BLD_DIR} conda/recipes/librmm --output) + while read -r LIBRMM_FILE; do + test -e ${LIBRMM_FILE} + echo "Upload librmm file: ${LIBRMM_FILE}" + gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${LIBRMM_FILE} --no-progress + done <<< "${LIBRMM_FILES}" fi if [[ "$BUILD_RMM" == "1" && "$UPLOAD_RMM" == "1" ]]; then export RMM_FILES=$(conda build --croot ${CONDA_BLD_DIR} conda/recipes/rmm --python=$PYTHON --output) while read -r RMM_FILE; do test -e ${RMM_FILE} - echo "Upload rmm" - echo ${RMM_FILE} + echo "Upload rmm file: ${RMM_FILE}" gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${RMM_FILE} --no-progress done <<< "${RMM_FILES}" fi diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 8a7a94e22..d2065e0d5 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -32,11 +32,6 @@ export GIT_DESCRIBE_TAG=`git describe --abbrev=0 --tags` export GIT_DESCRIBE_NUMBER=`git rev-list ${GIT_DESCRIBE_TAG}..HEAD --count` export MINOR_VERSION=`echo $GIT_DESCRIBE_TAG | grep -o -E '([0-9]+\.[0-9]+)'` -# Set sccache as CMake compiler -export CMAKE_CUDA_COMPILER_LAUNCHER="sccache" -export CMAKE_CXX_COMPILER_LAUNCHER="sccache" -export CMAKE_C_COMPILER_LAUNCHER="sccache" - ################################################################################ # SETUP - Check environment ################################################################################ @@ -95,7 +90,8 @@ if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then py.test --cache-clear --basetemp=${WORKSPACE}/rmm-cuda-tmp --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term fi else - export LD_LIBRARY_PATH="$WORKSPACE/ci/artifacts/rmm/cpu/conda_work/build:$LD_LIBRARY_PATH" + + gpuci_mamba_retry install -c $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ librmm librmm_tests TESTRESULTS_DIR=${WORKSPACE}/test-results mkdir -p ${TESTRESULTS_DIR} @@ -105,9 +101,8 @@ else nvidia-smi gpuci_logger "Running googletests" - # run gtests - cd $WORKSPACE/ci/artifacts/rmm/cpu/conda_work - for gt in "build/gtests/*" ; do + # run gtests from librmm_tests package + for gt in "$CONDA_PREFIX/bin/gtests/librmm/*" ; do ${gt} --gtest_output=xml:${TESTRESULTS_DIR}/ exitcode=$? if (( ${exitcode} != 0 )); then @@ -117,13 +112,6 @@ else done cd $WORKSPACE/python - - CONDA_FILE=`find $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ -name "librmm*.tar.bz2"` - CONDA_FILE=`basename "$CONDA_FILE" .tar.bz2` #get filename without extension - CONDA_FILE=${CONDA_FILE//-/=} #convert to conda install - gpuci_logger "Installing $CONDA_FILE" - gpuci_mamba_retry install -c $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ "$CONDA_FILE" - export LIBRMM_BUILD_DIR="$WORKSPACE/ci/artifacts/rmm/cpu/conda_work/build" gpuci_logger "Building rmm" diff --git a/conda/recipes/librmm/build.sh b/conda/recipes/librmm/build.sh index 2646dcb5e..1c129d4d0 100644 --- a/conda/recipes/librmm/build.sh +++ b/conda/recipes/librmm/build.sh @@ -1,8 +1,3 @@ # Copyright (c) 2018-2019, NVIDIA CORPORATION. -# This assumes the script is executed from the root of the repo directory -if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then - ./build.sh -v clean librmm --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" -else - ./build.sh -v clean librmm tests benchmarks --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" -fi +./build.sh -n -v clean librmm tests benchmarks --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" diff --git a/conda/recipes/librmm/install_librmm.sh b/conda/recipes/librmm/install_librmm.sh new file mode 100644 index 000000000..cc4722354 --- /dev/null +++ b/conda/recipes/librmm/install_librmm.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +cmake --install build diff --git a/conda/recipes/librmm/install_librmm_tests.sh b/conda/recipes/librmm/install_librmm_tests.sh new file mode 100644 index 000000000..9993e1ba9 --- /dev/null +++ b/conda/recipes/librmm/install_librmm_tests.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +cmake --install build --component testing diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 19c5523f4..bf0f101b3 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -3,82 +3,107 @@ {% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} {% set cuda_version='.'.join(environ.get('CUDA', '9.2').split('.')[:2]) %} {% set cuda_major=cuda_version.split('.')[0] %} +{% set cmake_version=">=3.20.1" %} +{% set gtest_version="=1.10.0" %} package: - name: librmm - version: {{ version }} + name: librmm-split source: git_url: ../../.. +requirements: + build: + - cmake {{ cmake_version }} + build: - number: {{ GIT_DESCRIBE_NUMBER }} - string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} script_env: - CC - CXX - CUDAHOSTCXX - PARALLEL_LEVEL - - VERSION_SUFFIX - CMAKE_GENERATOR - CMAKE_C_COMPILER_LAUNCHER - CMAKE_CXX_COMPILER_LAUNCHER - CMAKE_CUDA_COMPILER_LAUNCHER - - PROJECT_FLASH - SCCACHE_S3_KEY_PREFIX=librmm-aarch64 # [aarch64] - SCCACHE_S3_KEY_PREFIX=librmm-linux64 # [linux64] - SCCACHE_BUCKET=rapids-sccache - SCCACHE_REGION=us-west-2 - SCCACHE_IDLE_TIMEOUT=32768 - run_exports: - - {{ pin_subpackage("librmm", max_pin="x.x") }} - -requirements: - build: - - cmake >=3.20.1 - host: - - cudatoolkit {{ cuda_version }}.* - run: - - spdlog>=1.8.5,<1.9 - - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} - -test: - commands: - - test -f $PREFIX/include/rmm/thrust_rmm_allocator.h - - test -f $PREFIX/include/rmm/logger.hpp - - test -f $PREFIX/include/rmm/cuda_stream.hpp - - test -f $PREFIX/include/rmm/cuda_stream_view.hpp - - test -f $PREFIX/include/rmm/cuda_stream_pool.hpp - - test -f $PREFIX/include/rmm/device_uvector.hpp - - test -f $PREFIX/include/rmm/device_scalar.hpp - - test -f $PREFIX/include/rmm/device_buffer.hpp - - test -f $PREFIX/include/rmm/detail/aligned.hpp - - test -f $PREFIX/include/rmm/detail/error.hpp - - test -f $PREFIX/include/rmm/detail/exec_check_disable.hpp - - test -f $PREFIX/include/rmm/mr/device/detail/arena.hpp - - test -f $PREFIX/include/rmm/mr/device/detail/free_list.hpp - - test -f $PREFIX/include/rmm/mr/device/detail/coalescing_free_list.hpp - - test -f $PREFIX/include/rmm/mr/device/detail/fixed_size_free_list.hpp - - test -f $PREFIX/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/arena_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/binning_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/cuda_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/device_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/fixed_size_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/limiting_resource_adaptor.hpp - - test -f $PREFIX/include/rmm/mr/device/logging_resource_adaptor.hpp - - test -f $PREFIX/include/rmm/mr/device/managed_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/owning_wrapper.hpp - - test -f $PREFIX/include/rmm/mr/device/per_device_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/pool_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/thread_safe_resource_adaptor.hpp - - test -f $PREFIX/include/rmm/mr/device/thrust_allocator_adaptor.hpp - - test -f $PREFIX/include/rmm/mr/host/host_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/host/new_delete_resource.hpp - - test -f $PREFIX/include/rmm/mr/host/pinned_memory_resource.hpp -about: - home: http://rapids.ai/ - license: Apache-2.0 - # license_file: LICENSE - summary: librmm library +outputs: + - name: librmm + version: {{ version }} + script: install_librmm.sh + build: + number: {{ GIT_DESCRIBE_NUMBER }} + string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + run_exports: + - {{ pin_subpackage("librmm", max_pin="x.x") }} + requirements: + build: + - cmake {{ cmake_version }} + host: + - cudatoolkit {{ cuda_version }}.* + run: + - spdlog>=1.8.5,<1.9 + - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} + test: + commands: + - test -f $PREFIX/include/rmm/thrust_rmm_allocator.h + - test -f $PREFIX/include/rmm/logger.hpp + - test -f $PREFIX/include/rmm/cuda_stream.hpp + - test -f $PREFIX/include/rmm/cuda_stream_view.hpp + - test -f $PREFIX/include/rmm/cuda_stream_pool.hpp + - test -f $PREFIX/include/rmm/device_uvector.hpp + - test -f $PREFIX/include/rmm/device_scalar.hpp + - test -f $PREFIX/include/rmm/device_buffer.hpp + - test -f $PREFIX/include/rmm/detail/aligned.hpp + - test -f $PREFIX/include/rmm/detail/error.hpp + - test -f $PREFIX/include/rmm/detail/exec_check_disable.hpp + - test -f $PREFIX/include/rmm/mr/device/detail/arena.hpp + - test -f $PREFIX/include/rmm/mr/device/detail/free_list.hpp + - test -f $PREFIX/include/rmm/mr/device/detail/coalescing_free_list.hpp + - test -f $PREFIX/include/rmm/mr/device/detail/fixed_size_free_list.hpp + - test -f $PREFIX/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp + - test -f $PREFIX/include/rmm/mr/device/arena_memory_resource.hpp + - test -f $PREFIX/include/rmm/mr/device/binning_memory_resource.hpp + - test -f $PREFIX/include/rmm/mr/device/cuda_memory_resource.hpp + - test -f $PREFIX/include/rmm/mr/device/device_memory_resource.hpp + - test -f $PREFIX/include/rmm/mr/device/fixed_size_memory_resource.hpp + - test -f $PREFIX/include/rmm/mr/device/limiting_resource_adaptor.hpp + - test -f $PREFIX/include/rmm/mr/device/logging_resource_adaptor.hpp + - test -f $PREFIX/include/rmm/mr/device/managed_memory_resource.hpp + - test -f $PREFIX/include/rmm/mr/device/owning_wrapper.hpp + - test -f $PREFIX/include/rmm/mr/device/per_device_resource.hpp + - test -f $PREFIX/include/rmm/mr/device/pool_memory_resource.hpp + - test -f $PREFIX/include/rmm/mr/device/thread_safe_resource_adaptor.hpp + - test -f $PREFIX/include/rmm/mr/device/thrust_allocator_adaptor.hpp + - test -f $PREFIX/include/rmm/mr/host/host_memory_resource.hpp + - test -f $PREFIX/include/rmm/mr/host/new_delete_resource.hpp + - test -f $PREFIX/include/rmm/mr/host/pinned_memory_resource.hpp + about: + home: http://rapids.ai/ + license: Apache-2.0 + summary: librmm library + - name: librmm_tests + version: {{ version }} + script: install_librmm_tests.sh + build: + number: {{ GIT_DESCRIBE_NUMBER }} + string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + requirements: + build: + - cmake {{ cmake_version }} + host: + - cudatoolkit {{ cuda_version }}.* + run: + - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} + - {{ pin_subpackage('librmm', exact=True) }} + - gtest {{ gtest_version }} + - gmock {{ gtest_version }} + about: + home: http://rapids.ai/ + license: Apache-2.0 + summary: librmm test & benchmark executables From cf33a5acad4769b7434d22d9527d8b223761b311 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Thu, 17 Feb 2022 19:51:51 +1100 Subject: [PATCH 052/675] New benchmark compares concurrent throughput of device_vector and device_uvector (#981) Adds a new benchmark in `device_uvector_benchmark.cpp` that compares using multiple streams and concurrent kernels interleaved with vector creation. This is then parameterized on the type of the vector: 1. `thrust::device_vector` -- uses cudaMalloc allocation 2. `rmm::device_vector` -- uses RMM allocation 3. `rmm::device_uvector` -- uses RMM allocation and uninitialized vector The benchmark uses the `cuda_async_memory_resource` so that cudaMallocAsync is used for allocation of the `rmm::` vector types. The performance on V100 demonstrates that option 1. is slowest due to allocation bottlenecks. 2. alleviates these by using `cudaMallocFromPoolAsync`, but there is no concurrency among the kernels because `thrust::device_vector` synchronizes the default stream. 3. Is fastest and achieves full concurrency (verified in `nsight-sys`). ```---------------------------------------------------------------------------------------------------------------------------------- Benchmark Time CPU Iterations UserCounters... ---------------------------------------------------------------------------------------------------------------------------------- BM_VectorWorkflow>/100000/manual_time 242 us 267 us 2962 bytes_per_second=13.8375G/s BM_VectorWorkflow>/1000000/manual_time 1441 us 1465 us 472 bytes_per_second=23.273G/s BM_VectorWorkflow>/10000000/manual_time 10483 us 10498 us 68 bytes_per_second=31.9829G/s BM_VectorWorkflow>/100000000/manual_time 63583 us 63567 us 12 bytes_per_second=52.7303G/s BM_VectorWorkflow>/100000/manual_time 82.0 us 105 us 8181 bytes_per_second=40.8661G/s BM_VectorWorkflow>/1000000/manual_time 502 us 527 us 1357 bytes_per_second=66.8029G/s BM_VectorWorkflow>/10000000/manual_time 4714 us 4746 us 148 bytes_per_second=71.1222G/s BM_VectorWorkflow>/100000000/manual_time 46451 us 46478 us 13 bytes_per_second=72.1784G/s BM_VectorWorkflow>/100000/manual_time 39.0 us 59.9 us 17970 bytes_per_second=85.8733G/s BM_VectorWorkflow>/1000000/manual_time 135 us 159 us 5253 bytes_per_second=248.987G/s BM_VectorWorkflow>/10000000/manual_time 1319 us 1351 us 516 bytes_per_second=254.169G/s BM_VectorWorkflow>/100000000/manual_time 12841 us 12865 us 54 bytes_per_second=261.099G/s ``` Authors: - Mark Harris (https://github.com/harrism) Approvers: - Jake Hemstad (https://github.com/jrhemstad) - Conor Hoekstra (https://github.com/codereport) URL: https://github.com/rapidsai/rmm/pull/981 --- .../device_uvector/device_uvector_bench.cu | 126 +++++++++++++++++- 1 file changed, 119 insertions(+), 7 deletions(-) diff --git a/benchmarks/device_uvector/device_uvector_bench.cu b/benchmarks/device_uvector/device_uvector_bench.cu index 7e73451e6..701e5fceb 100644 --- a/benchmarks/device_uvector/device_uvector_bench.cu +++ b/benchmarks/device_uvector/device_uvector_bench.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,8 +14,14 @@ * limitations under the License. */ +#include "../synchronization/synchronization.hpp" +#include "thrust/detail/raw_pointer_cast.h" + +#include +#include #include #include +#include #include #include #include @@ -24,18 +30,21 @@ #include -static void BM_UvectorSizeConstruction(benchmark::State& state) +#include +#include + +void BM_UvectorSizeConstruction(benchmark::State& state) { rmm::mr::cuda_memory_resource cuda_mr{}; rmm::mr::pool_memory_resource mr{&cuda_mr}; rmm::mr::set_current_device_resource(&mr); for (auto _ : state) { // NOLINT(clang-analyzer-deadcode.DeadStores) - rmm::device_uvector vec(state.range(0), rmm::cuda_stream_view{}); + rmm::device_uvector vec(state.range(0), rmm::cuda_stream_view{}); cudaDeviceSynchronize(); } - state.SetItemsProcessed(static_cast(state.iterations())); + state.SetItemsProcessed(static_cast(state.iterations())); rmm::mr::set_current_device_resource(nullptr); } @@ -45,18 +54,18 @@ BENCHMARK(BM_UvectorSizeConstruction) ->Range(10'000, 1'000'000'000) // NOLINT ->Unit(benchmark::kMicrosecond); -static void BM_ThrustVectorSizeConstruction(benchmark::State& state) +void BM_ThrustVectorSizeConstruction(benchmark::State& state) { rmm::mr::cuda_memory_resource cuda_mr{}; rmm::mr::pool_memory_resource mr{&cuda_mr}; rmm::mr::set_current_device_resource(&mr); for (auto _ : state) { // NOLINT(clang-analyzer-deadcode.DeadStores) - rmm::device_vector vec(state.range(0)); + rmm::device_vector vec(state.range(0)); cudaDeviceSynchronize(); } - state.SetItemsProcessed(static_cast(state.iterations())); + state.SetItemsProcessed(static_cast(state.iterations())); rmm::mr::set_current_device_resource(nullptr); } @@ -66,4 +75,107 @@ BENCHMARK(BM_ThrustVectorSizeConstruction) ->Range(10'000, 1'000'000'000) // NOLINT ->Unit(benchmark::kMicrosecond); +// simple kernel used to test concurrent execution. +__global__ void kernel(int const* input, int* output, std::size_t num) +{ + for (auto i = blockDim.x * blockIdx.x + threadIdx.x; i < num; i += gridDim.x * blockDim.x) { + output[i] = input[i] * input[i]; + } +} + +using thrust_vector = thrust::device_vector; +using rmm_vector = rmm::device_vector; +using rmm_uvector = rmm::device_uvector; + +template +Vector make_vector(std::int64_t num_elements, rmm::cuda_stream_view stream, bool zero_init = false) +{ + static_assert(std::is_same_v or std::is_same_v or + std::is_same_v, + "unsupported vector type"); + if constexpr (std::is_same_v) { + return Vector(num_elements, 0); + } else if constexpr (std::is_same_v) { + return Vector(num_elements, 0, rmm::mr::thrust_allocator(stream)); + } else if constexpr (std::is_same_v) { + auto vec = Vector(num_elements, stream); + if (zero_init) { + cudaMemsetAsync(vec.data(), 0, num_elements * sizeof(std::int32_t), stream.value()); + } + return vec; + } +} + +template +int32_t* vector_data(Vector& vec) +{ + return thrust::raw_pointer_cast(vec.data()); +} + +template +void vector_workflow(std::size_t num_elements, + std::int64_t num_blocks, + std::int64_t block_size, + rmm::cuda_stream const& input_stream, + std::vector const& streams) +{ + auto input = make_vector(num_elements, input_stream, true); + input_stream.synchronize(); + for (rmm::cuda_stream_view stream : streams) { + auto output = make_vector(num_elements, stream); + kernel<<>>( + vector_data(input), vector_data(output), num_elements); + } + + for (rmm::cuda_stream_view stream : streams) { + stream.synchronize(); + } +} + +template +void BM_VectorWorkflow(benchmark::State& state) +{ + rmm::mr::cuda_async_memory_resource cuda_async_mr{}; + rmm::mr::set_current_device_resource(&cuda_async_mr); + + rmm::cuda_stream input_stream; + std::vector streams(4); + + auto const num_elements = state.range(0); + auto constexpr block_size = 256; + auto constexpr num_blocks = 16; + + for (auto _ : state) { // NOLINT(clang-analyzer-deadcode.DeadStores) + cuda_event_timer timer(state, true, input_stream); // flush_l2_cache = true + vector_workflow(num_elements, num_blocks, block_size, input_stream, streams); + } + + auto constexpr num_accesses = 9; + auto const bytes = num_elements * sizeof(std::int32_t) * num_accesses; + state.SetBytesProcessed(static_cast(state.iterations() * bytes)); + + rmm::mr::set_current_device_resource(nullptr); +} + +BENCHMARK_TEMPLATE(BM_VectorWorkflow, thrust_vector) // NOLINT + ->RangeMultiplier(10) // NOLINT + ->Range(100'000, 100'000'000) // NOLINT + ->Unit(benchmark::kMicrosecond) + ->UseManualTime(); + +// The only difference here is that `rmm::device_vector` uses `rmm::current_device_resource()` +// for allocation while `thrust::device_vector` uses cudaMalloc/cudaFree. In the benchmarks we use +// `cuda_async_memory_resource`, which is faster. +BENCHMARK_TEMPLATE(BM_VectorWorkflow, rmm_vector) // NOLINT + ->RangeMultiplier(10) // NOLINT + ->Range(100'000, 100'000'000) // NOLINT + ->Unit(benchmark::kMicrosecond) + ->UseManualTime(); + +BENCHMARK_TEMPLATE(BM_VectorWorkflow, rmm_uvector) // NOLINT + ->RangeMultiplier(10) // NOLINT + ->Range(100'000, 100'000'000) // NOLINT + ->Unit(benchmark::kMicrosecond) + ->UseManualTime(); + BENCHMARK_MAIN(); From 28b273dd67c5d0bbf5f05505189aca9f4afe8656 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Tue, 22 Feb 2022 15:09:55 -0500 Subject: [PATCH 053/675] Update `librmm` `conda` outputs (#983) This PR is a continuation of #978. Initially I thought we'd be able to do a single top-level build with `build.sh` and then simply run `cmake --install...` for the `Outputs` entries. However, I think this would require us to duplicate the `requirements` for each `Outputs` package in the top-level build, which doesn't seem like a good practice. Instead, this PR changes the recipe to build and install the relevant CMake components during each package's individual build steps. The environment variables are copied between package builds using a [YAML anchor](https://support.atlassian.com/bitbucket-cloud/docs/yaml-anchors/). Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Jake Awe (https://github.com/AyodeAwe) - Jordan Jacobelli (https://github.com/Ethyling) URL: https://github.com/rapidsai/rmm/pull/983 --- conda/recipes/librmm/build.sh | 3 -- conda/recipes/librmm/install_librmm.sh | 3 +- conda/recipes/librmm/install_librmm_tests.sh | 2 ++ conda/recipes/librmm/meta.yaml | 35 +++++++++----------- 4 files changed, 19 insertions(+), 24 deletions(-) delete mode 100644 conda/recipes/librmm/build.sh diff --git a/conda/recipes/librmm/build.sh b/conda/recipes/librmm/build.sh deleted file mode 100644 index 1c129d4d0..000000000 --- a/conda/recipes/librmm/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -# Copyright (c) 2018-2019, NVIDIA CORPORATION. - -./build.sh -n -v clean librmm tests benchmarks --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" diff --git a/conda/recipes/librmm/install_librmm.sh b/conda/recipes/librmm/install_librmm.sh index cc4722354..f8533698f 100644 --- a/conda/recipes/librmm/install_librmm.sh +++ b/conda/recipes/librmm/install_librmm.sh @@ -1,3 +1,4 @@ #!/bin/bash +# Copyright (c) 2018-2022, NVIDIA CORPORATION. -cmake --install build +./build.sh -v librmm --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" diff --git a/conda/recipes/librmm/install_librmm_tests.sh b/conda/recipes/librmm/install_librmm_tests.sh index 9993e1ba9..cde738cc0 100644 --- a/conda/recipes/librmm/install_librmm_tests.sh +++ b/conda/recipes/librmm/install_librmm_tests.sh @@ -1,3 +1,5 @@ #!/bin/bash +# Copyright (c) 2018-2022, NVIDIA CORPORATION. +./build.sh -n -v librmm tests benchmarks --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" cmake --install build --component testing diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index bf0f101b3..cfc52ea60 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -12,26 +12,6 @@ package: source: git_url: ../../.. -requirements: - build: - - cmake {{ cmake_version }} - -build: - script_env: - - CC - - CXX - - CUDAHOSTCXX - - PARALLEL_LEVEL - - CMAKE_GENERATOR - - CMAKE_C_COMPILER_LAUNCHER - - CMAKE_CXX_COMPILER_LAUNCHER - - CMAKE_CUDA_COMPILER_LAUNCHER - - SCCACHE_S3_KEY_PREFIX=librmm-aarch64 # [aarch64] - - SCCACHE_S3_KEY_PREFIX=librmm-linux64 # [linux64] - - SCCACHE_BUCKET=rapids-sccache - - SCCACHE_REGION=us-west-2 - - SCCACHE_IDLE_TIMEOUT=32768 - outputs: - name: librmm version: {{ version }} @@ -39,6 +19,20 @@ outputs: build: number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + script_env: &script_env + - CC + - CXX + - CUDAHOSTCXX + - PARALLEL_LEVEL + - CMAKE_GENERATOR + - CMAKE_C_COMPILER_LAUNCHER + - CMAKE_CXX_COMPILER_LAUNCHER + - CMAKE_CUDA_COMPILER_LAUNCHER + - SCCACHE_S3_KEY_PREFIX=librmm-aarch64 # [aarch64] + - SCCACHE_S3_KEY_PREFIX=librmm-linux64 # [linux64] + - SCCACHE_BUCKET=rapids-sccache + - SCCACHE_REGION=us-west-2 + - SCCACHE_IDLE_TIMEOUT=32768 run_exports: - {{ pin_subpackage("librmm", max_pin="x.x") }} requirements: @@ -93,6 +87,7 @@ outputs: build: number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + script_env: *script_env requirements: build: - cmake {{ cmake_version }} From d8dc71501657e820078bc26843565990d8052533 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 23 Feb 2022 07:18:37 +1100 Subject: [PATCH 054/675] Fix warning/error in debug assertion in device_uvector.hpp (#979) Fixes #973 Authors: - Mark Harris (https://github.com/harrism) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Rong Ou (https://github.com/rongou) URL: https://github.com/rapidsai/rmm/pull/979 --- include/rmm/device_uvector.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/rmm/device_uvector.hpp b/include/rmm/device_uvector.hpp index 57ef1149a..bbc36c432 100644 --- a/include/rmm/device_uvector.hpp +++ b/include/rmm/device_uvector.hpp @@ -489,7 +489,8 @@ class device_uvector { */ [[nodiscard]] std::int64_t ssize() const noexcept { - assert(size() < std::numeric_limits::max() && "Size overflows signed integer"); + assert(size() < static_cast(std::numeric_limits::max()) && + "Size overflows signed integer"); return static_cast(size()); } From ace0964f0af3ac8dad696f02541fc236dca5da97 Mon Sep 17 00:00:00 2001 From: Rong Ou Date: Fri, 25 Feb 2022 09:57:09 -0800 Subject: [PATCH 055/675] Skip async mr tests when cuda runtime/driver < 11.2 (#986) The cuda async allocator was added in 11.2, if the runtime or driver is older than that the tests wouldn't work. Fixes #985 Authors: - Rong Ou (https://github.com/rongou) Approvers: - Mark Harris (https://github.com/harrism) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/986 --- ci/gpu/build.sh | 2 +- .../mr/device/cuda_async_memory_resource.hpp | 34 +++++++++++++++---- tests/mr/device/cuda_async_mr_tests.cpp | 19 ++++++++--- tests/mr/device/mr_test.hpp | 12 ++++++- 4 files changed, 55 insertions(+), 12 deletions(-) diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index d2065e0d5..7302b6aad 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -102,7 +102,7 @@ else gpuci_logger "Running googletests" # run gtests from librmm_tests package - for gt in "$CONDA_PREFIX/bin/gtests/librmm/*" ; do + for gt in "$CONDA_PREFIX/bin/gtests/librmm/"* ; do ${gt} --gtest_output=xml:${TESTRESULTS_DIR}/ exitcode=$? if (( ${exitcode} != 0 )); then diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 70fef69b8..5c0525131 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -62,11 +62,7 @@ class cuda_async_memory_resource final : public device_memory_resource { { #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT // Check if cudaMallocAsync Memory pool supported - auto const device = rmm::detail::current_device(); - int cuda_pool_supported{}; - auto result = - cudaDeviceGetAttribute(&cuda_pool_supported, cudaDevAttrMemoryPoolsSupported, device.value()); - RMM_EXPECTS(result == cudaSuccess && cuda_pool_supported, + RMM_EXPECTS(is_supported(), "cudaMallocAsync not supported with this CUDA driver/runtime version"); // Construct explicit pool @@ -74,7 +70,7 @@ class cuda_async_memory_resource final : public device_memory_resource { pool_props.allocType = cudaMemAllocationTypePinned; pool_props.handleTypes = cudaMemHandleTypePosixFileDescriptor; pool_props.location.type = cudaMemLocationTypeDevice; - pool_props.location.id = device.value(); + pool_props.location.id = rmm::detail::current_device().value(); RMM_CUDA_TRY(cudaMemPoolCreate(&cuda_pool_handle_, &pool_props)); auto const [free, total] = rmm::detail::available_device_memory(); @@ -115,6 +111,32 @@ class cuda_async_memory_resource final : public device_memory_resource { cuda_async_memory_resource& operator=(cuda_async_memory_resource const&) = delete; cuda_async_memory_resource& operator=(cuda_async_memory_resource&&) = delete; + /** + * @brief Is cudaMallocAsync supported with this cuda runtime/driver version? + * @return true if both the cuda runtime and driver are newer than 11.2 + */ + static bool is_supported() + { +#if defined(RMM_CUDA_MALLOC_ASYNC_SUPPORT) + static auto runtime_supports_pool{[] { + int runtime_version{}; + RMM_CUDA_TRY(cudaRuntimeGetVersion(&runtime_version)); + constexpr auto min_async_version{11020}; + return runtime_version >= min_async_version; + }()}; + static auto driver_supports_pool{[] { + int cuda_pool_supported{}; + auto result = cudaDeviceGetAttribute(&cuda_pool_supported, + cudaDevAttrMemoryPoolsSupported, + rmm::detail::current_device().value()); + return result == cudaSuccess and cuda_pool_supported == 1; + }()}; + return runtime_supports_pool and driver_supports_pool; +#else + return false; +#endif + } + /** * @brief Query whether the resource supports use of non-null CUDA streams for * allocation/deallocation. `cuda_memory_resource` does not support streams. diff --git a/tests/mr/device/cuda_async_mr_tests.cpp b/tests/mr/device/cuda_async_mr_tests.cpp index 1a2d0288b..1ab806883 100644 --- a/tests/mr/device/cuda_async_mr_tests.cpp +++ b/tests/mr/device/cuda_async_mr_tests.cpp @@ -24,7 +24,18 @@ namespace { using cuda_async_mr = rmm::mr::cuda_async_memory_resource; -TEST(AsyncMRTest, ThrowIfNotSupported) +class AsyncMRTest : public ::testing::Test { + protected: + void SetUp() override + { + if (!rmm::mr::cuda_async_memory_resource::is_supported()) { + GTEST_SKIP() << "Skipping tests since cudaMallocAsync not supported with this CUDA " + << "driver/runtime version"; + } + } +}; + +TEST_F(AsyncMRTest, ThrowIfNotSupported) { auto construct_mr = []() { cuda_async_mr mr; }; #ifndef RMM_CUDA_MALLOC_ASYNC_SUPPORT @@ -35,7 +46,7 @@ TEST(AsyncMRTest, ThrowIfNotSupported) } #if defined(RMM_CUDA_MALLOC_ASYNC_SUPPORT) -TEST(AsyncMRTest, ExplicitInitialPoolSize) +TEST_F(AsyncMRTest, ExplicitInitialPoolSize) { const auto pool_init_size{100}; cuda_async_mr mr{pool_init_size}; @@ -44,7 +55,7 @@ TEST(AsyncMRTest, ExplicitInitialPoolSize) RMM_CUDA_TRY(cudaDeviceSynchronize()); } -TEST(AsyncMRTest, ExplicitReleaseThreshold) +TEST_F(AsyncMRTest, ExplicitReleaseThreshold) { const auto pool_init_size{100}; const auto pool_release_threshold{1000}; @@ -54,7 +65,7 @@ TEST(AsyncMRTest, ExplicitReleaseThreshold) RMM_CUDA_TRY(cudaDeviceSynchronize()); } -TEST(AsyncMRTest, DifferentPoolsUnequal) +TEST_F(AsyncMRTest, DifferentPoolsUnequal) { const auto pool_init_size{100}; const auto pool_release_threshold{1000}; diff --git a/tests/mr/device/mr_test.hpp b/tests/mr/device/mr_test.hpp index 684701fb8..b292dfd46 100644 --- a/tests/mr/device/mr_test.hpp +++ b/tests/mr/device/mr_test.hpp @@ -234,6 +234,10 @@ struct mr_test : public ::testing::TestWithParam { { auto factory = GetParam().factory; mr = factory(); + if (mr == nullptr) { + GTEST_SKIP() << "Skipping tests since the memory resource is not supported with this CUDA " + << "driver/runtime version"; + } } std::shared_ptr mr; ///< Pointer to resource to use in tests @@ -246,7 +250,13 @@ struct mr_allocation_test : public mr_test { /// MR factory functions inline auto make_cuda() { return std::make_shared(); } -inline auto make_cuda_async() { return std::make_shared(); } +inline auto make_cuda_async() +{ + if (rmm::mr::cuda_async_memory_resource::is_supported()) { + return std::make_shared(); + } + return std::shared_ptr{nullptr}; +} inline auto make_managed() { return std::make_shared(); } From 36c13ff70f48876e7e5b9cf5fff78f6063fdaf50 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 11 Mar 2022 12:28:31 -0800 Subject: [PATCH 056/675] Use scikit-build for the build process (#976) This PR replaces a lot of the setuptools logic with using scikit-build, which allows us to leverage the existing CMake configuration for the C++ components of RMM to build the Python package using standard pip- and setup.py-based installs. Replaces #637. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Mark Harris (https://github.com/harrism) - AJ Schmidt (https://github.com/ajschmidt8) - Keith Kraus (https://github.com/kkraus14) - Robert Maynard (https://github.com/robertmaynard) - GALI PREM SAGAR (https://github.com/galipremsagar) URL: https://github.com/rapidsai/rmm/pull/976 --- .gitignore | 3 + CONTRIBUTING.md | 8 +- build.sh | 13 +- ci/release/update-version.sh | 1 + cmake/config.json | 2 +- conda/environments/rmm_dev_cuda11.5.yml | 1 + conda/environments/rmm_dev_cuda11.6.yml | 1 + conda/recipes/rmm/meta.yaml | 6 +- python/CMakeLists.txt | 65 ++++++++ python/cmake/CMakeLists.txt | 16 ++ python/cmake/rmm_python_helpers.cmake | 48 ++++++ python/cmake/skbuild_patches.cmake | 48 ++++++ python/dev_requirements.txt | 3 +- python/pyproject.toml | 19 ++- python/rmm/_cuda/CMakeLists.txt | 19 +++ python/rmm/_lib/CMakeLists.txt | 19 +++ python/setup.py | 207 ++---------------------- 17 files changed, 273 insertions(+), 206 deletions(-) create mode 100644 python/CMakeLists.txt create mode 100644 python/cmake/CMakeLists.txt create mode 100644 python/cmake/rmm_python_helpers.cmake create mode 100644 python/cmake/skbuild_patches.cmake create mode 100644 python/rmm/_cuda/CMakeLists.txt create mode 100644 python/rmm/_lib/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 0e2619266..2c603209d 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,9 @@ pip-delete-this-directory.txt # Ignore dynamically generated .pxd files python/rmm/_cuda/gpu.pxd +# Ignore _skbuild directory +_skbuild/ + # Unit test / coverage reports htmlcov/ .tox/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5e730cbb0..bd654bef3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,6 +34,12 @@ into three categories: 8. Once reviewed and approved, a RAPIDS developer will merge your pull request. Note that for C++ code, two reviewers are required. +To set up a development environment, follow the steps in the [README](https://github.com/rapidsai/rmm/blob/main/README.md) for cloning the repository and creating the conda environment. +Once the environment is created, you can build and install RMM using +```bash +$ python setup.py develop +``` +This command will build the RMM Python library inside the clone and automatically make it importable when running Python anywhere on your machine. Remember, if you are unsure about anything, don't hesitate to comment on issues and ask for clarifications! @@ -52,7 +58,7 @@ implementation of the issue, ask them in the issue instead of the PR. ### Building and Testing on a gpuCI image locally - Before submitting a pull request, you can do a local build and test on your machine that mimics our gpuCI environment using the `ci/local/build.sh` script. +Before submitting a pull request, you can do a local build and test on your machine that mimics our gpuCI environment using the `ci/local/build.sh` script. For detailed information on usage of this script, see [here](ci/local/README.md). ## Attribution diff --git a/build.sh b/build.sh index e04442344..1a83652ad 100755 --- a/build.sh +++ b/build.sh @@ -37,8 +37,8 @@ HELP="$0 [clean] [librmm] [rmm] [-v] [-g] [-n] [-s] [--ptds] [--no-cudamallocasy default action (no args) is to build and install 'librmm' and 'rmm' targets " LIBRMM_BUILD_DIR=${LIBRMM_BUILD_DIR:=${REPODIR}/build} -RMM_BUILD_DIR=${REPODIR}/python/build -BUILD_DIRS="${LIBRMM_BUILD_DIR} ${RMM_BUILD_DIR}" +RMM_BUILD_DIR="${REPODIR}/python/build ${REPODIR}/python/_skbuild" +BUILD_DIR="${LIBRMM_BUILD_DIR} ${RMM_BUILD_DIR}" # Set defaults for vars modified by flags to this script VERBOSE_FLAG="" @@ -157,7 +157,7 @@ if hasArg clean; then if [ -d "${bd}" ]; then find "${bd}" -mindepth 1 -delete rmdir "${bd}" || true - fi + fi done fi @@ -178,15 +178,16 @@ if (( NUMARGS == 0 )) || hasArg rmm; then cd "${REPODIR}/python" export INSTALL_PREFIX echo "building rmm..." + if [[ ${CUDA_MALLOC_ASYNC_SUPPORT} == OFF ]]; then - python setup.py build_ext_no_async --inplace + python setup.py build_ext --inplace -- -DCUDA_MALLOC_ASYNC_SUPPORT=OFF -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} else - python setup.py build_ext --inplace + python setup.py build_ext --inplace -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} fi if [[ ${INSTALL_TARGET} != "" ]]; then echo "installing rmm..." - python setup.py install --single-version-externally-managed --record=record.txt + python setup.py install --single-version-externally-managed --record=record.txt -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} fi fi diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 6b7342961..fcc52922f 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -30,6 +30,7 @@ function sed_runner() { } sed_runner 's/'" VERSION .*"'/'" VERSION ${NEXT_FULL_TAG}"'/g' CMakeLists.txt +sed_runner 's/'"rmm_version .*)"'/'"rmm_version ${NEXT_FULL_TAG})"'/g' python/CMakeLists.txt sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' CMakeLists.txt sed_runner 's/'"PROJECT_NUMBER = .*"'/'"PROJECT_NUMBER = ${NEXT_SHORT_TAG}"'/g' doxygen/Doxyfile diff --git a/cmake/config.json b/cmake/config.json index fa3f769cc..6fb9d3fd7 100644 --- a/cmake/config.json +++ b/cmake/config.json @@ -28,7 +28,7 @@ "max_pargs_hwrap": 999 }, "lint": { - "disabled_codes": ["C0301"], + "disabled_codes": ["C0301", "C0112"], "function_pattern": "[0-9A-z_]+", "macro_pattern": "[0-9A-z_]+", "global_var_pattern": "[A-z][0-9A-z_]+", diff --git a/conda/environments/rmm_dev_cuda11.5.yml b/conda/environments/rmm_dev_cuda11.5.yml index 549aca8d5..c09595999 100644 --- a/conda/environments/rmm_dev_cuda11.5.yml +++ b/conda/environments/rmm_dev_cuda11.5.yml @@ -16,6 +16,7 @@ dependencies: - cffi>=1.10.0 - pytest - cudatoolkit=11.5 +- scikit-build>=0.13.1 - spdlog>=1.8.5,<1.9 - cython>=0.29,<0.30 - gcovr>=5.0 diff --git a/conda/environments/rmm_dev_cuda11.6.yml b/conda/environments/rmm_dev_cuda11.6.yml index d8e2320a4..9b1d258d6 100644 --- a/conda/environments/rmm_dev_cuda11.6.yml +++ b/conda/environments/rmm_dev_cuda11.6.yml @@ -16,6 +16,7 @@ dependencies: - cffi>=1.10.0 - pytest - cudatoolkit=11.6 +- scikit-build>=0.13.1 - spdlog>=1.8.5,<1.9 - cython>=0.29,<0.30 - gcovr>=5.0 diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index ce1ecec07..4baa09085 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2021, NVIDIA CORPORATION. +# Copyright (c) 2019-2022, NVIDIA CORPORATION. {% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} {% set py_version=environ.get('CONDA_PY', 35) %} @@ -27,7 +27,9 @@ requirements: - python - librmm {{ version }} - setuptools - - cython >=0.29,<0.30 + - cython>=0.29,<0.30 + - cmake>=3.20.1 + - scikit-build>=0.13.1 - spdlog>=1.8.5,<2.0.0a0 - cudatoolkit {{ cuda_version }}.* - cuda-python >=11.5,<12.0 diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt new file mode 100644 index 000000000..a6442fdc7 --- /dev/null +++ b/python/CMakeLists.txt @@ -0,0 +1,65 @@ +# ============================================================================= +# Copyright (c) 2022, 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. +# ============================================================================= + +cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) + +# TODO: Pull this directly from the file written by rapids_cmake_write_version_file. +set(rmm_version 22.04.00) + +project( + rmm-python + VERSION ${rmm_version} + LANGUAGES # TODO: Building Python extension modules via the python_extension_module requires the C + # language to be enabled here. The test project that is built in scikit-build to verify + # various linking options for the python library is hardcoded to build with C, so until + # that is fixed we need to keep C. + C + CXX + # TODO: The C++ RMM CMake configuration targets cuda_std_17 features, which prior to + # CMake 3.22 will also pull in the corresponding required languages even if this project + # does not actually require those languages. As a result, we need to include CUDA here. + # We can remove CUDA once we upgrade the minimum required CMake version to 3.22. + CUDA) + +option(FIND_RMM_CPP "Search for existing RMM C++ installations before defaulting to local files" + OFF) + +find_package(PythonExtensions REQUIRED) +find_package(Cython REQUIRED) + +# Ignore unused variable warning. +set(ignored_variable "${SKBUILD}") + +# If the user requested it we attempt to find RMM. TODO: Should we allow the user to specify a path +# instead of just searching? This version assumes that the installation has been appropriately +# configured for CMake discovery. +if(FIND_RMM_CPP) + find_package(RMM ${rmm_version}) +else() + set(RMM_FOUND OFF) +endif() + +if(DEFINED CUDA_MALLOC_ASYNC_SUPPORT AND NOT CUDA_MALLOC_ASYNC_SUPPORT) + add_compile_definitions("RMM_DISABLE_CUDA_MALLOC_ASYNC") +endif() + +if(NOT RMM_FOUND) + set(BUILD_TESTS OFF) + set(BUILD_BENCHMARKS OFF) + add_subdirectory(../ rmm-cpp) +endif() + +add_subdirectory(cmake) +add_subdirectory(rmm/_cuda) +add_subdirectory(rmm/_lib) diff --git a/python/cmake/CMakeLists.txt b/python/cmake/CMakeLists.txt new file mode 100644 index 000000000..9469891ae --- /dev/null +++ b/python/cmake/CMakeLists.txt @@ -0,0 +1,16 @@ +# ============================================================================= +# Copyright (c) 2022, 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. +# ============================================================================= + +include(rmm_python_helpers.cmake) +include(skbuild_patches.cmake) diff --git a/python/cmake/rmm_python_helpers.cmake b/python/cmake/rmm_python_helpers.cmake new file mode 100644 index 000000000..91f0a5a17 --- /dev/null +++ b/python/cmake/rmm_python_helpers.cmake @@ -0,0 +1,48 @@ +# ============================================================================= +# Copyright (c) 2022, 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. +# ============================================================================= + +#[=======================================================================[.rst: +add_cython_modules +------------------ + +Generate C(++) from Cython and create Python modules. + +.. code-block:: cmake + + add_cython_modules() + +Creates a Cython target for a module, then adds a corresponding Python +extension module. + +``ModuleName`` + The list of modules to build. + +#]=======================================================================] +function(add_cython_modules cython_modules) + foreach(cython_module ${cython_modules}) + add_cython_target(${cython_module} CXX PY3) + add_library(${cython_module} MODULE ${cython_module}) + python_extension_module(${cython_module}) + + # To avoid libraries being prefixed with "lib". + set_target_properties(${cython_module} PROPERTIES PREFIX "") + target_link_libraries(${cython_module} rmm::rmm) + + # Compute the install directory relative to the source and rely on installs being relative to + # the CMAKE_PREFIX_PATH for e.g. editable installs. + cmake_path(RELATIVE_PATH CMAKE_CURRENT_SOURCE_DIR BASE_DIRECTORY ${rmm-python_SOURCE_DIR} + OUTPUT_VARIABLE install_dst) + install(TARGETS ${cython_module} DESTINATION ${install_dst}) + endforeach(cython_module ${cython_sources}) +endfunction() diff --git a/python/cmake/skbuild_patches.cmake b/python/cmake/skbuild_patches.cmake new file mode 100644 index 000000000..6302e9e2f --- /dev/null +++ b/python/cmake/skbuild_patches.cmake @@ -0,0 +1,48 @@ +# ============================================================================= +# Copyright (c) 2022, 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. +# ============================================================================= + +#[=======================================================================[.rst: +_set_python_extension_symbol_visibility +--------------------------------------- + +The original version of this function in scikit-build runs a linker script to +modify the visibility of symbols. This version is a patch to avoid overwriting +the visibility of symbols because RMM specifically overrides some symbol +visibility in order to share certain functional-local static variables. + +#]=======================================================================] +# TODO: Should we guard this based on a scikit-build version? Override this function to avoid +# scikit-build clobbering symbol visibility. +function(_set_python_extension_symbol_visibility _target) + if(PYTHON_VERSION_MAJOR VERSION_GREATER 2) + set(_modinit_prefix "PyInit_") + else() + set(_modinit_prefix "init") + endif() + message("_modinit_prefix:${_modinit_prefix}") + if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") + set_target_properties(${_target} PROPERTIES LINK_FLAGS "/EXPORT:${_modinit_prefix}${_target}") + elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(_script_path ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_target}-version-script.map) + file( + WRITE ${_script_path} + # Note: The change is to this script, which does not indiscriminately mark all non PyInit + # symbols as local. + "{global: ${_modinit_prefix}${_target}; };") + set_property( + TARGET ${_target} + APPEND_STRING + PROPERTY LINK_FLAGS " -Wl,--version-script=\"${_script_path}\"") + endif() +endfunction() diff --git a/python/dev_requirements.txt b/python/dev_requirements.txt index 2113ee242..09ad10049 100644 --- a/python/dev_requirements.txt +++ b/python/dev_requirements.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-2022, NVIDIA CORPORATION. clang==8.0.1 flake8==3.8.3 @@ -12,3 +12,4 @@ pytest-xdist cython>=0.29,<0.30 wheel setuptools +scikit-build>=0.13.1 diff --git a/python/pyproject.toml b/python/pyproject.toml index f10a40c81..5fe11a11e 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,11 +1,26 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-2022, 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. [build-system] requires = [ "wheel", "setuptools", - "Cython>=0.29,<0.30", + "cython>=0.29,<0.30", + "scikit-build>=0.13.1", + "cmake>=3.20.1", + "ninja", ] [tool.black] diff --git a/python/rmm/_cuda/CMakeLists.txt b/python/rmm/_cuda/CMakeLists.txt new file mode 100644 index 000000000..16489dde5 --- /dev/null +++ b/python/rmm/_cuda/CMakeLists.txt @@ -0,0 +1,19 @@ +# ============================================================================= +# Copyright (c) 2022, 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 the list of Cython files to build +set(cython_modules stream) + +# Build all of the Cython targets +add_cython_modules("${cython_modules}") diff --git a/python/rmm/_lib/CMakeLists.txt b/python/rmm/_lib/CMakeLists.txt new file mode 100644 index 000000000..954af9331 --- /dev/null +++ b/python/rmm/_lib/CMakeLists.txt @@ -0,0 +1,19 @@ +# ============================================================================= +# Copyright (c) 2022, 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 the list of Cython files to build +set(cython_modules device_buffer lib memory_resource cuda_stream) + +# Build all of the Cython targets +add_cython_modules("${cython_modules}") diff --git a/python/setup.py b/python/setup.py index 50888ab3c..feaa29fe5 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,192 +1,10 @@ -# Copyright (c) 2019-2021, NVIDIA CORPORATION. +# Copyright (c) 2019-2022, NVIDIA CORPORATION. -import glob -import os -import re -import shutil -import sysconfig - -# Must import in this order: -# setuptools -> Cython.Distutils.build_ext -> setuptools.command.build_ext -# Otherwise, setuptools.command.build_ext ends up inheriting from -# Cython.Distutils.old_build_ext which we do not want -import setuptools - -try: - from Cython.Distutils.build_ext import new_build_ext as _build_ext -except ImportError: - from setuptools.command.build_ext import build_ext as _build_ext - -from distutils.sysconfig import get_python_lib - -import setuptools.command.build_ext -from setuptools import find_packages, setup -from setuptools.extension import Extension +from setuptools import find_packages +from skbuild import setup import versioneer -install_requires = ["numba", "cython", "cuda-python"] - - -def get_cuda_version_from_header(cuda_include_dir): - - cuda_version = None - - with open( - os.path.join(cuda_include_dir, "cuda.h"), "r", encoding="utf-8" - ) as f: - for line in f.readlines(): - if re.search(r"#define CUDA_VERSION ", line) is not None: - cuda_version = line - break - - if cuda_version is None: - raise TypeError("CUDA_VERSION not found in cuda.h") - cuda_version = int(cuda_version.split()[2]) - return "%d.%d" % (cuda_version // 1000, (cuda_version % 1000) // 10) - - -cython_tests = glob.glob("rmm/_lib/tests/*.pyx") - -CUDA_HOME = os.environ.get("CUDA_HOME", False) -if not CUDA_HOME: - path_to_cuda_gdb = shutil.which("cuda-gdb") - if path_to_cuda_gdb is None: - raise OSError( - "Could not locate CUDA. " - "Please set the environment variable " - "CUDA_HOME to the path to the CUDA installation " - "and try again." - ) - CUDA_HOME = os.path.dirname(os.path.dirname(path_to_cuda_gdb)) - -if not os.path.isdir(CUDA_HOME): - raise OSError(f"Invalid CUDA_HOME: directory does not exist: {CUDA_HOME}") - -cuda_include_dir = os.path.join(CUDA_HOME, "include") -cuda_lib_dir = os.path.join(CUDA_HOME, "lib64") -CUDA_VERSION = get_cuda_version_from_header(cuda_include_dir) - -INSTALL_PREFIX = os.environ.get("INSTALL_PREFIX", False) -if os.path.isdir(INSTALL_PREFIX): - rmm_include_dir = os.path.join(INSTALL_PREFIX, "include") -else: - # use uninstalled headers in source tree - rmm_include_dir = "../include" - -include_dirs = [ - rmm_include_dir, - os.path.dirname(sysconfig.get_path("include")), - cuda_include_dir, -] - -library_dirs = [ - get_python_lib(), - os.path.join(os.sys.prefix, "lib"), - cuda_lib_dir, -] - -extensions = [ - # lib: - Extension( - "*", - sources=["rmm/_lib/*.pyx"], - include_dirs=include_dirs, - library_dirs=library_dirs, - runtime_library_dirs=[ - cuda_lib_dir, - os.path.join(os.sys.prefix, "lib"), - ], - libraries=["cuda", "cudart"], - language="c++", - extra_compile_args=["-std=c++17"], - ), - # cuda: - Extension( - "*", - sources=["rmm/_cuda/*.pyx"], - include_dirs=include_dirs, - library_dirs=library_dirs, - runtime_library_dirs=[ - cuda_lib_dir, - os.path.join(os.sys.prefix, "lib"), - ], - libraries=["cuda", "cudart"], - language="c++", - extra_compile_args=["-std=c++17"], - ), - # tests: - Extension( - "*", - sources=cython_tests, - include_dirs=include_dirs, - library_dirs=library_dirs, - runtime_library_dirs=[ - cuda_lib_dir, - os.path.join(os.sys.prefix, "lib"), - ], - libraries=["cuda", "cudart"], - language="c++", - extra_compile_args=["-std=c++17"], - ), -] - - -def remove_flags(compiler, *flags): - for flag in flags: - try: - compiler.compiler_so = list( - filter((flag).__ne__, compiler.compiler_so) - ) - except Exception: - pass - - -class build_ext_no_debug(_build_ext): - def build_extensions(self): - # Full optimization - self.compiler.compiler_so.append("-O3") - # No debug symbols, full optimization, no '-Wstrict-prototypes' warning - remove_flags( - self.compiler, "-g", "-G", "-O1", "-O2", "-Wstrict-prototypes" - ) - super().build_extensions() - - def finalize_options(self): - if self.distribution.ext_modules: - # Delay import this to allow for Cython-less installs - from Cython.Build.Dependencies import cythonize - - nthreads = getattr(self, "parallel", None) # -j option in Py3.5+ - nthreads = int(nthreads) if nthreads else None - self.distribution.ext_modules = cythonize( - self.distribution.ext_modules, - nthreads=nthreads, - force=self.force, - gdb_debug=False, - compiler_directives=dict( - profile=False, - language_level=3, - embedsignature=True, - binding=True, - ), - ) - # Skip calling super() and jump straight to setuptools - setuptools.command.build_ext.build_ext.finalize_options(self) - - -class build_ext_no_async(build_ext_no_debug): - def build_extensions(self): - # Disable async support - self.compiler.compiler_so.append("-DRMM_DISABLE_CUDA_MALLOC_ASYNC") - super().build_extensions() - - -cmdclass = dict() -cmdclass.update(versioneer.get_cmdclass()) -cmdclass["build_ext"] = build_ext_no_debug -cmdclass["build_ext_no_async"] = build_ext_no_async - setup( name="rmm", version=versioneer.get_version(), @@ -204,15 +22,18 @@ def build_extensions(self): "Programming Language :: Python :: 3.8", ], # Include the separately-compiled shared library - setup_requires=["Cython>=0.29,<0.30"], extras_require={"test": ["pytest", "pytest-xdist"]}, - ext_modules=extensions, packages=find_packages(include=["rmm", "rmm.*"]), - package_data=dict.fromkeys( - find_packages(include=["rmm._lib", "rmm._lib.includes", "rmm._cuda*"]), - ["*.hpp", "*.pxd"], - ), - cmdclass=cmdclass, - install_requires=install_requires, + package_data={ + # Note: A dict comprehension with an explicit copy is necessary (rather + # than something simpler like a dict.fromkeys) because otherwise every + # package will refer to the same list and skbuild modifies it in place. + key: ["*.hpp", "*.pxd"] + for key in find_packages( + include=["rmm._lib", "rmm._lib.includes", "rmm._cuda*"] + ) + }, + cmdclass=versioneer.get_cmdclass(), + install_requires=["numba", "cython", "cuda-python"], zip_safe=False, ) From 39dc9f79324ce4adf362d130c3e7e6e9eced7914 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Mon, 14 Mar 2022 10:50:45 -0400 Subject: [PATCH 057/675] Add `.github/ops-bot.yaml` config file (#991) In the near future, the [rapidsai/ops-bot](https://github.com/rapidsai/ops-bot) GitHub application that we use for GitHub automation will be enabled on all repositories in the `rapidsai` GitHub organization. Since not all features of the application are applicable to all repositories, this PR adds a new file, `.github/ops-bot.yaml`, which can configure which features are enabled per repository. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/991 --- .github/ops-bot.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .github/ops-bot.yaml diff --git a/.github/ops-bot.yaml b/.github/ops-bot.yaml new file mode 100644 index 000000000..408e28843 --- /dev/null +++ b/.github/ops-bot.yaml @@ -0,0 +1,8 @@ +# This file controls which features from the `ops-bot` repository below are enabled. +# - https://github.com/rapidsai/ops-bot + +auto_merger: true +branch_checker: true +label_checker: true +release_drafter: true +external_contributors: true From 4997097e0d95e71c16a0c6fc22cb8cf15ccfa5b9 Mon Sep 17 00:00:00 2001 From: Sevag Hanssian Date: Mon, 14 Mar 2022 13:49:20 -0400 Subject: [PATCH 058/675] Add cuda-python dependency to pyproject.toml (#994) When trying to install rmm with pip using the git url, I ran into some Cython CUDA compile errors: ``` (rapids) root@5a38f55ffbdd:/rmm/python# pip install -e 'git+https://github.com/rapidsai/rmm.git@branch-22.04#egg=rmm&subdirectory=python' ... /src/rmm/python/rmm/_lib/cuda_stream.pxd:16:0: 'cuda/ccudart.pxd' not found Error compiling Cython file: ------------------------------------------------------------ cimport cython from cuda.ccudart cimport cudaStream_t ^ ... ``` Adding `cuda-python` to the pyproject.toml requires (as suggested by @vyasr and @shwina) helped solve the issue: ``` (rapids) root@5a38f55ffbdd:/rmm/python# pip install . Processing /rmm/python Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done ... (rapids) root@5a38f55ffbdd:/rmm/python# python -c 'import rmm; buf = rmm.DeviceBuffer(size=100); print(buf.size); print(buf.ptr)' 100 140379508703232 (rapids) root@5a38f55ffbdd:/rmm/python# ``` Authors: - Sevag Hanssian (https://github.com/sevagh) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Ashwin Srinath (https://github.com/shwina) URL: https://github.com/rapidsai/rmm/pull/994 --- python/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/python/pyproject.toml b/python/pyproject.toml index 5fe11a11e..88ed56b3f 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -21,6 +21,7 @@ requires = [ "scikit-build>=0.13.1", "cmake>=3.20.1", "ninja", + "cuda-python>=11.5,<12.0", ] [tool.black] From 6856d867beb1fe226f44cd17d78b36db243380ea Mon Sep 17 00:00:00 2001 From: Rong Ou Date: Mon, 14 Mar 2022 20:16:26 -0700 Subject: [PATCH 059/675] Log allocation failures (#988) Right now when we run out of memory, the last allocation that causes the OOM is not being logged. Adding a new `allocate failure` line to the log to help with debugging. For now these lines are ignored by the replay utility. @abellina Authors: - Rong Ou (https://github.com/rongou) Approvers: - Mark Harris (https://github.com/harrism) - Jake Hemstad (https://github.com/jrhemstad) URL: https://github.com/rapidsai/rmm/pull/988 --- benchmarks/replay/replay.cpp | 3 +- benchmarks/utilities/log_parser.hpp | 21 ++++++++--- .../mr/device/logging_resource_adaptor.hpp | 23 ++++++++---- tests/logger_tests.cpp | 35 +++++++++++++++++++ 4 files changed, 70 insertions(+), 12 deletions(-) diff --git a/benchmarks/replay/replay.cpp b/benchmarks/replay/replay.cpp index aa8c077da..edae79acf 100644 --- a/benchmarks/replay/replay.cpp +++ b/benchmarks/replay/replay.cpp @@ -217,10 +217,11 @@ struct replay_benchmark { cv.wait(lock, [&]() { return event_index == event.index; }); } + // rmm::detail::action::ALLOCATE_FAILURE is ignored. if (rmm::detail::action::ALLOCATE == event.act) { auto ptr = mr_->allocate(event.size); set_allocation(event.pointer, allocation{ptr, event.size}); - } else { + } else if (rmm::detail::action::FREE == event.act) { auto alloc = remove_allocation(event.pointer); mr_->deallocate(alloc.ptr, event.size); } diff --git a/benchmarks/utilities/log_parser.hpp b/benchmarks/utilities/log_parser.hpp index db939e65f..d52672a4b 100644 --- a/benchmarks/utilities/log_parser.hpp +++ b/benchmarks/utilities/log_parser.hpp @@ -33,7 +33,7 @@ namespace rmm::detail { -enum class action : bool { ALLOCATE, FREE }; +enum class action { ALLOCATE, FREE, ALLOCATE_FAILURE }; /** * @brief Represents an allocation event @@ -85,8 +85,13 @@ struct event { inline std::ostream& operator<<(std::ostream& os, event const& evt) { - const auto* act_string = (evt.act == action::ALLOCATE) ? "allocate" : "free"; - + const auto* act_string{[&evt] { + switch (evt.act) { + case action::ALLOCATE: return "allocate"; + case action::FREE: return "free"; + default: return "allocate failure"; + } + }()}; const auto format_width{9}; os << "Thread: " << evt.thread_id << std::setw(format_width) << act_string @@ -164,8 +169,14 @@ inline std::vector parse_csv(std::string const& filename) for (std::size_t i = 0; i < actions.size(); ++i) { auto const& action = actions[i]; - RMM_EXPECTS((action == "allocate") or (action == "free"), "Invalid action string."); - auto act = (action == "allocate") ? action::ALLOCATE : action::FREE; + RMM_EXPECTS((action == "allocate") or (action == "allocate failure") or (action == "free"), + "Invalid action string."); + auto act{action::ALLOCATE_FAILURE}; + if (action == "allocate") { + act = action::ALLOCATE; + } else if (action == "free") { + act = action::FREE; + } events[i] = event{tids[i], act, sizes[i], pointers[i], streams[i], i}; } return events; diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index f583e31b9..60fd0d366 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -205,10 +205,16 @@ class logging_resource_adaptor final : public device_memory_resource { * @brief Allocates memory of size at least `bytes` using the upstream * resource and logs the allocation. * - * If the upstream allocation is successful logs the - * following CSV formatted line to the file specified at construction: + * If the upstream allocation is successful, logs the following CSV formatted + * line to the file specified at construction: * ``` - * thread_id,*TIMESTAMP*,"allocate",*bytes*,*stream* + * thread_id,*TIMESTAMP*,"allocate",*pointer*,*bytes*,*stream* + * ``` + * + * If the upstream allocation failed, logs the following CSV formatted line + * to the file specified at construction: + * ``` + * thread_id,*TIMESTAMP*,"allocate failure",0x0,*bytes*,*stream* * ``` * * The returned pointer has at least 256B alignment. @@ -222,9 +228,14 @@ class logging_resource_adaptor final : public device_memory_resource { */ void* do_allocate(std::size_t bytes, cuda_stream_view stream) override { - auto const ptr = upstream_->allocate(bytes, stream); - logger_->info("allocate,{},{},{}", ptr, bytes, fmt::ptr(stream.value())); - return ptr; + try { + auto const ptr = upstream_->allocate(bytes, stream); + logger_->info("allocate,{},{},{}", ptr, bytes, fmt::ptr(stream.value())); + return ptr; + } catch (...) { + logger_->info("allocate failure,{},{},{}", nullptr, bytes, fmt::ptr(stream.value())); + throw; + } } /** diff --git a/tests/logger_tests.cpp b/tests/logger_tests.cpp index 1b8356ac7..f221a3a36 100644 --- a/tests/logger_tests.cpp +++ b/tests/logger_tests.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include "./byte_literals.hpp" #include #include @@ -24,6 +25,9 @@ #include +namespace rmm::test { +namespace { + class raii_restore_env { public: raii_restore_env(char const* name) : name_(name) @@ -212,6 +216,34 @@ TEST(Adaptor, EnvironmentPath) expect_log_events(filename, expected_events); } +TEST(Adaptor, AllocateFailure) +{ + std::string filename{"logs/failure.txt"}; + rmm::mr::cuda_memory_resource upstream; + + auto log_mr = rmm::mr::make_logging_adaptor(&upstream, filename); + + auto const size0{99}; + auto const size1{1_TiB}; + + auto* ptr0 = log_mr.allocate(size0); + log_mr.deallocate(ptr0, size0); + try { + log_mr.allocate(size1); + } catch (...) { + } + log_mr.flush(); + + using rmm::detail::action; + using rmm::detail::event; + + std::vector expected_events{{action::ALLOCATE, size0, ptr0}, + {action::FREE, size0, ptr0}, + {action::ALLOCATE_FAILURE, size1, nullptr}}; + + expect_log_events(filename, expected_events); +} + TEST(Adaptor, STDOUT) { testing::internal::CaptureStdout(); @@ -247,3 +279,6 @@ TEST(Adaptor, STDERR) std::string header = output.substr(0, output.find('\n')); ASSERT_EQ(header, log_mr.header()); } + +} // namespace +} // namespace rmm::test From 3992c3c5b2d7bd9af3de89e39191f520d76c8387 Mon Sep 17 00:00:00 2001 From: Anis Ladram Date: Tue, 15 Mar 2022 17:49:59 -0400 Subject: [PATCH 060/675] Fix free-before-alloc in multithreaded test (#992) Uses a CUDA event to make sure `streamA` and `streamB` are correctly synchronized. Authors: - Anis Ladram (https://github.com/aladram) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/992 --- tests/mr/device/mr_multithreaded_tests.cpp | 31 +++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/tests/mr/device/mr_multithreaded_tests.cpp b/tests/mr/device/mr_multithreaded_tests.cpp index 38c34d93f..6d6d8edc2 100644 --- a/tests/mr/device/mr_multithreaded_tests.cpp +++ b/tests/mr/device/mr_multithreaded_tests.cpp @@ -179,6 +179,7 @@ void allocate_loop(rmm::mr::device_memory_resource* mr, std::size_t num_allocations, std::list& allocations, std::mutex& mtx, + cudaEvent_t& event, rmm::cuda_stream_view stream) { constexpr std::size_t max_size{1_MiB}; @@ -191,6 +192,7 @@ void allocate_loop(rmm::mr::device_memory_resource* mr, void* ptr = mr->allocate(size, stream); { std::lock_guard lock(mtx); + RMM_CUDA_TRY(cudaEventRecord(event, stream.value())); allocations.emplace_back(ptr, size); } } @@ -200,12 +202,14 @@ void deallocate_loop(rmm::mr::device_memory_resource* mr, std::size_t num_allocations, std::list& allocations, std::mutex& mtx, + cudaEvent_t& event, rmm::cuda_stream_view stream) { for (std::size_t i = 0; i < num_allocations;) { std::lock_guard lock(mtx); if (allocations.empty()) { continue; } i++; + RMM_CUDA_TRY(cudaStreamWaitEvent(stream.value(), event)); allocation alloc = allocations.front(); allocations.pop_front(); mr->deallocate(alloc.ptr, alloc.size, stream); @@ -220,15 +224,30 @@ void test_allocate_free_different_threads(rmm::mr::device_memory_resource* mr, std::mutex mtx; std::list allocations; - - std::thread producer( - allocate_loop, mr, num_allocations, std::ref(allocations), std::ref(mtx), streamA); - - std::thread consumer( - deallocate_loop, mr, num_allocations, std::ref(allocations), std::ref(mtx), streamB); + cudaEvent_t event; + + RMM_CUDA_TRY(cudaEventCreate(&event)); + + std::thread producer(allocate_loop, + mr, + num_allocations, + std::ref(allocations), + std::ref(mtx), + std::ref(event), + streamA); + + std::thread consumer(deallocate_loop, + mr, + num_allocations, + std::ref(allocations), + std::ref(mtx), + std::ref(event), + streamB); producer.join(); consumer.join(); + + RMM_CUDA_TRY(cudaEventDestroy(event)); } TEST_P(mr_test_mt, AllocFreeDifferentThreadsDefaultStream) From 438d312257fa5bc6b57b8c2b1191e6e61d04a307 Mon Sep 17 00:00:00 2001 From: Rong Ou Date: Wed, 16 Mar 2022 13:01:45 -0700 Subject: [PATCH 061/675] Disable opportunistic reuse in async mr when cuda driver < 11.5 (#993) With https://github.com/NVIDIA/spark-rapids/issues/4710 we found some issues with the async pool that may cause memory errors with older drivers. This was confirmed with the cuda team. For driver version < 11.5, we'll disable `cudaMemPoolReuseAllowOpportunistic`. @abellina Authors: - Rong Ou (https://github.com/rongou) Approvers: - Alessandro Bellina (https://github.com/abellina) - Jake Hemstad (https://github.com/jrhemstad) - Mark Harris (https://github.com/harrism) - Leo Fang (https://github.com/leofang) URL: https://github.com/rapidsai/rmm/pull/993 --- include/rmm/mr/device/cuda_async_memory_resource.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 5c0525131..f73497a5e 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -73,6 +73,18 @@ class cuda_async_memory_resource final : public device_memory_resource { pool_props.location.id = rmm::detail::current_device().value(); RMM_CUDA_TRY(cudaMemPoolCreate(&cuda_pool_handle_, &pool_props)); + // CUDA drivers before 11.5 have known incompatibilities with the async allocator. + // We'll disable `cudaMemPoolReuseAllowOpportunistic` if cuda driver < 11.5. + // See https://github.com/NVIDIA/spark-rapids/issues/4710. + int driver_version{}; + RMM_CUDA_TRY(cudaDriverGetVersion(&driver_version)); + constexpr auto min_async_version{11050}; + if (driver_version < min_async_version) { + int disabled{0}; + RMM_CUDA_TRY( + cudaMemPoolSetAttribute(cuda_pool_handle_, cudaMemPoolReuseAllowOpportunistic, &disabled)); + } + auto const [free, total] = rmm::detail::available_device_memory(); // Need an l-value to take address to pass to cudaMemPoolSetAttribute From c49493dea6caf7e8c840b1c83f20caa50de92d5f Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Thu, 17 Mar 2022 12:35:16 -0400 Subject: [PATCH 062/675] DOC --- CHANGELOG.md | 4 ++++ CMakeLists.txt | 4 ++-- doxygen/Doxyfile | 2 +- python/CMakeLists.txt | 2 +- python/docs/conf.py | 6 +++--- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2012917b3..d2ab8428f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# RMM 22.06.00 (Date TBD) + +Please see https://github.com/rapidsai/rmm/releases/tag/v22.06.00a for the latest changes to this development branch. + # RMM 22.04.00 (Date TBD) Please see https://github.com/rapidsai/rmm/releases/tag/v22.04.00a for the latest changes to this development branch. diff --git a/CMakeLists.txt b/CMakeLists.txt index 425f3e8da..49ccadb0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.04/RAPIDS.cmake +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.06/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) @@ -25,7 +25,7 @@ include(rapids-find) project( RMM - VERSION 22.04.00 + VERSION 22.06.00 LANGUAGES CXX) # Write the version header diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 4540def1f..d252e6d69 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "RMM" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 22.04 +PROJECT_NUMBER = 22.06 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index a6442fdc7..c92a4ec74 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -15,7 +15,7 @@ cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) # TODO: Pull this directly from the file written by rapids_cmake_write_version_file. -set(rmm_version 22.04.00) +set(rmm_version 22.06.00) project( rmm-python diff --git a/python/docs/conf.py b/python/docs/conf.py index 5c88dcb2b..186edaa5a 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -19,7 +19,7 @@ author = "NVIDIA" # The full version, including alpha/beta/rc tags -release = "22.04.00" +release = "22.06.00" # -- General configuration --------------------------------------------------- @@ -69,9 +69,9 @@ # built documents. # # The short X.Y version. -version = "22.04" +version = "22.06" # The full version, including alpha/beta/rc tags. -release = "22.04.00" +release = "22.06.00" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. From b21734e28ed3af5787f4aeb64c683364dd9b2bf4 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Thu, 17 Mar 2022 16:59:57 -0400 Subject: [PATCH 063/675] Update `librmm` `conda` recipe (#997) This PR updates the `librmm` `conda` recipe with some learnings from https://github.com/rapidsai/cudf/pull/10326. Namely that the top-level `build.sh` script is the only feasible approach for consolidating the recipes. The implication of these changes is that any shared libraries used in the top-level build must now manually be specified as `run` dependencies of the corresponding `outputs` package. To help reduce the amount of duplication of version specifications for these packages, dependency versions can be specified in `conda/recipes/librmm/conda_build_config.yaml`. The exception here is the version spec used for `cudatoolkit` since that comes from an environment variable in the CI process. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Jake Awe (https://github.com/AyodeAwe) - Jordan Jacobelli (https://github.com/Ethyling) URL: https://github.com/rapidsai/rmm/pull/997 --- conda/recipes/librmm/build.sh | 3 ++ conda/recipes/librmm/conda_build_config.yaml | 5 ++ conda/recipes/librmm/install_librmm.sh | 3 +- conda/recipes/librmm/install_librmm_tests.sh | 2 - conda/recipes/librmm/meta.yaml | 50 ++++++++++---------- 5 files changed, 35 insertions(+), 28 deletions(-) create mode 100644 conda/recipes/librmm/build.sh create mode 100644 conda/recipes/librmm/conda_build_config.yaml diff --git a/conda/recipes/librmm/build.sh b/conda/recipes/librmm/build.sh new file mode 100644 index 000000000..8bf1cb7e3 --- /dev/null +++ b/conda/recipes/librmm/build.sh @@ -0,0 +1,3 @@ +# Copyright (c) 2018-2022, NVIDIA CORPORATION. + +./build.sh -n -v clean librmm tests benchmarks --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml new file mode 100644 index 000000000..56b428fe7 --- /dev/null +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -0,0 +1,5 @@ +cmake_version: + - ">=3.20.1" + +gtest_version: + - "=1.10.0" diff --git a/conda/recipes/librmm/install_librmm.sh b/conda/recipes/librmm/install_librmm.sh index f8533698f..cc4722354 100644 --- a/conda/recipes/librmm/install_librmm.sh +++ b/conda/recipes/librmm/install_librmm.sh @@ -1,4 +1,3 @@ #!/bin/bash -# Copyright (c) 2018-2022, NVIDIA CORPORATION. -./build.sh -v librmm --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" +cmake --install build diff --git a/conda/recipes/librmm/install_librmm_tests.sh b/conda/recipes/librmm/install_librmm_tests.sh index cde738cc0..9993e1ba9 100644 --- a/conda/recipes/librmm/install_librmm_tests.sh +++ b/conda/recipes/librmm/install_librmm_tests.sh @@ -1,5 +1,3 @@ #!/bin/bash -# Copyright (c) 2018-2022, NVIDIA CORPORATION. -./build.sh -n -v librmm tests benchmarks --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" cmake --install build --component testing diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index cfc52ea60..7e6d0eb1c 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -1,10 +1,9 @@ -# Copyright (c) 2018, NVIDIA CORPORATION. +# Copyright (c) 2018-2022, NVIDIA CORPORATION. {% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} {% set cuda_version='.'.join(environ.get('CUDA', '9.2').split('.')[:2]) %} {% set cuda_major=cuda_version.split('.')[0] %} -{% set cmake_version=">=3.20.1" %} -{% set gtest_version="=1.10.0" %} +{% set cuda_spec = ">=" + cuda_major ~ ",<" + (cuda_major | int + 1) ~ ".0a0" %} # i.e. >=11,<12.0a0 package: name: librmm-split @@ -12,6 +11,28 @@ package: source: git_url: ../../.. +requirements: + build: + - cmake {{ cmake_version }} + host: + - cudatoolkit {{ cuda_version }}.* + +build: + script_env: + - CC + - CXX + - CUDAHOSTCXX + - PARALLEL_LEVEL + - CMAKE_GENERATOR + - CMAKE_C_COMPILER_LAUNCHER + - CMAKE_CXX_COMPILER_LAUNCHER + - CMAKE_CUDA_COMPILER_LAUNCHER + - SCCACHE_S3_KEY_PREFIX=librmm-aarch64 # [aarch64] + - SCCACHE_S3_KEY_PREFIX=librmm-linux64 # [linux64] + - SCCACHE_BUCKET=rapids-sccache + - SCCACHE_REGION=us-west-2 + - SCCACHE_IDLE_TIMEOUT=32768 + outputs: - name: librmm version: {{ version }} @@ -19,30 +40,14 @@ outputs: build: number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} - script_env: &script_env - - CC - - CXX - - CUDAHOSTCXX - - PARALLEL_LEVEL - - CMAKE_GENERATOR - - CMAKE_C_COMPILER_LAUNCHER - - CMAKE_CXX_COMPILER_LAUNCHER - - CMAKE_CUDA_COMPILER_LAUNCHER - - SCCACHE_S3_KEY_PREFIX=librmm-aarch64 # [aarch64] - - SCCACHE_S3_KEY_PREFIX=librmm-linux64 # [linux64] - - SCCACHE_BUCKET=rapids-sccache - - SCCACHE_REGION=us-west-2 - - SCCACHE_IDLE_TIMEOUT=32768 run_exports: - {{ pin_subpackage("librmm", max_pin="x.x") }} requirements: build: - cmake {{ cmake_version }} - host: - - cudatoolkit {{ cuda_version }}.* run: + - cudatoolkit {{ cuda_spec }} - spdlog>=1.8.5,<1.9 - - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} test: commands: - test -f $PREFIX/include/rmm/thrust_rmm_allocator.h @@ -87,14 +92,11 @@ outputs: build: number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} - script_env: *script_env requirements: build: - cmake {{ cmake_version }} - host: - - cudatoolkit {{ cuda_version }}.* run: - - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} + - cudatoolkit {{ cuda_spec }} - {{ pin_subpackage('librmm', exact=True) }} - gtest {{ gtest_version }} - gmock {{ gtest_version }} From 7434bd6bd600d17d4b63e347960042bd81daa3e3 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 18 Mar 2022 09:12:44 -0400 Subject: [PATCH 064/675] Use CUDA 11.2+ features via dlopen (#990) By binding to the cudart 11.2 functions at runtime we remove the requirement that these symbols exist, therefore allowing RMM to be compiled with 11.2+ and used with 11.0 or 11.1. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Jake Hemstad (https://github.com/jrhemstad) - Rong Ou (https://github.com/rongou) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/990 --- CMakeLists.txt | 1 + include/rmm/detail/dynamic_load_runtime.hpp | 140 ++++++++++++++++++ .../mr/device/cuda_async_memory_resource.hpp | 48 ++---- tests/mr/device/cuda_async_mr_tests.cpp | 2 +- tests/mr/device/mr_test.hpp | 2 +- 5 files changed, 156 insertions(+), 37 deletions(-) create mode 100644 include/rmm/detail/dynamic_load_runtime.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 425f3e8da..8f6f0c176 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,7 @@ target_include_directories(rmm INTERFACE "$ +#include +#include +#include + +namespace rmm::detail { + +/** + * @brief `dynamic_load_runtime` loads the cuda runtime library at runtime + * + * By loading the cudart library at runtime we can use functions that + * are added in newer minor versions of the cuda runtime. + */ +struct dynamic_load_runtime { + static void* get_cuda_runtime_handle() + { + auto close_cudart = [](void* handle) { ::dlclose(handle); }; + auto open_cudart = []() { + ::dlerror(); + const int major = CUDART_VERSION / 1000; + const std::string libname_ver = "libcudart.so." + std::to_string(major) + ".0"; + const std::string libname = "libcudart.so"; + + auto ptr = ::dlopen(libname_ver.c_str(), RTLD_LAZY); + if (!ptr) { ptr = ::dlopen(libname.c_str(), RTLD_LAZY); } + if (ptr) { return ptr; } + + RMM_FAIL("Unable to dlopen cudart"); + }; + static std::unique_ptr cudart_handle{open_cudart(), close_cudart}; + return cudart_handle.get(); + } + + template + using function_sig = std::add_pointer_t; + + template + static std::optional function(const char* func_name) + { + auto* runtime = get_cuda_runtime_handle(); + auto* handle = ::dlsym(runtime, func_name); + if (!handle) { return std::nullopt; } + auto* function_ptr = reinterpret_cast(handle); + return std::optional(function_ptr); + } +}; + +#if defined(RMM_STATIC_CUDART) +// clang-format off +#define RMM_CUDART_API_WRAPPER(name, signature) \ + template \ + static cudaError_t name(Args... args) \ + { \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Waddress\"") \ + static_assert(static_cast(::name), \ + "Failed to find #name function with arguments #signature"); \ + _Pragma("GCC diagnostic pop") \ + return ::name(args...); \ + } +// clang-format on +#else +#define RMM_CUDART_API_WRAPPER(name, signature) \ + template \ + static cudaError_t name(Args... args) \ + { \ + static const auto func = dynamic_load_runtime::function(#name); \ + if (func) { return (*func)(args...); } \ + RMM_FAIL("Failed to find #name function in libcudart.so"); \ + } +#endif + +#if CUDART_VERSION >= 11020 // 11.2 introduced cudaMallocAsync +/** + * @brief Bind to the stream-ordered memory allocator functions + * at runtime. + * + * This allows RMM users to compile/link against CUDA 11.2+ and run with + * < CUDA 11.2 runtime as these functions are found at call time. + */ +struct async_alloc { + static bool is_supported() + { +#if defined(RMM_STATIC_CUDART) + static bool runtime_supports_pool = (CUDART_VERSION >= 11020); +#else + static bool runtime_supports_pool = + dynamic_load_runtime::function>( + "cudaFreeAsync") + .has_value(); +#endif + + static auto driver_supports_pool{[] { + int cuda_pool_supported{}; + auto result = cudaDeviceGetAttribute(&cuda_pool_supported, + cudaDevAttrMemoryPoolsSupported, + rmm::detail::current_device().value()); + return result == cudaSuccess and cuda_pool_supported == 1; + }()}; + return runtime_supports_pool and driver_supports_pool; + } + + template + using cudart_sig = dynamic_load_runtime::function_sig; + + using cudaMemPoolCreate_sig = cudart_sig; + RMM_CUDART_API_WRAPPER(cudaMemPoolCreate, cudaMemPoolCreate_sig); + + using cudaMemPoolSetAttribute_sig = cudart_sig; + RMM_CUDART_API_WRAPPER(cudaMemPoolSetAttribute, cudaMemPoolSetAttribute_sig); + + using cudaMemPoolDestroy_sig = cudart_sig; + RMM_CUDART_API_WRAPPER(cudaMemPoolDestroy, cudaMemPoolDestroy_sig); + + using cudaMallocFromPoolAsync_sig = cudart_sig; + RMM_CUDART_API_WRAPPER(cudaMallocFromPoolAsync, cudaMallocFromPoolAsync_sig); + + using cudaFreeAsync_sig = cudart_sig; + RMM_CUDART_API_WRAPPER(cudaFreeAsync, cudaFreeAsync_sig); +}; +#endif + +#undef RMM_CUDART_API_WRAPPER +} // namespace rmm::detail diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index f73497a5e..8099c5d96 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -62,7 +63,7 @@ class cuda_async_memory_resource final : public device_memory_resource { { #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT // Check if cudaMallocAsync Memory pool supported - RMM_EXPECTS(is_supported(), + RMM_EXPECTS(rmm::detail::async_alloc::is_supported(), "cudaMallocAsync not supported with this CUDA driver/runtime version"); // Construct explicit pool @@ -71,7 +72,7 @@ class cuda_async_memory_resource final : public device_memory_resource { pool_props.handleTypes = cudaMemHandleTypePosixFileDescriptor; pool_props.location.type = cudaMemLocationTypeDevice; pool_props.location.id = rmm::detail::current_device().value(); - RMM_CUDA_TRY(cudaMemPoolCreate(&cuda_pool_handle_, &pool_props)); + RMM_CUDA_TRY(rmm::detail::async_alloc::cudaMemPoolCreate(&cuda_pool_handle_, &pool_props)); // CUDA drivers before 11.5 have known incompatibilities with the async allocator. // We'll disable `cudaMemPoolReuseAllowOpportunistic` if cuda driver < 11.5. @@ -81,16 +82,16 @@ class cuda_async_memory_resource final : public device_memory_resource { constexpr auto min_async_version{11050}; if (driver_version < min_async_version) { int disabled{0}; - RMM_CUDA_TRY( - cudaMemPoolSetAttribute(cuda_pool_handle_, cudaMemPoolReuseAllowOpportunistic, &disabled)); + RMM_CUDA_TRY(rmm::detail::async_alloc::cudaMemPoolSetAttribute( + cuda_pool_handle_, cudaMemPoolReuseAllowOpportunistic, &disabled)); } auto const [free, total] = rmm::detail::available_device_memory(); // Need an l-value to take address to pass to cudaMemPoolSetAttribute uint64_t threshold = release_threshold.value_or(total); - RMM_CUDA_TRY( - cudaMemPoolSetAttribute(cuda_pool_handle_, cudaMemPoolAttrReleaseThreshold, &threshold)); + RMM_CUDA_TRY(rmm::detail::async_alloc::cudaMemPoolSetAttribute( + cuda_pool_handle_, cudaMemPoolAttrReleaseThreshold, &threshold)); // Allocate and immediately deallocate the initial_pool_size to prime the pool with the // specified size @@ -115,7 +116,7 @@ class cuda_async_memory_resource final : public device_memory_resource { ~cuda_async_memory_resource() override { #if defined(RMM_CUDA_MALLOC_ASYNC_SUPPORT) - RMM_ASSERT_CUDA_SUCCESS(cudaMemPoolDestroy(pool_handle())); + RMM_ASSERT_CUDA_SUCCESS(rmm::detail::async_alloc::cudaMemPoolDestroy(pool_handle())); #endif } cuda_async_memory_resource(cuda_async_memory_resource const&) = delete; @@ -123,32 +124,6 @@ class cuda_async_memory_resource final : public device_memory_resource { cuda_async_memory_resource& operator=(cuda_async_memory_resource const&) = delete; cuda_async_memory_resource& operator=(cuda_async_memory_resource&&) = delete; - /** - * @brief Is cudaMallocAsync supported with this cuda runtime/driver version? - * @return true if both the cuda runtime and driver are newer than 11.2 - */ - static bool is_supported() - { -#if defined(RMM_CUDA_MALLOC_ASYNC_SUPPORT) - static auto runtime_supports_pool{[] { - int runtime_version{}; - RMM_CUDA_TRY(cudaRuntimeGetVersion(&runtime_version)); - constexpr auto min_async_version{11020}; - return runtime_version >= min_async_version; - }()}; - static auto driver_supports_pool{[] { - int cuda_pool_supported{}; - auto result = cudaDeviceGetAttribute(&cuda_pool_supported, - cudaDevAttrMemoryPoolsSupported, - rmm::detail::current_device().value()); - return result == cudaSuccess and cuda_pool_supported == 1; - }()}; - return runtime_supports_pool and driver_supports_pool; -#else - return false; -#endif - } - /** * @brief Query whether the resource supports use of non-null CUDA streams for * allocation/deallocation. `cuda_memory_resource` does not support streams. @@ -184,7 +159,8 @@ class cuda_async_memory_resource final : public device_memory_resource { void* ptr{nullptr}; #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT if (bytes > 0) { - RMM_CUDA_TRY_ALLOC(cudaMallocFromPoolAsync(&ptr, bytes, pool_handle(), stream.value())); + RMM_CUDA_TRY_ALLOC(rmm::detail::async_alloc::cudaMallocFromPoolAsync( + &ptr, bytes, pool_handle(), stream.value())); } #else (void)bytes; @@ -203,7 +179,9 @@ class cuda_async_memory_resource final : public device_memory_resource { void do_deallocate(void* ptr, std::size_t, rmm::cuda_stream_view stream) override { #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT - if (ptr != nullptr) { RMM_ASSERT_CUDA_SUCCESS(cudaFreeAsync(ptr, stream.value())); } + if (ptr != nullptr) { + RMM_ASSERT_CUDA_SUCCESS(rmm::detail::async_alloc::cudaFreeAsync(ptr, stream.value())); + } #else (void)ptr; (void)stream; diff --git a/tests/mr/device/cuda_async_mr_tests.cpp b/tests/mr/device/cuda_async_mr_tests.cpp index 1ab806883..d261a11b5 100644 --- a/tests/mr/device/cuda_async_mr_tests.cpp +++ b/tests/mr/device/cuda_async_mr_tests.cpp @@ -28,7 +28,7 @@ class AsyncMRTest : public ::testing::Test { protected: void SetUp() override { - if (!rmm::mr::cuda_async_memory_resource::is_supported()) { + if (!rmm::detail::async_alloc::is_supported()) { GTEST_SKIP() << "Skipping tests since cudaMallocAsync not supported with this CUDA " << "driver/runtime version"; } diff --git a/tests/mr/device/mr_test.hpp b/tests/mr/device/mr_test.hpp index b292dfd46..790c697cf 100644 --- a/tests/mr/device/mr_test.hpp +++ b/tests/mr/device/mr_test.hpp @@ -252,7 +252,7 @@ inline auto make_cuda() { return std::make_shared inline auto make_cuda_async() { - if (rmm::mr::cuda_async_memory_resource::is_supported()) { + if (rmm::detail::async_alloc::is_supported()) { return std::make_shared(); } return std::shared_ptr{nullptr}; From f358d5aec7eb688cc26e8f2f7578c92df396fb66 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Fri, 18 Mar 2022 12:26:16 -0400 Subject: [PATCH 065/675] Remove `no_cma`/`has_cma` variants (#996) Depends on #990. Once #990 is merged, we should no longer need the `no_cma`/`has_cma` `rmm` package variants. This PR removes the two variants. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Jake Awe (https://github.com/AyodeAwe) - Robert Maynard (https://github.com/robertmaynard) URL: https://github.com/rapidsai/rmm/pull/996 --- benchmarks/CMakeLists.txt | 4 ---- build.sh | 16 +++------------- conda/recipes/rmm/build.sh | 7 +------ conda/recipes/rmm/conda_build_config.yaml | 3 --- conda/recipes/rmm/meta.yaml | 8 ++------ python/CMakeLists.txt | 4 ---- tests/CMakeLists.txt | 3 --- 7 files changed, 6 insertions(+), 39 deletions(-) delete mode 100644 conda/recipes/rmm/conda_build_config.yaml diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 61e420638..9dfb2c538 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -42,10 +42,6 @@ function(ConfigureBench BENCH_NAME) target_compile_definitions(${BENCH_NAME} PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM) endif() - if(DEFINED CUDA_MALLOC_ASYNC_SUPPORT AND NOT CUDA_MALLOC_ASYNC_SUPPORT) - target_compile_definitions(${TEST_NAME} PUBLIC "RMM_DISABLE_CUDA_MALLOC_ASYNC") - endif() - target_compile_options( ${BENCH_NAME} PUBLIC $<$:-Wall -Werror -Wno-error=deprecated-declarations -Wno-unknown-pragmas>) diff --git a/build.sh b/build.sh index 1a83652ad..4d5f31d82 100755 --- a/build.sh +++ b/build.sh @@ -18,8 +18,8 @@ ARGS=$* # script, and that this script resides in the repo dir! REPODIR=$(cd $(dirname $0); pwd) -VALIDARGS="clean librmm rmm -v -g -n -s --ptds --no-cudamallocasync -h tests benchmarks" -HELP="$0 [clean] [librmm] [rmm] [-v] [-g] [-n] [-s] [--ptds] [--no-cudamallocasync] [--cmake-args=\"\"] [-h] +VALIDARGS="clean librmm rmm -v -g -n -s --ptds -h tests benchmarks" +HELP="$0 [clean] [librmm] [rmm] [-v] [-g] [-n] [-s] [--ptds] [--cmake-args=\"\"] [-h] clean - remove all existing build artifacts and configuration (start over) librmm - build and install the librmm C++ code rmm - build and install the rmm Python package @@ -30,7 +30,6 @@ HELP="$0 [clean] [librmm] [rmm] [-v] [-g] [-n] [-s] [--ptds] [--no-cudamallocasy -n - no install step -s - statically link against cudart --ptds - enable per-thread default stream - --no-cudamallocasync - disable CUDA malloc async support --cmake-args=\\\"\\\" - pass arbitrary list of CMake configuration options (escape all quotes in argument) -h - print this text @@ -48,7 +47,6 @@ BUILD_BENCHMARKS=OFF BUILD_TESTS=OFF CUDA_STATIC_RUNTIME=OFF PER_THREAD_DEFAULT_STREAM=OFF -CUDA_MALLOC_ASYNC_SUPPORT=ON RAN_CMAKE=0 # Set defaults for vars that may not have been defined externally @@ -94,7 +92,6 @@ function ensureCMakeRan { -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \ -DCUDA_STATIC_RUNTIME="${CUDA_STATIC_RUNTIME}" \ -DPER_THREAD_DEFAULT_STREAM="${PER_THREAD_DEFAULT_STREAM}" \ - -DCUDA_MALLOC_ASYNC_SUPPORT="${CUDA_MALLOC_ASYNC_SUPPORT}" \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ -DBUILD_TESTS=${BUILD_TESTS} \ -DBUILD_BENCHMARKS=${BUILD_BENCHMARKS} \ @@ -143,9 +140,6 @@ fi if hasArg --ptds; then PER_THREAD_DEFAULT_STREAM=ON fi -if hasArg --no-cudamallocasync; then - CUDA_MALLOC_ASYNC_SUPPORT=OFF -fi # If clean given, run it prior to any other steps if hasArg clean; then @@ -179,11 +173,7 @@ if (( NUMARGS == 0 )) || hasArg rmm; then export INSTALL_PREFIX echo "building rmm..." - if [[ ${CUDA_MALLOC_ASYNC_SUPPORT} == OFF ]]; then - python setup.py build_ext --inplace -- -DCUDA_MALLOC_ASYNC_SUPPORT=OFF -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} - else - python setup.py build_ext --inplace -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} - fi + python setup.py build_ext --inplace -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} if [[ ${INSTALL_TARGET} != "" ]]; then echo "installing rmm..." diff --git a/conda/recipes/rmm/build.sh b/conda/recipes/rmm/build.sh index 08990c36e..d2c672e69 100644 --- a/conda/recipes/rmm/build.sh +++ b/conda/recipes/rmm/build.sh @@ -1,9 +1,4 @@ # Copyright (c) 2018-2019, NVIDIA CORPORATION. # Script assumes the script is executed from the root of the repo directory -BUILD_FLAGS="" -if [ "${cudaMallocAsync}" == "no_cma" ]; then - BUILD_FLAGS="${BUILD_FLAGS} --no-cudamallocasync" -fi - -./build.sh -v clean rmm ${BUILD_FLAGS} +./build.sh -v clean rmm diff --git a/conda/recipes/rmm/conda_build_config.yaml b/conda/recipes/rmm/conda_build_config.yaml deleted file mode 100644 index fcbbfef87..000000000 --- a/conda/recipes/rmm/conda_build_config.yaml +++ /dev/null @@ -1,3 +0,0 @@ -cudaMallocAsync: - - has_cma - - no_cma diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 4baa09085..725828464 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -14,7 +14,7 @@ source: build: number: {{ GIT_DESCRIBE_NUMBER }} - string: cuda{{ cuda_major }}_py{{ py_version }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }}_{{ cudaMallocAsync }} + string: cuda{{ cuda_major }}_py{{ py_version }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} script_env: - RMM_BUILD_NO_GPU_TEST - VERSION_SUFFIX @@ -37,11 +37,7 @@ requirements: - python - numba >=0.49 - numpy -{% if cudaMallocAsync == "has_cma" %} - - {{ pin_compatible('cudatoolkit', max_pin='x', lower_bound='11.2') }} # cudatoolkit >=11.2,<12.0.0 -{% else %} - - {{ pin_compatible('cudatoolkit', upper_bound='11.2', lower_bound='11.0') }} # cudatoolkit >=11.0,<11.2 -{% endif %} + - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} - cuda-python >=11.5,<12.0 test: diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index a6442fdc7..dd0f288e9 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -50,10 +50,6 @@ else() set(RMM_FOUND OFF) endif() -if(DEFINED CUDA_MALLOC_ASYNC_SUPPORT AND NOT CUDA_MALLOC_ASYNC_SUPPORT) - add_compile_definitions("RMM_DISABLE_CUDA_MALLOC_ASYNC") -endif() - if(NOT RMM_FOUND) set(BUILD_TESTS OFF) set(BUILD_BENCHMARKS OFF) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 69fbfb6aa..344f66db5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -31,9 +31,6 @@ function(ConfigureTestInternal TEST_NAME) INSTALL_RPATH "\$ORIGIN/../../../lib") target_compile_definitions(${TEST_NAME} PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") - if(DEFINED CUDA_MALLOC_ASYNC_SUPPORT AND NOT CUDA_MALLOC_ASYNC_SUPPORT) - target_compile_definitions(${TEST_NAME} PUBLIC "RMM_DISABLE_CUDA_MALLOC_ASYNC") - endif() target_compile_options(${TEST_NAME} PUBLIC $<$:-Wall -Werror -Wno-error=deprecated-declarations>) From 374d5512de3147792603440909badeae346050ce Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Fri, 18 Mar 2022 12:26:49 -0400 Subject: [PATCH 066/675] Rename `librmm_tests` to `librmm-tests` (#1000) This PR updates the `librmm_tests` package name to `librmm-tests`. Seems like `-` is the convention used on Anaconda.org. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Jordan Jacobelli (https://github.com/Ethyling) URL: https://github.com/rapidsai/rmm/pull/1000 --- ci/gpu/build.sh | 4 ++-- conda/recipes/librmm/meta.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 7302b6aad..af39aaf75 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -91,7 +91,7 @@ if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then fi else - gpuci_mamba_retry install -c $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ librmm librmm_tests + gpuci_mamba_retry install -c $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ librmm librmm-tests TESTRESULTS_DIR=${WORKSPACE}/test-results mkdir -p ${TESTRESULTS_DIR} @@ -101,7 +101,7 @@ else nvidia-smi gpuci_logger "Running googletests" - # run gtests from librmm_tests package + # run gtests from librmm-tests package for gt in "$CONDA_PREFIX/bin/gtests/librmm/"* ; do ${gt} --gtest_output=xml:${TESTRESULTS_DIR}/ exitcode=$? diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 7e6d0eb1c..f70ac8744 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -86,7 +86,7 @@ outputs: home: http://rapids.ai/ license: Apache-2.0 summary: librmm library - - name: librmm_tests + - name: librmm-tests version: {{ version }} script: install_librmm_tests.sh build: From 851d3bac2a34804a135735748381ba9edbccf2a1 Mon Sep 17 00:00:00 2001 From: Ashwin Srinath <3190405+shwina@users.noreply.github.com> Date: Mon, 21 Mar 2022 15:30:10 -0400 Subject: [PATCH 067/675] Bump Python requirements in `setup.cfg` and `rmm_dev.yml` (#982) Authors: - Ashwin Srinath (https://github.com/shwina) Approvers: - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) - Leo Fang (https://github.com/leofang) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/982 --- README.md | 3 ++- conda/environments/rmm_dev_cuda11.5.yml | 2 +- conda/environments/rmm_dev_cuda11.6.yml | 2 +- python/setup.cfg | 2 +- python/setup.py | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2f028a20d..3f71c3394 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,8 @@ conda install -c nvidia -c rapidsai -c conda-forge \ We also provide [nightly Conda packages](https://anaconda.org/rapidsai-nightly) built from the HEAD of our latest development branch. -Note: RMM is supported only on Linux, and with Python versions 3.7 and later. +Note: RMM is supported only on Linux, and only tested with Python versions 3.8 and 3.9. + Note: The RMM package from Conda requires building with GCC 9 or later. Otherwise, your application may fail to build. diff --git a/conda/environments/rmm_dev_cuda11.5.yml b/conda/environments/rmm_dev_cuda11.5.yml index c09595999..d0b3816b7 100644 --- a/conda/environments/rmm_dev_cuda11.5.yml +++ b/conda/environments/rmm_dev_cuda11.5.yml @@ -10,7 +10,7 @@ dependencies: - flake8=3.8.3 - black=19.10 - isort=5.6.4 -- python>=3.7,<3.9 +- python>=3.8,<3.10 - numba>=0.49 - numpy - cffi>=1.10.0 diff --git a/conda/environments/rmm_dev_cuda11.6.yml b/conda/environments/rmm_dev_cuda11.6.yml index 9b1d258d6..c0e8e2ed9 100644 --- a/conda/environments/rmm_dev_cuda11.6.yml +++ b/conda/environments/rmm_dev_cuda11.6.yml @@ -10,7 +10,7 @@ dependencies: - flake8=3.8.3 - black=19.10 - isort=5.6.4 -- python>=3.7,<3.9 +- python>=3.8,<3.10 - numba>=0.49 - numpy - cffi>=1.10.0 diff --git a/python/setup.cfg b/python/setup.cfg index 8722e91cc..df5c37624 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -54,4 +54,4 @@ packages = find: install_requires = numpy numba>=0.49 -python_requires = >=3.7,<3.9 +python_requires = >=3.8 diff --git a/python/setup.py b/python/setup.py index feaa29fe5..106a22f90 100644 --- a/python/setup.py +++ b/python/setup.py @@ -18,8 +18,8 @@ "Topic :: Scientific/Engineering", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", ], # Include the separately-compiled shared library extras_require={"test": ["pytest", "pytest-xdist"]}, From 2715eea1ba3c0e619ac6069f5137849278ceafe8 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Wed, 23 Mar 2022 13:35:32 -0400 Subject: [PATCH 068/675] update `ops-bot` config file (#1005) I recently committed a config file to be used by the [rapidsai/ops-bot](https://github.com/rapidsai/ops-bot/) and in hindsight, I should've had the new `external_contributors` functionality set to `false` until we're ready to roll it out everywhere. This PR fixes that. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: --- .github/ops-bot.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ops-bot.yaml b/.github/ops-bot.yaml index 408e28843..0a52b6795 100644 --- a/.github/ops-bot.yaml +++ b/.github/ops-bot.yaml @@ -5,4 +5,4 @@ auto_merger: true branch_checker: true label_checker: true release_drafter: true -external_contributors: true +external_contributors: false From 220ba88346d05b7b9204b7adc286ed60ad431897 Mon Sep 17 00:00:00 2001 From: fkallen <37172449+fkallen@users.noreply.github.com> Date: Thu, 24 Mar 2022 00:42:29 +0100 Subject: [PATCH 069/675] Allow construction of cuda_async_memory_resource from existing pool (#889) Adds a new MR type `cuda_async_view_memory_resource` which has a constructor `cuda_async_view_memory_resource(cudaMemPool_t valid_pool_handle)` . The memory resource will use this pool for allocation and deallocation instead of managing its own pool. Refactors `cuda_async_memory_resource` to have an instance of the above and create it with a `cudaMemPool_t` that it owns. Authors: - https://github.com/fkallen Approvers: - Mark Harris (https://github.com/harrism) - Jake Hemstad (https://github.com/jrhemstad) - Rong Ou (https://github.com/rongou) URL: https://github.com/rapidsai/rmm/pull/889 --- include/rmm/detail/dynamic_load_runtime.hpp | 3 + .../mr/device/cuda_async_memory_resource.hpp | 25 ++- .../cuda_async_view_memory_resource.hpp | 177 ++++++++++++++++++ tests/mr/device/cuda_async_mr_tests.cpp | 1 + tests/mr/device/cuda_async_view_mr_tests.cpp | 83 ++++++++ 5 files changed, 276 insertions(+), 13 deletions(-) create mode 100644 include/rmm/mr/device/cuda_async_view_memory_resource.hpp create mode 100644 tests/mr/device/cuda_async_view_mr_tests.cpp diff --git a/include/rmm/detail/dynamic_load_runtime.hpp b/include/rmm/detail/dynamic_load_runtime.hpp index 2fe641260..6e60201c1 100644 --- a/include/rmm/detail/dynamic_load_runtime.hpp +++ b/include/rmm/detail/dynamic_load_runtime.hpp @@ -133,6 +133,9 @@ struct async_alloc { using cudaFreeAsync_sig = cudart_sig; RMM_CUDART_API_WRAPPER(cudaFreeAsync, cudaFreeAsync_sig); + + using cudaDeviceGetDefaultMemPool_sig = cudart_sig; + RMM_CUDART_API_WRAPPER(cudaDeviceGetDefaultMemPool, cudaDeviceGetDefaultMemPool_sig); }; #endif diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 8099c5d96..78e885406 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -72,7 +73,9 @@ class cuda_async_memory_resource final : public device_memory_resource { pool_props.handleTypes = cudaMemHandleTypePosixFileDescriptor; pool_props.location.type = cudaMemLocationTypeDevice; pool_props.location.id = rmm::detail::current_device().value(); - RMM_CUDA_TRY(rmm::detail::async_alloc::cudaMemPoolCreate(&cuda_pool_handle_, &pool_props)); + cudaMemPool_t cuda_pool_handle{}; + RMM_CUDA_TRY(rmm::detail::async_alloc::cudaMemPoolCreate(&cuda_pool_handle, &pool_props)); + pool_ = cuda_async_view_memory_resource{cuda_pool_handle}; // CUDA drivers before 11.5 have known incompatibilities with the async allocator. // We'll disable `cudaMemPoolReuseAllowOpportunistic` if cuda driver < 11.5. @@ -83,7 +86,7 @@ class cuda_async_memory_resource final : public device_memory_resource { if (driver_version < min_async_version) { int disabled{0}; RMM_CUDA_TRY(rmm::detail::async_alloc::cudaMemPoolSetAttribute( - cuda_pool_handle_, cudaMemPoolReuseAllowOpportunistic, &disabled)); + pool_handle(), cudaMemPoolReuseAllowOpportunistic, &disabled)); } auto const [free, total] = rmm::detail::available_device_memory(); @@ -91,7 +94,7 @@ class cuda_async_memory_resource final : public device_memory_resource { // Need an l-value to take address to pass to cudaMemPoolSetAttribute uint64_t threshold = release_threshold.value_or(total); RMM_CUDA_TRY(rmm::detail::async_alloc::cudaMemPoolSetAttribute( - cuda_pool_handle_, cudaMemPoolAttrReleaseThreshold, &threshold)); + pool_handle(), cudaMemPoolAttrReleaseThreshold, &threshold)); // Allocate and immediately deallocate the initial_pool_size to prime the pool with the // specified size @@ -110,7 +113,7 @@ class cuda_async_memory_resource final : public device_memory_resource { * @brief Returns the underlying native handle to the CUDA pool * */ - [[nodiscard]] cudaMemPool_t pool_handle() const noexcept { return cuda_pool_handle_; } + [[nodiscard]] cudaMemPool_t pool_handle() const noexcept { return pool_.pool_handle(); } #endif ~cuda_async_memory_resource() override @@ -141,7 +144,7 @@ class cuda_async_memory_resource final : public device_memory_resource { private: #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT - cudaMemPool_t cuda_pool_handle_{}; + cuda_async_view_memory_resource pool_{}; #endif /** @@ -158,10 +161,7 @@ class cuda_async_memory_resource final : public device_memory_resource { { void* ptr{nullptr}; #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT - if (bytes > 0) { - RMM_CUDA_TRY_ALLOC(rmm::detail::async_alloc::cudaMallocFromPoolAsync( - &ptr, bytes, pool_handle(), stream.value())); - } + ptr = pool_.allocate(bytes, stream); #else (void)bytes; (void)stream; @@ -176,14 +176,13 @@ class cuda_async_memory_resource final : public device_memory_resource { * * @param p Pointer to be deallocated */ - void do_deallocate(void* ptr, std::size_t, rmm::cuda_stream_view stream) override + void do_deallocate(void* ptr, std::size_t size, rmm::cuda_stream_view stream) override { #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT - if (ptr != nullptr) { - RMM_ASSERT_CUDA_SUCCESS(rmm::detail::async_alloc::cudaFreeAsync(ptr, stream.value())); - } + pool_.deallocate(ptr, size, stream); #else (void)ptr; + (void)size; (void)stream; #endif } diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp new file mode 100644 index 000000000..d36a2bff0 --- /dev/null +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2021, 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. + */ +#pragma once + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + +#if CUDART_VERSION >= 11020 // 11.2 introduced cudaMallocAsync +#define RMM_CUDA_MALLOC_ASYNC_SUPPORT +#endif + +namespace rmm::mr { + +/** + * @brief `device_memory_resource` derived class that uses `cudaMallocAsync`/`cudaFreeAsync` for + * allocation/deallocation. + */ +class cuda_async_view_memory_resource final : public device_memory_resource { + public: +#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT + /** + * @brief Constructs a cuda_async_view_memory_resource which uses an existing CUDA memory pool. + * The provided pool is not owned by cuda_async_view_memory_resource and must remain valid + * during the lifetime of the memory resource. + * + * @throws rmm::runtime_error if the CUDA version does not support `cudaMallocAsync` + * + * @param valid_pool_handle Handle to a CUDA memory pool which will be used to + * serve allocation requests. + */ + cuda_async_view_memory_resource(cudaMemPool_t valid_pool_handle) + : cuda_pool_handle_{[valid_pool_handle]() { + RMM_EXPECTS(nullptr != valid_pool_handle, "Unexpected null pool handle."); + return valid_pool_handle; + }()} + { + // Check if cudaMallocAsync Memory pool supported + auto const device = rmm::detail::current_device(); + int cuda_pool_supported{}; + auto result = + cudaDeviceGetAttribute(&cuda_pool_supported, cudaDevAttrMemoryPoolsSupported, device.value()); + RMM_EXPECTS(result == cudaSuccess && cuda_pool_supported, + "cudaMallocAsync not supported with this CUDA driver/runtime version"); + } +#endif + +#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT + /** + * @brief Returns the underlying native handle to the CUDA pool + * + */ + [[nodiscard]] cudaMemPool_t pool_handle() const noexcept { return cuda_pool_handle_; } +#endif + + cuda_async_view_memory_resource() = default; + cuda_async_view_memory_resource(cuda_async_view_memory_resource const&) = default; + cuda_async_view_memory_resource(cuda_async_view_memory_resource&&) = default; + cuda_async_view_memory_resource& operator=(cuda_async_view_memory_resource const&) = default; + cuda_async_view_memory_resource& operator=(cuda_async_view_memory_resource&&) = default; + + /** + * @brief Query whether the resource supports use of non-null CUDA streams for + * allocation/deallocation. `cuda_memory_resource` does not support streams. + * + * @returns bool true + */ + [[nodiscard]] bool supports_streams() const noexcept override { return true; } + + /** + * @brief Query whether the resource supports the get_mem_info API. + * + * @return true + */ + [[nodiscard]] bool supports_get_mem_info() const noexcept override { return false; } + + private: +#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT + cudaMemPool_t cuda_pool_handle_{}; +#endif + + /** + * @brief Allocates memory of size at least `bytes` using cudaMalloc. + * + * The returned pointer has at least 256B alignment. + * + * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled + * + * @param bytes The size, in bytes, of the allocation + * @return void* Pointer to the newly allocated memory + */ + void* do_allocate(std::size_t bytes, rmm::cuda_stream_view stream) override + { + void* ptr{nullptr}; +#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT + if (bytes > 0) { + RMM_CUDA_TRY_ALLOC(rmm::detail::async_alloc::cudaMallocFromPoolAsync( + &ptr, bytes, pool_handle(), stream.value())); + } +#else + (void)bytes; + (void)stream; +#endif + return ptr; + } + + /** + * @brief Deallocate memory pointed to by \p p. + * + * @throws Nothing. + * + * @param p Pointer to be deallocated + */ + void do_deallocate(void* ptr, std::size_t, rmm::cuda_stream_view stream) override + { +#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT + if (ptr != nullptr) { + RMM_ASSERT_CUDA_SUCCESS(rmm::detail::async_alloc::cudaFreeAsync(ptr, stream.value())); + } +#else + (void)ptr; + (void)stream; +#endif + } + + /** + * @brief Compare this resource to another. + * + * @throws Nothing. + * + * @param other The other resource to compare to + * @return true If the two resources are equivalent + * @return false If the two resources are not equal + */ + [[nodiscard]] bool do_is_equal(device_memory_resource const& other) const noexcept override + { + return dynamic_cast(&other) != nullptr; + } + + /** + * @brief Get free and available memory for memory resource + * + * @throws `rmm::cuda_error` if unable to retrieve memory info. + * + * @return std::pair contaiing free_size and total_size of memory + */ + [[nodiscard]] std::pair do_get_mem_info( + rmm::cuda_stream_view) const override + { + return std::make_pair(0, 0); + } +}; + +} // namespace rmm::mr diff --git a/tests/mr/device/cuda_async_mr_tests.cpp b/tests/mr/device/cuda_async_mr_tests.cpp index d261a11b5..37ed5c306 100644 --- a/tests/mr/device/cuda_async_mr_tests.cpp +++ b/tests/mr/device/cuda_async_mr_tests.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include diff --git a/tests/mr/device/cuda_async_view_mr_tests.cpp b/tests/mr/device/cuda_async_view_mr_tests.cpp new file mode 100644 index 000000000..86cb6f106 --- /dev/null +++ b/tests/mr/device/cuda_async_view_mr_tests.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2021, 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. + */ + +#include +#include +#include + +#include + +namespace rmm::test { +namespace { + +using cuda_async_view_mr = rmm::mr::cuda_async_view_memory_resource; + +#if defined(RMM_CUDA_MALLOC_ASYNC_SUPPORT) + +TEST(PoolTest, UsePool) +{ + cudaMemPool_t memPool{}; + RMM_CUDA_TRY(rmm::detail::async_alloc::cudaDeviceGetDefaultMemPool( + &memPool, rmm::detail::current_device().value())); + + const auto pool_init_size{100}; + cuda_async_view_mr mr{memPool}; + void* ptr = mr.allocate(pool_init_size); + mr.deallocate(ptr, pool_init_size); + RMM_CUDA_TRY(cudaDeviceSynchronize()); +} + +TEST(PoolTest, NotTakingOwnershipOfPool) +{ + cudaMemPoolProps poolProps = {}; + poolProps.allocType = cudaMemAllocationTypePinned; + poolProps.location.id = rmm::detail::current_device().value(); + poolProps.location.type = cudaMemLocationTypeDevice; + + cudaMemPool_t memPool{}; + + RMM_CUDA_TRY(rmm::detail::async_alloc::cudaMemPoolCreate(&memPool, &poolProps)); + + { + const auto pool_init_size{100}; + cuda_async_view_mr mr{memPool}; + void* ptr = mr.allocate(pool_init_size); + mr.deallocate(ptr, pool_init_size); + RMM_CUDA_TRY(cudaDeviceSynchronize()); + } + + auto destroy_valid_pool = [&]() { + auto result = rmm::detail::async_alloc::cudaMemPoolDestroy(memPool); + RMM_EXPECTS(result == cudaSuccess, "Pool wrapper did destroy pool"); + }; + + EXPECT_NO_THROW(destroy_valid_pool()); +} + +TEST(PoolTest, ThrowIfNullptrPool) +{ + auto construct_mr = []() { + cudaMemPool_t memPool{nullptr}; + cuda_async_view_mr mr{memPool}; + }; + + EXPECT_THROW(construct_mr(), rmm::logic_error); +} + +#endif + +} // namespace +} // namespace rmm::test From fb296feb317604100a61aab8dceb78cd5ad44c9c Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 29 Mar 2022 10:39:35 -0700 Subject: [PATCH 070/675] Clean up Thrust includes. (#1011) ## Description This PR cleans up some `#include`s for Thrust. This is meant to help ease the transition to Thrust 1.16 when that is updated in rapids-cmake. ## Context I opened a PR https://github.com/rapidsai/cudf/pull/10489 that updates cuDF to Thrust 1.16. Notably, Thrust reduced the number of internal header inclusions: > [#1572](https://github.com/NVIDIA/thrust/pull/1572) Removed several unnecessary header includes. Downstream projects may need to update their includes if they were relying on this behavior. I spoke with @robertmaynard and he recommended making similar changes to clean up includes ("include what we use," in essence) to make sure we have compatibility with future versions of Thrust across all RAPIDS libraries. It looks like rmm may be able to build with Thrust 1.16 even without these changes, but I think this changeset may help prevent future problems arising from inconsistency and reliance on `detail` headers. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) - Vyas Ramasubramani (https://github.com/vyasr) - Conor Hoekstra (https://github.com/codereport) URL: https://github.com/rapidsai/rmm/pull/1011 --- benchmarks/device_uvector/device_uvector_bench.cu | 4 +++- include/rmm/mr/device/thrust_allocator_adaptor.hpp | 3 ++- tests/mr/device/thrust_allocator_tests.cu | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/benchmarks/device_uvector/device_uvector_bench.cu b/benchmarks/device_uvector/device_uvector_bench.cu index 701e5fceb..454db81a5 100644 --- a/benchmarks/device_uvector/device_uvector_bench.cu +++ b/benchmarks/device_uvector/device_uvector_bench.cu @@ -15,7 +15,6 @@ */ #include "../synchronization/synchronization.hpp" -#include "thrust/detail/raw_pointer_cast.h" #include #include @@ -30,6 +29,9 @@ #include +#include +#include + #include #include diff --git a/include/rmm/mr/device/thrust_allocator_adaptor.hpp b/include/rmm/mr/device/thrust_allocator_adaptor.hpp index 56e910801..c09c9f334 100644 --- a/include/rmm/mr/device/thrust_allocator_adaptor.hpp +++ b/include/rmm/mr/device/thrust_allocator_adaptor.hpp @@ -19,8 +19,9 @@ #include #include -#include #include +#include +#include namespace rmm::mr { /** diff --git a/tests/mr/device/thrust_allocator_tests.cu b/tests/mr/device/thrust_allocator_tests.cu index e0d467595..3a56a541b 100644 --- a/tests/mr/device/thrust_allocator_tests.cu +++ b/tests/mr/device/thrust_allocator_tests.cu @@ -23,6 +23,8 @@ #include +#include + // explicit instantiation for test coverage purposes template class rmm::mr::thrust_allocator; From 1caa8eec3d58cb2c19648f48222b2e86c411dd88 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 29 Mar 2022 15:05:52 -0700 Subject: [PATCH 071/675] Pin click version to last support by black<22.3.0. --- .pre-commit-config.yaml | 2 ++ conda/environments/rmm_dev_cuda11.5.yml | 1 + conda/environments/rmm_dev_cuda11.6.yml | 1 + 3 files changed, 4 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a50c645ba..8a98beb9e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,6 +12,8 @@ repos: rev: 19.10b0 hooks: - id: black + additional_dependencies: + - click==8.0.4 - repo: https://gitlab.com/pycqa/flake8 rev: 3.8.3 hooks: diff --git a/conda/environments/rmm_dev_cuda11.5.yml b/conda/environments/rmm_dev_cuda11.5.yml index d0b3816b7..4c107fd74 100644 --- a/conda/environments/rmm_dev_cuda11.5.yml +++ b/conda/environments/rmm_dev_cuda11.5.yml @@ -5,6 +5,7 @@ channels: dependencies: - clang=11.1.0 - clang-tools=11.1.0 +- click=8.0.4 - cmake>=3.20.1 - cmake-format=0.6.11 - flake8=3.8.3 diff --git a/conda/environments/rmm_dev_cuda11.6.yml b/conda/environments/rmm_dev_cuda11.6.yml index c0e8e2ed9..0f69d897a 100644 --- a/conda/environments/rmm_dev_cuda11.6.yml +++ b/conda/environments/rmm_dev_cuda11.6.yml @@ -5,6 +5,7 @@ channels: dependencies: - clang=11.1.0 - clang-tools=11.1.0 +- click=8.0.4 - cmake>=3.20.1 - cmake-format=0.6.11 - flake8=3.8.3 From 59fa0b4932c9d34ad07f70e94e8a66686dc2fa73 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 29 Mar 2022 15:08:55 -0700 Subject: [PATCH 072/675] Fix formatting. --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8a98beb9e..f57423eb7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,8 +12,8 @@ repos: rev: 19.10b0 hooks: - id: black - additional_dependencies: - - click==8.0.4 + additional_dependencies: + - click==8.0.4 - repo: https://gitlab.com/pycqa/flake8 rev: 3.8.3 hooks: From 41a246188234e440811373396a7f9c2d2a7725e5 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 30 Mar 2022 16:40:28 -0700 Subject: [PATCH 073/675] Remove pip requirements file. (#1015) This PR removes a pip requirements file that is no longer used. This were previously introduced to support https://github.com/rapidsai/cudf/pull/7647 but that Dockerfile is no longer maintained. See also https://github.com/rapidsai/cudf/pull/10543. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1015 --- python/dev_requirements.txt | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 python/dev_requirements.txt diff --git a/python/dev_requirements.txt b/python/dev_requirements.txt deleted file mode 100644 index 09ad10049..000000000 --- a/python/dev_requirements.txt +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2021-2022, NVIDIA CORPORATION. - -clang==8.0.1 -flake8==3.8.3 -black==19.10b0 -isort==5.6.4 -cmake-format==0.6.11 -numpy -numba>=0.49 -pytest -pytest-xdist -cython>=0.29,<0.30 -wheel -setuptools -scikit-build>=0.13.1 From 14206897310badbb02c946c2afcb1f89505e9088 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 31 Mar 2022 09:18:13 -0700 Subject: [PATCH 074/675] Pin CMake to last working version. (#1014) CMake 3.23 appears to have a bug relating to CUDA support that breaks our builds. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Mark Harris (https://github.com/harrism) --- conda/environments/rmm_dev_cuda11.5.yml | 2 +- conda/environments/rmm_dev_cuda11.6.yml | 2 +- conda/recipes/librmm/conda_build_config.yaml | 2 +- conda/recipes/rmm/meta.yaml | 2 +- python/pyproject.toml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conda/environments/rmm_dev_cuda11.5.yml b/conda/environments/rmm_dev_cuda11.5.yml index 4c107fd74..55558f015 100644 --- a/conda/environments/rmm_dev_cuda11.5.yml +++ b/conda/environments/rmm_dev_cuda11.5.yml @@ -6,7 +6,7 @@ dependencies: - clang=11.1.0 - clang-tools=11.1.0 - click=8.0.4 -- cmake>=3.20.1 +- cmake>=3.20.1,<3.23 - cmake-format=0.6.11 - flake8=3.8.3 - black=19.10 diff --git a/conda/environments/rmm_dev_cuda11.6.yml b/conda/environments/rmm_dev_cuda11.6.yml index 0f69d897a..fff6f926a 100644 --- a/conda/environments/rmm_dev_cuda11.6.yml +++ b/conda/environments/rmm_dev_cuda11.6.yml @@ -6,7 +6,7 @@ dependencies: - clang=11.1.0 - clang-tools=11.1.0 - click=8.0.4 -- cmake>=3.20.1 +- cmake>=3.20.1,<3.23 - cmake-format=0.6.11 - flake8=3.8.3 - black=19.10 diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index 56b428fe7..725ed4744 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -1,5 +1,5 @@ cmake_version: - - ">=3.20.1" + - ">=3.20.1,<3.23" gtest_version: - "=1.10.0" diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 725828464..82eb0a06d 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -28,7 +28,7 @@ requirements: - librmm {{ version }} - setuptools - cython>=0.29,<0.30 - - cmake>=3.20.1 + - cmake>=3.20.1,<3.23 - scikit-build>=0.13.1 - spdlog>=1.8.5,<2.0.0a0 - cudatoolkit {{ cuda_version }}.* diff --git a/python/pyproject.toml b/python/pyproject.toml index 88ed56b3f..a0d65bb73 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -19,7 +19,7 @@ requires = [ "setuptools", "cython>=0.29,<0.30", "scikit-build>=0.13.1", - "cmake>=3.20.1", + "cmake>=3.20.1,<3.23", "ninja", "cuda-python>=11.5,<12.0", ] From 921d2869d4166d1375f35ecbfa0dc1c996bfcffc Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 1 Apr 2022 07:50:46 -0700 Subject: [PATCH 075/675] Update black version (#1010) This PR updates to black 22.3.0 which contains a critical bugfix for a recent release of Click 8.1.0. It also includes some minor reformatting associated with the version bump. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - https://github.com/jakirkham - Jordan Jacobelli (https://github.com/Ethyling) URL: https://github.com/rapidsai/rmm/pull/1010 --- .pre-commit-config.yaml | 5 ++--- ci/checks/style.sh | 2 +- conda/environments/rmm_dev_cuda11.5.yml | 3 +-- conda/environments/rmm_dev_cuda11.6.yml | 3 +-- python/rmm/rmm.py | 3 ++- python/rmm/tests/test_rmm.py | 9 ++++++--- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f57423eb7..00189783f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,11 +9,10 @@ repos: types: [text] types_or: [python, cython] - repo: https://github.com/ambv/black - rev: 19.10b0 + rev: 22.3.0 hooks: - id: black - additional_dependencies: - - click==8.0.4 + args: ["--config=python/pyproject.toml"] - repo: https://gitlab.com/pycqa/flake8 rev: 3.8.3 hooks: diff --git a/ci/checks/style.sh b/ci/checks/style.sh index eb41bc6b5..cec606871 100644 --- a/ci/checks/style.sh +++ b/ci/checks/style.sh @@ -19,7 +19,7 @@ ISORT=`isort --check-only python --settings-path=python/setup.cfg ` ISORT_RETVAL=$? # Run black and get results/return code -BLACK=`black --check python` +BLACK=`black --config python/pyproject.toml --check python` BLACK_RETVAL=$? # Run flake8 and get results/return code diff --git a/conda/environments/rmm_dev_cuda11.5.yml b/conda/environments/rmm_dev_cuda11.5.yml index 55558f015..40fd1f10c 100644 --- a/conda/environments/rmm_dev_cuda11.5.yml +++ b/conda/environments/rmm_dev_cuda11.5.yml @@ -5,11 +5,10 @@ channels: dependencies: - clang=11.1.0 - clang-tools=11.1.0 -- click=8.0.4 - cmake>=3.20.1,<3.23 - cmake-format=0.6.11 - flake8=3.8.3 -- black=19.10 +- black=22.3.0 - isort=5.6.4 - python>=3.8,<3.10 - numba>=0.49 diff --git a/conda/environments/rmm_dev_cuda11.6.yml b/conda/environments/rmm_dev_cuda11.6.yml index fff6f926a..50b116329 100644 --- a/conda/environments/rmm_dev_cuda11.6.yml +++ b/conda/environments/rmm_dev_cuda11.6.yml @@ -5,11 +5,10 @@ channels: dependencies: - clang=11.1.0 - clang-tools=11.1.0 -- click=8.0.4 - cmake>=3.20.1,<3.23 - cmake-format=0.6.11 - flake8=3.8.3 -- black=19.10 +- black=22.3.0 - isort=5.6.4 - python>=3.8,<3.10 - numba>=0.49 diff --git a/python/rmm/rmm.py b/python/rmm/rmm.py index 9c57c6ac6..f77df659a 100644 --- a/python/rmm/rmm.py +++ b/python/rmm/rmm.py @@ -137,7 +137,8 @@ def get_ipc_handle(self, memory): start, end = cuda.cudadrv.driver.device_extents(memory) ipchandle = (ctypes.c_byte * 64)() # IPC handle is 64 bytes cuda.cudadrv.driver.driver.cuIpcGetMemHandle( - ctypes.byref(ipchandle), start, + ctypes.byref(ipchandle), + start, ) source_info = cuda.current_context().device.get_device_identity() offset = memory.handle.value - start diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index c82c306c7..409ed6b72 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -526,7 +526,8 @@ def test_mr_upstream_lifetime(): @pytest.mark.skipif( - not _CUDAMALLOC_ASYNC_SUPPORTED, reason="cudaMallocAsync not supported", + not _CUDAMALLOC_ASYNC_SUPPORTED, + reason="cudaMallocAsync not supported", ) @pytest.mark.parametrize("dtype", _dtypes) @pytest.mark.parametrize("nelem", _nelems) @@ -539,7 +540,8 @@ def test_cuda_async_memory_resource(dtype, nelem, alloc): @pytest.mark.skipif( - not _CUDAMALLOC_ASYNC_SUPPORTED, reason="cudaMallocAsync not supported", + not _CUDAMALLOC_ASYNC_SUPPORTED, + reason="cudaMallocAsync not supported", ) @pytest.mark.parametrize("nelems", _nelems) def test_cuda_async_memory_resource_stream(nelems): @@ -555,7 +557,8 @@ def test_cuda_async_memory_resource_stream(nelems): @pytest.mark.skipif( - not _CUDAMALLOC_ASYNC_SUPPORTED, reason="cudaMallocAsync not supported", + not _CUDAMALLOC_ASYNC_SUPPORTED, + reason="cudaMallocAsync not supported", ) @pytest.mark.parametrize("nelem", _nelems) @pytest.mark.parametrize("alloc", _allocs) From 88a4a6281e655f823d6649f1394c55f29a09417d Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Wed, 6 Apr 2022 10:36:48 -0400 Subject: [PATCH 076/675] update changelog --- CHANGELOG.md | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2012917b3..371b3b353 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,40 @@ -# RMM 22.04.00 (Date TBD) +# RMM 22.04.00 (6 Apr 2022) -Please see https://github.com/rapidsai/rmm/releases/tag/v22.04.00a for the latest changes to this development branch. +## 🐛 Bug Fixes + +- Add cuda-python dependency to pyproject.toml ([#994](https://github.com/rapidsai/rmm/pull/994)) [@sevagh](https://github.com/sevagh) +- Disable opportunistic reuse in async mr when cuda driver < 11.5 ([#993](https://github.com/rapidsai/rmm/pull/993)) [@rongou](https://github.com/rongou) +- Use CUDA 11.2+ features via dlopen ([#990](https://github.com/rapidsai/rmm/pull/990)) [@robertmaynard](https://github.com/robertmaynard) +- Skip async mr tests when cuda runtime/driver < 11.2 ([#986](https://github.com/rapidsai/rmm/pull/986)) [@rongou](https://github.com/rongou) +- Fix warning/error in debug assertion in device_uvector.hpp ([#979](https://github.com/rapidsai/rmm/pull/979)) [@harrism](https://github.com/harrism) +- Fix signed/unsigned comparison warning ([#970](https://github.com/rapidsai/rmm/pull/970)) [@jlowe](https://github.com/jlowe) +- Fix comparison of async MRs with different underlying pools. ([#965](https://github.com/rapidsai/rmm/pull/965)) [@harrism](https://github.com/harrism) + +## 🚀 New Features + +- Use scikit-build for the build process ([#976](https://github.com/rapidsai/rmm/pull/976)) [@vyasr](https://github.com/vyasr) + +## 🛠️ Improvements + +- Temporarily disable new `ops-bot` functionality ([#1005](https://github.com/rapidsai/rmm/pull/1005)) [@ajschmidt8](https://github.com/ajschmidt8) +- Rename `librmm_tests` to `librmm-tests` ([#1000](https://github.com/rapidsai/rmm/pull/1000)) [@ajschmidt8](https://github.com/ajschmidt8) +- Update `librmm` `conda` recipe ([#997](https://github.com/rapidsai/rmm/pull/997)) [@ajschmidt8](https://github.com/ajschmidt8) +- Remove `no_cma`/`has_cma` variants ([#996](https://github.com/rapidsai/rmm/pull/996)) [@ajschmidt8](https://github.com/ajschmidt8) +- Fix free-before-alloc in multithreaded test ([#992](https://github.com/rapidsai/rmm/pull/992)) [@aladram](https://github.com/aladram) +- Add `.github/ops-bot.yaml` config file ([#991](https://github.com/rapidsai/rmm/pull/991)) [@ajschmidt8](https://github.com/ajschmidt8) +- Log allocation failures ([#988](https://github.com/rapidsai/rmm/pull/988)) [@rongou](https://github.com/rongou) +- Update `librmm` `conda` outputs ([#983](https://github.com/rapidsai/rmm/pull/983)) [@ajschmidt8](https://github.com/ajschmidt8) +- Bump Python requirements in `setup.cfg` and `rmm_dev.yml` ([#982](https://github.com/rapidsai/rmm/pull/982)) [@shwina](https://github.com/shwina) +- New benchmark compares concurrent throughput of device_vector and device_uvector ([#981](https://github.com/rapidsai/rmm/pull/981)) [@harrism](https://github.com/harrism) +- Update `librmm` recipe to output `librmm_tests` package ([#978](https://github.com/rapidsai/rmm/pull/978)) [@ajschmidt8](https://github.com/ajschmidt8) +- Update upload.sh to use `--croot` ([#975](https://github.com/rapidsai/rmm/pull/975)) [@AyodeAwe](https://github.com/AyodeAwe) +- Fix `conda` uploads ([#974](https://github.com/rapidsai/rmm/pull/974)) [@ajschmidt8](https://github.com/ajschmidt8) +- Add CMake `install` rules for tests ([#969](https://github.com/rapidsai/rmm/pull/969)) [@ajschmidt8](https://github.com/ajschmidt8) +- Add device_buffer::ssize() and device_uvector::ssize() ([#966](https://github.com/rapidsai/rmm/pull/966)) [@harrism](https://github.com/harrism) +- Added yml file for cudatoolkit version 11.6 ([#964](https://github.com/rapidsai/rmm/pull/964)) [@alhad-deshpande](https://github.com/alhad-deshpande) +- Replace `ccache` with `sccache` ([#963](https://github.com/rapidsai/rmm/pull/963)) [@ajschmidt8](https://github.com/ajschmidt8) +- Make `pool_memory_resource::pool_size()` public ([#962](https://github.com/rapidsai/rmm/pull/962)) [@shwina](https://github.com/shwina) +- Allow construction of cuda_async_memory_resource from existing pool ([#889](https://github.com/rapidsai/rmm/pull/889)) [@fkallen](https://github.com/fkallen) # RMM 22.02.00 (2 Feb 2022) From 23d98ba6d1dd7a71bf736436c082cf105c2e0801 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 7 Apr 2022 12:09:06 -0700 Subject: [PATCH 077/675] Properly enable Cython docstrings. (#1020) This PR embeds signatures in Cython functions and classes so that they'll be accessible for normal Python help. While docstrings are currently present as expected, we still have to provide Cython with the appropriate directives to tell it that we want signatures. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Ashwin Srinath (https://github.com/shwina) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1020 --- python/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index c958d5d9a..cb12813f9 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -14,9 +14,12 @@ cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) -# TODO: Pull this directly from the file written by rapids_cmake_write_version_file. set(rmm_version 22.06.00) +set(CYTHON_FLAGS + "--directive binding=True,embedsignature=True,always_allow_keywords=True" + CACHE STRING "The directives for Cython compilation.") + project( rmm-python VERSION ${rmm_version} From a0674983a4c3c5b152e2d374ccf025d61573642a Mon Sep 17 00:00:00 2001 From: brandon-b-miller <53796099+brandon-b-miller@users.noreply.github.com> Date: Fri, 8 Apr 2022 10:33:43 -0500 Subject: [PATCH 078/675] Update `RMMNumbaManager` to handle `NUMBA_CUDA_USE_NVIDIA_BINDING=1` (#1004) Fixes https://github.com/rapidsai/rmm/issues/1003 Authors: - https://github.com/brandon-b-miller Approvers: - Ashwin Srinath (https://github.com/shwina) - Graham Markall (https://github.com/gmarkall) URL: https://github.com/rapidsai/rmm/pull/1004 --- python/rmm/rmm.py | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/python/rmm/rmm.py b/python/rmm/rmm.py index f77df659a..3e99f51e2 100644 --- a/python/rmm/rmm.py +++ b/python/rmm/rmm.py @@ -13,7 +13,8 @@ # limitations under the License. import ctypes -from numba import cuda +from cuda.cuda import CUdeviceptr, cuIpcGetMemHandle +from numba import config, cuda from numba.cuda import HostOnlyCUDAMemoryManager, IpcHandle, MemoryPointer import rmm @@ -118,14 +119,20 @@ def memalloc(self, size): """ buf = librmm.DeviceBuffer(size=size) ctx = self.context - ptr = ctypes.c_uint64(int(buf.ptr)) - finalizer = _make_emm_plugin_finalizer(ptr.value, self.allocations) + + if config.CUDA_USE_NVIDIA_BINDING: + ptr = CUdeviceptr(int(buf.ptr)) + else: + # expect ctypes bindings in numba + ptr = ctypes.c_uint64(int(buf.ptr)) + + finalizer = _make_emm_plugin_finalizer(int(buf.ptr), self.allocations) # self.allocations is initialized by the parent, HostOnlyCUDAManager, # and cleared upon context reset, so although we insert into it here # and delete from it in the finalizer, we need not do any other # housekeeping elsewhere. - self.allocations[ptr.value] = buf + self.allocations[int(buf.ptr)] = buf return MemoryPointer(ctx, ptr, size, finalizer=finalizer) @@ -135,13 +142,19 @@ def get_ipc_handle(self, memory): the RMM memory pool. """ start, end = cuda.cudadrv.driver.device_extents(memory) - ipchandle = (ctypes.c_byte * 64)() # IPC handle is 64 bytes - cuda.cudadrv.driver.driver.cuIpcGetMemHandle( - ctypes.byref(ipchandle), - start, - ) + + if config.CUDA_USE_NVIDIA_BINDING: + _, ipchandle = cuIpcGetMemHandle(start) + offset = int(memory.handle) - int(start) + else: + ipchandle = (ctypes.c_byte * 64)() # IPC handle is 64 bytes + cuda.cudadrv.driver.driver.cuIpcGetMemHandle( + ctypes.byref(ipchandle), + start, + ) + offset = memory.handle.value - start source_info = cuda.current_context().device.get_device_identity() - offset = memory.handle.value - start + return IpcHandle( memory, ipchandle, memory.size, source_info, offset=offset ) From 36dd42db02fbda76b213c320e389c7c4a52510dd Mon Sep 17 00:00:00 2001 From: Conor Hoekstra <36027403+codereport@users.noreply.github.com> Date: Mon, 11 Apr 2022 15:21:36 -0400 Subject: [PATCH 079/675] Documentation Fix: Replace `cudf::logic_error` with `rmm::logic_error` (#1021) Stumbled across a reference to `cudf::logic_error` that should read `rmm::logic_error`. This PR fixes this small mistake. Authors: - Conor Hoekstra (https://github.com/codereport) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1021 --- include/rmm/detail/error.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/rmm/detail/error.hpp b/include/rmm/detail/error.hpp index 709fac238..1c669822c 100644 --- a/include/rmm/detail/error.hpp +++ b/include/rmm/detail/error.hpp @@ -102,7 +102,7 @@ class out_of_range : public std::out_of_range { * @param[in] _condition Expression that evaluates to true or false * @param[in] _expection_type The exception type to throw; must inherit * `std::exception`. If not specified (i.e. if only two macro - * arguments are provided), defaults to `cudf::logic_error` + * arguments are provided), defaults to `rmm::logic_error` * @param[in] _what String literal description of why the exception was * thrown, i.e. why `_condition` was expected to be true. * @throw `_exception_type` if the condition evaluates to 0 (false). From 97617ba826e89d69ff14457b1ede7d1478cbfa96 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 13 Apr 2022 19:46:10 -0700 Subject: [PATCH 080/675] Update CMake pinning to just avoid 3.23.0. (#1023) CMake 3.23.1 contains the bug fixes that we need to make use of CMake 3.23, so now we can update the pinnings to just avoid 3.23.0. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - https://github.com/jakirkham - Jordan Jacobelli (https://github.com/Ethyling) - Robert Maynard (https://github.com/robertmaynard) URL: https://github.com/rapidsai/rmm/pull/1023 --- conda/environments/rmm_dev_cuda11.5.yml | 2 +- conda/environments/rmm_dev_cuda11.6.yml | 2 +- conda/recipes/librmm/conda_build_config.yaml | 2 +- conda/recipes/rmm/meta.yaml | 2 +- python/pyproject.toml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conda/environments/rmm_dev_cuda11.5.yml b/conda/environments/rmm_dev_cuda11.5.yml index 40fd1f10c..7cdaf866e 100644 --- a/conda/environments/rmm_dev_cuda11.5.yml +++ b/conda/environments/rmm_dev_cuda11.5.yml @@ -5,7 +5,7 @@ channels: dependencies: - clang=11.1.0 - clang-tools=11.1.0 -- cmake>=3.20.1,<3.23 +- cmake>=3.20.1,!=3.23.0 - cmake-format=0.6.11 - flake8=3.8.3 - black=22.3.0 diff --git a/conda/environments/rmm_dev_cuda11.6.yml b/conda/environments/rmm_dev_cuda11.6.yml index 50b116329..fec069e83 100644 --- a/conda/environments/rmm_dev_cuda11.6.yml +++ b/conda/environments/rmm_dev_cuda11.6.yml @@ -5,7 +5,7 @@ channels: dependencies: - clang=11.1.0 - clang-tools=11.1.0 -- cmake>=3.20.1,<3.23 +- cmake>=3.20.1,!=3.23.0 - cmake-format=0.6.11 - flake8=3.8.3 - black=22.3.0 diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index 725ed4744..bc011740d 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -1,5 +1,5 @@ cmake_version: - - ">=3.20.1,<3.23" + - ">=3.20.1,!=3.23.0" gtest_version: - "=1.10.0" diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 82eb0a06d..5d5a7b224 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -28,7 +28,7 @@ requirements: - librmm {{ version }} - setuptools - cython>=0.29,<0.30 - - cmake>=3.20.1,<3.23 + - cmake>=3.20.1,!=3.23.0 - scikit-build>=0.13.1 - spdlog>=1.8.5,<2.0.0a0 - cudatoolkit {{ cuda_version }}.* diff --git a/python/pyproject.toml b/python/pyproject.toml index a0d65bb73..786e7df08 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -19,7 +19,7 @@ requires = [ "setuptools", "cython>=0.29,<0.30", "scikit-build>=0.13.1", - "cmake>=3.20.1,<3.23", + "cmake>=3.20.1,!=3.23.0", "ninja", "cuda-python>=11.5,<12.0", ] From a45fe3c58c2a029d1bd3530af850567d2f823f20 Mon Sep 17 00:00:00 2001 From: jakirkham Date: Thu, 14 Apr 2022 13:58:50 -0700 Subject: [PATCH 081/675] Use `lib` (not `lib64`) for libraries (#1024) Previously some CMake files were getting installed with the `rmm` packages. These were installed because the library directory here did not line up with [the one used by `librmm`]( https://github.com/rapidsai/rmm/blob/97617ba826e89d69ff14457b1ede7d1478cbfa96/conda/recipes/librmm/build.sh#L3 ). This fixes that issue. Also should deduplicate any CMake files that are already included in `librmm` and drop them from `rmm`. cc @robertmaynard @vyasr Authors: - https://github.com/jakirkham Approvers: - Robert Maynard (https://github.com/robertmaynard) - Vyas Ramasubramani (https://github.com/vyasr) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1024 --- conda/recipes/rmm/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda/recipes/rmm/build.sh b/conda/recipes/rmm/build.sh index d2c672e69..4facfce60 100644 --- a/conda/recipes/rmm/build.sh +++ b/conda/recipes/rmm/build.sh @@ -1,4 +1,4 @@ # Copyright (c) 2018-2019, NVIDIA CORPORATION. # Script assumes the script is executed from the root of the repo directory -./build.sh -v clean rmm +./build.sh -v clean rmm --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" From f82d458222f7b55ec64a0c09aa8b0d6f7f76fc7c Mon Sep 17 00:00:00 2001 From: jakirkham Date: Fri, 15 Apr 2022 07:33:42 -0700 Subject: [PATCH 082/675] Use `lib` (not `lib64`) for libraries (backport from 22.06 to 22.04) (#1026) Backport of PR ( https://github.com/rapidsai/rmm/pull/1024 ) to 22.04. cc @robertmaynard @vyasr Authors: - Vyas Ramasubramani (https://github.com/vyasr) - https://github.com/jakirkham Approvers: - Ray Douglass (https://github.com/raydouglass) - Mark Sadang (https://github.com/msadang) --- build.sh | 6 +++--- conda/recipes/rmm/build.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 4d5f31d82..863feeb15 100755 --- a/build.sh +++ b/build.sh @@ -37,7 +37,7 @@ HELP="$0 [clean] [librmm] [rmm] [-v] [-g] [-n] [-s] [--ptds] [--cmake-args=\" Date: Tue, 19 Apr 2022 18:40:44 -0400 Subject: [PATCH 083/675] Callback memory resource (#980) This PR adds a `CallbackMemoryResource` that accepts Python callback functions that are responsible for allocating and deallocating memory (warning: this should not be used in production for performance reasons). ```python import rmm # using a CudaMemoryResource as the backing MR, # define allocation and deallocation functions that # print the amount of memory being (de)allocated base_mr = rmm.mr.CudaMemoryResource() def allocate(size): print(f"Allocating {size}") return base_mr.allocate(size) def deallocate(ptr, size): print(f"Deallocating {size}") return base_mr.deallocate(ptr, size) # create a CallbackMemoryResource and set it to be # the default memory resource used by RMM: mr = rmm.mr.CallbackMemoryResource(allocate, deallocate) rmm.mr.set_current_device_resource(mr) ``` ```python # All allocations/deallocations go through the callback: s = cudf.Series([0, 1, 2]) # prints "Allocating 24" ``` Authors: - Ashwin Srinath (https://github.com/shwina) Approvers: - Jake Hemstad (https://github.com/jrhemstad) - Bradley Dice (https://github.com/bdice) - Mike Wilson (https://github.com/hyperbolic2346) - Leo Fang (https://github.com/leofang) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/980 --- .../mr/device/callback_memory_resource.hpp | 125 ++++++++++++++++++ python/rmm/_lib/memory_resource.pxd | 10 +- python/rmm/_lib/memory_resource.pyx | 98 +++++++++++++- python/rmm/mr.py | 2 + python/rmm/tests/test_rmm.py | 33 ++++- tests/CMakeLists.txt | 3 + tests/mock_resource.hpp | 34 +++++ tests/mr/device/aligned_mr_tests.cpp | 13 +- tests/mr/device/callback_mr_tests.cpp | 84 ++++++++++++ 9 files changed, 385 insertions(+), 17 deletions(-) create mode 100644 include/rmm/mr/device/callback_memory_resource.hpp create mode 100644 tests/mock_resource.hpp create mode 100644 tests/mr/device/callback_mr_tests.cpp diff --git a/include/rmm/mr/device/callback_memory_resource.hpp b/include/rmm/mr/device/callback_memory_resource.hpp new file mode 100644 index 000000000..e2deef46b --- /dev/null +++ b/include/rmm/mr/device/callback_memory_resource.hpp @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2022, 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. + */ +#pragma once + +#include + +#include +#include +#include + +namespace rmm::mr { + +/** + * @brief Callback function type used by callback memory resource for allocation. + * + * The signature of the callback function is: + * `void* allocate_callback_t(std::size_t bytes, cuda_stream_view stream, void* arg); + * + * * Returns a pointer to an allocation of at least `bytes` usable immediately on + * `stream`. The stream-ordered behavior requirements are identical to + * `device_memory_resource::allocate`. + * + * * This signature is compatible with `do_allocate` but adds the extra function + * parameter `arg`. The `arg` is provided to the constructor of the + * `callback_memory_resource` and will be forwarded along to every invocation + * of the callback function. + */ +using allocate_callback_t = std::function; + +/** + * @brief Callback function type used by callback_memory_resource for deallocation. + * + * The signature of the callback function is: + * `void deallocate_callback_t(void* ptr, std::size_t bytes, cuda_stream_view stream, void* arg); + * + * * Deallocates memory pointed to by `ptr`. `bytes` specifies the size of the allocation + * in bytes, and must equal the value of `bytes` that was passed to the allocate callback + * function. The stream-ordered behavior requirements are identical to + * `device_memory_resource::deallocate`. + * + * * This signature is compatible with `do_deallocate` but adds the extra function + * parameter `arg`. The `arg` is provided to the constructor of the + * `callback_memory_resource` and will be forwarded along to every invocation + * of the callback function. + */ +using deallocate_callback_t = std::function; + +/** + * @brief A device memory resource that uses the provided callbacks for memory allocation + * and deallocation. + */ +class callback_memory_resource final : public device_memory_resource { + public: + /** + * @brief Construct a new callback memory resource. + * + * Constructs a callback memory resource that uses the user-provided callbacks + * `allocate_callback` for allocation and `deallocate_callback` for deallocation. + * + * @param allocate_callback The callback function used for allocation + * @param deallocate_callback The callback function used for deallocation + * @param allocate_callback_arg Additional context passed to `allocate_callback`. + * It is the caller's responsibility to maintain the lifetime of the pointed-to data + * for the duration of the lifetime of the `callback_memory_resource`. + * @param deallocate_callback_arg Additional context passed to `deallocate_callback`. + * It is the caller's responsibility to maintain the lifetime of the pointed-to data + * for the duration of the lifetime of the `callback_memory_resource`. + */ + callback_memory_resource(allocate_callback_t allocate_callback, + deallocate_callback_t deallocate_callback, + void* allocate_callback_arg = nullptr, + void* deallocate_callback_arg = nullptr) noexcept + : allocate_callback_(allocate_callback), + deallocate_callback_(deallocate_callback), + allocate_callback_arg_(allocate_callback_arg), + deallocate_callback_arg_(deallocate_callback_arg) + { + } + + callback_memory_resource() = delete; + ~callback_memory_resource() override = default; + callback_memory_resource(callback_memory_resource const&) = delete; + callback_memory_resource& operator=(callback_memory_resource const&) = delete; + callback_memory_resource(callback_memory_resource&&) noexcept = default; + callback_memory_resource& operator=(callback_memory_resource&&) noexcept = default; + + private: + void* do_allocate(std::size_t bytes, cuda_stream_view stream) override + { + return allocate_callback_(bytes, stream, allocate_callback_arg_); + } + + void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override + { + deallocate_callback_(ptr, bytes, stream, deallocate_callback_arg_); + } + + [[nodiscard]] std::pair do_get_mem_info(cuda_stream_view) const override + { + throw std::runtime_error("cannot get free / total memory"); + } + + [[nodiscard]] virtual bool supports_streams() const noexcept { return false; } + [[nodiscard]] virtual bool supports_get_mem_info() const noexcept { return false; } + + allocate_callback_t allocate_callback_; + deallocate_callback_t deallocate_callback_; + void* allocate_callback_arg_; + void* deallocate_callback_arg_; +}; + +} // namespace rmm::mr diff --git a/python/rmm/_lib/memory_resource.pxd b/python/rmm/_lib/memory_resource.pxd index 3a71fd500..92ce1ce54 100644 --- a/python/rmm/_lib/memory_resource.pxd +++ b/python/rmm/_lib/memory_resource.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,11 +21,11 @@ from libcpp.vector cimport vector cdef extern from "rmm/mr/device/device_memory_resource.hpp" \ namespace "rmm::mr" nogil: cdef cppclass device_memory_resource: - pass + void* allocate(size_t bytes) except + + void deallocate(void* ptr, size_t bytes) except + cdef class DeviceMemoryResource: cdef shared_ptr[device_memory_resource] c_obj - cdef device_memory_resource* get_mr(self) cdef class UpstreamResourceAdaptor(DeviceMemoryResource): @@ -57,6 +57,10 @@ cdef class BinningMemoryResource(UpstreamResourceAdaptor): size_t allocation_size, DeviceMemoryResource bin_resource=*) +cdef class CallbackMemoryResource(DeviceMemoryResource): + cdef object _allocate_func + cdef object _deallocate_func + cdef class LoggingResourceAdaptor(UpstreamResourceAdaptor): cdef object _log_file_name cpdef get_file_name(self) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index e02f1a3ae..a110bff97 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ import warnings from collections import defaultdict from cython.operator cimport dereference as deref -from libc.stdint cimport int8_t, int64_t +from libc.stdint cimport int8_t, int64_t, uintptr_t from libcpp cimport bool from libcpp.cast cimport dynamic_cast from libcpp.memory cimport make_shared, make_unique, shared_ptr, unique_ptr @@ -26,6 +26,7 @@ from libcpp.string cimport string from cuda.cudart import cudaError_t from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice +from rmm._lib.cuda_stream_view cimport cuda_stream_view # NOTE: Keep extern declarations in .pyx file as much as possible to avoid @@ -76,6 +77,19 @@ cdef extern from "rmm/mr/device/fixed_size_memory_resource.hpp" \ size_t block_size, size_t block_to_preallocate) except + +cdef extern from "rmm/mr/device/callback_memory_resource.hpp" \ + namespace "rmm::mr" nogil: + ctypedef void* (*allocate_callback_t)(size_t, void*) + ctypedef void (*deallocate_callback_t)(void*, size_t, void*) + + cdef cppclass callback_memory_resource(device_memory_resource): + callback_memory_resource( + allocate_callback_t allocate_callback, + deallocate_callback_t deallocate_callback, + void* allocate_callback_arg, + void* deallocate_callback_arg + ) except + + cdef extern from "rmm/mr/device/binning_memory_resource.hpp" \ namespace "rmm::mr" nogil: cdef cppclass binning_memory_resource[Upstream](device_memory_resource): @@ -168,6 +182,12 @@ cdef class DeviceMemoryResource: cdef device_memory_resource* get_mr(self): return self.c_obj.get() + def allocate(self, size_t nbytes): + return self.c_obj.get().allocate(nbytes) + + def deallocate(self, uintptr_t ptr, size_t nbytes): + self.c_obj.get().deallocate((ptr), nbytes) + cdef class UpstreamResourceAdaptor(DeviceMemoryResource): @@ -444,6 +464,80 @@ cdef class BinningMemoryResource(UpstreamResourceAdaptor): bin_resource.get_mr()) +cdef void* _allocate_callback_wrapper( + size_t nbytes, + cuda_stream_view stream, + void* ctx +) with gil: + return ((ctx)(nbytes)) + +cdef void _deallocate_callback_wrapper( + void* ptr, + size_t nbytes, + cuda_stream_view stream, + void* ctx +) with gil: + (ctx)((ptr), nbytes) + + +cdef class CallbackMemoryResource(DeviceMemoryResource): + """ + A memory resource that uses the user-provided callables to do + memory allocation and deallocation. + + ``CallbackMemoryResource`` should really only be used for + debugging memory issues, as there is a significant performance + penalty associated with using a Python function for each memory + allocation and deallocation. + + Parameters + ---------- + allocate_func: callable + The allocation function must accept a single integer argument, + representing the number of bytes to allocate, and return an + integer representing the pointer to the allocated memory. + deallocate_func: callable + The deallocation function must accept two arguments, an integer + representing the pointer to the memory to free, and a second + integer representing the number of bytes to free. + + Examples + ------- + >>> import rmm + >>> base_mr = rmm.mr.CudaMemoryResource() + >>> def allocate_func(size): + ... print(f"Allocating {size} bytes") + ... return base_mr.allocate(size) + ... + >>> def deallocate_func(ptr, size): + ... print(f"Deallocating {size} bytes") + ... return base_mr.deallocate(ptr, size) + ... + >>> rmm.mr.set_current_device_resource( + rmm.mr.CallbackMemoryResource(allocate_func, deallocate_func) + ) + >>> dbuf = rmm.DeviceBuffer(size=256) + Allocating 256 bytes + >>> del dbuf + Deallocating 256 bytes + """ + def __init__( + self, + allocate_func, + deallocate_func, + ): + self._allocate_func = allocate_func + self._deallocate_func = deallocate_func + self.c_obj.reset( + new callback_memory_resource( + (_allocate_callback_wrapper), + (_deallocate_callback_wrapper), + (allocate_func), + (deallocate_func) + ) + ) + + def _append_id(filename, id): """ Append ".dev" onto a filename before the extension diff --git a/python/rmm/mr.py b/python/rmm/mr.py index eaa9705eb..ea0a0cf8c 100644 --- a/python/rmm/mr.py +++ b/python/rmm/mr.py @@ -13,6 +13,7 @@ # limitations under the License. from rmm._lib.memory_resource import ( BinningMemoryResource, + CallbackMemoryResource, CudaAsyncMemoryResource, CudaMemoryResource, DeviceMemoryResource, @@ -39,6 +40,7 @@ __all__ = [ "BinningMemoryResource", + "CallbackMemoryResource", "CudaAsyncMemoryResource", "CudaMemoryResource", "DeviceMemoryResource", diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index 409ed6b72..fa38ee9fe 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2022, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -719,3 +719,34 @@ def test_dev_buf_circle_ref_dealloc(): # deallocate `dbuf1` (which needs the MR alive), a segfault occurs. gc.collect() + + +def test_mr_allocate_deallocate(): + mr = rmm.mr.TrackingResourceAdaptor(rmm.mr.get_current_device_resource()) + size = 1 << 23 # 8 MiB + ptr = mr.allocate(size) + assert mr.get_allocated_bytes() == 1 << 23 + mr.deallocate(ptr, size) + assert mr.get_allocated_bytes() == 0 + + +def test_custom_mr(capsys): + base_mr = rmm.mr.CudaMemoryResource() + + def allocate_func(size): + print(f"Allocating {size} bytes") + return base_mr.allocate(size) + + def deallocate_func(ptr, size): + print(f"Deallocating {size} bytes") + return base_mr.deallocate(ptr, size) + + rmm.mr.set_current_device_resource( + rmm.mr.CallbackMemoryResource(allocate_func, deallocate_func) + ) + + dbuf = rmm.DeviceBuffer(size=256) + del dbuf + + captured = capsys.readouterr() + assert captured.out == "Allocating 256 bytes\nDeallocating 256 bytes\n" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 344f66db5..8f68141fd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -150,3 +150,6 @@ ConfigureTest(ARENA_MR_TEST mr/device/arena_mr_tests.cpp) # binning MR tests ConfigureTest(BINNING_MR_TEST mr/device/binning_mr_tests.cpp) + +# callback memory resource tests +ConfigureTest(CALLBACK_MR_TEST mr/device/callback_mr_tests.cpp) diff --git a/tests/mock_resource.hpp b/tests/mock_resource.hpp new file mode 100644 index 000000000..0436e2a2a --- /dev/null +++ b/tests/mock_resource.hpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, 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. + */ +#pragma once + +#include + +#include + +namespace rmm::test { + +class mock_resource : public rmm::mr::device_memory_resource { + public: + MOCK_METHOD(bool, supports_streams, (), (const, override, noexcept)); + MOCK_METHOD(bool, supports_get_mem_info, (), (const, override, noexcept)); + MOCK_METHOD(void*, do_allocate, (std::size_t, cuda_stream_view), (override)); + MOCK_METHOD(void, do_deallocate, (void*, std::size_t, cuda_stream_view), (override)); + using size_pair = std::pair; + MOCK_METHOD(size_pair, do_get_mem_info, (cuda_stream_view), (const, override)); +}; + +} // namespace rmm::test diff --git a/tests/mr/device/aligned_mr_tests.cpp b/tests/mr/device/aligned_mr_tests.cpp index f1ed561f4..62b941d6f 100644 --- a/tests/mr/device/aligned_mr_tests.cpp +++ b/tests/mr/device/aligned_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ * limitations under the License. */ +#include "../../mock_resource.hpp" #include #include #include @@ -28,16 +29,6 @@ namespace { using ::testing::Return; -class mock_resource : public rmm::mr::device_memory_resource { - public: - MOCK_METHOD(bool, supports_streams, (), (const, override, noexcept)); - MOCK_METHOD(bool, supports_get_mem_info, (), (const, override, noexcept)); - MOCK_METHOD(void*, do_allocate, (std::size_t, cuda_stream_view), (override)); - MOCK_METHOD(void, do_deallocate, (void*, std::size_t, cuda_stream_view), (override)); - using size_pair = std::pair; - MOCK_METHOD(size_pair, do_get_mem_info, (cuda_stream_view), (const, override)); -}; - using aligned_mock = rmm::mr::aligned_resource_adaptor; using aligned_real = rmm::mr::aligned_resource_adaptor; diff --git a/tests/mr/device/callback_mr_tests.cpp b/tests/mr/device/callback_mr_tests.cpp new file mode 100644 index 000000000..101a75fc8 --- /dev/null +++ b/tests/mr/device/callback_mr_tests.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2022, 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. + */ + +#include "../../byte_literals.hpp" +#include "../../mock_resource.hpp" +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + +namespace rmm::test { +namespace { + +using ::testing::_; + +TEST(CallbackTest, TestCallbacksAreInvoked) +{ + auto base_mr = mock_resource(); + EXPECT_CALL(base_mr, do_allocate(10_MiB, cuda_stream_view{})).Times(1); + EXPECT_CALL(base_mr, do_deallocate(_, 10_MiB, cuda_stream_view{})).Times(1); + + auto allocate_callback = [](std::size_t size, cuda_stream_view stream, void* arg) { + auto base_mr = static_cast(arg); + return base_mr->allocate(size, stream); + }; + auto deallocate_callback = [](void* ptr, std::size_t size, cuda_stream_view stream, void* arg) { + auto base_mr = static_cast(arg); + base_mr->deallocate(ptr, size, stream); + }; + auto mr = + rmm::mr::callback_memory_resource(allocate_callback, deallocate_callback, &base_mr, &base_mr); + auto ptr = mr.allocate(10_MiB); + mr.deallocate(ptr, 10_MiB); +} + +TEST(CallbackTest, LoggingTest) +{ + testing::internal::CaptureStdout(); + + auto base_mr = rmm::mr::get_current_device_resource(); + auto allocate_callback = [](std::size_t size, cuda_stream_view stream, void* arg) { + std::cout << "Allocating " << size << " bytes" << std::endl; + auto base_mr = static_cast(arg); + return base_mr->allocate(size, stream); + }; + + auto deallocate_callback = [](void* ptr, std::size_t size, cuda_stream_view stream, void* arg) { + std::cout << "Deallocating " << size << " bytes" << std::endl; + auto base_mr = static_cast(arg); + base_mr->deallocate(ptr, size, stream); + }; + auto mr = + rmm::mr::callback_memory_resource(allocate_callback, deallocate_callback, base_mr, base_mr); + auto ptr = mr.allocate(10_MiB); + mr.deallocate(ptr, 10_MiB); + + std::string output = testing::internal::GetCapturedStdout(); + std::string expect = fmt::format("Allocating {} bytes\nDeallocating {} bytes\n", 10_MiB, 10_MiB); + ASSERT_EQ(expect, output); +} + +} // namespace +} // namespace rmm::test From ab4b81ae8c490dc838414b1a4a43b097d093a536 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 25 Apr 2022 17:47:04 -0400 Subject: [PATCH 084/675] Update cmake-format version for pre-commit and environments. (#995) Update to cmake-format 0.6.13. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Mark Harris (https://github.com/harrism) - Robert Maynard (https://github.com/robertmaynard) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/995 --- .pre-commit-config.yaml | 4 ++-- conda/environments/rmm_dev_cuda11.5.yml | 2 +- conda/environments/rmm_dev_cuda11.6.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 00189783f..95e63ddb1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,7 +36,7 @@ repos: # Note that pre-commit autoupdate does not update the versions # of dependencies, so we'll have to update this manually. additional_dependencies: - - cmake-format==0.6.11 + - cmakelang==0.6.13 - id: cmake-lint name: cmake-lint entry: ./scripts/run-cmake-format.sh cmake-lint @@ -45,7 +45,7 @@ repos: # Note that pre-commit autoupdate does not update the versions # of dependencies, so we'll have to update this manually. additional_dependencies: - - cmake-format==0.6.11 + - cmakelang==0.6.13 default_language_version: python: python3 diff --git a/conda/environments/rmm_dev_cuda11.5.yml b/conda/environments/rmm_dev_cuda11.5.yml index 7cdaf866e..10cea6321 100644 --- a/conda/environments/rmm_dev_cuda11.5.yml +++ b/conda/environments/rmm_dev_cuda11.5.yml @@ -6,7 +6,7 @@ dependencies: - clang=11.1.0 - clang-tools=11.1.0 - cmake>=3.20.1,!=3.23.0 -- cmake-format=0.6.11 +- cmakelang=0.6.13 - flake8=3.8.3 - black=22.3.0 - isort=5.6.4 diff --git a/conda/environments/rmm_dev_cuda11.6.yml b/conda/environments/rmm_dev_cuda11.6.yml index fec069e83..7681e4580 100644 --- a/conda/environments/rmm_dev_cuda11.6.yml +++ b/conda/environments/rmm_dev_cuda11.6.yml @@ -6,7 +6,7 @@ dependencies: - clang=11.1.0 - clang-tools=11.1.0 - cmake>=3.20.1,!=3.23.0 -- cmake-format=0.6.11 +- cmakelang=0.6.13 - flake8=3.8.3 - black=22.3.0 - isort=5.6.4 From 573351d9d0f79cf80e202ed515a0827678043c96 Mon Sep 17 00:00:00 2001 From: fkallen <37172449+fkallen@users.noreply.github.com> Date: Wed, 27 Apr 2022 01:16:28 +0200 Subject: [PATCH 085/675] Add rmm::exec_policy_nosync (#1009) Add `rmm:exec_policy_nosync`. For Thrust 1.16 and newer, this policy is based on `execute_on_stream_nosync_base` instead of `execute_on_stream_base` to allow Thrust algorithms to skip synchronizations. For older Thrust versions, this is an alias to rmm::exec_policy Authors: - https://github.com/fkallen Approvers: - Rong Ou (https://github.com/rongou) - Mark Harris (https://github.com/harrism) - Jake Hemstad (https://github.com/jrhemstad) - Christopher Harris (https://github.com/cwharris) URL: https://github.com/rapidsai/rmm/pull/1009 --- include/rmm/exec_policy.hpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/include/rmm/exec_policy.hpp b/include/rmm/exec_policy.hpp index 98cd91cd4..fdd22249f 100644 --- a/include/rmm/exec_policy.hpp +++ b/include/rmm/exec_policy.hpp @@ -25,6 +25,7 @@ #include #include +#include namespace rmm { @@ -46,4 +47,33 @@ class exec_policy : public thrust_exec_policy_t { } }; +#if THRUST_VERSION >= 101600 + +using thrust_exec_policy_nosync_t = + thrust::detail::execute_with_allocator, + thrust::cuda_cub::execute_on_stream_nosync_base>; +/** + * @brief Helper class usable as a Thrust CUDA execution policy + * that uses RMM for temporary memory allocation on the specified stream + * and which allows the Thrust backend to skip stream synchronizations that + * are not required for correctness. + */ +class exec_policy_nosync : public thrust_exec_policy_nosync_t { + public: + explicit exec_policy_nosync( + cuda_stream_view stream = cuda_stream_default, + rmm::mr::device_memory_resource* mr = mr::get_current_device_resource()) + : thrust_exec_policy_nosync_t( + thrust::cuda::par_nosync(rmm::mr::thrust_allocator(stream, mr)).on(stream.value())) + { + } +}; + +#else + +using thrust_exec_policy_nosync_t = thrust_exec_policy_t; +using exec_policy_nosync = exec_policy; + +#endif + } // namespace rmm From a2c35e43e0811f6ae0e4ba456da77ca08ad1ad3a Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 4 May 2022 12:20:28 +1000 Subject: [PATCH 086/675] opt-in to IPC handle export type --- include/rmm/detail/dynamic_load_runtime.hpp | 27 +++++++++++++++++++ .../mr/device/cuda_async_memory_resource.hpp | 14 +++++++--- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/include/rmm/detail/dynamic_load_runtime.hpp b/include/rmm/detail/dynamic_load_runtime.hpp index 6e60201c1..5c6ff1f6b 100644 --- a/include/rmm/detail/dynamic_load_runtime.hpp +++ b/include/rmm/detail/dynamic_load_runtime.hpp @@ -14,8 +14,13 @@ * limitations under the License. */ #pragma once + +#include + #include + #include + #include #include @@ -116,6 +121,28 @@ struct async_alloc { return runtime_supports_pool and driver_supports_pool; } + /** + * @brief Check whether the specified `cudaMemAllocationHandleType` is supported on the present + * CUDA driver/runtime version. + * + * @note This query was introduced in CUDA 11.3 so on CUDA 11.2 this will only return true for + * `cudaMemHandleTypeNone`. + * + * @param handle_type An IPC export handle type to check for support. + * @return true if supported + * @return false if unsupported + */ + static bool is_export_handle_type_supported(cudaMemAllocationHandleType handle_type) + { + int supported_handle_types_bitmask{}; +#if CUDART_VERSION >= 11030 // 11.3 introduced cudaDevAttrMemoryPoolSupportedHandleTypes + cudaDeviceGetAttribute(&supported_handle_types_bitmask, + cudaDevAttrMemoryPoolSupportedHandleTypes, + rmm::detail::current_device().value()); +#endif + return (supported_handle_types_bitmask & handle_type) == handle_type; + } + template using cudart_sig = dynamic_load_runtime::function_sig; diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 78e885406..ce5b8ecb0 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -57,10 +57,14 @@ class cuda_async_memory_resource final : public device_memory_resource { * initial pool size is half of the available GPU memory. * @param release_threshold Optional release threshold size in bytes of the pool. If no value is * provided, the release threshold is set to the total amount of memory on the current device. + * @param export_handle_types Optional `cudaMemAllocationHandleType` that allocations from this + * resource should support for interprocess communication (IPC). Default is + * `cudaMemHandleTypeNone` for no IPC support. */ // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) - cuda_async_memory_resource(thrust::optional initial_pool_size = {}, - thrust::optional release_threshold = {}) + cuda_async_memory_resource(thrust::optional initial_pool_size = {}, + thrust::optional release_threshold = {}, + thrust::optional export_handle_type = {}) { #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT // Check if cudaMallocAsync Memory pool supported @@ -69,8 +73,10 @@ class cuda_async_memory_resource final : public device_memory_resource { // Construct explicit pool cudaMemPoolProps pool_props{}; - pool_props.allocType = cudaMemAllocationTypePinned; - pool_props.handleTypes = cudaMemHandleTypePosixFileDescriptor; + pool_props.allocType = cudaMemAllocationTypePinned; + pool_props.handleTypes = export_handle_type.value_or(cudaMemHandleTypeNone); + RMM_EXPECTS(rmm::detail::async_alloc::is_export_handle_type_supported(pool_props.handleTypes), + "Requested IPC memory handle type not supported"); pool_props.location.type = cudaMemLocationTypeDevice; pool_props.location.id = rmm::detail::current_device().value(); cudaMemPool_t cuda_pool_handle{}; From 2d8d46a8068fd2de937cce79a44c1017b5f7c238 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 4 May 2022 03:47:56 -0700 Subject: [PATCH 087/675] Attempt at updating Cython for handle type parameter --- python/rmm/_lib/memory_resource.pyx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index a110bff97..549fa0694 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -24,6 +24,7 @@ from libcpp.memory cimport make_shared, make_unique, shared_ptr, unique_ptr from libcpp.string cimport string from cuda.cudart import cudaError_t +from cuda.cudart import cudaMemAllocationHandleType from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice from rmm._lib.cuda_stream_view cimport cuda_stream_view @@ -57,8 +58,10 @@ cdef extern from "rmm/mr/device/managed_memory_resource.hpp" \ cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ namespace "rmm::mr" nogil: cdef cppclass cuda_async_memory_resource(device_memory_resource): - cuda_async_memory_resource(optional[size_t] initial_pool_size, - optional[size_t] release_threshold) except + + cuda_async_memory_resource( + optional[size_t] initial_pool_size, + optional[size_t] release_threshold, + optional[cudaMemAllocationHandleType] export_handle_type) except + cdef extern from "rmm/mr/device/pool_memory_resource.hpp" \ namespace "rmm::mr" nogil: @@ -234,7 +237,7 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): value, unused memory held by the pool will be released at the next synchronization point. """ - def __cinit__(self, initial_pool_size=None, release_threshold=None): + def __cinit__(self, initial_pool_size=None, release_threshold=None, export_handle_type=None): cdef optional[size_t] c_initial_pool_size = ( optional[size_t]() if initial_pool_size is None @@ -247,10 +250,17 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): else optional[size_t](release_threshold) ) + cdef optional[cudaMemAllocationHandleType] c_export_handle_type = ( + optional[cudaMemAllocationHandleType]() + if export_handle_type is None + else optional[export_handle_type](export_handle_type) + ) + self.c_obj.reset( new cuda_async_memory_resource( c_initial_pool_size, - c_release_threshold + c_release_threshold, + c_export_handle_type ) ) From 9e9101bdc32740a9c7f3bcf146656559d3d05f7b Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 4 May 2022 03:58:14 -0700 Subject: [PATCH 088/675] style --- python/rmm/_lib/memory_resource.pyx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 549fa0694..241cd32a6 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -237,7 +237,12 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): value, unused memory held by the pool will be released at the next synchronization point. """ - def __cinit__(self, initial_pool_size=None, release_threshold=None, export_handle_type=None): + def __cinit__( + self, + initial_pool_size=None, + release_threshold=None, + export_handle_type=None + ): cdef optional[size_t] c_initial_pool_size = ( optional[size_t]() if initial_pool_size is None From e79460843e9fdadd82104b7c02c6f96294138de5 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 4 May 2022 03:59:50 -0700 Subject: [PATCH 089/675] style --- python/rmm/_lib/memory_resource.pyx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 241cd32a6..1232b66c9 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -238,9 +238,9 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): next synchronization point. """ def __cinit__( - self, - initial_pool_size=None, - release_threshold=None, + self, + initial_pool_size=None, + release_threshold=None, export_handle_type=None ): cdef optional[size_t] c_initial_pool_size = ( From 7c06c0b279c9bfd1a13de57048ce96aaf07816e2 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 4 May 2022 15:31:19 -0700 Subject: [PATCH 090/675] More Cython struggles --- python/rmm/_lib/memory_resource.pyx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 1232b66c9..1110d9a55 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -24,9 +24,10 @@ from libcpp.memory cimport make_shared, make_unique, shared_ptr, unique_ptr from libcpp.string cimport string from cuda.cudart import cudaError_t -from cuda.cudart import cudaMemAllocationHandleType +from cuda.ccudart import cudaMemAllocationHandleType from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice + from rmm._lib.cuda_stream_view cimport cuda_stream_view @@ -61,7 +62,7 @@ cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ cuda_async_memory_resource( optional[size_t] initial_pool_size, optional[size_t] release_threshold, - optional[cudaMemAllocationHandleType] export_handle_type) except + + optional[bool] enable_ipc) except + cdef extern from "rmm/mr/device/pool_memory_resource.hpp" \ namespace "rmm::mr" nogil: @@ -241,7 +242,7 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): self, initial_pool_size=None, release_threshold=None, - export_handle_type=None + enable_ipc=True ): cdef optional[size_t] c_initial_pool_size = ( optional[size_t]() @@ -257,8 +258,8 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): cdef optional[cudaMemAllocationHandleType] c_export_handle_type = ( optional[cudaMemAllocationHandleType]() - if export_handle_type is None - else optional[export_handle_type](export_handle_type) + if enable_ipc == True + else optional[cudaMemAllocationHandleType](cudaMemHandleTypePosixFileDescriptor) ) self.c_obj.reset( From 3a1a98d5128c0c2bf799731feb3096bfa20f7803 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 4 May 2022 15:38:16 -0700 Subject: [PATCH 091/675] cimport --- python/rmm/_lib/memory_resource.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 1110d9a55..9e829ea56 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -24,7 +24,7 @@ from libcpp.memory cimport make_shared, make_unique, shared_ptr, unique_ptr from libcpp.string cimport string from cuda.cudart import cudaError_t -from cuda.ccudart import cudaMemAllocationHandleType +from cuda.ccudart cimport cudaMemAllocationHandleType, cudaMemHandleTypePosixFileDescriptor from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice @@ -62,7 +62,7 @@ cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ cuda_async_memory_resource( optional[size_t] initial_pool_size, optional[size_t] release_threshold, - optional[bool] enable_ipc) except + + optional[cudaMemAllocationHandleType] export_handle_type) except + cdef extern from "rmm/mr/device/pool_memory_resource.hpp" \ namespace "rmm::mr" nogil: From 34e3fd8ab028d45b1718cd2a10347d6c09103e54 Mon Sep 17 00:00:00 2001 From: Jordan Jacobelli Date: Mon, 9 May 2022 16:58:10 +0200 Subject: [PATCH 092/675] Build python using conda in GPU jobs (#1017) This PR convert the `from sources` build we are doing in GPU test job to a `conda build`. This is done for the following reasons: - This is required step to improve the Ops CI/CD setup to a more convenient pipeline - This is required to start using `conda` compilers and `mamba` to build RAPIDS packages - This prevent us from manually managing and installing the dependencies in GPU job - This ensure the packages can be installed - This ensure the tests are running and working against the package content and not the build results. Currently the Python packages are not tested. This may increase the global pipeline time, but the usage of `mamba` should resolve this as `mamba` is faster than `conda` to build packages Authors: - Jordan Jacobelli (https://github.com/Ethyling) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1017 --- ci/gpu/build.sh | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index af39aaf75..9176d4b15 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -31,6 +31,7 @@ export CUDA_REL="${CUDA_MAJOR_VER}.${CUDA_MINOR_VER}" export GIT_DESCRIBE_TAG=`git describe --abbrev=0 --tags` export GIT_DESCRIBE_NUMBER=`git rev-list ${GIT_DESCRIBE_TAG}..HEAD --count` export MINOR_VERSION=`echo $GIT_DESCRIBE_TAG | grep -o -E '([0-9]+\.[0-9]+)'` +unset GIT_DESCRIBE_TAG ################################################################################ # SETUP - Check environment @@ -43,15 +44,6 @@ gpuci_logger "Activate conda env" . /opt/conda/etc/profile.d/conda.sh conda activate rapids -# Install build env -gpuci_mamba_retry install -y \ - "cudatoolkit=$CUDA_REL" \ - "rapids-build-env=${MINOR_VERSION}.*" - -# https://docs.rapids.ai/maintainers/depmgmt/ -# conda remove --force rapids-build-env -# gpuci_mamba_retry install "your-pkg=1.0.0" - gpuci_logger "Check versions" python --version $CC --version @@ -63,6 +55,15 @@ conda config --show-sources conda list --show-channel-urls if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then + # Install build env + gpuci_mamba_retry install -y \ + "cudatoolkit=$CUDA_REL" \ + "rapids-build-env=${MINOR_VERSION}.*" + + # https://docs.rapids.ai/maintainers/depmgmt/ + # conda remove --force rapids-build-env + # gpuci_mamba_retry install "your-pkg=1.0.0" + ################################################################################ # BUILD - Build and install librmm and rmm ################################################################################ @@ -90,7 +91,6 @@ if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then py.test --cache-clear --basetemp=${WORKSPACE}/rmm-cuda-tmp --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term fi else - gpuci_mamba_retry install -c $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ librmm librmm-tests TESTRESULTS_DIR=${WORKSPACE}/test-results @@ -111,12 +111,14 @@ else fi done - cd $WORKSPACE/python - export LIBRMM_BUILD_DIR="$WORKSPACE/ci/artifacts/rmm/cpu/conda_work/build" - - gpuci_logger "Building rmm" - "$WORKSPACE/build.sh" -v rmm + export CONDA_BLD_DIR="$WORKSPACE/.conda-bld" + gpuci_logger "Building and installing rmm" + gpuci_conda_retry build --no-build-id --croot ${CONDA_BLD_DIR} \ + -c $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ conda/recipes/rmm + gpuci_mamba_retry install -c $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ \ + -c ${CONDA_BLD_DIR} rmm + cd $WORKSPACE/python gpuci_logger "pytest rmm" py.test --cache-clear --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term exitcode=$? From 3b0f7fc19e562846bc5aeb90a7ca4de42b244b0c Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Tue, 10 May 2022 18:35:12 +0100 Subject: [PATCH 093/675] Replace `to_device` with `DeviceBuffer.to_device` (#1033) As well as in the basic python docs, `to_device` was also explicitly referenced in the README. Follows up #902 which missed this reference. Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - https://github.com/jakirkham URL: https://github.com/rapidsai/rmm/pull/1033 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f71c3394..bc18c2966 100644 --- a/README.md +++ b/README.md @@ -608,7 +608,7 @@ DeviceBuffers can also be created by copying data from host memory: >>> import rmm >>> import numpy as np >>> a = np.array([1, 2, 3], dtype='float64') ->>> buf = rmm.to_device(a.tobytes()) +>>> buf = rmm.DeviceBuffer.to_device(a.tobytes()) >>> buf.size 24 ``` From 4e8bca57a8b7cbc46c05ded1fbb70b57f9042e75 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 10 May 2022 17:39:46 -0700 Subject: [PATCH 094/675] Use new rapids-cython component of rapids-cmake to simplify builds (#1031) The custom CMake code written in python/cmake has now been generalized and ported to rapids-cmake so that it can be shared across rapids libraries. This PR depends on rapidsai/rapids-cmake#184 and tests will not pass until that is merged. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Robert Maynard (https://github.com/robertmaynard) - https://github.com/jakirkham URL: https://github.com/rapidsai/rmm/pull/1031 --- ci/release/update-version.sh | 1 + python/CMakeLists.txt | 37 ++++++++------------- python/cmake/CMakeLists.txt | 16 --------- python/cmake/rmm_python_helpers.cmake | 48 --------------------------- python/cmake/skbuild_patches.cmake | 48 --------------------------- python/rmm/_cuda/CMakeLists.txt | 8 ++--- python/rmm/_lib/CMakeLists.txt | 7 ++-- python/setup.py | 2 +- 8 files changed, 24 insertions(+), 143 deletions(-) delete mode 100644 python/cmake/CMakeLists.txt delete mode 100644 python/cmake/rmm_python_helpers.cmake delete mode 100644 python/cmake/skbuild_patches.cmake diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index fcc52922f..01450d8bf 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -32,6 +32,7 @@ function sed_runner() { sed_runner 's/'" VERSION .*"'/'" VERSION ${NEXT_FULL_TAG}"'/g' CMakeLists.txt sed_runner 's/'"rmm_version .*)"'/'"rmm_version ${NEXT_FULL_TAG})"'/g' python/CMakeLists.txt sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' CMakeLists.txt +sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' python/CMakeLists.txt sed_runner 's/'"PROJECT_NUMBER = .*"'/'"PROJECT_NUMBER = ${NEXT_SHORT_TAG}"'/g' doxygen/Doxyfile diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index cb12813f9..8caafd917 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -16,9 +16,9 @@ cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) set(rmm_version 22.06.00) -set(CYTHON_FLAGS - "--directive binding=True,embedsignature=True,always_allow_keywords=True" - CACHE STRING "The directives for Cython compilation.") +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.06/RAPIDS.cmake + ${CMAKE_BINARY_DIR}/RAPIDS.cmake) +include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) project( rmm-python @@ -27,38 +27,29 @@ project( # language to be enabled here. The test project that is built in scikit-build to verify # various linking options for the python library is hardcoded to build with C, so until # that is fixed we need to keep C. - C - CXX - # TODO: The C++ RMM CMake configuration targets cuda_std_17 features, which prior to - # CMake 3.22 will also pull in the corresponding required languages even if this project - # does not actually require those languages. As a result, we need to include CUDA here. - # We can remove CUDA once we upgrade the minimum required CMake version to 3.22. - CUDA) + C CXX) option(FIND_RMM_CPP "Search for existing RMM C++ installations before defaulting to local files" OFF) -find_package(PythonExtensions REQUIRED) -find_package(Cython REQUIRED) - -# Ignore unused variable warning. -set(ignored_variable "${SKBUILD}") - -# If the user requested it we attempt to find RMM. TODO: Should we allow the user to specify a path -# instead of just searching? This version assumes that the installation has been appropriately -# configured for CMake discovery. +# If the user requested it we attempt to find RMM. if(FIND_RMM_CPP) - find_package(RMM ${rmm_version}) + find_package(rmm ${rmm_version}) else() - set(RMM_FOUND OFF) + set(rmm_FOUND OFF) endif() -if(NOT RMM_FOUND) +if(NOT rmm_FOUND) + # TODO: This will not be necessary once we upgrade to CMake 3.22, which will pull in the required + # languages for the C++ project even if this project does not require those languges. + enable_language(CUDA) set(BUILD_TESTS OFF) set(BUILD_BENCHMARKS OFF) add_subdirectory(../ rmm-cpp) endif() -add_subdirectory(cmake) +include(rapids-cython) +rapids_cython_init() + add_subdirectory(rmm/_cuda) add_subdirectory(rmm/_lib) diff --git a/python/cmake/CMakeLists.txt b/python/cmake/CMakeLists.txt deleted file mode 100644 index 9469891ae..000000000 --- a/python/cmake/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# ============================================================================= -# Copyright (c) 2022, 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. -# ============================================================================= - -include(rmm_python_helpers.cmake) -include(skbuild_patches.cmake) diff --git a/python/cmake/rmm_python_helpers.cmake b/python/cmake/rmm_python_helpers.cmake deleted file mode 100644 index 91f0a5a17..000000000 --- a/python/cmake/rmm_python_helpers.cmake +++ /dev/null @@ -1,48 +0,0 @@ -# ============================================================================= -# Copyright (c) 2022, 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. -# ============================================================================= - -#[=======================================================================[.rst: -add_cython_modules ------------------- - -Generate C(++) from Cython and create Python modules. - -.. code-block:: cmake - - add_cython_modules() - -Creates a Cython target for a module, then adds a corresponding Python -extension module. - -``ModuleName`` - The list of modules to build. - -#]=======================================================================] -function(add_cython_modules cython_modules) - foreach(cython_module ${cython_modules}) - add_cython_target(${cython_module} CXX PY3) - add_library(${cython_module} MODULE ${cython_module}) - python_extension_module(${cython_module}) - - # To avoid libraries being prefixed with "lib". - set_target_properties(${cython_module} PROPERTIES PREFIX "") - target_link_libraries(${cython_module} rmm::rmm) - - # Compute the install directory relative to the source and rely on installs being relative to - # the CMAKE_PREFIX_PATH for e.g. editable installs. - cmake_path(RELATIVE_PATH CMAKE_CURRENT_SOURCE_DIR BASE_DIRECTORY ${rmm-python_SOURCE_DIR} - OUTPUT_VARIABLE install_dst) - install(TARGETS ${cython_module} DESTINATION ${install_dst}) - endforeach(cython_module ${cython_sources}) -endfunction() diff --git a/python/cmake/skbuild_patches.cmake b/python/cmake/skbuild_patches.cmake deleted file mode 100644 index 6302e9e2f..000000000 --- a/python/cmake/skbuild_patches.cmake +++ /dev/null @@ -1,48 +0,0 @@ -# ============================================================================= -# Copyright (c) 2022, 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. -# ============================================================================= - -#[=======================================================================[.rst: -_set_python_extension_symbol_visibility ---------------------------------------- - -The original version of this function in scikit-build runs a linker script to -modify the visibility of symbols. This version is a patch to avoid overwriting -the visibility of symbols because RMM specifically overrides some symbol -visibility in order to share certain functional-local static variables. - -#]=======================================================================] -# TODO: Should we guard this based on a scikit-build version? Override this function to avoid -# scikit-build clobbering symbol visibility. -function(_set_python_extension_symbol_visibility _target) - if(PYTHON_VERSION_MAJOR VERSION_GREATER 2) - set(_modinit_prefix "PyInit_") - else() - set(_modinit_prefix "init") - endif() - message("_modinit_prefix:${_modinit_prefix}") - if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") - set_target_properties(${_target} PROPERTIES LINK_FLAGS "/EXPORT:${_modinit_prefix}${_target}") - elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(_script_path ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_target}-version-script.map) - file( - WRITE ${_script_path} - # Note: The change is to this script, which does not indiscriminately mark all non PyInit - # symbols as local. - "{global: ${_modinit_prefix}${_target}; };") - set_property( - TARGET ${_target} - APPEND_STRING - PROPERTY LINK_FLAGS " -Wl,--version-script=\"${_script_path}\"") - endif() -endfunction() diff --git a/python/rmm/_cuda/CMakeLists.txt b/python/rmm/_cuda/CMakeLists.txt index 16489dde5..1f17b0d2c 100644 --- a/python/rmm/_cuda/CMakeLists.txt +++ b/python/rmm/_cuda/CMakeLists.txt @@ -12,8 +12,8 @@ # the License. # ============================================================================= -# Set the list of Cython files to build -set(cython_modules stream) +set(cython_sources stream.pyx) +set(linked_libraries rmm::rmm) -# Build all of the Cython targets -add_cython_modules("${cython_modules}") +rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}" + CXX) diff --git a/python/rmm/_lib/CMakeLists.txt b/python/rmm/_lib/CMakeLists.txt index 954af9331..44f4513b2 100644 --- a/python/rmm/_lib/CMakeLists.txt +++ b/python/rmm/_lib/CMakeLists.txt @@ -12,8 +12,9 @@ # the License. # ============================================================================= -# Set the list of Cython files to build -set(cython_modules device_buffer lib memory_resource cuda_stream) +set(cython_sources device_buffer.pyx lib.pyx memory_resource.pyx cuda_stream.pyx) +set(linked_libraries rmm::rmm) # Build all of the Cython targets -add_cython_modules("${cython_modules}") +rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}" + CXX) diff --git a/python/setup.py b/python/setup.py index 106a22f90..7cbc92638 100644 --- a/python/setup.py +++ b/python/setup.py @@ -34,6 +34,6 @@ ) }, cmdclass=versioneer.get_cmdclass(), - install_requires=["numba", "cython", "cuda-python"], + install_requires=["numba", "cuda-python"], zip_safe=False, ) From 6974ab1db087987183f6bfd81aaf172437f1fbf8 Mon Sep 17 00:00:00 2001 From: Ashwin Srinath Date: Wed, 11 May 2022 16:44:45 -0400 Subject: [PATCH 095/675] Use our own declaration for cudaMemAllocationHandleType --- python/rmm/_lib/memory_resource.pyx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 9e829ea56..2fb051590 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -24,13 +24,21 @@ from libcpp.memory cimport make_shared, make_unique, shared_ptr, unique_ptr from libcpp.string cimport string from cuda.cudart import cudaError_t -from cuda.ccudart cimport cudaMemAllocationHandleType, cudaMemHandleTypePosixFileDescriptor from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice from rmm._lib.cuda_stream_view cimport cuda_stream_view +# NOTE: We can't use declarations of CUDA types from CUDA Python and +# expect them to work with external code. So we declare them +# ourselves. See https://github.com/NVIDIA/cuda-python/issues/22 for +# details. +cdef extern from "driver_types.h" nogil: + enum cudaMemAllocationHandleType: + cudaMemHandleTypePosixFileDescriptor + + # NOTE: Keep extern declarations in .pyx file as much as possible to avoid # leaking dependencies when importing RMM Cython .pxd files cdef extern from "thrust/optional.h" namespace "thrust" nogil: @@ -258,8 +266,10 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): cdef optional[cudaMemAllocationHandleType] c_export_handle_type = ( optional[cudaMemAllocationHandleType]() - if enable_ipc == True - else optional[cudaMemAllocationHandleType](cudaMemHandleTypePosixFileDescriptor) + if enable_ipc + else optional[cudaMemAllocationHandleType]( + cudaMemHandleTypePosixFileDescriptor + ) ) self.c_obj.reset( From d55c2989abd27965070c3fefac4093c24cc32b8c Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 11 May 2022 16:44:21 -0700 Subject: [PATCH 096/675] Fix inverted logic and add parameter docs. --- python/rmm/_lib/memory_resource.pyx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 2fb051590..e76cc8c30 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -245,6 +245,9 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): Release threshold in bytes. If the pool size grows beyond this value, unused memory held by the pool will be released at the next synchronization point. + enable_ipc: Boolean, optional + If true, enables export of Posix file descriptor handle for the memory + allocated by this resource so that it can be used with CUDA IPC. """ def __cinit__( self, @@ -265,11 +268,9 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): ) cdef optional[cudaMemAllocationHandleType] c_export_handle_type = ( - optional[cudaMemAllocationHandleType]() + optional[cudaMemHandleTypePosixFileDescriptor]() if enable_ipc - else optional[cudaMemAllocationHandleType]( - cudaMemHandleTypePosixFileDescriptor - ) + else optional[cudaMemAllocationHandleType]() ) self.c_obj.reset( From 040a09d4ddf190c7d989e998c9a35049770df5e5 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 11 May 2022 19:01:40 -0700 Subject: [PATCH 097/675] Fix optional syntax --- python/rmm/_lib/memory_resource.pyx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index e76cc8c30..a113f2b78 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -268,7 +268,9 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): ) cdef optional[cudaMemAllocationHandleType] c_export_handle_type = ( - optional[cudaMemHandleTypePosixFileDescriptor]() + optional[cudaMemAllocationHandleType]( + cudaMemHandleTypePosixFileDescriptor + ) if enable_ipc else optional[cudaMemAllocationHandleType]() ) From 6986e677fa62df12df4ad6bbc3fc61b2900ff334 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 11 May 2022 22:29:32 -0700 Subject: [PATCH 098/675] Fix pre-CUDA 11.2 build. --- include/rmm/mr/device/cuda_async_memory_resource.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index ce5b8ecb0..37366005b 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -44,6 +44,7 @@ namespace rmm::mr { */ class cuda_async_memory_resource final : public device_memory_resource { public: +#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT /** * @brief Constructs a cuda_async_memory_resource with the optionally specified initial pool size * and release threshold. @@ -57,7 +58,7 @@ class cuda_async_memory_resource final : public device_memory_resource { * initial pool size is half of the available GPU memory. * @param release_threshold Optional release threshold size in bytes of the pool. If no value is * provided, the release threshold is set to the total amount of memory on the current device. - * @param export_handle_types Optional `cudaMemAllocationHandleType` that allocations from this + * @param export_handle_type Optional `cudaMemAllocationHandleType` that allocations from this * resource should support for interprocess communication (IPC). Default is * `cudaMemHandleTypeNone` for no IPC support. */ @@ -66,7 +67,6 @@ class cuda_async_memory_resource final : public device_memory_resource { thrust::optional release_threshold = {}, thrust::optional export_handle_type = {}) { -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT // Check if cudaMallocAsync Memory pool supported RMM_EXPECTS(rmm::detail::async_alloc::is_supported(), "cudaMallocAsync not supported with this CUDA driver/runtime version"); @@ -107,12 +107,16 @@ class cuda_async_memory_resource final : public device_memory_resource { auto const pool_size = initial_pool_size.value_or(free / 2); auto* ptr = do_allocate(pool_size, cuda_stream_default); do_deallocate(ptr, pool_size, cuda_stream_default); - + } #else + // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) + cuda_async_memory_resource(thrust::optional initial_pool_size = {}, + thrust::optional release_threshold = {}) + { RMM_FAIL( "cudaMallocAsync not supported by the version of the CUDA Toolkit used for this build"); -#endif } +#endif #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT /** From f99eba066cccdb49037700b65abbf967c28b3ad6 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 11 May 2022 22:32:45 -0700 Subject: [PATCH 099/675] Default enable_ipc to False --- python/rmm/_lib/memory_resource.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index a113f2b78..218964944 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -246,14 +246,14 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): value, unused memory held by the pool will be released at the next synchronization point. enable_ipc: Boolean, optional - If true, enables export of Posix file descriptor handle for the memory + If True, enables export of Posix file descriptor handle for the memory allocated by this resource so that it can be used with CUDA IPC. """ def __cinit__( self, initial_pool_size=None, release_threshold=None, - enable_ipc=True + enable_ipc=False ): cdef optional[size_t] c_initial_pool_size = ( optional[size_t]() From 37e5639e3286df0e1e35f17dab18b7f4c7c98607 Mon Sep 17 00:00:00 2001 From: Ashwin Srinath Date: Thu, 12 May 2022 11:21:56 -0400 Subject: [PATCH 100/675] Try something hacky... --- python/rmm/_lib/memory_resource.pyx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 218964944..5dda43742 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -34,7 +34,18 @@ from rmm._lib.cuda_stream_view cimport cuda_stream_view # expect them to work with external code. So we declare them # ourselves. See https://github.com/NVIDIA/cuda-python/issues/22 for # details. -cdef extern from "driver_types.h" nogil: +cdef extern from * nogil: + """ + #include + + #if (CUDART_VERSION < 11030) + enum cudaMemAllocationHandleType { + cudaMemHandleTypePosixFileDescriptor = 0 + }; + #endif + """ + int CUDART_VERSION + enum cudaMemAllocationHandleType: cudaMemHandleTypePosixFileDescriptor From 94d95beb7d440c096f9f3df75214535390c30870 Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Mon, 16 May 2022 21:36:09 -0500 Subject: [PATCH 101/675] Clarify using RMM with other Python libraries (#1034) Based on an internal question, clarified the README docs on what the APIs for enabling cuPy/Numba to use RMM simply inherit whatever the state of RMM is as opposed to modify the state (like enabling a memory pool). Authors: - Jake Hemstad (https://github.com/jrhemstad) - Ashwin Srinath (https://github.com/shwina) Approvers: - Bradley Dice (https://github.com/bdice) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1034 --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index bc18c2966..ddb393f53 100644 --- a/README.md +++ b/README.md @@ -684,6 +684,11 @@ allocations by setting the CuPy CUDA allocator to >>> cupy.cuda.set_allocator(rmm.rmm_cupy_allocator) ``` + +**Note:** This only configures CuPy to use the current RMM resource for allocations. +It does not initialize nor change the current resource, e.g., enabling a memory pool. +See [here](#memoryresource-objects) for more information on changing the current memory resource. + ### Using RMM with Numba You can configure Numba to use RMM for memory allocations using the @@ -704,3 +709,7 @@ This can be done in two ways: >>> import rmm >>> cuda.set_memory_manager(rmm.RMMNumbaManager) ``` + +**Note:** This only configures Numba to use the current RMM resource for allocations. +It does not initialize nor change the current resource, e.g., enabling a memory pool. +See [here](#memoryresource-objects) for more information on changing the current memory resource. From 5e5633b3622a3db01928bf92ad2a542bc1a8e9aa Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Mon, 16 May 2022 19:43:51 -0700 Subject: [PATCH 102/675] Add our own allocation_handle_type enum so we don't leak a CUDA version dependency. Cython is not working -- not sure how to do it. --- .../mr/device/cuda_async_memory_resource.hpp | 25 ++++++++++++++----- python/rmm/_lib/memory_resource.pyx | 16 ++++++++---- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 37366005b..d008743e8 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -44,6 +44,17 @@ namespace rmm::mr { */ class cuda_async_memory_resource final : public device_memory_resource { public: + /** + * Flags for specifying particular handle types + */ + enum class allocation_handle_type { + none = 0x0, /**< Does not allow any export mechanism. > */ + posix_file_descriptor = 0x1, /**< Allows a file descriptor to be used for exporting. Permitted + only on POSIX systems. (int) */ + win32 = 0x2, /**< Allows a Win32 NT handle to be used for exporting. (HANDLE) */ + win32_kmt = 0x4 /**< Allows a Win32 KMT handle to be used for exporting. (D3DKMT_HANDLE) */ + }; + #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT /** * @brief Constructs a cuda_async_memory_resource with the optionally specified initial pool size @@ -63,9 +74,9 @@ class cuda_async_memory_resource final : public device_memory_resource { * `cudaMemHandleTypeNone` for no IPC support. */ // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) - cuda_async_memory_resource(thrust::optional initial_pool_size = {}, - thrust::optional release_threshold = {}, - thrust::optional export_handle_type = {}) + cuda_async_memory_resource(thrust::optional initial_pool_size = {}, + thrust::optional release_threshold = {}, + thrust::optional export_handle_type = {}) { // Check if cudaMallocAsync Memory pool supported RMM_EXPECTS(rmm::detail::async_alloc::is_supported(), @@ -74,7 +85,8 @@ class cuda_async_memory_resource final : public device_memory_resource { // Construct explicit pool cudaMemPoolProps pool_props{}; pool_props.allocType = cudaMemAllocationTypePinned; - pool_props.handleTypes = export_handle_type.value_or(cudaMemHandleTypeNone); + pool_props.handleTypes = static_cast( + export_handle_type.value_or(allocation_handle_type::none)); RMM_EXPECTS(rmm::detail::async_alloc::is_export_handle_type_supported(pool_props.handleTypes), "Requested IPC memory handle type not supported"); pool_props.location.type = cudaMemLocationTypeDevice; @@ -110,8 +122,9 @@ class cuda_async_memory_resource final : public device_memory_resource { } #else // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) - cuda_async_memory_resource(thrust::optional initial_pool_size = {}, - thrust::optional release_threshold = {}) + cuda_async_memory_resource(thrust::optional initial_pool_size = {}, + thrust::optional release_threshold = {}, + thrust::optional export_handle_type = {}) { RMM_FAIL( "cudaMallocAsync not supported by the version of the CUDA Toolkit used for this build"); diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 218964944..9424b89e5 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -67,10 +67,16 @@ cdef extern from "rmm/mr/device/managed_memory_resource.hpp" \ cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ namespace "rmm::mr" nogil: cdef cppclass cuda_async_memory_resource(device_memory_resource): + enum allocation_handle_type: + none, + posix_file_descriptor, + win32, + win32_kmt + cuda_async_memory_resource( optional[size_t] initial_pool_size, optional[size_t] release_threshold, - optional[cudaMemAllocationHandleType] export_handle_type) except + + optional[allocation_handle_type] export_handle_type) except + cdef extern from "rmm/mr/device/pool_memory_resource.hpp" \ namespace "rmm::mr" nogil: @@ -267,12 +273,12 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): else optional[size_t](release_threshold) ) - cdef optional[cudaMemAllocationHandleType] c_export_handle_type = ( - optional[cudaMemAllocationHandleType]( - cudaMemHandleTypePosixFileDescriptor + cdef optional[allocation_handle_type] c_export_handle_type = ( + optional[allocation_handle_type]( + posix_file_descriptor ) if enable_ipc - else optional[cudaMemAllocationHandleType]() + else optional[allocation_handle_type]() ) self.c_obj.reset( From 77ba4e37fba8354f297fe89c84e7b8a5e9305329 Mon Sep 17 00:00:00 2001 From: Ashwin Srinath Date: Tue, 17 May 2022 09:21:04 -0400 Subject: [PATCH 103/675] Move allocation_handle_type declaration under different namespace --- python/rmm/_lib/memory_resource.pyx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index acb4a5dce..6df0f83e1 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -77,18 +77,24 @@ cdef extern from "rmm/mr/device/managed_memory_resource.hpp" \ cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ namespace "rmm::mr" nogil: - cdef cppclass cuda_async_memory_resource(device_memory_resource): - enum allocation_handle_type: - none, - posix_file_descriptor, - win32, - win32_kmt + cdef cppclass cuda_async_memory_resource(device_memory_resource): cuda_async_memory_resource( optional[size_t] initial_pool_size, optional[size_t] release_threshold, optional[allocation_handle_type] export_handle_type) except + +cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ + namespace \ + "rmm::mr::cuda_async_memory_resource::allocation_handle_type" \ + nogil: + enum allocation_handle_type \ + "rmm::mr::cuda_async_memory_resource::allocation_handle_type": + none + posix_file_descriptor + win32 + win32_kmt + cdef extern from "rmm/mr/device/pool_memory_resource.hpp" \ namespace "rmm::mr" nogil: cdef cppclass pool_memory_resource[Upstream](device_memory_resource): From 008b8f169dd18833380f68c12b753cb7badd4f84 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Tue, 17 May 2022 21:35:33 -0700 Subject: [PATCH 104/675] Remove unused Cython duplicate cudaMemAllocationHandleType --- python/rmm/_lib/memory_resource.pyx | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 6df0f83e1..0599f7b8e 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -30,26 +30,6 @@ from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice from rmm._lib.cuda_stream_view cimport cuda_stream_view -# NOTE: We can't use declarations of CUDA types from CUDA Python and -# expect them to work with external code. So we declare them -# ourselves. See https://github.com/NVIDIA/cuda-python/issues/22 for -# details. -cdef extern from * nogil: - """ - #include - - #if (CUDART_VERSION < 11030) - enum cudaMemAllocationHandleType { - cudaMemHandleTypePosixFileDescriptor = 0 - }; - #endif - """ - int CUDART_VERSION - - enum cudaMemAllocationHandleType: - cudaMemHandleTypePosixFileDescriptor - - # NOTE: Keep extern declarations in .pyx file as much as possible to avoid # leaking dependencies when importing RMM Cython .pxd files cdef extern from "thrust/optional.h" namespace "thrust" nogil: @@ -84,6 +64,7 @@ cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ optional[size_t] release_threshold, optional[allocation_handle_type] export_handle_type) except + +# TODO: when we adopt Cython 3.0 use enum class cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ namespace \ "rmm::mr::cuda_async_memory_resource::allocation_handle_type" \ From 617a84edeb8f04e2ad764b4782fd83dbc1421512 Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Thu, 19 May 2022 11:03:30 -0400 Subject: [PATCH 105/675] DOC --- CHANGELOG.md | 4 ++++ CMakeLists.txt | 4 ++-- doxygen/Doxyfile | 2 +- python/CMakeLists.txt | 4 ++-- python/docs/conf.py | 6 +++--- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f291791ec..6e545df69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# RMM 22.08.00 (Date TBD) + +Please see https://github.com/rapidsai/rmm/releases/tag/v22.08.00a for the latest changes to this development branch. + # RMM 22.06.00 (Date TBD) Please see https://github.com/rapidsai/rmm/releases/tag/v22.06.00a for the latest changes to this development branch. diff --git a/CMakeLists.txt b/CMakeLists.txt index 890d89319..23cde1de6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.06/RAPIDS.cmake +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.08/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) @@ -25,7 +25,7 @@ include(rapids-find) project( RMM - VERSION 22.06.00 + VERSION 22.08.00 LANGUAGES CXX) # Write the version header diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index d252e6d69..7f7a53ab9 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "RMM" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 22.06 +PROJECT_NUMBER = 22.08 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 8caafd917..3be640f45 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -14,9 +14,9 @@ cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) -set(rmm_version 22.06.00) +set(rmm_version 22.08.00) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.06/RAPIDS.cmake +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.08/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) diff --git a/python/docs/conf.py b/python/docs/conf.py index 186edaa5a..d0fd76924 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -19,7 +19,7 @@ author = "NVIDIA" # The full version, including alpha/beta/rc tags -release = "22.06.00" +release = "22.08.00" # -- General configuration --------------------------------------------------- @@ -69,9 +69,9 @@ # built documents. # # The short X.Y version. -version = "22.06" +version = "22.08" # The full version, including alpha/beta/rc tags. -release = "22.06.00" +release = "22.08.00" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. From b215d47fdd4d469c5ac965dcb8af28d9445e173f Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Thu, 19 May 2022 17:31:09 -0700 Subject: [PATCH 106/675] better inline doxy style and move ifdef inside ctor --- .../mr/device/cuda_async_memory_resource.hpp | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index d008743e8..db5336d54 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -48,14 +48,13 @@ class cuda_async_memory_resource final : public device_memory_resource { * Flags for specifying particular handle types */ enum class allocation_handle_type { - none = 0x0, /**< Does not allow any export mechanism. > */ - posix_file_descriptor = 0x1, /**< Allows a file descriptor to be used for exporting. Permitted - only on POSIX systems. (int) */ - win32 = 0x2, /**< Allows a Win32 NT handle to be used for exporting. (HANDLE) */ - win32_kmt = 0x4 /**< Allows a Win32 KMT handle to be used for exporting. (D3DKMT_HANDLE) */ + none = 0x0, ///< Does not allow any export mechanism. + posix_file_descriptor = 0x1, ///< Allows a file descriptor to be used for exporting. Permitted + ///< only on POSIX systems. + win32 = 0x2, ///< Allows a Win32 NT handle to be used for exporting. (HANDLE) + win32_kmt = 0x4 ///< Allows a Win32 KMT handle to be used for exporting. (D3DKMT_HANDLE) }; -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT /** * @brief Constructs a cuda_async_memory_resource with the optionally specified initial pool size * and release threshold. @@ -78,6 +77,7 @@ class cuda_async_memory_resource final : public device_memory_resource { thrust::optional release_threshold = {}, thrust::optional export_handle_type = {}) { +#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT // Check if cudaMallocAsync Memory pool supported RMM_EXPECTS(rmm::detail::async_alloc::is_supported(), "cudaMallocAsync not supported with this CUDA driver/runtime version"); @@ -119,17 +119,11 @@ class cuda_async_memory_resource final : public device_memory_resource { auto const pool_size = initial_pool_size.value_or(free / 2); auto* ptr = do_allocate(pool_size, cuda_stream_default); do_deallocate(ptr, pool_size, cuda_stream_default); - } #else - // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) - cuda_async_memory_resource(thrust::optional initial_pool_size = {}, - thrust::optional release_threshold = {}, - thrust::optional export_handle_type = {}) - { RMM_FAIL( "cudaMallocAsync not supported by the version of the CUDA Toolkit used for this build"); - } #endif + } #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT /** From 67baac830f683b4b30d6c1aad893f38c3697f67c Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Fri, 20 May 2022 10:33:55 +1000 Subject: [PATCH 107/675] Apply suggestions from code review Co-authored-by: Bradley Dice --- python/rmm/_lib/memory_resource.pyx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 0599f7b8e..8c87acb71 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -249,15 +249,15 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): Release threshold in bytes. If the pool size grows beyond this value, unused memory held by the pool will be released at the next synchronization point. - enable_ipc: Boolean, optional - If True, enables export of Posix file descriptor handle for the memory + enable_ipc: bool, optional + If True, enables export of POSIX file descriptor handles for the memory allocated by this resource so that it can be used with CUDA IPC. """ def __cinit__( - self, - initial_pool_size=None, - release_threshold=None, - enable_ipc=False + self, + initial_pool_size=None, + release_threshold=None, + enable_ipc=False ): cdef optional[size_t] c_initial_pool_size = ( optional[size_t]() From 2598b1941d5876475af5319e77e447ead224586a Mon Sep 17 00:00:00 2001 From: jakirkham Date: Thu, 19 May 2022 17:49:28 -0700 Subject: [PATCH 108/675] Clarifies Python requirements and version constraints (#1037) Fixes https://github.com/rapidsai/rmm/issues/945 Python requirements were a bit fuzzy or inconsistent in places. This straightens them out and applies the same constraint in various places. Authors: - https://github.com/jakirkham Approvers: - Bradley Dice (https://github.com/bdice) - AJ Schmidt (https://github.com/ajschmidt8) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1037 --- conda/environments/rmm_dev_cuda11.5.yml | 2 +- conda/environments/rmm_dev_cuda11.6.yml | 2 +- conda/recipes/rmm/meta.yaml | 2 +- python/setup.cfg | 3 ++- python/setup.py | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/conda/environments/rmm_dev_cuda11.5.yml b/conda/environments/rmm_dev_cuda11.5.yml index 10cea6321..fc9167500 100644 --- a/conda/environments/rmm_dev_cuda11.5.yml +++ b/conda/environments/rmm_dev_cuda11.5.yml @@ -12,7 +12,7 @@ dependencies: - isort=5.6.4 - python>=3.8,<3.10 - numba>=0.49 -- numpy +- numpy>=1.19 - cffi>=1.10.0 - pytest - cudatoolkit=11.5 diff --git a/conda/environments/rmm_dev_cuda11.6.yml b/conda/environments/rmm_dev_cuda11.6.yml index 7681e4580..3fa2fbb6e 100644 --- a/conda/environments/rmm_dev_cuda11.6.yml +++ b/conda/environments/rmm_dev_cuda11.6.yml @@ -12,7 +12,7 @@ dependencies: - isort=5.6.4 - python>=3.8,<3.10 - numba>=0.49 -- numpy +- numpy>=1.19 - cffi>=1.10.0 - pytest - cudatoolkit=11.6 diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 5d5a7b224..0c89749af 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -36,7 +36,7 @@ requirements: run: - python - numba >=0.49 - - numpy + - numpy >=1.19 - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} - cuda-python >=11.5,<12.0 diff --git a/python/setup.cfg b/python/setup.cfg index df5c37624..de2d6a679 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -52,6 +52,7 @@ skip= [options] packages = find: install_requires = - numpy + cuda-python>=11.5,<12.0 + numpy>=1.19 numba>=0.49 python_requires = >=3.8 diff --git a/python/setup.py b/python/setup.py index 7cbc92638..24ac9c7ee 100644 --- a/python/setup.py +++ b/python/setup.py @@ -34,6 +34,6 @@ ) }, cmdclass=versioneer.get_cmdclass(), - install_requires=["numba", "cuda-python"], + install_requires=["cuda-python>=11.5,<12.0", "numpy>=1.19", "numba>=0.49"], zip_safe=False, ) From 51e4afeb7f3772a5c27731adc11bc78838902850 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Fri, 20 May 2022 10:52:28 -0400 Subject: [PATCH 109/675] enable external_contributors feature for ops-bot --- .github/ops-bot.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ops-bot.yaml b/.github/ops-bot.yaml index 0a52b6795..408e28843 100644 --- a/.github/ops-bot.yaml +++ b/.github/ops-bot.yaml @@ -5,4 +5,4 @@ auto_merger: true branch_checker: true label_checker: true release_drafter: true -external_contributors: false +external_contributors: true From 28e98dd06fe9352eb8a2517c45c658f7e8657991 Mon Sep 17 00:00:00 2001 From: Jordan Jacobelli Date: Fri, 20 May 2022 21:40:31 +0200 Subject: [PATCH 110/675] Use conda compilers (#977) This PR enables the usage of conda compilers to build conda packages. This is required to use `mambabuild` Authors: - Jordan Jacobelli (https://github.com/Ethyling) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/977 --- conda/recipes/librmm/conda_build_config.yaml | 12 ++++++++++ conda/recipes/librmm/meta.yaml | 14 +++++++++--- conda/recipes/rmm/conda_build_config.yaml | 11 +++++++++ conda/recipes/rmm/meta.yaml | 24 +++++++++++--------- 4 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 conda/recipes/rmm/conda_build_config.yaml diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index bc011740d..d84ffd1b3 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -1,5 +1,17 @@ +c_compiler_version: + - 9 + +cxx_compiler_version: + - 9 + +cuda_compiler: + - nvcc + cmake_version: - ">=3.20.1,!=3.23.0" gtest_version: - "=1.10.0" + +sysroot_version: + - "2.17" diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index f70ac8744..120800559 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -14,14 +14,16 @@ source: requirements: build: - cmake {{ cmake_version }} + - {{ compiler('c') }} + - {{ compiler('cxx') }} + - {{ compiler('cuda') }} {{ cuda_version }} + - sysroot_linux-64 {{ sysroot_version }} # [linux64] + - sysroot_linux-aarch64 {{ sysroot_version }} # [aarch64] host: - cudatoolkit {{ cuda_version }}.* build: script_env: - - CC - - CXX - - CUDAHOSTCXX - PARALLEL_LEVEL - CMAKE_GENERATOR - CMAKE_C_COMPILER_LAUNCHER @@ -42,6 +44,9 @@ outputs: string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} run_exports: - {{ pin_subpackage("librmm", max_pin="x.x") }} + ignore_run_exports_from: + - nvcc_linux-64 # [linux64] + - nvcc_linux-aarch64 # [aarch64] requirements: build: - cmake {{ cmake_version }} @@ -92,6 +97,9 @@ outputs: build: number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + ignore_run_exports_from: + - nvcc_linux-64 # [linux64] + - nvcc_linux-aarch64 # [aarch64] requirements: build: - cmake {{ cmake_version }} diff --git a/conda/recipes/rmm/conda_build_config.yaml b/conda/recipes/rmm/conda_build_config.yaml new file mode 100644 index 000000000..322fe6faa --- /dev/null +++ b/conda/recipes/rmm/conda_build_config.yaml @@ -0,0 +1,11 @@ +c_compiler_version: + - 9 + +cxx_compiler_version: + - 9 + +cuda_compiler: + - nvcc + +sysroot_version: + - "2.17" diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 0c89749af..777131fcb 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -18,27 +18,29 @@ build: script_env: - RMM_BUILD_NO_GPU_TEST - VERSION_SUFFIX - - CC - - CXX - - CUDAHOSTCXX requirements: + build: + - cmake>=3.20.1,!=3.23.0 + - {{ compiler('c') }} + - {{ compiler('cxx') }} + - {{ compiler('cuda') }} {{ cuda_version }} + - sysroot_linux-64 {{ sysroot_version }} # [linux64] + - sysroot_linux-aarch64 {{ sysroot_version }} # [aarch64] host: + - cuda-python >=11.5,<12.0 + - cudatoolkit {{ cuda_version }}.* + - cython >=0.29,<0.30 + - librmm {{ version }}.* - python - - librmm {{ version }} - - setuptools - - cython>=0.29,<0.30 - - cmake>=3.20.1,!=3.23.0 - scikit-build>=0.13.1 + - setuptools - spdlog>=1.8.5,<2.0.0a0 - - cudatoolkit {{ cuda_version }}.* - - cuda-python >=11.5,<12.0 run: - - python + - cuda-python >=11.5,<12.0 - numba >=0.49 - numpy >=1.19 - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} - - cuda-python >=11.5,<12.0 test: imports: From 2519b308f10932f5eee9a51e819d0e7415fc75d9 Mon Sep 17 00:00:00 2001 From: Jordan Jacobelli Date: Mon, 23 May 2022 15:51:06 +0200 Subject: [PATCH 111/675] Fix conda recipes for conda compilers (#1043) - Simplify recipes using `{{ target_platform }}` for `sysroot` package and `compiler()` function in `ignore_run_exports_from` - Add missisng `ignore_run_exports_from` to `rmm` Authors: - Jordan Jacobelli (https://github.com/Ethyling) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1043 --- conda/recipes/librmm/meta.yaml | 9 +++------ conda/recipes/rmm/meta.yaml | 5 +++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 120800559..de0d55933 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -17,8 +17,7 @@ requirements: - {{ compiler('c') }} - {{ compiler('cxx') }} - {{ compiler('cuda') }} {{ cuda_version }} - - sysroot_linux-64 {{ sysroot_version }} # [linux64] - - sysroot_linux-aarch64 {{ sysroot_version }} # [aarch64] + - sysroot_{{ target_platform }} {{ sysroot_version }} host: - cudatoolkit {{ cuda_version }}.* @@ -45,8 +44,7 @@ outputs: run_exports: - {{ pin_subpackage("librmm", max_pin="x.x") }} ignore_run_exports_from: - - nvcc_linux-64 # [linux64] - - nvcc_linux-aarch64 # [aarch64] + - {{ compiler('cuda') }} requirements: build: - cmake {{ cmake_version }} @@ -98,8 +96,7 @@ outputs: number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} ignore_run_exports_from: - - nvcc_linux-64 # [linux64] - - nvcc_linux-aarch64 # [aarch64] + - {{ compiler('cuda') }} requirements: build: - cmake {{ cmake_version }} diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 777131fcb..33cbf99df 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -18,6 +18,8 @@ build: script_env: - RMM_BUILD_NO_GPU_TEST - VERSION_SUFFIX + ignore_run_exports_from: + - {{ compiler('cuda') }} requirements: build: @@ -25,8 +27,7 @@ requirements: - {{ compiler('c') }} - {{ compiler('cxx') }} - {{ compiler('cuda') }} {{ cuda_version }} - - sysroot_linux-64 {{ sysroot_version }} # [linux64] - - sysroot_linux-aarch64 {{ sysroot_version }} # [aarch64] + - sysroot_{{ target_platform }} {{ sysroot_version }} host: - cuda-python >=11.5,<12.0 - cudatoolkit {{ cuda_version }}.* From bc06d5af20e88064e091f691efa604f123426c4c Mon Sep 17 00:00:00 2001 From: Jordan Jacobelli Date: Mon, 23 May 2022 16:13:28 +0200 Subject: [PATCH 112/675] Build conda packages using mambabuild (#900) Use `mambabuild` to build `conda` packages. This should speed up the builds and help to debug `conda` conflict issues Authors: - Jordan Jacobelli (https://github.com/Ethyling) Approvers: - https://github.com/jakirkham - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/900 --- ci/cpu/build.sh | 11 +++++++---- ci/gpu/build.sh | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ci/cpu/build.sh b/ci/cpu/build.sh index c042db739..7b1208758 100755 --- a/ci/cpu/build.sh +++ b/ci/cpu/build.sh @@ -55,6 +55,9 @@ conda list --show-channel-urls # FIX Added to deal with Anancoda SSL verification issues during conda builds conda config --set ssl_verify False +# FIXME: Move installation to gpuci/rapidsai images +gpuci_mamba_retry install -c conda-forge boa + ################################################################################ # BUILD - Conda package builds (conda deps: librmm <- rmm) ################################################################################ @@ -62,9 +65,9 @@ conda config --set ssl_verify False if [[ "$BUILD_LIBRMM" == "1" ]]; then gpuci_logger "Build conda pkg for librmm" if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then - gpuci_conda_retry build conda/recipes/librmm --python=$PYTHON + gpuci_conda_retry mambabuild conda/recipes/librmm --python=$PYTHON else - gpuci_conda_retry build --no-build-id --croot ${CONDA_BLD_DIR} --dirty --no-remove-work-dir conda/recipes/librmm + gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} --dirty --no-remove-work-dir conda/recipes/librmm mkdir -p ${CONDA_BLD_DIR}/librmm mv ${CONDA_BLD_DIR}/work/ ${CONDA_BLD_DIR}/librmm/work fi @@ -75,9 +78,9 @@ fi if [[ "$BUILD_RMM" == "1" ]]; then gpuci_logger "Build conda pkg for rmm" if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then - gpuci_conda_retry build conda/recipes/rmm --python=$PYTHON + gpuci_conda_retry mambabuild conda/recipes/rmm --python=$PYTHON else - gpuci_conda_retry build --no-build-id --croot ${CONDA_BLD_DIR} --dirty --no-remove-work-dir \ + gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} --dirty --no-remove-work-dir \ -c $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ conda/recipes/rmm mkdir -p ${CONDA_BLD_DIR}/rmm mv ${CONDA_BLD_DIR}/work/ ${CONDA_BLD_DIR}/rmm/work diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 9176d4b15..2689667fb 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -111,9 +111,11 @@ else fi done + # TODO: Move boa install to gpuci/rapidsai + gpuci_mamba_retry install boa export CONDA_BLD_DIR="$WORKSPACE/.conda-bld" gpuci_logger "Building and installing rmm" - gpuci_conda_retry build --no-build-id --croot ${CONDA_BLD_DIR} \ + gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} \ -c $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ conda/recipes/rmm gpuci_mamba_retry install -c $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ \ -c ${CONDA_BLD_DIR} rmm From 7fb898610a6c2a15ce22d3c9f4a36e9fcdce2025 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Tue, 24 May 2022 07:49:53 +1000 Subject: [PATCH 113/675] Apply suggestions from code review Co-authored-by: Vyas Ramasubramani --- include/rmm/detail/dynamic_load_runtime.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/rmm/detail/dynamic_load_runtime.hpp b/include/rmm/detail/dynamic_load_runtime.hpp index 5c6ff1f6b..0350ef4ad 100644 --- a/include/rmm/detail/dynamic_load_runtime.hpp +++ b/include/rmm/detail/dynamic_load_runtime.hpp @@ -125,7 +125,7 @@ struct async_alloc { * @brief Check whether the specified `cudaMemAllocationHandleType` is supported on the present * CUDA driver/runtime version. * - * @note This query was introduced in CUDA 11.3 so on CUDA 11.2 this will only return true for + * @note This query was introduced in CUDA 11.3 so on CUDA 11.2 this function will only return true for * `cudaMemHandleTypeNone`. * * @param handle_type An IPC export handle type to check for support. From 748b03b3d9c5e35c15df68dc18eca1c1830af80e Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Tue, 24 May 2022 07:54:03 +1000 Subject: [PATCH 114/675] Update include/rmm/mr/device/cuda_async_memory_resource.hpp Co-authored-by: Vyas Ramasubramani --- include/rmm/mr/device/cuda_async_memory_resource.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index db5336d54..a91e3d469 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -69,7 +69,7 @@ class cuda_async_memory_resource final : public device_memory_resource { * @param release_threshold Optional release threshold size in bytes of the pool. If no value is * provided, the release threshold is set to the total amount of memory on the current device. * @param export_handle_type Optional `cudaMemAllocationHandleType` that allocations from this - * resource should support for interprocess communication (IPC). Default is + * resource should support interprocess communication (IPC). Default is * `cudaMemHandleTypeNone` for no IPC support. */ // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) From c9e10a6dc18e6843d30ed062fb506ea5f086be81 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Mon, 23 May 2022 14:56:34 -0700 Subject: [PATCH 115/675] Document allocation_handle_type --- include/rmm/mr/device/cuda_async_memory_resource.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index a91e3d469..b51ae4827 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -45,7 +45,14 @@ namespace rmm::mr { class cuda_async_memory_resource final : public device_memory_resource { public: /** - * Flags for specifying particular handle types + * @brief Flags for specifying memory allocation handle types. + * + * @note These values are exact copies from `cudaMemAllocationHandleType`. We need to + * define our own enum here because the earliest CUDA runtime version that supports asynchronous + * memory pools (CUDA 11.2) did not support these flags. So we need a placeholder that can be + * used consistently in the constructor of `cuda_async_memory_resource` with all versions of + * CUDA >= 11.2. See the `cudaMemAllocationHandleType` docs at + * https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html" */ enum class allocation_handle_type { none = 0x0, ///< Does not allow any export mechanism. From b30bc152de3c54ccc94bb0d266919e7846b938a7 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Mon, 23 May 2022 14:59:40 -0700 Subject: [PATCH 116/675] clang-format --- include/rmm/detail/dynamic_load_runtime.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/rmm/detail/dynamic_load_runtime.hpp b/include/rmm/detail/dynamic_load_runtime.hpp index 0350ef4ad..be9373082 100644 --- a/include/rmm/detail/dynamic_load_runtime.hpp +++ b/include/rmm/detail/dynamic_load_runtime.hpp @@ -125,8 +125,8 @@ struct async_alloc { * @brief Check whether the specified `cudaMemAllocationHandleType` is supported on the present * CUDA driver/runtime version. * - * @note This query was introduced in CUDA 11.3 so on CUDA 11.2 this function will only return true for - * `cudaMemHandleTypeNone`. + * @note This query was introduced in CUDA 11.3 so on CUDA 11.2 this function will only return + * true for `cudaMemHandleTypeNone`. * * @param handle_type An IPC export handle type to check for support. * @return true if supported From b79bf20c98ae4fc8d0de168fed58be49025c4024 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 23 May 2022 15:14:35 -0700 Subject: [PATCH 117/675] Update include/rmm/mr/device/cuda_async_memory_resource.hpp --- include/rmm/mr/device/cuda_async_memory_resource.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index b51ae4827..063e65bb8 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -49,10 +49,10 @@ class cuda_async_memory_resource final : public device_memory_resource { * * @note These values are exact copies from `cudaMemAllocationHandleType`. We need to * define our own enum here because the earliest CUDA runtime version that supports asynchronous - * memory pools (CUDA 11.2) did not support these flags. So we need a placeholder that can be + * memory pools (CUDA 11.2) did not support these flags, so we need a placeholder that can be * used consistently in the constructor of `cuda_async_memory_resource` with all versions of * CUDA >= 11.2. See the `cudaMemAllocationHandleType` docs at - * https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html" + * https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html */ enum class allocation_handle_type { none = 0x0, ///< Does not allow any export mechanism. From fea5c9ed452dfd6eb0b8e3e673b110b2c2167d0d Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Tue, 24 May 2022 14:55:46 -0400 Subject: [PATCH 118/675] update ops-bot.yaml config --- .github/ops-bot.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ops-bot.yaml b/.github/ops-bot.yaml index 408e28843..236696d94 100644 --- a/.github/ops-bot.yaml +++ b/.github/ops-bot.yaml @@ -5,4 +5,4 @@ auto_merger: true branch_checker: true label_checker: true release_drafter: true -external_contributors: true +copy_prs: true From bfe7db5defef4d3c55aa9de53186fb1fbede4b79 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Tue, 24 May 2022 18:18:46 -0700 Subject: [PATCH 119/675] Check for CUDA error when testing handle type support. --- include/rmm/detail/dynamic_load_runtime.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/rmm/detail/dynamic_load_runtime.hpp b/include/rmm/detail/dynamic_load_runtime.hpp index be9373082..a095eb321 100644 --- a/include/rmm/detail/dynamic_load_runtime.hpp +++ b/include/rmm/detail/dynamic_load_runtime.hpp @@ -136,9 +136,9 @@ struct async_alloc { { int supported_handle_types_bitmask{}; #if CUDART_VERSION >= 11030 // 11.3 introduced cudaDevAttrMemoryPoolSupportedHandleTypes - cudaDeviceGetAttribute(&supported_handle_types_bitmask, - cudaDevAttrMemoryPoolSupportedHandleTypes, - rmm::detail::current_device().value()); + RMM_CUDA_TRY(cudaDeviceGetAttribute(&supported_handle_types_bitmask, + cudaDevAttrMemoryPoolSupportedHandleTypes, + rmm::detail::current_device().value())); #endif return (supported_handle_types_bitmask & handle_type) == handle_type; } From aa38cdcf7b208d4ef9993af261819ae21cdc46fe Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Tue, 24 May 2022 18:20:40 -0700 Subject: [PATCH 120/675] Change default `enable_ipc` back to True --- python/rmm/_lib/memory_resource.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 8c87acb71..6719fa0f0 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -257,7 +257,7 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): self, initial_pool_size=None, release_threshold=None, - enable_ipc=False + enable_ipc=True ): cdef optional[size_t] c_initial_pool_size = ( optional[size_t]() From aeb3fb286087554c197bf0cc6c63568e297f5821 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Wed, 25 May 2022 15:27:46 -0700 Subject: [PATCH 121/675] Default enable_ipc to false, raise error if not supported, and test for error. --- python/rmm/_lib/memory_resource.pyx | 20 ++++++++++++++++++-- python/rmm/tests/test_rmm.py | 15 +++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 6719fa0f0..f373279c4 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -25,7 +25,13 @@ from libcpp.string cimport string from cuda.cudart import cudaError_t -from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice +from rmm._cuda.gpu import ( + CUDARuntimeError, + driverGetVersion, + getDevice, + runtimeGetVersion, + setDevice, +) from rmm._lib.cuda_stream_view cimport cuda_stream_view @@ -257,7 +263,7 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): self, initial_pool_size=None, release_threshold=None, - enable_ipc=True + enable_ipc=False ): cdef optional[size_t] c_initial_pool_size = ( optional[size_t]() @@ -271,6 +277,16 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): else optional[size_t](release_threshold) ) + # IPC export handle support query is only possibly on CUDA 11.3 or + # later, so IPC not supported on earlier versions + if enable_ipc: + driver_version = driverGetVersion() + runtime_version = runtimeGetVersion() + if (driver_version <= 11020 or runtime_version <= 11020): + raise ValueError( + "enable_ipc=True is not supported on CUDA <= 11.2." + ) + cdef optional[allocation_handle_type] c_export_handle_type = ( optional[allocation_handle_type]( posix_file_descriptor diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index fa38ee9fe..94f375aec 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -539,6 +539,21 @@ def test_cuda_async_memory_resource(dtype, nelem, alloc): array_tester(dtype, nelem, alloc) +@pytest.mark.skipif( + not _CUDAMALLOC_ASYNC_SUPPORTED, + reason="cudaMallocAsync not supported", +) +def test_cuda_async_memory_resource_ipc(): + # Test that enabling IPC earlier than CUDA 11.3 raises a ValueError + if _driver_version < 11030 or _runtime_version < 11030: + with pytest.raises(ValueError): + mr = rmm.mr.CudaAsyncMemoryResource(enable_ipc=True) + else: + mr = rmm.mr.CudaAsyncMemoryResource(enable_ipc=True) + rmm.mr.set_current_device_resource(mr) + assert rmm.mr.get_current_device_resource_type() is type(mr) + + @pytest.mark.skipif( not _CUDAMALLOC_ASYNC_SUPPORTED, reason="cudaMallocAsync not supported", From e0ac26bce5405f9e9eebb67585105e71297a2d6c Mon Sep 17 00:00:00 2001 From: Mark Sadang <63854412+msadang@users.noreply.github.com> Date: Wed, 25 May 2022 20:07:25 -0700 Subject: [PATCH 122/675] Revert "Make IPC handle export optional in cuda_async_memory_resource" --- include/rmm/detail/dynamic_load_runtime.hpp | 27 --------- .../mr/device/cuda_async_memory_resource.hpp | 34 ++--------- python/rmm/_lib/memory_resource.pyx | 59 ++----------------- python/rmm/tests/test_rmm.py | 15 ----- 4 files changed, 10 insertions(+), 125 deletions(-) diff --git a/include/rmm/detail/dynamic_load_runtime.hpp b/include/rmm/detail/dynamic_load_runtime.hpp index a095eb321..6e60201c1 100644 --- a/include/rmm/detail/dynamic_load_runtime.hpp +++ b/include/rmm/detail/dynamic_load_runtime.hpp @@ -14,13 +14,8 @@ * limitations under the License. */ #pragma once - -#include - #include - #include - #include #include @@ -121,28 +116,6 @@ struct async_alloc { return runtime_supports_pool and driver_supports_pool; } - /** - * @brief Check whether the specified `cudaMemAllocationHandleType` is supported on the present - * CUDA driver/runtime version. - * - * @note This query was introduced in CUDA 11.3 so on CUDA 11.2 this function will only return - * true for `cudaMemHandleTypeNone`. - * - * @param handle_type An IPC export handle type to check for support. - * @return true if supported - * @return false if unsupported - */ - static bool is_export_handle_type_supported(cudaMemAllocationHandleType handle_type) - { - int supported_handle_types_bitmask{}; -#if CUDART_VERSION >= 11030 // 11.3 introduced cudaDevAttrMemoryPoolSupportedHandleTypes - RMM_CUDA_TRY(cudaDeviceGetAttribute(&supported_handle_types_bitmask, - cudaDevAttrMemoryPoolSupportedHandleTypes, - rmm::detail::current_device().value())); -#endif - return (supported_handle_types_bitmask & handle_type) == handle_type; - } - template using cudart_sig = dynamic_load_runtime::function_sig; diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 063e65bb8..78e885406 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -44,24 +44,6 @@ namespace rmm::mr { */ class cuda_async_memory_resource final : public device_memory_resource { public: - /** - * @brief Flags for specifying memory allocation handle types. - * - * @note These values are exact copies from `cudaMemAllocationHandleType`. We need to - * define our own enum here because the earliest CUDA runtime version that supports asynchronous - * memory pools (CUDA 11.2) did not support these flags, so we need a placeholder that can be - * used consistently in the constructor of `cuda_async_memory_resource` with all versions of - * CUDA >= 11.2. See the `cudaMemAllocationHandleType` docs at - * https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html - */ - enum class allocation_handle_type { - none = 0x0, ///< Does not allow any export mechanism. - posix_file_descriptor = 0x1, ///< Allows a file descriptor to be used for exporting. Permitted - ///< only on POSIX systems. - win32 = 0x2, ///< Allows a Win32 NT handle to be used for exporting. (HANDLE) - win32_kmt = 0x4 ///< Allows a Win32 KMT handle to be used for exporting. (D3DKMT_HANDLE) - }; - /** * @brief Constructs a cuda_async_memory_resource with the optionally specified initial pool size * and release threshold. @@ -75,14 +57,10 @@ class cuda_async_memory_resource final : public device_memory_resource { * initial pool size is half of the available GPU memory. * @param release_threshold Optional release threshold size in bytes of the pool. If no value is * provided, the release threshold is set to the total amount of memory on the current device. - * @param export_handle_type Optional `cudaMemAllocationHandleType` that allocations from this - * resource should support interprocess communication (IPC). Default is - * `cudaMemHandleTypeNone` for no IPC support. */ // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) - cuda_async_memory_resource(thrust::optional initial_pool_size = {}, - thrust::optional release_threshold = {}, - thrust::optional export_handle_type = {}) + cuda_async_memory_resource(thrust::optional initial_pool_size = {}, + thrust::optional release_threshold = {}) { #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT // Check if cudaMallocAsync Memory pool supported @@ -91,11 +69,8 @@ class cuda_async_memory_resource final : public device_memory_resource { // Construct explicit pool cudaMemPoolProps pool_props{}; - pool_props.allocType = cudaMemAllocationTypePinned; - pool_props.handleTypes = static_cast( - export_handle_type.value_or(allocation_handle_type::none)); - RMM_EXPECTS(rmm::detail::async_alloc::is_export_handle_type_supported(pool_props.handleTypes), - "Requested IPC memory handle type not supported"); + pool_props.allocType = cudaMemAllocationTypePinned; + pool_props.handleTypes = cudaMemHandleTypePosixFileDescriptor; pool_props.location.type = cudaMemLocationTypeDevice; pool_props.location.id = rmm::detail::current_device().value(); cudaMemPool_t cuda_pool_handle{}; @@ -126,6 +101,7 @@ class cuda_async_memory_resource final : public device_memory_resource { auto const pool_size = initial_pool_size.value_or(free / 2); auto* ptr = do_allocate(pool_size, cuda_stream_default); do_deallocate(ptr, pool_size, cuda_stream_default); + #else RMM_FAIL( "cudaMallocAsync not supported by the version of the CUDA Toolkit used for this build"); diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index f373279c4..a110bff97 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -25,14 +25,7 @@ from libcpp.string cimport string from cuda.cudart import cudaError_t -from rmm._cuda.gpu import ( - CUDARuntimeError, - driverGetVersion, - getDevice, - runtimeGetVersion, - setDevice, -) - +from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice from rmm._lib.cuda_stream_view cimport cuda_stream_view @@ -63,24 +56,9 @@ cdef extern from "rmm/mr/device/managed_memory_resource.hpp" \ cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ namespace "rmm::mr" nogil: - cdef cppclass cuda_async_memory_resource(device_memory_resource): - cuda_async_memory_resource( - optional[size_t] initial_pool_size, - optional[size_t] release_threshold, - optional[allocation_handle_type] export_handle_type) except + - -# TODO: when we adopt Cython 3.0 use enum class -cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ - namespace \ - "rmm::mr::cuda_async_memory_resource::allocation_handle_type" \ - nogil: - enum allocation_handle_type \ - "rmm::mr::cuda_async_memory_resource::allocation_handle_type": - none - posix_file_descriptor - win32 - win32_kmt + cuda_async_memory_resource(optional[size_t] initial_pool_size, + optional[size_t] release_threshold) except + cdef extern from "rmm/mr/device/pool_memory_resource.hpp" \ namespace "rmm::mr" nogil: @@ -255,16 +233,8 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): Release threshold in bytes. If the pool size grows beyond this value, unused memory held by the pool will be released at the next synchronization point. - enable_ipc: bool, optional - If True, enables export of POSIX file descriptor handles for the memory - allocated by this resource so that it can be used with CUDA IPC. """ - def __cinit__( - self, - initial_pool_size=None, - release_threshold=None, - enable_ipc=False - ): + def __cinit__(self, initial_pool_size=None, release_threshold=None): cdef optional[size_t] c_initial_pool_size = ( optional[size_t]() if initial_pool_size is None @@ -277,29 +247,10 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): else optional[size_t](release_threshold) ) - # IPC export handle support query is only possibly on CUDA 11.3 or - # later, so IPC not supported on earlier versions - if enable_ipc: - driver_version = driverGetVersion() - runtime_version = runtimeGetVersion() - if (driver_version <= 11020 or runtime_version <= 11020): - raise ValueError( - "enable_ipc=True is not supported on CUDA <= 11.2." - ) - - cdef optional[allocation_handle_type] c_export_handle_type = ( - optional[allocation_handle_type]( - posix_file_descriptor - ) - if enable_ipc - else optional[allocation_handle_type]() - ) - self.c_obj.reset( new cuda_async_memory_resource( c_initial_pool_size, - c_release_threshold, - c_export_handle_type + c_release_threshold ) ) diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index 94f375aec..fa38ee9fe 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -539,21 +539,6 @@ def test_cuda_async_memory_resource(dtype, nelem, alloc): array_tester(dtype, nelem, alloc) -@pytest.mark.skipif( - not _CUDAMALLOC_ASYNC_SUPPORTED, - reason="cudaMallocAsync not supported", -) -def test_cuda_async_memory_resource_ipc(): - # Test that enabling IPC earlier than CUDA 11.3 raises a ValueError - if _driver_version < 11030 or _runtime_version < 11030: - with pytest.raises(ValueError): - mr = rmm.mr.CudaAsyncMemoryResource(enable_ipc=True) - else: - mr = rmm.mr.CudaAsyncMemoryResource(enable_ipc=True) - rmm.mr.set_current_device_resource(mr) - assert rmm.mr.get_current_device_resource_type() is type(mr) - - @pytest.mark.skipif( not _CUDAMALLOC_ASYNC_SUPPORTED, reason="cudaMallocAsync not supported", From 914cb4c89ee80655f077ff2c29902617251efaef Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Thu, 26 May 2022 14:58:06 +1000 Subject: [PATCH 123/675] Revert "Revert "Make IPC handle export optional in cuda_async_memory_resource"" (#1051) Co-authored-by: Mark Sadang <63854412+msadang@users.noreply.github.com> --- include/rmm/detail/dynamic_load_runtime.hpp | 27 +++++++++ .../mr/device/cuda_async_memory_resource.hpp | 34 +++++++++-- python/rmm/_lib/memory_resource.pyx | 59 +++++++++++++++++-- python/rmm/tests/test_rmm.py | 15 +++++ 4 files changed, 125 insertions(+), 10 deletions(-) diff --git a/include/rmm/detail/dynamic_load_runtime.hpp b/include/rmm/detail/dynamic_load_runtime.hpp index 6e60201c1..a095eb321 100644 --- a/include/rmm/detail/dynamic_load_runtime.hpp +++ b/include/rmm/detail/dynamic_load_runtime.hpp @@ -14,8 +14,13 @@ * limitations under the License. */ #pragma once + +#include + #include + #include + #include #include @@ -116,6 +121,28 @@ struct async_alloc { return runtime_supports_pool and driver_supports_pool; } + /** + * @brief Check whether the specified `cudaMemAllocationHandleType` is supported on the present + * CUDA driver/runtime version. + * + * @note This query was introduced in CUDA 11.3 so on CUDA 11.2 this function will only return + * true for `cudaMemHandleTypeNone`. + * + * @param handle_type An IPC export handle type to check for support. + * @return true if supported + * @return false if unsupported + */ + static bool is_export_handle_type_supported(cudaMemAllocationHandleType handle_type) + { + int supported_handle_types_bitmask{}; +#if CUDART_VERSION >= 11030 // 11.3 introduced cudaDevAttrMemoryPoolSupportedHandleTypes + RMM_CUDA_TRY(cudaDeviceGetAttribute(&supported_handle_types_bitmask, + cudaDevAttrMemoryPoolSupportedHandleTypes, + rmm::detail::current_device().value())); +#endif + return (supported_handle_types_bitmask & handle_type) == handle_type; + } + template using cudart_sig = dynamic_load_runtime::function_sig; diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 78e885406..063e65bb8 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -44,6 +44,24 @@ namespace rmm::mr { */ class cuda_async_memory_resource final : public device_memory_resource { public: + /** + * @brief Flags for specifying memory allocation handle types. + * + * @note These values are exact copies from `cudaMemAllocationHandleType`. We need to + * define our own enum here because the earliest CUDA runtime version that supports asynchronous + * memory pools (CUDA 11.2) did not support these flags, so we need a placeholder that can be + * used consistently in the constructor of `cuda_async_memory_resource` with all versions of + * CUDA >= 11.2. See the `cudaMemAllocationHandleType` docs at + * https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html + */ + enum class allocation_handle_type { + none = 0x0, ///< Does not allow any export mechanism. + posix_file_descriptor = 0x1, ///< Allows a file descriptor to be used for exporting. Permitted + ///< only on POSIX systems. + win32 = 0x2, ///< Allows a Win32 NT handle to be used for exporting. (HANDLE) + win32_kmt = 0x4 ///< Allows a Win32 KMT handle to be used for exporting. (D3DKMT_HANDLE) + }; + /** * @brief Constructs a cuda_async_memory_resource with the optionally specified initial pool size * and release threshold. @@ -57,10 +75,14 @@ class cuda_async_memory_resource final : public device_memory_resource { * initial pool size is half of the available GPU memory. * @param release_threshold Optional release threshold size in bytes of the pool. If no value is * provided, the release threshold is set to the total amount of memory on the current device. + * @param export_handle_type Optional `cudaMemAllocationHandleType` that allocations from this + * resource should support interprocess communication (IPC). Default is + * `cudaMemHandleTypeNone` for no IPC support. */ // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) - cuda_async_memory_resource(thrust::optional initial_pool_size = {}, - thrust::optional release_threshold = {}) + cuda_async_memory_resource(thrust::optional initial_pool_size = {}, + thrust::optional release_threshold = {}, + thrust::optional export_handle_type = {}) { #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT // Check if cudaMallocAsync Memory pool supported @@ -69,8 +91,11 @@ class cuda_async_memory_resource final : public device_memory_resource { // Construct explicit pool cudaMemPoolProps pool_props{}; - pool_props.allocType = cudaMemAllocationTypePinned; - pool_props.handleTypes = cudaMemHandleTypePosixFileDescriptor; + pool_props.allocType = cudaMemAllocationTypePinned; + pool_props.handleTypes = static_cast( + export_handle_type.value_or(allocation_handle_type::none)); + RMM_EXPECTS(rmm::detail::async_alloc::is_export_handle_type_supported(pool_props.handleTypes), + "Requested IPC memory handle type not supported"); pool_props.location.type = cudaMemLocationTypeDevice; pool_props.location.id = rmm::detail::current_device().value(); cudaMemPool_t cuda_pool_handle{}; @@ -101,7 +126,6 @@ class cuda_async_memory_resource final : public device_memory_resource { auto const pool_size = initial_pool_size.value_or(free / 2); auto* ptr = do_allocate(pool_size, cuda_stream_default); do_deallocate(ptr, pool_size, cuda_stream_default); - #else RMM_FAIL( "cudaMallocAsync not supported by the version of the CUDA Toolkit used for this build"); diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index a110bff97..f373279c4 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -25,7 +25,14 @@ from libcpp.string cimport string from cuda.cudart import cudaError_t -from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice +from rmm._cuda.gpu import ( + CUDARuntimeError, + driverGetVersion, + getDevice, + runtimeGetVersion, + setDevice, +) + from rmm._lib.cuda_stream_view cimport cuda_stream_view @@ -56,9 +63,24 @@ cdef extern from "rmm/mr/device/managed_memory_resource.hpp" \ cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ namespace "rmm::mr" nogil: + cdef cppclass cuda_async_memory_resource(device_memory_resource): - cuda_async_memory_resource(optional[size_t] initial_pool_size, - optional[size_t] release_threshold) except + + cuda_async_memory_resource( + optional[size_t] initial_pool_size, + optional[size_t] release_threshold, + optional[allocation_handle_type] export_handle_type) except + + +# TODO: when we adopt Cython 3.0 use enum class +cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ + namespace \ + "rmm::mr::cuda_async_memory_resource::allocation_handle_type" \ + nogil: + enum allocation_handle_type \ + "rmm::mr::cuda_async_memory_resource::allocation_handle_type": + none + posix_file_descriptor + win32 + win32_kmt cdef extern from "rmm/mr/device/pool_memory_resource.hpp" \ namespace "rmm::mr" nogil: @@ -233,8 +255,16 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): Release threshold in bytes. If the pool size grows beyond this value, unused memory held by the pool will be released at the next synchronization point. + enable_ipc: bool, optional + If True, enables export of POSIX file descriptor handles for the memory + allocated by this resource so that it can be used with CUDA IPC. """ - def __cinit__(self, initial_pool_size=None, release_threshold=None): + def __cinit__( + self, + initial_pool_size=None, + release_threshold=None, + enable_ipc=False + ): cdef optional[size_t] c_initial_pool_size = ( optional[size_t]() if initial_pool_size is None @@ -247,10 +277,29 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): else optional[size_t](release_threshold) ) + # IPC export handle support query is only possibly on CUDA 11.3 or + # later, so IPC not supported on earlier versions + if enable_ipc: + driver_version = driverGetVersion() + runtime_version = runtimeGetVersion() + if (driver_version <= 11020 or runtime_version <= 11020): + raise ValueError( + "enable_ipc=True is not supported on CUDA <= 11.2." + ) + + cdef optional[allocation_handle_type] c_export_handle_type = ( + optional[allocation_handle_type]( + posix_file_descriptor + ) + if enable_ipc + else optional[allocation_handle_type]() + ) + self.c_obj.reset( new cuda_async_memory_resource( c_initial_pool_size, - c_release_threshold + c_release_threshold, + c_export_handle_type ) ) diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index fa38ee9fe..94f375aec 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -539,6 +539,21 @@ def test_cuda_async_memory_resource(dtype, nelem, alloc): array_tester(dtype, nelem, alloc) +@pytest.mark.skipif( + not _CUDAMALLOC_ASYNC_SUPPORTED, + reason="cudaMallocAsync not supported", +) +def test_cuda_async_memory_resource_ipc(): + # Test that enabling IPC earlier than CUDA 11.3 raises a ValueError + if _driver_version < 11030 or _runtime_version < 11030: + with pytest.raises(ValueError): + mr = rmm.mr.CudaAsyncMemoryResource(enable_ipc=True) + else: + mr = rmm.mr.CudaAsyncMemoryResource(enable_ipc=True) + rmm.mr.set_current_device_resource(mr) + assert rmm.mr.get_current_device_resource_type() is type(mr) + + @pytest.mark.skipif( not _CUDAMALLOC_ASYNC_SUPPORTED, reason="cudaMallocAsync not supported", From 04a4321f763cb41c4b31c6956e66c3494b4c929f Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Fri, 27 May 2022 10:56:17 -0400 Subject: [PATCH 124/675] update ops-bot config --- .github/ops-bot.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ops-bot.yaml b/.github/ops-bot.yaml index 236696d94..2ef41b367 100644 --- a/.github/ops-bot.yaml +++ b/.github/ops-bot.yaml @@ -6,3 +6,4 @@ branch_checker: true label_checker: true release_drafter: true copy_prs: true +rerun_tests: true From 270b35b80444a4492cee6986d034965869655c6e Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 3 Jun 2022 11:24:37 -0700 Subject: [PATCH 125/675] Change build.sh to find C++ library by default and avoid shadowing CMAKE_ARGS (#1053) Discussions with the team indicated a general preference for having build.sh default to finding the C++ library by default (and erroring if one is not found) rather than building a new copy of librmm when building rmm Python. This change has little effect on rmm since it's header-only, but is being made for consistency with other libraries. More importantly, this PR also avoids shadowing the `CMAKE_ARGS` environment variable in build.sh, which is important for conda-forge compatibility. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1053 --- build.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/build.sh b/build.sh index 863feeb15..77d9e6722 100755 --- a/build.sh +++ b/build.sh @@ -71,12 +71,12 @@ function cmakeArgs { # 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 - CMAKE_ARGS=$(echo $ARGS | { grep -Eo "\-\-cmake\-args=\".+\"" || true; }) - if [[ -n ${CMAKE_ARGS} ]]; then - # Remove the full CMAKE_ARGS argument from list of args so that it passes validArgs function - ARGS=${ARGS//$CMAKE_ARGS/} + EXTRA_CMAKE_ARGS=$(echo $ARGS | { grep -Eo "\-\-cmake\-args=\".+\"" || true; }) + if [[ -n ${EXTRA_CMAKE_ARGS} ]]; then + # Remove the full EXTRA_CMAKE_ARGS argument from list of args so that it passes validArgs function + ARGS=${ARGS//$EXTRA_CMAKE_ARGS/} # Filter the full argument down to just the extra string that will be added to cmake call - CMAKE_ARGS=$(echo $CMAKE_ARGS | grep -Eo "\".+\"" | sed -e 's/^"//' -e 's/"$//') + EXTRA_CMAKE_ARGS=$(echo $EXTRA_CMAKE_ARGS | grep -Eo "\".+\"" | sed -e 's/^"//' -e 's/"$//') fi fi } @@ -95,7 +95,7 @@ function ensureCMakeRan { -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ -DBUILD_TESTS=${BUILD_TESTS} \ -DBUILD_BENCHMARKS=${BUILD_BENCHMARKS} \ - ${CMAKE_ARGS} + ${EXTRA_CMAKE_ARGS} RAN_CMAKE=1 fi } @@ -141,6 +141,11 @@ if hasArg --ptds; then PER_THREAD_DEFAULT_STREAM=ON fi +# Append `-DFIND_RMM_CPP=ON` to CMAKE_ARGS unless a user specified the option. +if [[ "${EXTRA_CMAKE_ARGS}" != *"DFIND_RMM_CPP"* ]]; then + EXTRA_CMAKE_ARGS="${EXTRA_CMAKE_ARGS} -DFIND_RMM_CPP=ON" +fi + # If clean given, run it prior to any other steps if hasArg clean; then # If the dirs to clean are mounted dirs in a container, the @@ -173,11 +178,11 @@ if (( NUMARGS == 0 )) || hasArg rmm; then export INSTALL_PREFIX echo "building rmm..." - python setup.py build_ext --inplace -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} ${CMAKE_ARGS} + python setup.py build_ext --inplace -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} ${EXTRA_CMAKE_ARGS} if [[ ${INSTALL_TARGET} != "" ]]; then echo "installing rmm..." - python setup.py install --single-version-externally-managed --record=record.txt -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} ${CMAKE_ARGS} + python setup.py install --single-version-externally-managed --record=record.txt -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} ${EXTRA_CMAKE_ARGS} fi fi From 89713b2c221f8931044d1e5c7a5889cad4125454 Mon Sep 17 00:00:00 2001 From: Gera Shegalov Date: Mon, 6 Jun 2022 13:31:45 -0700 Subject: [PATCH 126/675] Properly handle cudaMemHandleTypeNone and cudaErrorInvalidValue in is_export_handle_type_supported (#1055) - [x] Intercept `cudaErrorInvalidValue` returned from `cudaDeviceGetAttribute` to return `false` from `is_export_handle_type_supported ` - [x] Return true from is_export_handle_type_supported for `cudaMemHandleTypeNone` Co-authored-by: @jrhemstad Co-authored-by: @harrism Closes #1054 Signed-off-by: Gera Shegalov Authors: - Gera Shegalov (https://github.com/gerashegalov) Approvers: - Rong Ou (https://github.com/rongou) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1055 --- include/rmm/detail/dynamic_load_runtime.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/rmm/detail/dynamic_load_runtime.hpp b/include/rmm/detail/dynamic_load_runtime.hpp index a095eb321..28121e6a8 100644 --- a/include/rmm/detail/dynamic_load_runtime.hpp +++ b/include/rmm/detail/dynamic_load_runtime.hpp @@ -136,9 +136,18 @@ struct async_alloc { { int supported_handle_types_bitmask{}; #if CUDART_VERSION >= 11030 // 11.3 introduced cudaDevAttrMemoryPoolSupportedHandleTypes - RMM_CUDA_TRY(cudaDeviceGetAttribute(&supported_handle_types_bitmask, - cudaDevAttrMemoryPoolSupportedHandleTypes, - rmm::detail::current_device().value())); + if (cudaMemHandleTypeNone != handle_type) { + auto const result = cudaDeviceGetAttribute(&supported_handle_types_bitmask, + cudaDevAttrMemoryPoolSupportedHandleTypes, + rmm::detail::current_device().value()); + + // Don't throw on cudaErrorInvalidValue + auto const unsupported_runtime = (result == cudaErrorInvalidValue); + if (unsupported_runtime) return false; + // throw any other error that may have occurred + RMM_CUDA_TRY(result); + } + #endif return (supported_handle_types_bitmask & handle_type) == handle_type; } From 185c18e642cd569a96e6bf77273f9e409308ac3f Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Tue, 7 Jun 2022 11:26:06 -0400 Subject: [PATCH 127/675] update changelog --- CHANGELOG.md | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f291791ec..bb3dde1e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,36 @@ -# RMM 22.06.00 (Date TBD) +# RMM 22.06.00 (7 Jun 2022) -Please see https://github.com/rapidsai/rmm/releases/tag/v22.06.00a for the latest changes to this development branch. +## 🐛 Bug Fixes + +- Clarifies Python requirements and version constraints ([#1037](https://github.com/rapidsai/rmm/pull/1037)) [@jakirkham](https://github.com/jakirkham) +- Use `lib` (not `lib64`) for libraries ([#1024](https://github.com/rapidsai/rmm/pull/1024)) [@jakirkham](https://github.com/jakirkham) +- Properly enable Cython docstrings. ([#1020](https://github.com/rapidsai/rmm/pull/1020)) [@vyasr](https://github.com/vyasr) +- Update `RMMNumbaManager` to handle `NUMBA_CUDA_USE_NVIDIA_BINDING=1` ([#1004](https://github.com/rapidsai/rmm/pull/1004)) [@brandon-b-miller](https://github.com/brandon-b-miller) + +## 📖 Documentation + +- Clarify using RMM with other Python libraries ([#1034](https://github.com/rapidsai/rmm/pull/1034)) [@jrhemstad](https://github.com/jrhemstad) +- Replace `to_device` with `DeviceBuffer.to_device` ([#1033](https://github.com/rapidsai/rmm/pull/1033)) [@wence-](https://github.com/wence-) +- Documentation Fix: Replace `cudf::logic_error` with `rmm::logic_error` ([#1021](https://github.com/rapidsai/rmm/pull/1021)) [@codereport](https://github.com/codereport) + +## 🚀 New Features + +- Add rmm::exec_policy_nosync ([#1009](https://github.com/rapidsai/rmm/pull/1009)) [@fkallen](https://github.com/fkallen) +- Callback memory resource ([#980](https://github.com/rapidsai/rmm/pull/980)) [@shwina](https://github.com/shwina) + +## 🛠️ Improvements + +- Fix conda recipes for conda compilers ([#1043](https://github.com/rapidsai/rmm/pull/1043)) [@Ethyling](https://github.com/Ethyling) +- Use new rapids-cython component of rapids-cmake to simplify builds ([#1031](https://github.com/rapidsai/rmm/pull/1031)) [@vyasr](https://github.com/vyasr) +- Merge branch-22.04 to branch-22.06 ([#1028](https://github.com/rapidsai/rmm/pull/1028)) [@jakirkham](https://github.com/jakirkham) +- Update CMake pinning to just avoid 3.23.0. ([#1023](https://github.com/rapidsai/rmm/pull/1023)) [@vyasr](https://github.com/vyasr) +- Build python using conda in GPU jobs ([#1017](https://github.com/rapidsai/rmm/pull/1017)) [@Ethyling](https://github.com/Ethyling) +- Remove pip requirements file. ([#1015](https://github.com/rapidsai/rmm/pull/1015)) [@bdice](https://github.com/bdice) +- Clean up Thrust includes. ([#1011](https://github.com/rapidsai/rmm/pull/1011)) [@bdice](https://github.com/bdice) +- Update black version ([#1010](https://github.com/rapidsai/rmm/pull/1010)) [@vyasr](https://github.com/vyasr) +- Update cmake-format version for pre-commit and environments. ([#995](https://github.com/rapidsai/rmm/pull/995)) [@vyasr](https://github.com/vyasr) +- Use conda compilers ([#977](https://github.com/rapidsai/rmm/pull/977)) [@Ethyling](https://github.com/Ethyling) +- Build conda packages using mambabuild ([#900](https://github.com/rapidsai/rmm/pull/900)) [@Ethyling](https://github.com/Ethyling) # RMM 22.04.00 (6 Apr 2022) From f68417a64e0424c54797eae193d92be6992f5c45 Mon Sep 17 00:00:00 2001 From: Ashwin Srinath <3190405+shwina@users.noreply.github.com> Date: Thu, 16 Jun 2022 20:07:46 -0400 Subject: [PATCH 128/675] Add a missed `except *` (#1057) Authors: - Ashwin Srinath (https://github.com/shwina) Approvers: - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) - https://github.com/jakirkham URL: https://github.com/rapidsai/rmm/pull/1057 --- python/rmm/_lib/device_buffer.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/rmm/_lib/device_buffer.pyx b/python/rmm/_lib/device_buffer.pyx index bc761c29c..d33198315 100644 --- a/python/rmm/_lib/device_buffer.pyx +++ b/python/rmm/_lib/device_buffer.pyx @@ -344,7 +344,7 @@ cdef void _copy_async(const void* src, void* dst, size_t count, ccudart.cudaMemcpyKind kind, - cuda_stream_view stream) nogil: + cuda_stream_view stream) nogil except *: """ Asynchronously copy data between host and/or device pointers From 8b8699311c763e16f290868dfa807f4221586154 Mon Sep 17 00:00:00 2001 From: jakirkham Date: Tue, 21 Jun 2022 21:41:54 -0700 Subject: [PATCH 129/675] Specify `language` as `'en'` instead of `None` (#1059) Needed for Sphinx 5 compatibility. Should fix the following warning occurring in doc builds. ``` Invalid configuration value found: 'language = None'. Update your configuration to a valid langauge code. Falling back to 'en' (English). ``` xref: https://github.com/sphinx-doc/sphinx/pull/10481 Authors: - https://github.com/jakirkham - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) URL: https://github.com/rapidsai/rmm/pull/1059 --- python/docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/docs/conf.py b/python/docs/conf.py index d0fd76924..ebb24dbf3 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -78,7 +78,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = "en" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. From 6927e7d87a2fca74d85bcd032c3bda4505250def Mon Sep 17 00:00:00 2001 From: GALI PREM SAGAR Date: Mon, 4 Jul 2022 03:02:29 -0500 Subject: [PATCH 130/675] Pin max version of `cuda-python` to `11.7` (#1062) This PR pins max version of `cuda-python` to `11.7` Authors: - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - Ashwin Srinath (https://github.com/shwina) - Jordan Jacobelli (https://github.com/Ethyling) URL: https://github.com/rapidsai/rmm/pull/1062 --- conda/environments/rmm_dev_cuda11.5.yml | 2 +- conda/environments/rmm_dev_cuda11.6.yml | 2 +- conda/recipes/rmm/meta.yaml | 4 ++-- python/pyproject.toml | 2 +- python/setup.cfg | 2 +- python/setup.py | 6 +++++- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/conda/environments/rmm_dev_cuda11.5.yml b/conda/environments/rmm_dev_cuda11.5.yml index fc9167500..ecfad3812 100644 --- a/conda/environments/rmm_dev_cuda11.5.yml +++ b/conda/environments/rmm_dev_cuda11.5.yml @@ -20,4 +20,4 @@ dependencies: - spdlog>=1.8.5,<1.9 - cython>=0.29,<0.30 - gcovr>=5.0 -- cuda-python>=11.5,<12.0 +- cuda-python>=11.5,<11.7.1 diff --git a/conda/environments/rmm_dev_cuda11.6.yml b/conda/environments/rmm_dev_cuda11.6.yml index 3fa2fbb6e..80a28e6bc 100644 --- a/conda/environments/rmm_dev_cuda11.6.yml +++ b/conda/environments/rmm_dev_cuda11.6.yml @@ -20,4 +20,4 @@ dependencies: - spdlog>=1.8.5,<1.9 - cython>=0.29,<0.30 - gcovr>=5.0 -- cuda-python>=11.6,<12.0 +- cuda-python>=11.6,11.7.1 diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 33cbf99df..a4d5f19c3 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -29,7 +29,7 @@ requirements: - {{ compiler('cuda') }} {{ cuda_version }} - sysroot_{{ target_platform }} {{ sysroot_version }} host: - - cuda-python >=11.5,<12.0 + - cuda-python >=11.5,<11.7.1 - cudatoolkit {{ cuda_version }}.* - cython >=0.29,<0.30 - librmm {{ version }}.* @@ -38,7 +38,7 @@ requirements: - setuptools - spdlog>=1.8.5,<2.0.0a0 run: - - cuda-python >=11.5,<12.0 + - cuda-python >=11.5,<11.7.1 - numba >=0.49 - numpy >=1.19 - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} diff --git a/python/pyproject.toml b/python/pyproject.toml index 786e7df08..57be17669 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -21,7 +21,7 @@ requires = [ "scikit-build>=0.13.1", "cmake>=3.20.1,!=3.23.0", "ninja", - "cuda-python>=11.5,<12.0", + "cuda-python>=11.5,<11.7.1", ] [tool.black] diff --git a/python/setup.cfg b/python/setup.cfg index de2d6a679..06b44e59f 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -52,7 +52,7 @@ skip= [options] packages = find: install_requires = - cuda-python>=11.5,<12.0 + cuda-python>=11.5,<11.7.1 numpy>=1.19 numba>=0.49 python_requires = >=3.8 diff --git a/python/setup.py b/python/setup.py index 24ac9c7ee..2f91d200b 100644 --- a/python/setup.py +++ b/python/setup.py @@ -34,6 +34,10 @@ ) }, cmdclass=versioneer.get_cmdclass(), - install_requires=["cuda-python>=11.5,<12.0", "numpy>=1.19", "numba>=0.49"], + install_requires=[ + "cuda-python>=11.5,<11.7.1", + "numpy>=1.19", + "numba>=0.49", + ], zip_safe=False, ) From f0958fadadecd15e9097ad3f06f5c89f3af31bb7 Mon Sep 17 00:00:00 2001 From: Ray Douglass <3107146+raydouglass@users.noreply.github.com> Date: Wed, 6 Jul 2022 10:43:19 -0400 Subject: [PATCH 131/675] Pin max version of `cuda-python` to `11.7` (#1062) (#1063) This PR pins max version of `cuda-python` to `11.7` This is a back port of #1062. Authors: - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) --- conda/environments/rmm_dev_cuda11.5.yml | 2 +- conda/environments/rmm_dev_cuda11.6.yml | 2 +- conda/recipes/rmm/meta.yaml | 4 ++-- python/pyproject.toml | 2 +- python/setup.cfg | 2 +- python/setup.py | 6 +++++- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/conda/environments/rmm_dev_cuda11.5.yml b/conda/environments/rmm_dev_cuda11.5.yml index fc9167500..ecfad3812 100644 --- a/conda/environments/rmm_dev_cuda11.5.yml +++ b/conda/environments/rmm_dev_cuda11.5.yml @@ -20,4 +20,4 @@ dependencies: - spdlog>=1.8.5,<1.9 - cython>=0.29,<0.30 - gcovr>=5.0 -- cuda-python>=11.5,<12.0 +- cuda-python>=11.5,<11.7.1 diff --git a/conda/environments/rmm_dev_cuda11.6.yml b/conda/environments/rmm_dev_cuda11.6.yml index 3fa2fbb6e..80a28e6bc 100644 --- a/conda/environments/rmm_dev_cuda11.6.yml +++ b/conda/environments/rmm_dev_cuda11.6.yml @@ -20,4 +20,4 @@ dependencies: - spdlog>=1.8.5,<1.9 - cython>=0.29,<0.30 - gcovr>=5.0 -- cuda-python>=11.6,<12.0 +- cuda-python>=11.6,11.7.1 diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 33cbf99df..a4d5f19c3 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -29,7 +29,7 @@ requirements: - {{ compiler('cuda') }} {{ cuda_version }} - sysroot_{{ target_platform }} {{ sysroot_version }} host: - - cuda-python >=11.5,<12.0 + - cuda-python >=11.5,<11.7.1 - cudatoolkit {{ cuda_version }}.* - cython >=0.29,<0.30 - librmm {{ version }}.* @@ -38,7 +38,7 @@ requirements: - setuptools - spdlog>=1.8.5,<2.0.0a0 run: - - cuda-python >=11.5,<12.0 + - cuda-python >=11.5,<11.7.1 - numba >=0.49 - numpy >=1.19 - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} diff --git a/python/pyproject.toml b/python/pyproject.toml index 786e7df08..57be17669 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -21,7 +21,7 @@ requires = [ "scikit-build>=0.13.1", "cmake>=3.20.1,!=3.23.0", "ninja", - "cuda-python>=11.5,<12.0", + "cuda-python>=11.5,<11.7.1", ] [tool.black] diff --git a/python/setup.cfg b/python/setup.cfg index de2d6a679..06b44e59f 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -52,7 +52,7 @@ skip= [options] packages = find: install_requires = - cuda-python>=11.5,<12.0 + cuda-python>=11.5,<11.7.1 numpy>=1.19 numba>=0.49 python_requires = >=3.8 diff --git a/python/setup.py b/python/setup.py index 24ac9c7ee..2f91d200b 100644 --- a/python/setup.py +++ b/python/setup.py @@ -34,6 +34,10 @@ ) }, cmdclass=versioneer.get_cmdclass(), - install_requires=["cuda-python>=11.5,<12.0", "numpy>=1.19", "numba>=0.49"], + install_requires=[ + "cuda-python>=11.5,<11.7.1", + "numpy>=1.19", + "numba>=0.49", + ], zip_safe=False, ) From b91a4a98c2b12ab10b83cc666147b290df28e42c Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 8 Jul 2022 14:10:53 -0700 Subject: [PATCH 132/675] Forward merge 22.06 into 22.08 (#1066) Replaces #1056 Authors: - Vyas Ramasubramani (https://github.com/vyasr) - Ray Douglass (https://github.com/raydouglass) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1066 --- CHANGELOG.md | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e545df69..21c0a1d9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,39 @@ Please see https://github.com/rapidsai/rmm/releases/tag/v22.08.00a for the latest changes to this development branch. -# RMM 22.06.00 (Date TBD) +# RMM 22.06.00 (7 Jun 2022) -Please see https://github.com/rapidsai/rmm/releases/tag/v22.06.00a for the latest changes to this development branch. +## 🐛 Bug Fixes + +- Clarifies Python requirements and version constraints ([#1037](https://github.com/rapidsai/rmm/pull/1037)) [@jakirkham](https://github.com/jakirkham) +- Use `lib` (not `lib64`) for libraries ([#1024](https://github.com/rapidsai/rmm/pull/1024)) [@jakirkham](https://github.com/jakirkham) +- Properly enable Cython docstrings. ([#1020](https://github.com/rapidsai/rmm/pull/1020)) [@vyasr](https://github.com/vyasr) +- Update `RMMNumbaManager` to handle `NUMBA_CUDA_USE_NVIDIA_BINDING=1` ([#1004](https://github.com/rapidsai/rmm/pull/1004)) [@brandon-b-miller](https://github.com/brandon-b-miller) + +## 📖 Documentation + +- Clarify using RMM with other Python libraries ([#1034](https://github.com/rapidsai/rmm/pull/1034)) [@jrhemstad](https://github.com/jrhemstad) +- Replace `to_device` with `DeviceBuffer.to_device` ([#1033](https://github.com/rapidsai/rmm/pull/1033)) [@wence-](https://github.com/wence-) +- Documentation Fix: Replace `cudf::logic_error` with `rmm::logic_error` ([#1021](https://github.com/rapidsai/rmm/pull/1021)) [@codereport](https://github.com/codereport) + +## 🚀 New Features + +- Add rmm::exec_policy_nosync ([#1009](https://github.com/rapidsai/rmm/pull/1009)) [@fkallen](https://github.com/fkallen) +- Callback memory resource ([#980](https://github.com/rapidsai/rmm/pull/980)) [@shwina](https://github.com/shwina) + +## 🛠️ Improvements + +- Fix conda recipes for conda compilers ([#1043](https://github.com/rapidsai/rmm/pull/1043)) [@Ethyling](https://github.com/Ethyling) +- Use new rapids-cython component of rapids-cmake to simplify builds ([#1031](https://github.com/rapidsai/rmm/pull/1031)) [@vyasr](https://github.com/vyasr) +- Merge branch-22.04 to branch-22.06 ([#1028](https://github.com/rapidsai/rmm/pull/1028)) [@jakirkham](https://github.com/jakirkham) +- Update CMake pinning to just avoid 3.23.0. ([#1023](https://github.com/rapidsai/rmm/pull/1023)) [@vyasr](https://github.com/vyasr) +- Build python using conda in GPU jobs ([#1017](https://github.com/rapidsai/rmm/pull/1017)) [@Ethyling](https://github.com/Ethyling) +- Remove pip requirements file. ([#1015](https://github.com/rapidsai/rmm/pull/1015)) [@bdice](https://github.com/bdice) +- Clean up Thrust includes. ([#1011](https://github.com/rapidsai/rmm/pull/1011)) [@bdice](https://github.com/bdice) +- Update black version ([#1010](https://github.com/rapidsai/rmm/pull/1010)) [@vyasr](https://github.com/vyasr) +- Update cmake-format version for pre-commit and environments. ([#995](https://github.com/rapidsai/rmm/pull/995)) [@vyasr](https://github.com/vyasr) +- Use conda compilers ([#977](https://github.com/rapidsai/rmm/pull/977)) [@Ethyling](https://github.com/Ethyling) +- Build conda packages using mambabuild ([#900](https://github.com/rapidsai/rmm/pull/900)) [@Ethyling](https://github.com/Ethyling) # RMM 22.04.00 (6 Apr 2022) From 7f7f9cb8a9818e210f8c1fdfe17a07aefcb9a76f Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 14 Jul 2022 09:08:37 -0700 Subject: [PATCH 133/675] Update isort to 5.10.1 (#1069) Updating isort to align with changes in cudf. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1069 --- .pre-commit-config.yaml | 2 +- conda/environments/rmm_dev_cuda11.5.yml | 2 +- conda/environments/rmm_dev_cuda11.6.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 95e63ddb1..10a6cbcd6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pycqa/isort - rev: 5.6.4 + rev: 5.10.1 hooks: - id: isort args: ["--settings-path=python/setup.cfg"] diff --git a/conda/environments/rmm_dev_cuda11.5.yml b/conda/environments/rmm_dev_cuda11.5.yml index ecfad3812..8fa5450de 100644 --- a/conda/environments/rmm_dev_cuda11.5.yml +++ b/conda/environments/rmm_dev_cuda11.5.yml @@ -9,7 +9,7 @@ dependencies: - cmakelang=0.6.13 - flake8=3.8.3 - black=22.3.0 -- isort=5.6.4 +- isort=5.10.1 - python>=3.8,<3.10 - numba>=0.49 - numpy>=1.19 diff --git a/conda/environments/rmm_dev_cuda11.6.yml b/conda/environments/rmm_dev_cuda11.6.yml index 80a28e6bc..6fc922672 100644 --- a/conda/environments/rmm_dev_cuda11.6.yml +++ b/conda/environments/rmm_dev_cuda11.6.yml @@ -9,7 +9,7 @@ dependencies: - cmakelang=0.6.13 - flake8=3.8.3 - black=22.3.0 -- isort=5.6.4 +- isort=5.10.1 - python>=3.8,<3.10 - numba>=0.49 - numpy>=1.19 From 8e5b190f32b12895f3e1a6074f492f86259e221f Mon Sep 17 00:00:00 2001 From: Ashwin Srinath <3190405+shwina@users.noreply.github.com> Date: Wed, 20 Jul 2022 06:08:02 -0400 Subject: [PATCH 134/675] Add the ability to register and unregister reinitialization hooks (#1072) This PR introduces the ability to register one or more "hooks" that will be invoked before each call to `rmm.reinitialize()`. The motivation is to allow downstream libraries to register hooks that are responsible for deleting any internal objects that that keep references to an RMM memory resource. In particular, this is useful for https://github.com/rapidsai/cudf/pull/11246. Authors: - Ashwin Srinath (https://github.com/shwina) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - https://github.com/jakirkham - Peter Andreas Entschev (https://github.com/pentschev) - Bradley Dice (https://github.com/bdice) - Lawrence Mitchell (https://github.com/wence-) URL: https://github.com/rapidsai/rmm/pull/1072 --- python/rmm/__init__.py | 2 ++ python/rmm/rmm.py | 49 +++++++++++++++++++++++++ python/rmm/tests/test_rmm.py | 69 ++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+) diff --git a/python/rmm/__init__.py b/python/rmm/__init__.py index bdb7f7c56..424bcaa35 100644 --- a/python/rmm/__init__.py +++ b/python/rmm/__init__.py @@ -22,8 +22,10 @@ RMMNumbaManager, _numba_memory_manager, is_initialized, + register_reinitialize_hook, reinitialize, rmm_cupy_allocator, + unregister_reinitialize_hook, ) __version__ = get_versions()["version"] diff --git a/python/rmm/rmm.py b/python/rmm/rmm.py index 3e99f51e2..fd46b4793 100644 --- a/python/rmm/rmm.py +++ b/python/rmm/rmm.py @@ -29,6 +29,9 @@ def __init__(self, errcode, msg): super(RMMError, self).__init__(msg) +_reinitialize_hooks = [] + + def reinitialize( pool_allocator=False, managed_memory=False, @@ -82,6 +85,9 @@ def reinitialize( Use `rmm.get_log_filenames()` to get the log file names corresponding to each device. """ + for func, args, kwargs in reversed(_reinitialize_hooks): + func(*args, **kwargs) + rmm.mr._initialize( pool_allocator=pool_allocator, managed_memory=managed_memory, @@ -231,3 +237,46 @@ def rmm_cupy_allocator(nbytes): ptr = cupy.cuda.memory.MemoryPointer(mem, 0) return ptr + + +def register_reinitialize_hook(func, *args, **kwargs): + """ + Add a function to the list of functions ("hooks") that will be + called before :py:func:`~rmm.reinitialize()`. + + A user or library may register hooks to perform any necessary + cleanup before RMM is reinitialized. For example, a library with + an internal cache of objects that use device memory allocated by + RMM can register a hook to release those references before RMM is + reinitialized, thus ensuring that the relevant device memory + resource can be deallocated. + + Hooks are called in the *reverse* order they are registered. This + is useful, for example, when a library registers multiple hooks + and needs them to run in a specific order for cleanup to be safe. + Hooks cannot rely on being registered in a particular order + relative to hooks registered by other packages, since that is + determined by package import ordering. + + Parameters + ---------- + func : callable + Function to be called before :py:func:`~rmm.reinitialize()` + args, kwargs + Positional and keyword arguments to be passed to `func` + """ + global _reinitialize_hooks + _reinitialize_hooks.append((func, args, kwargs)) + return func + + +def unregister_reinitialize_hook(func): + """ + Remove `func` from list of hooks that will be called before + :py:func:`~rmm.reinitialize()`. + + If `func` was registered more than once, every instance of it will + be removed from the list of hooks. + """ + global _reinitialize_hooks + _reinitialize_hooks = [x for x in _reinitialize_hooks if x[0] != func] diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index 94f375aec..5d5c3c18f 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -765,3 +765,72 @@ def deallocate_func(ptr, size): captured = capsys.readouterr() assert captured.out == "Allocating 256 bytes\nDeallocating 256 bytes\n" + + +@pytest.fixture +def make_reinit_hook(): + funcs = [] + + def _make_reinit_hook(func, *args, **kwargs): + funcs.append(func) + rmm.register_reinitialize_hook(func, *args, **kwargs) + return func + + yield _make_reinit_hook + for func in funcs: + rmm.unregister_reinitialize_hook(func) + + +def test_reinit_hooks_register(make_reinit_hook): + L = [] + make_reinit_hook(lambda: L.append(1)) + make_reinit_hook(lambda: L.append(2)) + make_reinit_hook(lambda x: L.append(x), 3) + + rmm.reinitialize() + assert L == [3, 2, 1] + + +def test_reinit_hooks_unregister(make_reinit_hook): + L = [] + one = make_reinit_hook(lambda: L.append(1)) + make_reinit_hook(lambda: L.append(2)) + + rmm.unregister_reinitialize_hook(one) + rmm.reinitialize() + assert L == [2] + + +def test_reinit_hooks_register_twice(make_reinit_hook): + L = [] + + def func_with_arg(x): + L.append(x) + + def func_without_arg(): + L.append(2) + + make_reinit_hook(func_with_arg, 1) + make_reinit_hook(func_without_arg) + make_reinit_hook(func_with_arg, 3) + make_reinit_hook(func_without_arg) + + rmm.reinitialize() + assert L == [2, 3, 2, 1] + + +def test_reinit_hooks_unregister_twice_registered(make_reinit_hook): + # unregistering a twice-registered function + # should unregister both instances: + L = [] + + def func_with_arg(x): + L.append(x) + + make_reinit_hook(func_with_arg, 1) + make_reinit_hook(lambda: L.append(2)) + make_reinit_hook(func_with_arg, 3) + + rmm.unregister_reinitialize_hook(func_with_arg) + rmm.reinitialize() + assert L == [2] From 721c50fab74c6801fcf8aae69f5c3ebe2eba9aa1 Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Fri, 22 Jul 2022 10:48:51 -0400 Subject: [PATCH 135/675] DOC --- CHANGELOG.md | 4 ++++ CMakeLists.txt | 4 ++-- doxygen/Doxyfile | 2 +- python/CMakeLists.txt | 4 ++-- python/docs/conf.py | 6 +++--- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21c0a1d9b..4126147fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# RMM 22.10.00 (Date TBD) + +Please see https://github.com/rapidsai/rmm/releases/tag/v22.10.00a for the latest changes to this development branch. + # RMM 22.08.00 (Date TBD) Please see https://github.com/rapidsai/rmm/releases/tag/v22.08.00a for the latest changes to this development branch. diff --git a/CMakeLists.txt b/CMakeLists.txt index 23cde1de6..944fdbca1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.08/RAPIDS.cmake +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.10/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) @@ -25,7 +25,7 @@ include(rapids-find) project( RMM - VERSION 22.08.00 + VERSION 22.10.00 LANGUAGES CXX) # Write the version header diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 7f7a53ab9..4a81ac006 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "RMM" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 22.08 +PROJECT_NUMBER = 22.10 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 3be640f45..40bcc0955 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -14,9 +14,9 @@ cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) -set(rmm_version 22.08.00) +set(rmm_version 22.10.00) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.08/RAPIDS.cmake +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.10/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) diff --git a/python/docs/conf.py b/python/docs/conf.py index ebb24dbf3..c661135c4 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -19,7 +19,7 @@ author = "NVIDIA" # The full version, including alpha/beta/rc tags -release = "22.08.00" +release = "22.10.00" # -- General configuration --------------------------------------------------- @@ -69,9 +69,9 @@ # built documents. # # The short X.Y version. -version = "22.08" +version = "22.10" # The full version, including alpha/beta/rc tags. -release = "22.08.00" +release = "22.10.00" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. From 594070fb0e7547f35584f1a7ca2e442244d5a0a9 Mon Sep 17 00:00:00 2001 From: GALI PREM SAGAR Date: Tue, 2 Aug 2022 13:53:14 -0500 Subject: [PATCH 136/675] Centralize common css & js code in docs (#1075) This PR will utilize the common css & js code being merged here: https://github.com/rapidsai/docs/pull/286 Authors: - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1075 --- doxygen/Doxyfile | 324 +++++++++++++++++++++++++++++--------------- doxygen/header.html | 62 +++++++++ 2 files changed, 274 insertions(+), 112 deletions(-) create mode 100644 doxygen/header.html diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 7f7a53ab9..2dfc37421 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -1,4 +1,4 @@ -# Doxyfile 1.8.11 +# Doxyfile 1.8.20 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -17,11 +17,11 @@ # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv -# for the list of possible encodings. +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. # The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 @@ -93,6 +93,14 @@ ALLOW_UNICODE_NAMES = NO OUTPUT_LANGUAGE = English +# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all generated output in the proper direction. +# Possible values are: None, LTR, RTL and Context. +# The default value is: None. + +OUTPUT_TEXT_DIRECTION = None + # If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member # descriptions after the members that are listed in the file and class # documentation (similar to Javadoc). Set to NO to disable this. @@ -179,6 +187,16 @@ SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If # set to NO, the Qt-style will behave just like regular Qt-style comments (thus @@ -199,6 +217,14 @@ QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. @@ -226,16 +252,15 @@ TAB_SIZE = 4 # will allow you to put the command \sideeffect (or @sideeffect) in the # documentation, which will result in a user-defined paragraph with heading # "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines. +# newlines (in the resulting output). You can put ^^ in the value part of an +# alias to insert a newline as if a physical newline was in the original file. +# When you need a literal { or } or , in the value part of an alias you have to +# escape them by means of a backslash (\), this can lead to conflicts with the +# commands \{ and \} for these it is advised to use the version @{ and @} or use +# a double escape (\\{ and \\}) ALIASES = -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = - # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For # instance, some of the names that are used will be different. The list of all @@ -264,28 +289,38 @@ OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: -# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: -# Fortran. In the later case the parser tries to guess whether the code is fixed -# or free formatted code, this is the default for Fortran type files), VHDL. For -# instance to make doxygen treat .inc files as Fortran files (default is PHP), -# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL, +# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. # # Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise # the files are not read by doxygen. -EXTENSION_MAPPING = cu=C++ cuh=C++ +EXTENSION_MAPPING = cu=C++ \ + cuh=C++ # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. +# documentation. See https://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you can # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in # case of backward compatibilities issues. @@ -293,6 +328,15 @@ EXTENSION_MAPPING = cu=C++ cuh=C++ MARKDOWN_SUPPORT = YES +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can # be prevented in individual cases by putting a % sign in front of the word or @@ -318,7 +362,7 @@ BUILTIN_STL_SUPPORT = NO CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. @@ -404,6 +448,19 @@ TYPEDEF_HIDES_STRUCT = NO LOOKUP_CACHE_SIZE = 0 +# The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which efficively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- @@ -424,6 +481,12 @@ EXTRACT_ALL = NO EXTRACT_PRIVATE = NO +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. # The default value is: NO. @@ -478,8 +541,8 @@ HIDE_UNDOC_MEMBERS = NO HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO, these declarations will be -# included in the documentation. +# declarations. If set to NO, these declarations will be included in the +# documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO @@ -502,7 +565,7 @@ INTERNAL_DOCS = NO # names in lower-case letters. If set to YES, upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. +# (including Cygwin) and Mac users are advised to set this option to NO. # The default value is: system dependent. CASE_SENSE_NAMES = YES @@ -689,7 +752,7 @@ LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. @@ -734,7 +797,8 @@ WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return # value. If set to NO, doxygen will only warn about wrong or incomplete -# parameter documentation, but not about the absence of documentation. +# parameter documentation, but not about the absence of documentation. If +# EXTRACT_ALL is set to YES then this flag will automatically be disabled. # The default value is: NO. WARN_NO_PARAMDOC = YES @@ -771,12 +835,13 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = ../src ../include +INPUT = ../src \ + ../include # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: http://www.gnu.org/software/libiconv) for the list of +# documentation (see: https://www.gnu.org/software/libiconv/) for the list of # possible encodings. # The default value is: UTF-8. @@ -793,10 +858,17 @@ INPUT_ENCODING = UTF-8 # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, -# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f, *.for, *.tcl, -# *.vhd, *.vhdl, *.ucf, *.qsf, *.as and *.js. - -FILE_PATTERNS = *.c *.cpp *.h *.hpp *.cu *.cuh +# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment), +# *.doc (to be provided as doxygen C comment), *.txt (to be provided as doxygen +# C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, +# *.vhdl, *.ucf, *.qsf and *.ice. + +FILE_PATTERNS = *.c \ + *.cpp \ + *.h \ + *.hpp \ + *.cu \ + *.cuh # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. @@ -838,7 +910,7 @@ EXCLUDE_PATTERNS = # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or directories # that contain example code fragments that are included (see the \include @@ -949,7 +1021,7 @@ INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. +# entity all documented functions referencing it will be listed. # The default value is: NO. REFERENCED_BY_RELATION = NO @@ -981,12 +1053,12 @@ SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system -# (see http://www.gnu.org/software/global/global.html). You will need version +# (see https://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: # - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file # - Make sure the INPUT points to the root of the source tree # - Run doxygen as normal # @@ -1008,25 +1080,6 @@ USE_HTAGS = NO VERBATIM_HEADERS = YES -# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the -# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the -# cost of reduced performance. This can be particularly helpful with template -# rich C++ code for which doxygen's built-in parser lacks the necessary type -# information. -# Note: The availability of this option depends on whether or not doxygen was -# generated with the -Duse-libclang=ON option for CMake. -# The default value is: NO. - -CLANG_ASSISTED_PARSING = NO - -# If clang assisted parsing is enabled you can provide the compiler with command -# line options that you would normally use when invoking the compiler. Note that -# the include paths will already be set by doxygen for the files and directories -# specified with INPUT and INCLUDE_PATH. -# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. - -CLANG_OPTIONS = - #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- @@ -1095,7 +1148,7 @@ HTML_FILE_EXTENSION = .html # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_HEADER = +HTML_HEADER = header.html # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard @@ -1145,7 +1198,7 @@ HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to # this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. @@ -1181,6 +1234,17 @@ HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = NO +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. @@ -1204,13 +1268,13 @@ HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a +# environment (see: https://developer.apple.com/xcode/), introduced with OSX +# 10.5 (Leopard). To create a documentation set, doxygen will generate a # Makefile in the HTML output directory. Running make will produce the docset in # that directory and running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1249,7 +1313,7 @@ DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# (see: https://www.microsoft.com/en-us/download/details.aspx?id=21138) on # Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output @@ -1280,7 +1344,7 @@ CHM_FILE = HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated -# (YES) or that it should be included in the master .chm file (NO). +# (YES) or that it should be included in the main .chm file (NO). # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. @@ -1325,7 +1389,7 @@ QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace -# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1333,7 +1397,7 @@ QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- +# Folders (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual- # folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1342,7 +1406,7 @@ QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1350,7 +1414,7 @@ QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- # filters). # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1358,7 +1422,7 @@ QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_SECT_FILTER_ATTRS = @@ -1442,6 +1506,17 @@ TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + # Use this tag to change the font size of LaTeX formulas included as images in # the HTML documentation. When you change the font size after a successful # doxygen run you need to manually remove any form_*.png images from the HTML @@ -1451,7 +1526,7 @@ EXT_LINKS_IN_WINDOW = NO FORMULA_FONTSIZE = 10 -# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# Use the FORMULA_TRANSPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are not # supported properly for IE 6.0, but are supported on all modern browsers. # @@ -1462,8 +1537,14 @@ FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering +# https://www.mathjax.org) which uses client side JavaScript for the rendering # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path @@ -1490,8 +1571,8 @@ MATHJAX_FORMAT = HTML-CSS # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. +# MathJax from https://www.mathjax.org before deployment. +# The default value is: https://cdn.jsdelivr.net/npm/mathjax@2. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest @@ -1533,7 +1614,7 @@ MATHJAX_CODEFILE = SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a web server instead of a web client using Javascript. There +# implemented using a web server instead of a web client using JavaScript. There # are two flavors of web server based searching depending on the EXTERNAL_SEARCH # setting. When disabled, doxygen will generate a PHP script for searching and # an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing @@ -1552,7 +1633,7 @@ SERVER_BASED_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). +# Xapian (see: https://xapian.org/). # # See the section "External Indexing and Searching" for details. # The default value is: NO. @@ -1565,7 +1646,7 @@ EXTERNAL_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). See the section "External Indexing and +# Xapian (see: https://xapian.org/). See the section "External Indexing and # Searching" for details. # This tag requires that the tag SEARCHENGINE is set to YES. @@ -1617,21 +1698,35 @@ LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. # -# Note that when enabling USE_PDFLATEX this option is only used for generating -# bitmaps for formulas in the HTML output, but not in the Makefile that is -# written to the output directory. -# The default file is: latex. +# Note that when not enabling USE_PDFLATEX the default is latex when enabling +# USE_PDFLATEX the default is pdflatex and when in the later case latex is +# chosen this is overwritten by pdflatex. For specific output languages the +# default can have been set differently, this depends on the implementation of +# the output language. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate # index for LaTeX. +# Note: This tag is used in the Makefile / make.bat. +# See also: LATEX_MAKEINDEX_CMD for the part in the generated output file +# (.tex). # The default file is: makeindex. # This tag requires that the tag GENERATE_LATEX is set to YES. MAKEINDEX_CMD_NAME = makeindex +# The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to +# generate index for LaTeX. In case there is no backslash (\) as first character +# it will be automatically added in the LaTeX code. +# Note: This tag is used in the generated output file (.tex). +# See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat. +# The default value is: makeindex. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_MAKEINDEX_CMD = makeindex + # If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX # documents. This may be useful for small projects and may help to save some # trees in general. @@ -1716,9 +1811,11 @@ LATEX_EXTRA_FILES = PDF_HYPERLINKS = YES -# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate -# the PDF file directly from the LaTeX files. Set this option to YES, to get a -# higher quality PDF documentation. +# If the USE_PDFLATEX tag is set to YES, doxygen will use the engine as +# specified with LATEX_CMD_NAME to generate the PDF file directly from the LaTeX +# files. Set this option to YES, to get a higher quality PDF documentation. +# +# See also section LATEX_CMD_NAME for selecting the engine. # The default value is: YES. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1752,7 +1849,7 @@ LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. See -# http://en.wikipedia.org/wiki/BibTeX and \cite for more info. +# https://en.wikipedia.org/wiki/BibTeX and \cite for more info. # The default value is: plain. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1766,6 +1863,14 @@ LATEX_BIB_STYLE = plain LATEX_TIMESTAMP = NO +# The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute) +# path from which the emoji images will be read. If a relative path is entered, +# it will be relative to the LATEX_OUTPUT directory. If left blank the +# LATEX_OUTPUT directory will be used. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_EMOJI_DIRECTORY = + #--------------------------------------------------------------------------- # Configuration options related to the RTF output #--------------------------------------------------------------------------- @@ -1805,9 +1910,9 @@ COMPACT_RTF = NO RTF_HYPERLINKS = NO -# Load stylesheet definitions from file. Syntax is similar to doxygen's config -# file, i.e. a series of assignments. You only have to provide replacements, -# missing definitions are set to their default value. +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# configuration file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. # # See also section "Doxygen usage" for information on how to generate the # default style sheet that doxygen normally uses. @@ -1816,8 +1921,8 @@ RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an RTF document. Syntax is -# similar to doxygen's config file. A template extensions file can be generated -# using doxygen -e rtf extensionFile. +# similar to doxygen's configuration file. A template extensions file can be +# generated using doxygen -e rtf extensionFile. # This tag requires that the tag GENERATE_RTF is set to YES. RTF_EXTENSIONS_FILE = @@ -1903,6 +2008,13 @@ XML_OUTPUT = xml XML_PROGRAMLISTING = YES +# If the XML_NS_MEMB_FILE_SCOPE tag is set to YES, doxygen will include +# namespace members in file scope as well, matching the HTML output. +# The default value is: NO. +# This tag requires that the tag GENERATE_XML is set to YES. + +XML_NS_MEMB_FILE_SCOPE = NO + #--------------------------------------------------------------------------- # Configuration options related to the DOCBOOK output #--------------------------------------------------------------------------- @@ -1935,9 +2047,9 @@ DOCBOOK_PROGRAMLISTING = NO #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an -# AutoGen Definitions (see http://autogen.sf.net) file that captures the -# structure of the code including all documentation. Note that this feature is -# still experimental and incomplete at the moment. +# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures +# the structure of the code including all documentation. Note that this feature +# is still experimental and incomplete at the moment. # The default value is: NO. GENERATE_AUTOGEN_DEF = NO @@ -2104,12 +2216,6 @@ EXTERNAL_GROUPS = YES EXTERNAL_PAGES = YES -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of 'which perl'). -# The default file (with absolute path) is: /usr/bin/perl. - -PERL_PATH = /usr/bin/perl - #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- @@ -2123,15 +2229,6 @@ PERL_PATH = /usr/bin/perl CLASS_DIAGRAMS = YES -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see: -# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - # You can include diagrams made with dia in doxygen documentation. Doxygen will # then run dia to produce the diagram and insert it in the documentation. The # DIA_PATH tag allows you to specify the directory where the dia binary resides. @@ -2150,7 +2247,7 @@ HIDE_UNDOC_RELATIONS = YES # http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent # Bell Labs. The other options in this section have no effect if this option is # set to NO -# The default value is: YES. +# The default value is: NO. HAVE_DOT = YES @@ -2306,9 +2403,7 @@ DIRECTORY_GRAPH = YES # Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order # to make the SVG files visible in IE 9+ (other browsers do not have this # requirement). -# Possible values are: png, png:cairo, png:cairo:cairo, png:cairo:gd, png:gd, -# png:gd:gd, jpg, jpg:cairo, jpg:cairo:gd, jpg:gd, jpg:gd:gd, gif, gif:cairo, -# gif:cairo:gd, gif:gd, gif:gd:gd, svg, png:gd, png:gd:gd, png:cairo, +# Possible values are: png, jpg, gif, svg, png:gd, png:gd:gd, png:cairo, # png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and # png:gdiplus:gdiplus. # The default value is: png. @@ -2361,6 +2456,11 @@ DIAFILE_DIRS = PLANTUML_JAR_PATH = +# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a +# configuration file for plantuml. + +PLANTUML_CFG_FILE = + # When using plantuml, the specified paths are searched for files specified by # the !include statement in a plantuml block. diff --git a/doxygen/header.html b/doxygen/header.html new file mode 100644 index 000000000..579d7829e --- /dev/null +++ b/doxygen/header.html @@ -0,0 +1,62 @@ + + + + + + + + +$projectname: $title +$title + + + +$treeview +$search +$mathjax + +$extrastylesheet + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
+
$projectname +  $projectnumber +
+
$projectbrief
+
+
$projectbrief
+
$searchbox
+
+ + From 1acfed7a69ffd1b242b212b8017e61058e4300ae Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 4 Aug 2022 07:23:10 -0700 Subject: [PATCH 137/675] Simplify PR template. (#1080) Simplifies PR template to match recent updates for cuDF, cuSpatial. See https://github.com/rapidsai/cudf/pull/10774, https://github.com/rapidsai/cuspatial/pull/617. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) - Jake Hemstad (https://github.com/jrhemstad) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1080 --- .github/PULL_REQUEST_TEMPLATE.md | 58 +++++--------------------------- 1 file changed, 9 insertions(+), 49 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 271cfc2ea..a16c8da96 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,49 +1,9 @@ - +## Description + + + + +## Checklist +- [ ] I am familiar with the [Contributing Guidelines](https://github.com/rapidsai/rmm/blob/HEAD/CONTRIBUTING.md). +- [ ] New or existing tests cover these changes. +- [ ] The documentation is up to date with these changes. From b70ceea08281f366378339ee907bcc7e79d13d73 Mon Sep 17 00:00:00 2001 From: GALI PREM SAGAR Date: Thu, 4 Aug 2022 14:34:59 -0500 Subject: [PATCH 138/675] switch to common js file and defer load it (#1081) This PR switches docs to use the custom common js code merged here: https://github.com/rapidsai/docs/pull/286 Authors: - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - Bradley Dice (https://github.com/bdice) - AJ Schmidt (https://github.com/ajschmidt8) --- python/docs/conf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/docs/conf.py b/python/docs/conf.py index ebb24dbf3..8effe7922 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -199,5 +199,7 @@ def setup(app): app.add_js_file("copybutton_pydocs.js") - app.add_css_file("params.css") app.add_css_file("https://docs.rapids.ai/assets/css/custom.css") + app.add_js_file( + "https://docs.rapids.ai/assets/js/custom.js", loading_method="defer" + ) From d3b1dfbeb55615df2cf1e5b6daae0f0ad6335a65 Mon Sep 17 00:00:00 2001 From: Tobias Ribizel Date: Sat, 6 Aug 2022 04:07:24 +0200 Subject: [PATCH 139/675] Add device_uvector::reserve and device_buffer::reserve (#1079) I am building a parser that outputs variable-sized blocks of data. To collect them, I would like to use pre-allocated `device_uvector`s, using `size()` to keep track of how much memory is already in use. Setting the capacity and size manually works at the moment by calling `vec.resize(capacity, stream); vec.resize(size, stream);` on an empty vector, but this seems unnecessarily complicated. Since `device_uvector` otherwise already closely matches the `std::vector` interface, I want to propose adding `reserve` to the interface. TODO: - [x] Add to Python interface Authors: - Tobias Ribizel (https://github.com/upsj) Approvers: - Jake Hemstad (https://github.com/jrhemstad) - Bradley Dice (https://github.com/bdice) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1079 --- include/rmm/device_buffer.hpp | 42 ++++++++++++++++++++++++------ include/rmm/device_uvector.hpp | 19 +++++++++++++- python/rmm/_lib/device_buffer.pxd | 2 ++ python/rmm/_lib/device_buffer.pyx | 5 ++++ python/rmm/_lib/device_uvector.pxd | 1 + tests/device_buffer_tests.cu | 25 ++++++++++++++++++ tests/device_uvector_tests.cpp | 36 +++++++++++++++++++++++++ 7 files changed, 121 insertions(+), 9 deletions(-) diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index 497d2cffe..d571e9304 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -236,6 +236,36 @@ class device_buffer { _stream = cuda_stream_view{}; } + /** + * @brief Increase the capacity of the device memory allocation + * + * If the requested `new_capacity` is less than or equal to `capacity()`, no + * action is taken. + * + * If `new_capacity` is larger than `capacity()`, a new allocation is made on + * `stream` to satisfy `new_capacity`, and the contents of the old allocation are + * copied on `stream` to the new allocation. The old allocation is then freed. + * The bytes from `[size(), new_capacity)` are uninitialized. + * + * @throws rmm::bad_alloc If creating the new allocation fails + * @throws rmm::cuda_error if the copy from the old to new allocation + * fails + * + * @param new_capacity The requested new capacity, in bytes + * @param stream The stream to use for allocation and copy + */ + void reserve(std::size_t new_capacity, cuda_stream_view stream) + { + set_stream(stream); + if (new_capacity > capacity()) { + auto tmp = device_buffer{new_capacity, stream, _mr}; + auto const old_size = size(); + RMM_CUDA_TRY(cudaMemcpyAsync(tmp.data(), data(), size(), cudaMemcpyDefault, stream.value())); + *this = std::move(tmp); + _size = old_size; + } + } + /** * @brief Resize the device memory allocation * @@ -256,7 +286,7 @@ class device_buffer { * * @throws rmm::bad_alloc If creating the new allocation fails * @throws rmm::cuda_error if the copy from the old to new allocation - *fails + * fails * * @param new_size The requested new size, in bytes * @param stream The stream to use for allocation and copy @@ -269,13 +299,9 @@ class device_buffer { if (new_size <= capacity()) { _size = new_size; } else { - void* const new_data = _mr->allocate(new_size, this->stream()); - RMM_CUDA_TRY( - cudaMemcpyAsync(new_data, data(), size(), cudaMemcpyDefault, this->stream().value())); - deallocate_async(); - _data = new_data; - _size = new_size; - _capacity = new_size; + auto tmp = device_buffer{new_size, stream, _mr}; + RMM_CUDA_TRY(cudaMemcpyAsync(tmp.data(), data(), size(), cudaMemcpyDefault, stream.value())); + *this = std::move(tmp); } } diff --git a/include/rmm/device_uvector.hpp b/include/rmm/device_uvector.hpp index bbc36c432..93abfa7a7 100644 --- a/include/rmm/device_uvector.hpp +++ b/include/rmm/device_uvector.hpp @@ -351,6 +351,23 @@ class device_uvector { return element(size() - 1, stream); } + /** + * @brief Increases the capacity of the vector to `new_capacity` elements. + * + * If `new_capacity <= capacity()`, no action is taken. + * + * If `new_capacity > capacity()`, a new allocation of size `new_capacity` is created, and the + * first `size()` elements from the current allocation are copied there as if by memcpy. Finally, + * the old allocation is freed and replaced by the new allocation. + * + * @param new_capacity The desired capacity (number of elements) + * @param stream The stream on which to perform the allocation/copy (if any) + */ + void reserve(std::size_t new_capacity, cuda_stream_view stream) + { + _storage.reserve(elements_to_bytes(new_capacity), stream); + } + /** * @brief Resizes the vector to contain `new_size` elements. * @@ -360,7 +377,7 @@ class device_uvector { * memory is allocated nor copied. `shrink_to_fit()` may be used to force deallocation of unused * memory. * - * If `new_size > capacity()`, elements are copied as if by mempcy to a new allocation. + * If `new_size > capacity()`, elements are copied as if by memcpy to a new allocation. * * The invariant `size() <= capacity()` holds. * diff --git a/python/rmm/_lib/device_buffer.pxd b/python/rmm/_lib/device_buffer.pxd index 635b1ed8a..fee6b126a 100644 --- a/python/rmm/_lib/device_buffer.pxd +++ b/python/rmm/_lib/device_buffer.pxd @@ -26,6 +26,7 @@ cdef extern from "rmm/device_buffer.hpp" namespace "rmm" nogil: device_buffer(size_t size, cuda_stream_view stream) except + device_buffer(const void* source_data, size_t size, cuda_stream_view stream) except + + void reserve(size_t new_capacity, cuda_stream_view stream) except + void resize(size_t new_size, cuda_stream_view stream) except + void shrink_to_fit(cuda_stream_view stream) except + void* data() @@ -57,6 +58,7 @@ cdef class DeviceBuffer: cpdef bytes tobytes(self, Stream stream=*) cdef size_t c_size(self) except * + cpdef void reserve(self, size_t new_capacity, Stream stream=*) except * cpdef void resize(self, size_t new_size, Stream stream=*) except * cpdef size_t capacity(self) except * cdef void* c_data(self) except * diff --git a/python/rmm/_lib/device_buffer.pyx b/python/rmm/_lib/device_buffer.pyx index d33198315..7607cd41f 100644 --- a/python/rmm/_lib/device_buffer.pyx +++ b/python/rmm/_lib/device_buffer.pyx @@ -288,6 +288,11 @@ cdef class DeviceBuffer: cdef size_t c_size(self) except *: return self.c_obj.get()[0].size() + cpdef void reserve(self, + size_t new_capacity, + Stream stream=DEFAULT_STREAM) except *: + self.c_obj.get()[0].reserve(new_capacity, stream.view()) + cpdef void resize(self, size_t new_size, Stream stream=DEFAULT_STREAM) except *: diff --git a/python/rmm/_lib/device_uvector.pxd b/python/rmm/_lib/device_uvector.pxd index 582f19fe7..29e122bbf 100644 --- a/python/rmm/_lib/device_uvector.pxd +++ b/python/rmm/_lib/device_uvector.pxd @@ -29,6 +29,7 @@ cdef extern from "rmm/device_buffer.hpp" namespace "rmm" nogil: ) except + T front_element(cuda_stream_view s) except + T back_element(cuda_stream_view s) except + + void reserve(size_t new_capacity, cuda_stream_view stream) except + void resize(size_t new_size, cuda_stream_view stream) except + void shrink_to_fit(cuda_stream_view stream) except + device_buffer release() diff --git a/tests/device_buffer_tests.cu b/tests/device_buffer_tests.cu index 9cab76323..4c25e2afb 100644 --- a/tests/device_buffer_tests.cu +++ b/tests/device_buffer_tests.cu @@ -458,6 +458,31 @@ TYPED_TEST(DeviceBufferTest, ResizeBigger) EXPECT_NE(old_data, buff.data()); } +TYPED_TEST(DeviceBufferTest, ReserveSmaller) +{ + rmm::device_buffer buff(this->size, rmm::cuda_stream_default, &this->mr); + auto* const old_data = buff.data(); + auto const old_capacity = buff.capacity(); + auto const new_capacity = buff.capacity() - 1; + buff.reserve(new_capacity, rmm::cuda_stream_default); + EXPECT_EQ(this->size, buff.size()); + EXPECT_EQ(old_capacity, buff.capacity()); + // Reserving smaller means the allocation is unchanged + EXPECT_EQ(old_data, buff.data()); +} + +TYPED_TEST(DeviceBufferTest, ReserveBigger) +{ + rmm::device_buffer buff(this->size, rmm::cuda_stream_default, &this->mr); + auto* const old_data = buff.data(); + auto const new_capacity = buff.capacity() + 1; + buff.reserve(new_capacity, rmm::cuda_stream_default); + EXPECT_EQ(this->size, buff.size()); + EXPECT_EQ(new_capacity, buff.capacity()); + // Reserving bigger means the data should point to a new allocation + EXPECT_NE(old_data, buff.data()); +} + TYPED_TEST(DeviceBufferTest, SetGetStream) { rmm::device_buffer buff(this->size, rmm::cuda_stream_default, &this->mr); diff --git a/tests/device_uvector_tests.cpp b/tests/device_uvector_tests.cpp index c1505bc0a..69d89e305 100644 --- a/tests/device_uvector_tests.cpp +++ b/tests/device_uvector_tests.cpp @@ -119,6 +119,42 @@ TYPED_TEST(TypedUVectorTest, ResizeLarger) EXPECT_EQ(vec.begin(), larger_begin); } +TYPED_TEST(TypedUVectorTest, ReserveSmaller) +{ + auto const original_size{12345}; + rmm::device_uvector vec(original_size, this->stream()); + auto* const original_data = vec.data(); + auto* const original_begin = vec.begin(); + auto const original_capacity = vec.capacity(); + + auto const smaller_capacity = vec.capacity() - 1; + vec.reserve(smaller_capacity, this->stream()); + + EXPECT_EQ(vec.data(), original_data); + EXPECT_EQ(vec.begin(), original_begin); + EXPECT_EQ(vec.size(), original_size); + EXPECT_EQ(vec.capacity(), original_capacity); +} + +TYPED_TEST(TypedUVectorTest, ReserveLarger) +{ + auto const original_size{12345}; + rmm::device_uvector vec(original_size, this->stream()); + vec.set_element(0, 1, this->stream()); + auto* const original_data = vec.data(); + auto* const original_begin = vec.begin(); + + auto const larger_capacity = vec.capacity() + 1; + vec.reserve(larger_capacity, this->stream()); + + EXPECT_NE(vec.data(), original_data); + EXPECT_NE(vec.begin(), original_begin); + EXPECT_EQ(vec.size(), original_size); + EXPECT_EQ(vec.capacity(), larger_capacity); + // The element should be copied + EXPECT_EQ(vec.element(0, this->stream()), 1); +} + TYPED_TEST(TypedUVectorTest, ResizeToZero) { auto const original_size{12345}; From 457ece7971288bdfbb8dc2d2465218ed9d24f4b4 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 9 Aug 2022 12:36:40 -0400 Subject: [PATCH 140/675] Use rapids-cmake 22.10 best practice for RAPIDS.cmake location (#1083) Removes possibility of another projects RAPIDS.cmake being used, and removes need to always download a version. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1083 --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 944fdbca1..ce246596e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,9 +14,11 @@ cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.10/RAPIDS.cmake - ${CMAKE_BINARY_DIR}/RAPIDS.cmake) -include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) +if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.10/RAPIDS.cmake + ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) +endif() +include(${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) include(rapids-cmake) include(rapids-cpm) From 03013f337496790ae8ff41c8aff4f5c975a8f9db Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Sat, 13 Aug 2022 17:12:48 -0500 Subject: [PATCH 141/675] Add resources section to README. (#1085) This PR adds a "Resources" section similar to the RMM README, similar to what I did in cuDF some time ago. My primary reason for adding this is to have a quick link to the RMM documentation. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1085 --- README.md | 120 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 68 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index ddb393f53..e6f0d914a 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,23 @@ [![Build Status](https://gpuci.gpuopenanalytics.com/job/rapidsai/job/gpuci/job/rmm/job/branches/job/rmm-branch-pipeline/badge/icon)](https://gpuci.gpuopenanalytics.com/job/rapidsai/job/gpuci/job/rmm/job/branches/job/rmm-branch-pipeline/) +**NOTE:** For the latest stable [README.md](https://github.com/rapidsai/rmm/blob/main/README.md) ensure you are on the `main` branch. + +## Resources + +- [RMM Reference Documentation](https://docs.rapids.ai/api/rmm/stable/): Python API reference, tutorials, and topic guides. +- [librmm Reference Documentation](https://docs.rapids.ai/api/librmm/stable/): C/C++ CUDA library API reference. +- [Getting Started](https://rapids.ai/start.html): Instructions for installing RMM. +- [RAPIDS Community](https://rapids.ai/community.html): Get help, contribute, and collaborate. +- [GitHub repository](https://github.com/rapidsai/rmm): Download the RMM source code. +- [Issue tracker](https://github.com/rapidsai/rmm/issues): Report issues or request features. + +## Overview Achieving optimal performance in GPU-centric workflows frequently requires customizing how host and device memory are allocated. For example, using "pinned" host memory for asynchronous host <-> device memory transfers, or using a device memory pool sub-allocator to reduce the cost of -dynamic device memory allocation. +dynamic device memory allocation. The goal of the RAPIDS Memory Manager (RMM) is to provide: - A common interface that allows customizing [device](#device_memory_resource) and @@ -17,8 +29,7 @@ The goal of the RAPIDS Memory Manager (RMM) is to provide: For information on the interface RMM provides and how to use RMM in your C++ code, see [below](#using-rmm-in-c). -**NOTE:** For the latest stable [README.md](https://github.com/rapidsai/rmm/blob/main/README.md) -ensure you are on the `main` branch. +For a walkthrough about the design of the RAPIDS Memory Manager, read [Fast, Flexible Allocation for NVIDIA CUDA with RAPIDS Memory Manager](https://developer.nvidia.com/blog/fast-flexible-allocation-for-cuda-with-rapids-memory-manager/) on the NVIDIA Developer Blog. ## Installation @@ -164,7 +175,7 @@ Thrust. If you want to customize it, you can set the variables # Using RMM in C++ -The first goal of RMM is to provide a common interface for device and host memory allocation. +The first goal of RMM is to provide a common interface for device and host memory allocation. This allows both _users_ and _implementers_ of custom allocation logic to program to a single interface. @@ -187,15 +198,15 @@ It has two key functions: - Returns a pointer to an allocation of at least `bytes` bytes. 2. `void device_memory_resource::deallocate(void* p, std::size_t bytes, cuda_stream_view s)` - - Reclaims a previous allocation of size `bytes` pointed to by `p`. + - Reclaims a previous allocation of size `bytes` pointed to by `p`. - `p` *must* have been returned by a previous call to `allocate(bytes)`, otherwise behavior is undefined It is up to a derived class to provide implementations of these functions. See -[available resources](#available-resources) for example `device_memory_resource` derived classes. +[available resources](#available-resources) for example `device_memory_resource` derived classes. -Unlike `std::pmr::memory_resource`, `rmm::mr::device_memory_resource` does not allow specifying an -alignment argument. All allocations are required to be aligned to at least 256B. Furthermore, +Unlike `std::pmr::memory_resource`, `rmm::mr::device_memory_resource` does not allow specifying an +alignment argument. All allocations are required to be aligned to at least 256B. Furthermore, `device_memory_resource` adds an additional `cuda_stream_view` argument to allow specifying the stream on which to perform the (de)allocation. @@ -203,26 +214,26 @@ on which to perform the (de)allocation. `rmm::cuda_stream_view` is a simple non-owning wrapper around a CUDA `cudaStream_t`. This wrapper's purpose is to provide strong type safety for stream types. (`cudaStream_t` is an alias for a pointer, -which can lead to ambiguity in APIs when it is assigned `0`.) All RMM stream-ordered APIs take a +which can lead to ambiguity in APIs when it is assigned `0`.) All RMM stream-ordered APIs take a `rmm::cuda_stream_view` argument. -`rmm::cuda_stream` is a simple owning wrapper around a CUDA `cudaStream_t`. This class provides +`rmm::cuda_stream` is a simple owning wrapper around a CUDA `cudaStream_t`. This class provides RAII semantics (constructor creates the CUDA stream, destructor destroys it). An `rmm::cuda_stream` can never represent the CUDA default stream or per-thread default stream; it only ever represents a single non-default stream. `rmm::cuda_stream` cannot be copied, but can be moved. ## `cuda_stream_pool` -`rmm::cuda_stream_pool` provides fast access to a pool of CUDA streams. This class can be used to -create a set of `cuda_stream` objects whose lifetime is equal to the `cuda_stream_pool`. Using the +`rmm::cuda_stream_pool` provides fast access to a pool of CUDA streams. This class can be used to +create a set of `cuda_stream` objects whose lifetime is equal to the `cuda_stream_pool`. Using the stream pool can be faster than creating the streams on the fly. The size of the pool is configurable. -Depending on this size, multiple calls to `cuda_stream_pool::get_stream()` may return instances of +Depending on this size, multiple calls to `cuda_stream_pool::get_stream()` may return instances of `rmm::cuda_stream_view` that represent identical CUDA streams. ### Thread Safety All current device memory resources are thread safe unless documented otherwise. More specifically, -calls to memory resource `allocate()` and `deallocate()` methods are safe with respect to calls to +calls to memory resource `allocate()` and `deallocate()` methods are safe with respect to calls to either of these functions from other threads. They are _not_ thread safe with respect to construction and destruction of the memory resource object. @@ -248,7 +259,7 @@ used internally by a `device_memory_resource` for managing available memory with synchronization, and it may also be synchronized at a later time, for example using a call to `cudaStreamSynchronize()`. -For this reason, it is Undefined Behavior to destroy a CUDA stream that is passed to +For this reason, it is Undefined Behavior to destroy a CUDA stream that is passed to `device_memory_resource::deallocate`. If the stream on which the allocation was last used has been destroyed before calling `deallocate` or it is known that it will be destroyed, it is likely better to synchronize the stream (before destroying it) and then pass a different stream to `deallocate` @@ -257,6 +268,11 @@ to synchronize the stream (before destroying it) and then pass a different strea Note that device memory data structures such as `rmm::device_buffer` and `rmm::device_uvector` follow these stream-ordered memory allocation semantics and rules. +For further information about stream-ordered memory allocation semantics, read +[Using the NVIDIA CUDA Stream-Ordered Memory +Allocator](https://developer.nvidia.com/blog/using-cuda-stream-ordered-memory-allocator-part-1/) +on the NVIDIA Developer Blog. + ### Available Resources RMM provides several `device_memory_resource` derived classes to satisfy various user requirements. @@ -268,10 +284,10 @@ Allocates and frees device memory using `cudaMalloc` and `cudaFree`. #### `managed_memory_resource` -Allocates and frees device memory using `cudaMallocManaged` and `cudaFree`. +Allocates and frees device memory using `cudaMallocManaged` and `cudaFree`. Note that `managed_memory_resource` cannot be used with NVIDIA Virtual GPU Software (vGPU, for use -with virtual machines or hypervisors) because [NVIDIA CUDA Unified Memory is not supported by +with virtual machines or hypervisors) because [NVIDIA CUDA Unified Memory is not supported by NVIDIA vGPU](https://docs.nvidia.com/grid/latest/grid-vgpu-user-guide/index.html#cuda-open-cl-support-vgpu). #### `pool_memory_resource` @@ -285,13 +301,13 @@ cost is constant. #### `binning_memory_resource` -Configurable to use multiple upstream memory resources for allocations that fall within different +Configurable to use multiple upstream memory resources for allocations that fall within different bin sizes. Often configured with multiple bins backed by `fixed_size_memory_resource`s and a single `pool_memory_resource` for allocations larger than the largest bin size. ### Default Resources and Per-device Resources -RMM users commonly need to configure a `device_memory_resource` object to use for all allocations +RMM users commonly need to configure a `device_memory_resource` object to use for all allocations where another resource has not explicitly been provided. A common example is configuring a `pool_memory_resource` to use for all allocations to get fast dynamic allocation. @@ -302,7 +318,7 @@ Accessing and modifying the default resource is done through two functions: - `device_memory_resource* get_current_device_resource()` - Returns a pointer to the default resource for the current CUDA device. - The initial default memory resource is an instance of `cuda_memory_resource`. - - This function is thread safe with respect to concurrent calls to it and + - This function is thread safe with respect to concurrent calls to it and `set_current_device_resource()`. - For more explicit control, you can use `get_per_device_resource()`, which takes a device ID. @@ -331,13 +347,13 @@ that was active when the `device_memory_resource` was created. Otherwise behavio If a `device_memory_resource` is used with a stream associated with a different CUDA device than the device for which the memory resource was created, behavior is undefined. - + Creating a `device_memory_resource` for each device requires care to set the current device before creating each resource, and to maintain the lifetime of the resources as long as they are set as per-device resources. Here is an example loop that creates `unique_ptr`s to `pool_memory_resource` objects for each device and sets them as the per-device resource for that device. -```c++ +```c++ std::vector> per_device_pools; for(int i = 0; i < N; ++i) { cudaSetDevice(i); // set device i before creating MR @@ -350,12 +366,12 @@ for(int i = 0; i < N; ++i) { ### Allocators -C++ interfaces commonly allow customizable memory allocation through an [`Allocator`](https://en.cppreference.com/w/cpp/named_req/Allocator) object. +C++ interfaces commonly allow customizable memory allocation through an [`Allocator`](https://en.cppreference.com/w/cpp/named_req/Allocator) object. RMM provides several `Allocator` and `Allocator`-like classes. #### `polymorphic_allocator` -A [stream-ordered](#stream-ordered-memory-allocation) allocator similar to [`std::pmr::polymorphic_allocator`](https://en.cppreference.com/w/cpp/memory/polymorphic_allocator). +A [stream-ordered](#stream-ordered-memory-allocation) allocator similar to [`std::pmr::polymorphic_allocator`](https://en.cppreference.com/w/cpp/memory/polymorphic_allocator). Unlike the standard C++ `Allocator` interface, the `allocate` and `deallocate` functions take a `cuda_stream_view` indicating the stream on which the (de)allocation occurs. #### `stream_allocator_adaptor` @@ -371,17 +387,17 @@ rmm::mr::polymorphic_allocator stream_alloc; auto adapted = rmm::mr::make_stream_allocator_adaptor(stream_alloc, stream); // Allocates 100 bytes using `stream_alloc` on `stream` -auto p = adapted.allocate(100); +auto p = adapted.allocate(100); ... // Deallocates using `stream_alloc` on `stream` -adapted.deallocate(p,100); +adapted.deallocate(p,100); ``` #### `thrust_allocator` `thrust_allocator` is a device memory allocator that uses the strongly typed `thrust::device_ptr`, making it usable with containers like `thrust::device_vector`. -See [below](#using-rmm-with-thrust) for more information on using RMM with Thrust. +See [below](#using-rmm-with-thrust) for more information on using RMM with Thrust. ## Device Data Structures @@ -394,7 +410,7 @@ An untyped, uninitialized RAII class for stream ordered device memory allocation ```c++ cuda_stream_view s{...}; // Allocates at least 100 bytes on stream `s` using the *default* resource -rmm::device_buffer b{100,s}; +rmm::device_buffer b{100,s}; void* p = b.data(); // Raw, untyped pointer to underlying device memory kernel<<<..., s.value()>>>(b.data()); // `b` is only safe to use on `s` @@ -417,11 +433,11 @@ cuda_stream_view s{...}; // default resource rmm::device_uvector v(100, s); // Initializes the elements to 0 -thrust::uninitialized_fill(thrust::cuda::par.on(s.value()), v.begin(), v.end(), int32_t{0}); +thrust::uninitialized_fill(thrust::cuda::par.on(s.value()), v.begin(), v.end(), int32_t{0}); rmm::mr::device_memory_resource * mr = new my_custom_resource{...}; // Allocates uninitialized storage for 100 `int32_t` elements on stream `s` using the resource `mr` -rmm::device_uvector v2{100, s, mr}; +rmm::device_uvector v2{100, s, mr}; ``` ### `device_scalar` @@ -433,7 +449,7 @@ modifying the value in device memory from the host, or retrieving the value from ```c++ cuda_stream_view s{...}; // Allocates uninitialized storage for a single `int32_t` in device memory -rmm::device_scalar a{s}; +rmm::device_scalar a{s}; a.set_value(42, s); // Updates the value in device memory to `42` on stream `s` kernel<<<...,s.value()>>>(a.data()); // Pass raw pointer to underlying element in device memory @@ -453,11 +469,11 @@ Similar to `device_memory_resource`, it has two key functions for (de)allocation `alignment` 2. `void host_memory_resource::deallocate(void* p, std::size_t bytes, std::size_t alignment)` - - Reclaims a previous allocation of size `bytes` pointed to by `p`. + - Reclaims a previous allocation of size `bytes` pointed to by `p`. Unlike `device_memory_resource`, the `host_memory_resource` interface and behavior is identical to -`std::pmr::memory_resource`. +`std::pmr::memory_resource`. ### Available Resources @@ -506,7 +522,7 @@ RMM includes two forms of logging. Memory event logging and debug logging. ### Memory Event Logging and `logging_resource_adaptor` Memory event logging writes details of every allocation or deallocation to a CSV (comma-separated -value) file. In C++, Memory Event Logging is enabled by using the `logging_resource_adaptor` as a +value) file. In C++, Memory Event Logging is enabled by using the `logging_resource_adaptor` as a wrapper around any other `device_memory_resource` object. Each row in the log represents either an allocation or a deallocation. The columns of the file are @@ -525,7 +541,7 @@ rmm::mr::cuda_memory_resource upstream; rmm::mr::logging_resource_adaptor log_mr{&upstream, filename}; ``` -If a file name is not specified, the environment variable `RMM_LOG_FILE` is queried for the file +If a file name is not specified, the environment variable `RMM_LOG_FILE` is queried for the file name. If `RMM_LOG_FILE` is not set, then an exception is thrown by the `logging_resource_adaptor` constructor. @@ -535,7 +551,7 @@ set to `True`. The log file name can be set using the `log_file_name` parameter. ### Debug Logging -RMM includes a debug logger which can be enabled to log trace and debug information to a file. This +RMM includes a debug logger which can be enabled to log trace and debug information to a file. This information can show when errors occur, when additional memory is allocated from upstream resources, etc. The default log file is `rmm_log.txt` in the current working directory, but the environment variable `RMM_DEBUG_LOG_FILE` can be set to specify the path and file name. @@ -547,27 +563,27 @@ of more detailed logging. The default is `INFO`. Available levels are `TRACE`, ` The log relies on the [spdlog](https://github.com/gabime/spdlog.git) library. Note that to see logging below the `INFO` level, the C++ application must also call -`rmm::logger().set_level()`, e.g. to enable all levels of logging down to `TRACE`, call +`rmm::logger().set_level()`, e.g. to enable all levels of logging down to `TRACE`, call `rmm::logger().set_level(spdlog::level::trace)` (and compile with `-DRMM_LOGGING_LEVEL=TRACE`). -Note that debug logging is different from the CSV memory allocation logging provided by +Note that debug logging is different from the CSV memory allocation logging provided by `rmm::mr::logging_resource_adapter`. The latter is for logging a history of allocation / deallocation actions which can be useful for replay with RMM's replay benchmark. ## RMM and CUDA Memory Bounds Checking Memory allocations taken from a memory resource that allocates a pool of memory (such as -`pool_memory_resource` and `arena_memory_resource`) are part of the same low-level CUDA memory -allocation. Therefore, out-of-bounds or misaligned accesses to these allocations are not likely to -be detected by CUDA tools such as +`pool_memory_resource` and `arena_memory_resource`) are part of the same low-level CUDA memory +allocation. Therefore, out-of-bounds or misaligned accesses to these allocations are not likely to +be detected by CUDA tools such as [CUDA Compute Sanitizer](https://docs.nvidia.com/cuda/compute-sanitizer/index.html) memcheck. -Exceptions to this are `cuda_memory_resource`, which wraps `cudaMalloc`, and -`cuda_async_memory_resource`, which uses `cudaMallocAsync` with CUDA's built-in memory pool -functionality (CUDA 11.2 or later required). Illegal memory accesses to memory allocated by these +Exceptions to this are `cuda_memory_resource`, which wraps `cudaMalloc`, and +`cuda_async_memory_resource`, which uses `cudaMallocAsync` with CUDA's built-in memory pool +functionality (CUDA 11.2 or later required). Illegal memory accesses to memory allocated by these resources are detectable with Compute Sanitizer Memcheck. -It may be possible in the future to add support for memory bounds checking with other memory +It may be possible in the future to add support for memory bounds checking with other memory resources using NVTX APIs. ## Using RMM in Python Code @@ -626,7 +642,7 @@ array([1., 2., 3.]) `MemoryResource` objects are used to configure how device memory allocations are made by RMM. -By default if a `MemoryResource` is not set explicitly, RMM uses the `CudaMemoryResource`, which +By default if a `MemoryResource` is not set explicitly, RMM uses the `CudaMemoryResource`, which uses `cudaMalloc` for allocating device memory. `rmm.reinitialize()` provides an easy way to initialize RMM with specific memory resource options @@ -666,10 +682,10 @@ of 1 GiB and a maximum size of 4 GiB. The pool uses Other MemoryResources include: * `FixedSizeMemoryResource` for allocating fixed blocks of memory -* `BinningMemoryResource` for allocating blocks within specified "bin" sizes from different memory +* `BinningMemoryResource` for allocating blocks within specified "bin" sizes from different memory resources -MemoryResources are highly configurable and can be composed together in different ways. +MemoryResources are highly configurable and can be composed together in different ways. See `help(rmm.mr)` for more information. ### Using RMM with CuPy @@ -685,8 +701,8 @@ allocations by setting the CuPy CUDA allocator to ``` -**Note:** This only configures CuPy to use the current RMM resource for allocations. -It does not initialize nor change the current resource, e.g., enabling a memory pool. +**Note:** This only configures CuPy to use the current RMM resource for allocations. +It does not initialize nor change the current resource, e.g., enabling a memory pool. See [here](#memoryresource-objects) for more information on changing the current memory resource. ### Using RMM with Numba @@ -710,6 +726,6 @@ This can be done in two ways: >>> cuda.set_memory_manager(rmm.RMMNumbaManager) ``` -**Note:** This only configures Numba to use the current RMM resource for allocations. -It does not initialize nor change the current resource, e.g., enabling a memory pool. +**Note:** This only configures Numba to use the current RMM resource for allocations. +It does not initialize nor change the current resource, e.g., enabling a memory pool. See [here](#memoryresource-objects) for more information on changing the current memory resource. From adcfb9343607bb65cfff9635ee724ba671097022 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 15 Aug 2022 17:31:34 -0500 Subject: [PATCH 142/675] Improve docs formatting and update links. (#1086) This PR improves a variety of small issues in the docs, including misaligned headers that cause poor rendering, outdated links, and inconsistent use of code formatting. I am hoping to make a few more passes through the docs to make them more useful and move from the deprecated `recommonmark` to MyST as was recently done in cuDF. This PR is a starting point that is probably worth merging on its own. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1086 --- README.md | 2 +- python/docs/basics.md | 2 +- python/rmm/_lib/memory_resource.pyx | 16 +++++++++------ python/rmm/rmm.py | 30 ++++++++++++++--------------- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index e6f0d914a..3aeaa5b24 100644 --- a/README.md +++ b/README.md @@ -708,7 +708,7 @@ See [here](#memoryresource-objects) for more information on changing the current ### Using RMM with Numba You can configure Numba to use RMM for memory allocations using the -Numba [EMM Plugin](http://numba.pydata.org/numba-doc/latest/cuda/external-memory.html#setting-the-emm-plugin). +Numba [EMM Plugin](https://numba.readthedocs.io/en/stable/cuda/external-memory.html#setting-emm-plugin). This can be done in two ways: diff --git a/python/docs/basics.md b/python/docs/basics.md index 4299e077e..008ddaf54 100644 --- a/python/docs/basics.md +++ b/python/docs/basics.md @@ -146,7 +146,7 @@ allocations by setting the CuPy CUDA allocator to ### Using RMM with Numba You can configure Numba to use RMM for memory allocations using the -Numba [EMM Plugin](http://numba.pydata.org/numba-doc/latest/cuda/external-memory.html#setting-the-emm-plugin). +Numba [EMM Plugin](https://numba.readthedocs.io/en/stable/cuda/external-memory.html#setting-emm-plugin). This can be done in two ways: diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index f373279c4..22d1d8f3e 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -236,19 +236,20 @@ cdef class CudaMemoryResource(DeviceMemoryResource): def __init__(self): """ - Memory resource that uses cudaMalloc/Free for allocation/deallocation + Memory resource that uses ``cudaMalloc``/``cudaFree`` for + allocation/deallocation. """ pass cdef class CudaAsyncMemoryResource(DeviceMemoryResource): """ - Memory resource that uses cudaMallocAsync/Free for + Memory resource that uses ``cudaMallocAsync``/``cudaFreeAsync`` for allocation/deallocation. Parameters ---------- - initial_pool_size : int,optional + initial_pool_size : int, optional Initial pool size in bytes. By default, half the available memory on the device is used. release_threshold: int, optional @@ -312,7 +313,7 @@ cdef class ManagedMemoryResource(DeviceMemoryResource): def __init__(self): """ - Memory resource that uses cudaMallocManaged/Free for + Memory resource that uses ``cudaMallocManaged``/``cudaFree`` for allocation/deallocation. """ pass @@ -361,7 +362,7 @@ cdef class PoolMemoryResource(UpstreamResourceAdaptor): upstream_mr : DeviceMemoryResource The DeviceMemoryResource from which to allocate blocks for the pool. - initial_pool_size : int,optional + initial_pool_size : int, optional Initial pool size in bytes. By default, half the available memory on the device is used. maximum_pool_size : int, optional @@ -551,7 +552,7 @@ cdef class CallbackMemoryResource(DeviceMemoryResource): integer representing the number of bytes to free. Examples - ------- + -------- >>> import rmm >>> base_mr = rmm.mr.CudaMemoryResource() >>> def allocate_func(size): @@ -695,6 +696,9 @@ cdef class StatisticsResourceAdaptor(UpstreamResourceAdaptor): Gets the current, peak, and total allocated bytes and number of allocations. + The dictionary keys are ``current_bytes``, ``current_count``, + ``peak_bytes``, ``peak_count``, ``total_bytes``, and ``total_count``. + Returns: dict: Dictionary containing allocation counts and bytes. """ diff --git a/python/rmm/rmm.py b/python/rmm/rmm.py index fd46b4793..398d83de3 100644 --- a/python/rmm/rmm.py +++ b/python/rmm/rmm.py @@ -66,24 +66,22 @@ def reinitialize( logging : bool, default False If True, enable run-time logging of all memory events (alloc, free, realloc). - This has significant performance impact. + This has a significant performance impact. log_file_name : str Name of the log file. If not specified, the environment variable - RMM_LOG_FILE is used. A ValueError is thrown if neither is available. - A separate log file is produced for each device, - and the suffix `".dev{id}"` is automatically added to the log file - name. + ``RMM_LOG_FILE`` is used. A ``ValueError`` is thrown if neither is + available. A separate log file is produced for each device, and the + suffix `".dev{id}"` is automatically added to the log file name. Notes ----- - Note that if you use the environment variable CUDA_VISIBLE_DEVICES - with logging enabled, the suffix may not be what you expect. For - example, if you set CUDA_VISIBLE_DEVICES=1, the log file produced - will still have suffix `0`. Similarly, if you set - CUDA_VISIBLE_DEVICES=1,0 and use devices 0 and 1, the log file - with suffix `0` will correspond to the GPU with device ID `1`. - Use `rmm.get_log_filenames()` to get the log file names - corresponding to each device. + Note that if you use the environment variable ``CUDA_VISIBLE_DEVICES`` with + logging enabled, the suffix may not be what you expect. For example, if you + set ``CUDA_VISIBLE_DEVICES=1``, the log file produced will still have + suffix ``0``. Similarly, if you set ``CUDA_VISIBLE_DEVICES=1,0`` and use + devices 0 and 1, the log file with suffix ``0`` will correspond to the GPU + with device ID ``1``. Use `rmm.get_log_filenames()` to get the log file + names corresponding to each device. """ for func, args, kwargs in reversed(_reinitialize_hooks): func(*args, **kwargs) @@ -101,7 +99,7 @@ def reinitialize( def is_initialized(): """ - Returns true if RMM has been initialized, false otherwise + Returns True if RMM has been initialized, False otherwise. """ return rmm.mr.is_initialized() @@ -111,7 +109,7 @@ class RMMNumbaManager(HostOnlyCUDAMemoryManager): External Memory Management Plugin implementation for Numba. Provides on-device allocation only. - See http://numba.pydata.org/numba-doc/latest/cuda/external-memory.html for + See https://numba.readthedocs.io/en/stable/cuda/external-memory.html for details of the interface being implemented here. """ @@ -206,7 +204,7 @@ def finalizer(): # Enables the use of RMM for Numba via an environment variable setting, # NUMBA_CUDA_MEMORY_MANAGER=rmm. See: -# http://numba.pydata.org/numba-doc/latest/cuda/external-memory.html#environment-variable +# https://numba.readthedocs.io/en/stable/cuda/external-memory.html#environment-variable _numba_memory_manager = RMMNumbaManager try: From f6bf0471d71c49c2956df90733befa5660d28b68 Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Wed, 17 Aug 2022 10:20:06 -0400 Subject: [PATCH 143/675] update changelog --- CHANGELOG.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21c0a1d9b..11fbd91e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,23 @@ -# RMM 22.08.00 (Date TBD) +# RMM 22.08.00 (17 Aug 2022) -Please see https://github.com/rapidsai/rmm/releases/tag/v22.08.00a for the latest changes to this development branch. +## 🐛 Bug Fixes + +- Specify `language` as `'en'` instead of `None` ([#1059](https://github.com/rapidsai/rmm/pull/1059)) [@jakirkham](https://github.com/jakirkham) +- Add a missed `except *` ([#1057](https://github.com/rapidsai/rmm/pull/1057)) [@shwina](https://github.com/shwina) +- Properly handle cudaMemHandleTypeNone and cudaErrorInvalidValue in is_export_handle_type_supported ([#1055](https://github.com/rapidsai/rmm/pull/1055)) [@gerashegalov](https://github.com/gerashegalov) + +## 📖 Documentation + +- Centralize common css & js code in docs ([#1075](https://github.com/rapidsai/rmm/pull/1075)) [@galipremsagar](https://github.com/galipremsagar) + +## 🛠️ Improvements + +- Add the ability to register and unregister reinitialization hooks ([#1072](https://github.com/rapidsai/rmm/pull/1072)) [@shwina](https://github.com/shwina) +- Update isort to 5.10.1 ([#1069](https://github.com/rapidsai/rmm/pull/1069)) [@vyasr](https://github.com/vyasr) +- Forward merge 22.06 into 22.08 ([#1067](https://github.com/rapidsai/rmm/pull/1067)) [@vyasr](https://github.com/vyasr) +- Forward merge 22.06 into 22.08 ([#1066](https://github.com/rapidsai/rmm/pull/1066)) [@vyasr](https://github.com/vyasr) +- Pin max version of `cuda-python` to `11.7` ([#1062](https://github.com/rapidsai/rmm/pull/1062)) [@galipremsagar](https://github.com/galipremsagar) +- Change build.sh to find C++ library by default and avoid shadowing CMAKE_ARGS ([#1053](https://github.com/rapidsai/rmm/pull/1053)) [@vyasr](https://github.com/vyasr) # RMM 22.06.00 (7 Jun 2022) From 368101a098a16850b2803bdf955e7c7e4d6c1257 Mon Sep 17 00:00:00 2001 From: Mark Harris Date: Tue, 23 Aug 2022 07:11:07 +1000 Subject: [PATCH 144/675] Branch 22.10 merge 22.08 (#1089) Authors: - Mark Harris (https://github.com/harrism) - Ray Douglass (https://github.com/raydouglass) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1089 --- CHANGELOG.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4126147fc..4602e1f3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,26 @@ Please see https://github.com/rapidsai/rmm/releases/tag/v22.10.00a for the latest changes to this development branch. -# RMM 22.08.00 (Date TBD) +# RMM 22.08.00 (17 Aug 2022) -Please see https://github.com/rapidsai/rmm/releases/tag/v22.08.00a for the latest changes to this development branch. +## 🐛 Bug Fixes + +- Specify `language` as `'en'` instead of `None` ([#1059](https://github.com/rapidsai/rmm/pull/1059)) [@jakirkham](https://github.com/jakirkham) +- Add a missed `except *` ([#1057](https://github.com/rapidsai/rmm/pull/1057)) [@shwina](https://github.com/shwina) +- Properly handle cudaMemHandleTypeNone and cudaErrorInvalidValue in is_export_handle_type_supported ([#1055](https://github.com/rapidsai/rmm/pull/1055)) [@gerashegalov](https://github.com/gerashegalov) + +## 📖 Documentation + +- Centralize common css & js code in docs ([#1075](https://github.com/rapidsai/rmm/pull/1075)) [@galipremsagar](https://github.com/galipremsagar) + +## 🛠️ Improvements + +- Add the ability to register and unregister reinitialization hooks ([#1072](https://github.com/rapidsai/rmm/pull/1072)) [@shwina](https://github.com/shwina) +- Update isort to 5.10.1 ([#1069](https://github.com/rapidsai/rmm/pull/1069)) [@vyasr](https://github.com/vyasr) +- Forward merge 22.06 into 22.08 ([#1067](https://github.com/rapidsai/rmm/pull/1067)) [@vyasr](https://github.com/vyasr) +- Forward merge 22.06 into 22.08 ([#1066](https://github.com/rapidsai/rmm/pull/1066)) [@vyasr](https://github.com/vyasr) +- Pin max version of `cuda-python` to `11.7` ([#1062](https://github.com/rapidsai/rmm/pull/1062)) [@galipremsagar](https://github.com/galipremsagar) +- Change build.sh to find C++ library by default and avoid shadowing CMAKE_ARGS ([#1053](https://github.com/rapidsai/rmm/pull/1053)) [@vyasr](https://github.com/vyasr) # RMM 22.06.00 (7 Jun 2022) From 45f60da0fc6f95b226404fddf9f6d47ecf499f21 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 22 Aug 2022 18:46:04 -0500 Subject: [PATCH 145/675] Improve DeviceBuffer docs. (#1090) I noticed a few errors in the `DeviceBuffer` docs while using Python's `help(rmm.DeviceBuffer)`. These errors probably weren't noticed because the docs for `DeviceBuffer` are [not publicly exposed](https://docs.rapids.ai/api/rmm/nightly/search.html?q=DeviceBuffer&check_keywords=yes&area=default). Reviewers: Should we check to ensure that we are exposing docs for this class and other APIs in the `rmm.*` Python namespace, and add those (in a separate PR)? Authors: - Bradley Dice (https://github.com/bdice) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) - Ashwin Srinath (https://github.com/shwina) URL: https://github.com/rapidsai/rmm/pull/1090 --- python/rmm/_lib/device_buffer.pyx | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/python/rmm/_lib/device_buffer.pyx b/python/rmm/_lib/device_buffer.pyx index 7607cd41f..4a6d873be 100644 --- a/python/rmm/_lib/device_buffer.pyx +++ b/python/rmm/_lib/device_buffer.pyx @@ -67,7 +67,6 @@ cdef class DeviceBuffer: Note ---- - If the pointer passed is non-null and ``stream`` is the default stream, it is synchronized after the copy. However if a non-default ``stream`` is provided, this function is fully asynchronous. @@ -146,15 +145,15 @@ cdef class DeviceBuffer: @staticmethod def to_device(const unsigned char[::1] b, Stream stream=DEFAULT_STREAM): - """Calls ``to_device`` function on arguments provided""" + """Calls ``to_device`` function on arguments provided.""" return to_device(b, stream) cpdef copy_to_host(self, ary=None, Stream stream=DEFAULT_STREAM): - """Copy from a ``DeviceBuffer`` to a buffer on host + """Copy from a ``DeviceBuffer`` to a buffer on host. Parameters ---------- - hb : ``bytes``-like buffer to write into + ary : ``bytes``-like buffer to write into stream : CUDA stream to use for copying, default the default stream Examples @@ -179,7 +178,7 @@ cdef class DeviceBuffer: hb = ary = np.empty((s,), dtype="u1") elif len(hb) < s: raise ValueError( - "Argument `hb` is too small. Need space for %i bytes." % s + "Argument `ary` is too small. Need space for %i bytes." % s ) copy_ptr_to_host(dbp.data(), hb[:s], stream) @@ -191,7 +190,7 @@ cdef class DeviceBuffer: Parameters ---------- - hb : ``bytes``-like buffer to copy from + ary : ``bytes``-like buffer to copy from stream : CUDA stream to use for copying, default the default stream Examples @@ -210,7 +209,7 @@ cdef class DeviceBuffer: cdef size_t s = len(hb) if s > self.size: raise ValueError( - "Argument `hb` is too large. Need space for %i bytes." % s + "Argument `ary` is too large. Need space for %i bytes." % s ) copy_host_to_ptr(hb[:s], dbp.data(), stream) @@ -306,7 +305,7 @@ cdef class DeviceBuffer: cdef device_buffer c_release(self) except *: """ - Releases ownership the data held by this DeviceBuffer. + Releases ownership of the data held by this DeviceBuffer. """ return move(cython.operator.dereference(self.c_obj)) @@ -314,7 +313,7 @@ cdef class DeviceBuffer: @cython.boundscheck(False) cpdef DeviceBuffer to_device(const unsigned char[::1] b, Stream stream=DEFAULT_STREAM): - """Return a new ``DeviceBuffer`` with a copy of the data + """Return a new ``DeviceBuffer`` with a copy of the data. Parameters ---------- @@ -351,16 +350,17 @@ cdef void _copy_async(const void* src, ccudart.cudaMemcpyKind kind, cuda_stream_view stream) nogil except *: """ - Asynchronously copy data between host and/or device pointers + Asynchronously copy data between host and/or device pointers. This is a convenience wrapper around cudaMemcpyAsync that checks for errors. Only used for internal implementation. Parameters ---------- - src : pointer to ``bytes``-like host buffer to or device data to copy from - dst : pointer to ``bytes``-like host buffer to or device data to copy into + src : pointer to ``bytes``-like host buffer or device data to copy from + dst : pointer to ``bytes``-like host buffer or device data to copy into count : the size in bytes to copy + kind : the kind of copy to perform stream : CUDA stream to use for copying, default the default stream """ cdef cudaError_t err = cudaMemcpyAsync(dst, src, count, kind, @@ -384,7 +384,6 @@ cpdef void copy_ptr_to_host(uintptr_t db, Note ---- - If ``stream`` is the default stream, it is synchronized after the copy. However if a non-default ``stream`` is provided, this function is fully asynchronous. @@ -427,7 +426,6 @@ cpdef void copy_host_to_ptr(const unsigned char[::1] hb, Note ---- - If ``stream`` is the default stream, it is synchronized after the copy. However if a non-default ``stream`` is provided, this function is fully asynchronous. @@ -468,6 +466,7 @@ cpdef void copy_device_to_ptr(uintptr_t d_src, ---------- d_src : pointer to data on device to copy from d_dst : pointer to data on device to write into + count : the size in bytes to copy stream : CUDA stream to use for copying, default the default stream Examples From 6eb255dd7e2a438e3cee920411e449400853687b Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 23 Aug 2022 09:10:40 -0500 Subject: [PATCH 146/675] Fix docs for module-level API (#1091) This PR's primary intention is to fix the `rmm` module API documentation so that classes like `DeviceBuffer` appear, and to remove documentation for the `rmm.rmm` submodule in favor of the top-level API that defines all public names. I fixed all warnings that appear when building with Sphinx, and addressed a few other minor issues that didn't deserve their own PRs but were important to fix. I rendered the docs locally and the difference is very substantial -- parameter docstrings, public properties of classes, and other names now automatically appear or render correctly where they weren't before. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Ashwin Srinath (https://github.com/shwina) - Mark Sadang (https://github.com/msadang) URL: https://github.com/rapidsai/rmm/pull/1091 --- conda/environments/rmm_dev_cuda11.5.yml | 1 + conda/environments/rmm_dev_cuda11.6.yml | 1 + python/docs/api.rst | 15 +++------------ python/docs/basics.md | 2 +- python/docs/conf.py | 25 ++++++++----------------- python/pyproject.toml | 2 +- python/rmm/__init__.py | 16 ++++++++++++++++ python/rmm/_lib/device_buffer.pyx | 3 +++ python/rmm/_lib/memory_resource.pxd | 2 +- python/rmm/_lib/memory_resource.pyx | 15 ++++++++++----- 10 files changed, 45 insertions(+), 37 deletions(-) diff --git a/conda/environments/rmm_dev_cuda11.5.yml b/conda/environments/rmm_dev_cuda11.5.yml index 8fa5450de..83ae65eaf 100644 --- a/conda/environments/rmm_dev_cuda11.5.yml +++ b/conda/environments/rmm_dev_cuda11.5.yml @@ -21,3 +21,4 @@ dependencies: - cython>=0.29,<0.30 - gcovr>=5.0 - cuda-python>=11.5,<11.7.1 +- sphinx_rtd_theme diff --git a/conda/environments/rmm_dev_cuda11.6.yml b/conda/environments/rmm_dev_cuda11.6.yml index 6fc922672..46bc60649 100644 --- a/conda/environments/rmm_dev_cuda11.6.yml +++ b/conda/environments/rmm_dev_cuda11.6.yml @@ -21,3 +21,4 @@ dependencies: - cython>=0.29,<0.30 - gcovr>=5.0 - cuda-python>=11.6,11.7.1 +- sphinx_rtd_theme diff --git a/python/docs/api.rst b/python/docs/api.rst index 13213fc34..ebc68c354 100644 --- a/python/docs/api.rst +++ b/python/docs/api.rst @@ -1,10 +1,10 @@ API Reference ============== -High-level API --------------- +Module Contents +--------------- -.. automodule:: rmm.rmm +.. automodule:: rmm :members: :undoc-members: :show-inheritance: @@ -17,12 +17,3 @@ Memory Resources :members: :undoc-members: :show-inheritance: - - -Module contents ---------------- - -.. automodule:: rmm - :members: - :undoc-members: - :show-inheritance: diff --git a/python/docs/basics.md b/python/docs/basics.md index 008ddaf54..368145b3d 100644 --- a/python/docs/basics.md +++ b/python/docs/basics.md @@ -152,7 +152,7 @@ This can be done in two ways: 1. Setting the environment variable `NUMBA_CUDA_MEMORY_MANAGER`: - ```python + ```bash $ NUMBA_CUDA_MEMORY_MANAGER=rmm python (args) ``` diff --git a/python/docs/conf.py b/python/docs/conf.py index 0b696c4ad..3db21a2e0 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -15,10 +15,16 @@ # -- Project information ----------------------------------------------------- project = "rmm" -copyright = "2020, NVIDIA" +copyright = "2020-2022, NVIDIA" author = "NVIDIA" -# The full version, including alpha/beta/rc tags +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = "22.10" +# The full version, including alpha/beta/rc tags. release = "22.10.00" @@ -39,7 +45,6 @@ "IPython.sphinxext.ipython_directive", "nbsphinx", "recommonmark", - "sphinx.ext.napoleon", ] @@ -59,20 +64,6 @@ # The master toctree document. master_doc = "index" -# General information about the project. -project = "rmm" -copyright = "2020, NVIDIA" -author = "NVIDIA" - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = "22.10" -# The full version, including alpha/beta/rc tags. -release = "22.10.00" - # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # diff --git a/python/pyproject.toml b/python/pyproject.toml index 57be17669..d1f1a6639 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -26,7 +26,7 @@ requires = [ [tool.black] line-length = 79 -target-version = ["py36"] +target-version = ["py38"] include = '\.py?$' exclude = ''' /( diff --git a/python/rmm/__init__.py b/python/rmm/__init__.py index 424bcaa35..acdeb93a8 100644 --- a/python/rmm/__init__.py +++ b/python/rmm/__init__.py @@ -28,4 +28,20 @@ unregister_reinitialize_hook, ) +__all__ = [ + "DeviceBuffer", + "RMMError", + "RMMNumbaManager", + "disable_logging", + "enable_logging", + "get_log_filenames", + "get_versions", + "is_initialized", + "mr", + "register_reinitialize_hook", + "reinitialize", + "rmm_cupy_allocator", + "unregister_reinitialize_hook", +] + __version__ = get_versions()["version"] diff --git a/python/rmm/_lib/device_buffer.pyx b/python/rmm/_lib/device_buffer.pyx index 4a6d873be..9ac034774 100644 --- a/python/rmm/_lib/device_buffer.pyx +++ b/python/rmm/_lib/device_buffer.pyx @@ -106,14 +106,17 @@ cdef class DeviceBuffer: @property def nbytes(self): + """Gets the size of the buffer in bytes.""" return self.size @property def ptr(self): + """Gets a pointer to the underlying data.""" return int(self.c_data()) @property def size(self): + """Gets the size of the buffer in bytes.""" return int(self.c_size()) def __reduce__(self): diff --git a/python/rmm/_lib/memory_resource.pxd b/python/rmm/_lib/memory_resource.pxd index 92ce1ce54..387d39866 100644 --- a/python/rmm/_lib/memory_resource.pxd +++ b/python/rmm/_lib/memory_resource.pxd @@ -50,7 +50,7 @@ cdef class FixedSizeMemoryResource(UpstreamResourceAdaptor): cdef class BinningMemoryResource(UpstreamResourceAdaptor): - cdef readonly list bin_mrs + cdef readonly list _bin_mrs cpdef add_bin( self, diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 22d1d8f3e..c774b5e50 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -426,7 +426,7 @@ cdef class BinningMemoryResource(UpstreamResourceAdaptor): int8_t max_size_exponent=-1, ): - self.bin_mrs = [] + self._bin_mrs = [] if (min_size_exponent == -1 or max_size_exponent == -1): self.c_obj.reset( @@ -460,15 +460,15 @@ cdef class BinningMemoryResource(UpstreamResourceAdaptor): If min_size_exponent and max_size_exponent are specified, initializes with one or more FixedSizeMemoryResource bins in the range - [2^min_size_exponent, 2^max_size_exponent]. + ``[2**min_size_exponent, 2**max_size_exponent]``. - Call add_bin to add additional bin allocators. + Call :py:meth:`~.add_bin` to add additional bin allocators. Parameters ---------- upstream_mr : DeviceMemoryResource The memory resource to use for allocations larger than any of the - bins + bins. min_size_exponent : size_t The base-2 exponent of the minimum size FixedSizeMemoryResource bin to create. @@ -506,13 +506,18 @@ cdef class BinningMemoryResource(UpstreamResourceAdaptor): self.c_obj.get()))[0].add_bin(allocation_size) else: # Save the ref to the new bin resource to ensure its lifetime - self.bin_mrs.append(bin_resource) + self._bin_mrs.append(bin_resource) (( self.c_obj.get()))[0].add_bin( allocation_size, bin_resource.get_mr()) + @property + def bin_mrs(self) -> list: + """Get the list of binned memory resources.""" + return self._bin_mrs + cdef void* _allocate_callback_wrapper( size_t nbytes, From ed43650bc22bfbd0bd04d6293de3e17f75222a13 Mon Sep 17 00:00:00 2001 From: Tobias Ribizel Date: Sat, 27 Aug 2022 00:49:15 +0200 Subject: [PATCH 147/675] Add `gdb` pretty-printers for rmm types (#1088) This PR adds a pretty-printer for `device_uvector` and pulls in Thrust pretty-printers that were added in https://github.com/NVIDIA/thrust/pull/1631. CMake provides a convenience script to load all of the pretty-printers, to resolve the duplication concerns raised in https://github.com/rapidsai/cudf/pull/11499. Example output:
``` $ gdb -q gtests/DEVICE_UVECTOR_TEST Reading symbols from gtests/DEVICE_UVECTOR_TEST... (gdb) b cudaMalloc Function "cudaMalloc" not defined. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (cudaMalloc) pending. (gdb) run Starting program: /home/nfs/tribizel/rapids/rmm/build/cuda-11.5.0/feature__pretty-printers/debug/gtests/DEVICE_UVECTOR_TEST warning: Error disabling address space randomization: Operation not permitted [Thread debugging using libthread_db enabled] Using host libthread_db library "/usr/lib/x86_64-linux-gnu/libthread_db.so.1". Running main() from gmock_main.cc [==========] Running 95 tests from 5 test suites. [----------] Global test environment set-up. [----------] 19 tests from TypedUVectorTest/0, where TypeParam = signed char [ RUN ] TypedUVectorTest/0.MemoryResource [New Thread 0x7f741efc1000 (LWP 86147)] Thread 1 "DEVICE_UVECTOR_" hit Breakpoint 1, 0x00007f7426dddc80 in cudaMalloc () from /home/nfs/tribizel/rapids/compose/etc/conda/cuda_11.5/envs/rapids/lib/libcudart.so.11.0 (gdb) c Continuing. [New Thread 0x7f741e7c0000 (LWP 86148)] [ OK ] TypedUVectorTest/0.MemoryResource (999 ms) [ RUN ] TypedUVectorTest/0.ZeroSizeConstructor [ OK ] TypedUVectorTest/0.ZeroSizeConstructor (0 ms) [ RUN ] TypedUVectorTest/0.NonZeroSizeConstructor Thread 1 "DEVICE_UVECTOR_" hit Breakpoint 1, 0x00007f7426dddc80 in cudaMalloc () from /home/nfs/tribizel/rapids/compose/etc/conda/cuda_11.5/envs/rapids/lib/libcudart.so.11.0 (gdb) finish Run till exit from #0 0x00007f7426dddc80 in cudaMalloc () from /home/nfs/tribizel/rapids/compose/etc/conda/cuda_11.5/envs/rapids/lib/libcudart.so.11.0 rmm::mr::cuda_memory_resource::do_allocate (bytes=, this=) at /home/nfs/tribizel/rapids/rmm/include/rmm/mr/device/cuda_memory_resource.hpp:70 70 RMM_CUDA_TRY_ALLOC(cudaMalloc(&ptr, bytes)); (gdb) finish Run till exit from #0 rmm::mr::cuda_memory_resource::do_allocate (bytes=, this=) at /home/nfs/tribizel/rapids/rmm/include/rmm/mr/device/cuda_memory_resource.hpp:70 0x00005587874feef0 in rmm::device_buffer::allocate_async (bytes=12345, this=0x7ffefebb46b0) at /home/nfs/tribizel/rapids/rmm/include/rmm/device_buffer.hpp:418 418 _data = (bytes > 0) ? memory_resource()->allocate(bytes, stream()) : nullptr; Value returned is $1 = (void *) 0x7f73ff000000 (gdb) finish Run till exit from #0 0x00005587874feef0 in rmm::device_buffer::allocate_async (bytes=12345, this=0x7ffefebb46b0) at /home/nfs/tribizel/rapids/rmm/include/rmm/device_buffer.hpp:418 TypedUVectorTest_NonZeroSizeConstructor_Test::TestBody (this=) at /home/nfs/tribizel/rapids/rmm/tests/device_uvector_tests.cpp:55 55 EXPECT_EQ(vec.size(), size); (gdb) print vec $2 = {_storage = {_data = 0x7f73ff000000, _size = 12345, _capacity = 12345, _stream = {stream_ = 0x0}, _mr = 0x558787561008 }} (gdb) source load-pretty-printers (gdb) print vec $3 = rmm::device_uvector of length 12345, capacity 12345 = {0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000'...} (gdb) ```
Authors: - Tobias Ribizel (https://github.com/upsj) Approvers: - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1088 --- CMakeLists.txt | 5 ++ scripts/gdb-pretty-printers.py | 144 ++++++++++++++++++++++++++++++++ scripts/load-pretty-printers.in | 2 + 3 files changed, 151 insertions(+) create mode 100644 scripts/gdb-pretty-printers.py create mode 100644 scripts/load-pretty-printers.in diff --git a/CMakeLists.txt b/CMakeLists.txt index ce246596e..d5de4f6c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,6 +108,11 @@ endif() include(CPack) +# optionally assemble Thrust pretty-printers +if(Thrust_SOURCE_DIR) + configure_file(scripts/load-pretty-printers.in load-pretty-printers @ONLY) +endif() + # install export targets install(TARGETS rmm EXPORT rmm-exports) install(DIRECTORY include/rmm/ DESTINATION include/rmm) diff --git a/scripts/gdb-pretty-printers.py b/scripts/gdb-pretty-printers.py new file mode 100644 index 000000000..df6a662ee --- /dev/null +++ b/scripts/gdb-pretty-printers.py @@ -0,0 +1,144 @@ +# Copyright (c) 2022, 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. +# + +import gdb + + +class HostIterator: + """Iterates over arrays in host memory.""" + + def __init__(self, start, size): + self.item = start + self.size = size + self.count = 0 + + def __iter__(self): + return self + + def __next__(self): + if self.count >= self.size: + raise StopIteration + elt = self.item.dereference() + count = self.count + self.item += 1 + self.count += 1 + return (f"[{count}]", elt) + + +class DeviceIterator: + """Iterates over arrays in device memory by copying chunks into host memory.""" + + def __init__(self, start, size): + self.exec = exec + self.item = start + self.size = size + self.count = 0 + self.buffer = None + self.sizeof = self.item.dereference().type.sizeof + self.buffer_start = 0 + # At most 1 MB or size, at least 1 + self.buffer_size = min(size, max(1, 2 ** 20 // self.sizeof)) + self.buffer = gdb.parse_and_eval(f"(void*)malloc({self.buffer_size * self.sizeof})") + self.buffer.fetch_lazy() + self.buffer_count = self.buffer_size + self.update_buffer() + + def update_buffer(self): + if self.buffer_count >= self.buffer_size: + self.buffer_item = gdb.parse_and_eval( + hex(self.buffer)).cast(self.item.type) + self.buffer_count = 0 + self.buffer_start = self.count + device_addr = hex(self.item.dereference().address) + buffer_addr = hex(self.buffer) + size = min(self.buffer_size, self.size - + self.buffer_start) * self.sizeof + status = gdb.parse_and_eval( + f"(cudaError)cudaMemcpy({buffer_addr}, {device_addr}, {size}, cudaMemcpyDeviceToHost)") + if status != 0: + raise gdb.MemoryError( + f"memcpy from device failed: {status}") + + def __del__(self): + gdb.parse_and_eval(f"(void)free({hex(self.buffer)})").fetch_lazy() + + def __iter__(self): + return self + + def __next__(self): + if self.count >= self.size: + raise StopIteration + self.update_buffer() + elt = self.buffer_item.dereference() + self.buffer_item += 1 + self.buffer_count += 1 + count = self.count + self.item += 1 + self.count += 1 + return (f"[{count}]", elt) + + +class RmmDeviceUVectorPrinter(gdb.printing.PrettyPrinter): + """Print a rmm::device_uvector.""" + + def __init__(self, val): + self.val = val + el_type = val.type.template_argument(0) + self.pointer = val["_storage"]["_data"].cast(el_type.pointer()) + self.size = int(val["_storage"]["_size"]) // el_type.sizeof + self.capacity = int(val["_storage"]["_capacity"]) // el_type.sizeof + + def children(self): + return DeviceIterator(self.pointer, self.size) + + def to_string(self): + return (f"{self.val.type} of length {self.size}, capacity {self.capacity}") + + def display_hint(self): + return "array" + + +# Workaround to avoid using the pretty printer on things like std::vector::iterator +def is_template_type_not_alias(typename): + loc = typename.find("<") + if loc is None: + return False + depth = 0 + for char in typename[loc:-1]: + if char == "<": + depth += 1 + if char == ">": + depth -= 1 + if depth == 0: + return False + return True + + +def template_match(typename, template_name): + return typename.startswith(template_name + "<") and typename.endswith(">") + + +def lookup_rmm_type(val): + if not str(val.type.unqualified()).startswith("rmm::"): + return None + suffix = str(val.type.unqualified())[5:] + if not is_template_type_not_alias(suffix): + return None + if template_match(suffix, "device_uvector"): + return RmmDeviceUVectorPrinter(val) + return None + + +gdb.pretty_printers.append(lookup_rmm_type) diff --git a/scripts/load-pretty-printers.in b/scripts/load-pretty-printers.in new file mode 100644 index 000000000..bd59968cc --- /dev/null +++ b/scripts/load-pretty-printers.in @@ -0,0 +1,2 @@ +source @Thrust_SOURCE_DIR@/scripts/gdb-pretty-printers.py +source @PROJECT_SOURCE_DIR@/scripts/gdb-pretty-printers.py From 9c6f5b6d0343c15ddd54a3f894c48f76ff98ce29 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Tue, 6 Sep 2022 15:45:31 -0400 Subject: [PATCH 148/675] Bifurcate Dependency Lists (#1073) ## Summary This PR uses [rapids-dependency-file-generator](https://github.com/rapidsai/dependency-file-generator) along with a new `dependencies.yaml` file to bifurcate the existing dependency lists in the `conda/environments` directory. `rapids-dependency-file-generator` will generate `conda` environment files based on the contents of the new `dependencies.yaml` file (see [rapidsai/dependency-file-generator](https://github.com/rapidsai/dependency-file-generator) for more details). There is also a new GitHub Action that runs a shared workflow (which lives [here](https://github.com/rapidsai/shared-action-workflows/blob/main/.github/workflows/dependency-files.yaml)) to ensure that the generated dependency files are up-to-date in each PR. This shared workflow can easily be implemented across other RAPIDS repositories. ## Why is this PR Needed? This PR is necessary to support some upcoming changes in CI. We've recently created some new, slimmer CI images (~450MB vs. the current 6.5GB) in anticipation of the move to GitHub Actions. These new images omit the large dependency packages (i.e. `rapids-{build,notebook,doc}-env`) from the [rapidsai/integration](https://github.com/rapidsai/integration) repository, which will eventually be deprecated and deleted entirely. One of the consequences of removing the `integration` packages from our CI images is that commonly used test dependencies (i.e. `pytest`) are no longer included in the CI images by default. Therefore, we need to ensure that each repository has a list of the dependencies that are required to test its respective libraries. A similar list will also be needed in other repositories for JupyterLab Notebook dependencies (which will be utilized in our `runtime` end-user images), but that list does not apply to `rmm`. ## Impacts of these Changes The changes in this PR impact developers and CI as follows: ### Developers Developers should now update the dependencies in the `dependencies.yaml` file instead of the generated dependency files. If they accidentally update the generated dependency files, the new GitHub Action will fail. At this point, the developer will need to install `rapids-dependency-file-generator` and run it from the project's root directory. For example: ```sh pip install rapids-dependency-file-generator rapids-dependency-file-generator ``` This step can also be implemented as a pre-commit hook. ### CI The new GitHub Action CI process will use the dependencies in the `test` list in `dependencies.yaml` to create a new test environment for `rmm`/`librmm` in CI. For example: ```sh ENV_NAME="rmm_test" rapids-dependency-file-generator \ --file_key "test" \ --generate "conda" \ --matrix "cuda=11.5;arch=$(arch)" > env.yaml mamba env create --file env.yaml mamba activate "$ENV_NAME" # ... run `rmm`/`librmm` tests ``` ## Additional Information The new GitHub Action will enforce that an `all` environment (under the `files.all` key) is included in the `dependencies.yaml` file and that it includes all of the dependency lists in the `dependencies.conda` and `dependencies.conda_and_requirements` sections. This is enforced in the shared workflow [here](https://github.com/rapidsai/shared-action-workflows/blob/d5cf5f802a0da73aed5ed01ee18daf5dd3a0f095/.github/workflows/dependency-files.yaml#L42-L80). It exists to provide some standardization across the RAPIDS libraries and will eventually replace the `rapids-{build,notebook,doc}-env` packages in our `devel` end-user images. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Bradley Dice (https://github.com/bdice) - Ray Douglass (https://github.com/raydouglass) --- .github/workflows/dependency-files.yml | 8 +++ README.md | 2 +- ...11.5.yml => all_cuda-115_arch-x86_64.yaml} | 21 +++--- ...11.6.yml => all_cuda-116_arch-x86_64.yaml} | 21 +++--- dependencies.yaml | 64 +++++++++++++++++++ 5 files changed, 95 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/dependency-files.yml rename conda/environments/{rmm_dev_cuda11.5.yml => all_cuda-115_arch-x86_64.yaml} (64%) rename conda/environments/{rmm_dev_cuda11.6.yml => all_cuda-116_arch-x86_64.yaml} (58%) create mode 100644 dependencies.yaml diff --git a/.github/workflows/dependency-files.yml b/.github/workflows/dependency-files.yml new file mode 100644 index 000000000..aeda16f41 --- /dev/null +++ b/.github/workflows/dependency-files.yml @@ -0,0 +1,8 @@ +name: dependency-files + +on: + pull_request: + +jobs: + check-generated-files: + uses: rapidsai/shared-action-workflows/.github/workflows/dependency-files.yaml@main diff --git a/README.md b/README.md index 3aeaa5b24..507c5e325 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ $ cd rmm - Create the conda development environment `rmm_dev` ```bash # create the conda environment (assuming in base `rmm` directory) -$ conda env create --name rmm_dev --file conda/environments/rmm_dev_cuda11.0.yml +$ conda env create --name rmm_dev --file conda/environments/all_cuda-115_arch-x86_64.yaml # activate the environment $ conda activate rmm_dev ``` diff --git a/conda/environments/rmm_dev_cuda11.5.yml b/conda/environments/all_cuda-115_arch-x86_64.yaml similarity index 64% rename from conda/environments/rmm_dev_cuda11.5.yml rename to conda/environments/all_cuda-115_arch-x86_64.yaml index 83ae65eaf..5efa00959 100644 --- a/conda/environments/rmm_dev_cuda11.5.yml +++ b/conda/environments/all_cuda-115_arch-x86_64.yaml @@ -1,24 +1,25 @@ -name: rmm_dev +# This file is generated by `rapids-dependency-file-generator`. +# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. channels: - rapidsai - conda-forge dependencies: -- clang=11.1.0 +- black=22.3.0 - clang-tools=11.1.0 +- clang=11.1.0 - cmake>=3.20.1,!=3.23.0 - cmakelang=0.6.13 +- cuda-python>=11.5,<11.7.1 +- cudatoolkit=11.5 +- cython>=0.29,<0.30 - flake8=3.8.3 -- black=22.3.0 +- gcovr>=5.0 - isort=5.10.1 -- python>=3.8,<3.10 - numba>=0.49 - numpy>=1.19 -- cffi>=1.10.0 - pytest -- cudatoolkit=11.5 +- pytest-cov +- python>=3.8,<3.10 - scikit-build>=0.13.1 - spdlog>=1.8.5,<1.9 -- cython>=0.29,<0.30 -- gcovr>=5.0 -- cuda-python>=11.5,<11.7.1 -- sphinx_rtd_theme +name: all_cuda-115_arch-x86_64 diff --git a/conda/environments/rmm_dev_cuda11.6.yml b/conda/environments/all_cuda-116_arch-x86_64.yaml similarity index 58% rename from conda/environments/rmm_dev_cuda11.6.yml rename to conda/environments/all_cuda-116_arch-x86_64.yaml index 46bc60649..65ab0e6a0 100644 --- a/conda/environments/rmm_dev_cuda11.6.yml +++ b/conda/environments/all_cuda-116_arch-x86_64.yaml @@ -1,24 +1,25 @@ -name: rmm_dev +# This file is generated by `rapids-dependency-file-generator`. +# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. channels: - rapidsai - conda-forge dependencies: -- clang=11.1.0 +- black=22.3.0 - clang-tools=11.1.0 +- clang=11.1.0 - cmake>=3.20.1,!=3.23.0 - cmakelang=0.6.13 +- cuda-python>=11.6,<11.7.1 +- cudatoolkit=11.6 +- cython>=0.29,<0.30 - flake8=3.8.3 -- black=22.3.0 +- gcovr>=5.0 - isort=5.10.1 -- python>=3.8,<3.10 - numba>=0.49 - numpy>=1.19 -- cffi>=1.10.0 - pytest -- cudatoolkit=11.6 +- pytest-cov +- python>=3.8,<3.10 - scikit-build>=0.13.1 - spdlog>=1.8.5,<1.9 -- cython>=0.29,<0.30 -- gcovr>=5.0 -- cuda-python>=11.6,11.7.1 -- sphinx_rtd_theme +name: all_cuda-116_arch-x86_64 diff --git a/dependencies.yaml b/dependencies.yaml new file mode 100644 index 000000000..583e9415d --- /dev/null +++ b/dependencies.yaml @@ -0,0 +1,64 @@ +# Dependency list for https://github.com/rapidsai/dependency-file-generator +files: + all: + generate: conda + matrix: + cuda: ["11.5", "11.6"] + arch: [x86_64] + includes: + - build + - develop + - run + - test + test: + generate: none + includes: + - test +channels: + - rapidsai + - conda-forge +dependencies: + conda_and_requirements: + common: + build: + - cmake>=3.20.1,!=3.23.0 + - cython>=0.29,<0.30 + - python>=3.8,<3.10 + - scikit-build>=0.13.1 + run: + - numba>=0.49 + - numpy>=1.19 + develop: + - black=22.3.0 + - clang=11.1.0 + - cmakelang=0.6.13 + - flake8=3.8.3 + - gcovr>=5.0 + - isort=5.10.1 + test: + - pytest + - pytest-cov + specific: + - matrix: + cuda: "11.5" + build: + - cuda-python>=11.5,<11.7.1 + - matrix: + cuda: "11.6" + build: + - cuda-python>=11.6,<11.7.1 + conda: + common: + build: + - spdlog>=1.8.5,<1.9 + develop: + - clang-tools=11.1.0 + specific: + - matrix: + cuda: "11.5" + build: + - cudatoolkit=11.5 + - matrix: + cuda: "11.6" + build: + - cudatoolkit=11.6 From 7ec63040b1a312cc8357f9047901667d3e8ed976 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 9 Sep 2022 12:28:08 -0700 Subject: [PATCH 149/675] Move clang dependency to conda develop packages. (#1092) This moves the `clang` package to the `conda` section instead of `conda_and_requirements`, since it is not pip-installable (the `clang` package on PyPI is not the same thing). Authors: - Bradley Dice (https://github.com/bdice) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1092 --- dependencies.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.yaml b/dependencies.yaml index 583e9415d..3e947b1d7 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -30,7 +30,6 @@ dependencies: - numpy>=1.19 develop: - black=22.3.0 - - clang=11.1.0 - cmakelang=0.6.13 - flake8=3.8.3 - gcovr>=5.0 @@ -52,6 +51,7 @@ dependencies: build: - spdlog>=1.8.5,<1.9 develop: + - clang=11.1.0 - clang-tools=11.1.0 specific: - matrix: From 28f6d2dfc231a15cd61ef81d76d6fb439956ffc1 Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Mon, 19 Sep 2022 22:21:02 +0200 Subject: [PATCH 150/675] `build.sh`: accept `--help` (#1093) Currently, the `--help` argument isn't supported: ``` $ ./build.sh --help Invalid option or formatting, check --help: --help ``` Authors: - Mads R. B. Kristensen (https://github.com/madsbk) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1093 --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 77d9e6722..5cbe43f6a 100755 --- a/build.sh +++ b/build.sh @@ -100,7 +100,7 @@ function ensureCMakeRan { fi } -if hasArg -h; then +if hasArg -h || hasArg --help; then echo "${HELP}" exit 0 fi From d355216488b5f31032abba1363e663c1c12553f6 Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Fri, 23 Sep 2022 11:36:52 -0400 Subject: [PATCH 151/675] DOC --- CHANGELOG.md | 4 ++++ CMakeLists.txt | 4 ++-- doxygen/Doxyfile | 2 +- python/CMakeLists.txt | 4 ++-- python/docs/conf.py | 4 ++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4602e1f3c..b36e1c4bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# RMM 22.12.00 (Date TBD) + +Please see https://github.com/rapidsai/rmm/releases/tag/v22.12.00a for the latest changes to this development branch. + # RMM 22.10.00 (Date TBD) Please see https://github.com/rapidsai/rmm/releases/tag/v22.10.00a for the latest changes to this development branch. diff --git a/CMakeLists.txt b/CMakeLists.txt index d5de4f6c7..f09c788e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.10/RAPIDS.cmake + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.12/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) endif() include(${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) @@ -27,7 +27,7 @@ include(rapids-find) project( RMM - VERSION 22.10.00 + VERSION 22.12.00 LANGUAGES CXX) # Write the version header diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 6d8df26f4..5e76c59f5 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "RMM" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 22.10 +PROJECT_NUMBER = 22.12 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 40bcc0955..a8c1a36f0 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -14,9 +14,9 @@ cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) -set(rmm_version 22.10.00) +set(rmm_version 22.12.00) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.10/RAPIDS.cmake +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.12/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) diff --git a/python/docs/conf.py b/python/docs/conf.py index 3db21a2e0..6e8182894 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -23,9 +23,9 @@ # built documents. # # The short X.Y version. -version = "22.10" +version = "22.12" # The full version, including alpha/beta/rc tags. -release = "22.10.00" +release = "22.12.00" # -- General configuration --------------------------------------------------- From 8de9847ccdac465bf9b838c8d01f322a3f34cb59 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 26 Sep 2022 21:34:20 -0400 Subject: [PATCH 152/675] Document that minimum required CMake version is now 3.23.1 (#1098) With rapids-cmake now requiring CMake 3.23.1 update consumers to correctly express this requirement Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Ray Douglass (https://github.com/raydouglass) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1098 --- CMakeLists.txt | 2 +- README.md | 2 +- conda/environments/all_cuda-115_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-116_arch-x86_64.yaml | 2 +- conda/recipes/librmm/conda_build_config.yaml | 2 +- conda/recipes/rmm/meta.yaml | 2 +- dependencies.yaml | 2 +- python/CMakeLists.txt | 2 +- python/pyproject.toml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d5de4f6c7..da2739e54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ # the License. # ============================================================================= -cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) +cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.10/RAPIDS.cmake diff --git a/README.md b/README.md index 507c5e325..2df1886dd 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Compiler requirements: * `gcc` version 9.3+ * `nvcc` version 11.0+ -* `cmake` version 3.20.1+ +* `cmake` version 3.23.1+ CUDA/GPU requirements: diff --git a/conda/environments/all_cuda-115_arch-x86_64.yaml b/conda/environments/all_cuda-115_arch-x86_64.yaml index 5efa00959..504344d52 100644 --- a/conda/environments/all_cuda-115_arch-x86_64.yaml +++ b/conda/environments/all_cuda-115_arch-x86_64.yaml @@ -7,7 +7,7 @@ dependencies: - black=22.3.0 - clang-tools=11.1.0 - clang=11.1.0 -- cmake>=3.20.1,!=3.23.0 +- cmake>=3.23.1 - cmakelang=0.6.13 - cuda-python>=11.5,<11.7.1 - cudatoolkit=11.5 diff --git a/conda/environments/all_cuda-116_arch-x86_64.yaml b/conda/environments/all_cuda-116_arch-x86_64.yaml index 65ab0e6a0..bea861989 100644 --- a/conda/environments/all_cuda-116_arch-x86_64.yaml +++ b/conda/environments/all_cuda-116_arch-x86_64.yaml @@ -7,7 +7,7 @@ dependencies: - black=22.3.0 - clang-tools=11.1.0 - clang=11.1.0 -- cmake>=3.20.1,!=3.23.0 +- cmake>=3.23.1 - cmakelang=0.6.13 - cuda-python>=11.6,<11.7.1 - cudatoolkit=11.6 diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index d84ffd1b3..fed85c316 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -8,7 +8,7 @@ cuda_compiler: - nvcc cmake_version: - - ">=3.20.1,!=3.23.0" + - ">=3.23.1" gtest_version: - "=1.10.0" diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index a4d5f19c3..9ae9679d6 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -23,7 +23,7 @@ build: requirements: build: - - cmake>=3.20.1,!=3.23.0 + - cmake>=3.23.1 - {{ compiler('c') }} - {{ compiler('cxx') }} - {{ compiler('cuda') }} {{ cuda_version }} diff --git a/dependencies.yaml b/dependencies.yaml index 3e947b1d7..8cafe278b 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -21,7 +21,7 @@ dependencies: conda_and_requirements: common: build: - - cmake>=3.20.1,!=3.23.0 + - cmake>=3.23.1 - cython>=0.29,<0.30 - python>=3.8,<3.10 - scikit-build>=0.13.1 diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 40bcc0955..26b776f4d 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -12,7 +12,7 @@ # the License. # ============================================================================= -cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) +cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) set(rmm_version 22.10.00) diff --git a/python/pyproject.toml b/python/pyproject.toml index d1f1a6639..c21e11779 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -19,7 +19,7 @@ requires = [ "setuptools", "cython>=0.29,<0.30", "scikit-build>=0.13.1", - "cmake>=3.20.1,!=3.23.0", + "cmake>=3.23.1", "ninja", "cuda-python>=11.5,<11.7.1", ] From 6e0d65a9d1c3058e33cbfbe3f64d81307f51cb2a Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 26 Sep 2022 22:09:00 -0400 Subject: [PATCH 153/675] Support using THRUST_WRAPPED_NAMESPACE (#1077) Allows rmm to be used in the presence of `THRUST_WRAPPED_NAMESPACE` which changes the namespace location of all thrust types. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Rong Ou (https://github.com/rongou) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1077 --- include/rmm/detail/thrust_namespace.h | 34 +++++++++++++++++++ include/rmm/device_vector.hpp | 1 + include/rmm/exec_policy.hpp | 1 + .../mr/device/cuda_async_memory_resource.hpp | 1 + .../cuda_async_view_memory_resource.hpp | 1 + .../mr/device/fixed_size_memory_resource.hpp | 1 + .../rmm/mr/device/pool_memory_resource.hpp | 1 + .../mr/device/thrust_allocator_adaptor.hpp | 1 + include/rmm/thrust_rmm_allocator.h | 1 + tests/CMakeLists.txt | 5 +++ tests/device_buffer_tests.cu | 4 +++ 11 files changed, 51 insertions(+) create mode 100644 include/rmm/detail/thrust_namespace.h diff --git a/include/rmm/detail/thrust_namespace.h b/include/rmm/detail/thrust_namespace.h new file mode 100644 index 000000000..b4b349eec --- /dev/null +++ b/include/rmm/detail/thrust_namespace.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022, 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. + */ + +#pragma once + +#include // namespace macros + +#ifdef THRUST_WRAPPED_NAMESPACE + +// Ensure the namespace exist before we import it +// so that this include can occur before thrust includes +namespace THRUST_WRAPPED_NAMESPACE { +namespace thrust { +} +} // namespace THRUST_WRAPPED_NAMESPACE + +namespace rmm { +using namespace THRUST_WRAPPED_NAMESPACE; +} + +#endif diff --git a/include/rmm/device_vector.hpp b/include/rmm/device_vector.hpp index c38f06b66..95fbe3810 100644 --- a/include/rmm/device_vector.hpp +++ b/include/rmm/device_vector.hpp @@ -18,6 +18,7 @@ #include +#include #include namespace rmm { diff --git a/include/rmm/exec_policy.hpp b/include/rmm/exec_policy.hpp index fdd22249f..015c3646d 100644 --- a/include/rmm/exec_policy.hpp +++ b/include/rmm/exec_policy.hpp @@ -24,6 +24,7 @@ #include #include +#include #include #include diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 063e65bb8..f378d7fd3 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -23,6 +23,7 @@ #include #include +#include #include #include diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index d36a2bff0..b562bc4c6 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -22,6 +22,7 @@ #include #include +#include #include #include diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index 59b0b59b8..65b6b77b7 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -21,6 +21,7 @@ #include #include +#include #include #include diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index c94e9e8c4..60ab60cf4 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -24,6 +24,7 @@ #include #include +#include #include #include #include diff --git a/include/rmm/mr/device/thrust_allocator_adaptor.hpp b/include/rmm/mr/device/thrust_allocator_adaptor.hpp index c09c9f334..2b2aee0dd 100644 --- a/include/rmm/mr/device/thrust_allocator_adaptor.hpp +++ b/include/rmm/mr/device/thrust_allocator_adaptor.hpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include diff --git a/include/rmm/thrust_rmm_allocator.h b/include/rmm/thrust_rmm_allocator.h index 894f402a1..3bbcab0a5 100644 --- a/include/rmm/thrust_rmm_allocator.h +++ b/include/rmm/thrust_rmm_allocator.h @@ -20,6 +20,7 @@ #include #include +#include #include namespace rmm { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8f68141fd..ecb44a49c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -87,6 +87,11 @@ function(ConfigureTest TEST_NAME) string(REGEX REPLACE "_TEST$" "_PTDS_TEST" PTDS_TEST_NAME "${TEST_NAME}") ConfigureTestInternal("${PTDS_TEST_NAME}" ${ARGN}) target_compile_definitions("${PTDS_TEST_NAME}" PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM) + + # Test with custom thrust namespace + string(REGEX REPLACE "_TEST$" "_NAMESPACE_TEST" NS_TEST_NAME "${TEST_NAME}") + ConfigureTestInternal("${NS_TEST_NAME}" ${ARGN}) + target_compile_definitions("${NS_TEST_NAME}" PUBLIC THRUST_WRAPPED_NAMESPACE=rmm_thrust) endfunction() # test sources diff --git a/tests/device_buffer_tests.cu b/tests/device_buffer_tests.cu index 4c25e2afb..fadae7bb2 100644 --- a/tests/device_buffer_tests.cu +++ b/tests/device_buffer_tests.cu @@ -29,6 +29,10 @@ #include #include +namespace testing { +namespace thrust = THRUST_NS_QUALIFIER; +} +using namespace testing; #include From e0fd8eb4338fd9a78f214554fcc7e890b081d612 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 27 Sep 2022 11:52:58 -0400 Subject: [PATCH 154/675] Remove cuda event deadlocking issues in device mr tests (#1097) We fixed both deadlocking issues due to a assumption that std::mutex would have fair scheduling, and work around deadlocks found in cuda event created in very short lived threads ( < 10ms ). Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Mark Harris (https://github.com/harrism) - Lawrence Mitchell (https://github.com/wence-) URL: https://github.com/rapidsai/rmm/pull/1097 --- tests/mr/device/mr_multithreaded_tests.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/mr/device/mr_multithreaded_tests.cpp b/tests/mr/device/mr_multithreaded_tests.cpp index 6d6d8edc2..1412e828f 100644 --- a/tests/mr/device/mr_multithreaded_tests.cpp +++ b/tests/mr/device/mr_multithreaded_tests.cpp @@ -179,6 +179,7 @@ void allocate_loop(rmm::mr::device_memory_resource* mr, std::size_t num_allocations, std::list& allocations, std::mutex& mtx, + std::condition_variable& allocations_ready, cudaEvent_t& event, rmm::cuda_stream_view stream) { @@ -195,27 +196,32 @@ void allocate_loop(rmm::mr::device_memory_resource* mr, RMM_CUDA_TRY(cudaEventRecord(event, stream.value())); allocations.emplace_back(ptr, size); } + allocations_ready.notify_one(); } + // Work around for threads going away before cudaEvent has finished async processing + cudaEventSynchronize(event); } void deallocate_loop(rmm::mr::device_memory_resource* mr, std::size_t num_allocations, std::list& allocations, std::mutex& mtx, + std::condition_variable& allocations_ready, cudaEvent_t& event, rmm::cuda_stream_view stream) { - for (std::size_t i = 0; i < num_allocations;) { - std::lock_guard lock(mtx); - if (allocations.empty()) { continue; } - i++; + for (std::size_t i = 0; i < num_allocations; i++) { + std::unique_lock lock(mtx); + allocations_ready.wait(lock, [&allocations] { return !allocations.empty(); }); RMM_CUDA_TRY(cudaStreamWaitEvent(stream.value(), event)); allocation alloc = allocations.front(); allocations.pop_front(); mr->deallocate(alloc.ptr, alloc.size, stream); } -} + // Work around for threads going away before cudaEvent has finished async processing + cudaEventSynchronize(event); +} void test_allocate_free_different_threads(rmm::mr::device_memory_resource* mr, rmm::cuda_stream_view streamA, rmm::cuda_stream_view streamB) @@ -223,6 +229,7 @@ void test_allocate_free_different_threads(rmm::mr::device_memory_resource* mr, constexpr std::size_t num_allocations{100}; std::mutex mtx; + std::condition_variable allocations_ready; std::list allocations; cudaEvent_t event; @@ -233,6 +240,7 @@ void test_allocate_free_different_threads(rmm::mr::device_memory_resource* mr, num_allocations, std::ref(allocations), std::ref(mtx), + std::ref(allocations_ready), std::ref(event), streamA); @@ -241,6 +249,7 @@ void test_allocate_free_different_threads(rmm::mr::device_memory_resource* mr, num_allocations, std::ref(allocations), std::ref(mtx), + std::ref(allocations_ready), std::ref(event), streamB); From 42fd22bf4089cb5f6cbc9aab394e292d21f1751b Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Tue, 27 Sep 2022 19:24:05 +0200 Subject: [PATCH 155/675] Propagate exceptions raised in Python callback functions (#1096) Currently, we ignore Python exceptions raised in callback functions called by resources such as `CallbackMemoryResource`. This is because Cython doesn't automatically translate Python exceptions into C++ exceptions (even though Cython does translate C++ exceptions into Python automatically). To address this issue, we now translate Python exceptions raised in the callback function into a C++ exception manually. Next, we remove Cython's [automatic C++ to Python exception translation](https://cython.readthedocs.io/en/stable/src/userguide/wrapping_CPlusPlus.html#exceptions) by **not** using the `except +` declaration. Thus, when the callback raises an exception, the caller (a memory resource implemented in C++) can catch and/or propagate the exception. Authors: - Mads R. B. Kristensen (https://github.com/madsbk) Approvers: - Ashwin Srinath (https://github.com/shwina) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1096 --- python/rmm/_lib/memory_resource.pyx | 56 ++++++++++++++++++++++++++--- python/rmm/tests/test_rmm.py | 41 +++++++++++++++++++-- 2 files changed, 91 insertions(+), 6 deletions(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index c774b5e50..7cb011ff0 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -21,6 +21,7 @@ from libc.stdint cimport int8_t, int64_t, uintptr_t from libcpp cimport bool from libcpp.cast cimport dynamic_cast from libcpp.memory cimport make_shared, make_unique, shared_ptr, unique_ptr +from libcpp.pair cimport pair from libcpp.string cimport string from cuda.cudart import cudaError_t @@ -35,6 +36,41 @@ from rmm._cuda.gpu import ( from rmm._lib.cuda_stream_view cimport cuda_stream_view +# Transparent handle of a C++ exception +ctypedef pair[int, string] CppExcept + +cdef CppExcept translate_python_except_to_cpp(err: BaseException): + """Translate a Python exception into a C++ exception handle + + The returned exception handle can then be thrown by `throw_cpp_except()`, + which MUST be done without holding the GIL. + + This is useful when C++ calls a Python function and needs to catch or + propagate exceptions. + """ + if isinstance(err, MemoryError): + return CppExcept(0, str.encode(str(err))) + return CppExcept(-1, str.encode(str(err))) + +# Implementation of `throw_cpp_except()`, which throws a given `CppExcept`. +# This function MUST be called without the GIL otherwise the thrown C++ +# exception are translated back into a Python exception. +cdef extern from *: + """ + #include + #include + + void throw_cpp_except(std::pair res) { + switch(res.first) { + case 0: + throw rmm::out_of_memory(res.second); + default: + throw std::runtime_error(res.second); + } + } + """ + void throw_cpp_except(CppExcept) nogil + # NOTE: Keep extern declarations in .pyx file as much as possible to avoid # leaking dependencies when importing RMM Cython .pxd files @@ -523,8 +559,14 @@ cdef void* _allocate_callback_wrapper( size_t nbytes, cuda_stream_view stream, void* ctx -) with gil: - return ((ctx)(nbytes)) +) nogil: + cdef CppExcept err + with gil: + try: + return ((ctx)(nbytes)) + except BaseException as e: + err = translate_python_except_to_cpp(e) + throw_cpp_except(err) cdef void _deallocate_callback_wrapper( void* ptr, @@ -787,8 +829,14 @@ cdef class TrackingResourceAdaptor(UpstreamResourceAdaptor): self.c_obj.get()))[0].log_outstanding_allocations() -cdef bool _oom_callback_function(size_t bytes, void *callback_arg) with gil: - return (callback_arg)(bytes) +cdef bool _oom_callback_function(size_t bytes, void *callback_arg) nogil: + cdef CppExcept err + with gil: + try: + return (callback_arg)(bytes) + except BaseException as e: + err = translate_python_except_to_cpp(e) + throw_cpp_except(err) cdef class FailureCallbackResourceAdaptor(UpstreamResourceAdaptor): diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index 5d5c3c18f..e4b503c08 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -712,6 +712,18 @@ def callback(nbytes: int) -> bool: assert retried[0] +def test_failure_callback_resource_adaptor_error(): + def callback(nbytes: int) -> bool: + raise RuntimeError("MyError") + + cuda_mr = rmm.mr.CudaMemoryResource() + mr = rmm.mr.FailureCallbackResourceAdaptor(cuda_mr, callback) + rmm.mr.set_current_device_resource(mr) + + with pytest.raises(RuntimeError, match="MyError"): + rmm.DeviceBuffer(size=int(1e11)) + + def test_dev_buf_circle_ref_dealloc(): rmm.mr.set_current_device_resource(rmm.mr.CudaMemoryResource()) @@ -760,13 +772,38 @@ def deallocate_func(ptr, size): rmm.mr.CallbackMemoryResource(allocate_func, deallocate_func) ) - dbuf = rmm.DeviceBuffer(size=256) - del dbuf + rmm.DeviceBuffer(size=256) captured = capsys.readouterr() assert captured.out == "Allocating 256 bytes\nDeallocating 256 bytes\n" +@pytest.mark.parametrize( + "err_raise,err_catch", + [ + (MemoryError, MemoryError), + (RuntimeError, RuntimeError), + (Exception, RuntimeError), + (BaseException, RuntimeError), + ], +) +def test_callback_mr_error(err_raise, err_catch): + base_mr = rmm.mr.CudaMemoryResource() + + def allocate_func(size): + raise err_raise("My alloc error") + + def deallocate_func(ptr, size): + return base_mr.deallocate(ptr, size) + + rmm.mr.set_current_device_resource( + rmm.mr.CallbackMemoryResource(allocate_func, deallocate_func) + ) + + with pytest.raises(err_catch, match="My alloc error"): + rmm.DeviceBuffer(size=256) + + @pytest.fixture def make_reinit_hook(): funcs = [] From a60fb27b6716525e82b5971b75279cbe23d80267 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 27 Sep 2022 20:15:28 -0400 Subject: [PATCH 156/675] Ensure consistent spdlog dependency target no matter the source (#1101) This removes the difference in targets generated for rmm depending on if spdlog is found on the machine, compared to being built as part of rmm. Now in all cases rmm targets depend on `spdlog::spdlog_header_only` and never `rmm::spdlog_header_only`. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1101 --- cmake/thirdparty/get_spdlog.cmake | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cmake/thirdparty/get_spdlog.cmake b/cmake/thirdparty/get_spdlog.cmake index e816bff35..f78ae0262 100644 --- a/cmake/thirdparty/get_spdlog.cmake +++ b/cmake/thirdparty/get_spdlog.cmake @@ -17,11 +17,16 @@ function(find_and_configure_spdlog) include(${rapids-cmake-dir}/cpm/spdlog.cmake) rapids_cpm_spdlog(INSTALL_EXPORT_SET rmm-exports) + rapids_export_package(BUILD spdlog rmm-exports) if(spdlog_ADDED) - install(TARGETS spdlog_header_only EXPORT rmm-exports) - else() - rapids_export_package(BUILD spdlog rmm-exports) + rapids_export( + BUILD spdlog + EXPORT_SET spdlog + GLOBAL_TARGETS spdlog spdlog_header_only + NAMESPACE spdlog::) + include("${rapids-cmake-dir}/export/find_package_root.cmake") + rapids_export_find_package_root(BUILD spdlog [=[${CMAKE_CURRENT_LIST_DIR}]=] rmm-exports) endif() endfunction() From e1a44e3a7a56b6d9c7d12e78539f4939547e6254 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Wed, 28 Sep 2022 15:59:49 -0400 Subject: [PATCH 157/675] enable recently_updated check --- .github/ops-bot.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ops-bot.yaml b/.github/ops-bot.yaml index 2ef41b367..57bdd6110 100644 --- a/.github/ops-bot.yaml +++ b/.github/ops-bot.yaml @@ -7,3 +7,4 @@ label_checker: true release_drafter: true copy_prs: true rerun_tests: true +recently_updated: true From d8c18e63f96180eb3b42ab40d755094fb088cc93 Mon Sep 17 00:00:00 2001 From: fkallen <37172449+fkallen@users.noreply.github.com> Date: Thu, 29 Sep 2022 00:29:31 +0200 Subject: [PATCH 158/675] Avoid unused parameter warnings in do_get_mem_info (#1084) closes #1032 Authors: - https://github.com/fkallen - Mark Harris (https://github.com/harrism) - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Mark Harris (https://github.com/harrism) - Rong Ou (https://github.com/rongou) - Jake Hemstad (https://github.com/jrhemstad) URL: https://github.com/rapidsai/rmm/pull/1084 --- include/rmm/mr/device/arena_memory_resource.hpp | 2 +- include/rmm/mr/device/binning_memory_resource.hpp | 3 +-- include/rmm/mr/device/fixed_size_memory_resource.hpp | 3 +-- include/rmm/mr/device/limiting_resource_adaptor.hpp | 3 +-- include/rmm/mr/device/managed_memory_resource.hpp | 3 +-- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index f1b4e40c4..1b1043b4a 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -293,7 +293,7 @@ class arena_memory_resource final : public device_memory_resource { * @param stream to execute on. * @return std::pair containing free_size and total_size of memory. */ - std::pair do_get_mem_info(cuda_stream_view stream) const override + std::pair do_get_mem_info(cuda_stream_view) const override { return std::make_pair(0, 0); } diff --git a/include/rmm/mr/device/binning_memory_resource.hpp b/include/rmm/mr/device/binning_memory_resource.hpp index fa8a9aa7c..e8f9be4c4 100644 --- a/include/rmm/mr/device/binning_memory_resource.hpp +++ b/include/rmm/mr/device/binning_memory_resource.hpp @@ -201,8 +201,7 @@ class binning_memory_resource final : public device_memory_resource { * @param stream the stream being executed on * @return std::pair with available and free memory for resource */ - [[nodiscard]] std::pair do_get_mem_info( - cuda_stream_view stream) const override + [[nodiscard]] std::pair do_get_mem_info(cuda_stream_view) const override { return std::make_pair(0, 0); } diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index 65b6b77b7..9a1923c2d 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -216,8 +216,7 @@ class fixed_size_memory_resource * @param stream the stream being executed on * @return std::pair with available and free memory for resource */ - [[nodiscard]] std::pair do_get_mem_info( - cuda_stream_view stream) const override + [[nodiscard]] std::pair do_get_mem_info(cuda_stream_view) const override { return std::make_pair(0, 0); } diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index cdcee0857..ba21cbb51 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -184,8 +184,7 @@ class limiting_resource_adaptor final : public device_memory_resource { * @param stream Stream on which to get the mem info. * @return std::pair contaiing free_size and total_size of memory */ - [[nodiscard]] std::pair do_get_mem_info( - cuda_stream_view stream) const override + [[nodiscard]] std::pair do_get_mem_info(cuda_stream_view) const override { return {allocation_limit_ - allocated_bytes_, allocation_limit_}; } diff --git a/include/rmm/mr/device/managed_memory_resource.hpp b/include/rmm/mr/device/managed_memory_resource.hpp index 1bc917e0e..d36b43e7d 100644 --- a/include/rmm/mr/device/managed_memory_resource.hpp +++ b/include/rmm/mr/device/managed_memory_resource.hpp @@ -114,8 +114,7 @@ class managed_memory_resource final : public device_memory_resource { * @param stream to execute on * @return std::pair contaiing free_size and total_size of memory */ - [[nodiscard]] std::pair do_get_mem_info( - cuda_stream_view stream) const override + [[nodiscard]] std::pair do_get_mem_info(cuda_stream_view) const override { std::size_t free_size{}; std::size_t total_size{}; From d401f90c6c41dec8119584f02856f69397b45227 Mon Sep 17 00:00:00 2001 From: Jordan Jacobelli Date: Thu, 29 Sep 2022 16:28:07 +0200 Subject: [PATCH 159/675] Add GitHub Actions workflows (#1104) * Add GitHub Actions workflows Signed-off-by: Jordan Jacobelli * Force creation of conda envs in checks and tests Signed-off-by: Jordan Jacobelli * Add test reports Signed-off-by: Jordan Jacobelli * switch pkg uploads to use GH Actions * switch py.test to pytest * revert sccache prefix change Signed-off-by: Jordan Jacobelli Co-authored-by: AJ Schmidt --- .github/workflows/branch-workflow.yaml | 34 ++++++ .github/workflows/dependency-files.yml | 8 -- .github/workflows/nightly-workflow.yaml | 54 +++++++++ .github/workflows/pr-workflow.yaml | 41 +++++++ ci/build_cpp.sh | 13 +++ ci/build_python.sh | 15 +++ ci/check_style.sh | 139 ++++++++++++++++++++++++ ci/cpu/build.sh | 5 +- ci/test_cpp.sh | 35 ++++++ ci/test_python.sh | 46 ++++++++ ci/upload_to_anaconda.sh | 7 ++ conda/recipes/librmm/meta.yaml | 6 +- conda/recipes/rmm/meta.yaml | 2 +- dependencies.yaml | 15 +++ 14 files changed, 406 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/branch-workflow.yaml delete mode 100644 .github/workflows/dependency-files.yml create mode 100644 .github/workflows/nightly-workflow.yaml create mode 100644 .github/workflows/pr-workflow.yaml create mode 100755 ci/build_cpp.sh create mode 100755 ci/build_python.sh create mode 100755 ci/check_style.sh create mode 100755 ci/test_cpp.sh create mode 100755 ci/test_python.sh create mode 100755 ci/upload_to_anaconda.sh diff --git a/.github/workflows/branch-workflow.yaml b/.github/workflows/branch-workflow.yaml new file mode 100644 index 000000000..4b2966268 --- /dev/null +++ b/.github/workflows/branch-workflow.yaml @@ -0,0 +1,34 @@ +name: branch + +on: + push: + branches: + - "branch-*" + tags: + - v[0-9][0-9].[0-9][0-9].[0-9][0-9] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + cpp-build: + name: C++ build + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-matrix-build.yaml@main + with: + build_type: branch + python-build: + name: Python build + needs: cpp-build + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-matrix-build.yaml@main + with: + build_type: branch + upload-conda: + name: Upload conda packages for branch builds + needs: python-build + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@main + with: + build_type: branch diff --git a/.github/workflows/dependency-files.yml b/.github/workflows/dependency-files.yml deleted file mode 100644 index aeda16f41..000000000 --- a/.github/workflows/dependency-files.yml +++ /dev/null @@ -1,8 +0,0 @@ -name: dependency-files - -on: - pull_request: - -jobs: - check-generated-files: - uses: rapidsai/shared-action-workflows/.github/workflows/dependency-files.yaml@main diff --git a/.github/workflows/nightly-workflow.yaml b/.github/workflows/nightly-workflow.yaml new file mode 100644 index 000000000..9d0bffd43 --- /dev/null +++ b/.github/workflows/nightly-workflow.yaml @@ -0,0 +1,54 @@ +name: nightly + +on: + workflow_call: + inputs: + REF: + required: true + type: string + +jobs: + cpp-build: + name: C++ build + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-matrix-build.yaml@main + with: + build_type: nightly + repo: rapidsai/rmm + ref: ${{ inputs.REF }} + cpp-tests: + name: C++ tests for PRs + needs: cpp-build + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@main + with: + build_type: nightly + repo: rapidsai/rmm + ref: ${{ inputs.REF }} + python-build: + name: Python build + needs: cpp-build + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-matrix-build.yaml@main + with: + build_type: nightly + repo: rapidsai/rmm + ref: ${{ inputs.REF }} + python-tests: + name: Python tests for PRs + needs: python-build + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@main + with: + build_type: nightly + repo: rapidsai/rmm + ref: ${{ inputs.REF }} + upload-conda: + name: Upload conda packages for branch builds + needs: [python-tests, cpp-tests] + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@main + with: + build_type: nightly + repo: rapidsai/rmm + ref: ${{ inputs.REF }} diff --git a/.github/workflows/pr-workflow.yaml b/.github/workflows/pr-workflow.yaml new file mode 100644 index 000000000..fe17f4fd9 --- /dev/null +++ b/.github/workflows/pr-workflow.yaml @@ -0,0 +1,41 @@ +name: pr + +on: + push: + branches: + - 'pull-request/[0-9]+' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + pr-builder: + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@main + checks: + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@main + conda-cpp-build: + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-matrix-build.yaml@main + with: + build_type: pull-request + conda-cpp-tests: + needs: conda-cpp-build + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@main + with: + build_type: pull-request + conda-python-build: + needs: conda-cpp-build + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-matrix-build.yaml@main + with: + build_type: pull-request + conda-python-tests: + needs: conda-python-build + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@main + with: + build_type: pull-request diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh new file mode 100755 index 000000000..d0e879fc1 --- /dev/null +++ b/ci/build_cpp.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -euo pipefail + +source rapids-env-update + +rapids-print-env + +rapids-logger "Begin cpp build" + +rapids-mamba-retry mambabuild conda/recipes/librmm + +rapids-upload-conda-to-s3 cpp diff --git a/ci/build_python.sh b/ci/build_python.sh new file mode 100755 index 000000000..41ad07fcb --- /dev/null +++ b/ci/build_python.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -euo pipefail + +source rapids-env-update + +rapids-print-env + +rapids-logger "Begin py build" + +CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) + +rapids-mamba-retry mambabuild -c "${CPP_CHANNEL}" conda/recipes/rmm + +rapids-upload-conda-to-s3 python diff --git a/ci/check_style.sh b/ci/check_style.sh new file mode 100755 index 000000000..bac8e684b --- /dev/null +++ b/ci/check_style.sh @@ -0,0 +1,139 @@ +#!/bin/bash +# Copyright (c) 2020, NVIDIA CORPORATION. + +set -euo pipefail + +rapids-logger "Create checks conda environment" +. /opt/conda/etc/profile.d/conda.sh + +rapids-dependency-file-generator \ + --generate conda \ + --file_key checks \ + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" > env.yaml + +rapids-mamba-retry env create --force -f env.yaml -n checks +conda activate checks + +set +e + +# Run isort and get results/return code +ISORT=$(isort --check-only python --settings-path=python/setup.cfg) +ISORT_RETVAL=$? + +# Run black and get results/return code +BLACK=$(black --config python/pyproject.toml --check python) +BLACK_RETVAL=$? + +# Run flake8 and get results/return code +FLAKE=$(flake8 --config=python/.flake8 python) +FLAKE_RETVAL=$? + +# Run flake8-cython and get results/return code +FLAKE_CYTHON=$(flake8 --config=python/.flake8.cython) +FLAKE_CYTHON_RETVAL=$? + +# Run clang-format and check for a consistent code format +CLANG_FORMAT=$(python scripts/run-clang-format.py 2>&1) +CLANG_FORMAT_RETVAL=$? + +# Run cmake-format / cmake-lint and get results/return code +CMAKE_FILES=($(find . | grep -E "^.*\.cmake(\.in)?$|^.*/CMakeLists.txt$")) + +CMAKE_FORMATS=() +CMAKE_FORMAT_RETVAL=0 + +CMAKE_LINTS=() +CMAKE_LINT_RETVAL=0 + +CURRENT_TAG=$(git tag --merged HEAD | grep -xE '^v.*' | sort --version-sort | tail -n 1 | tr -d 'v') +CURRENT_MAJOR=$(echo "${CURRENT_TAG}" | awk '{split($0, a, "."); print a[1]}') +CURRENT_MINOR=$(echo "${CURRENT_TAG}" | awk '{split($0, a, "."); print a[2]}') +CURRENT_SHORT_TAG="${CURRENT_MAJOR}.${CURRENT_MINOR}" +rapids-retry curl -s "https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${CURRENT_SHORT_TAG}/cmake-format-rapids-cmake.json" -o cmake/rapids-cmake.json + +for cmake_file in "${CMAKE_FILES[@]}"; do + cmake-format --in-place --config-files cmake/config.json cmake/rapids-cmake.json -- "${cmake_file}" + TMP_CMAKE_FORMAT=$(git diff --color --exit-code -- "${cmake_file}") + TMP_CMAKE_FORMAT_RETVAL=$? + if [ "$TMP_CMAKE_FORMAT_RETVAL" != "0" ]; then + CMAKE_FORMAT_RETVAL=1 + CMAKE_FORMATS+=("$TMP_CMAKE_FORMAT") + fi + + TMP_CMAKE_LINT=$(cmake-lint --config-files cmake/config.json cmake/rapids-cmake.json -- "${cmake_file}") + TMP_CMAKE_LINT_RETVAL=$? + if [ "$TMP_CMAKE_LINT_RETVAL" != "0" ]; then + CMAKE_LINT_RETVAL=1 + CMAKE_LINTS+=("$TMP_CMAKE_LINT") + fi +done + + +# Output results if failure otherwise show pass +if [ "$ISORT_RETVAL" != "0" ]; then + echo -e "\n\n>>>> FAILED: isort style check; begin output\n\n" + echo -e "$ISORT" + echo -e "\n\n>>>> FAILED: isort style check; end output\n\n" +else + echo -e "\n\n>>>> PASSED: isort style check\n\n" +fi + +if [ "$BLACK_RETVAL" != "0" ]; then + echo -e "\n\n>>>> FAILED: black style check; begin output\n\n" + echo -e "$BLACK" + echo -e "\n\n>>>> FAILED: black style check; end output\n\n" +else + echo -e "\n\n>>>> PASSED: black style check\n\n" +fi + +if [ "$FLAKE_RETVAL" != "0" ]; then + echo -e "\n\n>>>> FAILED: flake8 style check; begin output\n\n" + echo -e "$FLAKE" + echo -e "\n\n>>>> FAILED: flake8 style check; end output\n\n" +else + echo -e "\n\n>>>> PASSED: flake8 style check\n\n" +fi + +if [ "$FLAKE_CYTHON_RETVAL" != "0" ]; then + echo -e "\n\n>>>> FAILED: flake8-cython style check; begin output\n\n" + echo -e "$FLAKE_CYTHON" + echo -e "\n\n>>>> FAILED: flake8-cython style check; end output\n\n" +else + echo -e "\n\n>>>> PASSED: flake8-cython style check\n\n" +fi + +if [ "$CLANG_FORMAT_RETVAL" != "0" ]; then + echo -e "\n\n>>>> FAILED: clang format check; begin output\n\n" + echo -e "$CLANG_FORMAT" + echo -e "\n\n>>>> FAILED: clang format check; end output\n\n" +else + echo -e "\n\n>>>> PASSED: clang format check\n\n" +fi + +if [ "$CMAKE_FORMAT_RETVAL" != "0" ]; then + echo -e "\n\n>>>> FAILED: cmake format check; begin output\n\n" + for CMAKE_FORMAT in "${CMAKE_FORMATS[@]}"; do + echo -e "$CMAKE_FORMAT" + echo -e "\n" + done + echo -e "\n\n>>>> FAILED: cmake format check; end output\n\n" +else + echo -e "\n\n>>>> PASSED: cmake format check\n\n" +fi + +if [ "$CMAKE_LINT_RETVAL" != "0" ]; then + echo -e "\n\n>>>> FAILED: cmake lint check; begin output\n\n" + for CMAKE_LINT in "${CMAKE_LINTS[@]}"; do + echo -e "$CMAKE_LINT" + echo -e "\n" + done + echo -e "\n\n>>>> FAILED: cmake lint check; end output\n\n" +else + echo -e "\n\n>>>> PASSED: cmake lint check\n\n" +fi + +RETVALS=($ISORT_RETVAL $BLACK_RETVAL $FLAKE_RETVAL $FLAKE_CYTHON_RETVAL $CLANG_FORMAT_RETVAL $CMAKE_FORMAT_RETVAL $CMAKE_LINT_RETVAL) +IFS=$'\n' +RETVAL=$(echo "${RETVALS[*]}" | sort -nr | head -n1) + +exit "${RETVAL}" diff --git a/ci/cpu/build.sh b/ci/cpu/build.sh index 7b1208758..d67d2ddbf 100755 --- a/ci/cpu/build.sh +++ b/ci/cpu/build.sh @@ -91,6 +91,5 @@ fi # UPLOAD - Conda packages ################################################################################ -gpuci_logger "Upload conda packages" -source ci/cpu/upload.sh - +# gpuci_logger "Upload conda packages" +# source ci/cpu/upload.sh diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh new file mode 100755 index 000000000..b57173ec7 --- /dev/null +++ b/ci/test_cpp.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +set -euo pipefail + +. /opt/conda/etc/profile.d/conda.sh +conda activate base + +rapids-print-env + +CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) + +rapids-mamba-retry install \ + -c "${CPP_CHANNEL}" \ + rmm librmm librmm-tests + +TESTRESULTS_DIR=test-results +mkdir -p ${TESTRESULTS_DIR} +SUITEERROR=0 + +rapids-logger "Check GPU usage" +nvidia-smi + +set +e + +rapids-logger "Running googletests" +for gt in "$CONDA_PREFIX/bin/gtests/librmm/"* ; do + ${gt} --gtest_output=xml:${TESTRESULTS_DIR}/ + exitcode=$? + if (( ${exitcode} != 0 )); then + SUITEERROR=${exitcode} + echo "FAILED: GTest ${gt}" + fi +done + +exit ${SUITEERROR} diff --git a/ci/test_python.sh b/ci/test_python.sh new file mode 100755 index 000000000..4ce258c9e --- /dev/null +++ b/ci/test_python.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +set -euo pipefail + +rapids-logger "Create test conda environment" +. /opt/conda/etc/profile.d/conda.sh + +rapids-dependency-file-generator \ + --generate conda \ + --file_key test \ + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" > env.yaml + +rapids-mamba-retry env create --force -f env.yaml -n test +conda activate test + +rapids-print-env + +rapids-logger "Downloading artifacts from previous jobs" +CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) +PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) + +rapids-mamba-retry install \ + -c "${CPP_CHANNEL}" \ + -c "${PYTHON_CHANNEL}" \ + rmm librmm + +TESTRESULTS_DIR="${PWD}/test-results" +mkdir -p "${TESTRESULTS_DIR}" +SUITEERROR=0 + +rapids-logger "Check GPU usage" +nvidia-smi + +cd python + +set +e + +rapids-logger "pytest rmm" +pytest --cache-clear --junitxml="${TESTRESULTS_DIR}/junit-rmm.xml" -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:python/rmm-coverage.xml --cov-report term +exitcode=$? +if (( ${exitcode} != 0 )); then + SUITEERROR=${exitcode} + echo "FAILED: 1 or more tests in /rmm/python" +fi + +exit ${SUITEERROR} diff --git a/ci/upload_to_anaconda.sh b/ci/upload_to_anaconda.sh new file mode 100755 index 000000000..e53103fda --- /dev/null +++ b/ci/upload_to_anaconda.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) +PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) + +rapids-upload-to-anaconda "${CPP_CHANNEL}" +rapids-upload-to-anaconda "${PYTHON_CHANNEL}" diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index de0d55933..2e519b48c 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -1,7 +1,7 @@ # Copyright (c) 2018-2022, NVIDIA CORPORATION. {% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} -{% set cuda_version='.'.join(environ.get('CUDA', '9.2').split('.')[:2]) %} +{% set cuda_version='.'.join(environ.get('RAPIDS_CUDA_VERSION', '11.5.2').split('.')[:2]) %} {% set cuda_major=cuda_version.split('.')[0] %} {% set cuda_spec = ">=" + cuda_major ~ ",<" + (cuda_major | int + 1) ~ ".0a0" %} # i.e. >=11,<12.0a0 @@ -24,7 +24,7 @@ requirements: build: script_env: - PARALLEL_LEVEL - - CMAKE_GENERATOR + - CMAKE_GENERATOR=Ninja - CMAKE_C_COMPILER_LAUNCHER - CMAKE_CXX_COMPILER_LAUNCHER - CMAKE_CUDA_COMPILER_LAUNCHER @@ -33,6 +33,8 @@ build: - SCCACHE_BUCKET=rapids-sccache - SCCACHE_REGION=us-west-2 - SCCACHE_IDLE_TIMEOUT=32768 + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY outputs: - name: librmm diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 9ae9679d6..4f999acd7 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -2,7 +2,7 @@ {% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} {% set py_version=environ.get('CONDA_PY', 35) %} -{% set cuda_version='.'.join(environ.get('CUDA', '10.1').split('.')[:2]) %} +{% set cuda_version='.'.join(environ.get('RAPIDS_CUDA_VERSION', '11.5.2').split('.')[:2]) %} {% set cuda_major=cuda_version.split('.')[0] %} package: diff --git a/dependencies.yaml b/dependencies.yaml index 8cafe278b..3bdbc1829 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -14,6 +14,13 @@ files: generate: none includes: - test + - py_version + checks: + generate: none + includes: + - build + - develop + - py_version channels: - rapidsai - conda-forge @@ -54,6 +61,14 @@ dependencies: - clang=11.1.0 - clang-tools=11.1.0 specific: + - matrix: + py: "3.8" + py_version: + - python=3.8 + - matrix: + py: "3.9" + py_version: + - python=3.9 - matrix: cuda: "11.5" build: From 1fddc7bfd7febf09e4825f74fd67e9e78eeb79ae Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Thu, 29 Sep 2022 11:43:20 -0400 Subject: [PATCH 160/675] retrigger GH Actions after shared workflow changes changes to shared workflows require a new commit to test. hence this blank, no-op commit --- .github/ops-bot.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ops-bot.yaml b/.github/ops-bot.yaml index 57bdd6110..6f542f418 100644 --- a/.github/ops-bot.yaml +++ b/.github/ops-bot.yaml @@ -8,3 +8,4 @@ release_drafter: true copy_prs: true rerun_tests: true recently_updated: true + From 8a3a552e07fa8254c54804addcab103aea89f985 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Thu, 29 Sep 2022 17:25:44 -0400 Subject: [PATCH 161/675] update GitHub Actions This commit includes the following changes: - removes the `name` fields from the jobs in the `nightly` and `branch` workflows so they're consistent with the `pr` workflow - removes `ci/upload_to_anaconda.sh` since it's not needed after the changes in https://github.com/rapidsai/gha-tools/pull/17 --- .github/workflows/branch-workflow.yaml | 3 --- .github/workflows/nightly-workflow.yaml | 5 ----- ci/upload_to_anaconda.sh | 7 ------- 3 files changed, 15 deletions(-) delete mode 100755 ci/upload_to_anaconda.sh diff --git a/.github/workflows/branch-workflow.yaml b/.github/workflows/branch-workflow.yaml index 4b2966268..198f9dd09 100644 --- a/.github/workflows/branch-workflow.yaml +++ b/.github/workflows/branch-workflow.yaml @@ -13,20 +13,17 @@ concurrency: jobs: cpp-build: - name: C++ build secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-matrix-build.yaml@main with: build_type: branch python-build: - name: Python build needs: cpp-build secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-matrix-build.yaml@main with: build_type: branch upload-conda: - name: Upload conda packages for branch builds needs: python-build secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@main diff --git a/.github/workflows/nightly-workflow.yaml b/.github/workflows/nightly-workflow.yaml index 9d0bffd43..bb4447e79 100644 --- a/.github/workflows/nightly-workflow.yaml +++ b/.github/workflows/nightly-workflow.yaml @@ -9,7 +9,6 @@ on: jobs: cpp-build: - name: C++ build secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-matrix-build.yaml@main with: @@ -17,7 +16,6 @@ jobs: repo: rapidsai/rmm ref: ${{ inputs.REF }} cpp-tests: - name: C++ tests for PRs needs: cpp-build secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@main @@ -26,7 +24,6 @@ jobs: repo: rapidsai/rmm ref: ${{ inputs.REF }} python-build: - name: Python build needs: cpp-build secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-matrix-build.yaml@main @@ -35,7 +32,6 @@ jobs: repo: rapidsai/rmm ref: ${{ inputs.REF }} python-tests: - name: Python tests for PRs needs: python-build secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@main @@ -44,7 +40,6 @@ jobs: repo: rapidsai/rmm ref: ${{ inputs.REF }} upload-conda: - name: Upload conda packages for branch builds needs: [python-tests, cpp-tests] secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@main diff --git a/ci/upload_to_anaconda.sh b/ci/upload_to_anaconda.sh deleted file mode 100755 index e53103fda..000000000 --- a/ci/upload_to_anaconda.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) -PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) - -rapids-upload-to-anaconda "${CPP_CHANNEL}" -rapids-upload-to-anaconda "${PYTHON_CHANNEL}" From 7d3f1a610daed0ceb4e152f2e11f27a1a7a615fa Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Tue, 4 Oct 2022 12:49:34 -0400 Subject: [PATCH 162/675] add nightly-test workflow --- .github/workflows/nightly-test-workflow.yaml | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/nightly-test-workflow.yaml diff --git a/.github/workflows/nightly-test-workflow.yaml b/.github/workflows/nightly-test-workflow.yaml new file mode 100644 index 000000000..144af12e4 --- /dev/null +++ b/.github/workflows/nightly-test-workflow.yaml @@ -0,0 +1,29 @@ +name: nightly-test + +on: + workflow_dispatch: + inputs: + branch: + required: true + type: string + sha: + required: true + type: string + +jobs: + cpp-tests: + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@use-sha + with: + build_type: nightly + repo: rapidsai/rmm + branch: ${{ inputs.branch }} + sha: ${{ inputs.sha }} + python-tests: + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@use-sha + with: + build_type: nightly + repo: rapidsai/rmm + branch: ${{ inputs.branch }} + sha: ${{ inputs.sha }} From 6bbd4e4075d07446ef3c420d6edcaff1b8d3ed8f Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Tue, 4 Oct 2022 13:46:58 -0400 Subject: [PATCH 163/675] Remove `rmm` installation from `librmm` tests` (#1117) This PR removes the `rmm` conda package installation for `rmm` tests since it shouldn't be needed. --- ci/test_cpp.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index b57173ec7..f2c11cb9f 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -11,7 +11,7 @@ CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) rapids-mamba-retry install \ -c "${CPP_CHANNEL}" \ - rmm librmm librmm-tests + librmm librmm-tests TESTRESULTS_DIR=test-results mkdir -p ${TESTRESULTS_DIR} From 69fd1424e0eb948f32d0ce061325da4abbacc421 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Tue, 4 Oct 2022 17:05:16 -0400 Subject: [PATCH 164/675] Add `cudatoolkit` versions to `dependencies.yaml` (#1119) This PR adds a new list of dependencies called `cudatoolkit`, which are used to ensure that the proper `cudatoolkit` version is installed when creating test environments in `ci/test_{cpp,python}.sh`. It also bifurcates the existing `test` environment into `test_cpp` and `test_python` since some of the `test_python` dependencies aren't relevant for the C++ tests. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Jordan Jacobelli (https://github.com/Ethyling) --- ci/cpu/build.sh | 4 ++++ ci/gpu/build.sh | 4 ++++ ci/test_cpp.sh | 8 ++++++++ ci/test_python.sh | 2 +- dependencies.yaml | 31 +++++++++++++++++++++++++------ 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/ci/cpu/build.sh b/ci/cpu/build.sh index d67d2ddbf..747930924 100755 --- a/ci/cpu/build.sh +++ b/ci/cpu/build.sh @@ -21,6 +21,10 @@ cd $WORKSPACE export GPUCI_CONDA_RETRY_MAX=1 export GPUCI_CONDA_RETRY_SLEEP=30 +# Workaround to keep Jenkins builds working +# until we migrate fully to GitHub Actions +export RAPIDS_CUDA_VERSION="${CUDA}" + # If nightly build, append current YYMMDD to version if [[ "$BUILD_MODE" = "branch" && "$SOURCE_BRANCH" = branch-* ]] ; then export VERSION_SUFFIX=`date +%y%m%d` diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 2689667fb..3db5d3f77 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -27,6 +27,10 @@ export CUDA_MAJOR_VER=$(echo "${CUDA_VERSION}" | cut -f 1 -d.) export CUDA_MINOR_VER=$(echo "${CUDA_VERSION}" | cut -f 2 -d.) export CUDA_REL="${CUDA_MAJOR_VER}.${CUDA_MINOR_VER}" +# Workaround to keep Jenkins builds working +# until we migrate fully to GitHub Actions +export RAPIDS_CUDA_VERSION="${CUDA}" + # Get latest tag and number of commits since tag export GIT_DESCRIBE_TAG=`git describe --abbrev=0 --tags` export GIT_DESCRIBE_NUMBER=`git rev-list ${GIT_DESCRIBE_TAG}..HEAD --count` diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index f2c11cb9f..6179c52a1 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -5,6 +5,14 @@ set -euo pipefail . /opt/conda/etc/profile.d/conda.sh conda activate base +rapids-dependency-file-generator \ + --generate conda \ + --file_key test_cpp \ + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*}" > env.yaml + +rapids-mamba-retry env create --force -f env.yaml -n test +conda activate test + rapids-print-env CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) diff --git a/ci/test_python.sh b/ci/test_python.sh index 4ce258c9e..29b269b1e 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -7,7 +7,7 @@ rapids-logger "Create test conda environment" rapids-dependency-file-generator \ --generate conda \ - --file_key test \ + --file_key test_python \ --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" > env.yaml rapids-mamba-retry env create --force -f env.yaml -n test diff --git a/dependencies.yaml b/dependencies.yaml index 3bdbc1829..f6d920af2 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -7,14 +7,21 @@ files: arch: [x86_64] includes: - build + - cudatoolkit - develop - run - - test - test: + - test_cpp + - test_python + test_python: generate: none includes: - - test + - cudatoolkit - py_version + - test_python + test_cpp: + generate: none + includes: + - cudatoolkit checks: generate: none includes: @@ -41,7 +48,7 @@ dependencies: - flake8=3.8.3 - gcovr>=5.0 - isort=5.10.1 - test: + test_python: - pytest - pytest-cov specific: @@ -69,11 +76,23 @@ dependencies: py: "3.9" py_version: - python=3.9 + - matrix: + cuda: "11.0" + cudatoolkit: + - cudatoolkit=11.0 + - matrix: + cuda: "11.2" + cudatoolkit: + - cudatoolkit=11.2 + - matrix: + cuda: "11.4" + cudatoolkit: + - cudatoolkit=11.4 - matrix: cuda: "11.5" - build: + cudatoolkit: - cudatoolkit=11.5 - matrix: cuda: "11.6" - build: + cudatoolkit: - cudatoolkit=11.6 From 373beef39a86312b1e4e9f018e236404859300cb Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Wed, 5 Oct 2022 17:54:23 -0400 Subject: [PATCH 165/675] update nightly workflow --- .../workflows/{nightly-test-workflow.yaml => nightly.yaml} | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) rename .github/workflows/{nightly-test-workflow.yaml => nightly.yaml} (83%) diff --git a/.github/workflows/nightly-test-workflow.yaml b/.github/workflows/nightly.yaml similarity index 83% rename from .github/workflows/nightly-test-workflow.yaml rename to .github/workflows/nightly.yaml index 144af12e4..d76a3aba3 100644 --- a/.github/workflows/nightly-test-workflow.yaml +++ b/.github/workflows/nightly.yaml @@ -1,4 +1,4 @@ -name: nightly-test +name: nightly on: workflow_dispatch: @@ -6,6 +6,9 @@ on: branch: required: true type: string + date: + required: true + type: string sha: required: true type: string @@ -18,6 +21,7 @@ jobs: build_type: nightly repo: rapidsai/rmm branch: ${{ inputs.branch }} + date: ${{ inputs.date }} sha: ${{ inputs.sha }} python-tests: secrets: inherit @@ -26,4 +30,5 @@ jobs: build_type: nightly repo: rapidsai/rmm branch: ${{ inputs.branch }} + date: ${{ inputs.date }} sha: ${{ inputs.sha }} From fc02f273223b03f66557298b52f3da9451048685 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Thu, 6 Oct 2022 15:32:55 -0400 Subject: [PATCH 166/675] Update GH Action Workflows (#1123) This PR includes the following changes to the GitHub Action workflows: - Removes superfluous `-workflow` suffix from all existing workflows - Renames `branch.yaml` and `nightly.yaml` to `build.yaml` and `test.yaml` respectively - (`nightly.yaml` was committed separately [here](https://github.com/rapidsai/rmm/commit/373beef39a86312b1e4e9f018e236404859300cb) due to some unrelated GH Action quirks I had to workaround) - Updates `build.yaml` and `test.yaml` to be reusable workflows for use in our nightly pipeline job --- .github/workflows/branch-workflow.yaml | 31 ---------- .github/workflows/build.yaml | 57 +++++++++++++++++++ .github/workflows/nightly-workflow.yaml | 49 ---------------- .../workflows/{pr-workflow.yaml => pr.yaml} | 2 +- .github/workflows/{nightly.yaml => test.yaml} | 8 +-- 5 files changed, 62 insertions(+), 85 deletions(-) delete mode 100644 .github/workflows/branch-workflow.yaml create mode 100644 .github/workflows/build.yaml delete mode 100644 .github/workflows/nightly-workflow.yaml rename .github/workflows/{pr-workflow.yaml => pr.yaml} (97%) rename .github/workflows/{nightly.yaml => test.yaml} (88%) diff --git a/.github/workflows/branch-workflow.yaml b/.github/workflows/branch-workflow.yaml deleted file mode 100644 index 198f9dd09..000000000 --- a/.github/workflows/branch-workflow.yaml +++ /dev/null @@ -1,31 +0,0 @@ -name: branch - -on: - push: - branches: - - "branch-*" - tags: - - v[0-9][0-9].[0-9][0-9].[0-9][0-9] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - cpp-build: - secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-matrix-build.yaml@main - with: - build_type: branch - python-build: - needs: cpp-build - secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-matrix-build.yaml@main - with: - build_type: branch - upload-conda: - needs: python-build - secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@main - with: - build_type: branch diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 000000000..9e8d59875 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,57 @@ +name: build + +on: + push: + branches: + - "branch-*" + tags: + - v[0-9][0-9].[0-9][0-9].[0-9][0-9] + workflow_call: + inputs: + branch: + required: true + type: string + date: + required: true + type: string + sha: + required: true + type: string + build_type: + type: string + default: nightly + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + cpp-build: + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-matrix-build.yaml@main + with: + build_type: ${{ inputs.build_type || 'branch' }} + repo: rapidsai/rmm + branch: ${{ inputs.branch }} + date: ${{ inputs.date }} + sha: ${{ inputs.sha }} + python-build: + needs: [cpp-build] + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-matrix-build.yaml@main + with: + build_type: ${{ inputs.build_type || 'branch' }} + repo: rapidsai/rmm + branch: ${{ inputs.branch }} + date: ${{ inputs.date }} + sha: ${{ inputs.sha }} + upload-conda: + needs: [cpp-build, python-build] + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@main + with: + build_type: ${{ inputs.build_type || 'branch' }} + repo: rapidsai/rmm + branch: ${{ inputs.branch }} + date: ${{ inputs.date }} + sha: ${{ inputs.sha }} diff --git a/.github/workflows/nightly-workflow.yaml b/.github/workflows/nightly-workflow.yaml deleted file mode 100644 index bb4447e79..000000000 --- a/.github/workflows/nightly-workflow.yaml +++ /dev/null @@ -1,49 +0,0 @@ -name: nightly - -on: - workflow_call: - inputs: - REF: - required: true - type: string - -jobs: - cpp-build: - secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-matrix-build.yaml@main - with: - build_type: nightly - repo: rapidsai/rmm - ref: ${{ inputs.REF }} - cpp-tests: - needs: cpp-build - secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@main - with: - build_type: nightly - repo: rapidsai/rmm - ref: ${{ inputs.REF }} - python-build: - needs: cpp-build - secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-matrix-build.yaml@main - with: - build_type: nightly - repo: rapidsai/rmm - ref: ${{ inputs.REF }} - python-tests: - needs: python-build - secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@main - with: - build_type: nightly - repo: rapidsai/rmm - ref: ${{ inputs.REF }} - upload-conda: - needs: [python-tests, cpp-tests] - secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@main - with: - build_type: nightly - repo: rapidsai/rmm - ref: ${{ inputs.REF }} diff --git a/.github/workflows/pr-workflow.yaml b/.github/workflows/pr.yaml similarity index 97% rename from .github/workflows/pr-workflow.yaml rename to .github/workflows/pr.yaml index fe17f4fd9..d5185004b 100644 --- a/.github/workflows/pr-workflow.yaml +++ b/.github/workflows/pr.yaml @@ -3,7 +3,7 @@ name: pr on: push: branches: - - 'pull-request/[0-9]+' + - "pull-request/[0-9]+" concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/nightly.yaml b/.github/workflows/test.yaml similarity index 88% rename from .github/workflows/nightly.yaml rename to .github/workflows/test.yaml index d76a3aba3..7230acd84 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/test.yaml @@ -1,7 +1,7 @@ -name: nightly +name: test on: - workflow_dispatch: + workflow_call: inputs: branch: required: true @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@use-sha + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@main with: build_type: nightly repo: rapidsai/rmm @@ -25,7 +25,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@use-sha + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@main with: build_type: nightly repo: rapidsai/rmm From 7dacc1d9c0e74ff9a035ec63cb787d39763be92d Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Fri, 7 Oct 2022 11:31:29 -0400 Subject: [PATCH 167/675] GH Actions - Enforce `checks` before builds run (#1125) This PR ensures that all checks (file-size checker, dependency file checker, and style checker) are passing before any of the builds run. This is to prevent PRs from consuming precious GPU resources when a follow-up commit will be required. This is the current behavior that's enforced on Jenkins. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Jordan Jacobelli (https://github.com/Ethyling) --- .github/workflows/pr.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index d5185004b..fd1ab511e 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -17,6 +17,7 @@ jobs: secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@main conda-cpp-build: + needs: checks secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-matrix-build.yaml@main with: From 8f7a432d365c19ba2f143b5163ebc83d62fa6674 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 11 Oct 2022 12:17:07 -0500 Subject: [PATCH 168/675] Format gdb script. (#1127) This applies rmm's configured pre-commit hooks to format the gdb pretty printer script that was recently added (#1088). I would like to move rmm to use pre-commit for all style checks (as was recently done for cudf) and this is a prerequisite step. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1127 --- scripts/gdb-pretty-printers.py | 35 +++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/scripts/gdb-pretty-printers.py b/scripts/gdb-pretty-printers.py index df6a662ee..f541b0c2e 100644 --- a/scripts/gdb-pretty-printers.py +++ b/scripts/gdb-pretty-printers.py @@ -38,7 +38,7 @@ def __next__(self): class DeviceIterator: - """Iterates over arrays in device memory by copying chunks into host memory.""" + """Iterates over device arrays by copying chunks to the host.""" def __init__(self, start, size): self.exec = exec @@ -49,27 +49,33 @@ def __init__(self, start, size): self.sizeof = self.item.dereference().type.sizeof self.buffer_start = 0 # At most 1 MB or size, at least 1 - self.buffer_size = min(size, max(1, 2 ** 20 // self.sizeof)) - self.buffer = gdb.parse_and_eval(f"(void*)malloc({self.buffer_size * self.sizeof})") + self.buffer_size = min(size, max(1, 2**20 // self.sizeof)) + self.buffer = gdb.parse_and_eval( + f"(void*)malloc({self.buffer_size * self.sizeof})" + ) self.buffer.fetch_lazy() self.buffer_count = self.buffer_size self.update_buffer() def update_buffer(self): if self.buffer_count >= self.buffer_size: - self.buffer_item = gdb.parse_and_eval( - hex(self.buffer)).cast(self.item.type) + self.buffer_item = gdb.parse_and_eval(hex(self.buffer)).cast( + self.item.type + ) self.buffer_count = 0 self.buffer_start = self.count device_addr = hex(self.item.dereference().address) buffer_addr = hex(self.buffer) - size = min(self.buffer_size, self.size - - self.buffer_start) * self.sizeof + size = ( + min(self.buffer_size, self.size - self.buffer_start) + * self.sizeof + ) status = gdb.parse_and_eval( - f"(cudaError)cudaMemcpy({buffer_addr}, {device_addr}, {size}, cudaMemcpyDeviceToHost)") + f"(cudaError)cudaMemcpy({buffer_addr}, {device_addr}, {size}, " + "cudaMemcpyDeviceToHost)" + ) if status != 0: - raise gdb.MemoryError( - f"memcpy from device failed: {status}") + raise gdb.MemoryError(f"memcpy from device failed: {status}") def __del__(self): gdb.parse_and_eval(f"(void)free({hex(self.buffer)})").fetch_lazy() @@ -101,16 +107,19 @@ def __init__(self, val): self.capacity = int(val["_storage"]["_capacity"]) // el_type.sizeof def children(self): - return DeviceIterator(self.pointer, self.size) + return DeviceIterator(self.pointer, self.size) def to_string(self): - return (f"{self.val.type} of length {self.size}, capacity {self.capacity}") + return ( + f"{self.val.type} of length {self.size}, capacity {self.capacity}" + ) def display_hint(self): return "array" -# Workaround to avoid using the pretty printer on things like std::vector::iterator +# Workaround to avoid using the pretty printer on things like +# std::vector::iterator def is_template_type_not_alias(typename): loc = typename.find("<") if loc is None: From da283f68b49278cbe0adf743c1bfc080d948fd84 Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Wed, 12 Oct 2022 10:16:15 -0400 Subject: [PATCH 169/675] update changelog --- CHANGELOG.md | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4602e1f3c..bcdac0cab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,39 @@ -# RMM 22.10.00 (Date TBD) +# RMM 22.10.00 (12 Oct 2022) -Please see https://github.com/rapidsai/rmm/releases/tag/v22.10.00a for the latest changes to this development branch. +## 🐛 Bug Fixes + +- Ensure consistent spdlog dependency target no matter the source ([#1101](https://github.com/rapidsai/rmm/pull/1101)) [@robertmaynard](https://github.com/robertmaynard) +- Remove cuda event deadlocking issues in device mr tests ([#1097](https://github.com/rapidsai/rmm/pull/1097)) [@robertmaynard](https://github.com/robertmaynard) +- Propagate exceptions raised in Python callback functions ([#1096](https://github.com/rapidsai/rmm/pull/1096)) [@madsbk](https://github.com/madsbk) +- Avoid unused parameter warnings in do_get_mem_info ([#1084](https://github.com/rapidsai/rmm/pull/1084)) [@fkallen](https://github.com/fkallen) +- Use rapids-cmake 22.10 best practice for RAPIDS.cmake location ([#1083](https://github.com/rapidsai/rmm/pull/1083)) [@robertmaynard](https://github.com/robertmaynard) + +## 📖 Documentation + +- Document that minimum required CMake version is now 3.23.1 ([#1098](https://github.com/rapidsai/rmm/pull/1098)) [@robertmaynard](https://github.com/robertmaynard) +- Fix docs for module-level API ([#1091](https://github.com/rapidsai/rmm/pull/1091)) [@bdice](https://github.com/bdice) +- Improve DeviceBuffer docs. ([#1090](https://github.com/rapidsai/rmm/pull/1090)) [@bdice](https://github.com/bdice) +- Branch 22.10 merge 22.08 ([#1089](https://github.com/rapidsai/rmm/pull/1089)) [@harrism](https://github.com/harrism) +- Improve docs formatting and update links. ([#1086](https://github.com/rapidsai/rmm/pull/1086)) [@bdice](https://github.com/bdice) +- Add resources section to README. ([#1085](https://github.com/rapidsai/rmm/pull/1085)) [@bdice](https://github.com/bdice) +- Simplify PR template. ([#1080](https://github.com/rapidsai/rmm/pull/1080)) [@bdice](https://github.com/bdice) + +## 🚀 New Features + +- Add `gdb` pretty-printers for rmm types ([#1088](https://github.com/rapidsai/rmm/pull/1088)) [@upsj](https://github.com/upsj) +- Support using THRUST_WRAPPED_NAMESPACE ([#1077](https://github.com/rapidsai/rmm/pull/1077)) [@robertmaynard](https://github.com/robertmaynard) + +## 🛠️ Improvements + +- GH Actions - Enforce `checks` before builds run ([#1125](https://github.com/rapidsai/rmm/pull/1125)) [@ajschmidt8](https://github.com/ajschmidt8) +- Update GH Action Workflows ([#1123](https://github.com/rapidsai/rmm/pull/1123)) [@ajschmidt8](https://github.com/ajschmidt8) +- Add `cudatoolkit` versions to `dependencies.yaml` ([#1119](https://github.com/rapidsai/rmm/pull/1119)) [@ajschmidt8](https://github.com/ajschmidt8) +- Remove `rmm` installation from `librmm` tests` ([#1117](https://github.com/rapidsai/rmm/pull/1117)) [@ajschmidt8](https://github.com/ajschmidt8) +- Add GitHub Actions workflows ([#1104](https://github.com/rapidsai/rmm/pull/1104)) [@Ethyling](https://github.com/Ethyling) +- `build.sh`: accept `--help` ([#1093](https://github.com/rapidsai/rmm/pull/1093)) [@madsbk](https://github.com/madsbk) +- Move clang dependency to conda develop packages. ([#1092](https://github.com/rapidsai/rmm/pull/1092)) [@bdice](https://github.com/bdice) +- Add device_uvector::reserve and device_buffer::reserve ([#1079](https://github.com/rapidsai/rmm/pull/1079)) [@upsj](https://github.com/upsj) +- Bifurcate Dependency Lists ([#1073](https://github.com/rapidsai/rmm/pull/1073)) [@ajschmidt8](https://github.com/ajschmidt8) # RMM 22.08.00 (17 Aug 2022) From 5a6d7a6994889ba3b2ab8b3635f29642e322cc99 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 14 Oct 2022 17:33:46 -0500 Subject: [PATCH 170/675] Relax test for async memory pool IPC handle support (#1130) Replaces #1121. This PR resolves an inconsistency in the Python tests for IPC handle support. This issue has existed for at least a few months but the failure was not noticed in our nightly CI until switching to GitHub Actions. The core problem was that we were checking driver versions to determine support for IPC handles, which turned out to be a bad course of action. Instead, we should rely on checking for the feature support directly, with `cudart.cudaDeviceGetAttribute(cudart.cudaDeviceAttr.cudaDevAttrMemoryPoolSupportedHandleTypes, device_id)`. This is handled by the C++ code in rmm, and we now defer to that logic in Python tests. After some collaborative debugging, we found that our CI runners with driver 450 (CUDA 11.0) and newer CUDA toolkit versions like 11.4 and 11.5 were reporting the driver version incorrectly, and returned a value equal to the container's runtime version. This appears to stem from the same issue reported in https://github.com/NVIDIA/nvidia-docker/issues/1515 and https://github.com/NVIDIA/libnvidia-container/issues/138. This seems to be due to how the `cuda-compat` package injects (forward?) compatibility support into containers. Both the driver and runtime claimed to be new enough to support IPC handles, which require CUDA 11.3, despite the driver being older than 11.3. This meant that the attempt to use an IPC handle was rejected by the C++ code at runtime and the Python test failed. The Python code no longer attempts to determine if IPC should be supported according to driver/runtime versions, because this is not valid for all the configurations in CI. Creating a valid check for IPC handle support in the Python layer is complicated, due to Docker driver version issues mentioned above, so we just ensure the test fails in a predictable way if the driver/runtime do not support IPC. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Ashwin Srinath (https://github.com/shwina) URL: https://github.com/rapidsai/rmm/pull/1130 --- python/rmm/_cuda/gpu.py | 2 +- python/rmm/_lib/memory_resource.pyx | 12 ++---------- python/rmm/tests/test_rmm.py | 26 +++++++++++++++++++++----- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/python/rmm/_cuda/gpu.py b/python/rmm/_cuda/gpu.py index 5dddaf54f..e7f768349 100644 --- a/python/rmm/_cuda/gpu.py +++ b/python/rmm/_cuda/gpu.py @@ -142,7 +142,7 @@ def getDeviceProperties(device: int): def deviceGetName(device: int): """ - Returns an identifer string for the device. + Returns an identifier string for the device. Parameters ---------- diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 7cb011ff0..a20d481e0 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -314,16 +314,8 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): else optional[size_t](release_threshold) ) - # IPC export handle support query is only possibly on CUDA 11.3 or - # later, so IPC not supported on earlier versions - if enable_ipc: - driver_version = driverGetVersion() - runtime_version = runtimeGetVersion() - if (driver_version <= 11020 or runtime_version <= 11020): - raise ValueError( - "enable_ipc=True is not supported on CUDA <= 11.2." - ) - + # If IPC memory handles are not supported, the constructor below will + # raise an error from C++. cdef optional[allocation_handle_type] c_export_handle_type = ( optional[allocation_handle_type]( posix_file_descriptor diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index e4b503c08..a8a2b68e0 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -544,12 +544,28 @@ def test_cuda_async_memory_resource(dtype, nelem, alloc): reason="cudaMallocAsync not supported", ) def test_cuda_async_memory_resource_ipc(): - # Test that enabling IPC earlier than CUDA 11.3 raises a ValueError - if _driver_version < 11030 or _runtime_version < 11030: - with pytest.raises(ValueError): - mr = rmm.mr.CudaAsyncMemoryResource(enable_ipc=True) - else: + # TODO: We don't have a great way to check if IPC is supported in Python, + # without using the C++ function + # rmm::detail::async_alloc::is_export_handle_type_supported. We can't + # accurately test driver and runtime versions for this via Python because + # cuda-python always has the IPC handle enum defined (which normally + # requires a CUDA 11.3 runtime) and the cuda-compat package in Docker + # containers prevents us from assuming that the driver we see actually + # supports IPC handles even if its reported version is new enough (we may + # see a newer driver than what is present on the host). We can only know + # the expected behavior by checking the C++ function mentioned above, which + # is then a redundant check because the CudaAsyncMemoryResource constructor + # follows the same logic. Therefore, we cannot easily ensure this test + # passes in certain expected configurations -- we can only ensure that if + # it fails, it fails in a predictable way. + try: mr = rmm.mr.CudaAsyncMemoryResource(enable_ipc=True) + except RuntimeError as e: + # CUDA 11.3 is required for IPC memory handle support + assert str(e).endswith( + "Requested IPC memory handle type not supported" + ) + else: rmm.mr.set_current_device_resource(mr) assert rmm.mr.get_current_device_resource_type() is type(mr) From c6908221ce7d171dbda66e5a060f9ed00074c3b1 Mon Sep 17 00:00:00 2001 From: GALI PREM SAGAR Date: Mon, 17 Oct 2022 21:13:09 -0500 Subject: [PATCH 171/675] Add a public `copy` API to `DeviceBuffer` (#1128) This PR adds a public `copy` API to `DeviceBuffer`, this is required for the ongoing `copy-on-write` work in https://github.com/rapidsai/cudf/pull/11718 Authors: - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1128 --- python/rmm/_lib/device_buffer.pxd | 2 ++ python/rmm/_lib/device_buffer.pyx | 33 +++++++++++++++++++++++++++---- python/rmm/tests/test_rmm.py | 27 +++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/python/rmm/_lib/device_buffer.pxd b/python/rmm/_lib/device_buffer.pxd index fee6b126a..42c2b4fef 100644 --- a/python/rmm/_lib/device_buffer.pxd +++ b/python/rmm/_lib/device_buffer.pxd @@ -26,6 +26,8 @@ cdef extern from "rmm/device_buffer.hpp" namespace "rmm" nogil: device_buffer(size_t size, cuda_stream_view stream) except + device_buffer(const void* source_data, size_t size, cuda_stream_view stream) except + + device_buffer(const device_buffer buf, + cuda_stream_view stream) except + void reserve(size_t new_capacity, cuda_stream_view stream) except + void resize(size_t new_size, cuda_stream_view stream) except + void shrink_to_fit(cuda_stream_view stream) except + diff --git a/python/rmm/_lib/device_buffer.pyx b/python/rmm/_lib/device_buffer.pyx index 9ac034774..ce0009dbf 100644 --- a/python/rmm/_lib/device_buffer.pyx +++ b/python/rmm/_lib/device_buffer.pyx @@ -17,7 +17,7 @@ cimport cython from cpython.bytes cimport PyBytes_AS_STRING, PyBytes_FromStringAndSize from cython.operator cimport dereference from libc.stdint cimport uintptr_t -from libcpp.memory cimport unique_ptr +from libcpp.memory cimport make_unique, unique_ptr from libcpp.utility cimport move from rmm._cuda.stream cimport Stream @@ -133,6 +133,32 @@ cdef class DeviceBuffer: } return intf + def copy(self): + """Returns a copy of DeviceBuffer. + + Returns + ------- + A deep copy of existing ``DeviceBuffer`` + + Examples + -------- + >>> import rmm + >>> db = rmm.DeviceBuffer.to_device(b"abc") + >>> db_copy = db.copy() + >>> db.copy_to_host() + array([97, 98, 99], dtype=uint8) + >>> db_copy.copy_to_host() + array([97, 98, 99], dtype=uint8) + >>> assert db is not db_copy + >>> assert db.ptr != db_copy.ptr + """ + ret = DeviceBuffer(ptr=self.ptr, size=self.size, stream=self.stream) + ret.mr = self.mr + return ret + + def __copy__(self): + return self.copy() + @staticmethod cdef DeviceBuffer c_from_unique_ptr(unique_ptr[device_buffer] ptr): cdef DeviceBuffer buf = DeviceBuffer.__new__(DeviceBuffer) @@ -475,13 +501,12 @@ cpdef void copy_device_to_ptr(uintptr_t d_src, Examples -------- >>> import rmm - >>> import numpy as np >>> db = rmm.DeviceBuffer(size=5) >>> db2 = rmm.DeviceBuffer.to_device(b"abc") >>> rmm._lib.device_buffer.copy_device_to_ptr(db2.ptr, db.ptr, db2.size) >>> hb = db.copy_to_host() - >>> print(hb) - array([10, 11, 12, 0, 0], dtype=uint8) + >>> hb + array([97, 98, 99, 0, 0], dtype=uint8) """ with nogil: diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index a8a2b68e0..931ff5336 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import copy import gc import os import sys @@ -887,3 +888,29 @@ def func_with_arg(x): rmm.unregister_reinitialize_hook(func_with_arg) rmm.reinitialize() assert L == [2] + + +@pytest.mark.parametrize( + "cuda_ary", + [ + lambda: rmm.DeviceBuffer.to_device(b"abc"), + lambda: cuda.to_device(np.array([97, 98, 99, 0, 0], dtype="u1")), + ], +) +@pytest.mark.parametrize( + "make_copy", [lambda db: db.copy(), lambda db: copy.copy(db)] +) +def test_rmm_device_buffer_copy(cuda_ary, make_copy): + cuda_ary = cuda_ary() + db = rmm.DeviceBuffer.to_device(np.zeros(5, dtype="u1")) + db.copy_from_device(cuda_ary) + db_copy = make_copy(db) + + assert db is not db_copy + assert db.ptr != db_copy.ptr + assert len(db) == len(db_copy) + + expected = np.array([97, 98, 99, 0, 0], dtype="u1") + result = db_copy.copy_to_host() + + np.testing.assert_equal(expected, result) From 3b3707ee3417953fa302deb789078d4ae1e6da5e Mon Sep 17 00:00:00 2001 From: Ray Douglass <3107146+raydouglass@users.noreply.github.com> Date: Tue, 25 Oct 2022 15:10:10 -0400 Subject: [PATCH 172/675] Remove stale labeler (#1137) This PR removes the stale issue labeler workflow Authors: - Ray Douglass (https://github.com/raydouglass) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1137 --- .github/workflows/stale.yaml | 57 ------------------------------------ 1 file changed, 57 deletions(-) delete mode 100644 .github/workflows/stale.yaml diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml deleted file mode 100644 index 8b65da69a..000000000 --- a/.github/workflows/stale.yaml +++ /dev/null @@ -1,57 +0,0 @@ -name: Mark inactive issues and pull requests - -on: - schedule: - - cron: "0 * * * *" - -jobs: - mark-inactive-30d: - runs-on: ubuntu-latest - steps: - - name: Mark 30 day inactive issues and pull requests - uses: actions/stale@v3 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: > - This issue has been labeled `inactive-30d` due to no recent activity in the past 30 days. - Please close this issue if no further response or action is needed. - Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. - This issue will be labeled `inactive-90d` if there is no activity in the next 60 days. - stale-issue-label: "inactive-30d" - exempt-issue-labels: "0 - Blocked,0 - Backlog,good first issue" - days-before-issue-stale: 30 - days-before-issue-close: -1 - stale-pr-message: > - This PR has been labeled `inactive-30d` due to no recent activity in the past 30 days. - Please close this PR if it is no longer required. - Otherwise, please respond with a comment indicating any updates. - This PR will be labeled `inactive-90d` if there is no activity in the next 60 days. - stale-pr-label: "inactive-30d" - exempt-pr-labels: "0 - Blocked,0 - Backlog,good first issue" - days-before-pr-stale: 30 - days-before-pr-close: -1 - operations-per-run: 50 - mark-inactive-90d: - runs-on: ubuntu-latest - steps: - - name: Mark 90 day inactive issues and pull requests - uses: actions/stale@v3 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: > - This issue has been labeled `inactive-90d` due to no recent activity in the past 90 days. - Please close this issue if no further response or action is needed. - Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. - stale-issue-label: "inactive-90d" - exempt-issue-labels: "0 - Blocked,0 - Backlog,good first issue" - days-before-issue-stale: 90 - days-before-issue-close: -1 - stale-pr-message: > - This PR has been labeled `inactive-90d` due to no recent activity in the past 90 days. - Please close this PR if it is no longer required. - Otherwise, please respond with a comment indicating any updates. - stale-pr-label: "inactive-90d" - exempt-pr-labels: "0 - Blocked,0 - Backlog,good first issue" - days-before-pr-stale: 90 - days-before-pr-close: -1 - operations-per-run: 50 From 58588e8cedd36a925deea52ca7a1bbb0b190b207 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Mon, 24 Oct 2022 16:40:08 -0400 Subject: [PATCH 173/675] Update `dependencies.yaml` schema This PR updates the `dependencies.yaml` schema in anticipation of https://github.com/rapidsai/dependency-file-generator/pull/11 being merged. --- dependencies.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dependencies.yaml b/dependencies.yaml index f6d920af2..7259b06c6 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -1,7 +1,7 @@ # Dependency list for https://github.com/rapidsai/dependency-file-generator files: all: - generate: conda + output: conda matrix: cuda: ["11.5", "11.6"] arch: [x86_64] @@ -13,17 +13,17 @@ files: - test_cpp - test_python test_python: - generate: none + output: none includes: - cudatoolkit - py_version - test_python test_cpp: - generate: none + output: none includes: - cudatoolkit checks: - generate: none + output: none includes: - build - develop @@ -32,7 +32,7 @@ channels: - rapidsai - conda-forge dependencies: - conda_and_requirements: + - output_types: [conda, requirements] common: build: - cmake>=3.23.1 @@ -60,7 +60,7 @@ dependencies: cuda: "11.6" build: - cuda-python>=11.6,<11.7.1 - conda: + - output_types: [conda] common: build: - spdlog>=1.8.5,<1.9 From da924da0d0cf35a18d399f0625cf85aa69a75b90 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Tue, 25 Oct 2022 15:41:58 -0400 Subject: [PATCH 174/675] update flags --- ci/check_style.sh | 2 +- ci/test_cpp.sh | 2 +- ci/test_python.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/check_style.sh b/ci/check_style.sh index bac8e684b..677d9ef7b 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -7,7 +7,7 @@ rapids-logger "Create checks conda environment" . /opt/conda/etc/profile.d/conda.sh rapids-dependency-file-generator \ - --generate conda \ + --output conda \ --file_key checks \ --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" > env.yaml diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 6179c52a1..30c0eec0a 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -6,7 +6,7 @@ set -euo pipefail conda activate base rapids-dependency-file-generator \ - --generate conda \ + --output conda \ --file_key test_cpp \ --matrix "cuda=${RAPIDS_CUDA_VERSION%.*}" > env.yaml diff --git a/ci/test_python.sh b/ci/test_python.sh index 29b269b1e..e9c3ac093 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -6,7 +6,7 @@ rapids-logger "Create test conda environment" . /opt/conda/etc/profile.d/conda.sh rapids-dependency-file-generator \ - --generate conda \ + --output conda \ --file_key test_python \ --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" > env.yaml From 4de6eeca057454b293982682d2e3e1d2596ec554 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 26 Oct 2022 09:20:35 -0700 Subject: [PATCH 175/675] Switch to using rapids-cmake for gbench. (#1139) Switch to using a centralized rapids-cmake function for getting Google benchmark Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Robert Maynard (https://github.com/robertmaynard) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1139 --- CMakeLists.txt | 3 ++- cmake/thirdparty/get_gbench.cmake | 30 ------------------------------ 2 files changed, 2 insertions(+), 31 deletions(-) delete mode 100644 cmake/thirdparty/get_gbench.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index bd14104df..13e2d44e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,7 +102,8 @@ endif() # optionally build benchmarks if(BUILD_BENCHMARKS AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) - include(cmake/thirdparty/get_gbench.cmake) + include(${rapids-cmake-dir}/cpm/gbench.cmake) + rapids_cpm_gbench() add_subdirectory(benchmarks) endif() diff --git a/cmake/thirdparty/get_gbench.cmake b/cmake/thirdparty/get_gbench.cmake deleted file mode 100644 index 16286edf6..000000000 --- a/cmake/thirdparty/get_gbench.cmake +++ /dev/null @@ -1,30 +0,0 @@ -# ============================================================================= -# Copyright (c) 2021, 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. -# ============================================================================= - -# Use CPM to find or clone gbench -function(find_and_configure_gbench VERSION) - - if(TARGET benchmark::benchmark) - return() - endif() - - rapids_cpm_find( - benchmark ${VERSION} - CPM_ARGS GITHUB_REPOSITORY google/benchmark VERSION ${VERSION} - GIT_SHALLOW TRUE - OPTIONS "BENCHMARK_ENABLE_TESTING OFF" "BENCHMARK_ENABLE_INSTALL OFF") - -endfunction() - -find_and_configure_gbench(1.5.2) From e043158ab1419be5cb88a212deebd1922fc12170 Mon Sep 17 00:00:00 2001 From: Ashwin Srinath <3190405+shwina@users.noreply.github.com> Date: Wed, 26 Oct 2022 15:35:22 -0400 Subject: [PATCH 176/675] HOTFIX: Update cuda-python dependency to 11.7.1 (#1136) This should resolve a segfault we are seeing with `cuda-python=11.7.0` (https://github.com/rapidsai/cudf/issues/11941). Authors: - Ashwin Srinath (https://github.com/shwina) - AJ Schmidt (https://github.com/ajschmidt8) - Bradley Dice (https://github.com/bdice) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) - Bradley Dice (https://github.com/bdice) - Mark Harris (https://github.com/harrism) - AJ Schmidt (https://github.com/ajschmidt8) --- README.md | 11 +++----- .../all_cuda-115_arch-x86_64.yaml | 2 +- .../all_cuda-116_arch-x86_64.yaml | 2 +- conda/recipes/rmm/meta.yaml | 4 +-- dependencies.yaml | 4 +-- python/pyproject.toml | 2 +- python/rmm/_cuda/gpu.py | 2 +- python/rmm/_lib/memory_resource.pyx | 12 ++------- python/rmm/tests/test_rmm.py | 26 +++++++++++++++---- 9 files changed, 35 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 2df1886dd..2292b331e 100644 --- a/README.md +++ b/README.md @@ -39,15 +39,12 @@ RMM can be installed with Conda ([miniconda](https://conda.io/miniconda.html), o [Anaconda distribution](https://www.anaconda.com/download)) from the `rapidsai` channel: ```bash +# for CUDA 11.5 +conda install -c rapidsai -c conda-forge -c nvidia \ + rmm cudatoolkit=11.5 # for CUDA 11.2 -conda install -c nvidia -c rapidsai -c conda-forge \ +conda install -c rapidsai -c conda-forge -c nvidia \ rmm cudatoolkit=11.2 -# for CUDA 11.1 -conda install -c nvidia -c rapidsai -c conda-forge \ - rmm cudatoolkit=11.1 -# for CUDA 11.0 -conda install -c nvidia -c rapidsai -c conda-forge \ - rmm cudatoolkit=11.0 ``` We also provide [nightly Conda packages](https://anaconda.org/rapidsai-nightly) built from the HEAD diff --git a/conda/environments/all_cuda-115_arch-x86_64.yaml b/conda/environments/all_cuda-115_arch-x86_64.yaml index 504344d52..9e452ac49 100644 --- a/conda/environments/all_cuda-115_arch-x86_64.yaml +++ b/conda/environments/all_cuda-115_arch-x86_64.yaml @@ -9,7 +9,7 @@ dependencies: - clang=11.1.0 - cmake>=3.23.1 - cmakelang=0.6.13 -- cuda-python>=11.5,<11.7.1 +- cuda-python>=11.7.1,<12.0 - cudatoolkit=11.5 - cython>=0.29,<0.30 - flake8=3.8.3 diff --git a/conda/environments/all_cuda-116_arch-x86_64.yaml b/conda/environments/all_cuda-116_arch-x86_64.yaml index bea861989..3c27666cf 100644 --- a/conda/environments/all_cuda-116_arch-x86_64.yaml +++ b/conda/environments/all_cuda-116_arch-x86_64.yaml @@ -9,7 +9,7 @@ dependencies: - clang=11.1.0 - cmake>=3.23.1 - cmakelang=0.6.13 -- cuda-python>=11.6,<11.7.1 +- cuda-python>=11.7.1,<12.0 - cudatoolkit=11.6 - cython>=0.29,<0.30 - flake8=3.8.3 diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 4f999acd7..09de74cea 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -29,7 +29,7 @@ requirements: - {{ compiler('cuda') }} {{ cuda_version }} - sysroot_{{ target_platform }} {{ sysroot_version }} host: - - cuda-python >=11.5,<11.7.1 + - cuda-python >=11.7.1,<12.0 - cudatoolkit {{ cuda_version }}.* - cython >=0.29,<0.30 - librmm {{ version }}.* @@ -38,7 +38,7 @@ requirements: - setuptools - spdlog>=1.8.5,<2.0.0a0 run: - - cuda-python >=11.5,<11.7.1 + - cuda-python >=11.7.1,<12.0 - numba >=0.49 - numpy >=1.19 - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} diff --git a/dependencies.yaml b/dependencies.yaml index 7259b06c6..543618335 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -55,11 +55,11 @@ dependencies: - matrix: cuda: "11.5" build: - - cuda-python>=11.5,<11.7.1 + - cuda-python>=11.7.1,<12.0 - matrix: cuda: "11.6" build: - - cuda-python>=11.6,<11.7.1 + - cuda-python>=11.7.1,<12.0 - output_types: [conda] common: build: diff --git a/python/pyproject.toml b/python/pyproject.toml index c21e11779..f1de64653 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -21,7 +21,7 @@ requires = [ "scikit-build>=0.13.1", "cmake>=3.23.1", "ninja", - "cuda-python>=11.5,<11.7.1", + "cuda-python>=11.7.1,<12.0" ] [tool.black] diff --git a/python/rmm/_cuda/gpu.py b/python/rmm/_cuda/gpu.py index 5dddaf54f..e7f768349 100644 --- a/python/rmm/_cuda/gpu.py +++ b/python/rmm/_cuda/gpu.py @@ -142,7 +142,7 @@ def getDeviceProperties(device: int): def deviceGetName(device: int): """ - Returns an identifer string for the device. + Returns an identifier string for the device. Parameters ---------- diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 7cb011ff0..a20d481e0 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -314,16 +314,8 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): else optional[size_t](release_threshold) ) - # IPC export handle support query is only possibly on CUDA 11.3 or - # later, so IPC not supported on earlier versions - if enable_ipc: - driver_version = driverGetVersion() - runtime_version = runtimeGetVersion() - if (driver_version <= 11020 or runtime_version <= 11020): - raise ValueError( - "enable_ipc=True is not supported on CUDA <= 11.2." - ) - + # If IPC memory handles are not supported, the constructor below will + # raise an error from C++. cdef optional[allocation_handle_type] c_export_handle_type = ( optional[allocation_handle_type]( posix_file_descriptor diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index e4b503c08..a8a2b68e0 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -544,12 +544,28 @@ def test_cuda_async_memory_resource(dtype, nelem, alloc): reason="cudaMallocAsync not supported", ) def test_cuda_async_memory_resource_ipc(): - # Test that enabling IPC earlier than CUDA 11.3 raises a ValueError - if _driver_version < 11030 or _runtime_version < 11030: - with pytest.raises(ValueError): - mr = rmm.mr.CudaAsyncMemoryResource(enable_ipc=True) - else: + # TODO: We don't have a great way to check if IPC is supported in Python, + # without using the C++ function + # rmm::detail::async_alloc::is_export_handle_type_supported. We can't + # accurately test driver and runtime versions for this via Python because + # cuda-python always has the IPC handle enum defined (which normally + # requires a CUDA 11.3 runtime) and the cuda-compat package in Docker + # containers prevents us from assuming that the driver we see actually + # supports IPC handles even if its reported version is new enough (we may + # see a newer driver than what is present on the host). We can only know + # the expected behavior by checking the C++ function mentioned above, which + # is then a redundant check because the CudaAsyncMemoryResource constructor + # follows the same logic. Therefore, we cannot easily ensure this test + # passes in certain expected configurations -- we can only ensure that if + # it fails, it fails in a predictable way. + try: mr = rmm.mr.CudaAsyncMemoryResource(enable_ipc=True) + except RuntimeError as e: + # CUDA 11.3 is required for IPC memory handle support + assert str(e).endswith( + "Requested IPC memory handle type not supported" + ) + else: rmm.mr.set_current_device_resource(mr) assert rmm.mr.get_current_device_resource_type() is type(mr) From ca53a5ea8b1ffb7df9ca3c85b491883408fc7425 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Thu, 27 Oct 2022 16:39:56 -0400 Subject: [PATCH 177/675] Use `ninja` in GitHub Actions (#1142) This PR adds an environment variable to ensure that CMake uses `ninja` as its build system, which was the behavior in Jenkins. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Sevag H (https://github.com/sevagh) URL: https://github.com/rapidsai/rmm/pull/1142 --- ci/build_cpp.sh | 2 ++ ci/build_python.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index d0e879fc1..6f8a1375c 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -4,6 +4,8 @@ set -euo pipefail source rapids-env-update +export CMAKE_GENERATOR=Ninja + rapids-print-env rapids-logger "Begin cpp build" diff --git a/ci/build_python.sh b/ci/build_python.sh index 41ad07fcb..ae4294cc5 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -4,6 +4,8 @@ set -euo pipefail source rapids-env-update +export CMAKE_GENERATOR=Ninja + rapids-print-env rapids-logger "Begin py build" From ade56a14d81c16380ca547cd46d8969042e29d78 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Fri, 28 Oct 2022 10:45:19 -0400 Subject: [PATCH 178/675] Remove Jenkins scripts (#1143) Since we've switched to GitHub Actions, this PR removes any old scripts that were used by Jenkins. Additionally it removes/updates any references to `gpuCI`. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Jordan Jacobelli (https://github.com/Ethyling) URL: https://github.com/rapidsai/rmm/pull/1143 --- .github/labeler.yml | 2 +- CONTRIBUTING.md | 5 -- README.md | 2 - ci/checks/changelog.sh | 39 ----------- ci/checks/style.sh | 137 ------------------------------------- ci/cpu/build.sh | 99 --------------------------- ci/cpu/prebuild.sh | 11 --- ci/cpu/upload.sh | 50 -------------- ci/gpu/build.sh | 137 ------------------------------------- ci/local/README.md | 58 ---------------- ci/local/build.sh | 151 ----------------------------------------- 11 files changed, 1 insertion(+), 690 deletions(-) delete mode 100755 ci/checks/changelog.sh delete mode 100644 ci/checks/style.sh delete mode 100755 ci/cpu/build.sh delete mode 100644 ci/cpu/prebuild.sh delete mode 100644 ci/cpu/upload.sh delete mode 100755 ci/gpu/build.sh delete mode 100644 ci/local/README.md delete mode 100755 ci/local/build.sh diff --git a/.github/labeler.yml b/.github/labeler.yml index 112d0d2f9..3260eeae2 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -17,5 +17,5 @@ cpp: - 'tests/**' - 'doxygen/**' -gpuCI: +ci: - 'ci/**' diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bd654bef3..61ac5873a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -56,10 +56,5 @@ contributing to. Start with _Step 3_ from above, commenting on the issue to let others know you are working on it. If you have any questions related to the implementation of the issue, ask them in the issue instead of the PR. -### Building and Testing on a gpuCI image locally - -Before submitting a pull request, you can do a local build and test on your machine that mimics our gpuCI environment using the `ci/local/build.sh` script. -For detailed information on usage of this script, see [here](ci/local/README.md). - ## Attribution Portions adopted from https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md diff --git a/README.md b/README.md index 2292b331e..ef2fa43a1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ #
 RMM: RAPIDS Memory Manager
-[![Build Status](https://gpuci.gpuopenanalytics.com/job/rapidsai/job/gpuci/job/rmm/job/branches/job/rmm-branch-pipeline/badge/icon)](https://gpuci.gpuopenanalytics.com/job/rapidsai/job/gpuci/job/rmm/job/branches/job/rmm-branch-pipeline/) - **NOTE:** For the latest stable [README.md](https://github.com/rapidsai/rmm/blob/main/README.md) ensure you are on the `main` branch. ## Resources diff --git a/ci/checks/changelog.sh b/ci/checks/changelog.sh deleted file mode 100755 index 2cb0edbac..000000000 --- a/ci/checks/changelog.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# Copyright (c) 2020, NVIDIA CORPORATION. -######################### -# RMM CHANGELOG Tester # -######################### - -# Checkout main for comparison -git checkout --force --quiet main - -# Switch back to tip of PR branch -git checkout --force --quiet current-pr-branch - -# Ignore errors during searching -set +e - -# Get list of modified files between matster and PR branch -CHANGELOG=`git diff --name-only main...current-pr-branch | grep CHANGELOG.md` -# Check if CHANGELOG has PR ID -PRNUM=`cat CHANGELOG.md | grep "$PR_ID"` -RETVAL=0 - -# Return status of check result -if [ "$CHANGELOG" != "" -a "$PRNUM" != "" ] ; then - echo -e "\n\n>>>> PASSED: CHANGELOG.md has been updated with current PR information.\n\nPlease ensure the update meets the following criteria.\n" -else - echo -e "\n\n>>>> FAILED: CHANGELOG.md has not been updated!\n\nPlease add a line describing this PR to CHANGELOG.md in the repository root directory. The line should meet the following criteria.\n" - RETVAL=1 -fi - -cat << EOF - It should be placed under the section for the appropriate release. - It should be placed under "New Features", "Improvements", or "Bug Fixes" as appropriate. - It should be formatted as '- PR # ' - Example format for #491 '- PR #491 Add CI test script to check for updates to CHANGELOG.md in PRs' - - -EOF - -exit $RETVAL diff --git a/ci/checks/style.sh b/ci/checks/style.sh deleted file mode 100644 index cec606871..000000000 --- a/ci/checks/style.sh +++ /dev/null @@ -1,137 +0,0 @@ -#!/bin/bash -# Copyright (c) 2020, NVIDIA CORPORATION. -##################### -# RMM Style Tester # -##################### - -# Ignore errors and set path -set +e -PATH=/opt/conda/bin:$PATH -LC_ALL=C.UTF-8 -LANG=C.UTF-8 - -# Activate common conda env -. /opt/conda/etc/profile.d/conda.sh -conda activate rapids - -# Run isort and get results/return code -ISORT=`isort --check-only python --settings-path=python/setup.cfg ` -ISORT_RETVAL=$? - -# Run black and get results/return code -BLACK=`black --config python/pyproject.toml --check python` -BLACK_RETVAL=$? - -# Run flake8 and get results/return code -FLAKE=`flake8 --config=python/.flake8 python` -FLAKE_RETVAL=$? - -# Run flake8-cython and get results/return code -FLAKE_CYTHON=`flake8 --config=python/.flake8.cython` -FLAKE_CYTHON_RETVAL=$? - -# Run clang-format and check for a consistent code format -CLANG_FORMAT=`python scripts/run-clang-format.py 2>&1` -CLANG_FORMAT_RETVAL=$? - -# Run cmake-format / cmake-lint and get results/return code -CMAKE_FILES=(`find | grep -E "^.*\.cmake(\.in)?$|^.*/CMakeLists.txt$"`) - -CMAKE_FORMATS=() -CMAKE_FORMAT_RETVAL=0 - -CMAKE_LINTS=() -CMAKE_LINT_RETVAL=0 - -CURRENT_TAG=$(git tag --merged HEAD | grep -xE '^v.*' | sort --version-sort | tail -n 1 | tr -d 'v') -CURRENT_MAJOR=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[1]}') -CURRENT_MINOR=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[2]}') -CURRENT_SHORT_TAG=${CURRENT_MAJOR}.${CURRENT_MINOR} -gpuci_retry curl -s https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${CURRENT_SHORT_TAG}/cmake-format-rapids-cmake.json -o cmake/rapids-cmake.json - -for cmake_file in "${CMAKE_FILES[@]}"; do - cmake-format --in-place --config-files cmake/config.json cmake/rapids-cmake.json -- ${cmake_file} - TMP_CMAKE_FORMAT=`git diff --color --exit-code -- ${cmake_file}` - TMP_CMAKE_FORMAT_RETVAL=$? - if [ "$TMP_CMAKE_FORMAT_RETVAL" != "0" ]; then - CMAKE_FORMAT_RETVAL=1 - CMAKE_FORMATS+=("$TMP_CMAKE_FORMAT") - fi - - TMP_CMAKE_LINT=`cmake-lint --config-files cmake/config.json cmake/rapids-cmake.json -- ${cmake_file}` - TMP_CMAKE_LINT_RETVAL=$? - if [ "$TMP_CMAKE_LINT_RETVAL" != "0" ]; then - CMAKE_LINT_RETVAL=1 - CMAKE_LINTS+=("$TMP_CMAKE_LINT") - fi -done - - -# Output results if failure otherwise show pass -if [ "$ISORT_RETVAL" != "0" ]; then - echo -e "\n\n>>>> FAILED: isort style check; begin output\n\n" - echo -e "$ISORT" - echo -e "\n\n>>>> FAILED: isort style check; end output\n\n" -else - echo -e "\n\n>>>> PASSED: isort style check\n\n" -fi - -if [ "$BLACK_RETVAL" != "0" ]; then - echo -e "\n\n>>>> FAILED: black style check; begin output\n\n" - echo -e "$BLACK" - echo -e "\n\n>>>> FAILED: black style check; end output\n\n" -else - echo -e "\n\n>>>> PASSED: black style check\n\n" -fi - -if [ "$FLAKE_RETVAL" != "0" ]; then - echo -e "\n\n>>>> FAILED: flake8 style check; begin output\n\n" - echo -e "$FLAKE" - echo -e "\n\n>>>> FAILED: flake8 style check; end output\n\n" -else - echo -e "\n\n>>>> PASSED: flake8 style check\n\n" -fi - -if [ "$FLAKE_CYTHON_RETVAL" != "0" ]; then - echo -e "\n\n>>>> FAILED: flake8-cython style check; begin output\n\n" - echo -e "$FLAKE_CYTHON" - echo -e "\n\n>>>> FAILED: flake8-cython style check; end output\n\n" -else - echo -e "\n\n>>>> PASSED: flake8-cython style check\n\n" -fi - -if [ "$CLANG_FORMAT_RETVAL" != "0" ]; then - echo -e "\n\n>>>> FAILED: clang format check; begin output\n\n" - echo -e "$CLANG_FORMAT" - echo -e "\n\n>>>> FAILED: clang format check; end output\n\n" -else - echo -e "\n\n>>>> PASSED: clang format check\n\n" -fi - -if [ "$CMAKE_FORMAT_RETVAL" != "0" ]; then - echo -e "\n\n>>>> FAILED: cmake format check; begin output\n\n" - for CMAKE_FORMAT in "${CMAKE_FORMATS[@]}"; do - echo -e "$CMAKE_FORMAT" - echo -e "\n" - done - echo -e "\n\n>>>> FAILED: cmake format check; end output\n\n" -else - echo -e "\n\n>>>> PASSED: cmake format check\n\n" -fi - -if [ "$CMAKE_LINT_RETVAL" != "0" ]; then - echo -e "\n\n>>>> FAILED: cmake lint check; begin output\n\n" - for CMAKE_LINT in "${CMAKE_LINTS[@]}"; do - echo -e "$CMAKE_LINT" - echo -e "\n" - done - echo -e "\n\n>>>> FAILED: cmake lint check; end output\n\n" -else - echo -e "\n\n>>>> PASSED: cmake lint check\n\n" -fi - -RETVALS=($ISORT_RETVAL $BLACK_RETVAL $FLAKE_RETVAL $FLAKE_CYTHON_RETVAL $CLANG_FORMAT_RETVAL $CMAKE_FORMAT_RETVAL $CMAKE_LINT_RETVAL) -IFS=$'\n' -RETVAL=`echo "${RETVALS[*]}" | sort -nr | head -n1` - -exit $RETVAL diff --git a/ci/cpu/build.sh b/ci/cpu/build.sh deleted file mode 100755 index 747930924..000000000 --- a/ci/cpu/build.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env bash -# Copyright (c) 2020, NVIDIA CORPORATION. -###################################### -# rmm CPU build script for CI # -###################################### -set -e - -# Set path, build parallel level and build generator -export PATH=/opt/conda/bin:/usr/local/cuda/bin:$PATH -export PARALLEL_LEVEL=${PARALLEL_LEVEL:-4} -export CMAKE_GENERATOR="Ninja" -export CONDA_BLD_DIR="$WORKSPACE/.conda-bld" - -# Set home to the job's workspace -export HOME=$WORKSPACE - -# Switch to project root; also root of repo checkout -cd $WORKSPACE - -# Setup 'gpuci_conda_retry' for build retries (results in 2 total attempts) -export GPUCI_CONDA_RETRY_MAX=1 -export GPUCI_CONDA_RETRY_SLEEP=30 - -# Workaround to keep Jenkins builds working -# until we migrate fully to GitHub Actions -export RAPIDS_CUDA_VERSION="${CUDA}" - -# If nightly build, append current YYMMDD to version -if [[ "$BUILD_MODE" = "branch" && "$SOURCE_BRANCH" = branch-* ]] ; then - export VERSION_SUFFIX=`date +%y%m%d` -fi - -################################################################################ -# SETUP - Check environment -################################################################################ - -gpuci_logger "Get env" -env - -gpuci_logger "Activate conda env" -. /opt/conda/etc/profile.d/conda.sh -conda activate rapids - -# Remove rapidsai-nightly channel if we are building main branch -if [ "$SOURCE_BRANCH" = "main" ]; then - conda config --system --remove channels rapidsai-nightly -fi - -gpuci_logger "Check versions" -python --version -$CC --version -$CXX --version - -gpuci_logger "Check conda environment" -conda info -conda config --show-sources -conda list --show-channel-urls - -# FIX Added to deal with Anancoda SSL verification issues during conda builds -conda config --set ssl_verify False - -# FIXME: Move installation to gpuci/rapidsai images -gpuci_mamba_retry install -c conda-forge boa - -################################################################################ -# BUILD - Conda package builds (conda deps: librmm <- rmm) -################################################################################ - -if [[ "$BUILD_LIBRMM" == "1" ]]; then - gpuci_logger "Build conda pkg for librmm" - if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then - gpuci_conda_retry mambabuild conda/recipes/librmm --python=$PYTHON - else - gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} --dirty --no-remove-work-dir conda/recipes/librmm - mkdir -p ${CONDA_BLD_DIR}/librmm - mv ${CONDA_BLD_DIR}/work/ ${CONDA_BLD_DIR}/librmm/work - fi - gpuci_logger "sccache stats" - sccache --show-stats -fi - -if [[ "$BUILD_RMM" == "1" ]]; then - gpuci_logger "Build conda pkg for rmm" - if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then - gpuci_conda_retry mambabuild conda/recipes/rmm --python=$PYTHON - else - gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} --dirty --no-remove-work-dir \ - -c $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ conda/recipes/rmm - mkdir -p ${CONDA_BLD_DIR}/rmm - mv ${CONDA_BLD_DIR}/work/ ${CONDA_BLD_DIR}/rmm/work - fi -fi - -################################################################################ -# UPLOAD - Conda packages -################################################################################ - -# gpuci_logger "Upload conda packages" -# source ci/cpu/upload.sh diff --git a/ci/cpu/prebuild.sh b/ci/cpu/prebuild.sh deleted file mode 100644 index e434ed550..000000000 --- a/ci/cpu/prebuild.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -#Always upload RMM packages -export UPLOAD_RMM=1 -export UPLOAD_LIBRMM=1 - -if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then - #If project flash is not activate, always build both - export BUILD_LIBRMM=1 - export BUILD_RMM=1 -fi diff --git a/ci/cpu/upload.sh b/ci/cpu/upload.sh deleted file mode 100644 index 9bff2db31..000000000 --- a/ci/cpu/upload.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# -# Adopted from https://github.com/tmcdonell/travis-scripts/blob/dfaac280ac2082cd6bcaba3217428347899f2975/update-accelerate-buildbot.sh - -set -e - -# Setup 'gpuci_retry' for upload retries (results in 4 total attempts) -export GPUCI_RETRY_MAX=3 -export GPUCI_RETRY_SLEEP=30 - -# Set default label options if they are not defined elsewhere -export LABEL_OPTION=${LABEL_OPTION:-"--label main"} - -# Skip uploads unless BUILD_MODE == "branch" -if [ ${BUILD_MODE} != "branch" ]; then - echo "Skipping upload" - return 0 -fi - -# Skip uploads if there is no upload key -if [ -z "$MY_UPLOAD_KEY" ]; then - echo "No upload key" - return 0 -fi - - -################################################################################ -# UPLOAD - Conda packages -################################################################################ - -gpuci_logger "Starting conda uploads" - -if [[ "$BUILD_LIBRMM" == "1" && "$UPLOAD_LIBRMM" == "1" ]]; then - export LIBRMM_FILES=$(conda build --croot ${CONDA_BLD_DIR} conda/recipes/librmm --output) - while read -r LIBRMM_FILE; do - test -e ${LIBRMM_FILE} - echo "Upload librmm file: ${LIBRMM_FILE}" - gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${LIBRMM_FILE} --no-progress - done <<< "${LIBRMM_FILES}" -fi - -if [[ "$BUILD_RMM" == "1" && "$UPLOAD_RMM" == "1" ]]; then - export RMM_FILES=$(conda build --croot ${CONDA_BLD_DIR} conda/recipes/rmm --python=$PYTHON --output) - while read -r RMM_FILE; do - test -e ${RMM_FILE} - echo "Upload rmm file: ${RMM_FILE}" - gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${RMM_FILE} --no-progress - done <<< "${RMM_FILES}" -fi - diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh deleted file mode 100755 index 3db5d3f77..000000000 --- a/ci/gpu/build.sh +++ /dev/null @@ -1,137 +0,0 @@ -#!/usr/bin/env bash -# Copyright (c) 2020, NVIDIA CORPORATION. -###################################### -# rmm GPU build & testscript for CI # -###################################### -set -e -NUMARGS=$# -ARGS=$* - -# Arg parsing function -function hasArg { - (( ${NUMARGS} != 0 )) && (echo " ${ARGS} " | grep -q " $1 ") -} - -# Set path and build parallel level -export PATH=/opt/conda/bin:/usr/local/cuda/bin:$PATH -export PARALLEL_LEVEL=${PARALLEL_LEVEL:-4} - -# Set home to the job's workspace -export HOME=$WORKSPACE - -# Switch to project root; also root of repo checkout -cd $WORKSPACE - -# Determine CUDA release version -export CUDA_MAJOR_VER=$(echo "${CUDA_VERSION}" | cut -f 1 -d.) -export CUDA_MINOR_VER=$(echo "${CUDA_VERSION}" | cut -f 2 -d.) -export CUDA_REL="${CUDA_MAJOR_VER}.${CUDA_MINOR_VER}" - -# Workaround to keep Jenkins builds working -# until we migrate fully to GitHub Actions -export RAPIDS_CUDA_VERSION="${CUDA}" - -# Get latest tag and number of commits since tag -export GIT_DESCRIBE_TAG=`git describe --abbrev=0 --tags` -export GIT_DESCRIBE_NUMBER=`git rev-list ${GIT_DESCRIBE_TAG}..HEAD --count` -export MINOR_VERSION=`echo $GIT_DESCRIBE_TAG | grep -o -E '([0-9]+\.[0-9]+)'` -unset GIT_DESCRIBE_TAG - -################################################################################ -# SETUP - Check environment -################################################################################ - -gpuci_logger "Get env" -env - -gpuci_logger "Activate conda env" -. /opt/conda/etc/profile.d/conda.sh -conda activate rapids - -gpuci_logger "Check versions" -python --version -$CC --version -$CXX --version - -gpuci_logger "Check conda environment" -conda info -conda config --show-sources -conda list --show-channel-urls - -if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then - # Install build env - gpuci_mamba_retry install -y \ - "cudatoolkit=$CUDA_REL" \ - "rapids-build-env=${MINOR_VERSION}.*" - - # https://docs.rapids.ai/maintainers/depmgmt/ - # conda remove --force rapids-build-env - # gpuci_mamba_retry install "your-pkg=1.0.0" - - ################################################################################ - # BUILD - Build and install librmm and rmm - ################################################################################ - - gpuci_logger "Build and install librmm and rmm" - "$WORKSPACE/build.sh" -v clean librmm rmm benchmarks tests - - ################################################################################ - # Test - librmm - ################################################################################ - - if hasArg --skip-tests; then - gpuci_logger "Skipping Tests" - else - gpuci_logger "Check GPU usage" - nvidia-smi - - gpuci_logger "Running googletests" - - cd "${WORKSPACE}/build" - GTEST_OUTPUT="xml:${WORKSPACE}/test-results/" make -j${PARALLEL_LEVEL} test - - gpuci_logger "Running rmm pytests..." - cd $WORKSPACE/python - py.test --cache-clear --basetemp=${WORKSPACE}/rmm-cuda-tmp --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term - fi -else - gpuci_mamba_retry install -c $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ librmm librmm-tests - - TESTRESULTS_DIR=${WORKSPACE}/test-results - mkdir -p ${TESTRESULTS_DIR} - SUITEERROR=0 - - gpuci_logger "Check GPU usage" - nvidia-smi - - gpuci_logger "Running googletests" - # run gtests from librmm-tests package - for gt in "$CONDA_PREFIX/bin/gtests/librmm/"* ; do - ${gt} --gtest_output=xml:${TESTRESULTS_DIR}/ - exitcode=$? - if (( ${exitcode} != 0 )); then - SUITEERROR=${exitcode} - echo "FAILED: GTest ${gt}" - fi - done - - # TODO: Move boa install to gpuci/rapidsai - gpuci_mamba_retry install boa - export CONDA_BLD_DIR="$WORKSPACE/.conda-bld" - gpuci_logger "Building and installing rmm" - gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} \ - -c $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ conda/recipes/rmm - gpuci_mamba_retry install -c $WORKSPACE/ci/artifacts/rmm/cpu/.conda-bld/ \ - -c ${CONDA_BLD_DIR} rmm - - cd $WORKSPACE/python - gpuci_logger "pytest rmm" - py.test --cache-clear --junitxml=${WORKSPACE}/test-results/junit-rmm.xml -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:${WORKSPACE}/python/rmm-coverage.xml --cov-report term - exitcode=$? - if (( ${exitcode} != 0 )); then - SUITEERROR=${exitcode} - echo "FAILED: 1 or more tests in /rmm/python" - fi - - exit ${SUITEERROR} -fi diff --git a/ci/local/README.md b/ci/local/README.md deleted file mode 100644 index e37268f04..000000000 --- a/ci/local/README.md +++ /dev/null @@ -1,58 +0,0 @@ -## Purpose - -This script is designed for developer and contributor use. This tool mimics the actions of gpuCI on your local machine. This allows you to test and even debug your code inside a gpuCI base container before pushing your code as a GitHub commit. -The script can be helpful in locally triaging and debugging RAPIDS continuous integration failures. - -## Requirements - -``` -nvidia-docker -``` - -## Usage - -``` -bash build.sh [-h] [-H] [-s] [-r ] [-i ] -Build and test your local repository using a base gpuCI Docker image - -where: - -H Show this help text - -r Path to repository (defaults to working directory) - -i Use Docker image (default is gpuci/rapidsai:${NIGHTLY_VERSION}-cuda10.1-devel-ubuntu16.04-py3.7) - -s Skip building and testing and start an interactive shell in a container of the Docker image -``` - -Example Usage: -`bash build.sh -r ~/rapids/rmm -i gpuci/rapidsai:0.16-cuda10.2-devel-ubuntu16.04-py3.7` - -For a full list of available gpuCI docker images, visit our [DockerHub](https://hub.docker.com/r/gpuci/rapidsai/tags) page. - -Style Check: -```bash -$ bash ci/local/build.sh -r ~/rapids/rmm -s -$ . /opt/conda/etc/profile.d/conda.sh -$ conda activate rapids # Activate gpuCI conda environment -$ cd rapids -$ flake8 python -``` - -## Information - -There are some caveats to be aware of when using this script, especially if you plan on developing from within the container itself. - - -### Docker Image Build Repository - -The docker image will generate build artifacts in a folder on your machine located in the `root` directory of the repository you passed to the script. For the above example, the directory is named `~/rapids/rmm/build_rapidsai_cuda10.1-ubuntu16.04-py3.7/`. Feel free to remove this directory after the script is finished. - -*Note*: The script *will not* override your local build repository. Your local environment stays in tact. - - -### Where The User is Dumped - -The script will build your repository and run all tests. If any tests fail, it dumps the user into the docker container itself to allow you to debug from within the container. If all the tests pass as expected the container exits and is automatically removed. Remember to exit the container if tests fail and you do not wish to debug within the container itself. - - -### Container File Structure - -Your repository will be located in the `/rapids/` folder of the container. This folder is volume mounted from the local machine. Any changes to the code in this repository are replicated onto the local machine. The `cpp/build` and `python/build` directories within your repository is on a separate mount to avoid conflicting with your local build artifacts. diff --git a/ci/local/build.sh b/ci/local/build.sh deleted file mode 100755 index 7adf8e62f..000000000 --- a/ci/local/build.sh +++ /dev/null @@ -1,151 +0,0 @@ -#!/bin/bash - -GIT_DESCRIBE_TAG=`git describe --tags` -MINOR_VERSION=`echo $GIT_DESCRIBE_TAG | grep -o -E '([0-9]+\.[0-9]+)'` - -DOCKER_IMAGE="gpuci/rapidsai:${MINOR_VERSION}-cuda10.1-devel-ubuntu16.04-py3.7" -REPO_PATH=${PWD} -RAPIDS_DIR_IN_CONTAINER="/rapids" -CPP_BUILD_DIR="build" -PYTHON_BUILD_DIR="python/build" -CONTAINER_SHELL_ONLY=0 - -SHORTHELP="$(basename "$0") [-h] [-H] [-s] [-r ] [-i ]" -LONGHELP="${SHORTHELP} -Build and test your local repository using a base gpuCI Docker image - -where: - -H Show this help text - -r Path to repository (defaults to working directory) - -i Use Docker image (default is ${DOCKER_IMAGE}) - -s Skip building and testing and start an interactive shell in a container of the Docker image -" - -# Limit GPUs available to container based on CUDA_VISIBLE_DEVICES -if [[ -z "${CUDA_VISIBLE_DEVICES}" ]]; then - NVIDIA_VISIBLE_DEVICES="all" -else - NVIDIA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES} -fi - -while getopts ":hHr:i:s" option; do - case ${option} in - r) - REPO_PATH=${OPTARG} - ;; - i) - DOCKER_IMAGE=${OPTARG} - ;; - s) - CONTAINER_SHELL_ONLY=1 - ;; - h) - echo "${SHORTHELP}" - exit 0 - ;; - H) - echo "${LONGHELP}" - exit 0 - ;; - *) - echo "ERROR: Invalid flag" - echo "${SHORTHELP}" - exit 1 - ;; - esac -done - -REPO_PATH_IN_CONTAINER="${RAPIDS_DIR_IN_CONTAINER}/$(basename "${REPO_PATH}")" -CPP_BUILD_DIR_IN_CONTAINER="${RAPIDS_DIR_IN_CONTAINER}/$(basename "${REPO_PATH}")/${CPP_BUILD_DIR}" -PYTHON_BUILD_DIR_IN_CONTAINER="${RAPIDS_DIR_IN_CONTAINER}/$(basename "${REPO_PATH}")/${PYTHON_BUILD_DIR}" - - -# BASE_CONTAINER_BUILD_DIR is named after the image name, allowing for -# multiple image builds to coexist on the local filesystem. This will -# be mapped to the typical BUILD_DIR inside of the container. Builds -# running in the container generate build artifacts just as they would -# in a bare-metal environment, and the host filesystem is able to -# maintain the host build in BUILD_DIR as well. - -# FIXME: Fix the shellcheck complaints -# shellcheck disable=SC2001,SC2005 -BASE_CONTAINER_BUILD_DIR=${REPO_PATH}/build_$(echo "$(basename "${DOCKER_IMAGE}")"|sed -e 's/:/_/g') -CPP_CONTAINER_BUILD_DIR=${BASE_CONTAINER_BUILD_DIR}/cpp -PYTHON_CONTAINER_BUILD_DIR=${BASE_CONTAINER_BUILD_DIR}/python - -# Note the prevention of expanding variables. Preventing expansion is critical as -# expansion in context of calling shell would lead to incorrect result as not -# all variables are set -BUILD_SCRIPT="#!/bin/bash -set -e -WORKSPACE=${REPO_PATH_IN_CONTAINER} -PREBUILD_SCRIPT=${REPO_PATH_IN_CONTAINER}/ci/gpu/prebuild.sh -BUILD_SCRIPT=${REPO_PATH_IN_CONTAINER}/ci/gpu/build.sh -cd \${WORKSPACE} -if [ -f \${PREBUILD_SCRIPT} ]; then - source \${PREBUILD_SCRIPT} -fi -yes | source \${BUILD_SCRIPT} -" - -if (( CONTAINER_SHELL_ONLY == 0 )); then - COMMAND="${CPP_BUILD_DIR_IN_CONTAINER}/build.sh || bash" -else - COMMAND="bash" -fi - -# Create the build dir for the container to mount, generate the build script inside of it -mkdir -p "${BASE_CONTAINER_BUILD_DIR}" -mkdir -p "${CPP_CONTAINER_BUILD_DIR}" -mkdir -p "${PYTHON_CONTAINER_BUILD_DIR}" -# Create build directories. This is to ensure correct owner for directories. If -# directories don't exist there is side effect from docker volume mounting creating build -# directories owned by root(volume mount point(s)) -mkdir -p "${REPO_PATH}/${CPP_BUILD_DIR}" -mkdir -p "${REPO_PATH}/${PYTHON_BUILD_DIR}" - -echo "${BUILD_SCRIPT}" > "${CPP_CONTAINER_BUILD_DIR}/build.sh" -chmod ugo+x "${CPP_CONTAINER_BUILD_DIR}/build.sh" - -# Mount passwd and group files to docker. This allows docker to resolve username and group -# avoiding these nags: -# * groups: cannot find name for group ID ID -# * I have no name!@id:/$ -# For ldap user user information is not present in system /etc/passwd and /etc/group files. -# Hence we generate dummy files for ldap users which docker uses to resolve username and group - -PASSWD_FILE="/etc/passwd" -GROUP_FILE="/etc/group" - -USER_FOUND=$(grep -wc "$(whoami)" < "$PASSWD_FILE") -if [ "$USER_FOUND" == 0 ]; then - echo "Local User not found, LDAP WAR for docker mounts activated. Creating dummy passwd and group" - echo "files to allow docker resolve username and group" - cp "$PASSWD_FILE" /tmp/passwd - PASSWD_FILE="/tmp/passwd" - cp "$GROUP_FILE" /tmp/group - GROUP_FILE="/tmp/group" - echo "$(whoami):x:$(id -u):$(id -g):$(whoami),,,:$HOME:$SHELL" >> "$PASSWD_FILE" - echo "$(whoami):x:$(id -g):" >> "$GROUP_FILE" -fi - - -# Run the generated build script in a container -docker pull "${DOCKER_IMAGE}" - -DOCKER_MAJOR=$(docker -v|sed 's/[^[0-9]*\([0-9]*\).*/\1/') -GPU_OPTS="--gpus device=${NVIDIA_VISIBLE_DEVICES}" -if [ "$DOCKER_MAJOR" -lt 19 ] -then - GPU_OPTS="--runtime=nvidia -e NVIDIA_VISIBLE_DEVICES='${NVIDIA_VISIBLE_DEVICES}'" -fi - -docker run --rm -it ${GPU_OPTS} \ - --user "$(id -u)":"$(id -g)" \ - -v "${REPO_PATH}":"${REPO_PATH_IN_CONTAINER}" \ - -v "${CPP_CONTAINER_BUILD_DIR}":"${CPP_BUILD_DIR_IN_CONTAINER}" \ - -v "${PYTHON_CONTAINER_BUILD_DIR}":"${PYTHON_BUILD_DIR_IN_CONTAINER}" \ - -v "$PASSWD_FILE":/etc/passwd:ro \ - -v "$GROUP_FILE":/etc/group:ro \ - --cap-add=SYS_PTRACE \ - "${DOCKER_IMAGE}" bash -c "${COMMAND}" From b5f9c894ebe2aa235b9756e7ea08044fa1582d1c Mon Sep 17 00:00:00 2001 From: Jordan Jacobelli Date: Mon, 31 Oct 2022 10:13:05 +0100 Subject: [PATCH 179/675] Enable sccache for python build (#1145) This PR enables `sccache` for python builds Authors: - Jordan Jacobelli (https://github.com/Ethyling) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1145 --- conda/recipes/rmm/meta.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 09de74cea..76b2890ce 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -18,6 +18,16 @@ build: script_env: - RMM_BUILD_NO_GPU_TEST - VERSION_SUFFIX + - CMAKE_C_COMPILER_LAUNCHER + - CMAKE_CXX_COMPILER_LAUNCHER + - CMAKE_CUDA_COMPILER_LAUNCHER + - SCCACHE_S3_KEY_PREFIX=rmm-aarch64 # [aarch64] + - SCCACHE_S3_KEY_PREFIX=rmm-linux64 # [linux64] + - SCCACHE_BUCKET=rapids-sccache + - SCCACHE_REGION=us-west-2 + - SCCACHE_IDLE_TIMEOUT=32768 + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY ignore_run_exports_from: - {{ compiler('cuda') }} From c1af31ff681c266bad4ac5500d773f10d62253db Mon Sep 17 00:00:00 2001 From: Charles Coulombe Date: Tue, 1 Nov 2022 15:32:13 -0400 Subject: [PATCH 180/675] Document required Python dependencies to build from source (#1146) Documents the RMM Python build requirements. Authors: - Charles Coulombe (https://github.com/ccoulombe) - Ashwin Srinath (https://github.com/shwina) Approvers: - Ashwin Srinath (https://github.com/shwina) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1146 --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index ef2fa43a1..69ac2a2bc 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,14 @@ CUDA/GPU requirements: You can obtain CUDA from [https://developer.nvidia.com/cuda-downloads](https://developer.nvidia.com/cuda-downloads) +Python requirements: +* `scikit-build` +* `cuda-python` +* `cython` + +For more details, see [pyproject.toml](python/pyproject.toml) + + ### Script to build RMM from source To install RMM from source, ensure the dependencies are met and follow the steps below: From 7269c6f6acd72e0c56315a60ace32ad02be0bc9e Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 4 Nov 2022 11:55:38 -0500 Subject: [PATCH 181/675] Update dependencies schema. (#1147) This PR updates the schema of `dependencies.yaml` to align with the changes in https://github.com/rapidsai/dependency-file-generator/pull/14. This PR should not be merged until the upstream repo is updated and a new release is made. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1147 --- dependencies.yaml | 130 ++++++++++++++++++++++++---------------------- 1 file changed, 69 insertions(+), 61 deletions(-) diff --git a/dependencies.yaml b/dependencies.yaml index 543618335..3960522f6 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -10,7 +10,6 @@ files: - cudatoolkit - develop - run - - test_cpp - test_python test_python: output: none @@ -32,67 +31,76 @@ channels: - rapidsai - conda-forge dependencies: - - output_types: [conda, requirements] + build: common: - build: - - cmake>=3.23.1 - - cython>=0.29,<0.30 - - python>=3.8,<3.10 - - scikit-build>=0.13.1 - run: - - numba>=0.49 - - numpy>=1.19 - develop: - - black=22.3.0 - - cmakelang=0.6.13 - - flake8=3.8.3 - - gcovr>=5.0 - - isort=5.10.1 - test_python: - - pytest - - pytest-cov - specific: - - matrix: - cuda: "11.5" - build: - - cuda-python>=11.7.1,<12.0 - - matrix: - cuda: "11.6" - build: + - output_types: [conda, requirements] + packages: + - cmake>=3.23.1 - cuda-python>=11.7.1,<12.0 - - output_types: [conda] + - cython>=0.29,<0.30 + - python>=3.8,<3.10 + - scikit-build>=0.13.1 + - output_types: conda + packages: + - spdlog>=1.8.5,<1.9 + cudatoolkit: + specific: + - output_types: conda + matrices: + - matrix: + cuda: "11.0" + packages: + - cudatoolkit=11.0 + - matrix: + cuda: "11.2" + packages: + - cudatoolkit=11.2 + - matrix: + cuda: "11.4" + packages: + - cudatoolkit=11.4 + - matrix: + cuda: "11.5" + packages: + - cudatoolkit=11.5 + - matrix: + cuda: "11.6" + packages: + - cudatoolkit=11.6 + develop: common: - build: - - spdlog>=1.8.5,<1.9 - develop: - - clang=11.1.0 - - clang-tools=11.1.0 + - output_types: [conda, requirements] + packages: + - black=22.3.0 + - cmakelang=0.6.13 + - flake8=3.8.3 + - gcovr>=5.0 + - isort=5.10.1 + - output_types: conda + packages: + - clang=11.1.0 + - clang-tools=11.1.0 + py_version: specific: - - matrix: - py: "3.8" - py_version: - - python=3.8 - - matrix: - py: "3.9" - py_version: - - python=3.9 - - matrix: - cuda: "11.0" - cudatoolkit: - - cudatoolkit=11.0 - - matrix: - cuda: "11.2" - cudatoolkit: - - cudatoolkit=11.2 - - matrix: - cuda: "11.4" - cudatoolkit: - - cudatoolkit=11.4 - - matrix: - cuda: "11.5" - cudatoolkit: - - cudatoolkit=11.5 - - matrix: - cuda: "11.6" - cudatoolkit: - - cudatoolkit=11.6 + - output_types: conda + matrices: + - matrix: + py: "3.8" + packages: + - python=3.8 + - matrix: + py: "3.9" + packages: + - python=3.9 + run: + common: + - output_types: [conda, requirements] + packages: + - numba>=0.49 + - numpy>=1.19 + test_python: + common: + - output_types: [conda, requirements] + packages: + - pytest + - pytest-cov From 637d5fd37643c4d783da1ed1de62ba2102dd290e Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 8 Nov 2022 16:21:41 -0600 Subject: [PATCH 182/675] Fix doxygen formatting for set_stream. (#1153) This PR fixes doxygen formatting for `set_stream`. I looked over the rest of the `device_buffer` docs and didn't see any other issues. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Rong Ou (https://github.com/rongou) URL: https://github.com/rapidsai/rmm/pull/1153 --- include/rmm/device_buffer.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index d571e9304..189ba7e24 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -381,7 +381,7 @@ class device_buffer { * * If no other rmm::device_buffer method that allocates memory is called * after this call with a different stream argument, then @p stream - * will be used for deallocation in the `rmm::device_uvector destructor. + * will be used for deallocation in the `rmm::device_uvector` destructor. * However, if either of `resize()` or `shrink_to_fit()` is called after this, * the later stream parameter will be stored and used in the destructor. */ From b94a5955028320499ff7efac1d40500d9f01a5de Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Wed, 9 Nov 2022 16:46:38 -0500 Subject: [PATCH 183/675] Add `ninja` & Update CI environment variables (#1155) This PR removes some environment variables that will now be defined in our CI images once https://github.com/rapidsai/ci-imgs/pull/19 is merged. Additionally, it adds `ninja` to our `build` requirements since `ninja` was removed from our CI images. Depends on https://github.com/rapidsai/ci-imgs/pull/19 and https://github.com/rapidsai/ci-imgs/pull/20. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - https://github.com/jakirkham - Robert Maynard (https://github.com/robertmaynard) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1155 --- conda/environments/all_cuda-115_arch-x86_64.yaml | 1 + conda/environments/all_cuda-116_arch-x86_64.yaml | 1 + conda/recipes/librmm/meta.yaml | 9 +++++---- conda/recipes/rmm/meta.yaml | 8 +++++--- dependencies.yaml | 1 + 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/conda/environments/all_cuda-115_arch-x86_64.yaml b/conda/environments/all_cuda-115_arch-x86_64.yaml index 9e452ac49..fc32370f9 100644 --- a/conda/environments/all_cuda-115_arch-x86_64.yaml +++ b/conda/environments/all_cuda-115_arch-x86_64.yaml @@ -15,6 +15,7 @@ dependencies: - flake8=3.8.3 - gcovr>=5.0 - isort=5.10.1 +- ninja - numba>=0.49 - numpy>=1.19 - pytest diff --git a/conda/environments/all_cuda-116_arch-x86_64.yaml b/conda/environments/all_cuda-116_arch-x86_64.yaml index 3c27666cf..5c4c8f4da 100644 --- a/conda/environments/all_cuda-116_arch-x86_64.yaml +++ b/conda/environments/all_cuda-116_arch-x86_64.yaml @@ -15,6 +15,7 @@ dependencies: - flake8=3.8.3 - gcovr>=5.0 - isort=5.10.1 +- ninja - numba>=0.49 - numpy>=1.19 - pytest diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 2e519b48c..0fadd41a2 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -14,6 +14,7 @@ source: requirements: build: - cmake {{ cmake_version }} + - ninja - {{ compiler('c') }} - {{ compiler('cxx') }} - {{ compiler('cuda') }} {{ cuda_version }} @@ -24,15 +25,15 @@ requirements: build: script_env: - PARALLEL_LEVEL - - CMAKE_GENERATOR=Ninja + - CMAKE_GENERATOR - CMAKE_C_COMPILER_LAUNCHER - CMAKE_CXX_COMPILER_LAUNCHER - CMAKE_CUDA_COMPILER_LAUNCHER - SCCACHE_S3_KEY_PREFIX=librmm-aarch64 # [aarch64] - SCCACHE_S3_KEY_PREFIX=librmm-linux64 # [linux64] - - SCCACHE_BUCKET=rapids-sccache - - SCCACHE_REGION=us-west-2 - - SCCACHE_IDLE_TIMEOUT=32768 + - SCCACHE_BUCKET + - SCCACHE_REGION + - SCCACHE_IDLE_TIMEOUT - AWS_ACCESS_KEY_ID - AWS_SECRET_ACCESS_KEY diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 76b2890ce..70c215957 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -18,14 +18,15 @@ build: script_env: - RMM_BUILD_NO_GPU_TEST - VERSION_SUFFIX + - CMAKE_GENERATOR - CMAKE_C_COMPILER_LAUNCHER - CMAKE_CXX_COMPILER_LAUNCHER - CMAKE_CUDA_COMPILER_LAUNCHER - SCCACHE_S3_KEY_PREFIX=rmm-aarch64 # [aarch64] - SCCACHE_S3_KEY_PREFIX=rmm-linux64 # [linux64] - - SCCACHE_BUCKET=rapids-sccache - - SCCACHE_REGION=us-west-2 - - SCCACHE_IDLE_TIMEOUT=32768 + - SCCACHE_BUCKET + - SCCACHE_REGION + - SCCACHE_IDLE_TIMEOUT - AWS_ACCESS_KEY_ID - AWS_SECRET_ACCESS_KEY ignore_run_exports_from: @@ -34,6 +35,7 @@ build: requirements: build: - cmake>=3.23.1 + - ninja - {{ compiler('c') }} - {{ compiler('cxx') }} - {{ compiler('cuda') }} {{ cuda_version }} diff --git a/dependencies.yaml b/dependencies.yaml index 3960522f6..6bb510b13 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -38,6 +38,7 @@ dependencies: - cmake>=3.23.1 - cuda-python>=11.7.1,<12.0 - cython>=0.29,<0.30 + - ninja - python>=3.8,<3.10 - scikit-build>=0.13.1 - output_types: conda From bf4cdb7e874eb11ba571d4762fc53ea6fd6b7051 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 10 Nov 2022 07:33:33 -0600 Subject: [PATCH 184/675] Remove CUDA 11.0 from dependencies.yaml. (#1152) CUDA 11.0 is not supported in the 22.12 release. This PR removes it from the `dependencies.yaml` file. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1152 --- README.md | 4 ++-- dependencies.yaml | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 69ac2a2bc..91c5c577f 100644 --- a/README.md +++ b/README.md @@ -62,12 +62,12 @@ See the [Get RAPIDS version picker](https://rapids.ai/start.html) for more OS an Compiler requirements: * `gcc` version 9.3+ -* `nvcc` version 11.0+ +* `nvcc` version 11.2+ * `cmake` version 3.23.1+ CUDA/GPU requirements: -* CUDA 11.0+ +* CUDA 11.2+ * NVIDIA driver 450.51+ * Pascal architecture or better diff --git a/dependencies.yaml b/dependencies.yaml index 6bb510b13..3331fdfdd 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -48,10 +48,6 @@ dependencies: specific: - output_types: conda matrices: - - matrix: - cuda: "11.0" - packages: - - cudatoolkit=11.0 - matrix: cuda: "11.2" packages: From 11daf79306054a7550cae334ff6572291fdcc461 Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Thu, 10 Nov 2022 12:56:08 -0500 Subject: [PATCH 185/675] DOC --- CHANGELOG.md | 4 ++++ CMakeLists.txt | 4 ++-- doxygen/Doxyfile | 2 +- python/CMakeLists.txt | 4 ++-- python/docs/conf.py | 4 ++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24ec05aa4..9dc2a4cd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# RMM 23.02.00 (Date TBD) + +Please see https://github.com/rapidsai/rmm/releases/tag/v23.02.00a for the latest changes to this development branch. + # RMM 22.12.00 (Date TBD) Please see https://github.com/rapidsai/rmm/releases/tag/v22.12.00a for the latest changes to this development branch. diff --git a/CMakeLists.txt b/CMakeLists.txt index 13e2d44e2..08f4339a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.12/RAPIDS.cmake + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.02/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) endif() include(${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) @@ -27,7 +27,7 @@ include(rapids-find) project( RMM - VERSION 22.12.00 + VERSION 23.02.00 LANGUAGES CXX) # Write the version header diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 5e76c59f5..39649f378 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "RMM" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 22.12 +PROJECT_NUMBER = 23.02 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 3803d718a..3c8b058a6 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -14,9 +14,9 @@ cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) -set(rmm_version 22.12.00) +set(rmm_version 23.02.00) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.12/RAPIDS.cmake +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.02/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) diff --git a/python/docs/conf.py b/python/docs/conf.py index 6e8182894..955ef1847 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -23,9 +23,9 @@ # built documents. # # The short X.Y version. -version = "22.12" +version = "23.02" # The full version, including alpha/beta/rc tags. -release = "22.12.00" +release = "23.02.00" # -- General configuration --------------------------------------------------- From 4da70d53986a66fa11588cab7ab20fe26d172abe Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 15 Nov 2022 11:50:09 -0500 Subject: [PATCH 186/675] Add wheel builds to rmm (#1148) This PR enables building wheels in RMM. Authors: - Vyas Ramasubramani (https://github.com/vyasr) - Sevag H (https://github.com/sevagh) - Paul Taylor (https://github.com/trxcllnt) Approvers: - Bradley Dice (https://github.com/bdice) - Sevag H (https://github.com/sevagh) URL: https://github.com/rapidsai/rmm/pull/1148 --- .github/workflows/wheels.yml | 52 ++++++++++++++++++++++++++++++++++++ .gitignore | 3 +++ python/CMakeLists.txt | 15 ++++++++--- python/LICENSE | 1 + python/setup.cfg | 9 ------- python/setup.py | 14 +++++++--- 6 files changed, 77 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/wheels.yml create mode 120000 python/LICENSE diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml new file mode 100644 index 000000000..abbe4f682 --- /dev/null +++ b/.github/workflows/wheels.yml @@ -0,0 +1,52 @@ +name: RMM wheels + +on: + workflow_call: + inputs: + versioneer-override: + type: string + default: '' + build-tag: + type: string + default: '' + branch: + required: true + type: string + date: + required: true + type: string + sha: + required: true + type: string + build-type: + type: string + default: nightly + +concurrency: + # Hardcode rmm rather than using github.repository to support calling this + # from other workflows that build multiple wheels. + group: "rmm-${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + rmm-wheels: + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux.yml@main + with: + repo: rapidsai/rmm + + build-type: ${{ inputs.build-type }} + branch: ${{ inputs.branch }} + sha: ${{ inputs.sha }} + date: ${{ inputs.date }} + + package-dir: python + package-name: rmm + + python-package-versioneer-override: ${{ inputs.versioneer-override }} + python-package-build-tag: ${{ inputs.build-tag }} + + skbuild-configure-options: "-DRMM_BUILD_WHEELS=ON" + + test-extras: test + test-unittest: "python -m pytest -v ./python/rmm/tests" + secrets: inherit diff --git a/.gitignore b/.gitignore index 2c603209d..1ab57e4d4 100644 --- a/.gitignore +++ b/.gitignore @@ -150,3 +150,6 @@ ENV/ # RMM log files rmm_log.txt + +# cibuildwheel +/wheelhouse diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 3803d718a..352ca5b75 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -31,6 +31,7 @@ project( option(FIND_RMM_CPP "Search for existing RMM C++ installations before defaulting to local files" OFF) +option(RMM_BUILD_WHEELS "Whether this build is generating a Python wheel." OFF) # If the user requested it we attempt to find RMM. if(FIND_RMM_CPP) @@ -40,12 +41,18 @@ else() endif() if(NOT rmm_FOUND) - # TODO: This will not be necessary once we upgrade to CMake 3.22, which will pull in the required - # languages for the C++ project even if this project does not require those languges. - enable_language(CUDA) set(BUILD_TESTS OFF) set(BUILD_BENCHMARKS OFF) - add_subdirectory(../ rmm-cpp) + + set(_exclude_from_all "") + if(RMM_BUILD_WHEELS) + # Statically link dependencies if building wheels + set(CUDA_STATIC_RUNTIME ON) + # Don't install the rmm C++ targets into wheels + set(_exclude_from_all EXCLUDE_FROM_ALL) + endif() + + add_subdirectory(../ rmm-cpp ${_exclude_from_all}) endif() include(rapids-cython) diff --git a/python/LICENSE b/python/LICENSE new file mode 120000 index 000000000..ea5b60640 --- /dev/null +++ b/python/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/python/setup.cfg b/python/setup.cfg index 06b44e59f..9e0227b94 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -47,12 +47,3 @@ skip= build dist __init__.py - - -[options] -packages = find: -install_requires = - cuda-python>=11.5,<11.7.1 - numpy>=1.19 - numba>=0.49 -python_requires = >=3.8 diff --git a/python/setup.py b/python/setup.py index 2f91d200b..7b8f2b4b0 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,13 +1,17 @@ # Copyright (c) 2019-2022, NVIDIA CORPORATION. +import os + from setuptools import find_packages from skbuild import setup import versioneer setup( - name="rmm", - version=versioneer.get_version(), + name="rmm" + os.getenv("RAPIDS_PY_WHEEL_CUDA_SUFFIX", default=""), + version=os.getenv( + "RAPIDS_PY_WHEEL_VERSIONEER_OVERRIDE", default=versioneer.get_version() + ), description="rmm - RAPIDS Memory Manager", url="https://github.com/rapidsai/rmm", author="NVIDIA Corporation", @@ -22,8 +26,10 @@ "Programming Language :: Python :: 3.9", ], # Include the separately-compiled shared library - extras_require={"test": ["pytest", "pytest-xdist"]}, + extras_require={"test": ["pytest"]}, packages=find_packages(include=["rmm", "rmm.*"]), + include_package_data=True, + python_requires=">=3.8", package_data={ # Note: A dict comprehension with an explicit copy is necessary (rather # than something simpler like a dict.fromkeys) because otherwise every @@ -35,7 +41,7 @@ }, cmdclass=versioneer.get_cmdclass(), install_requires=[ - "cuda-python>=11.5,<11.7.1", + "cuda-python>=11.7.1,<12.0", "numpy>=1.19", "numba>=0.49", ], From 28365560f2b7d432f1f01d147a4b2907fae6842a Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 16 Nov 2022 13:31:19 -0600 Subject: [PATCH 187/675] Use rapidsai CODE_OF_CONDUCT.md (#1159) This repo's `CODE_OF_CONDUCT.md` is superseded by an organization-wide policy: https://github.com/rapidsai/.github/pull/3 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1159 --- CODE_OF_CONDUCT.md | 76 ---------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index f68b37023..000000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,76 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, sex characteristics, gender identity and expression, -level of experience, education, socio-economic status, nationality, personal -appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment -include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at conduct@rapids.ai. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html - -[homepage]: https://www.contributor-covenant.org - -For answers to common questions about this code of conduct, see -https://www.contributor-covenant.org/faq From 3f7c61e1c2042f1f3e04e543e568db27bc1882a9 Mon Sep 17 00:00:00 2001 From: Sevag H Date: Thu, 17 Nov 2022 17:27:06 -0500 Subject: [PATCH 188/675] Align __version__ with wheel version (#1161) * Align __version__ with wheel version * Adjust setup.py to pass flake8 + black * Only override the version once * Complain if RAPIDS_PY_WHEEL_VERSIONEER_OVERRIDE is set but empty --- python/setup.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/python/setup.py b/python/setup.py index 7b8f2b4b0..8ea0f3ab7 100644 --- a/python/setup.py +++ b/python/setup.py @@ -7,11 +7,21 @@ import versioneer +if "RAPIDS_PY_WHEEL_VERSIONEER_OVERRIDE" in os.environ: + orig_get_versions = versioneer.get_versions + + version_override = os.environ["RAPIDS_PY_WHEEL_VERSIONEER_OVERRIDE"] + + def get_versions(): + data = orig_get_versions() + data["version"] = version_override + return data + + versioneer.get_versions = get_versions + setup( name="rmm" + os.getenv("RAPIDS_PY_WHEEL_CUDA_SUFFIX", default=""), - version=os.getenv( - "RAPIDS_PY_WHEEL_VERSIONEER_OVERRIDE", default=versioneer.get_version() - ), + version=versioneer.get_version(), description="rmm - RAPIDS Memory Manager", url="https://github.com/rapidsai/rmm", author="NVIDIA Corporation", From da7036aa4f216ec62077996856886eb8f4a9a57d Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 17 Nov 2022 17:50:10 -0500 Subject: [PATCH 189/675] Don't use CMake 3.25.0 as it has a show stopping FindCUDAToolkit bug (#1162) Don't use CMake 3.25.0 as it has a show stopping FindCUDAToolkit bug Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) - Mark Harris (https://github.com/harrism) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1162 --- conda/environments/all_cuda-115_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-116_arch-x86_64.yaml | 2 +- conda/recipes/librmm/conda_build_config.yaml | 2 +- conda/recipes/rmm/meta.yaml | 2 +- dependencies.yaml | 2 +- python/pyproject.toml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/conda/environments/all_cuda-115_arch-x86_64.yaml b/conda/environments/all_cuda-115_arch-x86_64.yaml index fc32370f9..0f6da8e09 100644 --- a/conda/environments/all_cuda-115_arch-x86_64.yaml +++ b/conda/environments/all_cuda-115_arch-x86_64.yaml @@ -7,7 +7,7 @@ dependencies: - black=22.3.0 - clang-tools=11.1.0 - clang=11.1.0 -- cmake>=3.23.1 +- cmake>=3.23.1,!=3.25.0 - cmakelang=0.6.13 - cuda-python>=11.7.1,<12.0 - cudatoolkit=11.5 diff --git a/conda/environments/all_cuda-116_arch-x86_64.yaml b/conda/environments/all_cuda-116_arch-x86_64.yaml index 5c4c8f4da..646565a90 100644 --- a/conda/environments/all_cuda-116_arch-x86_64.yaml +++ b/conda/environments/all_cuda-116_arch-x86_64.yaml @@ -7,7 +7,7 @@ dependencies: - black=22.3.0 - clang-tools=11.1.0 - clang=11.1.0 -- cmake>=3.23.1 +- cmake>=3.23.1,!=3.25.0 - cmakelang=0.6.13 - cuda-python>=11.7.1,<12.0 - cudatoolkit=11.6 diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index fed85c316..6a90ac289 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -8,7 +8,7 @@ cuda_compiler: - nvcc cmake_version: - - ">=3.23.1" + - ">=3.23.1,!=3.25.0" gtest_version: - "=1.10.0" diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 70c215957..9628df6e7 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -34,7 +34,7 @@ build: requirements: build: - - cmake>=3.23.1 + - cmake>=3.23.1,!=3.25.0 - ninja - {{ compiler('c') }} - {{ compiler('cxx') }} diff --git a/dependencies.yaml b/dependencies.yaml index 3331fdfdd..bd9b36122 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -35,7 +35,7 @@ dependencies: common: - output_types: [conda, requirements] packages: - - cmake>=3.23.1 + - cmake>=3.23.1,!=3.25.0 - cuda-python>=11.7.1,<12.0 - cython>=0.29,<0.30 - ninja diff --git a/python/pyproject.toml b/python/pyproject.toml index f1de64653..0d4cfea09 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -19,7 +19,7 @@ requires = [ "setuptools", "cython>=0.29,<0.30", "scikit-build>=0.13.1", - "cmake>=3.23.1", + "cmake>=3.23.1,!=3.25.0", "ninja", "cuda-python>=11.7.1,<12.0" ] From 8a0169663f516cb9a0d0a8d6b94e7828e1b26eef Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Wed, 30 Nov 2022 17:55:07 -0500 Subject: [PATCH 190/675] Enable `codecov` (#1171) This PR enables `codecov` for GitHub Actions for `rmm`. The `codecov` results can be placed in the directory defined by the `RAPIDS_COVERAGE_DIR` variable, which is set in our shared workflows. Additionally, this PR configures the unit test results to be placed in the directory defined by the `RAPIDS_TESTS_DIR` variable, which is also set in our shared workflows. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Bradley Dice (https://github.com/bdice) --- ci/check_style.sh | 2 +- ci/test_cpp.sh | 8 ++++---- ci/test_python.sh | 17 +++++++++++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ci/check_style.sh b/ci/check_style.sh index 677d9ef7b..ef8565ded 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -9,7 +9,7 @@ rapids-logger "Create checks conda environment" rapids-dependency-file-generator \ --output conda \ --file_key checks \ - --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" > env.yaml + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee env.yaml rapids-mamba-retry env create --force -f env.yaml -n checks conda activate checks diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 30c0eec0a..3953171d0 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -8,7 +8,7 @@ conda activate base rapids-dependency-file-generator \ --output conda \ --file_key test_cpp \ - --matrix "cuda=${RAPIDS_CUDA_VERSION%.*}" > env.yaml + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*}" | tee env.yaml rapids-mamba-retry env create --force -f env.yaml -n test conda activate test @@ -21,8 +21,8 @@ rapids-mamba-retry install \ -c "${CPP_CHANNEL}" \ librmm librmm-tests -TESTRESULTS_DIR=test-results -mkdir -p ${TESTRESULTS_DIR} +RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"} +mkdir -p "${RAPIDS_TESTS_DIR}" SUITEERROR=0 rapids-logger "Check GPU usage" @@ -32,7 +32,7 @@ set +e rapids-logger "Running googletests" for gt in "$CONDA_PREFIX/bin/gtests/librmm/"* ; do - ${gt} --gtest_output=xml:${TESTRESULTS_DIR}/ + ${gt} --gtest_output=xml:${RAPIDS_TESTS_DIR}/ exitcode=$? if (( ${exitcode} != 0 )); then SUITEERROR=${exitcode} diff --git a/ci/test_python.sh b/ci/test_python.sh index e9c3ac093..511a69337 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -8,7 +8,7 @@ rapids-logger "Create test conda environment" rapids-dependency-file-generator \ --output conda \ --file_key test_python \ - --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" > env.yaml + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee env.yaml rapids-mamba-retry env create --force -f env.yaml -n test conda activate test @@ -24,8 +24,9 @@ rapids-mamba-retry install \ -c "${PYTHON_CHANNEL}" \ rmm librmm -TESTRESULTS_DIR="${PWD}/test-results" -mkdir -p "${TESTRESULTS_DIR}" +RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"} +RAPIDS_COVERAGE_DIR=${RAPIDS_COVERAGE_DIR:-"${PWD}/coverage-results"} +mkdir -p "${RAPIDS_TESTS_DIR}" "${RAPIDS_COVERAGE_DIR}" SUITEERROR=0 rapids-logger "Check GPU usage" @@ -36,7 +37,15 @@ cd python set +e rapids-logger "pytest rmm" -pytest --cache-clear --junitxml="${TESTRESULTS_DIR}/junit-rmm.xml" -v --cov-config=.coveragerc --cov=rmm --cov-report=xml:python/rmm-coverage.xml --cov-report term +pytest \ + --cache-clear \ + --junitxml="${RAPIDS_TESTS_DIR}/junit-rmm.xml" \ + -v \ + --cov-config=.coveragerc \ + --cov=rmm \ + --cov-report=xml:"${RAPIDS_COVERAGE_DIR}/rmm-coverage.xml" \ + --cov-report term + exitcode=$? if (( ${exitcode} != 0 )); then SUITEERROR=${exitcode} From c1e06b97609c2aebd19c0b820061ed08526b3255 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Fri, 2 Dec 2022 15:39:12 -0500 Subject: [PATCH 191/675] Update PR Workflow (#1174) Because of the changes in https://github.com/rapidsai/shared-action-workflows/pull/24, we need to update the `rmm` PR workflow accordingly. Similar to https://github.com/rapidsai/cudf/pull/12296. --- .github/workflows/pr.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index fd1ab511e..3ddb08dd7 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -11,6 +11,12 @@ concurrency: jobs: pr-builder: + needs: + - checks + - conda-cpp-build + - conda-cpp-tests + - conda-python-build + - conda-python-tests secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@main checks: From 7bf7a763a3b6a32a7a57f900de35e2e5f30f17c0 Mon Sep 17 00:00:00 2001 From: Keith Kraus Date: Fri, 2 Dec 2022 16:01:54 -0500 Subject: [PATCH 192/675] Upgrade to spdlog 1.10 (#1173) Updates spdlog dependency to 1.10 to match the conda-forge pinning. Depends on https://github.com/rapidsai/rapids-cmake/pull/312 Also updates the flake8 pre-commit hook location since it's migrated from gitlab to github. Authors: - Keith Kraus (https://github.com/kkraus14) Approvers: - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1173 --- .pre-commit-config.yaml | 2 +- conda/environments/all_cuda-115_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-116_arch-x86_64.yaml | 2 +- conda/recipes/librmm/conda_build_config.yaml | 3 +++ conda/recipes/librmm/meta.yaml | 2 +- conda/recipes/rmm/meta.yaml | 1 - dependencies.yaml | 2 +- 7 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 10a6cbcd6..356c35db7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: hooks: - id: black args: ["--config=python/pyproject.toml"] - - repo: https://gitlab.com/pycqa/flake8 + - repo: https://github.com/PyCQA/flake8 rev: 3.8.3 hooks: - id: flake8 diff --git a/conda/environments/all_cuda-115_arch-x86_64.yaml b/conda/environments/all_cuda-115_arch-x86_64.yaml index 0f6da8e09..5177051a9 100644 --- a/conda/environments/all_cuda-115_arch-x86_64.yaml +++ b/conda/environments/all_cuda-115_arch-x86_64.yaml @@ -22,5 +22,5 @@ dependencies: - pytest-cov - python>=3.8,<3.10 - scikit-build>=0.13.1 -- spdlog>=1.8.5,<1.9 +- spdlog=1.10 name: all_cuda-115_arch-x86_64 diff --git a/conda/environments/all_cuda-116_arch-x86_64.yaml b/conda/environments/all_cuda-116_arch-x86_64.yaml index 646565a90..368b008f6 100644 --- a/conda/environments/all_cuda-116_arch-x86_64.yaml +++ b/conda/environments/all_cuda-116_arch-x86_64.yaml @@ -22,5 +22,5 @@ dependencies: - pytest-cov - python>=3.8,<3.10 - scikit-build>=0.13.1 -- spdlog>=1.8.5,<1.9 +- spdlog=1.10 name: all_cuda-116_arch-x86_64 diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index 6a90ac289..9f3f371a6 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -13,5 +13,8 @@ cmake_version: gtest_version: - "=1.10.0" +spdlog_version: + - "1.10" + sysroot_version: - "2.17" diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 0fadd41a2..a6599bb33 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -53,7 +53,7 @@ outputs: - cmake {{ cmake_version }} run: - cudatoolkit {{ cuda_spec }} - - spdlog>=1.8.5,<1.9 + - spdlog {{ spdlog_version }} test: commands: - test -f $PREFIX/include/rmm/thrust_rmm_allocator.h diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 9628df6e7..0edc9df5a 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -48,7 +48,6 @@ requirements: - python - scikit-build>=0.13.1 - setuptools - - spdlog>=1.8.5,<2.0.0a0 run: - cuda-python >=11.7.1,<12.0 - numba >=0.49 diff --git a/dependencies.yaml b/dependencies.yaml index bd9b36122..8c838e96e 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -43,7 +43,7 @@ dependencies: - scikit-build>=0.13.1 - output_types: conda packages: - - spdlog>=1.8.5,<1.9 + - spdlog=1.10 cudatoolkit: specific: - output_types: conda From 4d1dee1e9c305fcd0003d378340928bc5c9518d0 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 5 Dec 2022 16:22:51 -0800 Subject: [PATCH 193/675] Revert "Upgrade to spdlog 1.10 (#1173)" (#1176) This reverts commit 7bf7a763a3b6a32a7a57f900de35e2e5f30f17c0. cc: @kkraus14 There's a handful of issues this caused downstream. We'll be sorting through these and fixing them but need to quickly revert this for now. Currrent problems: 1. rmm's meta.yaml doesn't correctly specify spdlog as a build dep. It's [incorrectly listed as a runtime dep](https://github.com/rapidsai/rmm/blob/7bf7a763a3b6a32a7a57f900de35e2e5f30f17c0/conda/recipes/librmm/meta.yaml#L56). This means that rmm [pulls spdlog via CPM with rapids-cmake](https://github.com/rapidsai/rmm/actions/runs/3595940512/jobs/6056061203#step:6:595) `-- CPM: adding package spdlog@1.8.5 (v1.8.5)` and then clobbers its own installed spdlog headers: ``` 2022-12-01T19:46:46.2167513Z ClobberWarning: This transaction has incompatible packages due to a shared path. 2022-12-01T19:46:46.2168766Z packages: conda-forge/linux-64::spdlog-1.10.0-h924138e_0, file:///tmp/conda-bld-output/linux-64::librmm-23.02.00a-cuda11_gc328a18d_11 2022-12-01T19:46:46.2169686Z path: 'include/spdlog/async.h' ``` 2. spdlog 1.10.0 doesn't work with nvcc. We need spdlog 1.11.0 to get fmt 9.1.0, which contains [a necessary fix](https://github.com/fmtlib/fmt/pull/2971). However, there's some uncertainty about how to handle the spdlog conda-forge package which [no longer vendors fmt](https://github.com/conda-forge/spdlog-feedstock/pull/50) while rapids-cmake is still using the upstream repo which continues to vendor fmt. Does this inconsistency matter, as long as we pin `fmt=9.1.0` in the conda package cases? @kkraus14 It looks like you weighed in on this matter [here](https://github.com/conda-forge/spdlog-feedstock/issues/53) and [here](https://github.com/conda-forge/conda-forge-pinning-feedstock/pull/3654). If you have insights that can help us with this quandary, please share! Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1176 --- conda/environments/all_cuda-115_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-116_arch-x86_64.yaml | 2 +- conda/recipes/librmm/conda_build_config.yaml | 2 +- dependencies.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conda/environments/all_cuda-115_arch-x86_64.yaml b/conda/environments/all_cuda-115_arch-x86_64.yaml index 5177051a9..0f6da8e09 100644 --- a/conda/environments/all_cuda-115_arch-x86_64.yaml +++ b/conda/environments/all_cuda-115_arch-x86_64.yaml @@ -22,5 +22,5 @@ dependencies: - pytest-cov - python>=3.8,<3.10 - scikit-build>=0.13.1 -- spdlog=1.10 +- spdlog>=1.8.5,<1.9 name: all_cuda-115_arch-x86_64 diff --git a/conda/environments/all_cuda-116_arch-x86_64.yaml b/conda/environments/all_cuda-116_arch-x86_64.yaml index 368b008f6..646565a90 100644 --- a/conda/environments/all_cuda-116_arch-x86_64.yaml +++ b/conda/environments/all_cuda-116_arch-x86_64.yaml @@ -22,5 +22,5 @@ dependencies: - pytest-cov - python>=3.8,<3.10 - scikit-build>=0.13.1 -- spdlog=1.10 +- spdlog>=1.8.5,<1.9 name: all_cuda-116_arch-x86_64 diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index 9f3f371a6..ce0bbeec5 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -14,7 +14,7 @@ gtest_version: - "=1.10.0" spdlog_version: - - "1.10" + - ">=1.8.5,<1.9" sysroot_version: - "2.17" diff --git a/dependencies.yaml b/dependencies.yaml index 8c838e96e..bd9b36122 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -43,7 +43,7 @@ dependencies: - scikit-build>=0.13.1 - output_types: conda packages: - - spdlog=1.10 + - spdlog>=1.8.5,<1.9 cudatoolkit: specific: - output_types: conda From be379e5fb4c9fc2bdd82d4cae5a0216e6f5c3458 Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Thu, 8 Dec 2022 09:45:38 -0500 Subject: [PATCH 194/675] update changelog --- CHANGELOG.md | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24ec05aa4..436e11f30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,34 @@ -# RMM 22.12.00 (Date TBD) +# RMM 22.12.00 (8 Dec 2022) -Please see https://github.com/rapidsai/rmm/releases/tag/v22.12.00a for the latest changes to this development branch. +## 🐛 Bug Fixes + +- Don't use CMake 3.25.0 as it has a show stopping FindCUDAToolkit bug ([#1162](https://github.com/rapidsai/rmm/pull/1162)) [@robertmaynard](https://github.com/robertmaynard) +- Relax test for async memory pool IPC handle support ([#1130](https://github.com/rapidsai/rmm/pull/1130)) [@bdice](https://github.com/bdice) + +## 📖 Documentation + +- Use rapidsai CODE_OF_CONDUCT.md ([#1159](https://github.com/rapidsai/rmm/pull/1159)) [@bdice](https://github.com/bdice) +- Fix doxygen formatting for set_stream. ([#1153](https://github.com/rapidsai/rmm/pull/1153)) [@bdice](https://github.com/bdice) +- Document required Python dependencies to build from source ([#1146](https://github.com/rapidsai/rmm/pull/1146)) [@ccoulombe](https://github.com/ccoulombe) +- fix failed automerge (Branch 22.12 merge 22.10) ([#1131](https://github.com/rapidsai/rmm/pull/1131)) [@harrism](https://github.com/harrism) + +## 🚀 New Features + +- Add wheel builds to rmm ([#1148](https://github.com/rapidsai/rmm/pull/1148)) [@vyasr](https://github.com/vyasr) + +## 🛠️ Improvements + +- Align __version__ with wheel version ([#1161](https://github.com/rapidsai/rmm/pull/1161)) [@sevagh](https://github.com/sevagh) +- Add `ninja` & Update CI environment variables ([#1155](https://github.com/rapidsai/rmm/pull/1155)) [@ajschmidt8](https://github.com/ajschmidt8) +- Remove CUDA 11.0 from dependencies.yaml. ([#1152](https://github.com/rapidsai/rmm/pull/1152)) [@bdice](https://github.com/bdice) +- Update dependencies schema. ([#1147](https://github.com/rapidsai/rmm/pull/1147)) [@bdice](https://github.com/bdice) +- Enable sccache for python build ([#1145](https://github.com/rapidsai/rmm/pull/1145)) [@Ethyling](https://github.com/Ethyling) +- Remove Jenkins scripts ([#1143](https://github.com/rapidsai/rmm/pull/1143)) [@ajschmidt8](https://github.com/ajschmidt8) +- Use `ninja` in GitHub Actions ([#1142](https://github.com/rapidsai/rmm/pull/1142)) [@ajschmidt8](https://github.com/ajschmidt8) +- Switch to using rapids-cmake for gbench. ([#1139](https://github.com/rapidsai/rmm/pull/1139)) [@vyasr](https://github.com/vyasr) +- Remove stale labeler ([#1137](https://github.com/rapidsai/rmm/pull/1137)) [@raydouglass](https://github.com/raydouglass) +- Add a public `copy` API to `DeviceBuffer` ([#1128](https://github.com/rapidsai/rmm/pull/1128)) [@galipremsagar](https://github.com/galipremsagar) +- Format gdb script. ([#1127](https://github.com/rapidsai/rmm/pull/1127)) [@bdice](https://github.com/bdice) # RMM 22.10.00 (12 Oct 2022) From c83a16fcf37358806eef05e35b44dcfc88630532 Mon Sep 17 00:00:00 2001 From: Ashwin Srinath <3190405+shwina@users.noreply.github.com> Date: Tue, 13 Dec 2022 16:57:13 -0500 Subject: [PATCH 195/675] Ensure `UpstreamResourceAdaptor` is not cleared by the Python GC (#1170) Closes #1169. Essentially, we are running into the situation described in https://cython.readthedocs.io/en/latest/src/userguide/extension_types.html#disabling-cycle-breaking-tp-clear with `UpstreamResourceAdaptor`. The solution is to prevent clearing of `UpstreamResourceAdaptor` objects by decorating them with `no_gc_clear`. Cython calls out the following: > If you use no_gc_clear, it is important that any given reference cycle contains at least one object without no_gc_clear. Otherwise, the cycle cannot be broken, which is a memory leak. The other object in RMM that we mark `@no_gc_clear` is `DeviceBuffer`, and a `DeviceBuffer` can keep a reference to an `UpstreamResourceAdaptor`. But, an `UpstreamResourceAdaptor` cannot keep a reference to a `DeviceBuffer`, so instances of the two cannot form a reference cycle AFAICT. Authors: - Ashwin Srinath (https://github.com/shwina) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1170 --- python/rmm/_lib/memory_resource.pyx | 3 +++ python/rmm/tests/test_rmm.py | 29 +++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index a20d481e0..afeeb3557 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -16,6 +16,7 @@ import os import warnings from collections import defaultdict +cimport cython from cython.operator cimport dereference as deref from libc.stdint cimport int8_t, int64_t, uintptr_t from libcpp cimport bool @@ -247,6 +248,8 @@ cdef class DeviceMemoryResource: self.c_obj.get().deallocate((ptr), nbytes) +# See the note about `no_gc_clear` in `device_buffer.pyx`. +@cython.no_gc_clear cdef class UpstreamResourceAdaptor(DeviceMemoryResource): def __cinit__(self, DeviceMemoryResource upstream_mr, *args, **kwargs): diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index 931ff5336..89d67a9c4 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -742,6 +742,13 @@ def callback(nbytes: int) -> bool: def test_dev_buf_circle_ref_dealloc(): + # This test creates a reference cycle containing a `DeviceBuffer` + # and ensures that the garbage collector does not clear it, i.e., + # that the GC does not remove all references to other Python + # objects from it. The `DeviceBuffer` needs to keep its reference + # to the `DeviceMemoryResource` that was used to create it in + # order to be cleaned up properly. See GH #931. + rmm.mr.set_current_device_resource(rmm.mr.CudaMemoryResource()) dbuf1 = rmm.DeviceBuffer(size=1_000_000) @@ -751,17 +758,27 @@ def test_dev_buf_circle_ref_dealloc(): l1.append(l1) # due to the reference cycle, the device buffer doesn't actually get - # cleaned up until later, when we invoke `gc.collect()`: + # cleaned up until after `gc.collect()` is called. del dbuf1, l1 rmm.mr.set_current_device_resource(rmm.mr.CudaMemoryResource()) - # by now, the only remaining reference to the *original* memory - # resource should be in `dbuf1`. However, the cyclic garbage collector - # will eliminate that reference when it clears the object via its - # `tp_clear` method. Later, when `tp_dealloc` attemps to actually - # deallocate `dbuf1` (which needs the MR alive), a segfault occurs. + # test that after the call to `gc.collect()`, the `DeviceBuffer` + # is deallocated successfully (i.e., without a segfault). + gc.collect() + + +def test_upstream_mr_circle_ref_dealloc(): + # This test is just like the one above, except it tests that + # instances of `UpstreamResourceAdaptor` (such as + # `PoolMemoryResource`) are not cleared by the GC. + rmm.mr.set_current_device_resource(rmm.mr.CudaMemoryResource()) + mr = rmm.mr.PoolMemoryResource(rmm.mr.get_current_device_resource()) + l1 = [mr] + l1.append(l1) + del mr, l1 + rmm.mr.set_current_device_resource(rmm.mr.CudaMemoryResource()) gc.collect() From c5c02fc2e1e60c02b6a474a812d7ed6e89df4cb8 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 13 Dec 2022 17:43:58 -0800 Subject: [PATCH 196/675] Update pre-commit hooks (#1154) This PR updates rmm's pre-commit hooks and CI style check scripts. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) - Ray Douglass (https://github.com/raydouglass) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1154 --- .clang-format | 4 +- .gitattributes | 1 + .github/CODEOWNERS | 2 +- .../ISSUE_TEMPLATE/documentation-request.md | 1 - .github/ops-bot.yaml | 1 - .pre-commit-config.yaml | 48 +++-- ci/check_style.sh | 128 +------------ ci/docs/build.sh | 3 +- ci/release/update-version.sh | 10 +- cmake/config.json | 2 +- .../all_cuda-115_arch-x86_64.yaml | 7 +- .../all_cuda-116_arch-x86_64.yaml | 7 +- dependencies.yaml | 17 +- print_env.sh | 22 +-- python/.flake8 | 10 - python/.flake8.cython | 30 --- python/rmm/_lib/cuda_stream.pyx | 1 - python/rmm/_lib/device_buffer.pyx | 4 +- python/rmm/_lib/memory_resource.pyx | 13 +- python/rmm/_lib/tests/test_device_buffer.pyx | 2 - python/setup.cfg | 23 +++ python/setup.py | 3 +- scripts/run-clang-format.py | 175 ------------------ scripts/run-cmake-format.sh | 2 +- 24 files changed, 102 insertions(+), 414 deletions(-) create mode 100644 .gitattributes delete mode 100644 python/.flake8 delete mode 100644 python/.flake8.cython delete mode 100755 scripts/run-clang-format.py diff --git a/.clang-format b/.clang-format index 6019a6f3d..26b9a5bf4 100644 --- a/.clang-format +++ b/.clang-format @@ -15,7 +15,7 @@ AlignTrailingComments: true AllowAllArgumentsOnNextLine: true AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: true +AllowShortBlocksOnASingleLine: true AllowShortCaseLabelsOnASingleLine: true AllowShortEnumsOnASingleLine: true AllowShortFunctionsOnASingleLine: All @@ -27,7 +27,7 @@ AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: true AlwaysBreakTemplateDeclarations: Yes -BinPackArguments: false +BinPackArguments: false BinPackParameters: false BraceWrapping: AfterClass: false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..723c5b8b1 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +python/rmm/_version.py export-subst diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 44656683c..3c02b406c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -11,7 +11,7 @@ python/ @rapidsai/rmm-python-codeowners **/cmake/ @rapidsai/rmm-cmake-codeowners #build/ops code owners -.github/ @rapidsai/ops-codeowners +.github/ @rapidsai/ops-codeowners ci/ @rapidsai/ops-codeowners conda/ @rapidsai/ops-codeowners **/Dockerfile @rapidsai/ops-codeowners diff --git a/.github/ISSUE_TEMPLATE/documentation-request.md b/.github/ISSUE_TEMPLATE/documentation-request.md index 29445495e..24215eceb 100644 --- a/.github/ISSUE_TEMPLATE/documentation-request.md +++ b/.github/ISSUE_TEMPLATE/documentation-request.md @@ -30,4 +30,3 @@ A clear and concise description of what documentation is needed and why. **Steps taken to search for needed documentation** List any steps you have taken. - diff --git a/.github/ops-bot.yaml b/.github/ops-bot.yaml index 6f542f418..57bdd6110 100644 --- a/.github/ops-bot.yaml +++ b/.github/ops-bot.yaml @@ -8,4 +8,3 @@ release_drafter: true copy_prs: true rerun_tests: true recently_updated: true - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 356c35db7..027ce9857 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,31 +1,49 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. repos: - - repo: https://github.com/pycqa/isort + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - repo: https://github.com/PyCQA/isort rev: 5.10.1 hooks: - id: isort - args: ["--settings-path=python/setup.cfg"] + args: ["--config-root=python/", "--resolve-all-configs"] files: python/.* - exclude: __init__.py$ - types: [text] - types_or: [python, cython] + types_or: [python, cython, pyi] - repo: https://github.com/ambv/black rev: 22.3.0 hooks: - id: black args: ["--config=python/pyproject.toml"] - repo: https://github.com/PyCQA/flake8 - rev: 3.8.3 + rev: 5.0.4 hooks: - id: flake8 - alias: flake8 - name: flake8 - args: ["--config=python/.flake8"] - types: [python] - - id: flake8 - alias: flake8-cython - name: flake8-cython - args: ["--config=python/.flake8.cython"] - types: [cython] + args: ["--config=python/setup.cfg"] + files: python/.*$ + types: [file] + types_or: [python, cython] + additional_dependencies: ["flake8-force"] + - repo: https://github.com/MarcoGorelli/cython-lint + rev: v0.1.10 + hooks: + - id: cython-lint + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v11.1.0 + hooks: + - id: clang-format + types_or: [c, c++, cuda] + args: ["-fallback-style=none", "-style=file", "-i"] + - repo: https://github.com/sirosen/texthooks + rev: 0.4.0 + hooks: + - id: fix-smartquotes + exclude: | + (?x)^( + ^benchmarks/utilities/cxxopts.hpp + ) - repo: local hooks: - id: cmake-format diff --git a/ci/check_style.sh b/ci/check_style.sh index ef8565ded..66f961d41 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -14,126 +14,10 @@ rapids-dependency-file-generator \ rapids-mamba-retry env create --force -f env.yaml -n checks conda activate checks -set +e +FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.02/cmake-format-rapids-cmake.json +export RAPIDS_CMAKE_FORMAT_FILE=/tmp/rapids_cmake_ci/cmake-formats-rapids-cmake.json +mkdir -p $(dirname ${RAPIDS_CMAKE_FORMAT_FILE}) +wget -O ${RAPIDS_CMAKE_FORMAT_FILE} ${FORMAT_FILE_URL} -# Run isort and get results/return code -ISORT=$(isort --check-only python --settings-path=python/setup.cfg) -ISORT_RETVAL=$? - -# Run black and get results/return code -BLACK=$(black --config python/pyproject.toml --check python) -BLACK_RETVAL=$? - -# Run flake8 and get results/return code -FLAKE=$(flake8 --config=python/.flake8 python) -FLAKE_RETVAL=$? - -# Run flake8-cython and get results/return code -FLAKE_CYTHON=$(flake8 --config=python/.flake8.cython) -FLAKE_CYTHON_RETVAL=$? - -# Run clang-format and check for a consistent code format -CLANG_FORMAT=$(python scripts/run-clang-format.py 2>&1) -CLANG_FORMAT_RETVAL=$? - -# Run cmake-format / cmake-lint and get results/return code -CMAKE_FILES=($(find . | grep -E "^.*\.cmake(\.in)?$|^.*/CMakeLists.txt$")) - -CMAKE_FORMATS=() -CMAKE_FORMAT_RETVAL=0 - -CMAKE_LINTS=() -CMAKE_LINT_RETVAL=0 - -CURRENT_TAG=$(git tag --merged HEAD | grep -xE '^v.*' | sort --version-sort | tail -n 1 | tr -d 'v') -CURRENT_MAJOR=$(echo "${CURRENT_TAG}" | awk '{split($0, a, "."); print a[1]}') -CURRENT_MINOR=$(echo "${CURRENT_TAG}" | awk '{split($0, a, "."); print a[2]}') -CURRENT_SHORT_TAG="${CURRENT_MAJOR}.${CURRENT_MINOR}" -rapids-retry curl -s "https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${CURRENT_SHORT_TAG}/cmake-format-rapids-cmake.json" -o cmake/rapids-cmake.json - -for cmake_file in "${CMAKE_FILES[@]}"; do - cmake-format --in-place --config-files cmake/config.json cmake/rapids-cmake.json -- "${cmake_file}" - TMP_CMAKE_FORMAT=$(git diff --color --exit-code -- "${cmake_file}") - TMP_CMAKE_FORMAT_RETVAL=$? - if [ "$TMP_CMAKE_FORMAT_RETVAL" != "0" ]; then - CMAKE_FORMAT_RETVAL=1 - CMAKE_FORMATS+=("$TMP_CMAKE_FORMAT") - fi - - TMP_CMAKE_LINT=$(cmake-lint --config-files cmake/config.json cmake/rapids-cmake.json -- "${cmake_file}") - TMP_CMAKE_LINT_RETVAL=$? - if [ "$TMP_CMAKE_LINT_RETVAL" != "0" ]; then - CMAKE_LINT_RETVAL=1 - CMAKE_LINTS+=("$TMP_CMAKE_LINT") - fi -done - - -# Output results if failure otherwise show pass -if [ "$ISORT_RETVAL" != "0" ]; then - echo -e "\n\n>>>> FAILED: isort style check; begin output\n\n" - echo -e "$ISORT" - echo -e "\n\n>>>> FAILED: isort style check; end output\n\n" -else - echo -e "\n\n>>>> PASSED: isort style check\n\n" -fi - -if [ "$BLACK_RETVAL" != "0" ]; then - echo -e "\n\n>>>> FAILED: black style check; begin output\n\n" - echo -e "$BLACK" - echo -e "\n\n>>>> FAILED: black style check; end output\n\n" -else - echo -e "\n\n>>>> PASSED: black style check\n\n" -fi - -if [ "$FLAKE_RETVAL" != "0" ]; then - echo -e "\n\n>>>> FAILED: flake8 style check; begin output\n\n" - echo -e "$FLAKE" - echo -e "\n\n>>>> FAILED: flake8 style check; end output\n\n" -else - echo -e "\n\n>>>> PASSED: flake8 style check\n\n" -fi - -if [ "$FLAKE_CYTHON_RETVAL" != "0" ]; then - echo -e "\n\n>>>> FAILED: flake8-cython style check; begin output\n\n" - echo -e "$FLAKE_CYTHON" - echo -e "\n\n>>>> FAILED: flake8-cython style check; end output\n\n" -else - echo -e "\n\n>>>> PASSED: flake8-cython style check\n\n" -fi - -if [ "$CLANG_FORMAT_RETVAL" != "0" ]; then - echo -e "\n\n>>>> FAILED: clang format check; begin output\n\n" - echo -e "$CLANG_FORMAT" - echo -e "\n\n>>>> FAILED: clang format check; end output\n\n" -else - echo -e "\n\n>>>> PASSED: clang format check\n\n" -fi - -if [ "$CMAKE_FORMAT_RETVAL" != "0" ]; then - echo -e "\n\n>>>> FAILED: cmake format check; begin output\n\n" - for CMAKE_FORMAT in "${CMAKE_FORMATS[@]}"; do - echo -e "$CMAKE_FORMAT" - echo -e "\n" - done - echo -e "\n\n>>>> FAILED: cmake format check; end output\n\n" -else - echo -e "\n\n>>>> PASSED: cmake format check\n\n" -fi - -if [ "$CMAKE_LINT_RETVAL" != "0" ]; then - echo -e "\n\n>>>> FAILED: cmake lint check; begin output\n\n" - for CMAKE_LINT in "${CMAKE_LINTS[@]}"; do - echo -e "$CMAKE_LINT" - echo -e "\n" - done - echo -e "\n\n>>>> FAILED: cmake lint check; end output\n\n" -else - echo -e "\n\n>>>> PASSED: cmake lint check\n\n" -fi - -RETVALS=($ISORT_RETVAL $BLACK_RETVAL $FLAKE_RETVAL $FLAKE_CYTHON_RETVAL $CLANG_FORMAT_RETVAL $CMAKE_FORMAT_RETVAL $CMAKE_LINT_RETVAL) -IFS=$'\n' -RETVAL=$(echo "${RETVALS[*]}" | sort -nr | head -n1) - -exit "${RETVAL}" +# Run pre-commit checks +pre-commit run --hook-stage manual --all-files --show-diff-on-failure diff --git a/ci/docs/build.sh b/ci/docs/build.sh index 972dc7391..eed509dc5 100644 --- a/ci/docs/build.sh +++ b/ci/docs/build.sh @@ -54,10 +54,9 @@ for PROJECT in ${PROJECTS[@]}; do if [ ! -d "api/$PROJECT/$BRANCH_VERSION" ]; then mkdir -p api/$PROJECT/$BRANCH_VERSION fi - rm -rf $DOCS_WORKSPACE/api/$PROJECT/$BRANCH_VERSION/* + rm -rf $DOCS_WORKSPACE/api/$PROJECT/$BRANCH_VERSION/* done mv $PROJECT_WORKSPACE/doxygen/html/* $DOCS_WORKSPACE/api/librmm/$BRANCH_VERSION mv $PROJECT_WORKSPACE/python/docs/_build/html/* $DOCS_WORKSPACE/api/rmm/$BRANCH_VERSION - diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 01450d8bf..b8ee8d2c9 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -29,12 +29,20 @@ function sed_runner() { sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak } +# cpp update sed_runner 's/'" VERSION .*"'/'" VERSION ${NEXT_FULL_TAG}"'/g' CMakeLists.txt -sed_runner 's/'"rmm_version .*)"'/'"rmm_version ${NEXT_FULL_TAG})"'/g' python/CMakeLists.txt sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' CMakeLists.txt + +# Python update +sed_runner 's/'"rmm_version .*)"'/'"rmm_version ${NEXT_FULL_TAG})"'/g' python/CMakeLists.txt sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' python/CMakeLists.txt +# cmake-format rapids-cmake definitions +sed_runner 's/'"branch-.*\/cmake-format-rapids-cmake.json"'/'"branch-${NEXT_SHORT_TAG}\/cmake-format-rapids-cmake.json"'/g' ci/checks/style.sh + +# doxyfile update sed_runner 's/'"PROJECT_NUMBER = .*"'/'"PROJECT_NUMBER = ${NEXT_SHORT_TAG}"'/g' doxygen/Doxyfile +# sphinx docs update sed_runner 's/'"version =.*"'/'"version = \"${NEXT_SHORT_TAG}\""'/g' python/docs/conf.py sed_runner 's/'"release =.*"'/'"release = \"${NEXT_FULL_TAG}\""'/g' python/docs/conf.py diff --git a/cmake/config.json b/cmake/config.json index 6fb9d3fd7..59fc54be3 100644 --- a/cmake/config.json +++ b/cmake/config.json @@ -9,7 +9,7 @@ "VERSION": "?", "GIT_SHALLOW": "?", "OPTIONS": "*", - "FIND_PACKAGE_ARGUMENTS": "*" + "FIND_PACKAGE_ARGUMENTS": "*" } }, "ConfigureTest": { diff --git a/conda/environments/all_cuda-115_arch-x86_64.yaml b/conda/environments/all_cuda-115_arch-x86_64.yaml index 0f6da8e09..fd40328c3 100644 --- a/conda/environments/all_cuda-115_arch-x86_64.yaml +++ b/conda/environments/all_cuda-115_arch-x86_64.yaml @@ -4,20 +4,15 @@ channels: - rapidsai - conda-forge dependencies: -- black=22.3.0 -- clang-tools=11.1.0 -- clang=11.1.0 - cmake>=3.23.1,!=3.25.0 -- cmakelang=0.6.13 - cuda-python>=11.7.1,<12.0 - cudatoolkit=11.5 - cython>=0.29,<0.30 -- flake8=3.8.3 - gcovr>=5.0 -- isort=5.10.1 - ninja - numba>=0.49 - numpy>=1.19 +- pre-commit - pytest - pytest-cov - python>=3.8,<3.10 diff --git a/conda/environments/all_cuda-116_arch-x86_64.yaml b/conda/environments/all_cuda-116_arch-x86_64.yaml index 646565a90..3cec992a5 100644 --- a/conda/environments/all_cuda-116_arch-x86_64.yaml +++ b/conda/environments/all_cuda-116_arch-x86_64.yaml @@ -4,20 +4,15 @@ channels: - rapidsai - conda-forge dependencies: -- black=22.3.0 -- clang-tools=11.1.0 -- clang=11.1.0 - cmake>=3.23.1,!=3.25.0 -- cmakelang=0.6.13 - cuda-python>=11.7.1,<12.0 - cudatoolkit=11.6 - cython>=0.29,<0.30 -- flake8=3.8.3 - gcovr>=5.0 -- isort=5.10.1 - ninja - numba>=0.49 - numpy>=1.19 +- pre-commit - pytest - pytest-cov - python>=3.8,<3.10 diff --git a/dependencies.yaml b/dependencies.yaml index bd9b36122..1b16db27b 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -7,6 +7,7 @@ files: arch: [x86_64] includes: - build + - checks - cudatoolkit - develop - run @@ -24,8 +25,7 @@ files: checks: output: none includes: - - build - - develop + - checks - py_version channels: - rapidsai @@ -44,6 +44,11 @@ dependencies: - output_types: conda packages: - spdlog>=1.8.5,<1.9 + checks: + common: + - output_types: [conda, requirements] + packages: + - pre-commit cudatoolkit: specific: - output_types: conda @@ -68,15 +73,7 @@ dependencies: common: - output_types: [conda, requirements] packages: - - black=22.3.0 - - cmakelang=0.6.13 - - flake8=3.8.3 - gcovr>=5.0 - - isort=5.10.1 - - output_types: conda - packages: - - clang=11.1.0 - - clang-tools=11.1.0 py_version: specific: - output_types: conda diff --git a/print_env.sh b/print_env.sh index 28b3049cf..f67641ea2 100755 --- a/print_env.sh +++ b/print_env.sh @@ -1,38 +1,38 @@ #!/usr/bin/env bash # Reports relevant environment information useful for diagnosing and # debugging RMM issues. -# Usage: +# Usage: # "./print_env.sh" - prints to stdout # "./print_env.sh > env.txt" - prints to file "env.txt" echo "**git***" git log --decorate -n 1 -echo +echo echo "***OS Information***" cat /etc/*-release uname -a -echo +echo echo "***GPU Information***" nvidia-smi -echo +echo echo "***CPU***" lscpu echo echo "***CMake***" -which cmake && cmake --version -echo +which cmake && cmake --version +echo echo "***g++***" -which g++ && g++ --version -echo +which g++ && g++ --version +echo echo "***nvcc***" -which nvcc && nvcc --version -echo +which nvcc && nvcc --version +echo echo "***Python***" which python && python --version @@ -57,7 +57,7 @@ echo # Print conda packages if conda exists if type "conda" > /dev/null; then echo '***conda packages***' -which conda && conda list +which conda && conda list echo # Print pip packages if pip exists elif type "pip" > /dev/null; then diff --git a/python/.flake8 b/python/.flake8 deleted file mode 100644 index 1d251eec6..000000000 --- a/python/.flake8 +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. - -[flake8] -exclude = __init__.py -ignore = - # line break before binary operator - W503 - # whitespace before : - E203 - diff --git a/python/.flake8.cython b/python/.flake8.cython deleted file mode 100644 index 2b614a924..000000000 --- a/python/.flake8.cython +++ /dev/null @@ -1,30 +0,0 @@ -# -# Copyright (c) 2018-2019, 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. -# - -[flake8] -filename = *.pyx, *.pxd -exclude = *.egg, build, docs, .git -ignore = E999, E225, E226, E227, E402, W503, W504, E211 - -# Rules ignored: -# E999: invalid syntax (works for Python, not Cython) -# E211: whitespace before '(' (used in multi-line imports) -# E225: Missing whitespace around operators (breaks cython casting syntax like ) -# E226: Missing whitespace around arithmetic operators (breaks cython pointer syntax like int*) -# E227: Missing whitespace around bitwise or shift operator (Can also break casting syntax) -# E402: Module level import not at top of file (cimport is not recognized as import) -# W503: line break before binary operator (breaks lines that start with a pointer) -# W504: line break after binary operator (breaks lines that end with a pointer) diff --git a/python/rmm/_lib/cuda_stream.pyx b/python/rmm/_lib/cuda_stream.pyx index d93af2509..fb35ec11f 100644 --- a/python/rmm/_lib/cuda_stream.pyx +++ b/python/rmm/_lib/cuda_stream.pyx @@ -14,7 +14,6 @@ cimport cython from cuda.ccudart cimport cudaStream_t -from libc.stdint cimport uintptr_t from libcpp cimport bool diff --git a/python/rmm/_lib/device_buffer.pyx b/python/rmm/_lib/device_buffer.pyx index ce0009dbf..43ebf41ac 100644 --- a/python/rmm/_lib/device_buffer.pyx +++ b/python/rmm/_lib/device_buffer.pyx @@ -15,9 +15,8 @@ import numpy as np cimport cython from cpython.bytes cimport PyBytes_AS_STRING, PyBytes_FromStringAndSize -from cython.operator cimport dereference from libc.stdint cimport uintptr_t -from libcpp.memory cimport make_unique, unique_ptr +from libcpp.memory cimport unique_ptr from libcpp.utility cimport move from rmm._cuda.stream cimport Stream @@ -31,7 +30,6 @@ from cuda.ccudart cimport ( cudaMemcpyAsync, cudaMemcpyKind, cudaStream_t, - cudaStreamSynchronize, ) from rmm._lib.memory_resource cimport get_current_device_resource diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index afeeb3557..854e14d8c 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -20,20 +20,13 @@ cimport cython from cython.operator cimport dereference as deref from libc.stdint cimport int8_t, int64_t, uintptr_t from libcpp cimport bool -from libcpp.cast cimport dynamic_cast -from libcpp.memory cimport make_shared, make_unique, shared_ptr, unique_ptr +from libcpp.memory cimport make_unique, unique_ptr from libcpp.pair cimport pair from libcpp.string cimport string from cuda.cudart import cudaError_t -from rmm._cuda.gpu import ( - CUDARuntimeError, - driverGetVersion, - getDevice, - runtimeGetVersion, - setDevice, -) +from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice from rmm._lib.cuda_stream_view cimport cuda_stream_view @@ -530,8 +523,6 @@ cdef class BinningMemoryResource(UpstreamResourceAdaptor): bin_resource : DeviceMemoryResource The resource to use for this bin (optional) """ - cdef DeviceMemoryResource _bin_resource - if bin_resource is None: (( self.c_obj.get()))[0].add_bin(allocation_size) diff --git a/python/rmm/_lib/tests/test_device_buffer.pyx b/python/rmm/_lib/tests/test_device_buffer.pyx index c4f5e5ae3..733383827 100644 --- a/python/rmm/_lib/tests/test_device_buffer.pyx +++ b/python/rmm/_lib/tests/test_device_buffer.pyx @@ -12,11 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import cython import numpy as np from libcpp.memory cimport make_unique -from libcpp.utility cimport move from rmm._lib.cuda_stream_view cimport cuda_stream_default from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer diff --git a/python/setup.cfg b/python/setup.cfg index 9e0227b94..7a1f5c819 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -13,6 +13,29 @@ versionfile_build = rmm/_version.py tag_prefix = v parentdir_prefix = rmm- +[flake8] +filename = *.py, *.pyx, *.pxd, *.pxi +exclude = __init__.py, *.egg, build, docs, .git +force-check = True +ignore = + # line break before binary operator + W503, + # whitespace before : + E203 +per-file-ignores = + # Rules ignored only in Cython: + # E211: whitespace before '(' (used in multi-line imports) + # E225: Missing whitespace around operators (breaks cython casting syntax like ) + # E226: Missing whitespace around arithmetic operators (breaks cython pointer syntax like int*) + # E227: Missing whitespace around bitwise or shift operator (Can also break casting syntax) + # E275: Missing whitespace after keyword (Doesn't work with Cython except?) + # E402: invalid syntax (works for Python, not Cython) + # E999: invalid syntax (works for Python, not Cython) + # W504: line break after binary operator (breaks lines that end with a pointer) + *.pyx: E211, E225, E226, E227, E275, E402, E999, W504 + *.pxd: E211, E225, E226, E227, E275, E402, E999, W504 + *.pxi: E211, E225, E226, E227, E275, E402, E999, W504 + [isort] line_length=79 multi_line_output=3 diff --git a/python/setup.py b/python/setup.py index 8ea0f3ab7..ee8fb9e5f 100644 --- a/python/setup.py +++ b/python/setup.py @@ -2,11 +2,10 @@ import os +import versioneer from setuptools import find_packages from skbuild import setup -import versioneer - if "RAPIDS_PY_WHEEL_VERSIONEER_OVERRIDE" in os.environ: orig_get_versions = versioneer.get_versions diff --git a/scripts/run-clang-format.py b/scripts/run-clang-format.py deleted file mode 100755 index 6c4370742..000000000 --- a/scripts/run-clang-format.py +++ /dev/null @@ -1,175 +0,0 @@ -# Copyright (c) 2019-2020, 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. -# - -from __future__ import print_function - -import argparse -import os -import re -import subprocess -import sys -import tempfile - -EXPECTED_VERSION = "11.1.0" -VERSION_REGEX = re.compile(r"clang-format version ([0-9.]+)") -# NOTE: populate this list with more top-level dirs as we add more of them -# to the rmm repo -DEFAULT_DIRS = ["src", "include", "tests", "benchmarks"] - - -def parse_args(): - argparser = argparse.ArgumentParser("Runs clang-format on a project") - argparser.add_argument( - "-dstdir", - type=str, - default=None, - help="Directory to store the temporary outputs of" - " clang-format. If nothing is passed for this, then" - " a temporary dir will be created using `mkdtemp`", - ) - argparser.add_argument( - "-exe", - type=str, - default="clang-format", - help="Path to clang-format exe", - ) - argparser.add_argument( - "-inplace", - default=False, - action="store_true", - help="Replace the source files itself.", - ) - argparser.add_argument( - "-regex", - type=str, - default=r"[.](cu|cuh|h|hpp|cpp)$", - help="Regex string to filter in sources", - ) - argparser.add_argument( - "-ignore", - type=str, - default=r"cannylab/bh[.]cu$", - help="Regex used to ignore files from matched list", - ) - argparser.add_argument( - "-v", - dest="verbose", - action="store_true", - help="Print verbose messages", - ) - argparser.add_argument( - "dirs", type=str, nargs="*", help="List of dirs where to find sources" - ) - args = argparser.parse_args() - args.regex_compiled = re.compile(args.regex) - args.ignore_compiled = re.compile(args.ignore) - if args.dstdir is None: - args.dstdir = tempfile.mkdtemp() - ret = subprocess.check_output("%s --version" % args.exe, shell=True) - ret = ret.decode("utf-8") - version = VERSION_REGEX.match(ret) - if version is None: - raise Exception("Failed to figure out clang-format version!") - version = version.group(1) - if version != EXPECTED_VERSION: - raise Exception( - "clang-format exe must be v%s found '%s'" - % (EXPECTED_VERSION, version) - ) - if len(args.dirs) == 0: - args.dirs = DEFAULT_DIRS - return args - - -def list_all_src_files(file_regex, ignore_regex, srcdirs, dstdir, inplace): - allFiles = [] - for srcdir in srcdirs: - for root, dirs, files in os.walk(srcdir): - for f in files: - if re.search(file_regex, f): - src = os.path.join(root, f) - if re.search(ignore_regex, src): - continue - if inplace: - _dir = root - else: - _dir = os.path.join(dstdir, root) - dst = os.path.join(_dir, f) - allFiles.append((src, dst)) - return allFiles - - -def run_clang_format(src, dst, exe, verbose): - dstdir = os.path.dirname(dst) - if not os.path.exists(dstdir): - os.makedirs(dstdir) - # run the clang format command itself - if src == dst: - cmd = "%s -i %s" % (exe, src) - else: - cmd = "%s %s > %s" % (exe, src, dst) - try: - subprocess.check_call(cmd, shell=True) - except subprocess.CalledProcessError: - print("Failed to run clang-format! Maybe your env is not proper?") - raise - # run the diff to check if there are any formatting issues - cmd = "diff -q %s %s >/dev/null" % (src, dst) - try: - subprocess.check_call(cmd, shell=True) - if verbose: - print("%s passed" % os.path.basename(src)) - except subprocess.CalledProcessError: - print( - "%s failed! 'diff %s %s' will show formatting violations!" - % (os.path.basename(src), src, dst) - ) - return False - return True - - -def main(): - args = parse_args() - # Attempt to making sure that we run this script from root of repo always - if not os.path.exists(".git"): - print("Error!! This needs to always be run from the root of repo") - sys.exit(-1) - all_files = list_all_src_files( - args.regex_compiled, - args.ignore_compiled, - args.dirs, - args.dstdir, - args.inplace, - ) - # actual format checker - status = True - for src, dst in all_files: - if not run_clang_format(src, dst, args.exe, args.verbose): - status = False - if not status: - print("clang-format failed! You have 2 options:") - print(" 1. Look at formatting differences above and fix them manually") - print(" 2. Or run the below command to bulk-fix all these at once") - print("Bulk-fix command: ") - print( - " python scripts/run-clang-format.py %s -inplace" - % " ".join(sys.argv[1:]) - ) - sys.exit(-1) - return - - -if __name__ == "__main__": - main() diff --git a/scripts/run-cmake-format.sh b/scripts/run-cmake-format.sh index 6175a9dc8..a7d9984b3 100755 --- a/scripts/run-cmake-format.sh +++ b/scripts/run-cmake-format.sh @@ -15,7 +15,7 @@ # and exits gracefully if the file is not found. If a user wishes to specify a # config file at a nonstandard location, they may do so by setting the # environment variable RAPIDS_CMAKE_FORMAT_FILE. -# +# # This script can be invoked directly anywhere within the project repository. # Alternatively, it may be invoked as a pre-commit hook via # `pre-commit run (cmake-format)|(cmake-lint)`. From 0a6b1610d00d535ba43d037273760bca831ae547 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 20 Dec 2022 15:07:23 -0800 Subject: [PATCH 197/675] Update conda recipes. (#1180) A few minor tweaks to conda recipes to align with other RAPIDS packages for the GitHub Actions migration. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1180 --- conda/recipes/librmm/meta.yaml | 8 ++++---- conda/recipes/rmm/meta.yaml | 18 ++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index a6599bb33..720cf97c4 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -1,8 +1,8 @@ # Copyright (c) 2018-2022, NVIDIA CORPORATION. {% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} -{% set cuda_version='.'.join(environ.get('RAPIDS_CUDA_VERSION', '11.5.2').split('.')[:2]) %} -{% set cuda_major=cuda_version.split('.')[0] %} +{% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} +{% set cuda_major = cuda_version.split('.')[0] %} {% set cuda_spec = ">=" + cuda_major ~ ",<" + (cuda_major | int + 1) ~ ".0a0" %} # i.e. >=11,<12.0a0 package: @@ -89,7 +89,7 @@ outputs: - test -f $PREFIX/include/rmm/mr/host/new_delete_resource.hpp - test -f $PREFIX/include/rmm/mr/host/pinned_memory_resource.hpp about: - home: http://rapids.ai/ + home: https://rapids.ai/ license: Apache-2.0 summary: librmm library - name: librmm-tests @@ -109,6 +109,6 @@ outputs: - gtest {{ gtest_version }} - gmock {{ gtest_version }} about: - home: http://rapids.ai/ + home: https://rapids.ai/ license: Apache-2.0 summary: librmm test & benchmark executables diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 0edc9df5a..18f6011e5 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -1,9 +1,9 @@ # Copyright (c) 2019-2022, NVIDIA CORPORATION. {% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} -{% set py_version=environ.get('CONDA_PY', 35) %} -{% set cuda_version='.'.join(environ.get('RAPIDS_CUDA_VERSION', '11.5.2').split('.')[:2]) %} -{% set cuda_major=cuda_version.split('.')[0] %} +{% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} +{% set cuda_major = cuda_version.split('.')[0] %} +{% set py_version = environ['CONDA_PY'] %} package: name: rmm @@ -16,8 +16,6 @@ build: number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_py{{ py_version }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} script_env: - - RMM_BUILD_NO_GPU_TEST - - VERSION_SUFFIX - CMAKE_GENERATOR - CMAKE_C_COMPILER_LAUNCHER - CMAKE_CXX_COMPILER_LAUNCHER @@ -34,7 +32,7 @@ build: requirements: build: - - cmake>=3.23.1,!=3.25.0 + - cmake >=3.23.1,!=3.25.0 - ninja - {{ compiler('c') }} - {{ compiler('cxx') }} @@ -42,11 +40,11 @@ requirements: - sysroot_{{ target_platform }} {{ sysroot_version }} host: - cuda-python >=11.7.1,<12.0 - - cudatoolkit {{ cuda_version }}.* + - cudatoolkit ={{ cuda_version }} - cython >=0.29,<0.30 - - librmm {{ version }}.* + - librmm ={{ version }} - python - - scikit-build>=0.13.1 + - scikit-build >=0.13.1 - setuptools run: - cuda-python >=11.7.1,<12.0 @@ -59,7 +57,7 @@ test: - rmm about: - home: http://rapids.ai/ + home: https://rapids.ai/ license: Apache-2.0 license_family: Apache license_file: LICENSE From 3e2530128e325cd7ef65fc4295597d13409b6eaf Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Fri, 30 Dec 2022 16:45:49 -0500 Subject: [PATCH 198/675] Build CUDA `11.8` and Python `3.10` Packages (#1184) This PR updates `rmm` to build against branch [cuda-118](https://github.com/rapidsai/shared-action-workflows/compare/cuda-118) of the `shared-action-workflow` repository. That branch contains updates for CUDA 11.8 and Python 3.10 packages. It also includes some minor file renames. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1184 --- .github/workflows/build.yaml | 6 +++--- .github/workflows/pr.yaml | 12 +++++------ .github/workflows/test.yaml | 4 ++-- README.md | 2 +- .../all_cuda-116_arch-x86_64.yaml | 21 ------------------- ..._64.yaml => all_cuda-118_arch-x86_64.yaml} | 6 +++--- dependencies.yaml | 12 +++++++++-- 7 files changed, 25 insertions(+), 38 deletions(-) delete mode 100644 conda/environments/all_cuda-116_arch-x86_64.yaml rename conda/environments/{all_cuda-115_arch-x86_64.yaml => all_cuda-118_arch-x86_64.yaml} (85%) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9e8d59875..b446a5fd0 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-matrix-build.yaml@main + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@cuda-118 with: build_type: ${{ inputs.build_type || 'branch' }} repo: rapidsai/rmm @@ -38,7 +38,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-matrix-build.yaml@main + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@cuda-118 with: build_type: ${{ inputs.build_type || 'branch' }} repo: rapidsai/rmm @@ -48,7 +48,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@main + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@cuda-118 with: build_type: ${{ inputs.build_type || 'branch' }} repo: rapidsai/rmm diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 3ddb08dd7..be1c89255 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -18,31 +18,31 @@ jobs: - conda-python-build - conda-python-tests secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@main + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@cuda-118 checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@main + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@cuda-118 conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-matrix-build.yaml@main + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@cuda-118 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@main + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-118 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-matrix-build.yaml@main + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@cuda-118 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@main + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@cuda-118 with: build_type: pull-request diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7230acd84..990e49e61 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@main + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-118 with: build_type: nightly repo: rapidsai/rmm @@ -25,7 +25,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@main + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@cuda-118 with: build_type: nightly repo: rapidsai/rmm diff --git a/README.md b/README.md index 91c5c577f..369d7c54b 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ $ cd rmm - Create the conda development environment `rmm_dev` ```bash # create the conda environment (assuming in base `rmm` directory) -$ conda env create --name rmm_dev --file conda/environments/all_cuda-115_arch-x86_64.yaml +$ conda env create --name rmm_dev --file conda/environments/all_cuda-118_arch-x86_64.yaml # activate the environment $ conda activate rmm_dev ``` diff --git a/conda/environments/all_cuda-116_arch-x86_64.yaml b/conda/environments/all_cuda-116_arch-x86_64.yaml deleted file mode 100644 index 3cec992a5..000000000 --- a/conda/environments/all_cuda-116_arch-x86_64.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# This file is generated by `rapids-dependency-file-generator`. -# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. -channels: -- rapidsai -- conda-forge -dependencies: -- cmake>=3.23.1,!=3.25.0 -- cuda-python>=11.7.1,<12.0 -- cudatoolkit=11.6 -- cython>=0.29,<0.30 -- gcovr>=5.0 -- ninja -- numba>=0.49 -- numpy>=1.19 -- pre-commit -- pytest -- pytest-cov -- python>=3.8,<3.10 -- scikit-build>=0.13.1 -- spdlog>=1.8.5,<1.9 -name: all_cuda-116_arch-x86_64 diff --git a/conda/environments/all_cuda-115_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml similarity index 85% rename from conda/environments/all_cuda-115_arch-x86_64.yaml rename to conda/environments/all_cuda-118_arch-x86_64.yaml index fd40328c3..e075564df 100644 --- a/conda/environments/all_cuda-115_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -6,7 +6,7 @@ channels: dependencies: - cmake>=3.23.1,!=3.25.0 - cuda-python>=11.7.1,<12.0 -- cudatoolkit=11.5 +- cudatoolkit=11.8 - cython>=0.29,<0.30 - gcovr>=5.0 - ninja @@ -15,7 +15,7 @@ dependencies: - pre-commit - pytest - pytest-cov -- python>=3.8,<3.10 +- python>=3.8,<3.11 - scikit-build>=0.13.1 - spdlog>=1.8.5,<1.9 -name: all_cuda-115_arch-x86_64 +name: all_cuda-118_arch-x86_64 diff --git a/dependencies.yaml b/dependencies.yaml index 1b16db27b..e83e6ddd4 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -3,7 +3,7 @@ files: all: output: conda matrix: - cuda: ["11.5", "11.6"] + cuda: ["11.8"] arch: [x86_64] includes: - build @@ -39,7 +39,7 @@ dependencies: - cuda-python>=11.7.1,<12.0 - cython>=0.29,<0.30 - ninja - - python>=3.8,<3.10 + - python>=3.8,<3.11 - scikit-build>=0.13.1 - output_types: conda packages: @@ -69,6 +69,10 @@ dependencies: cuda: "11.6" packages: - cudatoolkit=11.6 + - matrix: + cuda: "11.8" + packages: + - cudatoolkit=11.8 develop: common: - output_types: [conda, requirements] @@ -86,6 +90,10 @@ dependencies: py: "3.9" packages: - python=3.9 + - matrix: + py: "3.10" + packages: + - python=3.10 run: common: - output_types: [conda, requirements] From 7fb45d44c8ca4151581f5c57e413d1aea4b00f3f Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Mon, 2 Jan 2023 14:36:13 -0500 Subject: [PATCH 199/675] Update workflows for nightly tests (#1186) Due to some limitations on the number of reusable workflows that can be used in a given GH Action workflow, I need to switch the nightly workflow files (`build.yaml` and `test.yaml`) to use `workflow_dispatch` instead of `workflow_call`. Because of this switch, we can also remove the hardcoded `repo` field in `{build,test}.yaml`. --- .github/workflows/build.yaml | 5 +---- .github/workflows/test.yaml | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b446a5fd0..d7e81bcd3 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -6,7 +6,7 @@ on: - "branch-*" tags: - v[0-9][0-9].[0-9][0-9].[0-9][0-9] - workflow_call: + workflow_dispatch: inputs: branch: required: true @@ -31,7 +31,6 @@ jobs: uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@cuda-118 with: build_type: ${{ inputs.build_type || 'branch' }} - repo: rapidsai/rmm branch: ${{ inputs.branch }} date: ${{ inputs.date }} sha: ${{ inputs.sha }} @@ -41,7 +40,6 @@ jobs: uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@cuda-118 with: build_type: ${{ inputs.build_type || 'branch' }} - repo: rapidsai/rmm branch: ${{ inputs.branch }} date: ${{ inputs.date }} sha: ${{ inputs.sha }} @@ -51,7 +49,6 @@ jobs: uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@cuda-118 with: build_type: ${{ inputs.build_type || 'branch' }} - repo: rapidsai/rmm branch: ${{ inputs.branch }} date: ${{ inputs.date }} sha: ${{ inputs.sha }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 990e49e61..c0961b587 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,7 +1,7 @@ name: test on: - workflow_call: + workflow_dispatch: inputs: branch: required: true @@ -19,7 +19,6 @@ jobs: uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-118 with: build_type: nightly - repo: rapidsai/rmm branch: ${{ inputs.branch }} date: ${{ inputs.date }} sha: ${{ inputs.sha }} @@ -28,7 +27,6 @@ jobs: uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@cuda-118 with: build_type: nightly - repo: rapidsai/rmm branch: ${{ inputs.branch }} date: ${{ inputs.date }} sha: ${{ inputs.sha }} From e324acef5c6b71e6ae89a3ff752b8dfb1ee8673c Mon Sep 17 00:00:00 2001 From: Ashwin Srinath <3190405+shwina@users.noreply.github.com> Date: Thu, 5 Jan 2023 15:47:11 -0500 Subject: [PATCH 200/675] Add RMM PyTorch allocator (#1168) Closes #1144 This PR adds an RMM-based allocator for PyTorch, `rmm.rmm_torch_allocator`. This enables, e.g., using the same memory pool in code that uses both RAPIDS and PyTorch. It also enables PyTorch to use all of the different memory resources provided by RMM. For example: ```python import rmm import torch torch.cuda.memory.change_current_allocator(rmm.rmm_torch_allocator) base_mr = rmm.mr.CudaMemoryResource() def allocate_func(size): print(f"Allocating {size} bytes") return base_mr.allocate(size) def deallocate_func(ptr, size): print(f"Deallocating {size} bytes") return base_mr.deallocate(ptr, size) rmm.mr.set_current_device_resource( rmm.mr.CallbackMemoryResource(allocate_func, deallocate_func) ) x = torch.tensor([1, 2]).cuda() del x y = torch.tensor([1, 2, 3]).cuda() del y ``` Output: ``` Allocating 16 bytes Deallocating 16 bytes Allocating 24 bytes Deallocating 24 bytes ``` Authors: - Ashwin Srinath (https://github.com/shwina) Approvers: - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1168 --- README.md | 47 +++++++++++++++++++++++++ python/rmm/__init__.py | 1 + python/rmm/_lib/CMakeLists.txt | 3 +- python/rmm/_lib/memory_resource.pxd | 8 +++++ python/rmm/_lib/memory_resource.pyx | 29 +++------------ python/rmm/_lib/per_device_resource.pxd | 23 ++++++++++++ python/rmm/_lib/torch_allocator.pyx | 24 +++++++++++++ python/rmm/rmm.py | 15 ++++++++ python/rmm/tests/conftest.py | 21 +++++++++++ python/rmm/tests/test_rmm.py | 29 ++++----------- python/rmm/tests/test_rmm_pytorch.py | 37 +++++++++++++++++++ 11 files changed, 189 insertions(+), 48 deletions(-) create mode 100644 python/rmm/_lib/per_device_resource.pxd create mode 100644 python/rmm/_lib/torch_allocator.pyx create mode 100644 python/rmm/tests/conftest.py create mode 100644 python/rmm/tests/test_rmm_pytorch.py diff --git a/README.md b/README.md index 369d7c54b..5905160af 100644 --- a/README.md +++ b/README.md @@ -732,3 +732,50 @@ This can be done in two ways: **Note:** This only configures Numba to use the current RMM resource for allocations. It does not initialize nor change the current resource, e.g., enabling a memory pool. See [here](#memoryresource-objects) for more information on changing the current memory resource. + +### Using RMM with PyTorch + +[PyTorch](https://pytorch.org/docs/stable/notes/cuda.html) can use RMM +for memory allocation. For example, to configure PyTorch to use an +RMM-managed pool: + +```python +import rmm +import torch + +rmm.reinitialize(pool_allocator=True) +torch.cuda.memory.change_current_allocator(rmm.rmm_torch_allocator) +``` + +PyTorch and RMM will now share the same memory pool. + +You can, of course, use a custom memory resource with PyTorch as well: + +```python +import rmm +import torch + +# note that you can configure PyTorch to use RMM either before or +# after changing RMM's memory resource. PyTorch will use whatever +# memory resource is configured to be the "current" memory resource at +# the time of allocation. +torch.cuda.change_current_allocator(rmm.rmm_torch_allocator) + +# configure RMM to use a managed memory resource, wrapped with a +# statistics resource adaptor that can report information about the +# amount of memory allocated: +mr = rmm.mr.StatisticsResourceAdaptor(rmm.mr.ManagedMemoryResource()) +rmm.mr.set_current_device_resource(mr) + +x = torch.tensor([1, 2]).cuda() + +# the memory resource reports information about PyTorch allocations: +mr.allocation_counts +Out[6]: +{'current_bytes': 16, + 'current_count': 1, + 'peak_bytes': 16, + 'peak_count': 1, + 'total_bytes': 16, + 'total_count': 1} +``` diff --git a/python/rmm/__init__.py b/python/rmm/__init__.py index acdeb93a8..9fb13fe73 100644 --- a/python/rmm/__init__.py +++ b/python/rmm/__init__.py @@ -25,6 +25,7 @@ register_reinitialize_hook, reinitialize, rmm_cupy_allocator, + rmm_torch_allocator, unregister_reinitialize_hook, ) diff --git a/python/rmm/_lib/CMakeLists.txt b/python/rmm/_lib/CMakeLists.txt index 44f4513b2..9e90d7e99 100644 --- a/python/rmm/_lib/CMakeLists.txt +++ b/python/rmm/_lib/CMakeLists.txt @@ -12,7 +12,8 @@ # the License. # ============================================================================= -set(cython_sources device_buffer.pyx lib.pyx memory_resource.pyx cuda_stream.pyx) +set(cython_sources device_buffer.pyx lib.pyx memory_resource.pyx cuda_stream.pyx + torch_allocator.pyx) set(linked_libraries rmm::rmm) # Build all of the Cython targets diff --git a/python/rmm/_lib/memory_resource.pxd b/python/rmm/_lib/memory_resource.pxd index 387d39866..5bb3746bc 100644 --- a/python/rmm/_lib/memory_resource.pxd +++ b/python/rmm/_lib/memory_resource.pxd @@ -17,12 +17,20 @@ from libcpp.memory cimport shared_ptr from libcpp.string cimport string from libcpp.vector cimport vector +from rmm._lib.cuda_stream_view cimport cuda_stream_view + cdef extern from "rmm/mr/device/device_memory_resource.hpp" \ namespace "rmm::mr" nogil: cdef cppclass device_memory_resource: void* allocate(size_t bytes) except + + void* allocate(size_t bytes, cuda_stream_view stream) except + void deallocate(void* ptr, size_t bytes) except + + void deallocate( + void* ptr, + size_t bytes, + cuda_stream_view stream + ) except + cdef class DeviceMemoryResource: cdef shared_ptr[device_memory_resource] c_obj diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 854e14d8c..774db374a 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -29,6 +29,10 @@ from cuda.cudart import cudaError_t from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice from rmm._lib.cuda_stream_view cimport cuda_stream_view +from rmm._lib.per_device_resource cimport ( + cuda_device_id, + set_per_device_resource as cpp_set_per_device_resource, +) # Transparent handle of a C++ exception ctypedef pair[int, string] CppExcept @@ -206,29 +210,6 @@ cdef extern from "rmm/mr/device/failure_callback_resource_adaptor.hpp" \ ) except + -cdef extern from "rmm/mr/device/per_device_resource.hpp" namespace "rmm" nogil: - - cdef cppclass cuda_device_id: - ctypedef int value_type - - cuda_device_id(value_type id) - - value_type value() - - cdef device_memory_resource* _set_current_device_resource \ - "rmm::mr::set_current_device_resource" (device_memory_resource* new_mr) - cdef device_memory_resource* _get_current_device_resource \ - "rmm::mr::get_current_device_resource" () - - cdef device_memory_resource* _set_per_device_resource \ - "rmm::mr::set_per_device_resource" ( - cuda_device_id id, - device_memory_resource* new_mr - ) - cdef device_memory_resource* _get_per_device_resource \ - "rmm::mr::get_per_device_resource"(cuda_device_id id) - - cdef class DeviceMemoryResource: cdef device_memory_resource* get_mr(self): @@ -967,7 +948,7 @@ cpdef set_per_device_resource(int device, DeviceMemoryResource mr): cdef unique_ptr[cuda_device_id] device_id = \ make_unique[cuda_device_id](device) - _set_per_device_resource(deref(device_id), mr.get_mr()) + cpp_set_per_device_resource(deref(device_id), mr.get_mr()) cpdef set_current_device_resource(DeviceMemoryResource mr): diff --git a/python/rmm/_lib/per_device_resource.pxd b/python/rmm/_lib/per_device_resource.pxd new file mode 100644 index 000000000..c33217622 --- /dev/null +++ b/python/rmm/_lib/per_device_resource.pxd @@ -0,0 +1,23 @@ +from rmm._lib.memory_resource cimport device_memory_resource + + +cdef extern from "rmm/mr/device/per_device_resource.hpp" namespace "rmm" nogil: + cdef cppclass cuda_device_id: + ctypedef int value_type + + cuda_device_id(value_type id) + + value_type value() + +cdef extern from "rmm/mr/device/per_device_resource.hpp" \ + namespace "rmm::mr" nogil: + cdef device_memory_resource* set_current_device_resource( + device_memory_resource* new_mr + ) + cdef device_memory_resource* get_current_device_resource() + cdef device_memory_resource* set_per_device_resource( + cuda_device_id id, device_memory_resource* new_mr + ) + cdef device_memory_resource* get_per_device_resource ( + cuda_device_id id + ) diff --git a/python/rmm/_lib/torch_allocator.pyx b/python/rmm/_lib/torch_allocator.pyx new file mode 100644 index 000000000..12dc9fe11 --- /dev/null +++ b/python/rmm/_lib/torch_allocator.pyx @@ -0,0 +1,24 @@ +from cuda.ccudart cimport cudaStream_t + +from rmm._lib.cuda_stream_view cimport cuda_stream_view +from rmm._lib.memory_resource cimport device_memory_resource +from rmm._lib.per_device_resource cimport get_current_device_resource + + +cdef public void* allocate( + ssize_t size, int device, void* stream +) except * with gil: + cdef device_memory_resource* mr = get_current_device_resource() + cdef cuda_stream_view stream_view = cuda_stream_view( + (stream) + ) + return mr[0].allocate(size, stream_view) + +cdef public void deallocate( + void* ptr, ssize_t size, void* stream +) except * with gil: + cdef device_memory_resource* mr = get_current_device_resource() + cdef cuda_stream_view stream_view = cuda_stream_view( + (stream) + ) + mr[0].deallocate(ptr, size, stream_view) diff --git a/python/rmm/rmm.py b/python/rmm/rmm.py index 398d83de3..cae9971dc 100644 --- a/python/rmm/rmm.py +++ b/python/rmm/rmm.py @@ -237,6 +237,21 @@ def rmm_cupy_allocator(nbytes): return ptr +try: + from torch.cuda.memory import CUDAPluggableAllocator +except ImportError: + rmm_torch_allocator = None +else: + import rmm._lib.torch_allocator + + _alloc_free_lib_path = rmm._lib.torch_allocator.__file__ + rmm_torch_allocator = CUDAPluggableAllocator( + _alloc_free_lib_path, + alloc_fn_name="allocate", + free_fn_name="deallocate", + ) + + def register_reinitialize_hook(func, *args, **kwargs): """ Add a function to the list of functions ("hooks") that will be diff --git a/python/rmm/tests/conftest.py b/python/rmm/tests/conftest.py new file mode 100644 index 000000000..5fad81c79 --- /dev/null +++ b/python/rmm/tests/conftest.py @@ -0,0 +1,21 @@ +import pytest + +import rmm + + +@pytest.fixture(scope="function", autouse=True) +def rmm_auto_reinitialize(): + # Run the test + yield + + # Automatically reinitialize the current memory resource after running each + # test + + rmm.reinitialize() + + +@pytest.fixture +def stats_mr(): + mr = rmm.mr.StatisticsResourceAdaptor(rmm.mr.CudaMemoryResource()) + rmm.mr.set_current_device_resource(mr) + return mr diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index 89d67a9c4..f79c60b43 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -42,17 +42,6 @@ ) -@pytest.fixture(scope="function", autouse=True) -def rmm_auto_reinitialize(): - - # Run the test - yield - - # Automatically reinitialize the current memory resource after running each - # test - rmm.reinitialize() - - def array_tester(dtype, nelem, alloc): # data h_in = np.full(nelem, 3.2, dtype) @@ -604,20 +593,14 @@ def test_cuda_async_memory_resource_threshold(nelem, alloc): array_tester("u1", 2 * nelem, alloc) # should trigger release -def test_statistics_resource_adaptor(): - - cuda_mr = rmm.mr.CudaMemoryResource() - - mr = rmm.mr.StatisticsResourceAdaptor(cuda_mr) - - rmm.mr.set_current_device_resource(mr) +def test_statistics_resource_adaptor(stats_mr): buffers = [rmm.DeviceBuffer(size=1000) for _ in range(10)] for i in range(9, 0, -2): del buffers[i] - assert mr.allocation_counts == { + assert stats_mr.allocation_counts == { "current_bytes": 5000, "current_count": 5, "peak_bytes": 10000, @@ -627,7 +610,7 @@ def test_statistics_resource_adaptor(): } # Push a new Tracking adaptor - mr2 = rmm.mr.StatisticsResourceAdaptor(mr) + mr2 = rmm.mr.StatisticsResourceAdaptor(stats_mr) rmm.mr.set_current_device_resource(mr2) for _ in range(2): @@ -641,7 +624,7 @@ def test_statistics_resource_adaptor(): "total_bytes": 2000, "total_count": 2, } - assert mr.allocation_counts == { + assert stats_mr.allocation_counts == { "current_bytes": 7000, "current_count": 7, "peak_bytes": 10000, @@ -661,7 +644,7 @@ def test_statistics_resource_adaptor(): "total_bytes": 2000, "total_count": 2, } - assert mr.allocation_counts == { + assert stats_mr.allocation_counts == { "current_bytes": 0, "current_count": 0, "peak_bytes": 10000, @@ -669,10 +652,10 @@ def test_statistics_resource_adaptor(): "total_bytes": 12000, "total_count": 12, } + gc.collect() def test_tracking_resource_adaptor(): - cuda_mr = rmm.mr.CudaMemoryResource() mr = rmm.mr.TrackingResourceAdaptor(cuda_mr, capture_stacks=True) diff --git a/python/rmm/tests/test_rmm_pytorch.py b/python/rmm/tests/test_rmm_pytorch.py new file mode 100644 index 000000000..eaa40c0ed --- /dev/null +++ b/python/rmm/tests/test_rmm_pytorch.py @@ -0,0 +1,37 @@ +import gc + +import pytest + +import rmm + +torch = pytest.importorskip("torch") + + +@pytest.fixture(scope="session") +def torch_allocator(): + try: + from torch.cuda.memory import change_current_allocator + except ImportError: + pytest.skip("pytorch pluggable allocator not available") + change_current_allocator(rmm.rmm_torch_allocator) + + +def test_rmm_torch_allocator(torch_allocator, stats_mr): + assert stats_mr.allocation_counts["current_bytes"] == 0 + x = torch.tensor([1, 2]).cuda() + assert stats_mr.allocation_counts["current_bytes"] > 0 + del x + gc.collect() + assert stats_mr.allocation_counts["current_bytes"] == 0 + + +def test_rmm_torch_allocator_using_stream(torch_allocator, stats_mr): + assert stats_mr.allocation_counts["current_bytes"] == 0 + s = torch.cuda.Stream() + with torch.cuda.stream(s): + x = torch.tensor([1, 2]).cuda() + torch.cuda.current_stream().wait_stream(s) + assert stats_mr.allocation_counts["current_bytes"] > 0 + del x + gc.collect() + assert stats_mr.allocation_counts["current_bytes"] == 0 From 0c1650711a284dadc0fd3cf2e720a62252378c4c Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 5 Jan 2023 17:26:42 -0600 Subject: [PATCH 201/675] Add support for Python 3.10. (#1166) This PR adds support for Python 3.10. This set of changes aligns with the behavior I'd like to see across RAPIDS for the Python version changes described in RAPIDS Support Notice (RSN) 22 and 23. https://github.com/rapidsai/docs/pull/310 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1166 --- README.md | 2 +- python/setup.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5905160af..2f6d54a64 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ conda install -c rapidsai -c conda-forge -c nvidia \ We also provide [nightly Conda packages](https://anaconda.org/rapidsai-nightly) built from the HEAD of our latest development branch. -Note: RMM is supported only on Linux, and only tested with Python versions 3.8 and 3.9. +Note: RMM is supported only on Linux, and only tested with Python versions 3.8 and 3.10. Note: The RMM package from Conda requires building with GCC 9 or later. Otherwise, your application may fail to build. diff --git a/python/setup.py b/python/setup.py index ee8fb9e5f..2adcf53b1 100644 --- a/python/setup.py +++ b/python/setup.py @@ -33,6 +33,7 @@ def get_versions(): "Programming Language :: Python", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", ], # Include the separately-compiled shared library extras_require={"test": ["pytest"]}, From 3732b31e8895ac010a284054dcce254ddec14020 Mon Sep 17 00:00:00 2001 From: Sevag H Date: Fri, 6 Jan 2023 18:28:27 -0500 Subject: [PATCH 202/675] Build wheels alongside conda CI (#1182) * Build wheels alongside conda CI * Remove package-dir param from wheel test/publish * wheel-publish needs wheel-build * Adjust versioneer-override param name * Add smoketest for abbreviated arm PR CI * make wheel builds depend on `checks` * Address PR feedback * Removed some wheel parameters Co-authored-by: AJ Schmidt Co-authored-by: AJ Schmidt --- .github/workflows/build.yaml | 23 ++++++++++++++++ .github/workflows/pr.yaml | 20 ++++++++++++++ .github/workflows/test.yaml | 11 ++++++++ .github/workflows/wheels.yml | 52 ------------------------------------ ci/wheel_smoke_test.py | 5 ++++ 5 files changed, 59 insertions(+), 52 deletions(-) delete mode 100644 .github/workflows/wheels.yml create mode 100644 ci/wheel_smoke_test.py diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d7e81bcd3..732aae51a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -52,3 +52,26 @@ jobs: branch: ${{ inputs.branch }} date: ${{ inputs.date }} sha: ${{ inputs.sha }} + wheel-build: + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@main + with: + build_type: ${{ inputs.build_type || 'branch' }} + repo: rapidsai/rmm + branch: ${{ inputs.branch }} + sha: ${{ inputs.sha }} + date: ${{ inputs.date }} + package-name: rmm + package-dir: python + skbuild-configure-options: "-DRMM_BUILD_WHEELS=ON" + wheel-publish: + needs: wheel-build + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@main + with: + build_type: ${{ inputs.build_type || 'branch' }} + repo: rapidsai/rmm + branch: ${{ inputs.branch }} + sha: ${{ inputs.sha }} + date: ${{ inputs.date }} + package-name: rmm diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index be1c89255..07b234dda 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -17,6 +17,8 @@ jobs: - conda-cpp-tests - conda-python-build - conda-python-tests + - wheel-build + - wheel-tests secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@cuda-118 checks: @@ -46,3 +48,21 @@ jobs: uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@cuda-118 with: build_type: pull-request + wheel-build: + needs: checks + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@main + with: + build_type: pull-request + package-dir: python + package-name: rmm + skbuild-configure-options: "-DRMM_BUILD_WHEELS=ON" + wheel-tests: + needs: wheel-build + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@main + with: + build_type: pull-request + package-name: rmm + test-unittest: "python -m pytest -v ./python/rmm/tests" + test-smoketest: "python ./ci/wheel_smoke_test.py" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c0961b587..49dd78071 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -30,3 +30,14 @@ jobs: branch: ${{ inputs.branch }} date: ${{ inputs.date }} sha: ${{ inputs.sha }} + wheel-tests: + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@main + with: + build_type: nightly + repo: rapidsai/rmm + branch: ${{ inputs.branch }} + date: ${{ inputs.date }} + sha: ${{ inputs.sha }} + package-name: rmm + test-unittest: "python -m pytest -v ./python/rmm/tests" diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml deleted file mode 100644 index abbe4f682..000000000 --- a/.github/workflows/wheels.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: RMM wheels - -on: - workflow_call: - inputs: - versioneer-override: - type: string - default: '' - build-tag: - type: string - default: '' - branch: - required: true - type: string - date: - required: true - type: string - sha: - required: true - type: string - build-type: - type: string - default: nightly - -concurrency: - # Hardcode rmm rather than using github.repository to support calling this - # from other workflows that build multiple wheels. - group: "rmm-${{ github.workflow }}-${{ github.ref }}" - cancel-in-progress: true - -jobs: - rmm-wheels: - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux.yml@main - with: - repo: rapidsai/rmm - - build-type: ${{ inputs.build-type }} - branch: ${{ inputs.branch }} - sha: ${{ inputs.sha }} - date: ${{ inputs.date }} - - package-dir: python - package-name: rmm - - python-package-versioneer-override: ${{ inputs.versioneer-override }} - python-package-build-tag: ${{ inputs.build-tag }} - - skbuild-configure-options: "-DRMM_BUILD_WHEELS=ON" - - test-extras: test - test-unittest: "python -m pytest -v ./python/rmm/tests" - secrets: inherit diff --git a/ci/wheel_smoke_test.py b/ci/wheel_smoke_test.py new file mode 100644 index 000000000..737c0b605 --- /dev/null +++ b/ci/wheel_smoke_test.py @@ -0,0 +1,5 @@ +import rmm + +if __name__ == "__main__": + buf = rmm.DeviceBuffer(size=100) + assert buf.size == 100 From 4e6716d2e1400c9fd6879a50c01d7793a3f1ada0 Mon Sep 17 00:00:00 2001 From: Sevag H Date: Mon, 9 Jan 2023 16:22:32 -0500 Subject: [PATCH 203/675] Upkeep/wheel param cleanup (#1187) An unnecessary parameter (`repo: rapidsai/rmm`) was left behind after the wheel PR was merged in #1182 This PR cleans it up Authors: - Sevag H (https://github.com/sevagh) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1187 --- .github/workflows/build.yaml | 2 -- .github/workflows/test.yaml | 1 - 2 files changed, 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 732aae51a..744d34dbd 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -57,7 +57,6 @@ jobs: uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@main with: build_type: ${{ inputs.build_type || 'branch' }} - repo: rapidsai/rmm branch: ${{ inputs.branch }} sha: ${{ inputs.sha }} date: ${{ inputs.date }} @@ -70,7 +69,6 @@ jobs: uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@main with: build_type: ${{ inputs.build_type || 'branch' }} - repo: rapidsai/rmm branch: ${{ inputs.branch }} sha: ${{ inputs.sha }} date: ${{ inputs.date }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 49dd78071..657c31949 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -35,7 +35,6 @@ jobs: uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@main with: build_type: nightly - repo: rapidsai/rmm branch: ${{ inputs.branch }} date: ${{ inputs.date }} sha: ${{ inputs.sha }} From 2075541841bff857d01d98b40f7a8f03705fbf32 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 11 Jan 2023 09:00:55 -0600 Subject: [PATCH 204/675] Fix documentation author (#1188) Fixes docs to mark NVIDIA as the author. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) URL: https://github.com/rapidsai/rmm/pull/1188 --- python/docs/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/docs/conf.py b/python/docs/conf.py index 955ef1847..ec5ba5b61 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -15,7 +15,7 @@ # -- Project information ----------------------------------------------------- project = "rmm" -copyright = "2020-2022, NVIDIA" +copyright = "2020-2023, NVIDIA" author = "NVIDIA" # The version info for the project you're documenting, acts as replacement for @@ -147,7 +147,7 @@ master_doc, "rmm.tex", "RMM Documentation", - "Continuum Analytics", + "NVIDIA Corporation", "manual", ) ] From 28ca7a68f2b4f08a09f3c3f3be3e616583bab468 Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Wed, 18 Jan 2023 12:28:39 -0600 Subject: [PATCH 205/675] add docs_build step (#1189) The PR adds a `docs_build` process to the PR and Build workflows for this repository. The generated docs are synced to s3 for only the build workflows. Authors: - Jake Awe (https://github.com/AyodeAwe) - Bradley Dice (https://github.com/bdice) Approvers: - Bradley Dice (https://github.com/bdice) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1189 --- .github/workflows/build.yaml | 11 +++++++++ .github/workflows/pr.yaml | 11 +++++++++ ci/build_docs.sh | 45 ++++++++++++++++++++++++++++++++++++ ci/test_cpp.sh | 2 +- ci/test_python.sh | 4 ++-- dependencies.yaml | 19 +++++++++++++++ doxygen/Doxyfile | 3 +-- 7 files changed, 90 insertions(+), 5 deletions(-) create mode 100755 ci/build_docs.sh diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 744d34dbd..cac1e8a29 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -52,6 +52,17 @@ jobs: branch: ${{ inputs.branch }} date: ${{ inputs.date }} sha: ${{ inputs.sha }} + docs-build: + if: ${{ startsWith(github.ref, 'refs/heads/branch-') }} + needs: python-build + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@cuda-118 + with: + build_type: pull-request + node_type: "gpu-latest-1" + arch: "amd64" + container_image: "rapidsai/ci:latest" + run_script: "ci/build_docs.sh" wheel-build: secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@main diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 07b234dda..5b20e2dd0 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -17,6 +17,7 @@ jobs: - conda-cpp-tests - conda-python-build - conda-python-tests + - docs-build - wheel-build - wheel-tests secrets: inherit @@ -48,6 +49,16 @@ jobs: uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@cuda-118 with: build_type: pull-request + docs-build: + needs: conda-python-build + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@cuda-118 + with: + build_type: pull-request + node_type: "gpu-latest-1" + arch: "amd64" + container_image: "rapidsai/ci:latest" + run_script: "ci/build_docs.sh" wheel-build: needs: checks secrets: inherit diff --git a/ci/build_docs.sh b/ci/build_docs.sh new file mode 100755 index 000000000..d5b6bfa86 --- /dev/null +++ b/ci/build_docs.sh @@ -0,0 +1,45 @@ +#!/bin/bash +set -euo pipefail + +rapids-logger "Create test conda environment" +. /opt/conda/etc/profile.d/conda.sh + +rapids-dependency-file-generator \ + --output conda \ + --file_key docs \ + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee env.yaml + +rapids-mamba-retry env create --force -f env.yaml -n docs +conda activate docs + +rapids-print-env + +rapids-logger "Downloading artifacts from previous jobs" +CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) +PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) +VERSION_NUMBER=$(rapids-get-rapids-version-from-git) + +rapids-mamba-retry install \ + --channel "${CPP_CHANNEL}" \ + --channel "${PYTHON_CHANNEL}" \ + rmm librmm + +# Build CPP docs +rapids-logger "Build Doxygen docs" +pushd doxygen +doxygen Doxyfile +popd + +# Build Python docs +rapids-logger "Build Python docs" +pushd python/docs +sphinx-build -b dirhtml . _html +sphinx-build -b text . _text +popd + +if [[ "${RAPIDS_BUILD_TYPE}" == "branch" ]]; then + rapids-logger "Upload Docs to S3" + aws s3 sync --delete doxygen/html "s3://rapidsai-docs/librmm/${VERSION_NUMBER}/html" + aws s3 sync --delete python/docs/_html "s3://rapidsai-docs/rmm/${VERSION_NUMBER}/html" + aws s3 sync --delete python/docs/_text "s3://rapidsai-docs/rmm/${VERSION_NUMBER}/txt" +fi diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 3953171d0..257e015fd 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -18,7 +18,7 @@ rapids-print-env CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) rapids-mamba-retry install \ - -c "${CPP_CHANNEL}" \ + --channel "${CPP_CHANNEL}" \ librmm librmm-tests RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"} diff --git a/ci/test_python.sh b/ci/test_python.sh index 511a69337..a8b446ca2 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -20,8 +20,8 @@ CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) rapids-mamba-retry install \ - -c "${CPP_CHANNEL}" \ - -c "${PYTHON_CHANNEL}" \ + --channel "${CPP_CHANNEL}" \ + --channel "${PYTHON_CHANNEL}" \ rmm librmm RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"} diff --git a/dependencies.yaml b/dependencies.yaml index e83e6ddd4..4c7a1f524 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -27,6 +27,12 @@ files: includes: - checks - py_version + docs: + output: none + includes: + - cudatoolkit + - docs + - py_version channels: - rapidsai - conda-forge @@ -78,6 +84,19 @@ dependencies: - output_types: [conda, requirements] packages: - gcovr>=5.0 + docs: + common: + - output_types: [conda] + packages: + - doxygen=1.8.20 + - graphviz + - ipython + - nbsphinx + - numpydoc + - sphinx + - sphinx_rtd_theme + - sphinx-copybutton + - sphinx-markdown-tables py_version: specific: - output_types: conda diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 39649f378..c58a45a8f 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -835,8 +835,7 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = ../src \ - ../include +INPUT = ../include # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses From 8cf4e9975cf82c7962236eb75c16f4f3b6bc96f9 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Wed, 18 Jan 2023 14:32:46 -0500 Subject: [PATCH 206/675] Fix `build.yaml` workflow (#1191) This PR fixes the `build.yaml` workflow so that the correct build type gets passed to the `docs-build` job. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1191 --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index cac1e8a29..e7bc7661e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -58,7 +58,7 @@ jobs: secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@cuda-118 with: - build_type: pull-request + build_type: branch node_type: "gpu-latest-1" arch: "amd64" container_image: "rapidsai/ci:latest" From f733e6f251db08a5baada0f7b88961531f8e502f Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Wed, 18 Jan 2023 14:55:37 -0600 Subject: [PATCH 207/675] Update `build.yaml` workflow to reduce verbosity (#1192) This PR adds the `--only-show-errors` flag to reduce verbose output from the `s3 sync` commands. Authors: - Jake Awe (https://github.com/AyodeAwe) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1192 --- ci/build_docs.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/build_docs.sh b/ci/build_docs.sh index d5b6bfa86..89a85fad2 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -39,7 +39,7 @@ popd if [[ "${RAPIDS_BUILD_TYPE}" == "branch" ]]; then rapids-logger "Upload Docs to S3" - aws s3 sync --delete doxygen/html "s3://rapidsai-docs/librmm/${VERSION_NUMBER}/html" - aws s3 sync --delete python/docs/_html "s3://rapidsai-docs/rmm/${VERSION_NUMBER}/html" - aws s3 sync --delete python/docs/_text "s3://rapidsai-docs/rmm/${VERSION_NUMBER}/txt" + aws s3 sync --no-progress --delete doxygen/html "s3://rapidsai-docs/librmm/${VERSION_NUMBER}/html" + aws s3 sync --no-progress --delete python/docs/_html "s3://rapidsai-docs/rmm/${VERSION_NUMBER}/html" + aws s3 sync --no-progress --delete python/docs/_text "s3://rapidsai-docs/rmm/${VERSION_NUMBER}/txt" fi From 93d86f2732ec420c1d317829835f47efd4613663 Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Mon, 23 Jan 2023 10:34:26 -0500 Subject: [PATCH 208/675] DOC --- CMakeLists.txt | 4 ++-- doxygen/Doxyfile | 2 +- python/CMakeLists.txt | 4 ++-- python/docs/conf.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08f4339a2..4cbb6c09b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.02/RAPIDS.cmake + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.04/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) endif() include(${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) @@ -27,7 +27,7 @@ include(rapids-find) project( RMM - VERSION 23.02.00 + VERSION 23.04.00 LANGUAGES CXX) # Write the version header diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index c58a45a8f..c4192f793 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "RMM" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 23.02 +PROJECT_NUMBER = 23.04 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 1b4d2c5e3..705f40ac7 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -14,9 +14,9 @@ cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) -set(rmm_version 23.02.00) +set(rmm_version 23.04.00) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.02/RAPIDS.cmake +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.04/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) diff --git a/python/docs/conf.py b/python/docs/conf.py index ec5ba5b61..31e3ba44f 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -23,9 +23,9 @@ # built documents. # # The short X.Y version. -version = "23.02" +version = "23.04" # The full version, including alpha/beta/rc tags. -release = "23.02.00" +release = "23.04.00" # -- General configuration --------------------------------------------------- From 7662b2411684079c58a1dc3d43d625b4a683f93f Mon Sep 17 00:00:00 2001 From: Sevag H Date: Tue, 24 Jan 2023 10:15:44 -0500 Subject: [PATCH 209/675] Use CTK 118/cp310 branch of wheel workflows (#1193) This PR builds wheels using the `cuda-118` branch of the workflows, which bumps CTK 11.5.1 to CTK 11.8.0 and cp39 to cp310. Authors: - Sevag H (https://github.com/sevagh) Approvers: - Bradley Dice (https://github.com/bdice) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1193 --- .github/workflows/build.yaml | 4 ++-- .github/workflows/pr.yaml | 4 ++-- .github/workflows/test.yaml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e7bc7661e..b286c3600 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -65,7 +65,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@main + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@cuda-118 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -77,7 +77,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@main + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@cuda-118 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 5b20e2dd0..2aad7e0c7 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -62,7 +62,7 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@main + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@cuda-118 with: build_type: pull-request package-dir: python @@ -71,7 +71,7 @@ jobs: wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@main + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@cuda-118 with: build_type: pull-request package-name: rmm diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 657c31949..098dfb965 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@main + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@cuda-118 with: build_type: nightly branch: ${{ inputs.branch }} From 4e030a05a50d76adfa79f6b7eca59c224ee1f599 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Mon, 30 Jan 2023 22:55:15 +0000 Subject: [PATCH 210/675] pre-commit: Update isort version to 5.12.0 (#1197) poetry version 1.5.0 broke installs of isort prior to 5.11.5 (see pycqa/isort#2077 and pycqa/isort#2078), so we need to upgrade. --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 027ce9857..9d60da84c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort args: ["--config-root=python/", "--resolve-all-configs"] From 66e6890c712404027805afb1280daa6b314cc6e3 Mon Sep 17 00:00:00 2001 From: Ray Douglass <3107146+raydouglass@users.noreply.github.com> Date: Fri, 3 Feb 2023 15:40:20 -0500 Subject: [PATCH 211/675] Fix update-version.sh (#1199) ## Description Fix path for style check script in `update-version.sh` ## Checklist - [x] I am familiar with the [Contributing Guidelines](https://github.com/rapidsai/rmm/blob/HEAD/CONTRIBUTING.md). - [ ] New or existing tests cover these changes. - [ ] The documentation is up to date with these changes. Authors: - Ray Douglass (https://github.com/raydouglass) Approvers: - Jake Awe (https://github.com/AyodeAwe) --- ci/release/update-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index b8ee8d2c9..866b7a48b 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -38,7 +38,7 @@ sed_runner 's/'"rmm_version .*)"'/'"rmm_version ${NEXT_FULL_TAG})"'/g' python/CM sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' python/CMakeLists.txt # cmake-format rapids-cmake definitions -sed_runner 's/'"branch-.*\/cmake-format-rapids-cmake.json"'/'"branch-${NEXT_SHORT_TAG}\/cmake-format-rapids-cmake.json"'/g' ci/checks/style.sh +sed_runner 's/'"branch-.*\/cmake-format-rapids-cmake.json"'/'"branch-${NEXT_SHORT_TAG}\/cmake-format-rapids-cmake.json"'/g' ci/check_style.sh # doxyfile update sed_runner 's/'"PROJECT_NUMBER = .*"'/'"PROJECT_NUMBER = ${NEXT_SHORT_TAG}"'/g' doxygen/Doxyfile From 14fe6646ec338031a38f0ebfa1bff39eddc2eac2 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Fri, 3 Feb 2023 17:22:10 -0500 Subject: [PATCH 212/675] update workflow branches [skip ci] (#1201) This PR updates the branch reference used for our shared workflows. I will open similar PRs for `branch-23.04` next week. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Ray Douglass (https://github.com/raydouglass) --- .github/workflows/build.yaml | 12 ++++++------ .github/workflows/pr.yaml | 18 +++++++++--------- .github/workflows/test.yaml | 6 +++--- ci/release/update-version.sh | 4 ++++ 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b286c3600..623ade564 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: ${{ startsWith(github.ref, 'refs/heads/branch-') }} needs: python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.02 with: build_type: branch node_type: "gpu-latest-1" @@ -65,7 +65,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -77,7 +77,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@branch-23.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 2aad7e0c7..946dd4270 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -21,38 +21,38 @@ jobs: - wheel-build - wheel-tests secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.02 checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.02 conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.02 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.02 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.02 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.02 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.02 with: build_type: pull-request node_type: "gpu-latest-1" @@ -62,7 +62,7 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.02 with: build_type: pull-request package-dir: python @@ -71,7 +71,7 @@ jobs: wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.02 with: build_type: pull-request package-name: rmm diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 098dfb965..803816df9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.02 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.02 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@cuda-118 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.02 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 866b7a48b..257a013b9 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -46,3 +46,7 @@ sed_runner 's/'"PROJECT_NUMBER = .*"'/'"PROJECT_NUMBER = ${NEXT_ # sphinx docs update sed_runner 's/'"version =.*"'/'"version = \"${NEXT_SHORT_TAG}\""'/g' python/docs/conf.py sed_runner 's/'"release =.*"'/'"release = \"${NEXT_FULL_TAG}\""'/g' python/docs/conf.py + +for FILE in .github/workflows/*.yaml; do + sed_runner "/shared-action-workflows/ s/@.*/@branch-${NEXT_SHORT_TAG}/g" "${FILE}" +done From 421880002a1d94bdde7ea43e155d5f8dc0fa9648 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 6 Feb 2023 11:59:21 -0600 Subject: [PATCH 213/675] Use date in build string instead of in the version. (#1195) Moves date information from the version to the build string. This will help with installing PR artifacts and nightly builds locally and in downstream CI workflows. cc: @ajschmidt8 Authors: - Bradley Dice (https://github.com/bdice) - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1195 --- conda/recipes/librmm/meta.yaml | 9 +++++---- conda/recipes/rmm/meta.yaml | 7 ++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 720cf97c4..61174c7b7 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -1,9 +1,10 @@ -# Copyright (c) 2018-2022, NVIDIA CORPORATION. +# Copyright (c) 2018-2023, NVIDIA CORPORATION. -{% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} +{% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') %} {% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} {% set cuda_major = cuda_version.split('.')[0] %} {% set cuda_spec = ">=" + cuda_major ~ ",<" + (cuda_major | int + 1) ~ ".0a0" %} # i.e. >=11,<12.0a0 +{% set date_string = environ['RAPIDS_DATE_STRING'] %} package: name: librmm-split @@ -43,7 +44,7 @@ outputs: script: install_librmm.sh build: number: {{ GIT_DESCRIBE_NUMBER }} - string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + string: cuda{{ cuda_major }}_{{ date_string }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} run_exports: - {{ pin_subpackage("librmm", max_pin="x.x") }} ignore_run_exports_from: @@ -97,7 +98,7 @@ outputs: script: install_librmm_tests.sh build: number: {{ GIT_DESCRIBE_NUMBER }} - string: cuda{{ cuda_major }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + string: cuda{{ cuda_major }}_{{ date_string }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} ignore_run_exports_from: - {{ compiler('cuda') }} requirements: diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 18f6011e5..7cf116dc0 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -1,9 +1,10 @@ -# Copyright (c) 2019-2022, NVIDIA CORPORATION. +# Copyright (c) 2019-2023, NVIDIA CORPORATION. -{% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} +{% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') %} {% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} {% set cuda_major = cuda_version.split('.')[0] %} {% set py_version = environ['CONDA_PY'] %} +{% set date_string = environ['RAPIDS_DATE_STRING'] %} package: name: rmm @@ -14,7 +15,7 @@ source: build: number: {{ GIT_DESCRIBE_NUMBER }} - string: cuda{{ cuda_major }}_py{{ py_version }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + string: cuda{{ cuda_major }}_py{{ py_version }}_{{ date_string }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} script_env: - CMAKE_GENERATOR - CMAKE_C_COMPILER_LAUNCHER From 1b6eaafa9e048bfd63f4ffe8b0e451883e77775f Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Wed, 8 Feb 2023 10:48:44 -0500 Subject: [PATCH 214/675] Update shared workflow branches (#1203) This PR updates the branch reference used for our shared workflows. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1203 --- .github/workflows/build.yaml | 12 ++++++------ .github/workflows/pr.yaml | 18 +++++++++--------- .github/workflows/test.yaml | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 623ade564..ef346a186 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: ${{ startsWith(github.ref, 'refs/heads/branch-') }} needs: python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.04 with: build_type: branch node_type: "gpu-latest-1" @@ -65,7 +65,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -77,7 +77,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@branch-23.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 946dd4270..d8f0b0d3c 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -21,38 +21,38 @@ jobs: - wheel-build - wheel-tests secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.04 checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.04 conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.04 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.04 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.04 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.04 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.04 with: build_type: pull-request node_type: "gpu-latest-1" @@ -62,7 +62,7 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.04 with: build_type: pull-request package-dir: python @@ -71,7 +71,7 @@ jobs: wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.04 with: build_type: pull-request package-name: rmm diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 803816df9..f4ef540fe 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.04 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.04 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.02 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.04 with: build_type: nightly branch: ${{ inputs.branch }} From 91d5cbdc70121c8e1d4f71bf4b9401613b855cb6 Mon Sep 17 00:00:00 2001 From: Ajay Thorve Date: Wed, 8 Feb 2023 13:17:51 -0800 Subject: [PATCH 215/675] Reduce error handling verbosity in CI tests scripts (#1204) This PR adds a less verbose [trap method](https://github.com/rapidsai/cugraph/blob/f2b081075704aabc789603e14ce552eac3fbe692/ci/test.sh#L19), for error handling to help ensure that we capture all potential error codes in our test scripts, and works as follows: - setting an environment variable, EXITCODE, with a default value of 0 - setting a trap statement triggered by ERR signals which will set EXITCODE=1 when any commands return a non-zero exit code cc @ajschmidt8 Authors: - Ajay Thorve (https://github.com/AjayThorve) - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1204 --- ci/build_cpp.sh | 1 + ci/build_docs.sh | 2 ++ ci/build_python.sh | 1 + ci/check_style.sh | 2 +- ci/test_cpp.sh | 13 +++++-------- ci/test_python.sh | 14 +++++--------- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 6f8a1375c..bc6e18021 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -1,4 +1,5 @@ #!/bin/bash +# Copyright (c) 2020-2023, NVIDIA CORPORATION. set -euo pipefail diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 89a85fad2..dc7d54493 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -1,4 +1,6 @@ #!/bin/bash +# Copyright (c) 2020-2023, NVIDIA CORPORATION. + set -euo pipefail rapids-logger "Create test conda environment" diff --git a/ci/build_python.sh b/ci/build_python.sh index ae4294cc5..b306d3e47 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -1,4 +1,5 @@ #!/bin/bash +# Copyright (c) 2020-2023, NVIDIA CORPORATION. set -euo pipefail diff --git a/ci/check_style.sh b/ci/check_style.sh index 66f961d41..82715f5ff 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2023, NVIDIA CORPORATION. set -euo pipefail diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 257e015fd..46022f8f2 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -1,5 +1,5 @@ #!/bin/bash - +# Copyright (c) 2020-2023, NVIDIA CORPORATION. set -euo pipefail . /opt/conda/etc/profile.d/conda.sh @@ -23,21 +23,18 @@ rapids-mamba-retry install \ RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"} mkdir -p "${RAPIDS_TESTS_DIR}" -SUITEERROR=0 rapids-logger "Check GPU usage" nvidia-smi +EXITCODE=0 +trap "EXITCODE=1" ERR set +e rapids-logger "Running googletests" for gt in "$CONDA_PREFIX/bin/gtests/librmm/"* ; do ${gt} --gtest_output=xml:${RAPIDS_TESTS_DIR}/ - exitcode=$? - if (( ${exitcode} != 0 )); then - SUITEERROR=${exitcode} - echo "FAILED: GTest ${gt}" - fi done -exit ${SUITEERROR} +rapids-logger "Test script exiting with value: $EXITCODE" +exit ${EXITCODE} diff --git a/ci/test_python.sh b/ci/test_python.sh index a8b446ca2..d8c1fdbce 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -1,5 +1,5 @@ #!/bin/bash - +# Copyright (c) 2020-2023, NVIDIA CORPORATION. set -euo pipefail rapids-logger "Create test conda environment" @@ -27,13 +27,14 @@ rapids-mamba-retry install \ RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"} RAPIDS_COVERAGE_DIR=${RAPIDS_COVERAGE_DIR:-"${PWD}/coverage-results"} mkdir -p "${RAPIDS_TESTS_DIR}" "${RAPIDS_COVERAGE_DIR}" -SUITEERROR=0 rapids-logger "Check GPU usage" nvidia-smi cd python +EXITCODE=0 +trap "EXITCODE=1" ERR set +e rapids-logger "pytest rmm" @@ -46,10 +47,5 @@ pytest \ --cov-report=xml:"${RAPIDS_COVERAGE_DIR}/rmm-coverage.xml" \ --cov-report term -exitcode=$? -if (( ${exitcode} != 0 )); then - SUITEERROR=${exitcode} - echo "FAILED: 1 or more tests in /rmm/python" -fi - -exit ${SUITEERROR} +rapids-logger "Test script exiting with value: $EXITCODE" +exit ${EXITCODE} From b835677e07e407bae18a85d7857bced54470c6b1 Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Thu, 9 Feb 2023 10:07:17 -0500 Subject: [PATCH 216/675] update changelog --- CHANGELOG.md | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b7a11963..efd534515 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,37 @@ -# RMM 23.02.00 (Date TBD) +# RMM 23.02.00 (9 Feb 2023) -Please see https://github.com/rapidsai/rmm/releases/tag/v23.02.00a for the latest changes to this development branch. +## 🐛 Bug Fixes + +- pre-commit: Update isort version to 5.12.0 ([#1197](https://github.com/rapidsai/rmm/pull/1197)) [@wence-](https://github.com/wence-) +- Revert "Upgrade to spdlog 1.10 ([#1173)" (#1176](https://github.com/rapidsai/rmm/pull/1173)" (#1176)) [@bdice](https://github.com/bdice) +- Ensure `UpstreamResourceAdaptor` is not cleared by the Python GC ([#1170](https://github.com/rapidsai/rmm/pull/1170)) [@shwina](https://github.com/shwina) + +## 📖 Documentation + +- Fix documentation author ([#1188](https://github.com/rapidsai/rmm/pull/1188)) [@bdice](https://github.com/bdice) + +## 🚀 New Features + +- Add RMM PyTorch allocator ([#1168](https://github.com/rapidsai/rmm/pull/1168)) [@shwina](https://github.com/shwina) + +## 🛠️ Improvements + +- Update shared workflow branches ([#1201](https://github.com/rapidsai/rmm/pull/1201)) [@ajschmidt8](https://github.com/ajschmidt8) +- Fix update-version.sh ([#1199](https://github.com/rapidsai/rmm/pull/1199)) [@raydouglass](https://github.com/raydouglass) +- Use CTK 118/cp310 branch of wheel workflows ([#1193](https://github.com/rapidsai/rmm/pull/1193)) [@sevagh](https://github.com/sevagh) +- Update `build.yaml` workflow to reduce verbosity ([#1192](https://github.com/rapidsai/rmm/pull/1192)) [@AyodeAwe](https://github.com/AyodeAwe) +- Fix `build.yaml` workflow ([#1191](https://github.com/rapidsai/rmm/pull/1191)) [@ajschmidt8](https://github.com/ajschmidt8) +- add docs_build step ([#1189](https://github.com/rapidsai/rmm/pull/1189)) [@AyodeAwe](https://github.com/AyodeAwe) +- Upkeep/wheel param cleanup ([#1187](https://github.com/rapidsai/rmm/pull/1187)) [@sevagh](https://github.com/sevagh) +- Update workflows for nightly tests ([#1186](https://github.com/rapidsai/rmm/pull/1186)) [@ajschmidt8](https://github.com/ajschmidt8) +- Build CUDA `11.8` and Python `3.10` Packages ([#1184](https://github.com/rapidsai/rmm/pull/1184)) [@ajschmidt8](https://github.com/ajschmidt8) +- Build wheels alongside conda CI ([#1182](https://github.com/rapidsai/rmm/pull/1182)) [@sevagh](https://github.com/sevagh) +- Update conda recipes. ([#1180](https://github.com/rapidsai/rmm/pull/1180)) [@bdice](https://github.com/bdice) +- Update PR Workflow ([#1174](https://github.com/rapidsai/rmm/pull/1174)) [@ajschmidt8](https://github.com/ajschmidt8) +- Upgrade to spdlog 1.10 ([#1173](https://github.com/rapidsai/rmm/pull/1173)) [@kkraus14](https://github.com/kkraus14) +- Enable `codecov` ([#1171](https://github.com/rapidsai/rmm/pull/1171)) [@ajschmidt8](https://github.com/ajschmidt8) +- Add support for Python 3.10. ([#1166](https://github.com/rapidsai/rmm/pull/1166)) [@bdice](https://github.com/bdice) +- Update pre-commit hooks ([#1154](https://github.com/rapidsai/rmm/pull/1154)) [@bdice](https://github.com/bdice) # RMM 22.12.00 (8 Dec 2022) From db924930a5ffc129a7dd4568d4265e9c360e24b5 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 13 Feb 2023 12:14:59 -0600 Subject: [PATCH 217/675] Update to spdlog>=1.11.0, fmt>=9.1.0. (#1177) Updates to `spdlog>=1.11.0` and `fmt>=9.1.0`. Also resolves some issues with spdlog in the librmm conda packages. Thanks @robertmaynard for helping advise me on this PR. **We need to test this downstream before merging.** Perhaps with cuML or some other library. Authors: - Bradley Dice (https://github.com/bdice) - Keith Kraus (https://github.com/kkraus14) Approvers: - Robert Maynard (https://github.com/robertmaynard) - Mark Harris (https://github.com/harrism) - Keith Kraus (https://github.com/kkraus14) - AJ Schmidt (https://github.com/ajschmidt8) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1177 --- CMakeLists.txt | 8 ++++++- cmake/thirdparty/get_fmt.cmake | 22 +++++++++++++++++++ cmake/thirdparty/get_spdlog.cmake | 4 ++-- .../all_cuda-118_arch-x86_64.yaml | 3 ++- conda/recipes/librmm/conda_build_config.yaml | 5 ++++- conda/recipes/librmm/meta.yaml | 10 ++++++++- dependencies.yaml | 3 ++- include/rmm/logger.hpp | 14 ++++++------ .../rmm/mr/device/arena_memory_resource.hpp | 1 - include/rmm/mr/device/detail/arena.hpp | 4 ++-- .../mr/device/detail/coalescing_free_list.hpp | 6 +++-- .../detail/stream_ordered_memory_resource.hpp | 4 +++- .../mr/device/logging_resource_adaptor.hpp | 3 ++- .../rmm/mr/device/pool_memory_resource.hpp | 4 +++- .../mr/device/tracking_resource_adaptor.hpp | 4 +++- python/CMakeLists.txt | 4 ++++ tests/mr/device/callback_mr_tests.cpp | 4 ++-- 17 files changed, 78 insertions(+), 25 deletions(-) create mode 100644 cmake/thirdparty/get_fmt.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cbb6c09b..b33ef5ad2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2018-2021, NVIDIA CORPORATION. +# Copyright (c) 2018-2023, 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 @@ -14,6 +14,10 @@ cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) +# TODO(keith): REMOVE BEFORE MERGING +set(rapids-cmake-repo "kkraus14/rapids-cmake") +set(rapids-cmake-branch "spdlog_1.11_fmt") + if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.04/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) @@ -58,6 +62,7 @@ rapids_find_package( BUILD_EXPORT_SET rmm-exports INSTALL_EXPORT_SET rmm-exports) rapids_cpm_init() +include(cmake/thirdparty/get_fmt.cmake) include(cmake/thirdparty/get_spdlog.cmake) include(cmake/thirdparty/get_thrust.cmake) @@ -77,6 +82,7 @@ else() endif() target_link_libraries(rmm INTERFACE rmm::Thrust) +target_link_libraries(rmm INTERFACE fmt::fmt-header-only) target_link_libraries(rmm INTERFACE spdlog::spdlog_header_only) target_link_libraries(rmm INTERFACE dl) target_compile_features(rmm INTERFACE cxx_std_17 $) diff --git a/cmake/thirdparty/get_fmt.cmake b/cmake/thirdparty/get_fmt.cmake new file mode 100644 index 000000000..5787fb73f --- /dev/null +++ b/cmake/thirdparty/get_fmt.cmake @@ -0,0 +1,22 @@ +# ============================================================================= +# Copyright (c) 2023, 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. +# ============================================================================= + +# Use CPM to find or clone fmt +function(find_and_configure_fmt) + + include(${rapids-cmake-dir}/cpm/fmt.cmake) + rapids_cpm_fmt(INSTALL_EXPORT_SET rmm-exports BUILD_EXPORT_SET rmm-exports) +endfunction() + +find_and_configure_fmt() diff --git a/cmake/thirdparty/get_spdlog.cmake b/cmake/thirdparty/get_spdlog.cmake index f78ae0262..24bbea89d 100644 --- a/cmake/thirdparty/get_spdlog.cmake +++ b/cmake/thirdparty/get_spdlog.cmake @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-2023, 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 @@ -16,7 +16,7 @@ function(find_and_configure_spdlog) include(${rapids-cmake-dir}/cpm/spdlog.cmake) - rapids_cpm_spdlog(INSTALL_EXPORT_SET rmm-exports) + rapids_cpm_spdlog(FMT_OPTION "EXTERNAL_FMT_HO" INSTALL_EXPORT_SET rmm-exports) rapids_export_package(BUILD spdlog rmm-exports) if(spdlog_ADDED) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index e075564df..499f5dbec 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -8,6 +8,7 @@ dependencies: - cuda-python>=11.7.1,<12.0 - cudatoolkit=11.8 - cython>=0.29,<0.30 +- fmt>=9.1.0,<10 - gcovr>=5.0 - ninja - numba>=0.49 @@ -17,5 +18,5 @@ dependencies: - pytest-cov - python>=3.8,<3.11 - scikit-build>=0.13.1 -- spdlog>=1.8.5,<1.9 +- spdlog>=1.11.0,<1.12 name: all_cuda-118_arch-x86_64 diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index ce0bbeec5..39dec9e5c 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -10,11 +10,14 @@ cuda_compiler: cmake_version: - ">=3.23.1,!=3.25.0" +fmt_version: + - ">=9.1.0,<10" + gtest_version: - "=1.10.0" spdlog_version: - - ">=1.8.5,<1.9" + - ">=1.11.0,<1.12" sysroot_version: - "2.17" diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 61174c7b7..dd3e58b62 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -21,7 +21,14 @@ requirements: - {{ compiler('cuda') }} {{ cuda_version }} - sysroot_{{ target_platform }} {{ sysroot_version }} host: - - cudatoolkit {{ cuda_version }}.* + - cudatoolkit ={{ cuda_version }} + # We require spdlog and fmt (which was devendored from spdlog + # conda-forge packages in 1.11.0) so that the spdlog headers are not + # pulled by CPM and installed as a part of the rmm packages. However, + # building against librmm still requires these headers. They are also + # added as a run requirement via the packages' run_exports. + - fmt {{ fmt_version }} + - spdlog {{ spdlog_version }} build: script_env: @@ -54,6 +61,7 @@ outputs: - cmake {{ cmake_version }} run: - cudatoolkit {{ cuda_spec }} + - fmt {{ fmt_version }} - spdlog {{ spdlog_version }} test: commands: diff --git a/dependencies.yaml b/dependencies.yaml index 4c7a1f524..879892ba3 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -49,7 +49,8 @@ dependencies: - scikit-build>=0.13.1 - output_types: conda packages: - - spdlog>=1.8.5,<1.9 + - fmt>=9.1.0,<10 + - spdlog>=1.11.0,<1.12 checks: common: - output_types: [conda, requirements] diff --git a/include/rmm/logger.hpp b/include/rmm/logger.hpp index 8109eb888..318535a4e 100644 --- a/include/rmm/logger.hpp +++ b/include/rmm/logger.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,12 +16,8 @@ #pragma once -// If using GCC, temporary workaround for older libcudacxx defining _LIBCPP_VERSION -// undefine it before including spdlog, due to fmtlib checking if it is defined -// TODO: remove once libcudacxx is on Github and RAPIDS depends on it -#ifdef __GNUG__ -#undef _LIBCPP_VERSION -#endif +#include +#include #include #include @@ -115,3 +111,7 @@ inline spdlog::logger& logger() #define RMM_LOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(&rmm::logger(), __VA_ARGS__) } // namespace rmm + +template <> +struct fmt::formatter : fmt::ostream_formatter { +}; diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index 1b1043b4a..b007d8f54 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -23,7 +23,6 @@ #include #include -#include #include #include diff --git a/include/rmm/mr/device/detail/arena.hpp b/include/rmm/mr/device/detail/arena.hpp index c0e5df377..493fb6cb1 100644 --- a/include/rmm/mr/device/detail/arena.hpp +++ b/include/rmm/mr/device/detail/arena.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,8 @@ #include +#include #include -#include #include #include diff --git a/include/rmm/mr/device/detail/coalescing_free_list.hpp b/include/rmm/mr/device/detail/coalescing_free_list.hpp index 8c5db7b02..d98ef7968 100644 --- a/include/rmm/mr/device/detail/coalescing_free_list.hpp +++ b/include/rmm/mr/device/detail/coalescing_free_list.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,14 +16,16 @@ #pragma once -#include #include #include +#include + #include #include #include #include +#include #include namespace rmm::mr::detail { diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index 50495cb17..fa53e480a 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,8 @@ #include #include +#include + #include #include diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 60fd0d366..ee887f5b9 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ #include #include +#include #include #include #include diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 60ab60cf4..297b3f864 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,8 @@ #include #include +#include + #include #include diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index fbcb44898..f1996ba01 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,8 @@ #include #include +#include + #include #include #include diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 705f40ac7..8bea660d8 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -16,6 +16,10 @@ cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) set(rmm_version 23.04.00) +# TODO(keith): REMOVE BEFORE MERGING +set(rapids-cmake-repo "kkraus14/rapids-cmake") +set(rapids-cmake-branch "spdlog_1.11_fmt") + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.04/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) diff --git a/tests/mr/device/callback_mr_tests.cpp b/tests/mr/device/callback_mr_tests.cpp index 101a75fc8..95dac93ec 100644 --- a/tests/mr/device/callback_mr_tests.cpp +++ b/tests/mr/device/callback_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ #include -#include +#include #include #include From c9c83abb3c5b8285de98aad9c0ebe4f988015029 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 13 Feb 2023 12:49:04 -0600 Subject: [PATCH 218/675] Revert changes overriding rapids-cmake repo. (#1209) PR #1177 was merged a little too early when CI passed due to the presence of a `/merge` comment and sufficient approvals. This reverts a temporary change to the rapids-cmake repo that is no longer needed because https://github.com/rapidsai/rapids-cmake/pull/368 has been merged. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Robert Maynard (https://github.com/robertmaynard) URL: https://github.com/rapidsai/rmm/pull/1209 --- CMakeLists.txt | 4 ---- python/CMakeLists.txt | 4 ---- 2 files changed, 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b33ef5ad2..fcc0f5c90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,10 +14,6 @@ cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) -# TODO(keith): REMOVE BEFORE MERGING -set(rapids-cmake-repo "kkraus14/rapids-cmake") -set(rapids-cmake-branch "spdlog_1.11_fmt") - if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.04/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 8bea660d8..705f40ac7 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -16,10 +16,6 @@ cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) set(rmm_version 23.04.00) -# TODO(keith): REMOVE BEFORE MERGING -set(rapids-cmake-repo "kkraus14/rapids-cmake") -set(rapids-cmake-branch "spdlog_1.11_fmt") - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.04/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) From 82e184fe21c6134a05961d6d9e560b65efefd8c6 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 16 Feb 2023 12:10:12 -0800 Subject: [PATCH 219/675] Stop using versioneer to manage versions (#1190) This PR replaces usage of versioneer with hard-coded version numbers in setup.py and __init__.py. Since rmm needs to manage versions across a wide range of file types (CMake, C++, Sphinx and doxygen docs, etc), versioneer cannot be relied on as a single source of truth and therefore does not allow us to single-source our versioning to the Git repo as is intended. Additionally, since the primary means of installing rmm is via conda packages (or now, pip packages), information from the package manager tends to be far more informative than the version strings for troubleshooting and debugging purposes. Conversely, the nonstandard version strings that it produces tend to be problematic for other tools, which at best will ignore such versions but at worst will simply fail. Relies on https://github.com/rapidsai/shared-action-workflows/pull/38 Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) - Sevag H (https://github.com/sevagh) URL: https://github.com/rapidsai/rmm/pull/1190 --- .gitattributes | 1 - .github/workflows/build.yaml | 1 + .github/workflows/pr.yaml | 1 + ci/check_style.sh | 2 +- ci/release/apply_wheel_modifications.sh | 9 + ci/release/update-version.sh | 2 + python/rmm/__init__.py | 5 +- python/rmm/_version.py | 566 ------- python/setup.cfg | 12 - python/setup.py | 16 +- python/versioneer.py | 1904 ----------------------- 11 files changed, 16 insertions(+), 2503 deletions(-) delete mode 100644 .gitattributes create mode 100755 ci/release/apply_wheel_modifications.sh delete mode 100644 python/rmm/_version.py delete mode 100644 python/versioneer.py diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 723c5b8b1..000000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -python/rmm/_version.py export-subst diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ef346a186..31a1bd35f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -74,6 +74,7 @@ jobs: package-name: rmm package-dir: python skbuild-configure-options: "-DRMM_BUILD_WHEELS=ON" + uses-versioneer: false wheel-publish: needs: wheel-build secrets: inherit diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index d8f0b0d3c..858c02691 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -68,6 +68,7 @@ jobs: package-dir: python package-name: rmm skbuild-configure-options: "-DRMM_BUILD_WHEELS=ON" + uses-versioneer: false wheel-tests: needs: wheel-build secrets: inherit diff --git a/ci/check_style.sh b/ci/check_style.sh index 82715f5ff..f073ff969 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -14,7 +14,7 @@ rapids-dependency-file-generator \ rapids-mamba-retry env create --force -f env.yaml -n checks conda activate checks -FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.02/cmake-format-rapids-cmake.json +FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.04/cmake-format-rapids-cmake.json export RAPIDS_CMAKE_FORMAT_FILE=/tmp/rapids_cmake_ci/cmake-formats-rapids-cmake.json mkdir -p $(dirname ${RAPIDS_CMAKE_FORMAT_FILE}) wget -O ${RAPIDS_CMAKE_FORMAT_FILE} ${FORMAT_FILE_URL} diff --git a/ci/release/apply_wheel_modifications.sh b/ci/release/apply_wheel_modifications.sh new file mode 100755 index 000000000..aad6ae84f --- /dev/null +++ b/ci/release/apply_wheel_modifications.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Copyright (c) 2023, NVIDIA CORPORATION. +# +# Usage: bash apply_wheel_modifications.sh + +VERSION=${1} + +sed -i "s/__version__ = .*/__version__ = \"${VERSION}\"/g" python/rmm/__init__.py +sed -i "s/version=.*,/version=\"${VERSION}\",/g" python/setup.py diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 257a013b9..c028a8eaf 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -36,6 +36,8 @@ sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cma # Python update sed_runner 's/'"rmm_version .*)"'/'"rmm_version ${NEXT_FULL_TAG})"'/g' python/CMakeLists.txt sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' python/CMakeLists.txt +sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/rmm/__init__.py +sed_runner "s/version=.*,/version=\"${NEXT_FULL_TAG}\",/g" python/setup.py # cmake-format rapids-cmake definitions sed_runner 's/'"branch-.*\/cmake-format-rapids-cmake.json"'/'"branch-${NEXT_SHORT_TAG}\/cmake-format-rapids-cmake.json"'/g' ci/check_style.sh diff --git a/python/rmm/__init__.py b/python/rmm/__init__.py index 9fb13fe73..e2d8f57d7 100644 --- a/python/rmm/__init__.py +++ b/python/rmm/__init__.py @@ -11,11 +11,9 @@ # 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. -import weakref from rmm import mr from rmm._lib.device_buffer import DeviceBuffer -from rmm._version import get_versions from rmm.mr import disable_logging, enable_logging, get_log_filenames from rmm.rmm import ( RMMError, @@ -36,7 +34,6 @@ "disable_logging", "enable_logging", "get_log_filenames", - "get_versions", "is_initialized", "mr", "register_reinitialize_hook", @@ -45,4 +42,4 @@ "unregister_reinitialize_hook", ] -__version__ = get_versions()["version"] +__version__ = "23.04.00" diff --git a/python/rmm/_version.py b/python/rmm/_version.py deleted file mode 100644 index 0dd28467b..000000000 --- a/python/rmm/_version.py +++ /dev/null @@ -1,566 +0,0 @@ -# This file helps to compute a version number in source trees obtained from -# git-archive tarball (such as those provided by githubs download-from-tag -# feature). Distribution tarballs (built by setup.py sdist) and build -# directories (produced by setup.py build) will contain a much shorter file -# that just contains the computed version number. - -# This file is released into the public domain. Generated by -# versioneer-0.18 (https://github.com/warner/python-versioneer) - -"""Git implementation of _version.py.""" - -import errno -import os -import re -import subprocess -import sys - - -def get_keywords(): - """Get the keywords needed to look up the version information.""" - # these strings will be replaced by git during git-archive. - # setup.py/versioneer.py will grep for the variable names, so they must - # each be defined on a line of their own. _version.py will just call - # get_keywords(). - git_refnames = "$Format:%d$" - git_full = "$Format:%H$" - git_date = "$Format:%ci$" - keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} - return keywords - - -class VersioneerConfig: - """Container for Versioneer configuration parameters.""" - - -def get_config(): - """Create, populate and return the VersioneerConfig() object.""" - # these strings are filled in when 'setup.py versioneer' creates - # _version.py - cfg = VersioneerConfig() - cfg.VCS = "git" - cfg.style = "pep440" - cfg.tag_prefix = "v" - cfg.parentdir_prefix = "rmm-" - cfg.versionfile_source = "rmm/_version.py" - cfg.verbose = False - return cfg - - -class NotThisMethod(Exception): - """Exception raised if a method is not valid for the current scenario.""" - - -LONG_VERSION_PY = {} -HANDLERS = {} - - -def register_vcs_handler(vcs, method): # decorator - """Decorator to mark a method as the handler for a particular VCS.""" - - def decorate(f): - """Store f in HANDLERS[vcs][method].""" - if vcs not in HANDLERS: - HANDLERS[vcs] = {} - HANDLERS[vcs][method] = f - return f - - return decorate - - -def run_command( - commands, args, cwd=None, verbose=False, hide_stderr=False, env=None -): - """Call the given command(s).""" - assert isinstance(commands, list) - p = None - for c in commands: - try: - dispcmd = str([c] + args) - # remember shell=False, so use git.cmd on windows, not just git - p = subprocess.Popen( - [c] + args, - cwd=cwd, - env=env, - stdout=subprocess.PIPE, - stderr=(subprocess.PIPE if hide_stderr else None), - ) - break - except EnvironmentError: - e = sys.exc_info()[1] - if e.errno == errno.ENOENT: - continue - if verbose: - print("unable to run %s" % dispcmd) - print(e) - return None, None - else: - if verbose: - print("unable to find command, tried %s" % (commands,)) - return None, None - stdout = p.communicate()[0].strip() - if sys.version_info[0] >= 3: - stdout = stdout.decode() - if p.returncode != 0: - if verbose: - print("unable to run %s (error)" % dispcmd) - print("stdout was %s" % stdout) - return None, p.returncode - return stdout, p.returncode - - -def versions_from_parentdir(parentdir_prefix, root, verbose): - """Try to determine the version from the parent directory name. - - Source tarballs conventionally unpack into a directory that includes both - the project name and a version string. We will also support searching up - two directory levels for an appropriately named parent directory - """ - rootdirs = [] - - for i in range(3): - dirname = os.path.basename(root) - if dirname.startswith(parentdir_prefix): - return { - "version": dirname[len(parentdir_prefix) :], - "full-revisionid": None, - "dirty": False, - "error": None, - "date": None, - } - else: - rootdirs.append(root) - root = os.path.dirname(root) # up a level - - if verbose: - print( - "Tried directories %s but none started with prefix %s" - % (str(rootdirs), parentdir_prefix) - ) - raise NotThisMethod("rootdir doesn't start with parentdir_prefix") - - -@register_vcs_handler("git", "get_keywords") -def git_get_keywords(versionfile_abs): - """Extract version information from the given file.""" - # the code embedded in _version.py can just fetch the value of these - # keywords. When used from setup.py, we don't want to import _version.py, - # so we do it with a regexp instead. This function is not used from - # _version.py. - keywords = {} - try: - f = open(versionfile_abs, "r") - for line in f.readlines(): - if line.strip().startswith("git_refnames ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["refnames"] = mo.group(1) - if line.strip().startswith("git_full ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["full"] = mo.group(1) - if line.strip().startswith("git_date ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["date"] = mo.group(1) - f.close() - except EnvironmentError: - pass - return keywords - - -@register_vcs_handler("git", "keywords") -def git_versions_from_keywords(keywords, tag_prefix, verbose): - """Get version information from git keywords.""" - if not keywords: - raise NotThisMethod("no keywords at all, weird") - date = keywords.get("date") - if date is not None: - # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant - # datestamp. However we prefer "%ci" (which expands to an "ISO-8601 - # -like" string, which we must then edit to make compliant), because - # it's been around since git-1.5.3, and it's too difficult to - # discover which version we're using, or to work around using an - # older one. - date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) - refnames = keywords["refnames"].strip() - if refnames.startswith("$Format"): - if verbose: - print("keywords are unexpanded, not using") - raise NotThisMethod("unexpanded keywords, not a git-archive tarball") - refs = set([r.strip() for r in refnames.strip("()").split(",")]) - # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of - # just "foo-1.0". If we see a "tag: " prefix, prefer those. - TAG = "tag: " - tags = set([r[len(TAG) :] for r in refs if r.startswith(TAG)]) - if not tags: - # Either we're using git < 1.8.3, or there really are no tags. We use - # a heuristic: assume all version tags have a digit. The old git %d - # expansion behaves like git log --decorate=short and strips out the - # refs/heads/ and refs/tags/ prefixes that would let us distinguish - # between branches and tags. By ignoring refnames without digits, we - # filter out many common branch names like "release" and - # "stabilization", as well as "HEAD" and "master". - tags = set([r for r in refs if re.search(r"\d", r)]) - if verbose: - print("discarding '%s', no digits" % ",".join(refs - tags)) - if verbose: - print("likely tags: %s" % ",".join(sorted(tags))) - for ref in sorted(tags): - # sorting will prefer e.g. "2.0" over "2.0rc1" - if ref.startswith(tag_prefix): - r = ref[len(tag_prefix) :] - if verbose: - print("picking %s" % r) - return { - "version": r, - "full-revisionid": keywords["full"].strip(), - "dirty": False, - "error": None, - "date": date, - } - # no suitable tags, so version is "0+unknown", but full hex is still there - if verbose: - print("no suitable tags, using unknown + full revision id") - return { - "version": "0+unknown", - "full-revisionid": keywords["full"].strip(), - "dirty": False, - "error": "no suitable tags", - "date": None, - } - - -@register_vcs_handler("git", "pieces_from_vcs") -def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): - """Get version from 'git describe' in the root of the source tree. - - This only gets called if the git-archive 'subst' keywords were *not* - expanded, and _version.py hasn't already been rewritten with a short - version string, meaning we're inside a checked out source tree. - """ - GITS = ["git"] - if sys.platform == "win32": - GITS = ["git.cmd", "git.exe"] - - out, rc = run_command( - GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True - ) - if rc != 0: - if verbose: - print("Directory %s not under git control" % root) - raise NotThisMethod("'git rev-parse --git-dir' returned error") - - # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] - # if there isn't one, this yields HEX[-dirty] (no NUM) - describe_out, rc = run_command( - GITS, - [ - "describe", - "--tags", - "--dirty", - "--always", - "--long", - "--match", - "%s*" % tag_prefix, - ], - cwd=root, - ) - # --long was added in git-1.5.5 - if describe_out is None: - raise NotThisMethod("'git describe' failed") - describe_out = describe_out.strip() - full_out, rc = run_command(GITS, ["rev-parse", "HEAD"], cwd=root) - if full_out is None: - raise NotThisMethod("'git rev-parse' failed") - full_out = full_out.strip() - - pieces = {} - pieces["long"] = full_out - pieces["short"] = full_out[:7] # maybe improved later - pieces["error"] = None - - # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] - # TAG might have hyphens. - git_describe = describe_out - - # look for -dirty suffix - dirty = git_describe.endswith("-dirty") - pieces["dirty"] = dirty - if dirty: - git_describe = git_describe[: git_describe.rindex("-dirty")] - - # now we have TAG-NUM-gHEX or HEX - - if "-" in git_describe: - # TAG-NUM-gHEX - mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe) - if not mo: - # unparseable. Maybe git-describe is misbehaving? - pieces["error"] = ( - "unable to parse git-describe output: '%s'" % describe_out - ) - return pieces - - # tag - full_tag = mo.group(1) - if not full_tag.startswith(tag_prefix): - if verbose: - fmt = "tag '%s' doesn't start with prefix '%s'" - print(fmt % (full_tag, tag_prefix)) - pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % ( - full_tag, - tag_prefix, - ) - return pieces - pieces["closest-tag"] = full_tag[len(tag_prefix) :] - - # distance: number of commits since tag - pieces["distance"] = int(mo.group(2)) - - # commit: short hex revision ID - pieces["short"] = mo.group(3) - - else: - # HEX: no tags - pieces["closest-tag"] = None - count_out, rc = run_command( - GITS, ["rev-list", "HEAD", "--count"], cwd=root - ) - pieces["distance"] = int(count_out) # total number of commits - - # commit date: see ISO-8601 comment in git_versions_from_keywords() - date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[ - 0 - ].strip() - pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) - - return pieces - - -def plus_or_dot(pieces): - """Return a + if we don't already have one, else return a .""" - if "+" in pieces.get("closest-tag", ""): - return "." - return "+" - - -def render_pep440(pieces): - """Build up version string, with post-release "local version identifier". - - Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you - get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty - - Exceptions: - 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += plus_or_dot(pieces) - rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - else: - # exception #1 - rendered = "0+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - return rendered - - -def render_pep440_pre(pieces): - """TAG[.post.devDISTANCE] -- No -dirty. - - Exceptions: - 1: no tags. 0.post.devDISTANCE - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"]: - rendered += ".post.dev%d" % pieces["distance"] - else: - # exception #1 - rendered = "0.post.dev%d" % pieces["distance"] - return rendered - - -def render_pep440_post(pieces): - """TAG[.postDISTANCE[.dev0]+gHEX] . - - The ".dev0" means dirty. Note that .dev0 sorts backwards - (a dirty tree will appear "older" than the corresponding clean one), - but you shouldn't be releasing software with -dirty anyways. - - Exceptions: - 1: no tags. 0.postDISTANCE[.dev0] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - rendered += plus_or_dot(pieces) - rendered += "g%s" % pieces["short"] - else: - # exception #1 - rendered = "0.post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - rendered += "+g%s" % pieces["short"] - return rendered - - -def render_pep440_old(pieces): - """TAG[.postDISTANCE[.dev0]] . - - The ".dev0" means dirty. - - Eexceptions: - 1: no tags. 0.postDISTANCE[.dev0] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - else: - # exception #1 - rendered = "0.post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - return rendered - - -def render_git_describe(pieces): - """TAG[-DISTANCE-gHEX][-dirty]. - - Like 'git describe --tags --dirty --always'. - - Exceptions: - 1: no tags. HEX[-dirty] (note: no 'g' prefix) - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"]: - rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) - else: - # exception #1 - rendered = pieces["short"] - if pieces["dirty"]: - rendered += "-dirty" - return rendered - - -def render_git_describe_long(pieces): - """TAG-DISTANCE-gHEX[-dirty]. - - Like 'git describe --tags --dirty --always -long'. - The distance/hash is unconditional. - - Exceptions: - 1: no tags. HEX[-dirty] (note: no 'g' prefix) - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) - else: - # exception #1 - rendered = pieces["short"] - if pieces["dirty"]: - rendered += "-dirty" - return rendered - - -def render(pieces, style): - """Render the given version pieces into the requested style.""" - if pieces["error"]: - return { - "version": "unknown", - "full-revisionid": pieces.get("long"), - "dirty": None, - "error": pieces["error"], - "date": None, - } - - if not style or style == "default": - style = "pep440" # the default - - if style == "pep440": - rendered = render_pep440(pieces) - elif style == "pep440-pre": - rendered = render_pep440_pre(pieces) - elif style == "pep440-post": - rendered = render_pep440_post(pieces) - elif style == "pep440-old": - rendered = render_pep440_old(pieces) - elif style == "git-describe": - rendered = render_git_describe(pieces) - elif style == "git-describe-long": - rendered = render_git_describe_long(pieces) - else: - raise ValueError("unknown style '%s'" % style) - - return { - "version": rendered, - "full-revisionid": pieces["long"], - "dirty": pieces["dirty"], - "error": None, - "date": pieces.get("date"), - } - - -def get_versions(): - """Get version information or return default if unable to do so.""" - # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have - # __file__, we can work backwards from there to the root. Some - # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which - # case we can only use expanded keywords. - - cfg = get_config() - verbose = cfg.verbose - - try: - return git_versions_from_keywords( - get_keywords(), cfg.tag_prefix, verbose - ) - except NotThisMethod: - pass - - try: - root = os.path.realpath(__file__) - # versionfile_source is the relative path from the top of the source - # tree (where the .git directory might live) to this file. Invert - # this to find the root from __file__. - for i in cfg.versionfile_source.split("/"): - root = os.path.dirname(root) - except NameError: - return { - "version": "0+unknown", - "full-revisionid": None, - "dirty": None, - "error": "unable to find root of source tree", - "date": None, - } - - try: - pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose) - return render(pieces, cfg.style) - except NotThisMethod: - pass - - try: - if cfg.parentdir_prefix: - return versions_from_parentdir(cfg.parentdir_prefix, root, verbose) - except NotThisMethod: - pass - - return { - "version": "0+unknown", - "full-revisionid": None, - "dirty": None, - "error": "unable to compute version", - "date": None, - } diff --git a/python/setup.cfg b/python/setup.cfg index 7a1f5c819..d5b0510b1 100644 --- a/python/setup.cfg +++ b/python/setup.cfg @@ -1,17 +1,5 @@ # Copyright (c) 2018-2021, NVIDIA CORPORATION. -# See the docstring in versioneer.py for instructions. Note that you must -# re-run 'versioneer.py setup' after changing this section, and commit the -# resulting files. - - -[versioneer] -VCS = git -style = pep440 -versionfile_source = rmm/_version.py -versionfile_build = rmm/_version.py -tag_prefix = v -parentdir_prefix = rmm- [flake8] filename = *.py, *.pyx, *.pxd, *.pxi diff --git a/python/setup.py b/python/setup.py index 2adcf53b1..a60f87e75 100644 --- a/python/setup.py +++ b/python/setup.py @@ -2,25 +2,12 @@ import os -import versioneer from setuptools import find_packages from skbuild import setup -if "RAPIDS_PY_WHEEL_VERSIONEER_OVERRIDE" in os.environ: - orig_get_versions = versioneer.get_versions - - version_override = os.environ["RAPIDS_PY_WHEEL_VERSIONEER_OVERRIDE"] - - def get_versions(): - data = orig_get_versions() - data["version"] = version_override - return data - - versioneer.get_versions = get_versions - setup( name="rmm" + os.getenv("RAPIDS_PY_WHEEL_CUDA_SUFFIX", default=""), - version=versioneer.get_version(), + version="23.04.00", description="rmm - RAPIDS Memory Manager", url="https://github.com/rapidsai/rmm", author="NVIDIA Corporation", @@ -49,7 +36,6 @@ def get_versions(): include=["rmm._lib", "rmm._lib.includes", "rmm._cuda*"] ) }, - cmdclass=versioneer.get_cmdclass(), install_requires=[ "cuda-python>=11.7.1,<12.0", "numpy>=1.19", diff --git a/python/versioneer.py b/python/versioneer.py deleted file mode 100644 index 72e29eaae..000000000 --- a/python/versioneer.py +++ /dev/null @@ -1,1904 +0,0 @@ -# Version: 0.18 - -"""The Versioneer - like a rocketeer, but for versions. - -The Versioneer -============== - -* like a rocketeer, but for versions! -* https://github.com/warner/python-versioneer -* Brian Warner -* License: Public Domain -* Compatible With: python2.6, 2.7, 3.2, 3.3, 3.4, 3.5, 3.6, and pypy -* [![Latest Version] -(https://pypip.in/version/versioneer/badge.svg?style=flat) -](https://pypi.python.org/pypi/versioneer/) -* [![Build Status] -(https://travis-ci.org/warner/python-versioneer.png?branch=master) -](https://travis-ci.org/warner/python-versioneer) - -This is a tool for managing a recorded version number in distutils-based -python projects. The goal is to remove the tedious and error-prone "update -the embedded version string" step from your release process. Making a new -release should be as easy as recording a new tag in your version-control -system, and maybe making new tarballs. - - -## Quick Install - -* `pip install versioneer` to somewhere to your $PATH -* add a `[versioneer]` section to your setup.cfg (see below) -* run `versioneer install` in your source tree, commit the results - -## Version Identifiers - -Source trees come from a variety of places: - -* a version-control system checkout (mostly used by developers) -* a nightly tarball, produced by build automation -* a snapshot tarball, produced by a web-based VCS browser, like github's - "tarball from tag" feature -* a release tarball, produced by "setup.py sdist", distributed through PyPI - -Within each source tree, the version identifier (either a string or a number, -this tool is format-agnostic) can come from a variety of places: - -* ask the VCS tool itself, e.g. "git describe" (for checkouts), which knows - about recent "tags" and an absolute revision-id -* the name of the directory into which the tarball was unpacked -* an expanded VCS keyword ($Id$, etc) -* a `_version.py` created by some earlier build step - -For released software, the version identifier is closely related to a VCS -tag. Some projects use tag names that include more than just the version -string (e.g. "myproject-1.2" instead of just "1.2"), in which case the tool -needs to strip the tag prefix to extract the version identifier. For -unreleased software (between tags), the version identifier should provide -enough information to help developers recreate the same tree, while also -giving them an idea of roughly how old the tree is (after version 1.2, before -version 1.3). Many VCS systems can report a description that captures this, -for example `git describe --tags --dirty --always` reports things like -"0.7-1-g574ab98-dirty" to indicate that the checkout is one revision past the -0.7 tag, has a unique revision id of "574ab98", and is "dirty" (it has -uncommitted changes. - -The version identifier is used for multiple purposes: - -* to allow the module to self-identify its version: `myproject.__version__` -* to choose a name and prefix for a 'setup.py sdist' tarball - -## Theory of Operation - -Versioneer works by adding a special `_version.py` file into your source -tree, where your `__init__.py` can import it. This `_version.py` knows how to -dynamically ask the VCS tool for version information at import time. - -`_version.py` also contains `$Revision$` markers, and the installation -process marks `_version.py` to have this marker rewritten with a tag name -during the `git archive` command. As a result, generated tarballs will -contain enough information to get the proper version. - -To allow `setup.py` to compute a version too, a `versioneer.py` is added to -the top level of your source tree, next to `setup.py` and the `setup.cfg` -that configures it. This overrides several distutils/setuptools commands to -compute the version when invoked, and changes `setup.py build` and `setup.py -sdist` to replace `_version.py` with a small static file that contains just -the generated version data. - -## Installation - -See [INSTALL.md](./INSTALL.md) for detailed installation instructions. - -## Version-String Flavors - -Code which uses Versioneer can learn about its version string at runtime by -importing `_version` from your main `__init__.py` file and running the -`get_versions()` function. From the "outside" (e.g. in `setup.py`), you can -import the top-level `versioneer.py` and run `get_versions()`. - -Both functions return a dictionary with different flavors of version -information: - -* `['version']`: A condensed version string, rendered using the selected - style. This is the most commonly used value for the project's version - string. The default "pep440" style yields strings like `0.11`, - `0.11+2.g1076c97`, or `0.11+2.g1076c97.dirty`. See the "Styles" section - below for alternative styles. - -* `['full-revisionid']`: detailed revision identifier. For Git, this is the - full SHA1 commit id, e.g. "1076c978a8d3cfc70f408fe5974aa6c092c949ac". - -* `['date']`: Date and time of the latest `HEAD` commit. For Git, it is the - commit date in ISO 8601 format. This will be None if the date is not - available. - -* `['dirty']`: a boolean, True if the tree has uncommitted changes. Note that - this is only accurate if run in a VCS checkout, otherwise it is likely to - be False or None - -* `['error']`: if the version string could not be computed, this will be set - to a string describing the problem, otherwise it will be None. It may be - useful to throw an exception in setup.py if this is set, to avoid e.g. - creating tarballs with a version string of "unknown". - -Some variants are more useful than others. Including `full-revisionid` in a -bug report should allow developers to reconstruct the exact code being tested -(or indicate the presence of local changes that should be shared with the -developers). `version` is suitable for display in an "about" box or a CLI -`--version` output: it can be easily compared against release notes and lists -of bugs fixed in various releases. - -The installer adds the following text to your `__init__.py` to place a basic -version in `YOURPROJECT.__version__`: - - from cudf._version import get_versions - __version__ = get_versions()['version'] - del get_versions - -## Styles - -The setup.cfg `style=` configuration controls how the VCS information is -rendered into a version string. - -The default style, "pep440", produces a PEP440-compliant string, equal to the -un-prefixed tag name for actual releases, and containing an additional "local -version" section with more detail for in-between builds. For Git, this is -TAG[+DISTANCE.gHEX[.dirty]] , using information from `git describe --tags ---dirty --always`. For example "0.11+2.g1076c97.dirty" indicates that the -tree is like the "1076c97" commit but has uncommitted changes (".dirty"), and -that this commit is two revisions ("+2") beyond the "0.11" tag. For released -software (exactly equal to a known tag), the identifier will only contain the -stripped tag, e.g. "0.11". - -Other styles are available. See [details.md](details.md) in the Versioneer -source tree for descriptions. - -## Debugging - -Versioneer tries to avoid fatal errors: if something goes wrong, it will tend -to return a version of "0+unknown". To investigate the problem, run `setup.py -version`, which will run the version-lookup code in a verbose mode, and will -display the full contents of `get_versions()` (including the `error` string, -which may help identify what went wrong). - -## Known Limitations - -Some situations are known to cause problems for Versioneer. This details the -most significant ones. More can be found on Github -[issues page](https://github.com/warner/python-versioneer/issues). - -### Subprojects - -Versioneer has limited support for source trees in which `setup.py` is not in -the root directory (e.g. `setup.py` and `.git/` are *not* siblings). The are -two common reasons why `setup.py` might not be in the root: - -* Source trees which contain multiple subprojects, such as - [Buildbot](https://github.com/buildbot/buildbot), which contains both - "master" and "slave" subprojects, each with their own `setup.py`, - `setup.cfg`, and `tox.ini`. Projects like these produce multiple PyPI - distributions (and upload multiple independently-installable tarballs). -* Source trees whose main purpose is to contain a C library, but which also - provide bindings to Python (and perhaps other langauges) in subdirectories. - -Versioneer will look for `.git` in parent directories, and most operations -should get the right version string. However `pip` and `setuptools` have bugs -and implementation details which frequently cause `pip install .` from a -subproject directory to fail to find a correct version string (so it usually -defaults to `0+unknown`). - -`pip install --editable .` should work correctly. `setup.py install` might -work too. - -Pip-8.1.1 is known to have this problem, but hopefully it will get fixed in -some later version. - -[Bug #38](https://github.com/warner/python-versioneer/issues/38) is tracking -this issue. The discussion in -[PR #61](https://github.com/warner/python-versioneer/pull/61) describes the -issue from the Versioneer side in more detail. -[pip PR#3176](https://github.com/pypa/pip/pull/3176) and -[pip PR#3615](https://github.com/pypa/pip/pull/3615) contain work to improve -pip to let Versioneer work correctly. - -Versioneer-0.16 and earlier only looked for a `.git` directory next to the -`setup.cfg`, so subprojects were completely unsupported with those releases. - -### Editable installs with setuptools <= 18.5 - -`setup.py develop` and `pip install --editable .` allow you to install a -project into a virtualenv once, then continue editing the source code (and -test) without re-installing after every change. - -"Entry-point scripts" (`setup(entry_points={"console_scripts": ..})`) are a -convenient way to specify executable scripts that should be installed along -with the python package. - -These both work as expected when using modern setuptools. When using -setuptools-18.5 or earlier, however, certain operations will cause -`pkg_resources.DistributionNotFound` errors when running the entrypoint -script, which must be resolved by re-installing the package. This happens -when the install happens with one version, then the egg_info data is -regenerated while a different version is checked out. Many setup.py commands -cause egg_info to be rebuilt (including `sdist`, `wheel`, and installing into -a different virtualenv), so this can be surprising. - -[Bug #83](https://github.com/warner/python-versioneer/issues/83) describes -this one, but upgrading to a newer version of setuptools should probably -resolve it. - -### Unicode version strings - -While Versioneer works (and is continually tested) with both Python 2 and -Python 3, it is not entirely consistent with bytes-vs-unicode distinctions. -Newer releases probably generate unicode version strings on py2. It's not -clear that this is wrong, but it may be surprising for applications when then -write these strings to a network connection or include them in bytes-oriented -APIs like cryptographic checksums. - -[Bug #71](https://github.com/warner/python-versioneer/issues/71) investigates -this question. - - -## Updating Versioneer - -To upgrade your project to a new release of Versioneer, do the following: - -* install the new Versioneer (`pip install -U versioneer` or equivalent) -* edit `setup.cfg`, if necessary, to include any new configuration settings - indicated by the release notes. See [UPGRADING](./UPGRADING.md) for details. -* re-run `versioneer install` in your source tree, to replace - `SRC/_version.py` -* commit any changed files - -## Future Directions - -This tool is designed to make it easily extended to other version-control -systems: all VCS-specific components are in separate directories like -src/git/ . The top-level `versioneer.py` script is assembled from these -components by running make-versioneer.py . In the future, make-versioneer.py -will take a VCS name as an argument, and will construct a version of -`versioneer.py` that is specific to the given VCS. It might also take the -configuration arguments that are currently provided manually during -installation by editing setup.py . Alternatively, it might go the other -direction and include code from all supported VCS systems, reducing the -number of intermediate scripts. - - -## License - -To make Versioneer easier to embed, all its code is dedicated to the public -domain. The `_version.py` that it creates is also in the public domain. -Specifically, both are released under the Creative Commons "Public Domain -Dedication" license (CC0-1.0), as described in -https://creativecommons.org/publicdomain/zero/1.0/ . - -""" - -from __future__ import print_function - -import errno -import json -import os -import re -import subprocess -import sys - -try: - import configparser -except ImportError: - import ConfigParser as configparser - - -class VersioneerConfig: - """Container for Versioneer configuration parameters.""" - - -def get_root(): - """Get the project root directory. - - We require that all commands are run from the project root, i.e. the - directory that contains setup.py, setup.cfg, and versioneer.py . - """ - root = os.path.realpath(os.path.abspath(os.getcwd())) - setup_py = os.path.join(root, "setup.py") - versioneer_py = os.path.join(root, "versioneer.py") - if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)): - # allow 'python path/to/setup.py COMMAND' - root = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0]))) - setup_py = os.path.join(root, "setup.py") - versioneer_py = os.path.join(root, "versioneer.py") - if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)): - err = ( - "Versioneer was unable to run the project root directory. " - "Versioneer requires setup.py to be executed from " - "its immediate directory (like 'python setup.py COMMAND'), " - "or in a way that lets it use sys.argv[0] to find the root " - "(like 'python path/to/setup.py COMMAND')." - ) - raise VersioneerBadRootError(err) - try: - # Certain runtime workflows (setup.py install/develop in a setuptools - # tree) execute all dependencies in a single python process, so - # "versioneer" may be imported multiple times, and python's shared - # module-import table will cache the first one. So we can't use - # os.path.dirname(__file__), as that will find whichever - # versioneer.py was first imported, even in later projects. - me = os.path.realpath(os.path.abspath(__file__)) - me_dir = os.path.normcase(os.path.splitext(me)[0]) - vsr_dir = os.path.normcase(os.path.splitext(versioneer_py)[0]) - if me_dir != vsr_dir: - print( - "Warning: build in %s is using versioneer.py from %s" - % (os.path.dirname(me), versioneer_py) - ) - except NameError: - pass - return root - - -def get_config_from_root(root): - """Read the project setup.cfg file to determine Versioneer config.""" - # This might raise EnvironmentError (if setup.cfg is missing), or - # configparser.NoSectionError (if it lacks a [versioneer] section), or - # configparser.NoOptionError (if it lacks "VCS="). See the docstring at - # the top of versioneer.py for instructions on writing your setup.cfg . - setup_cfg = os.path.join(root, "setup.cfg") - parser = configparser.SafeConfigParser() - with open(setup_cfg, "r") as f: - parser.readfp(f) - VCS = parser.get("versioneer", "VCS") # mandatory - - def get(parser, name): - if parser.has_option("versioneer", name): - return parser.get("versioneer", name) - return None - - cfg = VersioneerConfig() - cfg.VCS = VCS - cfg.style = get(parser, "style") or "" - cfg.versionfile_source = get(parser, "versionfile_source") - cfg.versionfile_build = get(parser, "versionfile_build") - cfg.tag_prefix = get(parser, "tag_prefix") - if cfg.tag_prefix in ("''", '""'): - cfg.tag_prefix = "" - cfg.parentdir_prefix = get(parser, "parentdir_prefix") - cfg.verbose = get(parser, "verbose") - return cfg - - -class NotThisMethod(Exception): - """Exception raised if a method is not valid for the current scenario.""" - - -# these dictionaries contain VCS-specific tools -LONG_VERSION_PY = {} -HANDLERS = {} - - -def register_vcs_handler(vcs, method): # decorator - """Decorator to mark a method as the handler for a particular VCS.""" - - def decorate(f): - """Store f in HANDLERS[vcs][method].""" - if vcs not in HANDLERS: - HANDLERS[vcs] = {} - HANDLERS[vcs][method] = f - return f - - return decorate - - -def run_command( - commands, args, cwd=None, verbose=False, hide_stderr=False, env=None -): - """Call the given command(s).""" - assert isinstance(commands, list) - p = None - for c in commands: - try: - dispcmd = str([c] + args) - # remember shell=False, so use git.cmd on windows, not just git - p = subprocess.Popen( - [c] + args, - cwd=cwd, - env=env, - stdout=subprocess.PIPE, - stderr=(subprocess.PIPE if hide_stderr else None), - ) - break - except EnvironmentError: - e = sys.exc_info()[1] - if e.errno == errno.ENOENT: - continue - if verbose: - print("unable to run %s" % dispcmd) - print(e) - return None, None - else: - if verbose: - print("unable to find command, tried %s" % (commands,)) - return None, None - stdout = p.communicate()[0].strip() - if sys.version_info[0] >= 3: - stdout = stdout.decode() - if p.returncode != 0: - if verbose: - print("unable to run %s (error)" % dispcmd) - print("stdout was %s" % stdout) - return None, p.returncode - return stdout, p.returncode - - -LONG_VERSION_PY[ - "git" -] = r''' -# This file helps to compute a version number in source trees obtained from -# git-archive tarball (such as those provided by githubs download-from-tag -# feature). Distribution tarballs (built by setup.py sdist) and build -# directories (produced by setup.py build) will contain a much shorter file -# that just contains the computed version number. - -# This file is released into the public domain. Generated by -# versioneer-0.18 (https://github.com/warner/python-versioneer) - -"""Git implementation of _version.py.""" - -import errno -import os -import re -import subprocess -import sys - - -def get_keywords(): - """Get the keywords needed to look up the version information.""" - # these strings will be replaced by git during git-archive. - # setup.py/versioneer.py will grep for the variable names, so they must - # each be defined on a line of their own. _version.py will just call - # get_keywords(). - git_refnames = "%(DOLLAR)sFormat:%%d%(DOLLAR)s" - git_full = "%(DOLLAR)sFormat:%%H%(DOLLAR)s" - git_date = "%(DOLLAR)sFormat:%%ci%(DOLLAR)s" - keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} - return keywords - - -class VersioneerConfig: - """Container for Versioneer configuration parameters.""" - - -def get_config(): - """Create, populate and return the VersioneerConfig() object.""" - # these strings are filled in when 'setup.py versioneer' creates - # _version.py - cfg = VersioneerConfig() - cfg.VCS = "git" - cfg.style = "%(STYLE)s" - cfg.tag_prefix = "%(TAG_PREFIX)s" - cfg.parentdir_prefix = "%(PARENTDIR_PREFIX)s" - cfg.versionfile_source = "%(VERSIONFILE_SOURCE)s" - cfg.verbose = False - return cfg - - -class NotThisMethod(Exception): - """Exception raised if a method is not valid for the current scenario.""" - - -LONG_VERSION_PY = {} -HANDLERS = {} - - -def register_vcs_handler(vcs, method): # decorator - """Decorator to mark a method as the handler for a particular VCS.""" - def decorate(f): - """Store f in HANDLERS[vcs][method].""" - if vcs not in HANDLERS: - HANDLERS[vcs] = {} - HANDLERS[vcs][method] = f - return f - return decorate - - -def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, - env=None): - """Call the given command(s).""" - assert isinstance(commands, list) - p = None - for c in commands: - try: - dispcmd = str([c] + args) - # remember shell=False, so use git.cmd on windows, not just git - p = subprocess.Popen([c] + args, cwd=cwd, env=env, - stdout=subprocess.PIPE, - stderr=(subprocess.PIPE if hide_stderr - else None)) - break - except EnvironmentError: - e = sys.exc_info()[1] - if e.errno == errno.ENOENT: - continue - if verbose: - print("unable to run %%s" %% dispcmd) - print(e) - return None, None - else: - if verbose: - print("unable to find command, tried %%s" %% (commands,)) - return None, None - stdout = p.communicate()[0].strip() - if sys.version_info[0] >= 3: - stdout = stdout.decode() - if p.returncode != 0: - if verbose: - print("unable to run %%s (error)" %% dispcmd) - print("stdout was %%s" %% stdout) - return None, p.returncode - return stdout, p.returncode - - -def versions_from_parentdir(parentdir_prefix, root, verbose): - """Try to determine the version from the parent directory name. - - Source tarballs conventionally unpack into a directory that includes both - the project name and a version string. We will also support searching up - two directory levels for an appropriately named parent directory - """ - rootdirs = [] - - for i in range(3): - dirname = os.path.basename(root) - if dirname.startswith(parentdir_prefix): - return {"version": dirname[len(parentdir_prefix):], - "full-revisionid": None, - "dirty": False, "error": None, "date": None} - else: - rootdirs.append(root) - root = os.path.dirname(root) # up a level - - if verbose: - print("Tried directories %%s but none started with prefix %%s" %% - (str(rootdirs), parentdir_prefix)) - raise NotThisMethod("rootdir doesn't start with parentdir_prefix") - - -@register_vcs_handler("git", "get_keywords") -def git_get_keywords(versionfile_abs): - """Extract version information from the given file.""" - # the code embedded in _version.py can just fetch the value of these - # keywords. When used from setup.py, we don't want to import _version.py, - # so we do it with a regexp instead. This function is not used from - # _version.py. - keywords = {} - try: - f = open(versionfile_abs, "r") - for line in f.readlines(): - if line.strip().startswith("git_refnames ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["refnames"] = mo.group(1) - if line.strip().startswith("git_full ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["full"] = mo.group(1) - if line.strip().startswith("git_date ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["date"] = mo.group(1) - f.close() - except EnvironmentError: - pass - return keywords - - -@register_vcs_handler("git", "keywords") -def git_versions_from_keywords(keywords, tag_prefix, verbose): - """Get version information from git keywords.""" - if not keywords: - raise NotThisMethod("no keywords at all, weird") - date = keywords.get("date") - if date is not None: - # git-2.2.0 added "%%cI", which expands to an ISO-8601 -compliant - # datestamp. However we prefer "%%ci" (which expands to an "ISO-8601 - # -like" string, which we must then edit to make compliant), because - # it's been around since git-1.5.3, and it's too difficult to - # discover which version we're using, or to work around using an - # older one. - date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) - refnames = keywords["refnames"].strip() - if refnames.startswith("$Format"): - if verbose: - print("keywords are unexpanded, not using") - raise NotThisMethod("unexpanded keywords, not a git-archive tarball") - refs = set([r.strip() for r in refnames.strip("()").split(",")]) - # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of - # just "foo-1.0". If we see a "tag: " prefix, prefer those. - TAG = "tag: " - tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)]) - if not tags: - # Either we're using git < 1.8.3, or there really are no tags. We use - # a heuristic: assume all version tags have a digit. The old git %%d - # expansion behaves like git log --decorate=short and strips out the - # refs/heads/ and refs/tags/ prefixes that would let us distinguish - # between branches and tags. By ignoring refnames without digits, we - # filter out many common branch names like "release" and - # "stabilization", as well as "HEAD" and "master". - tags = set([r for r in refs if re.search(r'\d', r)]) - if verbose: - print("discarding '%%s', no digits" %% ",".join(refs - tags)) - if verbose: - print("likely tags: %%s" %% ",".join(sorted(tags))) - for ref in sorted(tags): - # sorting will prefer e.g. "2.0" over "2.0rc1" - if ref.startswith(tag_prefix): - r = ref[len(tag_prefix):] - if verbose: - print("picking %%s" %% r) - return {"version": r, - "full-revisionid": keywords["full"].strip(), - "dirty": False, "error": None, - "date": date} - # no suitable tags, so version is "0+unknown", but full hex is still there - if verbose: - print("no suitable tags, using unknown + full revision id") - return {"version": "0+unknown", - "full-revisionid": keywords["full"].strip(), - "dirty": False, "error": "no suitable tags", "date": None} - - -@register_vcs_handler("git", "pieces_from_vcs") -def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): - """Get version from 'git describe' in the root of the source tree. - - This only gets called if the git-archive 'subst' keywords were *not* - expanded, and _version.py hasn't already been rewritten with a short - version string, meaning we're inside a checked out source tree. - """ - GITS = ["git"] - if sys.platform == "win32": - GITS = ["git.cmd", "git.exe"] - - out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root, - hide_stderr=True) - if rc != 0: - if verbose: - print("Directory %%s not under git control" %% root) - raise NotThisMethod("'git rev-parse --git-dir' returned error") - - # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] - # if there isn't one, this yields HEX[-dirty] (no NUM) - describe_out, rc = run_command(GITS, ["describe", "--tags", "--dirty", - "--always", "--long", - "--match", "%%s*" %% tag_prefix], - cwd=root) - # --long was added in git-1.5.5 - if describe_out is None: - raise NotThisMethod("'git describe' failed") - describe_out = describe_out.strip() - full_out, rc = run_command(GITS, ["rev-parse", "HEAD"], cwd=root) - if full_out is None: - raise NotThisMethod("'git rev-parse' failed") - full_out = full_out.strip() - - pieces = {} - pieces["long"] = full_out - pieces["short"] = full_out[:7] # maybe improved later - pieces["error"] = None - - # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] - # TAG might have hyphens. - git_describe = describe_out - - # look for -dirty suffix - dirty = git_describe.endswith("-dirty") - pieces["dirty"] = dirty - if dirty: - git_describe = git_describe[:git_describe.rindex("-dirty")] - - # now we have TAG-NUM-gHEX or HEX - - if "-" in git_describe: - # TAG-NUM-gHEX - mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe) - if not mo: - # unparseable. Maybe git-describe is misbehaving? - pieces["error"] = ("unable to parse git-describe output: '%%s'" - %% describe_out) - return pieces - - # tag - full_tag = mo.group(1) - if not full_tag.startswith(tag_prefix): - if verbose: - fmt = "tag '%%s' doesn't start with prefix '%%s'" - print(fmt %% (full_tag, tag_prefix)) - pieces["error"] = ("tag '%%s' doesn't start with prefix '%%s'" - %% (full_tag, tag_prefix)) - return pieces - pieces["closest-tag"] = full_tag[len(tag_prefix):] - - # distance: number of commits since tag - pieces["distance"] = int(mo.group(2)) - - # commit: short hex revision ID - pieces["short"] = mo.group(3) - - else: - # HEX: no tags - pieces["closest-tag"] = None - count_out, rc = run_command(GITS, ["rev-list", "HEAD", "--count"], - cwd=root) - pieces["distance"] = int(count_out) # total number of commits - - # commit date: see ISO-8601 comment in git_versions_from_keywords() - date = run_command(GITS, ["show", "-s", "--format=%%ci", "HEAD"], - cwd=root)[0].strip() - pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) - - return pieces - - -def plus_or_dot(pieces): - """Return a + if we don't already have one, else return a .""" - if "+" in pieces.get("closest-tag", ""): - return "." - return "+" - - -def render_pep440(pieces): - """Build up version string, with post-release "local version identifier". - - Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you - get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty - - Exceptions: - 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += plus_or_dot(pieces) - rendered += "%%d.g%%s" %% (pieces["distance"], pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - else: - # exception #1 - rendered = "0+untagged.%%d.g%%s" %% (pieces["distance"], - pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - return rendered - - -def render_pep440_pre(pieces): - """TAG[.post.devDISTANCE] -- No -dirty. - - Exceptions: - 1: no tags. 0.post.devDISTANCE - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"]: - rendered += ".post.dev%%d" %% pieces["distance"] - else: - # exception #1 - rendered = "0.post.dev%%d" %% pieces["distance"] - return rendered - - -def render_pep440_post(pieces): - """TAG[.postDISTANCE[.dev0]+gHEX] . - - The ".dev0" means dirty. Note that .dev0 sorts backwards - (a dirty tree will appear "older" than the corresponding clean one), - but you shouldn't be releasing software with -dirty anyways. - - Exceptions: - 1: no tags. 0.postDISTANCE[.dev0] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%%d" %% pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - rendered += plus_or_dot(pieces) - rendered += "g%%s" %% pieces["short"] - else: - # exception #1 - rendered = "0.post%%d" %% pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - rendered += "+g%%s" %% pieces["short"] - return rendered - - -def render_pep440_old(pieces): - """TAG[.postDISTANCE[.dev0]] . - - The ".dev0" means dirty. - - Eexceptions: - 1: no tags. 0.postDISTANCE[.dev0] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%%d" %% pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - else: - # exception #1 - rendered = "0.post%%d" %% pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - return rendered - - -def render_git_describe(pieces): - """TAG[-DISTANCE-gHEX][-dirty]. - - Like 'git describe --tags --dirty --always'. - - Exceptions: - 1: no tags. HEX[-dirty] (note: no 'g' prefix) - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"]: - rendered += "-%%d-g%%s" %% (pieces["distance"], pieces["short"]) - else: - # exception #1 - rendered = pieces["short"] - if pieces["dirty"]: - rendered += "-dirty" - return rendered - - -def render_git_describe_long(pieces): - """TAG-DISTANCE-gHEX[-dirty]. - - Like 'git describe --tags --dirty --always -long'. - The distance/hash is unconditional. - - Exceptions: - 1: no tags. HEX[-dirty] (note: no 'g' prefix) - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - rendered += "-%%d-g%%s" %% (pieces["distance"], pieces["short"]) - else: - # exception #1 - rendered = pieces["short"] - if pieces["dirty"]: - rendered += "-dirty" - return rendered - - -def render(pieces, style): - """Render the given version pieces into the requested style.""" - if pieces["error"]: - return {"version": "unknown", - "full-revisionid": pieces.get("long"), - "dirty": None, - "error": pieces["error"], - "date": None} - - if not style or style == "default": - style = "pep440" # the default - - if style == "pep440": - rendered = render_pep440(pieces) - elif style == "pep440-pre": - rendered = render_pep440_pre(pieces) - elif style == "pep440-post": - rendered = render_pep440_post(pieces) - elif style == "pep440-old": - rendered = render_pep440_old(pieces) - elif style == "git-describe": - rendered = render_git_describe(pieces) - elif style == "git-describe-long": - rendered = render_git_describe_long(pieces) - else: - raise ValueError("unknown style '%%s'" %% style) - - return {"version": rendered, "full-revisionid": pieces["long"], - "dirty": pieces["dirty"], "error": None, - "date": pieces.get("date")} - - -def get_versions(): - """Get version information or return default if unable to do so.""" - # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have - # __file__, we can work backwards from there to the root. Some - # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which - # case we can only use expanded keywords. - - cfg = get_config() - verbose = cfg.verbose - - try: - return git_versions_from_keywords(get_keywords(), cfg.tag_prefix, - verbose) - except NotThisMethod: - pass - - try: - root = os.path.realpath(__file__) - # versionfile_source is the relative path from the top of the source - # tree (where the .git directory might live) to this file. Invert - # this to find the root from __file__. - for i in cfg.versionfile_source.split('/'): - root = os.path.dirname(root) - except NameError: - return {"version": "0+unknown", "full-revisionid": None, - "dirty": None, - "error": "unable to find root of source tree", - "date": None} - - try: - pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose) - return render(pieces, cfg.style) - except NotThisMethod: - pass - - try: - if cfg.parentdir_prefix: - return versions_from_parentdir(cfg.parentdir_prefix, root, verbose) - except NotThisMethod: - pass - - return {"version": "0+unknown", "full-revisionid": None, - "dirty": None, - "error": "unable to compute version", "date": None} -''' - - -@register_vcs_handler("git", "get_keywords") -def git_get_keywords(versionfile_abs): - """Extract version information from the given file.""" - # the code embedded in _version.py can just fetch the value of these - # keywords. When used from setup.py, we don't want to import _version.py, - # so we do it with a regexp instead. This function is not used from - # _version.py. - keywords = {} - try: - f = open(versionfile_abs, "r") - for line in f.readlines(): - if line.strip().startswith("git_refnames ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["refnames"] = mo.group(1) - if line.strip().startswith("git_full ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["full"] = mo.group(1) - if line.strip().startswith("git_date ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["date"] = mo.group(1) - f.close() - except EnvironmentError: - pass - return keywords - - -@register_vcs_handler("git", "keywords") -def git_versions_from_keywords(keywords, tag_prefix, verbose): - """Get version information from git keywords.""" - if not keywords: - raise NotThisMethod("no keywords at all, weird") - date = keywords.get("date") - if date is not None: - # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant - # datestamp. However we prefer "%ci" (which expands to an "ISO-8601 - # -like" string, which we must then edit to make compliant), because - # it's been around since git-1.5.3, and it's too difficult to - # discover which version we're using, or to work around using an - # older one. - date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) - refnames = keywords["refnames"].strip() - if refnames.startswith("$Format"): - if verbose: - print("keywords are unexpanded, not using") - raise NotThisMethod("unexpanded keywords, not a git-archive tarball") - refs = set([r.strip() for r in refnames.strip("()").split(",")]) - # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of - # just "foo-1.0". If we see a "tag: " prefix, prefer those. - TAG = "tag: " - tags = set([r[len(TAG) :] for r in refs if r.startswith(TAG)]) - if not tags: - # Either we're using git < 1.8.3, or there really are no tags. We use - # a heuristic: assume all version tags have a digit. The old git %d - # expansion behaves like git log --decorate=short and strips out the - # refs/heads/ and refs/tags/ prefixes that would let us distinguish - # between branches and tags. By ignoring refnames without digits, we - # filter out many common branch names like "release" and - # "stabilization", as well as "HEAD" and "master". - tags = set([r for r in refs if re.search(r"\d", r)]) - if verbose: - print("discarding '%s', no digits" % ",".join(refs - tags)) - if verbose: - print("likely tags: %s" % ",".join(sorted(tags))) - for ref in sorted(tags): - # sorting will prefer e.g. "2.0" over "2.0rc1" - if ref.startswith(tag_prefix): - r = ref[len(tag_prefix) :] - if verbose: - print("picking %s" % r) - return { - "version": r, - "full-revisionid": keywords["full"].strip(), - "dirty": False, - "error": None, - "date": date, - } - # no suitable tags, so version is "0+unknown", but full hex is still there - if verbose: - print("no suitable tags, using unknown + full revision id") - return { - "version": "0+unknown", - "full-revisionid": keywords["full"].strip(), - "dirty": False, - "error": "no suitable tags", - "date": None, - } - - -@register_vcs_handler("git", "pieces_from_vcs") -def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): - """Get version from 'git describe' in the root of the source tree. - - This only gets called if the git-archive 'subst' keywords were *not* - expanded, and _version.py hasn't already been rewritten with a short - version string, meaning we're inside a checked out source tree. - """ - GITS = ["git"] - if sys.platform == "win32": - GITS = ["git.cmd", "git.exe"] - - out, rc = run_command( - GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True - ) - if rc != 0: - if verbose: - print("Directory %s not under git control" % root) - raise NotThisMethod("'git rev-parse --git-dir' returned error") - - # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] - # if there isn't one, this yields HEX[-dirty] (no NUM) - describe_out, rc = run_command( - GITS, - [ - "describe", - "--tags", - "--dirty", - "--always", - "--long", - "--match", - "%s*" % tag_prefix, - ], - cwd=root, - ) - # --long was added in git-1.5.5 - if describe_out is None: - raise NotThisMethod("'git describe' failed") - describe_out = describe_out.strip() - full_out, rc = run_command(GITS, ["rev-parse", "HEAD"], cwd=root) - if full_out is None: - raise NotThisMethod("'git rev-parse' failed") - full_out = full_out.strip() - - pieces = {} - pieces["long"] = full_out - pieces["short"] = full_out[:7] # maybe improved later - pieces["error"] = None - - # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] - # TAG might have hyphens. - git_describe = describe_out - - # look for -dirty suffix - dirty = git_describe.endswith("-dirty") - pieces["dirty"] = dirty - if dirty: - git_describe = git_describe[: git_describe.rindex("-dirty")] - - # now we have TAG-NUM-gHEX or HEX - - if "-" in git_describe: - # TAG-NUM-gHEX - mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe) - if not mo: - # unparseable. Maybe git-describe is misbehaving? - pieces["error"] = ( - "unable to parse git-describe output: '%s'" % describe_out - ) - return pieces - - # tag - full_tag = mo.group(1) - if not full_tag.startswith(tag_prefix): - if verbose: - fmt = "tag '%s' doesn't start with prefix '%s'" - print(fmt % (full_tag, tag_prefix)) - pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % ( - full_tag, - tag_prefix, - ) - return pieces - pieces["closest-tag"] = full_tag[len(tag_prefix) :] - - # distance: number of commits since tag - pieces["distance"] = int(mo.group(2)) - - # commit: short hex revision ID - pieces["short"] = mo.group(3) - - else: - # HEX: no tags - pieces["closest-tag"] = None - count_out, rc = run_command( - GITS, ["rev-list", "HEAD", "--count"], cwd=root - ) - pieces["distance"] = int(count_out) # total number of commits - - # commit date: see ISO-8601 comment in git_versions_from_keywords() - date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[ - 0 - ].strip() - pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) - - return pieces - - -def do_vcs_install(manifest_in, versionfile_source, ipy): - """Git-specific installation logic for Versioneer. - - For Git, this means creating/changing .gitattributes to mark _version.py - for export-subst keyword substitution. - """ - GITS = ["git"] - if sys.platform == "win32": - GITS = ["git.cmd", "git.exe"] - files = [manifest_in, versionfile_source] - if ipy: - files.append(ipy) - try: - me = __file__ - if me.endswith(".pyc") or me.endswith(".pyo"): - me = os.path.splitext(me)[0] + ".py" - versioneer_file = os.path.relpath(me) - except NameError: - versioneer_file = "versioneer.py" - files.append(versioneer_file) - present = False - try: - f = open(".gitattributes", "r") - for line in f.readlines(): - if line.strip().startswith(versionfile_source): - if "export-subst" in line.strip().split()[1:]: - present = True - f.close() - except EnvironmentError: - pass - if not present: - f = open(".gitattributes", "a+") - f.write("%s export-subst\n" % versionfile_source) - f.close() - files.append(".gitattributes") - run_command(GITS, ["add", "--"] + files) - - -def versions_from_parentdir(parentdir_prefix, root, verbose): - """Try to determine the version from the parent directory name. - - Source tarballs conventionally unpack into a directory that includes both - the project name and a version string. We will also support searching up - two directory levels for an appropriately named parent directory - """ - rootdirs = [] - - for i in range(3): - dirname = os.path.basename(root) - if dirname.startswith(parentdir_prefix): - return { - "version": dirname[len(parentdir_prefix) :], - "full-revisionid": None, - "dirty": False, - "error": None, - "date": None, - } - else: - rootdirs.append(root) - root = os.path.dirname(root) # up a level - - if verbose: - print( - "Tried directories %s but none started with prefix %s" - % (str(rootdirs), parentdir_prefix) - ) - raise NotThisMethod("rootdir doesn't start with parentdir_prefix") - - -SHORT_VERSION_PY = """ -# This file was generated by 'versioneer.py' (0.18) from -# revision-control system data, or from the parent directory name of an -# unpacked source archive. Distribution tarballs contain a pre-generated copy -# of this file. - -import json - -version_json = ''' -%s -''' # END VERSION_JSON - - -def get_versions(): - return json.loads(version_json) -""" - - -def versions_from_file(filename): - """Try to determine the version from _version.py if present.""" - try: - with open(filename) as f: - contents = f.read() - except EnvironmentError: - raise NotThisMethod("unable to read _version.py") - mo = re.search( - r"version_json = '''\n(.*)''' # END VERSION_JSON", - contents, - re.M | re.S, - ) - if not mo: - mo = re.search( - r"version_json = '''\r\n(.*)''' # END VERSION_JSON", - contents, - re.M | re.S, - ) - if not mo: - raise NotThisMethod("no version_json in _version.py") - return json.loads(mo.group(1)) - - -def write_to_version_file(filename, versions): - """Write the given version number to the given _version.py file.""" - os.unlink(filename) - contents = json.dumps( - versions, sort_keys=True, indent=1, separators=(",", ": ") - ) - with open(filename, "w") as f: - f.write(SHORT_VERSION_PY % contents) - - print("set %s to '%s'" % (filename, versions["version"])) - - -def plus_or_dot(pieces): - """Return a + if we don't already have one, else return a .""" - if "+" in pieces.get("closest-tag", ""): - return "." - return "+" - - -def render_pep440(pieces): - """Build up version string, with post-release "local version identifier". - - Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you - get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty - - Exceptions: - 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += plus_or_dot(pieces) - rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - else: - # exception #1 - rendered = "0+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - return rendered - - -def render_pep440_pre(pieces): - """TAG[.post.devDISTANCE] -- No -dirty. - - Exceptions: - 1: no tags. 0.post.devDISTANCE - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"]: - rendered += ".post.dev%d" % pieces["distance"] - else: - # exception #1 - rendered = "0.post.dev%d" % pieces["distance"] - return rendered - - -def render_pep440_post(pieces): - """TAG[.postDISTANCE[.dev0]+gHEX] . - - The ".dev0" means dirty. Note that .dev0 sorts backwards - (a dirty tree will appear "older" than the corresponding clean one), - but you shouldn't be releasing software with -dirty anyways. - - Exceptions: - 1: no tags. 0.postDISTANCE[.dev0] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - rendered += plus_or_dot(pieces) - rendered += "g%s" % pieces["short"] - else: - # exception #1 - rendered = "0.post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - rendered += "+g%s" % pieces["short"] - return rendered - - -def render_pep440_old(pieces): - """TAG[.postDISTANCE[.dev0]] . - - The ".dev0" means dirty. - - Eexceptions: - 1: no tags. 0.postDISTANCE[.dev0] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - else: - # exception #1 - rendered = "0.post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - return rendered - - -def render_git_describe(pieces): - """TAG[-DISTANCE-gHEX][-dirty]. - - Like 'git describe --tags --dirty --always'. - - Exceptions: - 1: no tags. HEX[-dirty] (note: no 'g' prefix) - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"]: - rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) - else: - # exception #1 - rendered = pieces["short"] - if pieces["dirty"]: - rendered += "-dirty" - return rendered - - -def render_git_describe_long(pieces): - """TAG-DISTANCE-gHEX[-dirty]. - - Like 'git describe --tags --dirty --always -long'. - The distance/hash is unconditional. - - Exceptions: - 1: no tags. HEX[-dirty] (note: no 'g' prefix) - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) - else: - # exception #1 - rendered = pieces["short"] - if pieces["dirty"]: - rendered += "-dirty" - return rendered - - -def render(pieces, style): - """Render the given version pieces into the requested style.""" - if pieces["error"]: - return { - "version": "unknown", - "full-revisionid": pieces.get("long"), - "dirty": None, - "error": pieces["error"], - "date": None, - } - - if not style or style == "default": - style = "pep440" # the default - - if style == "pep440": - rendered = render_pep440(pieces) - elif style == "pep440-pre": - rendered = render_pep440_pre(pieces) - elif style == "pep440-post": - rendered = render_pep440_post(pieces) - elif style == "pep440-old": - rendered = render_pep440_old(pieces) - elif style == "git-describe": - rendered = render_git_describe(pieces) - elif style == "git-describe-long": - rendered = render_git_describe_long(pieces) - else: - raise ValueError("unknown style '%s'" % style) - - return { - "version": rendered, - "full-revisionid": pieces["long"], - "dirty": pieces["dirty"], - "error": None, - "date": pieces.get("date"), - } - - -class VersioneerBadRootError(Exception): - """The project root directory is unknown or missing key files.""" - - -def get_versions(verbose=False): - """Get the project version from whatever source is available. - - Returns dict with two keys: 'version' and 'full'. - """ - if "versioneer" in sys.modules: - # see the discussion in cmdclass.py:get_cmdclass() - del sys.modules["versioneer"] - - root = get_root() - cfg = get_config_from_root(root) - - assert cfg.VCS is not None, "please set [versioneer]VCS= in setup.cfg" - handlers = HANDLERS.get(cfg.VCS) - assert handlers, "unrecognized VCS '%s'" % cfg.VCS - verbose = verbose or cfg.verbose - assert ( - cfg.versionfile_source is not None - ), "please set versioneer.versionfile_source" - assert cfg.tag_prefix is not None, "please set versioneer.tag_prefix" - - versionfile_abs = os.path.join(root, cfg.versionfile_source) - - # extract version from first of: _version.py, VCS command (e.g. 'git - # describe'), parentdir. This is meant to work for developers using a - # source checkout, for users of a tarball created by 'setup.py sdist', - # and for users of a tarball/zipball created by 'git archive' or github's - # download-from-tag feature or the equivalent in other VCSes. - - get_keywords_f = handlers.get("get_keywords") - from_keywords_f = handlers.get("keywords") - if get_keywords_f and from_keywords_f: - try: - keywords = get_keywords_f(versionfile_abs) - ver = from_keywords_f(keywords, cfg.tag_prefix, verbose) - if verbose: - print("got version from expanded keyword %s" % ver) - return ver - except NotThisMethod: - pass - - try: - ver = versions_from_file(versionfile_abs) - if verbose: - print("got version from file %s %s" % (versionfile_abs, ver)) - return ver - except NotThisMethod: - pass - - from_vcs_f = handlers.get("pieces_from_vcs") - if from_vcs_f: - try: - pieces = from_vcs_f(cfg.tag_prefix, root, verbose) - ver = render(pieces, cfg.style) - if verbose: - print("got version from VCS %s" % ver) - return ver - except NotThisMethod: - pass - - try: - if cfg.parentdir_prefix: - ver = versions_from_parentdir(cfg.parentdir_prefix, root, verbose) - if verbose: - print("got version from parentdir %s" % ver) - return ver - except NotThisMethod: - pass - - if verbose: - print("unable to compute version") - - return { - "version": "0+unknown", - "full-revisionid": None, - "dirty": None, - "error": "unable to compute version", - "date": None, - } - - -def get_version(): - """Get the short version string for this project.""" - return get_versions()["version"] - - -def get_cmdclass(): - """Get the custom setuptools/distutils subclasses used by Versioneer.""" - if "versioneer" in sys.modules: - del sys.modules["versioneer"] - # this fixes the "python setup.py develop" case (also 'install' and - # 'easy_install .'), in which subdependencies of the main project are - # built (using setup.py bdist_egg) in the same python process. Assume - # a main project A and a dependency B, which use different versions - # of Versioneer. A's setup.py imports A's Versioneer, leaving it in - # sys.modules by the time B's setup.py is executed, causing B to run - # with the wrong versioneer. Setuptools wraps the sub-dep builds in a - # sandbox that restores sys.modules to it's pre-build state, so the - # parent is protected against the child's "import versioneer". By - # removing ourselves from sys.modules here, before the child build - # happens, we protect the child from the parent's versioneer too. - # Also see https://github.com/warner/python-versioneer/issues/52 - - cmds = {} - - # we add "version" to both distutils and setuptools - from distutils.core import Command - - class cmd_version(Command): - description = "report generated version string" - user_options = [] - boolean_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - vers = get_versions(verbose=True) - print("Version: %s" % vers["version"]) - print(" full-revisionid: %s" % vers.get("full-revisionid")) - print(" dirty: %s" % vers.get("dirty")) - print(" date: %s" % vers.get("date")) - if vers["error"]: - print(" error: %s" % vers["error"]) - - cmds["version"] = cmd_version - - # we override "build_py" in both distutils and setuptools - # - # most invocation pathways end up running build_py: - # distutils/build -> build_py - # distutils/install -> distutils/build ->.. - # setuptools/bdist_wheel -> distutils/install ->.. - # setuptools/bdist_egg -> distutils/install_lib -> build_py - # setuptools/install -> bdist_egg ->.. - # setuptools/develop -> ? - # pip install: - # copies source tree to a tempdir before running egg_info/etc - # if .git isn't copied too, 'git describe' will fail - # then does setup.py bdist_wheel, or sometimes setup.py install - # setup.py egg_info -> ? - - # we override different "build_py" commands for both environments - if "setuptools" in sys.modules: - from setuptools.command.build_py import build_py as _build_py - else: - from distutils.command.build_py import build_py as _build_py - - class cmd_build_py(_build_py): - def run(self): - root = get_root() - cfg = get_config_from_root(root) - versions = get_versions() - _build_py.run(self) - # now locate _version.py in the new build/ directory and replace - # it with an updated value - if cfg.versionfile_build: - target_versionfile = os.path.join( - self.build_lib, cfg.versionfile_build - ) - print("UPDATING %s" % target_versionfile) - write_to_version_file(target_versionfile, versions) - - cmds["build_py"] = cmd_build_py - - if "cx_Freeze" in sys.modules: # cx_freeze enabled? - from cx_Freeze.dist import build_exe as _build_exe - - # nczeczulin reports that py2exe won't like the pep440-style string - # as FILEVERSION, but it can be used for PRODUCTVERSION, e.g. - # setup(console=[{ - # "version": versioneer.get_version().split("+", 1)[0], # FILEVERSION - # "product_version": versioneer.get_version(), - # ... - - class cmd_build_exe(_build_exe): - def run(self): - root = get_root() - cfg = get_config_from_root(root) - versions = get_versions() - target_versionfile = cfg.versionfile_source - print("UPDATING %s" % target_versionfile) - write_to_version_file(target_versionfile, versions) - - _build_exe.run(self) - os.unlink(target_versionfile) - with open(cfg.versionfile_source, "w") as f: - LONG = LONG_VERSION_PY[cfg.VCS] - f.write( - LONG - % { - "DOLLAR": "$", - "STYLE": cfg.style, - "TAG_PREFIX": cfg.tag_prefix, - "PARENTDIR_PREFIX": cfg.parentdir_prefix, - "VERSIONFILE_SOURCE": cfg.versionfile_source, - } - ) - - cmds["build_exe"] = cmd_build_exe - del cmds["build_py"] - - if "py2exe" in sys.modules: # py2exe enabled? - try: - from py2exe.distutils_buildexe import py2exe as _py2exe # py3 - except ImportError: - from py2exe.build_exe import py2exe as _py2exe # py2 - - class cmd_py2exe(_py2exe): - def run(self): - root = get_root() - cfg = get_config_from_root(root) - versions = get_versions() - target_versionfile = cfg.versionfile_source - print("UPDATING %s" % target_versionfile) - write_to_version_file(target_versionfile, versions) - - _py2exe.run(self) - os.unlink(target_versionfile) - with open(cfg.versionfile_source, "w") as f: - LONG = LONG_VERSION_PY[cfg.VCS] - f.write( - LONG - % { - "DOLLAR": "$", - "STYLE": cfg.style, - "TAG_PREFIX": cfg.tag_prefix, - "PARENTDIR_PREFIX": cfg.parentdir_prefix, - "VERSIONFILE_SOURCE": cfg.versionfile_source, - } - ) - - cmds["py2exe"] = cmd_py2exe - - # we override different "sdist" commands for both environments - if "setuptools" in sys.modules: - from setuptools.command.sdist import sdist as _sdist - else: - from distutils.command.sdist import sdist as _sdist - - class cmd_sdist(_sdist): - def run(self): - versions = get_versions() - self._versioneer_generated_versions = versions - # unless we update this, the command will keep using the old - # version - self.distribution.metadata.version = versions["version"] - return _sdist.run(self) - - def make_release_tree(self, base_dir, files): - root = get_root() - cfg = get_config_from_root(root) - _sdist.make_release_tree(self, base_dir, files) - # now locate _version.py in the new base_dir directory - # (remembering that it may be a hardlink) and replace it with an - # updated value - target_versionfile = os.path.join(base_dir, cfg.versionfile_source) - print("UPDATING %s" % target_versionfile) - write_to_version_file( - target_versionfile, self._versioneer_generated_versions - ) - - cmds["sdist"] = cmd_sdist - - return cmds - - -CONFIG_ERROR = """ -setup.cfg is missing the necessary Versioneer configuration. You need -a section like: - - [versioneer] - VCS = git - style = pep440 - versionfile_source = src/myproject/_version.py - versionfile_build = myproject/_version.py - tag_prefix = - parentdir_prefix = myproject- - -You will also need to edit your setup.py to use the results: - - import versioneer - setup(version=versioneer.get_version(), - cmdclass=versioneer.get_cmdclass(), ...) - -Please read the docstring in ./versioneer.py for configuration instructions, -edit setup.cfg, and re-run the installer or 'python versioneer.py setup'. -""" - -SAMPLE_CONFIG = """ -# See the docstring in versioneer.py for instructions. Note that you must -# re-run 'versioneer.py setup' after changing this section, and commit the -# resulting files. - -[versioneer] -#VCS = git -#style = pep440 -#versionfile_source = -#versionfile_build = -#tag_prefix = -#parentdir_prefix = - -""" - -INIT_PY_SNIPPET = """ -from cudf._version import get_versions -__version__ = get_versions()['version'] -del get_versions -""" - - -def do_setup(): - """Main VCS-independent setup function for installing Versioneer.""" - root = get_root() - try: - cfg = get_config_from_root(root) - except ( - EnvironmentError, - configparser.NoSectionError, - configparser.NoOptionError, - ) as e: - if isinstance(e, (EnvironmentError, configparser.NoSectionError)): - print( - "Adding sample versioneer config to setup.cfg", file=sys.stderr - ) - with open(os.path.join(root, "setup.cfg"), "a") as f: - f.write(SAMPLE_CONFIG) - print(CONFIG_ERROR, file=sys.stderr) - return 1 - - print(" creating %s" % cfg.versionfile_source) - with open(cfg.versionfile_source, "w") as f: - LONG = LONG_VERSION_PY[cfg.VCS] - f.write( - LONG - % { - "DOLLAR": "$", - "STYLE": cfg.style, - "TAG_PREFIX": cfg.tag_prefix, - "PARENTDIR_PREFIX": cfg.parentdir_prefix, - "VERSIONFILE_SOURCE": cfg.versionfile_source, - } - ) - - ipy = os.path.join(os.path.dirname(cfg.versionfile_source), "__init__.py") - if os.path.exists(ipy): - try: - with open(ipy, "r") as f: - old = f.read() - except EnvironmentError: - old = "" - if INIT_PY_SNIPPET not in old: - print(" appending to %s" % ipy) - with open(ipy, "a") as f: - f.write(INIT_PY_SNIPPET) - else: - print(" %s unmodified" % ipy) - else: - print(" %s doesn't exist, ok" % ipy) - ipy = None - - # Make sure both the top-level "versioneer.py" and versionfile_source - # (PKG/_version.py, used by runtime code) are in MANIFEST.in, so - # they'll be copied into source distributions. Pip won't be able to - # install the package without this. - manifest_in = os.path.join(root, "MANIFEST.in") - simple_includes = set() - try: - with open(manifest_in, "r") as f: - for line in f: - if line.startswith("include "): - for include in line.split()[1:]: - simple_includes.add(include) - except EnvironmentError: - pass - # That doesn't cover everything MANIFEST.in can do - # (http://docs.python.org/2/distutils/sourcedist.html#commands), so - # it might give some false negatives. Appending redundant 'include' - # lines is safe, though. - if "versioneer.py" not in simple_includes: - print(" appending 'versioneer.py' to MANIFEST.in") - with open(manifest_in, "a") as f: - f.write("include versioneer.py\n") - else: - print(" 'versioneer.py' already in MANIFEST.in") - if cfg.versionfile_source not in simple_includes: - print( - " appending versionfile_source ('%s') to MANIFEST.in" - % cfg.versionfile_source - ) - with open(manifest_in, "a") as f: - f.write("include %s\n" % cfg.versionfile_source) - else: - print(" versionfile_source already in MANIFEST.in") - - # Make VCS-specific changes. For git, this means creating/changing - # .gitattributes to mark _version.py for export-subst keyword - # substitution. - do_vcs_install(manifest_in, cfg.versionfile_source, ipy) - return 0 - - -def scan_setup_py(): - """Validate the contents of setup.py against Versioneer's expectations.""" - found = set() - setters = False - errors = 0 - with open("setup.py", "r") as f: - for line in f.readlines(): - if "import versioneer" in line: - found.add("import") - if "versioneer.get_cmdclass()" in line: - found.add("cmdclass") - if "versioneer.get_version()" in line: - found.add("get_version") - if "versioneer.VCS" in line: - setters = True - if "versioneer.versionfile_source" in line: - setters = True - if len(found) != 3: - print("") - print("Your setup.py appears to be missing some important items") - print("(but I might be wrong). Please make sure it has something") - print("roughly like the following:") - print("") - print(" import versioneer") - print(" setup( version=versioneer.get_version(),") - print(" cmdclass=versioneer.get_cmdclass(), ...)") - print("") - errors += 1 - if setters: - print("You should remove lines like 'versioneer.VCS = ' and") - print("'versioneer.versionfile_source = ' . This configuration") - print("now lives in setup.cfg, and should be removed from setup.py") - print("") - errors += 1 - return errors - - -if __name__ == "__main__": - cmd = sys.argv[1] - if cmd == "setup": - errors = do_setup() - errors += scan_setup_py() - if errors: - sys.exit(1) From 0cdd0ba2af8f6f5c7093588aeb8bb45288cb5c0b Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Fri, 17 Feb 2023 09:54:40 -0600 Subject: [PATCH 220/675] Skip docs job in nightly runs (#1215) This PR configures the branch workflow to skip the docs job during nightly runs. Authors: - Jake Awe (https://github.com/AyodeAwe) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1215 --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 31a1bd35f..37e928e01 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -53,7 +53,7 @@ jobs: date: ${{ inputs.date }} sha: ${{ inputs.sha }} docs-build: - if: ${{ startsWith(github.ref, 'refs/heads/branch-') }} + if: github.ref_type == 'branch' && github.event_name == 'push' needs: python-build secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.04 From 0fd9626b00a666725b0b5310e53e07ff5bf4bf77 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 17 Feb 2023 10:49:58 -0800 Subject: [PATCH 221/675] Use script rather than environment variable to modify package names (#1212) The package name defined in setup.py needs to be modified for wheels to reflect the CUDA version that the wheel was built for. Currently that modification is done via an environment variable that is pulled in setup.py code. This changeset replaces that approach with a direct modification using a script (similar to what is done for versions in #1190) to facilitate moving towards static project metadata specification via pyproject.toml. This PR depends on https://github.com/rapidsai/shared-action-workflows/pull/45. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Sevag H (https://github.com/sevagh) - Ashwin Srinath (https://github.com/shwina) URL: https://github.com/rapidsai/rmm/pull/1212 --- .github/workflows/build.yaml | 2 +- .github/workflows/pr.yaml | 2 +- ci/release/apply_wheel_modifications.sh | 3 +++ python/setup.py | 4 +--- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 37e928e01..e5256cfe0 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -74,7 +74,7 @@ jobs: package-name: rmm package-dir: python skbuild-configure-options: "-DRMM_BUILD_WHEELS=ON" - uses-versioneer: false + uses-setup-env-vars: false wheel-publish: needs: wheel-build secrets: inherit diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 858c02691..240344bc1 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -68,7 +68,7 @@ jobs: package-dir: python package-name: rmm skbuild-configure-options: "-DRMM_BUILD_WHEELS=ON" - uses-versioneer: false + uses-setup-env-vars: false wheel-tests: needs: wheel-build secrets: inherit diff --git a/ci/release/apply_wheel_modifications.sh b/ci/release/apply_wheel_modifications.sh index aad6ae84f..c981cd162 100755 --- a/ci/release/apply_wheel_modifications.sh +++ b/ci/release/apply_wheel_modifications.sh @@ -4,6 +4,9 @@ # Usage: bash apply_wheel_modifications.sh VERSION=${1} +CUDA_SUFFIX=${2} sed -i "s/__version__ = .*/__version__ = \"${VERSION}\"/g" python/rmm/__init__.py sed -i "s/version=.*,/version=\"${VERSION}\",/g" python/setup.py + +sed -i "s/name=\"rmm\",/name=\"rmm${CUDA_SUFFIX}\",/g" python/setup.py diff --git a/python/setup.py b/python/setup.py index a60f87e75..221908184 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,12 +1,10 @@ # Copyright (c) 2019-2022, NVIDIA CORPORATION. -import os - from setuptools import find_packages from skbuild import setup setup( - name="rmm" + os.getenv("RAPIDS_PY_WHEEL_CUDA_SUFFIX", default=""), + name="rmm", version="23.04.00", description="rmm - RAPIDS Memory Manager", url="https://github.com/rapidsai/rmm", From f3113d9eb13d0795937dd3dd33a64c794f1a3661 Mon Sep 17 00:00:00 2001 From: Carl Simon Adorf Date: Tue, 21 Feb 2023 19:15:07 +0100 Subject: [PATCH 222/675] CI: Remove specification of manual stage for check_style.sh script. (#1214) Do not explicitly specify to run the "manual" stage when running pre-commits as part of the ci/check_style.sh script. Authors: - Carl Simon Adorf (https://github.com/csadorf) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1214 --- ci/check_style.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/check_style.sh b/ci/check_style.sh index f073ff969..f9bfea7b4 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -20,4 +20,4 @@ mkdir -p $(dirname ${RAPIDS_CMAKE_FORMAT_FILE}) wget -O ${RAPIDS_CMAKE_FORMAT_FILE} ${FORMAT_FILE_URL} # Run pre-commit checks -pre-commit run --hook-stage manual --all-files --show-diff-on-failure +pre-commit run --all-files --show-diff-on-failure From ebf591ffc2fd7b83605f5725ec6e8ba425858c02 Mon Sep 17 00:00:00 2001 From: jakirkham Date: Wed, 22 Feb 2023 10:50:56 -0800 Subject: [PATCH 223/675] Migrate as much as possible to `pyproject.toml` (#1151) * Adds `tomli` dependency for Python pre-3.11 * Moves package data handling to `MANIFEST.in` * Symlinks and packages README * Specifies build backend & moves to newer `setuptools` backend * Pulls all metadata into `pyproject.toml` * Migrates `setup.cfg` content to `pyproject.toml` * Simplifies `setup.py` to the minimal amount of logic necessary Authors: - https://github.com/jakirkham - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1151 --- .pre-commit-config.yaml | 4 +- ci/release/apply_wheel_modifications.sh | 6 +- .../all_cuda-118_arch-x86_64.yaml | 1 + conda/recipes/rmm/meta.yaml | 3 +- dependencies.yaml | 1 + python/{setup.cfg => .flake8} | 38 +-------- python/MANIFEST.in | 13 ++++ python/README.md | 1 + python/pyproject.toml | 78 ++++++++++++++++++- python/setup.py | 35 --------- 10 files changed, 99 insertions(+), 81 deletions(-) rename python/{setup.cfg => .flake8} (65%) create mode 100644 python/MANIFEST.in create mode 120000 python/README.md diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9d60da84c..55bdfd884 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ repos: rev: 5.12.0 hooks: - id: isort - args: ["--config-root=python/", "--resolve-all-configs"] + args: ["--settings-path=python/pyproject.toml"] files: python/.* types_or: [python, cython, pyi] - repo: https://github.com/ambv/black @@ -21,7 +21,7 @@ repos: rev: 5.0.4 hooks: - id: flake8 - args: ["--config=python/setup.cfg"] + args: ["--config=python/.flake8"] files: python/.*$ types: [file] types_or: [python, cython] diff --git a/ci/release/apply_wheel_modifications.sh b/ci/release/apply_wheel_modifications.sh index c981cd162..90472d869 100755 --- a/ci/release/apply_wheel_modifications.sh +++ b/ci/release/apply_wheel_modifications.sh @@ -1,12 +1,12 @@ #!/bin/bash # Copyright (c) 2023, NVIDIA CORPORATION. # -# Usage: bash apply_wheel_modifications.sh +# Usage: bash apply_wheel_modifications.sh VERSION=${1} CUDA_SUFFIX=${2} sed -i "s/__version__ = .*/__version__ = \"${VERSION}\"/g" python/rmm/__init__.py -sed -i "s/version=.*,/version=\"${VERSION}\",/g" python/setup.py +sed -i "s/^version = .*/version = \"${VERSION}\"/g" python/pyproject.toml -sed -i "s/name=\"rmm\",/name=\"rmm${CUDA_SUFFIX}\",/g" python/setup.py +sed -i "s/^name = \"rmm\"/name = \"rmm${CUDA_SUFFIX}\"/g" python/pyproject.toml diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 499f5dbec..a001756a2 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -19,4 +19,5 @@ dependencies: - python>=3.8,<3.11 - scikit-build>=0.13.1 - spdlog>=1.11.0,<1.12 +- tomli name: all_cuda-118_arch-x86_64 diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 7cf116dc0..b816e24c5 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -46,7 +46,8 @@ requirements: - librmm ={{ version }} - python - scikit-build >=0.13.1 - - setuptools + - setuptools >=61.0.0 + - tomli # [py<311] run: - cuda-python >=11.7.1,<12.0 - numba >=0.49 diff --git a/dependencies.yaml b/dependencies.yaml index 879892ba3..e6fde1b98 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -47,6 +47,7 @@ dependencies: - ninja - python>=3.8,<3.11 - scikit-build>=0.13.1 + - tomli - output_types: conda packages: - fmt>=9.1.0,<10 diff --git a/python/setup.cfg b/python/.flake8 similarity index 65% rename from python/setup.cfg rename to python/.flake8 index d5b0510b1..4d610ba8e 100644 --- a/python/setup.cfg +++ b/python/.flake8 @@ -1,5 +1,4 @@ -# Copyright (c) 2018-2021, NVIDIA CORPORATION. - +# Copyright (c) 2023, NVIDIA CORPORATION. [flake8] filename = *.py, *.pyx, *.pxd, *.pxi @@ -23,38 +22,3 @@ per-file-ignores = *.pyx: E211, E225, E226, E227, E275, E402, E999, W504 *.pxd: E211, E225, E226, E227, E275, E402, E999, W504 *.pxi: E211, E225, E226, E227, E275, E402, E999, W504 - -[isort] -line_length=79 -multi_line_output=3 -include_trailing_comma=True -force_grid_wrap=0 -combine_as_imports=True -order_by_type=True -known_dask= - dask - distributed - dask_cuda -known_rapids= - nvtext - cudf - cuml - cugraph - dask_cudf -known_first_party= - rmm -default_section=THIRDPARTY -sections=FUTURE,STDLIB,THIRDPARTY,DASK,RAPIDS,FIRSTPARTY,LOCALFOLDER -skip= - thirdparty - .eggs - .git - .hg - .mypy_cache - .tox - .venv - _build - buck-out - build - dist - __init__.py diff --git a/python/MANIFEST.in b/python/MANIFEST.in new file mode 100644 index 000000000..708e097ed --- /dev/null +++ b/python/MANIFEST.in @@ -0,0 +1,13 @@ +# Cython files +recursive-include rmm *.pxd +recursive-include rmm *.pyx + +# Build files. Don't use a recursive include on '.' in case the repo is dirty +include . CMakeLists.txt +recursive-include rmm CMakeLists.txt + +# License +include LICENSE + +# README +include README diff --git a/python/README.md b/python/README.md new file mode 120000 index 000000000..32d46ee88 --- /dev/null +++ b/python/README.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file diff --git a/python/pyproject.toml b/python/pyproject.toml index 0d4cfea09..e05a2e73d 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -13,17 +13,52 @@ # limitations under the License. [build-system] - +build-backend = "setuptools.build_meta" requires = [ "wheel", - "setuptools", + "setuptools>=61.0.0", "cython>=0.29,<0.30", "scikit-build>=0.13.1", "cmake>=3.23.1,!=3.25.0", "ninja", - "cuda-python>=11.7.1,<12.0" + "cuda-python>=11.7.1,<12.0", + "tomli; python_version < '3.11'", +] + +[project] +name = "rmm" +version = "23.04.00" +description = "rmm - RAPIDS Memory Manager" +readme = { file = "README.md", content-type = "text/markdown" } +authors = [ + { name = "NVIDIA Corporation" }, +] +license = { text = "Apache 2.0" } +requires-python = ">=3.8" +dependencies = [ + "cuda-python>=11.7.1,<12.0", + "numpy>=1.19", + "numba>=0.49", +] +classifiers = [ + "Intended Audience :: Developers", + "Topic :: Database", + "Topic :: Scientific/Engineering", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.10", +] + +[project.optional-dependencies] +test = [ + "pytest", + "pytest-xdist", ] +[project.urls] +Homepage = "https://github.com/rapidsai/rmm" + [tool.black] line-length = 79 target-version = ["py38"] @@ -43,3 +78,40 @@ exclude = ''' dist )/ ''' + +[tool.isort] +line_length = 79 +multi_line_output = 3 +include_trailing_comma = true +force_grid_wrap = 0 +combine_as_imports = true +order_by_type = true +known_first_party = [ + "rmm", +] +default_section = "THIRDPARTY" +sections = [ + "FUTURE", + "STDLIB", + "THIRDPARTY", + "FIRSTPARTY", + "LOCALFOLDER", +] +skip = [ + "thirdparty", + ".eggs", + ".git", + ".hg", + ".mypy_cache", + ".tox", + ".venv", + "_build", + "buck-out", + "build", + "dist", + "__init__.py", +] + +[tool.setuptools] +license-files = ["LICENSE"] +zip-safe = false diff --git a/python/setup.py b/python/setup.py index 221908184..bf60268a6 100644 --- a/python/setup.py +++ b/python/setup.py @@ -4,40 +4,5 @@ from skbuild import setup setup( - name="rmm", - version="23.04.00", - description="rmm - RAPIDS Memory Manager", - url="https://github.com/rapidsai/rmm", - author="NVIDIA Corporation", - license="Apache 2.0", - classifiers=[ - "Intended Audience :: Developers", - "Topic :: Database", - "Topic :: Scientific/Engineering", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - ], - # Include the separately-compiled shared library - extras_require={"test": ["pytest"]}, packages=find_packages(include=["rmm", "rmm.*"]), - include_package_data=True, - python_requires=">=3.8", - package_data={ - # Note: A dict comprehension with an explicit copy is necessary (rather - # than something simpler like a dict.fromkeys) because otherwise every - # package will refer to the same list and skbuild modifies it in place. - key: ["*.hpp", "*.pxd"] - for key in find_packages( - include=["rmm._lib", "rmm._lib.includes", "rmm._cuda*"] - ) - }, - install_requires=[ - "cuda-python>=11.7.1,<12.0", - "numpy>=1.19", - "numba>=0.49", - ], - zip_safe=False, ) From c085cdb7b61a2fb88657303bc2e7f509b235a3ec Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 22 Feb 2023 14:07:25 -0800 Subject: [PATCH 224/675] Specify include_package_data to setup (#1218) For pure setuptools-based builds, the `include_package_data` option historically defaulted to False. With newer projects, i.e. with projects containing a pyproject.toml file, it defaults to True. However, for projects using scikit-build this setting must be provided explicitly to the `setup` function (not in the config file) to allow scikit-build to intercept the argument and use it in the preprocessing it does before invoking `setuptools.setup`. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - https://github.com/jakirkham URL: https://github.com/rapidsai/rmm/pull/1218 --- python/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/setup.py b/python/setup.py index bf60268a6..1572a4894 100644 --- a/python/setup.py +++ b/python/setup.py @@ -5,4 +5,5 @@ setup( packages=find_packages(include=["rmm", "rmm.*"]), + include_package_data=True, ) From fd6cddef368427e0d7e69f1384968b18fc77ffdc Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 24 Feb 2023 14:58:24 -0800 Subject: [PATCH 225/675] Fix some minor oversights in the conversion to pyproject.toml (#1226) There were a couple of issues that accidentally made it through in #1151. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1226 --- python/MANIFEST.in | 6 ------ python/pyproject.toml | 1 - python/setup.py | 1 + 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/python/MANIFEST.in b/python/MANIFEST.in index 708e097ed..0a521fd9e 100644 --- a/python/MANIFEST.in +++ b/python/MANIFEST.in @@ -5,9 +5,3 @@ recursive-include rmm *.pyx # Build files. Don't use a recursive include on '.' in case the repo is dirty include . CMakeLists.txt recursive-include rmm CMakeLists.txt - -# License -include LICENSE - -# README -include README diff --git a/python/pyproject.toml b/python/pyproject.toml index e05a2e73d..873e21445 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -114,4 +114,3 @@ skip = [ [tool.setuptools] license-files = ["LICENSE"] -zip-safe = false diff --git a/python/setup.py b/python/setup.py index 1572a4894..64d8524e3 100644 --- a/python/setup.py +++ b/python/setup.py @@ -6,4 +6,5 @@ setup( packages=find_packages(include=["rmm", "rmm.*"]), include_package_data=True, + zip_safe=False, ) From ef997db9193d6a9d5b9583f123451d44e3340169 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 24 Feb 2023 15:29:56 -0800 Subject: [PATCH 226/675] Run rapids-dependency-file-generator via pre-commit (#1217) This feature is enabled by the most recent release of dfg. This changes also allows us to disable the dfg CI check as it is now redundant. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1217 --- .github/workflows/pr.yaml | 2 ++ .pre-commit-config.yaml | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 240344bc1..eb3607c8c 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -25,6 +25,8 @@ jobs: checks: secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.04 + with: + enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 55bdfd884..261c57b27 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,15 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer + - repo: https://github.com/rapidsai/dependency-file-generator + rev: v1.4.0 + hooks: + - id: rapids-dependency-file-generator + args: ["--clean"] - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: From 1a75350e04649edd9b7a8186f5f600c7a66b4972 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Mon, 27 Feb 2023 20:21:32 +0000 Subject: [PATCH 227/675] Move external allocators into rmm.allocators module to defer imports (#1221) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RMM provides callbacks to configure third-party libraries to use RMM for memory allocation. Previously, these were defined in the top-level package, but that requires (potentially expensive) import of the package we're providing a hook for, since typically we must import that package to define the callback. This makes importing RMM expensive. To avoid this, move the callbacks into (not imported by default) sub-modules in `rmm.allocators`. So, if we want to configure the CuPy allocator, we now import `rmm_cupy_allocator` from `rmm.allocators.cupy`, and don't pay the price of importing pytorch. This change **deprecates** the use of the allocator callbacks in the top-level `rmm` module in favour of explicit imports from the relevant `rmm.allocators.XXX` sub-module. Before these changes, a sampling trace of `import rmm` with pyinstrument shows: $ pyinstrument -i 0.01 importrmm.py _ ._ __/__ _ _ _ _ _/_ Recorded: 10:19:56 Samples: 67 /_//_/// /_\ / //_// / //_'/ // Duration: 0.839 CPU time: 0.837 / _/ v4.4.0 Program: importrmm.py 0.839 importrmm.py:1 └─ 0.839 rmm/__init__.py:1 ├─ 0.315 rmm/allocators/torch.py:1 │ └─ 0.315 torch/__init__.py:1 │ [96 frames hidden] torch, , enum, inspect, tok... ├─ 0.297 rmm/mr.py:1 │ └─ 0.297 rmm/_lib/__init__.py:1 │ ├─ 0.216 numba/__init__.py:1 │ │ [140 frames hidden] numba, abc, , importlib, em... │ ├─ 0.040 numba/cuda/__init__.py:1 │ │ [34 frames hidden] numba, asyncio, ssl, , re, ... │ ├─ 0.030 __new__ enum.py:180 │ │ [5 frames hidden] enum, │ └─ 0.011 [self] None └─ 0.227 rmm/allocators/cupy.py:1 └─ 0.227 cupy/__init__.py:1 [123 frames hidden] cupy, pytest, _pytest, attr, importrmm.py:1 └─ 0.099 rmm/__init__.py:1 └─ 0.099 rmm/mr.py:1 └─ 0.099 rmm/_lib/__init__.py:1 ├─ 0.059 numpy/__init__.py:1 │ [31 frames hidden] numpy, re, sre_compile, , s... ├─ 0.020 __new__ enum.py:180 │ [2 frames hidden] enum ├─ 0.010 ctypes/__init__.py:1 │ [3 frames hidden] ctypes, └─ 0.010 _EnumDict.__setitem__ enum.py:89 [3 frames hidden] enum Closes #1211. Authors: - Lawrence Mitchell (https://github.com/wence-) - Bradley Dice (https://github.com/bdice) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1221 --- README.md | 18 +-- python/docs/api.rst | 18 +++ python/docs/basics.md | 38 +++++-- python/rmm/__init__.py | 34 +++++- python/rmm/_cuda/gpu.py | 3 +- python/rmm/_cuda/stream.pyx | 22 ++-- python/rmm/allocators/__init__.py | 0 python/rmm/allocators/cupy.py | 44 ++++++++ python/rmm/allocators/numba.py | 125 +++++++++++++++++++++ python/rmm/allocators/torch.py | 26 +++++ python/rmm/rmm.py | 162 +-------------------------- python/rmm/tests/test_rmm.py | 18 +-- python/rmm/tests/test_rmm_pytorch.py | 4 +- 13 files changed, 311 insertions(+), 201 deletions(-) create mode 100644 python/rmm/allocators/__init__.py create mode 100644 python/rmm/allocators/cupy.py create mode 100644 python/rmm/allocators/numba.py create mode 100644 python/rmm/allocators/torch.py diff --git a/README.md b/README.md index 2f6d54a64..a05ffa5e5 100644 --- a/README.md +++ b/README.md @@ -691,6 +691,8 @@ resources MemoryResources are highly configurable and can be composed together in different ways. See `help(rmm.mr)` for more information. +## Using RMM with third-party libraries + ### Using RMM with CuPy You can configure [CuPy](https://cupy.dev/) to use RMM for memory @@ -698,9 +700,9 @@ allocations by setting the CuPy CUDA allocator to `rmm_cupy_allocator`: ```python ->>> import rmm +>>> from rmm.allocators.cupy import rmm_cupy_allocator >>> import cupy ->>> cupy.cuda.set_allocator(rmm.rmm_cupy_allocator) +>>> cupy.cuda.set_allocator(rmm_cupy_allocator) ``` @@ -718,15 +720,15 @@ This can be done in two ways: 1. Setting the environment variable `NUMBA_CUDA_MEMORY_MANAGER`: ```python - $ NUMBA_CUDA_MEMORY_MANAGER=rmm python (args) + $ NUMBA_CUDA_MEMORY_MANAGER=rmm.allocators.numba python (args) ``` 2. Using the `set_memory_manager()` function provided by Numba: ```python >>> from numba import cuda - >>> import rmm - >>> cuda.set_memory_manager(rmm.RMMNumbaManager) + >>> from rmm.allocators.numba import RMMNumbaManager + >>> cuda.set_memory_manager(RMMNumbaManager) ``` **Note:** This only configures Numba to use the current RMM resource for allocations. @@ -741,10 +743,11 @@ RMM-managed pool: ```python import rmm +from rmm.allocators.torch import rmm_torch_allocator import torch rmm.reinitialize(pool_allocator=True) -torch.cuda.memory.change_current_allocator(rmm.rmm_torch_allocator) +torch.cuda.memory.change_current_allocator(rmm_torch_allocator) ``` PyTorch and RMM will now share the same memory pool. @@ -753,13 +756,14 @@ You can, of course, use a custom memory resource with PyTorch as well: ```python import rmm +from rmm.allocators.torch import rmm_torch_allocator import torch # note that you can configure PyTorch to use RMM either before or # after changing RMM's memory resource. PyTorch will use whatever # memory resource is configured to be the "current" memory resource at # the time of allocation. -torch.cuda.change_current_allocator(rmm.rmm_torch_allocator) +torch.cuda.change_current_allocator(rmm_torch_allocator) # configure RMM to use a managed memory resource, wrapped with a # statistics resource adaptor that can report information about the diff --git a/python/docs/api.rst b/python/docs/api.rst index ebc68c354..73cd5dd81 100644 --- a/python/docs/api.rst +++ b/python/docs/api.rst @@ -17,3 +17,21 @@ Memory Resources :members: :undoc-members: :show-inheritance: + +Memory Allocators +----------------- + +.. automodule:: rmm.allocators.cupy + :members: + :undoc-members: + :show-inheritance: + +.. automodule:: rmm.allocators.numba + :members: + :undoc-members: + :show-inheritance: + +.. automodule:: rmm.allocators.torch + :members: + :undoc-members: + :show-inheritance: diff --git a/python/docs/basics.md b/python/docs/basics.md index 368145b3d..0c47073c1 100644 --- a/python/docs/basics.md +++ b/python/docs/basics.md @@ -131,21 +131,31 @@ resources MemoryResources are highly configurable and can be composed together in different ways. See `help(rmm.mr)` for more information. +## Using RMM with third-party libraries + +A number of libraries provide hooks to control their device +allocations. RMM provides implementations of these for +[CuPy](https://cupy.dev), +[numba](https://numba.readthedocs.io/en/stable/), and [PyTorch](https://pytorch.org) in the +`rmm.allocators` submodule. All these approaches configure the library +to use the _current_ RMM memory resource for device +allocations. + ### Using RMM with CuPy You can configure [CuPy](https://cupy.dev/) to use RMM for memory allocations by setting the CuPy CUDA allocator to -`rmm_cupy_allocator`: +`rmm.allocators.cupy.rmm_cupy_allocator`: ```python ->>> import rmm +>>> from rmm.allocators.cupy import rmm_cupy_allocator >>> import cupy ->>> cupy.cuda.set_allocator(rmm.rmm_cupy_allocator) +>>> cupy.cuda.set_allocator(rmm_cupy_allocator) ``` ### Using RMM with Numba -You can configure Numba to use RMM for memory allocations using the +You can configure [Numba](https://numba.readthedocs.io/en/stable/) to use RMM for memory allocations using the Numba [EMM Plugin](https://numba.readthedocs.io/en/stable/cuda/external-memory.html#setting-emm-plugin). This can be done in two ways: @@ -153,13 +163,27 @@ This can be done in two ways: 1. Setting the environment variable `NUMBA_CUDA_MEMORY_MANAGER`: ```bash - $ NUMBA_CUDA_MEMORY_MANAGER=rmm python (args) + $ NUMBA_CUDA_MEMORY_MANAGER=rmm.allocators.numba python (args) ``` 2. Using the `set_memory_manager()` function provided by Numba: ```python >>> from numba import cuda - >>> import rmm - >>> cuda.set_memory_manager(rmm.RMMNumbaManager) + >>> from rmm.allocators.numba import RMMNumbaManager + >>> cuda.set_memory_manager(RMMNumbaManager) ``` + +### Using RMM with PyTorch + +You can configure +[PyTorch](https://pytorch.org/docs/stable/notes/cuda.html) to use RMM +for memory allocations using their by configuring the current +allocator. + +```python +from rmm.allocators.torch import rmm_torch_allocator +import torch + +torch.cuda.memory.change_current_allocator(rmm_torch_allocator) +``` diff --git a/python/rmm/__init__.py b/python/rmm/__init__.py index e2d8f57d7..d9e86c13e 100644 --- a/python/rmm/__init__.py +++ b/python/rmm/__init__.py @@ -17,20 +17,15 @@ from rmm.mr import disable_logging, enable_logging, get_log_filenames from rmm.rmm import ( RMMError, - RMMNumbaManager, - _numba_memory_manager, is_initialized, register_reinitialize_hook, reinitialize, - rmm_cupy_allocator, - rmm_torch_allocator, unregister_reinitialize_hook, ) __all__ = [ "DeviceBuffer", "RMMError", - "RMMNumbaManager", "disable_logging", "enable_logging", "get_log_filenames", @@ -38,8 +33,35 @@ "mr", "register_reinitialize_hook", "reinitialize", - "rmm_cupy_allocator", "unregister_reinitialize_hook", ] __version__ = "23.04.00" + + +_deprecated_names = { + "rmm_cupy_allocator": "cupy", + "rmm_torch_allocator": "torch", + "RMMNumbaManager": "numba", + "_numba_memory_manager": "numba", +} + + +def __getattr__(name): + if name in _deprecated_names: + import importlib + import warnings + + package = _deprecated_names[name] + warnings.warn( + f"Use of 'rmm.{name}' is deprecated and will be removed. " + f"'{name}' now lives in the 'rmm.allocators.{package}' sub-module, " + "please update your imports.", + FutureWarning, + ) + module = importlib.import_module( + f".allocators.{package}", package=__name__ + ) + return getattr(module, name) + else: + raise AttributeError(f"Module '{__name__}' has no attribute '{name}'") diff --git a/python/rmm/_cuda/gpu.py b/python/rmm/_cuda/gpu.py index e7f768349..2a23b41e6 100644 --- a/python/rmm/_cuda/gpu.py +++ b/python/rmm/_cuda/gpu.py @@ -1,6 +1,5 @@ # Copyright (c) 2020, NVIDIA CORPORATION. -import numba.cuda from cuda import cuda, cudart @@ -84,6 +83,8 @@ def runtimeGetVersion(): """ # TODO: Replace this with `cuda.cudart.cudaRuntimeGetVersion()` when the # limitation is fixed. + import numba.cuda + major, minor = numba.cuda.runtime.get_version() return major * 1000 + minor * 10 diff --git a/python/rmm/_cuda/stream.pyx b/python/rmm/_cuda/stream.pyx index 4f2ce26d0..d60dde4e1 100644 --- a/python/rmm/_cuda/stream.pyx +++ b/python/rmm/_cuda/stream.pyx @@ -16,6 +16,7 @@ from cuda.ccudart cimport cudaStream_t from libc.stdint cimport uintptr_t from libcpp cimport bool +from rmm._lib.cuda_stream cimport CudaStream from rmm._lib.cuda_stream_view cimport ( cuda_stream_default, cuda_stream_legacy, @@ -23,12 +24,6 @@ from rmm._lib.cuda_stream_view cimport ( cuda_stream_view, ) -from numba import cuda - -from rmm._lib.cuda_stream cimport CudaStream - -from rmm._lib.cuda_stream import CudaStream - cdef class Stream: def __init__(self, obj=None): @@ -46,10 +41,11 @@ cdef class Stream: self._init_with_new_cuda_stream() elif isinstance(obj, Stream): self._init_from_stream(obj) - elif isinstance(obj, cuda.cudadrv.driver.Stream): - self._init_from_numba_stream(obj) else: - self._init_from_cupy_stream(obj) + try: + self._init_from_numba_stream(obj) + except TypeError: + self._init_from_cupy_stream(obj) @staticmethod cdef Stream _from_cudaStream_t(cudaStream_t s, object owner=None): @@ -94,8 +90,12 @@ cdef class Stream: return self.c_is_default() def _init_from_numba_stream(self, obj): - self._cuda_stream = (int(obj)) - self._owner = obj + from numba import cuda + if isinstance(obj, cuda.cudadrv.driver.Stream): + self._cuda_stream = (int(obj)) + self._owner = obj + else: + raise TypeError(f"Cannot create stream from {type(obj)}") def _init_from_cupy_stream(self, obj): try: diff --git a/python/rmm/allocators/__init__.py b/python/rmm/allocators/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/python/rmm/allocators/cupy.py b/python/rmm/allocators/cupy.py new file mode 100644 index 000000000..89947c46b --- /dev/null +++ b/python/rmm/allocators/cupy.py @@ -0,0 +1,44 @@ +# Copyright (c) 2023, 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. +from rmm import _lib as librmm +from rmm._cuda.stream import Stream + +try: + import cupy +except ImportError: + cupy = None + + +def rmm_cupy_allocator(nbytes): + """ + A CuPy allocator that makes use of RMM. + + Examples + -------- + >>> from rmm.allocators.cupy import rmm_cupy_allocator + >>> import cupy + >>> cupy.cuda.set_allocator(rmm_cupy_allocator) + """ + if cupy is None: + raise ModuleNotFoundError("No module named 'cupy'") + + stream = Stream(obj=cupy.cuda.get_current_stream()) + buf = librmm.device_buffer.DeviceBuffer(size=nbytes, stream=stream) + dev_id = -1 if buf.ptr else cupy.cuda.device.get_device_id() + mem = cupy.cuda.UnownedMemory( + ptr=buf.ptr, size=buf.size, owner=buf, device_id=dev_id + ) + ptr = cupy.cuda.memory.MemoryPointer(mem, 0) + + return ptr diff --git a/python/rmm/allocators/numba.py b/python/rmm/allocators/numba.py new file mode 100644 index 000000000..18a010e1c --- /dev/null +++ b/python/rmm/allocators/numba.py @@ -0,0 +1,125 @@ +# Copyright (c) 2023, 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. + +import ctypes + +from cuda.cuda import CUdeviceptr, cuIpcGetMemHandle +from numba import config, cuda +from numba.cuda import HostOnlyCUDAMemoryManager, IpcHandle, MemoryPointer + +from rmm import _lib as librmm + + +def _make_emm_plugin_finalizer(handle, allocations): + """ + Factory to make the finalizer function. + We need to bind *handle* and *allocations* into the actual finalizer, which + takes no args. + """ + + def finalizer(): + """ + Invoked when the MemoryPointer is freed + """ + # At exit time (particularly in the Numba test suite) allocations may + # have already been cleaned up by a call to Context.reset() for the + # context, even if there are some DeviceNDArrays and their underlying + # allocations lying around. Finalizers then get called by weakref's + # atexit finalizer, at which point allocations[handle] no longer + # exists. This is harmless, except that a traceback is printed just + # prior to exit (without abnormally terminating the program), but is + # worrying for the user. To avoid the traceback, we check if + # allocations is already empty. + # + # In the case where allocations is not empty, but handle is not in + # allocations, then something has gone wrong - so we only guard against + # allocations being completely empty, rather than handle not being in + # allocations. + if allocations: + del allocations[handle] + + return finalizer + + +class RMMNumbaManager(HostOnlyCUDAMemoryManager): + """ + External Memory Management Plugin implementation for Numba. Provides + on-device allocation only. + + See https://numba.readthedocs.io/en/stable/cuda/external-memory.html for + details of the interface being implemented here. + """ + + def initialize(self): + # No special initialization needed to use RMM within a given context. + pass + + def memalloc(self, size): + """ + Allocate an on-device array from the RMM pool. + """ + buf = librmm.DeviceBuffer(size=size) + ctx = self.context + + if config.CUDA_USE_NVIDIA_BINDING: + ptr = CUdeviceptr(int(buf.ptr)) + else: + # expect ctypes bindings in numba + ptr = ctypes.c_uint64(int(buf.ptr)) + + finalizer = _make_emm_plugin_finalizer(int(buf.ptr), self.allocations) + + # self.allocations is initialized by the parent, HostOnlyCUDAManager, + # and cleared upon context reset, so although we insert into it here + # and delete from it in the finalizer, we need not do any other + # housekeeping elsewhere. + self.allocations[int(buf.ptr)] = buf + + return MemoryPointer(ctx, ptr, size, finalizer=finalizer) + + def get_ipc_handle(self, memory): + """ + Get an IPC handle for the MemoryPointer memory with offset modified by + the RMM memory pool. + """ + start, end = cuda.cudadrv.driver.device_extents(memory) + + if config.CUDA_USE_NVIDIA_BINDING: + _, ipc_handle = cuIpcGetMemHandle(start) + offset = int(memory.handle) - int(start) + else: + ipc_handle = (ctypes.c_byte * 64)() # IPC handle is 64 bytes + cuda.cudadrv.driver.driver.cuIpcGetMemHandle( + ctypes.byref(ipc_handle), + start, + ) + offset = memory.handle.value - start + source_info = cuda.current_context().device.get_device_identity() + + return IpcHandle( + memory, ipc_handle, memory.size, source_info, offset=offset + ) + + def get_memory_info(self): + raise NotImplementedError() + + @property + def interface_version(self): + return 1 + + +# Enables the use of RMM for Numba via an environment variable setting, +# NUMBA_CUDA_MEMORY_MANAGER=rmm. See: +# https://numba.readthedocs.io/en/stable/cuda/external-memory.html#environment-variable +_numba_memory_manager = RMMNumbaManager diff --git a/python/rmm/allocators/torch.py b/python/rmm/allocators/torch.py new file mode 100644 index 000000000..65b310a89 --- /dev/null +++ b/python/rmm/allocators/torch.py @@ -0,0 +1,26 @@ +# Copyright (c) 2023, 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. +try: + from torch.cuda.memory import CUDAPluggableAllocator +except ImportError: + rmm_torch_allocator = None +else: + import rmm._lib.torch_allocator + + _alloc_free_lib_path = rmm._lib.torch_allocator.__file__ + rmm_torch_allocator = CUDAPluggableAllocator( + _alloc_free_lib_path, + alloc_fn_name="allocate", + free_fn_name="deallocate", + ) diff --git a/python/rmm/rmm.py b/python/rmm/rmm.py index cae9971dc..e5290905c 100644 --- a/python/rmm/rmm.py +++ b/python/rmm/rmm.py @@ -11,15 +11,7 @@ # 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. -import ctypes - -from cuda.cuda import CUdeviceptr, cuIpcGetMemHandle -from numba import config, cuda -from numba.cuda import HostOnlyCUDAMemoryManager, IpcHandle, MemoryPointer - -import rmm -from rmm import _lib as librmm -from rmm._cuda.stream import Stream +from rmm import mr # Utility Functions @@ -86,7 +78,7 @@ def reinitialize( for func, args, kwargs in reversed(_reinitialize_hooks): func(*args, **kwargs) - rmm.mr._initialize( + mr._initialize( pool_allocator=pool_allocator, managed_memory=managed_memory, initial_pool_size=initial_pool_size, @@ -101,155 +93,7 @@ def is_initialized(): """ Returns True if RMM has been initialized, False otherwise. """ - return rmm.mr.is_initialized() - - -class RMMNumbaManager(HostOnlyCUDAMemoryManager): - """ - External Memory Management Plugin implementation for Numba. Provides - on-device allocation only. - - See https://numba.readthedocs.io/en/stable/cuda/external-memory.html for - details of the interface being implemented here. - """ - - def initialize(self): - # No special initialization needed to use RMM within a given context. - pass - - def memalloc(self, size): - """ - Allocate an on-device array from the RMM pool. - """ - buf = librmm.DeviceBuffer(size=size) - ctx = self.context - - if config.CUDA_USE_NVIDIA_BINDING: - ptr = CUdeviceptr(int(buf.ptr)) - else: - # expect ctypes bindings in numba - ptr = ctypes.c_uint64(int(buf.ptr)) - - finalizer = _make_emm_plugin_finalizer(int(buf.ptr), self.allocations) - - # self.allocations is initialized by the parent, HostOnlyCUDAManager, - # and cleared upon context reset, so although we insert into it here - # and delete from it in the finalizer, we need not do any other - # housekeeping elsewhere. - self.allocations[int(buf.ptr)] = buf - - return MemoryPointer(ctx, ptr, size, finalizer=finalizer) - - def get_ipc_handle(self, memory): - """ - Get an IPC handle for the MemoryPointer memory with offset modified by - the RMM memory pool. - """ - start, end = cuda.cudadrv.driver.device_extents(memory) - - if config.CUDA_USE_NVIDIA_BINDING: - _, ipchandle = cuIpcGetMemHandle(start) - offset = int(memory.handle) - int(start) - else: - ipchandle = (ctypes.c_byte * 64)() # IPC handle is 64 bytes - cuda.cudadrv.driver.driver.cuIpcGetMemHandle( - ctypes.byref(ipchandle), - start, - ) - offset = memory.handle.value - start - source_info = cuda.current_context().device.get_device_identity() - - return IpcHandle( - memory, ipchandle, memory.size, source_info, offset=offset - ) - - def get_memory_info(self): - raise NotImplementedError() - - @property - def interface_version(self): - return 1 - - -def _make_emm_plugin_finalizer(handle, allocations): - """ - Factory to make the finalizer function. - We need to bind *handle* and *allocations* into the actual finalizer, which - takes no args. - """ - - def finalizer(): - """ - Invoked when the MemoryPointer is freed - """ - # At exit time (particularly in the Numba test suite) allocations may - # have already been cleaned up by a call to Context.reset() for the - # context, even if there are some DeviceNDArrays and their underlying - # allocations lying around. Finalizers then get called by weakref's - # atexit finalizer, at which point allocations[handle] no longer - # exists. This is harmless, except that a traceback is printed just - # prior to exit (without abnormally terminating the program), but is - # worrying for the user. To avoid the traceback, we check if - # allocations is already empty. - # - # In the case where allocations is not empty, but handle is not in - # allocations, then something has gone wrong - so we only guard against - # allocations being completely empty, rather than handle not being in - # allocations. - if allocations: - del allocations[handle] - - return finalizer - - -# Enables the use of RMM for Numba via an environment variable setting, -# NUMBA_CUDA_MEMORY_MANAGER=rmm. See: -# https://numba.readthedocs.io/en/stable/cuda/external-memory.html#environment-variable -_numba_memory_manager = RMMNumbaManager - -try: - import cupy -except Exception: - cupy = None - - -def rmm_cupy_allocator(nbytes): - """ - A CuPy allocator that makes use of RMM. - - Examples - -------- - >>> import rmm - >>> import cupy - >>> cupy.cuda.set_allocator(rmm.rmm_cupy_allocator) - """ - if cupy is None: - raise ModuleNotFoundError("No module named 'cupy'") - - stream = Stream(obj=cupy.cuda.get_current_stream()) - buf = librmm.device_buffer.DeviceBuffer(size=nbytes, stream=stream) - dev_id = -1 if buf.ptr else cupy.cuda.device.get_device_id() - mem = cupy.cuda.UnownedMemory( - ptr=buf.ptr, size=buf.size, owner=buf, device_id=dev_id - ) - ptr = cupy.cuda.memory.MemoryPointer(mem, 0) - - return ptr - - -try: - from torch.cuda.memory import CUDAPluggableAllocator -except ImportError: - rmm_torch_allocator = None -else: - import rmm._lib.torch_allocator - - _alloc_free_lib_path = rmm._lib.torch_allocator.__file__ - rmm_torch_allocator = CUDAPluggableAllocator( - _alloc_free_lib_path, - alloc_fn_name="allocate", - free_fn_name="deallocate", - ) + return mr.is_initialized() def register_reinitialize_hook(func, *args, **kwargs): diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index f79c60b43..95afc8db3 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -24,6 +24,8 @@ import rmm import rmm._cuda.stream +from rmm.allocators.cupy import rmm_cupy_allocator +from rmm.allocators.numba import RMMNumbaManager if sys.version_info < (3, 8): try: @@ -33,7 +35,7 @@ else: import pickle -cuda.set_memory_manager(rmm.RMMNumbaManager) +cuda.set_memory_manager(RMMNumbaManager) _driver_version = rmm._cuda.gpu.driverGetVersion() _runtime_version = rmm._cuda.gpu.runtimeGetVersion() @@ -303,17 +305,17 @@ def test_rmm_pool_numba_stream(stream): def test_rmm_cupy_allocator(): cupy = pytest.importorskip("cupy") - m = rmm.rmm_cupy_allocator(42) + m = rmm_cupy_allocator(42) assert m.mem.size == 42 assert m.mem.ptr != 0 assert isinstance(m.mem._owner, rmm.DeviceBuffer) - m = rmm.rmm_cupy_allocator(0) + m = rmm_cupy_allocator(0) assert m.mem.size == 0 assert m.mem.ptr == 0 assert isinstance(m.mem._owner, rmm.DeviceBuffer) - cupy.cuda.set_allocator(rmm.rmm_cupy_allocator) + cupy.cuda.set_allocator(rmm_cupy_allocator) a = cupy.arange(10) assert isinstance(a.data.mem._owner, rmm.DeviceBuffer) @@ -323,7 +325,7 @@ def test_rmm_pool_cupy_allocator_with_stream(stream): cupy = pytest.importorskip("cupy") rmm.reinitialize(pool_allocator=True) - cupy.cuda.set_allocator(rmm.rmm_cupy_allocator) + cupy.cuda.set_allocator(rmm_cupy_allocator) if stream == "null": stream = cupy.cuda.stream.Stream.null @@ -331,12 +333,12 @@ def test_rmm_pool_cupy_allocator_with_stream(stream): stream = cupy.cuda.stream.Stream() with stream: - m = rmm.rmm_cupy_allocator(42) + m = rmm_cupy_allocator(42) assert m.mem.size == 42 assert m.mem.ptr != 0 assert isinstance(m.mem._owner, rmm.DeviceBuffer) - m = rmm.rmm_cupy_allocator(0) + m = rmm_cupy_allocator(0) assert m.mem.size == 0 assert m.mem.ptr == 0 assert isinstance(m.mem._owner, rmm.DeviceBuffer) @@ -355,7 +357,7 @@ def test_rmm_pool_cupy_allocator_stream_lifetime(): cupy = pytest.importorskip("cupy") rmm.reinitialize(pool_allocator=True) - cupy.cuda.set_allocator(rmm.rmm_cupy_allocator) + cupy.cuda.set_allocator(rmm_cupy_allocator) stream = cupy.cuda.stream.Stream() diff --git a/python/rmm/tests/test_rmm_pytorch.py b/python/rmm/tests/test_rmm_pytorch.py index eaa40c0ed..065507b61 100644 --- a/python/rmm/tests/test_rmm_pytorch.py +++ b/python/rmm/tests/test_rmm_pytorch.py @@ -2,7 +2,7 @@ import pytest -import rmm +from rmm.allocators.torch import rmm_torch_allocator torch = pytest.importorskip("torch") @@ -13,7 +13,7 @@ def torch_allocator(): from torch.cuda.memory import change_current_allocator except ImportError: pytest.skip("pytorch pluggable allocator not available") - change_current_allocator(rmm.rmm_torch_allocator) + change_current_allocator(rmm_torch_allocator) def test_rmm_torch_allocator(torch_allocator, stats_mr): From 3f30f3b14a34bce20a41938377e662e406436243 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 27 Feb 2023 15:02:48 -0600 Subject: [PATCH 228/675] Remove pickle compatibility layer in tests for Python < 3.8. (#1224) This is a small cleanup PR to remove a pickle compatibility layer for Python < 3.8. Authors: - Bradley Dice (https://github.com/bdice) - https://github.com/jakirkham Approvers: - https://github.com/jakirkham URL: https://github.com/rapidsai/rmm/pull/1224 --- python/rmm/tests/test_rmm.py | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index 95afc8db3..70aafe601 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -15,7 +15,7 @@ import copy import gc import os -import sys +import pickle from itertools import product import numpy as np @@ -27,14 +27,6 @@ from rmm.allocators.cupy import rmm_cupy_allocator from rmm.allocators.numba import RMMNumbaManager -if sys.version_info < (3, 8): - try: - import pickle5 as pickle - except ImportError: - import pickle -else: - import pickle - cuda.set_memory_manager(RMMNumbaManager) _driver_version = rmm._cuda.gpu.driverGetVersion() @@ -278,17 +270,16 @@ def test_rmm_device_buffer_pickle_roundtrip(hb): hb2 = db2.tobytes() assert hb == hb2 # out-of-band - if pickle.HIGHEST_PROTOCOL >= 5: - db = rmm.DeviceBuffer.to_device(hb) - buffers = [] - pb2 = pickle.dumps(db, protocol=5, buffer_callback=buffers.append) - del db - assert len(buffers) == 1 - assert isinstance(buffers[0], pickle.PickleBuffer) - assert bytes(buffers[0]) == hb - db3 = pickle.loads(pb2, buffers=buffers) - hb3 = db3.tobytes() - assert hb3 == hb + db = rmm.DeviceBuffer.to_device(hb) + buffers = [] + pb2 = pickle.dumps(db, protocol=5, buffer_callback=buffers.append) + del db + assert len(buffers) == 1 + assert isinstance(buffers[0], pickle.PickleBuffer) + assert bytes(buffers[0]) == hb + db3 = pickle.loads(pb2, buffers=buffers) + hb3 = db3.tobytes() + assert hb3 == hb @pytest.mark.parametrize("stream", [cuda.default_stream(), cuda.stream()]) From 83c40c82da5aae01553b3e9ac0404200c01b1e8d Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 28 Feb 2023 06:33:24 -0800 Subject: [PATCH 229/675] Fix update-version.sh. (#1227) We need to update the version regex in update-version.sh for the pyproject.toml changes in #1151. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1227 --- ci/release/update-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index c028a8eaf..05218e811 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -37,7 +37,7 @@ sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cma sed_runner 's/'"rmm_version .*)"'/'"rmm_version ${NEXT_FULL_TAG})"'/g' python/CMakeLists.txt sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' python/CMakeLists.txt sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/rmm/__init__.py -sed_runner "s/version=.*,/version=\"${NEXT_FULL_TAG}\",/g" python/setup.py +sed_runner "s/^version = .*/version = \"${NEXT_FULL_TAG}\"/g" python/pyproject.toml # cmake-format rapids-cmake definitions sed_runner 's/'"branch-.*\/cmake-format-rapids-cmake.json"'/'"branch-${NEXT_SHORT_TAG}\/cmake-format-rapids-cmake.json"'/g' ci/check_style.sh From 3bdadd6357fa302667309fe9075f294e40f06bf8 Mon Sep 17 00:00:00 2001 From: Ashwin Srinath <3190405+shwina@users.noreply.github.com> Date: Tue, 28 Feb 2023 14:03:25 -0500 Subject: [PATCH 230/675] Synchronize stream in `DeviceBuffer.c_from_unique_ptr` constructor (#1100) The `DeviceBuffer.__cinit__` method syncs the default stream to ensure that access to the `.ptr` and `.size` attributes of the underlying `rmm::device_buffer` is safe. However, the staticmethod `DeviceBuffer.c_from_unique_ptr` does not. This PR adds a stream sync to it. Authors: - Ashwin Srinath (https://github.com/shwina) - https://github.com/jakirkham Approvers: - Mark Harris (https://github.com/harrism) - https://github.com/jakirkham URL: https://github.com/rapidsai/rmm/pull/1100 --- python/rmm/_lib/device_buffer.pxd | 5 ++++- python/rmm/_lib/device_buffer.pyx | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/python/rmm/_lib/device_buffer.pxd b/python/rmm/_lib/device_buffer.pxd index 42c2b4fef..364dbb2c0 100644 --- a/python/rmm/_lib/device_buffer.pxd +++ b/python/rmm/_lib/device_buffer.pxd @@ -49,7 +49,10 @@ cdef class DeviceBuffer: cdef Stream stream @staticmethod - cdef DeviceBuffer c_from_unique_ptr(unique_ptr[device_buffer] ptr) + cdef DeviceBuffer c_from_unique_ptr( + unique_ptr[device_buffer] ptr, + Stream stream=* + ) @staticmethod cdef DeviceBuffer c_to_device(const unsigned char[::1] b, diff --git a/python/rmm/_lib/device_buffer.pyx b/python/rmm/_lib/device_buffer.pyx index 43ebf41ac..c2bfd1459 100644 --- a/python/rmm/_lib/device_buffer.pyx +++ b/python/rmm/_lib/device_buffer.pyx @@ -158,9 +158,16 @@ cdef class DeviceBuffer: return self.copy() @staticmethod - cdef DeviceBuffer c_from_unique_ptr(unique_ptr[device_buffer] ptr): + cdef DeviceBuffer c_from_unique_ptr( + unique_ptr[device_buffer] ptr, + Stream stream=DEFAULT_STREAM + ): cdef DeviceBuffer buf = DeviceBuffer.__new__(DeviceBuffer) + if stream.c_is_default(): + stream.c_synchronize() buf.c_obj = move(ptr) + buf.mr = get_current_device_resource() + buf.stream = stream return buf @staticmethod From 8958356177e9a378d539f37cc70ae88425c478e2 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 6 Mar 2023 12:21:04 -0800 Subject: [PATCH 231/675] Update to GCC 11 (#1228) This PR updates builds to use GCC 11. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1228 --- conda/recipes/librmm/conda_build_config.yaml | 4 ++-- conda/recipes/rmm/conda_build_config.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index 39dec9e5c..be4758d36 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -1,8 +1,8 @@ c_compiler_version: - - 9 + - 11 cxx_compiler_version: - - 9 + - 11 cuda_compiler: - nvcc diff --git a/conda/recipes/rmm/conda_build_config.yaml b/conda/recipes/rmm/conda_build_config.yaml index 322fe6faa..ad733ac69 100644 --- a/conda/recipes/rmm/conda_build_config.yaml +++ b/conda/recipes/rmm/conda_build_config.yaml @@ -1,8 +1,8 @@ c_compiler_version: - - 9 + - 11 cxx_compiler_version: - - 9 + - 11 cuda_compiler: - nvcc From 39f6ca57ccbfb696533c320b6745a71ed9ee7716 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Wed, 8 Mar 2023 17:19:00 -0500 Subject: [PATCH 232/675] Pass `AWS_SESSION_TOKEN` and `SCCACHE_S3_USE_SSL` vars to conda build (#1230) This PR ensures that the `AWS_SESSION_TOKEN` and `SCCACHE_S3_USE_SSL` environment variables are passed to our conda build process. `AWS_SESSION_TOKEN` is necessary in order to support using temporary credentials via AWS STS (we recently adopted this method in CI). `SCCACHE_S3_USE_SSL` has been reported to increase cache performance for S3. This PR also alphabetizes the `script_env` lists. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1230 --- conda/recipes/librmm/meta.yaml | 18 ++++++++++-------- conda/recipes/rmm/meta.yaml | 16 +++++++++------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index dd3e58b62..5513d5059 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -32,18 +32,20 @@ requirements: build: script_env: - - PARALLEL_LEVEL - - CMAKE_GENERATOR + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + - AWS_SESSION_TOKEN - CMAKE_C_COMPILER_LAUNCHER - - CMAKE_CXX_COMPILER_LAUNCHER - CMAKE_CUDA_COMPILER_LAUNCHER - - SCCACHE_S3_KEY_PREFIX=librmm-aarch64 # [aarch64] - - SCCACHE_S3_KEY_PREFIX=librmm-linux64 # [linux64] + - CMAKE_CXX_COMPILER_LAUNCHER + - CMAKE_GENERATOR + - PARALLEL_LEVEL - SCCACHE_BUCKET - - SCCACHE_REGION - SCCACHE_IDLE_TIMEOUT - - AWS_ACCESS_KEY_ID - - AWS_SECRET_ACCESS_KEY + - SCCACHE_REGION + - SCCACHE_S3_KEY_PREFIX=librmm-aarch64 # [aarch64] + - SCCACHE_S3_KEY_PREFIX=librmm-linux64 # [linux64] + - SCCACHE_S3_USE_SSL outputs: - name: librmm diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index b816e24c5..2a4d668ef 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -17,17 +17,19 @@ build: number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_py{{ py_version }}_{{ date_string }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} script_env: - - CMAKE_GENERATOR + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + - AWS_SESSION_TOKEN - CMAKE_C_COMPILER_LAUNCHER - - CMAKE_CXX_COMPILER_LAUNCHER - CMAKE_CUDA_COMPILER_LAUNCHER - - SCCACHE_S3_KEY_PREFIX=rmm-aarch64 # [aarch64] - - SCCACHE_S3_KEY_PREFIX=rmm-linux64 # [linux64] + - CMAKE_CXX_COMPILER_LAUNCHER + - CMAKE_GENERATOR - SCCACHE_BUCKET - - SCCACHE_REGION - SCCACHE_IDLE_TIMEOUT - - AWS_ACCESS_KEY_ID - - AWS_SECRET_ACCESS_KEY + - SCCACHE_REGION + - SCCACHE_S3_KEY_PREFIX=rmm-aarch64 # [aarch64] + - SCCACHE_S3_KEY_PREFIX=rmm-linux64 # [linux64] + - SCCACHE_S3_USE_SSL ignore_run_exports_from: - {{ compiler('cuda') }} From 663a9b0fb022864ed89f247e25465132a4eca589 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 14 Mar 2023 16:29:37 -0500 Subject: [PATCH 233/675] Add codespell as a linter (#1231) Following the example of https://github.com/rapidsai/cudf/pull/12097, this PR adds [codespell](https://github.com/codespell-project/codespell) as a linter for rmm. Note: I have not included a section in the CONTRIBUTING.md about how to use this (as was done in cudf's PR) because I plan to overhaul the contributing guides for all RAPIDS repos in the near term, and have a single source in docs.rapids.ai with common information about linters used in RAPIDS. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Rong Ou (https://github.com/rongou) - Ben Frederickson (https://github.com/benfred) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1231 --- .pre-commit-config.yaml | 9 +++++++++ benchmarks/synchronization/synchronization.hpp | 2 +- include/rmm/detail/stack_trace.hpp | 2 +- .../mr/device/detail/stream_ordered_memory_resource.hpp | 2 +- pyproject.toml | 9 +++++++++ tests/device_buffer_tests.cu | 2 +- tests/device_scalar_tests.cpp | 2 +- 7 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 pyproject.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 261c57b27..bcbf17018 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,6 +49,15 @@ repos: (?x)^( ^benchmarks/utilities/cxxopts.hpp ) + - repo: https://github.com/codespell-project/codespell + rev: v2.2.4 + hooks: + - id: codespell + exclude: | + (?x)^( + pyproject.toml| + benchmarks/utilities/cxxopts.hpp + ) - repo: local hooks: - id: cmake-format diff --git a/benchmarks/synchronization/synchronization.hpp b/benchmarks/synchronization/synchronization.hpp index b0007d9b2..e9a3cd34a 100644 --- a/benchmarks/synchronization/synchronization.hpp +++ b/benchmarks/synchronization/synchronization.hpp @@ -50,7 +50,7 @@ } // Register the function as a benchmark. You will need to set the `UseManualTime()` - // flag in order to use the timer embeded in this class. + // flag in order to use the timer embedded in this class. BENCHMARK(sample_cuda_benchmark)->UseManualTime(); diff --git a/include/rmm/detail/stack_trace.hpp b/include/rmm/detail/stack_trace.hpp index 082cef02e..f658fe7ad 100644 --- a/include/rmm/detail/stack_trace.hpp +++ b/include/rmm/detail/stack_trace.hpp @@ -39,7 +39,7 @@ namespace rmm::detail { /** - * @brief stack_trace is a class that will capture a stack on instatiation for output later. + * @brief stack_trace is a class that will capture a stack on instantiation for output later. * It can then be used in an output stream to display stack information. * * rmm::detail::stack_trace saved_stack; diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index fa53e480a..ddd3cb728 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -58,7 +58,7 @@ struct crtp { * This base class uses CRTP (https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern) * to provide static polymorphism to enable defining suballocator resources that maintain separate * pools per stream. All of the stream-ordering logic is contained in this class, but the logic - * to determine how memory pools are managed and the type of allocation is implented in a derived + * to determine how memory pools are managed and the type of allocation is implemented in a derived * class and in a free list class. * * For example, a coalescing pool memory resource uses a coalescing_free_list and maintains data diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..8a412773e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,9 @@ +[tool.codespell] +# note: pre-commit passes explicit lists of files here, which this skip file list doesn't override - +# this is only to allow you to run codespell interactively +skip = "./pyproject.toml,./.git,./.github,./cpp/build,.*egg-info.*,./.mypy_cache,./benchmarks/utilities/cxxopts.hpp" +# ignore short words, and typename parameters like OffsetT +ignore-regex = "\\b(.{1,4}|[A-Z]\\w*T)\\b" +ignore-words-list = "inout" +builtin = "clear" +quiet-level = 3 diff --git a/tests/device_buffer_tests.cu b/tests/device_buffer_tests.cu index fadae7bb2..d4c34385e 100644 --- a/tests/device_buffer_tests.cu +++ b/tests/device_buffer_tests.cu @@ -438,7 +438,7 @@ TYPED_TEST(DeviceBufferTest, ResizeSmaller) buff.shrink_to_fit(rmm::cuda_stream_default); EXPECT_NE(nullptr, buff.data()); - // A reallocation should have occured + // A reallocation should have occurred EXPECT_NE(old_data, buff.data()); EXPECT_EQ(new_size, buff.size()); EXPECT_EQ(buff.capacity(), buff.size()); diff --git a/tests/device_scalar_tests.cpp b/tests/device_scalar_tests.cpp index fd92f7d6e..7fbdaec29 100644 --- a/tests/device_scalar_tests.cpp +++ b/tests/device_scalar_tests.cpp @@ -71,7 +71,7 @@ using Types = ::testing::Types scalar{this->stream, this->mr}; EXPECT_NE(nullptr, scalar.data()); From d26ebfc983eef5ef7fd680a7b5b512eee367f191 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 16 Mar 2023 17:04:54 -0400 Subject: [PATCH 234/675] Remove MANIFEST.in use auto-generated one for sdists and package_data for wheels (#1233) Using MANIFEST.in currently runs into a pretty nasty scikit-build bug (https://github.com/scikit-build/scikit-build/issues/886) that results in any file included by the manifest being copied from the install tree back into the source tree whenever an in place build occurs after an install, overwriting any local changes. We need an alternative approach to ensure that all necessary files are included in built packages. There are two types: - sdists: scikit-build automatically generates a manifest during sdist generation if we don't provide one, and that manifest is reliably complete. It contains all files needed for a source build up to the rmm C++ code (which has always been true and is something we can come back to improving later if desired). - wheels: The autogenerated manifest is not used during wheel generation because the manifest generation hook is not invoked during wheel builds, so to include data in the wheels we must provide the `package_data` argument to `setup`. In this case we do not need to include CMake or pyx files because the result does not need to be possible to build from, it just needs pxd files for other packages to cimport if desired. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1233 --- python/MANIFEST.in | 7 ------- python/setup.py | 7 ++++--- 2 files changed, 4 insertions(+), 10 deletions(-) delete mode 100644 python/MANIFEST.in diff --git a/python/MANIFEST.in b/python/MANIFEST.in deleted file mode 100644 index 0a521fd9e..000000000 --- a/python/MANIFEST.in +++ /dev/null @@ -1,7 +0,0 @@ -# Cython files -recursive-include rmm *.pxd -recursive-include rmm *.pyx - -# Build files. Don't use a recursive include on '.' in case the repo is dirty -include . CMakeLists.txt -recursive-include rmm CMakeLists.txt diff --git a/python/setup.py b/python/setup.py index 64d8524e3..48b35d1bb 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,10 +1,11 @@ -# Copyright (c) 2019-2022, NVIDIA CORPORATION. +# Copyright (c) 2019-2023, NVIDIA CORPORATION. from setuptools import find_packages from skbuild import setup +packages = find_packages(include=["rmm*"]) setup( - packages=find_packages(include=["rmm", "rmm.*"]), - include_package_data=True, + packages=packages, + package_data={key: ["*.pxd"] for key in packages}, zip_safe=False, ) From 591726f2c4c0178daf7d9f2ca605cdf03f5137ba Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 20 Mar 2023 10:32:24 -0400 Subject: [PATCH 235/675] Use rapids-cmake parallel testing feature (#1183) Converts librmm over to use `rapids-cmake` new GPU aware parallel testing feature, which allows tests to run across all the GPUs on a machine without oversubscription. This will allow developers to run `ctest -j` and ctest will figure out given the current machine how many tests it can run in parallel given the current GPU set ( currently 4 tests per GPU ). Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Mark Harris (https://github.com/harrism) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1183 --- ci/test_cpp.sh | 6 ++--- dependencies.yaml | 8 ++++++- tests/CMakeLists.txt | 57 +++++++++++++++++++++++++++++++------------- 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 46022f8f2..12b3ab100 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -32,9 +32,9 @@ trap "EXITCODE=1" ERR set +e rapids-logger "Running googletests" -for gt in "$CONDA_PREFIX/bin/gtests/librmm/"* ; do - ${gt} --gtest_output=xml:${RAPIDS_TESTS_DIR}/ -done +cd $CONDA_PREFIX/bin/gtests/librmm/ +export GTEST_OUTPUT=xml:${RAPIDS_TESTS_DIR}/ +ctest -j20 --output-on-failure rapids-logger "Test script exiting with value: $EXITCODE" exit ${EXITCODE} diff --git a/dependencies.yaml b/dependencies.yaml index e6fde1b98..37885a940 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -22,6 +22,7 @@ files: output: none includes: - cudatoolkit + - test_cpp checks: output: none includes: @@ -41,7 +42,7 @@ dependencies: common: - output_types: [conda, requirements] packages: - - cmake>=3.23.1,!=3.25.0 + - &cmake_ver cmake>=3.23.1,!=3.25.0 - cuda-python>=11.7.1,<12.0 - cython>=0.29,<0.30 - ninja @@ -121,6 +122,11 @@ dependencies: packages: - numba>=0.49 - numpy>=1.19 + test_cpp: + common: + - output_types: conda + packages: + - *cmake_ver test_python: common: - output_types: [conda, requirements] diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ecb44a49c..24e9d240d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,6 +16,9 @@ option(DISABLE_DEPRECATION_WARNING "Disable warnings generated from deprecated declarations." OFF) option(CODE_COVERAGE "Enable generating code coverage with gcov." OFF) +include(rapids-test) +rapids_test_init() + # This function takes in a test name and test source and handles setting all of the associated # properties and linking to build the test function(ConfigureTestInternal TEST_NAME) @@ -68,48 +71,68 @@ function(ConfigureTestInternal TEST_NAME) PROPERTY ADDITIONAL_CLEAN_FILES ${COVERAGE_CLEAN_FILES}) endif() - add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME}) - - install( - TARGETS ${TEST_NAME} - COMPONENT testing - DESTINATION bin/gtests/librmm - EXCLUDE_FROM_ALL) endfunction() # Wrapper around `ConfigureTestInternal` that builds tests both with and without per thread default # stream function(ConfigureTest TEST_NAME) + + set(options) + set(one_value GPUS PERCENT) + set(multi_value) + cmake_parse_arguments(_RMM_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN}) + if(NOT DEFINED _RMM_TEST_GPUS AND NOT DEFINED _RMM_TEST_PERCENT) + set(_RMM_TEST_GPUS 1) + set(_RMM_TEST_PERCENT 5) + endif() + if(NOT DEFINED _RMM_TEST_GPUS) + set(_RMM_TEST_GPUS 1) + endif() + if(NOT DEFINED _RMM_TEST_PERCENT) + set(_RMM_TEST_PERCENT 100) + endif() + # Test with legacy default stream. - ConfigureTestInternal(${TEST_NAME} ${ARGN}) + ConfigureTestInternal(${TEST_NAME} ${_RMM_TEST_UNPARSED_ARGUMENTS}) # Test with per-thread default stream. string(REGEX REPLACE "_TEST$" "_PTDS_TEST" PTDS_TEST_NAME "${TEST_NAME}") - ConfigureTestInternal("${PTDS_TEST_NAME}" ${ARGN}) + ConfigureTestInternal("${PTDS_TEST_NAME}" ${_RMM_TEST_UNPARSED_ARGUMENTS}) target_compile_definitions("${PTDS_TEST_NAME}" PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM) # Test with custom thrust namespace string(REGEX REPLACE "_TEST$" "_NAMESPACE_TEST" NS_TEST_NAME "${TEST_NAME}") - ConfigureTestInternal("${NS_TEST_NAME}" ${ARGN}) + ConfigureTestInternal("${NS_TEST_NAME}" ${_RMM_TEST_UNPARSED_ARGUMENTS}) target_compile_definitions("${NS_TEST_NAME}" PUBLIC THRUST_WRAPPED_NAMESPACE=rmm_thrust) + + foreach(name ${TEST_NAME} ${PTDS_TEST_NAME} ${NS_TEST_NAME}) + rapids_test_add( + NAME ${name} + COMMAND ${TEST_NAME} + GPUS ${_RMM_TEST_GPUS} + PERCENT ${_RMM_TEST_PERCENT} + INSTALL_COMPONENT_SET testing) + endforeach() + endfunction() # test sources # device mr tests -ConfigureTest(DEVICE_MR_TEST mr/device/mr_tests.cpp mr/device/mr_multithreaded_tests.cpp) +ConfigureTest(DEVICE_MR_TEST mr/device/mr_tests.cpp mr/device/mr_multithreaded_tests.cpp GPUS 1 + PERCENT 90) # general adaptor tests ConfigureTest(ADAPTOR_TEST mr/device/adaptor_tests.cpp) # pool mr tests -ConfigureTest(POOL_MR_TEST mr/device/pool_mr_tests.cpp) +ConfigureTest(POOL_MR_TEST mr/device/pool_mr_tests.cpp GPUS 1 PERCENT 60) # cuda_async mr tests -ConfigureTest(CUDA_ASYNC_MR_TEST mr/device/cuda_async_mr_tests.cpp) +ConfigureTest(CUDA_ASYNC_MR_TEST mr/device/cuda_async_mr_tests.cpp GPUS 1 PERCENT 60) # thrust allocator tests -ConfigureTest(THRUST_ALLOCATOR_TEST mr/device/thrust_allocator_tests.cu) +ConfigureTest(THRUST_ALLOCATOR_TEST mr/device/thrust_allocator_tests.cu GPUS 1 PERCENT 60) # polymorphic allocator tests ConfigureTest(POLYMORPHIC_ALLOCATOR_TEST mr/device/polymorphic_allocator_tests.cpp) @@ -148,13 +171,15 @@ ConfigureTest(DEVICE_SCALAR_TEST device_scalar_tests.cpp) ConfigureTest(LOGGER_TEST logger_tests.cpp) # uvector tests -ConfigureTest(DEVICE_UVECTOR_TEST device_uvector_tests.cpp) +ConfigureTest(DEVICE_UVECTOR_TEST device_uvector_tests.cpp GPUS 1 PERCENT 60) # arena MR tests -ConfigureTest(ARENA_MR_TEST mr/device/arena_mr_tests.cpp) +ConfigureTest(ARENA_MR_TEST mr/device/arena_mr_tests.cpp GPUS 1 PERCENT 60) # binning MR tests ConfigureTest(BINNING_MR_TEST mr/device/binning_mr_tests.cpp) # callback memory resource tests ConfigureTest(CALLBACK_MR_TEST mr/device/callback_mr_tests.cpp) + +rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing DESTINATION bin/gtests/librmm) From d93f011336e37f482b86288310c990de423636ba Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 21 Mar 2023 16:23:08 -0400 Subject: [PATCH 236/675] Stop setting package version attribute in wheels (#1236) This PR removes modification of the `__init__.py::version` attribute that occurs during the wheel build process. See https://github.com/rapidsai/ops/issues/2592 for more information. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Sevag H (https://github.com/sevagh) URL: https://github.com/rapidsai/rmm/pull/1236 --- ci/release/apply_wheel_modifications.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/release/apply_wheel_modifications.sh b/ci/release/apply_wheel_modifications.sh index 90472d869..6889520a9 100755 --- a/ci/release/apply_wheel_modifications.sh +++ b/ci/release/apply_wheel_modifications.sh @@ -6,7 +6,6 @@ VERSION=${1} CUDA_SUFFIX=${2} -sed -i "s/__version__ = .*/__version__ = \"${VERSION}\"/g" python/rmm/__init__.py sed -i "s/^version = .*/version = \"${VERSION}\"/g" python/pyproject.toml sed -i "s/^name = \"rmm\"/name = \"rmm${CUDA_SUFFIX}\"/g" python/pyproject.toml From e8fbd06e98c22d91f2b453f4b475fe9c4a93958a Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 21 Mar 2023 16:35:26 -0400 Subject: [PATCH 237/675] Generate pyproject.toml dependencies using dfg (#1219) This PR updates dependencies.yaml to also generates the relevant dependency sections of pyproject.toml. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1219 --- .pre-commit-config.yaml | 2 +- dependencies.yaml | 34 +++++++++++++++++++++++++++++----- python/pyproject.toml | 22 +++++++++++----------- 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bcbf17018..b230cafb7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - repo: https://github.com/rapidsai/dependency-file-generator - rev: v1.4.0 + rev: v1.5.1 hooks: - id: rapids-dependency-file-generator args: ["--clean"] diff --git a/dependencies.yaml b/dependencies.yaml index 37885a940..f39f62803 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -34,25 +34,48 @@ files: - cudatoolkit - docs - py_version + py_build: + output: pyproject + extras: + table: build-system + includes: + - build + py_run: + output: pyproject + extras: + table: project + includes: + - run + py_optional_test: + output: pyproject + extras: + table: project.optional-dependencies + key: test + includes: + - test_python channels: - rapidsai - conda-forge dependencies: build: common: - - output_types: [conda, requirements] + - output_types: [conda, requirements, pyproject] packages: - &cmake_ver cmake>=3.23.1,!=3.25.0 - - cuda-python>=11.7.1,<12.0 + - &cuda_python cuda-python>=11.7.1,<12.0 - cython>=0.29,<0.30 - ninja - - python>=3.8,<3.11 - scikit-build>=0.13.1 - tomli - output_types: conda packages: - fmt>=9.1.0,<10 - spdlog>=1.11.0,<1.12 + - python>=3.8,<3.11 + - output_types: pyproject + packages: + - wheel + - setuptools>=61.0.0 checks: common: - output_types: [conda, requirements] @@ -118,10 +141,11 @@ dependencies: - python=3.10 run: common: - - output_types: [conda, requirements] + - output_types: [conda, requirements, pyproject] packages: - numba>=0.49 - numpy>=1.19 + - *cuda_python test_cpp: common: - output_types: conda @@ -129,7 +153,7 @@ dependencies: - *cmake_ver test_python: common: - - output_types: [conda, requirements] + - output_types: [conda, requirements, pyproject] packages: - pytest - pytest-cov diff --git a/python/pyproject.toml b/python/pyproject.toml index 873e21445..a462c341f 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -15,15 +15,15 @@ [build-system] build-backend = "setuptools.build_meta" requires = [ - "wheel", - "setuptools>=61.0.0", - "cython>=0.29,<0.30", - "scikit-build>=0.13.1", "cmake>=3.23.1,!=3.25.0", - "ninja", "cuda-python>=11.7.1,<12.0", - "tomli; python_version < '3.11'", -] + "cython>=0.29,<0.30", + "ninja", + "scikit-build>=0.13.1", + "setuptools>=61.0.0", + "tomli", + "wheel", +] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../dependencies.yaml and run `rapids-dependency-file-generator`. [project] name = "rmm" @@ -37,9 +37,9 @@ license = { text = "Apache 2.0" } requires-python = ">=3.8" dependencies = [ "cuda-python>=11.7.1,<12.0", - "numpy>=1.19", "numba>=0.49", -] + "numpy>=1.19", +] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../dependencies.yaml and run `rapids-dependency-file-generator`. classifiers = [ "Intended Audience :: Developers", "Topic :: Database", @@ -53,8 +53,8 @@ classifiers = [ [project.optional-dependencies] test = [ "pytest", - "pytest-xdist", -] + "pytest-cov", +] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../dependencies.yaml and run `rapids-dependency-file-generator`. [project.urls] Homepage = "https://github.com/rapidsai/rmm" From bc9155e9e81d127df5ba3b420671cd9043b869e0 Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Thu, 23 Mar 2023 14:52:57 -0400 Subject: [PATCH 238/675] DOC --- .github/workflows/build.yaml | 12 ++++++------ .github/workflows/pr.yaml | 18 +++++++++--------- .github/workflows/test.yaml | 6 +++--- CMakeLists.txt | 4 ++-- ci/check_style.sh | 2 +- doxygen/Doxyfile | 2 +- python/CMakeLists.txt | 4 ++-- python/docs/conf.py | 4 ++-- python/pyproject.toml | 2 +- python/rmm/__init__.py | 2 +- 10 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e5256cfe0..a4f29848c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' && github.event_name == 'push' needs: python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.06 with: build_type: branch node_type: "gpu-latest-1" @@ -65,7 +65,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -78,7 +78,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@branch-23.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index eb3607c8c..d65533a49 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -21,40 +21,40 @@ jobs: - wheel-build - wheel-tests secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.06 checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.06 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.06 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.06 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.06 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.06 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.06 with: build_type: pull-request node_type: "gpu-latest-1" @@ -64,7 +64,7 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.06 with: build_type: pull-request package-dir: python @@ -74,7 +74,7 @@ jobs: wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.06 with: build_type: pull-request package-name: rmm diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f4ef540fe..0dc90f036 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.06 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.06 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.04 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.06 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/CMakeLists.txt b/CMakeLists.txt index fcc0f5c90..b298f3cb2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.04/RAPIDS.cmake + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.06/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) endif() include(${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) @@ -27,7 +27,7 @@ include(rapids-find) project( RMM - VERSION 23.04.00 + VERSION 23.06.00 LANGUAGES CXX) # Write the version header diff --git a/ci/check_style.sh b/ci/check_style.sh index f9bfea7b4..36b856ae6 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -14,7 +14,7 @@ rapids-dependency-file-generator \ rapids-mamba-retry env create --force -f env.yaml -n checks conda activate checks -FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.04/cmake-format-rapids-cmake.json +FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.06/cmake-format-rapids-cmake.json export RAPIDS_CMAKE_FORMAT_FILE=/tmp/rapids_cmake_ci/cmake-formats-rapids-cmake.json mkdir -p $(dirname ${RAPIDS_CMAKE_FORMAT_FILE}) wget -O ${RAPIDS_CMAKE_FORMAT_FILE} ${FORMAT_FILE_URL} diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index c4192f793..e9323a222 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "RMM" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 23.04 +PROJECT_NUMBER = 23.06 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 705f40ac7..5950f3c21 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -14,9 +14,9 @@ cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) -set(rmm_version 23.04.00) +set(rmm_version 23.06.00) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.04/RAPIDS.cmake +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.06/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) diff --git a/python/docs/conf.py b/python/docs/conf.py index 31e3ba44f..8c014d8d5 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -23,9 +23,9 @@ # built documents. # # The short X.Y version. -version = "23.04" +version = "23.06" # The full version, including alpha/beta/rc tags. -release = "23.04.00" +release = "23.06.00" # -- General configuration --------------------------------------------------- diff --git a/python/pyproject.toml b/python/pyproject.toml index a462c341f..49cb29348 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -27,7 +27,7 @@ requires = [ [project] name = "rmm" -version = "23.04.00" +version = "23.06.00" description = "rmm - RAPIDS Memory Manager" readme = { file = "README.md", content-type = "text/markdown" } authors = [ diff --git a/python/rmm/__init__.py b/python/rmm/__init__.py index d9e86c13e..01b037bd8 100644 --- a/python/rmm/__init__.py +++ b/python/rmm/__init__.py @@ -36,7 +36,7 @@ "unregister_reinitialize_hook", ] -__version__ = "23.04.00" +__version__ = "23.06.00" _deprecated_names = { From 73612aaabd0b19e594cfa98c69a527f6a6038c0f Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Tue, 4 Apr 2023 11:15:43 -0400 Subject: [PATCH 239/675] empty commit to trigger `23.06` docs build From 0371ee77da2ee80879216054c706bcea39110bac Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 10 Apr 2023 10:13:37 -0700 Subject: [PATCH 240/675] Remove uses-setup-env-vars (#1242) This setting now matches the default behavior of the shared-action-workflows repo Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1242 --- .github/workflows/build.yaml | 1 - .github/workflows/pr.yaml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a4f29848c..39c204632 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -74,7 +74,6 @@ jobs: package-name: rmm package-dir: python skbuild-configure-options: "-DRMM_BUILD_WHEELS=ON" - uses-setup-env-vars: false wheel-publish: needs: wheel-build secrets: inherit diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index d65533a49..90f0b323f 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -70,7 +70,6 @@ jobs: package-dir: python package-name: rmm skbuild-configure-options: "-DRMM_BUILD_WHEELS=ON" - uses-setup-env-vars: false wheel-tests: needs: wheel-build secrets: inherit From 0aaf2789bbbbeabc7aae6e4775a74f2e83b238c4 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 14 Apr 2023 14:32:44 -0500 Subject: [PATCH 241/675] Update clang-format to 16.0.1. (#1246) This PR updates the clang-format version used by pre-commit. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Rong Ou (https://github.com/rongou) URL: https://github.com/rapidsai/rmm/pull/1246 --- .pre-commit-config.yaml | 2 +- .../random_allocations/random_allocations.cpp | 2 +- benchmarks/replay/replay.cpp | 6 +++--- .../synchronization/synchronization.hpp | 4 ++-- benchmarks/utilities/log_parser.hpp | 8 ++++---- .../utilities/simulated_memory_resource.hpp | 4 ++-- include/rmm/cuda_stream.hpp | 2 +- include/rmm/cuda_stream_pool.hpp | 6 +++--- include/rmm/cuda_stream_view.hpp | 10 +++++----- include/rmm/device_buffer.hpp | 10 +++++----- include/rmm/logger.hpp | 3 +-- .../mr/device/aligned_resource_adaptor.hpp | 10 +++++----- .../rmm/mr/device/arena_memory_resource.hpp | 6 +++--- .../rmm/mr/device/binning_memory_resource.hpp | 8 ++++---- .../mr/device/callback_memory_resource.hpp | 10 +++++----- .../mr/device/cuda_async_memory_resource.hpp | 6 +++--- .../cuda_async_view_memory_resource.hpp | 8 ++++---- .../rmm/mr/device/cuda_memory_resource.hpp | 10 +++++----- include/rmm/mr/device/detail/arena.hpp | 20 +++++++++---------- .../mr/device/detail/coalescing_free_list.hpp | 4 ++-- .../mr/device/detail/fixed_size_free_list.hpp | 4 ++-- include/rmm/mr/device/detail/free_list.hpp | 4 ++-- .../detail/stream_ordered_memory_resource.hpp | 12 +++++------ .../rmm/mr/device/device_memory_resource.hpp | 10 +++++----- .../failure_callback_resource_adaptor.hpp | 6 +++--- .../mr/device/fixed_size_memory_resource.hpp | 10 +++++----- .../mr/device/limiting_resource_adaptor.hpp | 10 +++++----- .../mr/device/logging_resource_adaptor.hpp | 14 ++++++------- .../rmm/mr/device/managed_memory_resource.hpp | 10 +++++----- .../rmm/mr/device/pool_memory_resource.hpp | 8 ++++---- .../mr/device/statistics_resource_adaptor.hpp | 10 +++++----- .../device/thread_safe_resource_adaptor.hpp | 10 +++++----- .../mr/device/tracking_resource_adaptor.hpp | 10 +++++----- include/rmm/mr/host/host_memory_resource.hpp | 10 +++++----- include/rmm/mr/host/new_delete_resource.hpp | 10 +++++----- .../rmm/mr/host/pinned_memory_resource.hpp | 10 +++++----- tests/cuda_stream_tests.cpp | 3 +-- tests/logger_tests.cpp | 4 ++-- tests/mr/device/arena_mr_tests.cpp | 9 ++++----- tests/mr/device/failure_callback_mr_tests.cpp | 2 +- tests/mr/device/mr_multithreaded_tests.cpp | 3 +-- tests/mr/device/mr_test.hpp | 3 +-- tests/mr/device/pool_mr_tests.cpp | 2 +- tests/mr/device/thrust_allocator_tests.cu | 3 +-- 44 files changed, 155 insertions(+), 161 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b230cafb7..7ee3cc4e7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,7 +36,7 @@ repos: hooks: - id: cython-lint - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v11.1.0 + rev: v16.0.1 hooks: - id: clang-format types_or: [c, c++, cuda] diff --git a/benchmarks/random_allocations/random_allocations.cpp b/benchmarks/random_allocations/random_allocations.cpp index 470442830..8c670525d 100644 --- a/benchmarks/random_allocations/random_allocations.cpp +++ b/benchmarks/random_allocations/random_allocations.cpp @@ -68,7 +68,7 @@ void random_allocation_free(rmm::mr::device_memory_resource& mr, { std::default_random_engine generator; - max_usage *= size_mb; // convert to bytes + max_usage *= size_mb; // convert to bytes constexpr int allocation_probability{73}; // percent constexpr int max_op_chance{99}; diff --git a/benchmarks/replay/replay.cpp b/benchmarks/replay/replay.cpp index edae79acf..9d2d00cc1 100644 --- a/benchmarks/replay/replay.cpp +++ b/benchmarks/replay/replay.cpp @@ -150,9 +150,9 @@ struct replay_benchmark { { } - ~replay_benchmark() = default; - replay_benchmark(replay_benchmark const&) = delete; - replay_benchmark& operator=(replay_benchmark const&) = delete; + ~replay_benchmark() = default; + replay_benchmark(replay_benchmark const&) = delete; + replay_benchmark& operator=(replay_benchmark const&) = delete; replay_benchmark& operator=(replay_benchmark&& other) noexcept = delete; /// Add an allocation to the map (NOT thread safe) diff --git a/benchmarks/synchronization/synchronization.hpp b/benchmarks/synchronization/synchronization.hpp index e9a3cd34a..1f26beb37 100644 --- a/benchmarks/synchronization/synchronization.hpp +++ b/benchmarks/synchronization/synchronization.hpp @@ -90,10 +90,10 @@ class cuda_event_timer { ~cuda_event_timer(); // disable copy and move - cuda_event_timer(cuda_event_timer const&) = delete; + cuda_event_timer(cuda_event_timer const&) = delete; cuda_event_timer& operator=(cuda_event_timer const&) = delete; cuda_event_timer(cuda_event_timer&&) = delete; - cuda_event_timer& operator=(cuda_event_timer&&) = delete; + cuda_event_timer& operator=(cuda_event_timer&&) = delete; private: cudaEvent_t start{}; diff --git a/benchmarks/utilities/log_parser.hpp b/benchmarks/utilities/log_parser.hpp index d52672a4b..bc1aee47c 100644 --- a/benchmarks/utilities/log_parser.hpp +++ b/benchmarks/utilities/log_parser.hpp @@ -40,10 +40,10 @@ enum class action { ALLOCATE, FREE, ALLOCATE_FAILURE }; * */ struct event { - event() = default; - event(event const&) = default; - event& operator=(event const&) = default; - event(event&&) noexcept = default; + event() = default; + event(event const&) = default; + event& operator=(event const&) = default; + event(event&&) noexcept = default; event& operator=(event&&) noexcept = default; ~event() = default; event(action act, std::size_t size, void const* ptr) diff --git a/benchmarks/utilities/simulated_memory_resource.hpp b/benchmarks/utilities/simulated_memory_resource.hpp index d8c7cf946..489339e69 100644 --- a/benchmarks/utilities/simulated_memory_resource.hpp +++ b/benchmarks/utilities/simulated_memory_resource.hpp @@ -46,10 +46,10 @@ class simulated_memory_resource final : public device_memory_resource { ~simulated_memory_resource() override = default; // Disable copy (and move) semantics. - simulated_memory_resource(simulated_memory_resource const&) = delete; + simulated_memory_resource(simulated_memory_resource const&) = delete; simulated_memory_resource& operator=(simulated_memory_resource const&) = delete; simulated_memory_resource(simulated_memory_resource&&) = delete; - simulated_memory_resource& operator=(simulated_memory_resource&&) = delete; + simulated_memory_resource& operator=(simulated_memory_resource&&) = delete; /** * @brief Query whether the resource supports use of non-null CUDA streams for diff --git a/include/rmm/cuda_stream.hpp b/include/rmm/cuda_stream.hpp index 185cd049e..d1adbf2ea 100644 --- a/include/rmm/cuda_stream.hpp +++ b/include/rmm/cuda_stream.hpp @@ -48,7 +48,7 @@ class cuda_stream { cuda_stream& operator=(cuda_stream&&) = default; ~cuda_stream() = default; cuda_stream(cuda_stream const&) = delete; // Copying disallowed: one stream one owner - cuda_stream& operator=(cuda_stream&) = delete; + cuda_stream& operator=(cuda_stream&) = delete; /** * @brief Construct a new cuda stream object diff --git a/include/rmm/cuda_stream_pool.hpp b/include/rmm/cuda_stream_pool.hpp index ee94a9850..71c426817 100644 --- a/include/rmm/cuda_stream_pool.hpp +++ b/include/rmm/cuda_stream_pool.hpp @@ -50,9 +50,9 @@ class cuda_stream_pool { } ~cuda_stream_pool() = default; - cuda_stream_pool(cuda_stream_pool&&) = delete; - cuda_stream_pool(cuda_stream_pool const&) = delete; - cuda_stream_pool& operator=(cuda_stream_pool&&) = delete; + cuda_stream_pool(cuda_stream_pool&&) = delete; + cuda_stream_pool(cuda_stream_pool const&) = delete; + cuda_stream_pool& operator=(cuda_stream_pool&&) = delete; cuda_stream_pool& operator=(cuda_stream_pool const&) = delete; /** diff --git a/include/rmm/cuda_stream_view.hpp b/include/rmm/cuda_stream_view.hpp index f913609f9..bc30f26d8 100644 --- a/include/rmm/cuda_stream_view.hpp +++ b/include/rmm/cuda_stream_view.hpp @@ -33,12 +33,12 @@ namespace rmm { */ class cuda_stream_view { public: - constexpr cuda_stream_view() = default; - constexpr cuda_stream_view(cuda_stream_view const&) = default; - constexpr cuda_stream_view(cuda_stream_view&&) = default; + constexpr cuda_stream_view() = default; + constexpr cuda_stream_view(cuda_stream_view const&) = default; + constexpr cuda_stream_view(cuda_stream_view&&) = default; constexpr cuda_stream_view& operator=(cuda_stream_view const&) = default; - constexpr cuda_stream_view& operator=(cuda_stream_view&&) = default; - ~cuda_stream_view() = default; + constexpr cuda_stream_view& operator=(cuda_stream_view&&) = default; + ~cuda_stream_view() = default; // Disable construction from literal 0 constexpr cuda_stream_view(int) = delete; //< Prevent cast from 0 diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index 189ba7e24..bd8a8211a 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -78,7 +78,7 @@ class device_buffer { public: // The copy constructor and copy assignment operator without a stream are deleted because they // provide no way to specify an explicit stream - device_buffer(device_buffer const& other) = delete; + device_buffer(device_buffer const& other) = delete; device_buffer& operator=(device_buffer const& other) = delete; /** @@ -394,10 +394,10 @@ class device_buffer { [[nodiscard]] mr::device_memory_resource* memory_resource() const noexcept { return _mr; } private: - void* _data{nullptr}; ///< Pointer to device memory allocation - std::size_t _size{}; ///< Requested size of the device memory allocation - std::size_t _capacity{}; ///< The actual size of the device memory allocation - cuda_stream_view _stream{}; ///< Stream to use for device memory deallocation + void* _data{nullptr}; ///< Pointer to device memory allocation + std::size_t _size{}; ///< Requested size of the device memory allocation + std::size_t _capacity{}; ///< The actual size of the device memory allocation + cuda_stream_view _stream{}; ///< Stream to use for device memory deallocation mr::device_memory_resource* _mr{ mr::get_current_device_resource()}; ///< The memory resource used to ///< allocate/deallocate device memory diff --git a/include/rmm/logger.hpp b/include/rmm/logger.hpp index 318535a4e..a12e7238e 100644 --- a/include/rmm/logger.hpp +++ b/include/rmm/logger.hpp @@ -113,5 +113,4 @@ inline spdlog::logger& logger() } // namespace rmm template <> -struct fmt::formatter : fmt::ostream_formatter { -}; +struct fmt::formatter : fmt::ostream_formatter {}; diff --git a/include/rmm/mr/device/aligned_resource_adaptor.hpp b/include/rmm/mr/device/aligned_resource_adaptor.hpp index 31b23a442..0b933fb56 100644 --- a/include/rmm/mr/device/aligned_resource_adaptor.hpp +++ b/include/rmm/mr/device/aligned_resource_adaptor.hpp @@ -69,12 +69,12 @@ class aligned_resource_adaptor final : public device_memory_resource { "Allocation alignment is not a power of 2."); } - aligned_resource_adaptor() = delete; - ~aligned_resource_adaptor() override = default; - aligned_resource_adaptor(aligned_resource_adaptor const&) = delete; - aligned_resource_adaptor(aligned_resource_adaptor&&) = delete; + aligned_resource_adaptor() = delete; + ~aligned_resource_adaptor() override = default; + aligned_resource_adaptor(aligned_resource_adaptor const&) = delete; + aligned_resource_adaptor(aligned_resource_adaptor&&) = delete; aligned_resource_adaptor& operator=(aligned_resource_adaptor const&) = delete; - aligned_resource_adaptor& operator=(aligned_resource_adaptor&&) = delete; + aligned_resource_adaptor& operator=(aligned_resource_adaptor&&) = delete; /** * @brief Get the upstream memory resource. diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index b007d8f54..67babfdc5 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -98,9 +98,9 @@ class arena_memory_resource final : public device_memory_resource { ~arena_memory_resource() override = default; // Disable copy (and move) semantics. - arena_memory_resource(arena_memory_resource const&) = delete; - arena_memory_resource& operator=(arena_memory_resource const&) = delete; - arena_memory_resource(arena_memory_resource&&) noexcept = delete; + arena_memory_resource(arena_memory_resource const&) = delete; + arena_memory_resource& operator=(arena_memory_resource const&) = delete; + arena_memory_resource(arena_memory_resource&&) noexcept = delete; arena_memory_resource& operator=(arena_memory_resource&&) noexcept = delete; /** diff --git a/include/rmm/mr/device/binning_memory_resource.hpp b/include/rmm/mr/device/binning_memory_resource.hpp index e8f9be4c4..705df63c6 100644 --- a/include/rmm/mr/device/binning_memory_resource.hpp +++ b/include/rmm/mr/device/binning_memory_resource.hpp @@ -87,11 +87,11 @@ class binning_memory_resource final : public device_memory_resource { */ ~binning_memory_resource() override = default; - binning_memory_resource() = delete; - binning_memory_resource(binning_memory_resource const&) = delete; - binning_memory_resource(binning_memory_resource&&) = delete; + binning_memory_resource() = delete; + binning_memory_resource(binning_memory_resource const&) = delete; + binning_memory_resource(binning_memory_resource&&) = delete; binning_memory_resource& operator=(binning_memory_resource const&) = delete; - binning_memory_resource& operator=(binning_memory_resource&&) = delete; + binning_memory_resource& operator=(binning_memory_resource&&) = delete; /** * @brief Query whether the resource supports use of non-null streams for diff --git a/include/rmm/mr/device/callback_memory_resource.hpp b/include/rmm/mr/device/callback_memory_resource.hpp index e2deef46b..1937e7ef0 100644 --- a/include/rmm/mr/device/callback_memory_resource.hpp +++ b/include/rmm/mr/device/callback_memory_resource.hpp @@ -90,11 +90,11 @@ class callback_memory_resource final : public device_memory_resource { { } - callback_memory_resource() = delete; - ~callback_memory_resource() override = default; - callback_memory_resource(callback_memory_resource const&) = delete; - callback_memory_resource& operator=(callback_memory_resource const&) = delete; - callback_memory_resource(callback_memory_resource&&) noexcept = default; + callback_memory_resource() = delete; + ~callback_memory_resource() override = default; + callback_memory_resource(callback_memory_resource const&) = delete; + callback_memory_resource& operator=(callback_memory_resource const&) = delete; + callback_memory_resource(callback_memory_resource&&) noexcept = default; callback_memory_resource& operator=(callback_memory_resource&&) noexcept = default; private: diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index f378d7fd3..d41eae63e 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -147,10 +147,10 @@ class cuda_async_memory_resource final : public device_memory_resource { RMM_ASSERT_CUDA_SUCCESS(rmm::detail::async_alloc::cudaMemPoolDestroy(pool_handle())); #endif } - cuda_async_memory_resource(cuda_async_memory_resource const&) = delete; - cuda_async_memory_resource(cuda_async_memory_resource&&) = delete; + cuda_async_memory_resource(cuda_async_memory_resource const&) = delete; + cuda_async_memory_resource(cuda_async_memory_resource&&) = delete; cuda_async_memory_resource& operator=(cuda_async_memory_resource const&) = delete; - cuda_async_memory_resource& operator=(cuda_async_memory_resource&&) = delete; + cuda_async_memory_resource& operator=(cuda_async_memory_resource&&) = delete; /** * @brief Query whether the resource supports use of non-null CUDA streams for diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index b562bc4c6..191e4741d 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -77,11 +77,11 @@ class cuda_async_view_memory_resource final : public device_memory_resource { [[nodiscard]] cudaMemPool_t pool_handle() const noexcept { return cuda_pool_handle_; } #endif - cuda_async_view_memory_resource() = default; - cuda_async_view_memory_resource(cuda_async_view_memory_resource const&) = default; - cuda_async_view_memory_resource(cuda_async_view_memory_resource&&) = default; + cuda_async_view_memory_resource() = default; + cuda_async_view_memory_resource(cuda_async_view_memory_resource const&) = default; + cuda_async_view_memory_resource(cuda_async_view_memory_resource&&) = default; cuda_async_view_memory_resource& operator=(cuda_async_view_memory_resource const&) = default; - cuda_async_view_memory_resource& operator=(cuda_async_view_memory_resource&&) = default; + cuda_async_view_memory_resource& operator=(cuda_async_view_memory_resource&&) = default; /** * @brief Query whether the resource supports use of non-null CUDA streams for diff --git a/include/rmm/mr/device/cuda_memory_resource.hpp b/include/rmm/mr/device/cuda_memory_resource.hpp index 800d0b62c..7a5385f4e 100644 --- a/include/rmm/mr/device/cuda_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_memory_resource.hpp @@ -29,12 +29,12 @@ namespace rmm::mr { */ class cuda_memory_resource final : public device_memory_resource { public: - cuda_memory_resource() = default; - ~cuda_memory_resource() override = default; - cuda_memory_resource(cuda_memory_resource const&) = default; - cuda_memory_resource(cuda_memory_resource&&) = default; + cuda_memory_resource() = default; + ~cuda_memory_resource() override = default; + cuda_memory_resource(cuda_memory_resource const&) = default; + cuda_memory_resource(cuda_memory_resource&&) = default; cuda_memory_resource& operator=(cuda_memory_resource const&) = default; - cuda_memory_resource& operator=(cuda_memory_resource&&) = default; + cuda_memory_resource& operator=(cuda_memory_resource&&) = default; /** * @brief Query whether the resource supports use of non-null CUDA streams for diff --git a/include/rmm/mr/device/detail/arena.hpp b/include/rmm/mr/device/detail/arena.hpp index 493fb6cb1..302c925f9 100644 --- a/include/rmm/mr/device/detail/arena.hpp +++ b/include/rmm/mr/device/detail/arena.hpp @@ -277,10 +277,10 @@ class superblock final : public byte_span { } // Disable copy semantics. - superblock(superblock const&) = delete; + superblock(superblock const&) = delete; superblock& operator=(superblock const&) = delete; // Allow move semantics. - superblock(superblock&&) noexcept = default; + superblock(superblock&&) noexcept = default; superblock& operator=(superblock&&) noexcept = default; ~superblock() = default; @@ -515,9 +515,9 @@ class global_arena final { } // Disable copy (and move) semantics. - global_arena(global_arena const&) = delete; - global_arena& operator=(global_arena const&) = delete; - global_arena(global_arena&&) noexcept = delete; + global_arena(global_arena const&) = delete; + global_arena& operator=(global_arena const&) = delete; + global_arena(global_arena&&) noexcept = delete; global_arena& operator=(global_arena&&) noexcept = delete; /** @@ -803,9 +803,9 @@ class arena { explicit arena(global_arena& global_arena) : global_arena_{global_arena} {} // Disable copy (and move) semantics. - arena(arena const&) = delete; - arena& operator=(arena const&) = delete; - arena(arena&&) noexcept = delete; + arena(arena const&) = delete; + arena& operator=(arena const&) = delete; + arena(arena&&) noexcept = delete; arena& operator=(arena&&) noexcept = delete; ~arena() = default; @@ -979,10 +979,10 @@ class arena_cleaner { explicit arena_cleaner(std::shared_ptr> const& arena) : arena_(arena) {} // Disable copy (and move) semantics. - arena_cleaner(arena_cleaner const&) = delete; + arena_cleaner(arena_cleaner const&) = delete; arena_cleaner& operator=(arena_cleaner const&) = delete; arena_cleaner(arena_cleaner&&) noexcept = delete; - arena_cleaner& operator=(arena_cleaner&&) = delete; + arena_cleaner& operator=(arena_cleaner&&) = delete; ~arena_cleaner() { diff --git a/include/rmm/mr/device/detail/coalescing_free_list.hpp b/include/rmm/mr/device/detail/coalescing_free_list.hpp index d98ef7968..dbc706117 100644 --- a/include/rmm/mr/device/detail/coalescing_free_list.hpp +++ b/include/rmm/mr/device/detail/coalescing_free_list.hpp @@ -175,10 +175,10 @@ struct coalescing_free_list : free_list { coalescing_free_list() = default; ~coalescing_free_list() override = default; - coalescing_free_list(coalescing_free_list const&) = delete; + coalescing_free_list(coalescing_free_list const&) = delete; coalescing_free_list& operator=(coalescing_free_list const&) = delete; coalescing_free_list(coalescing_free_list&&) = delete; - coalescing_free_list& operator=(coalescing_free_list&&) = delete; + coalescing_free_list& operator=(coalescing_free_list&&) = delete; /** * @brief Inserts a block into the `free_list` in the correct order, coalescing it with the diff --git a/include/rmm/mr/device/detail/fixed_size_free_list.hpp b/include/rmm/mr/device/detail/fixed_size_free_list.hpp index 1ca1656b0..ad26904c2 100644 --- a/include/rmm/mr/device/detail/fixed_size_free_list.hpp +++ b/include/rmm/mr/device/detail/fixed_size_free_list.hpp @@ -27,10 +27,10 @@ struct fixed_size_free_list : free_list { fixed_size_free_list() = default; ~fixed_size_free_list() override = default; - fixed_size_free_list(fixed_size_free_list const&) = delete; + fixed_size_free_list(fixed_size_free_list const&) = delete; fixed_size_free_list& operator=(fixed_size_free_list const&) = delete; fixed_size_free_list(fixed_size_free_list&&) = delete; - fixed_size_free_list& operator=(fixed_size_free_list&&) = delete; + fixed_size_free_list& operator=(fixed_size_free_list&&) = delete; /** * @brief Construct a new free_list from range defined by input iterators diff --git a/include/rmm/mr/device/detail/free_list.hpp b/include/rmm/mr/device/detail/free_list.hpp index baf8732a4..d4d42c122 100644 --- a/include/rmm/mr/device/detail/free_list.hpp +++ b/include/rmm/mr/device/detail/free_list.hpp @@ -67,10 +67,10 @@ class free_list { free_list() = default; virtual ~free_list() = default; - free_list(free_list const&) = delete; + free_list(free_list const&) = delete; free_list& operator=(free_list const&) = delete; free_list(free_list&&) = delete; - free_list& operator=(free_list&&) = delete; + free_list& operator=(free_list&&) = delete; using block_type = BlockType; using list_type = ListType; diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index ddd3cb728..69932913d 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -78,11 +78,11 @@ class stream_ordered_memory_resource : public crtp, public device_ public: ~stream_ordered_memory_resource() override { release(); } - stream_ordered_memory_resource() = default; - stream_ordered_memory_resource(stream_ordered_memory_resource const&) = delete; - stream_ordered_memory_resource(stream_ordered_memory_resource&&) = delete; + stream_ordered_memory_resource() = default; + stream_ordered_memory_resource(stream_ordered_memory_resource const&) = delete; + stream_ordered_memory_resource(stream_ordered_memory_resource&&) = delete; stream_ordered_memory_resource& operator=(stream_ordered_memory_resource const&) = delete; - stream_ordered_memory_resource& operator=(stream_ordered_memory_resource&&) = delete; + stream_ordered_memory_resource& operator=(stream_ordered_memory_resource&&) = delete; protected: using free_list = FreeListType; @@ -269,10 +269,10 @@ class stream_ordered_memory_resource : public crtp, public device_ ~event_wrapper() { RMM_ASSERT_CUDA_SUCCESS(cudaEventDestroy(event)); } cudaEvent_t event{}; - event_wrapper(event_wrapper const&) = delete; + event_wrapper(event_wrapper const&) = delete; event_wrapper& operator=(event_wrapper const&) = delete; event_wrapper(event_wrapper&&) noexcept = delete; - event_wrapper& operator=(event_wrapper&&) = delete; + event_wrapper& operator=(event_wrapper&&) = delete; }; /** diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index 52aa8c79f..e3ab954b5 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -81,11 +81,11 @@ namespace rmm::mr { */ class device_memory_resource { public: - device_memory_resource() = default; - virtual ~device_memory_resource() = default; - device_memory_resource(device_memory_resource const&) = default; - device_memory_resource& operator=(device_memory_resource const&) = default; - device_memory_resource(device_memory_resource&&) noexcept = default; + device_memory_resource() = default; + virtual ~device_memory_resource() = default; + device_memory_resource(device_memory_resource const&) = default; + device_memory_resource& operator=(device_memory_resource const&) = default; + device_memory_resource(device_memory_resource&&) noexcept = default; device_memory_resource& operator=(device_memory_resource&&) noexcept = default; /** diff --git a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp index b4e497868..4a46cb660 100644 --- a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp +++ b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp @@ -105,9 +105,9 @@ class failure_callback_resource_adaptor final : public device_memory_resource { RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); } - failure_callback_resource_adaptor() = delete; - ~failure_callback_resource_adaptor() override = default; - failure_callback_resource_adaptor(failure_callback_resource_adaptor const&) = delete; + failure_callback_resource_adaptor() = delete; + ~failure_callback_resource_adaptor() override = default; + failure_callback_resource_adaptor(failure_callback_resource_adaptor const&) = delete; failure_callback_resource_adaptor& operator=(failure_callback_resource_adaptor const&) = delete; failure_callback_resource_adaptor(failure_callback_resource_adaptor&&) noexcept = default; failure_callback_resource_adaptor& operator=(failure_callback_resource_adaptor&&) noexcept = diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index 9a1923c2d..b3686f78a 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -84,11 +84,11 @@ class fixed_size_memory_resource */ ~fixed_size_memory_resource() override { release(); } - fixed_size_memory_resource() = delete; - fixed_size_memory_resource(fixed_size_memory_resource const&) = delete; - fixed_size_memory_resource(fixed_size_memory_resource&&) = delete; + fixed_size_memory_resource() = delete; + fixed_size_memory_resource(fixed_size_memory_resource const&) = delete; + fixed_size_memory_resource(fixed_size_memory_resource&&) = delete; fixed_size_memory_resource& operator=(fixed_size_memory_resource const&) = delete; - fixed_size_memory_resource& operator=(fixed_size_memory_resource&&) = delete; + fixed_size_memory_resource& operator=(fixed_size_memory_resource&&) = delete; /** * @brief Query whether the resource supports use of non-null streams for @@ -271,7 +271,7 @@ class fixed_size_memory_resource } private: - Upstream* upstream_mr_; // The resource from which to allocate new blocks + Upstream* upstream_mr_; // The resource from which to allocate new blocks std::size_t const block_size_; // size of blocks this MR allocates std::size_t const upstream_chunk_size_; // size of chunks allocated from heap MR diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index ba21cbb51..6d1843e82 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -57,11 +57,11 @@ class limiting_resource_adaptor final : public device_memory_resource { RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); } - limiting_resource_adaptor() = delete; - ~limiting_resource_adaptor() override = default; - limiting_resource_adaptor(limiting_resource_adaptor const&) = delete; - limiting_resource_adaptor(limiting_resource_adaptor&&) noexcept = default; - limiting_resource_adaptor& operator=(limiting_resource_adaptor const&) = delete; + limiting_resource_adaptor() = delete; + ~limiting_resource_adaptor() override = default; + limiting_resource_adaptor(limiting_resource_adaptor const&) = delete; + limiting_resource_adaptor(limiting_resource_adaptor&&) noexcept = default; + limiting_resource_adaptor& operator=(limiting_resource_adaptor const&) = delete; limiting_resource_adaptor& operator=(limiting_resource_adaptor&&) noexcept = default; /** diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index ee887f5b9..71487705a 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -108,11 +108,11 @@ class logging_resource_adaptor final : public device_memory_resource { init_logger(auto_flush); } - logging_resource_adaptor() = delete; - ~logging_resource_adaptor() override = default; - logging_resource_adaptor(logging_resource_adaptor const&) = delete; - logging_resource_adaptor& operator=(logging_resource_adaptor const&) = delete; - logging_resource_adaptor(logging_resource_adaptor&&) noexcept = default; + logging_resource_adaptor() = delete; + ~logging_resource_adaptor() override = default; + logging_resource_adaptor(logging_resource_adaptor const&) = delete; + logging_resource_adaptor& operator=(logging_resource_adaptor const&) = delete; + logging_resource_adaptor(logging_resource_adaptor&&) noexcept = default; logging_resource_adaptor& operator=(logging_resource_adaptor&&) noexcept = default; /** @@ -301,8 +301,8 @@ class logging_resource_adaptor final : public device_memory_resource { std::shared_ptr logger_; ///< spdlog logger object - Upstream* upstream_; ///< The upstream resource used for satisfying - ///< allocation requests + Upstream* upstream_; ///< The upstream resource used for satisfying + ///< allocation requests }; /** diff --git a/include/rmm/mr/device/managed_memory_resource.hpp b/include/rmm/mr/device/managed_memory_resource.hpp index d36b43e7d..50317720a 100644 --- a/include/rmm/mr/device/managed_memory_resource.hpp +++ b/include/rmm/mr/device/managed_memory_resource.hpp @@ -29,12 +29,12 @@ namespace rmm::mr { */ class managed_memory_resource final : public device_memory_resource { public: - managed_memory_resource() = default; - ~managed_memory_resource() override = default; - managed_memory_resource(managed_memory_resource const&) = default; - managed_memory_resource(managed_memory_resource&&) = default; + managed_memory_resource() = default; + ~managed_memory_resource() override = default; + managed_memory_resource(managed_memory_resource const&) = default; + managed_memory_resource(managed_memory_resource&&) = default; managed_memory_resource& operator=(managed_memory_resource const&) = default; - managed_memory_resource& operator=(managed_memory_resource&&) = default; + managed_memory_resource& operator=(managed_memory_resource&&) = default; /** * @brief Query whether the resource supports use of non-null streams for diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 297b3f864..465c0653f 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -104,11 +104,11 @@ class pool_memory_resource final */ ~pool_memory_resource() override { release(); } - pool_memory_resource() = delete; - pool_memory_resource(pool_memory_resource const&) = delete; - pool_memory_resource(pool_memory_resource&&) = delete; + pool_memory_resource() = delete; + pool_memory_resource(pool_memory_resource const&) = delete; + pool_memory_resource(pool_memory_resource&&) = delete; pool_memory_resource& operator=(pool_memory_resource const&) = delete; - pool_memory_resource& operator=(pool_memory_resource&&) = delete; + pool_memory_resource& operator=(pool_memory_resource&&) = delete; /** * @brief Queries whether the resource supports use of non-null CUDA streams for diff --git a/include/rmm/mr/device/statistics_resource_adaptor.hpp b/include/rmm/mr/device/statistics_resource_adaptor.hpp index 298ac8bc1..c3fe3010f 100644 --- a/include/rmm/mr/device/statistics_resource_adaptor.hpp +++ b/include/rmm/mr/device/statistics_resource_adaptor.hpp @@ -79,11 +79,11 @@ class statistics_resource_adaptor final : public device_memory_resource { RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); } - statistics_resource_adaptor() = delete; - ~statistics_resource_adaptor() override = default; - statistics_resource_adaptor(statistics_resource_adaptor const&) = delete; - statistics_resource_adaptor& operator=(statistics_resource_adaptor const&) = delete; - statistics_resource_adaptor(statistics_resource_adaptor&&) noexcept = default; + statistics_resource_adaptor() = delete; + ~statistics_resource_adaptor() override = default; + statistics_resource_adaptor(statistics_resource_adaptor const&) = delete; + statistics_resource_adaptor& operator=(statistics_resource_adaptor const&) = delete; + statistics_resource_adaptor(statistics_resource_adaptor&&) noexcept = default; statistics_resource_adaptor& operator=(statistics_resource_adaptor&&) noexcept = default; /** diff --git a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp index 340ffa43d..37053cd07 100644 --- a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp +++ b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp @@ -52,12 +52,12 @@ class thread_safe_resource_adaptor final : public device_memory_resource { RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); } - thread_safe_resource_adaptor() = delete; - ~thread_safe_resource_adaptor() override = default; - thread_safe_resource_adaptor(thread_safe_resource_adaptor const&) = delete; - thread_safe_resource_adaptor(thread_safe_resource_adaptor&&) = delete; + thread_safe_resource_adaptor() = delete; + ~thread_safe_resource_adaptor() override = default; + thread_safe_resource_adaptor(thread_safe_resource_adaptor const&) = delete; + thread_safe_resource_adaptor(thread_safe_resource_adaptor&&) = delete; thread_safe_resource_adaptor& operator=(thread_safe_resource_adaptor const&) = delete; - thread_safe_resource_adaptor& operator=(thread_safe_resource_adaptor&&) = delete; + thread_safe_resource_adaptor& operator=(thread_safe_resource_adaptor&&) = delete; /** * @brief Get the upstream memory resource. diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index f1996ba01..3feac1213 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -83,11 +83,11 @@ class tracking_resource_adaptor final : public device_memory_resource { RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); } - tracking_resource_adaptor() = delete; - ~tracking_resource_adaptor() override = default; - tracking_resource_adaptor(tracking_resource_adaptor const&) = delete; - tracking_resource_adaptor& operator=(tracking_resource_adaptor const&) = delete; - tracking_resource_adaptor(tracking_resource_adaptor&&) noexcept = default; + tracking_resource_adaptor() = delete; + ~tracking_resource_adaptor() override = default; + tracking_resource_adaptor(tracking_resource_adaptor const&) = delete; + tracking_resource_adaptor& operator=(tracking_resource_adaptor const&) = delete; + tracking_resource_adaptor(tracking_resource_adaptor&&) noexcept = default; tracking_resource_adaptor& operator=(tracking_resource_adaptor&&) noexcept = default; /** diff --git a/include/rmm/mr/host/host_memory_resource.hpp b/include/rmm/mr/host/host_memory_resource.hpp index 4edffc860..c0fe85594 100644 --- a/include/rmm/mr/host/host_memory_resource.hpp +++ b/include/rmm/mr/host/host_memory_resource.hpp @@ -46,11 +46,11 @@ namespace rmm::mr { */ class host_memory_resource { public: - host_memory_resource() = default; - virtual ~host_memory_resource() = default; - host_memory_resource(host_memory_resource const&) = default; - host_memory_resource& operator=(host_memory_resource const&) = default; - host_memory_resource(host_memory_resource&&) noexcept = default; + host_memory_resource() = default; + virtual ~host_memory_resource() = default; + host_memory_resource(host_memory_resource const&) = default; + host_memory_resource& operator=(host_memory_resource const&) = default; + host_memory_resource(host_memory_resource&&) noexcept = default; host_memory_resource& operator=(host_memory_resource&&) noexcept = default; /** diff --git a/include/rmm/mr/host/new_delete_resource.hpp b/include/rmm/mr/host/new_delete_resource.hpp index 573ffb67f..ffd3345bb 100644 --- a/include/rmm/mr/host/new_delete_resource.hpp +++ b/include/rmm/mr/host/new_delete_resource.hpp @@ -30,12 +30,12 @@ namespace rmm::mr { */ class new_delete_resource final : public host_memory_resource { public: - new_delete_resource() = default; - ~new_delete_resource() override = default; - new_delete_resource(new_delete_resource const&) = default; - new_delete_resource(new_delete_resource&&) = default; + new_delete_resource() = default; + ~new_delete_resource() override = default; + new_delete_resource(new_delete_resource const&) = default; + new_delete_resource(new_delete_resource&&) = default; new_delete_resource& operator=(new_delete_resource const&) = default; - new_delete_resource& operator=(new_delete_resource&&) = default; + new_delete_resource& operator=(new_delete_resource&&) = default; private: /** diff --git a/include/rmm/mr/host/pinned_memory_resource.hpp b/include/rmm/mr/host/pinned_memory_resource.hpp index 5f9824dad..3e0c5e3e6 100644 --- a/include/rmm/mr/host/pinned_memory_resource.hpp +++ b/include/rmm/mr/host/pinned_memory_resource.hpp @@ -32,12 +32,12 @@ namespace rmm::mr { */ class pinned_memory_resource final : public host_memory_resource { public: - pinned_memory_resource() = default; - ~pinned_memory_resource() override = default; - pinned_memory_resource(pinned_memory_resource const&) = default; - pinned_memory_resource(pinned_memory_resource&&) = default; + pinned_memory_resource() = default; + ~pinned_memory_resource() override = default; + pinned_memory_resource(pinned_memory_resource const&) = default; + pinned_memory_resource(pinned_memory_resource&&) = default; pinned_memory_resource& operator=(pinned_memory_resource const&) = default; - pinned_memory_resource& operator=(pinned_memory_resource&&) = default; + pinned_memory_resource& operator=(pinned_memory_resource&&) = default; private: /** diff --git a/tests/cuda_stream_tests.cpp b/tests/cuda_stream_tests.cpp index 76423e403..465e5d4c5 100644 --- a/tests/cuda_stream_tests.cpp +++ b/tests/cuda_stream_tests.cpp @@ -24,8 +24,7 @@ #include #include -struct CudaStreamTest : public ::testing::Test { -}; +struct CudaStreamTest : public ::testing::Test {}; TEST_F(CudaStreamTest, Equality) { diff --git a/tests/logger_tests.cpp b/tests/logger_tests.cpp index f221a3a36..b3d4eb755 100644 --- a/tests/logger_tests.cpp +++ b/tests/logger_tests.cpp @@ -48,10 +48,10 @@ class raii_restore_env { } } - raii_restore_env(raii_restore_env const&) = default; + raii_restore_env(raii_restore_env const&) = default; raii_restore_env& operator=(raii_restore_env const&) = default; raii_restore_env(raii_restore_env&&) = default; - raii_restore_env& operator=(raii_restore_env&&) = default; + raii_restore_env& operator=(raii_restore_env&&) = default; private: std::string name_{}; diff --git a/tests/mr/device/arena_mr_tests.cpp b/tests/mr/device/arena_mr_tests.cpp index b86e2457c..23d0c1b85 100644 --- a/tests/mr/device/arena_mr_tests.cpp +++ b/tests/mr/device/arena_mr_tests.cpp @@ -486,7 +486,7 @@ TEST_F(ArenaTest, SizeSmallerThanSuperblockSize) // NOLINT TEST_F(ArenaTest, AllocateNinetyPercent) // NOLINT { - EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) + EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) auto const free = rmm::detail::available_device_memory().first; auto const ninety_percent = rmm::detail::align_up(static_cast(static_cast(free) * 0.9), @@ -497,7 +497,7 @@ TEST_F(ArenaTest, AllocateNinetyPercent) // NOLINT TEST_F(ArenaTest, SmallMediumLarge) // NOLINT { - EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) + EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) arena_mr mr(rmm::mr::get_current_device_resource()); auto* small = mr.allocate(256); auto* medium = mr.allocate(64_MiB); @@ -511,7 +511,7 @@ TEST_F(ArenaTest, SmallMediumLarge) // NOLINT TEST_F(ArenaTest, Defragment) // NOLINT { - EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) + EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) auto const arena_size = superblock::minimum_size * 4; arena_mr mr(rmm::mr::get_current_device_resource(), arena_size); std::vector threads; @@ -556,8 +556,7 @@ TEST_F(ArenaTest, DumpLogOnFailure) // NOLINT // NOLINTNEXTLINE(cppcoreguidelines-avoid-goto) EXPECT_THROW(mr.allocate(8_MiB), rmm::out_of_memory); - struct stat file_status { - }; + struct stat file_status {}; EXPECT_EQ(stat("rmm_arena_memory_dump.log", &file_status), 0); EXPECT_GE(file_status.st_size, 0); } diff --git a/tests/mr/device/failure_callback_mr_tests.cpp b/tests/mr/device/failure_callback_mr_tests.cpp index bb5484c69..11c119304 100644 --- a/tests/mr/device/failure_callback_mr_tests.cpp +++ b/tests/mr/device/failure_callback_mr_tests.cpp @@ -40,7 +40,7 @@ bool failure_handler(std::size_t /*bytes*/, void* arg) retried = true; return true; // First time we request an allocation retry } - return false; // Second time we let the adaptor throw std::bad_alloc + return false; // Second time we let the adaptor throw std::bad_alloc } TEST(FailureCallbackTest, RetryAllocationOnce) diff --git a/tests/mr/device/mr_multithreaded_tests.cpp b/tests/mr/device/mr_multithreaded_tests.cpp index 1412e828f..113b59e8f 100644 --- a/tests/mr/device/mr_multithreaded_tests.cpp +++ b/tests/mr/device/mr_multithreaded_tests.cpp @@ -31,8 +31,7 @@ namespace rmm::test { namespace { -struct mr_test_mt : public mr_test { -}; +struct mr_test_mt : public mr_test {}; INSTANTIATE_TEST_CASE_P(MultiThreadResourceTests, mr_test_mt, diff --git a/tests/mr/device/mr_test.hpp b/tests/mr/device/mr_test.hpp index 790c697cf..8c69df215 100644 --- a/tests/mr/device/mr_test.hpp +++ b/tests/mr/device/mr_test.hpp @@ -244,8 +244,7 @@ struct mr_test : public ::testing::TestWithParam { rmm::cuda_stream stream{}; }; -struct mr_allocation_test : public mr_test { -}; +struct mr_allocation_test : public mr_test {}; /// MR factory functions inline auto make_cuda() { return std::make_shared(); } diff --git a/tests/mr/device/pool_mr_tests.cpp b/tests/mr/device/pool_mr_tests.cpp index c4622075e..c5df1951c 100644 --- a/tests/mr/device/pool_mr_tests.cpp +++ b/tests/mr/device/pool_mr_tests.cpp @@ -100,7 +100,7 @@ TEST(PoolTest, ForceGrowth) EXPECT_NO_THROW(mr.allocate(1000)); EXPECT_THROW(mr.allocate(4000), rmm::out_of_memory); // too much EXPECT_NO_THROW(mr.allocate(500)); - EXPECT_NO_THROW(mr.allocate(2000)); // fits + EXPECT_NO_THROW(mr.allocate(2000)); // fits } } diff --git a/tests/mr/device/thrust_allocator_tests.cu b/tests/mr/device/thrust_allocator_tests.cu index 3a56a541b..41fb15973 100644 --- a/tests/mr/device/thrust_allocator_tests.cu +++ b/tests/mr/device/thrust_allocator_tests.cu @@ -31,8 +31,7 @@ template class rmm::mr::thrust_allocator; namespace rmm::test { namespace { -struct allocator_test : public mr_test { -}; +struct allocator_test : public mr_test {}; TEST_P(allocator_test, first) { From 3e6c612cc181134e796d48cbf8f73ebf0cc5ef72 Mon Sep 17 00:00:00 2001 From: Jordan Jacobelli Date: Mon, 17 Apr 2023 17:51:47 +0200 Subject: [PATCH 242/675] Use ARC V2 self-hosted runners for GPU jobs (#1239) This PR is updating the runner labels to use ARC V2 self-hosted runners for GPU jobs. This is needed to resolve the auto-scalling issues. Authors: - Jordan Jacobelli (https://github.com/jjacobelli) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1239 --- .github/workflows/build.yaml | 2 +- .github/workflows/pr.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 39c204632..6f6c8feb7 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -59,7 +59,7 @@ jobs: uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.06 with: build_type: branch - node_type: "gpu-latest-1" + node_type: "gpu-v100-latest-1" arch: "amd64" container_image: "rapidsai/ci:latest" run_script: "ci/build_docs.sh" diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 90f0b323f..9ff6b5b0c 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -57,7 +57,7 @@ jobs: uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.06 with: build_type: pull-request - node_type: "gpu-latest-1" + node_type: "gpu-v100-latest-1" arch: "amd64" container_image: "rapidsai/ci:latest" run_script: "ci/build_docs.sh" From 0e7b2d7ca0b7dda214fe2b58e26d59ee9e9d4c9b Mon Sep 17 00:00:00 2001 From: Sevag H Date: Tue, 18 Apr 2023 11:34:52 -0400 Subject: [PATCH 243/675] Remove wheel pytest verbosity (#1249) This PR removes the verbose flag from wheel pytest commands Authors: - Sevag H (https://github.com/sevagh) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1249 --- .github/workflows/pr.yaml | 2 +- .github/workflows/test.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 9ff6b5b0c..0e5a92b79 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -77,5 +77,5 @@ jobs: with: build_type: pull-request package-name: rmm - test-unittest: "python -m pytest -v ./python/rmm/tests" + test-unittest: "python -m pytest ./python/rmm/tests" test-smoketest: "python ./ci/wheel_smoke_test.py" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0dc90f036..039fd3b42 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -39,4 +39,4 @@ jobs: date: ${{ inputs.date }} sha: ${{ inputs.sha }} package-name: rmm - test-unittest: "python -m pytest -v ./python/rmm/tests" + test-unittest: "python -m pytest ./python/rmm/tests" From 9d3834b6ed0370ee6c86441750ab8cf8fb008e72 Mon Sep 17 00:00:00 2001 From: Jordan Jacobelli Date: Thu, 20 Apr 2023 21:55:18 +0200 Subject: [PATCH 244/675] Remove usage of rapids-get-rapids-version-from-git (#1251) Instead of using `rapids-get-rapids-version-from-git` we can just hardcode the version and use `update-version.sh` to update it Authors: - Jordan Jacobelli (https://github.com/jjacobelli) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1251 --- ci/build_docs.sh | 2 +- ci/release/update-version.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/build_docs.sh b/ci/build_docs.sh index dc7d54493..06f76b6ee 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -19,7 +19,7 @@ rapids-print-env rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) -VERSION_NUMBER=$(rapids-get-rapids-version-from-git) +VERSION_NUMBER="23.06" rapids-mamba-retry install \ --channel "${CPP_CHANNEL}" \ diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 05218e811..ff90e410a 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -49,6 +49,8 @@ sed_runner 's/'"PROJECT_NUMBER = .*"'/'"PROJECT_NUMBER = ${NEXT_ sed_runner 's/'"version =.*"'/'"version = \"${NEXT_SHORT_TAG}\""'/g' python/docs/conf.py sed_runner 's/'"release =.*"'/'"release = \"${NEXT_FULL_TAG}\""'/g' python/docs/conf.py +# CI files for FILE in .github/workflows/*.yaml; do sed_runner "/shared-action-workflows/ s/@.*/@branch-${NEXT_SHORT_TAG}/g" "${FILE}" done +sed_runner "s/VERSION_NUMBER=\".*/VERSION_NUMBER=\"${NEXT_SHORT_TAG}\"/g" ci/build_docs.sh From a7f5d77fc599fa6d75096bb2ef116e33f8192db2 Mon Sep 17 00:00:00 2001 From: Allard Hendriksen Date: Fri, 21 Apr 2023 00:08:47 +0200 Subject: [PATCH 245/675] Move RMM_LOGGING_ASSERT into separate header (#1241) Related to issue #1222 and also PR #1232. Compared to #1232, this PR might make it able to also have fast builds without precompiling spdlog. I include a table below showing which headers transitively include `rmm/logger.hpp` before and after PR (in debug and release builds). These are the rmm headers used by RAFT. | Header | Before | After | |-----------------------------------------------------|----------------|----------------| | rmm/cuda_device.hpp | debug release | | | rmm/cuda_stream.hpp | debug release | debug | | rmm/cuda_stream_pool.hpp | debug release | debug | | rmm/cuda_stream_view.hpp | debug release | | | rmm/device_buffer.hpp | debug release | | | rmm/device_scalar.hpp | debug release | | | rmm/device_uvector.hpp | debug release | | | rmm/device_vector.hpp | debug release | | | rmm/exec_policy.hpp | debug release | | | rmm/logger.hpp | debug release | debug release | | rmm/mr/device/aligned_resource_adaptor.hpp | debug release | | | rmm/mr/device/arena_memory_resource.hpp | debug release | debug release | | rmm/mr/device/binning_memory_resource.hpp | debug release | debug release | | rmm/mr/device/callback_memory_resource.hpp | debug release | | | rmm/mr/device/cuda_async_memory_resource.hpp | debug release | | | rmm/mr/device/cuda_async_view_memory_resource.hpp | debug release | | | rmm/mr/device/cuda_memory_resource.hpp | debug release | | | rmm/mr/device/device_memory_resource.hpp | debug release | | | rmm/mr/device/failure_callback_resource_adaptor.hpp | debug release | | | rmm/mr/device/fixed_size_memory_resource.hpp | debug release | debug release | | rmm/mr/device/limiting_resource_adaptor.hpp | debug release | | | rmm/mr/device/logging_resource_adaptor.hpp | debug release | debug release | | rmm/mr/device/managed_memory_resource.hpp | debug release | | | rmm/mr/device/owning_wrapper.hpp | debug release | | | rmm/mr/device/per_device_resource.hpp | debug release | | | rmm/mr/device/polymorphic_allocator.hpp | debug release | | | rmm/mr/device/pool_memory_resource.hpp | debug release | debug release | | rmm/mr/device/statistics_resource_adaptor.hpp | debug release | | | rmm/mr/device/thread_safe_resource_adaptor.hpp | debug release | | | rmm/mr/device/thrust_allocator_adaptor.hpp | debug release | | | rmm/mr/device/tracking_resource_adaptor.hpp | debug release | debug release | | rmm/mr/host/host_memory_resource.hpp | | | | rmm/mr/host/new_delete_resource.hpp | | | | rmm/mr/host/pinned_memory_resource.hpp | debug release | | Authors: - Allard Hendriksen (https://github.com/ahendriksen) - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Mark Harris (https://github.com/harrism) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1241 --- include/rmm/cuda_stream.hpp | 2 + include/rmm/detail/error.hpp | 23 --------- include/rmm/detail/logging_assert.hpp | 47 +++++++++++++++++++ .../rmm/mr/device/arena_memory_resource.hpp | 1 + include/rmm/mr/device/detail/arena.hpp | 1 + .../mr/device/fixed_size_memory_resource.hpp | 1 + .../rmm/mr/device/pool_memory_resource.hpp | 1 + .../mr/device/tracking_resource_adaptor.hpp | 1 + tests/mr/device/tracking_mr_tests.cpp | 1 + 9 files changed, 55 insertions(+), 23 deletions(-) create mode 100644 include/rmm/detail/logging_assert.hpp diff --git a/include/rmm/cuda_stream.hpp b/include/rmm/cuda_stream.hpp index d1adbf2ea..9d2dab4f0 100644 --- a/include/rmm/cuda_stream.hpp +++ b/include/rmm/cuda_stream.hpp @@ -16,8 +16,10 @@ #pragma once +#include #include #include +#include #include diff --git a/include/rmm/detail/error.hpp b/include/rmm/detail/error.hpp index 1c669822c..5d8b340ab 100644 --- a/include/rmm/detail/error.hpp +++ b/include/rmm/detail/error.hpp @@ -16,8 +16,6 @@ #pragma once -#include - #include #include @@ -245,24 +243,3 @@ class out_of_range : public std::out_of_range { assert(status__ == cudaSuccess); \ } while (0) #endif - -/** - * @brief Assertion that logs a CRITICAL log message on failure. - */ -#ifdef NDEBUG -#define RMM_LOGGING_ASSERT(_expr) (void)0 -#elif SPDLOG_ACTIVE_LEVEL < SPDLOG_LEVEL_OFF -#define RMM_LOGGING_ASSERT(_expr) \ - do { \ - bool const success = (_expr); \ - if (!success) { \ - RMM_LOG_CRITICAL( \ - "[" __FILE__ ":" RMM_STRINGIFY(__LINE__) "] Assertion " RMM_STRINGIFY(_expr) " failed."); \ - rmm::logger().flush(); \ - /* NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay) */ \ - assert(success); \ - } \ - } while (0) -#else -#define RMM_LOGGING_ASSERT(_expr) assert((_expr)); -#endif diff --git a/include/rmm/detail/logging_assert.hpp b/include/rmm/detail/logging_assert.hpp new file mode 100644 index 000000000..321bddab8 --- /dev/null +++ b/include/rmm/detail/logging_assert.hpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2020, 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. + */ + +#pragma once + +// Only include if needed in RMM_LOGGING_ASSERT below. The +// logger can be extremely expensive to compile, so we want to avoid including +// it. +#if !defined(NDEBUG) +#include +#include +#include +#endif + +/** + * @brief Assertion that logs a CRITICAL log message on failure. + */ +#ifdef NDEBUG +#define RMM_LOGGING_ASSERT(_expr) (void)0 +#elif SPDLOG_ACTIVE_LEVEL < SPDLOG_LEVEL_OFF +#define RMM_LOGGING_ASSERT(_expr) \ + do { \ + bool const success = (_expr); \ + if (!success) { \ + RMM_LOG_CRITICAL( \ + "[" __FILE__ ":" RMM_STRINGIFY(__LINE__) "] Assertion " RMM_STRINGIFY(_expr) " failed."); \ + rmm::logger().flush(); \ + /* NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay) */ \ + assert(success); \ + } \ + } while (0) +#else +#define RMM_LOGGING_ASSERT(_expr) assert((_expr)); +#endif diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index 67babfdc5..e16fbaf7c 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -16,6 +16,7 @@ #pragma once #include +#include #include #include #include diff --git a/include/rmm/mr/device/detail/arena.hpp b/include/rmm/mr/device/detail/arena.hpp index 302c925f9..d8da58493 100644 --- a/include/rmm/mr/device/detail/arena.hpp +++ b/include/rmm/mr/device/detail/arena.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index b3686f78a..4954415c3 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 465c0653f..8955fd958 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index 3feac1213..0bbdc7468 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -17,6 +17,7 @@ #include #include +#include #include #include diff --git a/tests/mr/device/tracking_mr_tests.cpp b/tests/mr/device/tracking_mr_tests.cpp index e804cf0ea..2af720d3f 100644 --- a/tests/mr/device/tracking_mr_tests.cpp +++ b/tests/mr/device/tracking_mr_tests.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include From 528b283cacdc312ef99052644a0bb33e07338836 Mon Sep 17 00:00:00 2001 From: Ashwin Srinath <3190405+shwina@users.noreply.github.com> Date: Fri, 21 Apr 2023 14:54:24 -0400 Subject: [PATCH 246/675] Update minimum Python version to Python 3.9 (#1252) Authors: - Ashwin Srinath (https://github.com/shwina) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1252 --- .github/workflows/build.yaml | 12 ++++++------ .github/workflows/pr.yaml | 18 +++++++++--------- .github/workflows/test.yaml | 6 +++--- README.md | 2 +- .../environments/all_cuda-118_arch-x86_64.yaml | 2 +- dependencies.yaml | 6 +----- python/pyproject.toml | 6 +++--- 7 files changed, 24 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6f6c8feb7..487d89616 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@py-39 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@py-39 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@py-39 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' && github.event_name == 'push' needs: python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@py-39 with: build_type: branch node_type: "gpu-v100-latest-1" @@ -65,7 +65,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@py-39 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -77,7 +77,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@py-39 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 0e5a92b79..866afa89f 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -21,40 +21,40 @@ jobs: - wheel-build - wheel-tests secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@py-39 checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@py-39 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@py-39 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@py-39 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@py-39 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@py-39 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@py-39 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -64,7 +64,7 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@py-39 with: build_type: pull-request package-dir: python @@ -73,7 +73,7 @@ jobs: wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@py-39 with: build_type: pull-request package-name: rmm diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 039fd3b42..b1c36db50 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@py-39 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@py-39 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@py-39 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/README.md b/README.md index a05ffa5e5..737f43790 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ conda install -c rapidsai -c conda-forge -c nvidia \ We also provide [nightly Conda packages](https://anaconda.org/rapidsai-nightly) built from the HEAD of our latest development branch. -Note: RMM is supported only on Linux, and only tested with Python versions 3.8 and 3.10. +Note: RMM is supported only on Linux, and only tested with Python versions 3.9 and 3.10. Note: The RMM package from Conda requires building with GCC 9 or later. Otherwise, your application may fail to build. diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index a001756a2..b640b70d6 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -16,7 +16,7 @@ dependencies: - pre-commit - pytest - pytest-cov -- python>=3.8,<3.11 +- python>=3.9,<3.11 - scikit-build>=0.13.1 - spdlog>=1.11.0,<1.12 - tomli diff --git a/dependencies.yaml b/dependencies.yaml index f39f62803..d4bd55fc8 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -71,7 +71,7 @@ dependencies: packages: - fmt>=9.1.0,<10 - spdlog>=1.11.0,<1.12 - - python>=3.8,<3.11 + - python>=3.9,<3.11 - output_types: pyproject packages: - wheel @@ -127,10 +127,6 @@ dependencies: specific: - output_types: conda matrices: - - matrix: - py: "3.8" - packages: - - python=3.8 - matrix: py: "3.9" packages: diff --git a/python/pyproject.toml b/python/pyproject.toml index 49cb29348..ca74d5db9 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -34,7 +34,7 @@ authors = [ { name = "NVIDIA Corporation" }, ] license = { text = "Apache 2.0" } -requires-python = ">=3.8" +requires-python = ">=3.9" dependencies = [ "cuda-python>=11.7.1,<12.0", "numba>=0.49", @@ -46,7 +46,7 @@ classifiers = [ "Topic :: Scientific/Engineering", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", - "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", ] @@ -61,7 +61,7 @@ Homepage = "https://github.com/rapidsai/rmm" [tool.black] line-length = 79 -target-version = ["py38"] +target-version = ["py39"] include = '\.py?$' exclude = ''' /( From 5fb272c58c5738da8e08e6e5e25911eb9bc69593 Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Fri, 28 Apr 2023 08:57:30 -0500 Subject: [PATCH 247/675] run docs builds nightly too (#1255) This PR configures `rmm` docs builds to also run nightly (not just on PR merges only) Authors: - Jake Awe (https://github.com/AyodeAwe) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1255 --- .github/workflows/build.yaml | 4 ++-- ci/build_docs.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 487d89616..aa5de620a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -53,12 +53,12 @@ jobs: date: ${{ inputs.date }} sha: ${{ inputs.sha }} docs-build: - if: github.ref_type == 'branch' && github.event_name == 'push' + if: github.ref_type == 'branch' needs: python-build secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@py-39 with: - build_type: branch + build_type: ${{ inputs.build_type || 'branch' }} node_type: "gpu-v100-latest-1" arch: "amd64" container_image: "rapidsai/ci:latest" diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 06f76b6ee..c3001f88f 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -39,7 +39,7 @@ sphinx-build -b dirhtml . _html sphinx-build -b text . _text popd -if [[ "${RAPIDS_BUILD_TYPE}" == "branch" ]]; then +if [[ "${RAPIDS_BUILD_TYPE}" != "pull-request" ]]; then rapids-logger "Upload Docs to S3" aws s3 sync --no-progress --delete doxygen/html "s3://rapidsai-docs/librmm/${VERSION_NUMBER}/html" aws s3 sync --no-progress --delete python/docs/_html "s3://rapidsai-docs/rmm/${VERSION_NUMBER}/html" From 2b4f3bebcaeadb3dce3f8f90fdb0bcee9157a7ce Mon Sep 17 00:00:00 2001 From: Ashwin Srinath <3190405+shwina@users.noreply.github.com> Date: Fri, 28 Apr 2023 13:46:46 -0400 Subject: [PATCH 248/675] Revert to branch-23.06 for shared-action-workflows (#1256) Authors: - Ashwin Srinath (https://github.com/shwina) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1256 --- .github/workflows/build.yaml | 12 ++++++------ .github/workflows/pr.yaml | 18 +++++++++--------- .github/workflows/test.yaml | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index aa5de620a..da55b332f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.06 with: build_type: ${{ inputs.build_type || 'branch' }} node_type: "gpu-v100-latest-1" @@ -65,7 +65,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -77,7 +77,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@branch-23.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 866afa89f..0e5a92b79 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -21,40 +21,40 @@ jobs: - wheel-build - wheel-tests secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.06 checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.06 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.06 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.06 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.06 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.06 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.06 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -64,7 +64,7 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.06 with: build_type: pull-request package-dir: python @@ -73,7 +73,7 @@ jobs: wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.06 with: build_type: pull-request package-name: rmm diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b1c36db50..039fd3b42 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.06 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.06 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@py-39 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.06 with: build_type: nightly branch: ${{ inputs.branch }} From 3744b35cbb5c8e81de1c717a069aa6be090ecaf7 Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Tue, 2 May 2023 07:13:12 -0500 Subject: [PATCH 249/675] enable local cache hits (#1257) --- conda/recipes/librmm/meta.yaml | 1 + conda/recipes/rmm/meta.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 5513d5059..e34448297 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -46,6 +46,7 @@ build: - SCCACHE_S3_KEY_PREFIX=librmm-aarch64 # [aarch64] - SCCACHE_S3_KEY_PREFIX=librmm-linux64 # [linux64] - SCCACHE_S3_USE_SSL + - SCCACHE_S3_NO_CREDENTIALS outputs: - name: librmm diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 2a4d668ef..ccf5c780f 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -30,6 +30,7 @@ build: - SCCACHE_S3_KEY_PREFIX=rmm-aarch64 # [aarch64] - SCCACHE_S3_KEY_PREFIX=rmm-linux64 # [linux64] - SCCACHE_S3_USE_SSL + - SCCACHE_S3_NO_CREDENTIALS ignore_run_exports_from: - {{ compiler('cuda') }} From bf4ff31dbde5aaff3b5c1616dec2aa4764902ebb Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Wed, 3 May 2023 10:12:44 -0500 Subject: [PATCH 250/675] add build vars (#1258) --- .github/workflows/build.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index da55b332f..bd5ad3853 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -59,6 +59,9 @@ jobs: uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.06 with: build_type: ${{ inputs.build_type || 'branch' }} + branch: ${{ inputs.branch }} + sha: ${{ inputs.sha }} + date: ${{ inputs.date }} node_type: "gpu-v100-latest-1" arch: "amd64" container_image: "rapidsai/ci:latest" From c1cf3f4f16612ac069f1fc9a8fcf3d09172e6975 Mon Sep 17 00:00:00 2001 From: Raymond Douglass Date: Wed, 3 May 2023 13:08:48 -0400 Subject: [PATCH 251/675] update changelog --- CHANGELOG.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index efd534515..99f2caece 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,38 @@ +# RMM 23.04.00 (6 Apr 2023) + +## 🐛 Bug Fixes + +- Remove MANIFEST.in use auto-generated one for sdists and package_data for wheels ([#1233](https://github.com/rapidsai/rmm/pull/1233)) [@vyasr](https://github.com/vyasr) +- Fix update-version.sh. ([#1227](https://github.com/rapidsai/rmm/pull/1227)) [@vyasr](https://github.com/vyasr) +- Specify include_package_data to setup ([#1218](https://github.com/rapidsai/rmm/pull/1218)) [@vyasr](https://github.com/vyasr) +- Revert changes overriding rapids-cmake repo. ([#1209](https://github.com/rapidsai/rmm/pull/1209)) [@bdice](https://github.com/bdice) +- Synchronize stream in `DeviceBuffer.c_from_unique_ptr` constructor ([#1100](https://github.com/rapidsai/rmm/pull/1100)) [@shwina](https://github.com/shwina) + +## 🚀 New Features + +- Use rapids-cmake parallel testing feature ([#1183](https://github.com/rapidsai/rmm/pull/1183)) [@robertmaynard](https://github.com/robertmaynard) + +## 🛠️ Improvements + +- Stop setting package version attribute in wheels ([#1236](https://github.com/rapidsai/rmm/pull/1236)) [@vyasr](https://github.com/vyasr) +- Add codespell as a linter ([#1231](https://github.com/rapidsai/rmm/pull/1231)) [@bdice](https://github.com/bdice) +- Pass `AWS_SESSION_TOKEN` and `SCCACHE_S3_USE_SSL` vars to conda build ([#1230](https://github.com/rapidsai/rmm/pull/1230)) [@ajschmidt8](https://github.com/ajschmidt8) +- Update to GCC 11 ([#1228](https://github.com/rapidsai/rmm/pull/1228)) [@bdice](https://github.com/bdice) +- Fix some minor oversights in the conversion to pyproject.toml ([#1226](https://github.com/rapidsai/rmm/pull/1226)) [@vyasr](https://github.com/vyasr) +- Remove pickle compatibility layer in tests for Python < 3.8. ([#1224](https://github.com/rapidsai/rmm/pull/1224)) [@bdice](https://github.com/bdice) +- Move external allocators into rmm.allocators module to defer imports ([#1221](https://github.com/rapidsai/rmm/pull/1221)) [@wence-](https://github.com/wence-) +- Generate pyproject.toml dependencies using dfg ([#1219](https://github.com/rapidsai/rmm/pull/1219)) [@vyasr](https://github.com/vyasr) +- Run rapids-dependency-file-generator via pre-commit ([#1217](https://github.com/rapidsai/rmm/pull/1217)) [@vyasr](https://github.com/vyasr) +- Skip docs job in nightly runs ([#1215](https://github.com/rapidsai/rmm/pull/1215)) [@AyodeAwe](https://github.com/AyodeAwe) +- CI: Remove specification of manual stage for check_style.sh script. ([#1214](https://github.com/rapidsai/rmm/pull/1214)) [@csadorf](https://github.com/csadorf) +- Use script rather than environment variable to modify package names ([#1212](https://github.com/rapidsai/rmm/pull/1212)) [@vyasr](https://github.com/vyasr) +- Reduce error handling verbosity in CI tests scripts ([#1204](https://github.com/rapidsai/rmm/pull/1204)) [@AjayThorve](https://github.com/AjayThorve) +- Update shared workflow branches ([#1203](https://github.com/rapidsai/rmm/pull/1203)) [@ajschmidt8](https://github.com/ajschmidt8) +- Use date in build string instead of in the version. ([#1195](https://github.com/rapidsai/rmm/pull/1195)) [@bdice](https://github.com/bdice) +- Stop using versioneer to manage versions ([#1190](https://github.com/rapidsai/rmm/pull/1190)) [@vyasr](https://github.com/vyasr) +- Update to spdlog>=1.11.0, fmt>=9.1.0. ([#1177](https://github.com/rapidsai/rmm/pull/1177)) [@bdice](https://github.com/bdice) +- Migrate as much as possible to `pyproject.toml` ([#1151](https://github.com/rapidsai/rmm/pull/1151)) [@jakirkham](https://github.com/jakirkham) + # RMM 23.02.00 (9 Feb 2023) ## 🐛 Bug Fixes From db86b06c972fd56331912cf29fd24cf3cfa8029b Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 3 May 2023 13:18:00 -0500 Subject: [PATCH 252/675] Pin to scikit-build<0.17.2. (#1262) Wheel builds are failing because of a recent update to scikit-build. See related PR: https://github.com/rapidsai/cudf/pull/13188 Blocks #1259. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1262 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/recipes/rmm/meta.yaml | 2 +- dependencies.yaml | 2 +- python/pyproject.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index b640b70d6..5638d1149 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -17,7 +17,7 @@ dependencies: - pytest - pytest-cov - python>=3.9,<3.11 -- scikit-build>=0.13.1 +- scikit-build>=0.13.1,<0.17.2 - spdlog>=1.11.0,<1.12 - tomli name: all_cuda-118_arch-x86_64 diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index ccf5c780f..a2e9487e0 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -48,7 +48,7 @@ requirements: - cython >=0.29,<0.30 - librmm ={{ version }} - python - - scikit-build >=0.13.1 + - scikit-build >=0.13.1,<0.17.2 - setuptools >=61.0.0 - tomli # [py<311] run: diff --git a/dependencies.yaml b/dependencies.yaml index d4bd55fc8..a9f6fbfcd 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -65,7 +65,7 @@ dependencies: - &cuda_python cuda-python>=11.7.1,<12.0 - cython>=0.29,<0.30 - ninja - - scikit-build>=0.13.1 + - scikit-build>=0.13.1,<0.17.2 - tomli - output_types: conda packages: diff --git a/python/pyproject.toml b/python/pyproject.toml index ca74d5db9..ea4858ea4 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -19,7 +19,7 @@ requires = [ "cuda-python>=11.7.1,<12.0", "cython>=0.29,<0.30", "ninja", - "scikit-build>=0.13.1", + "scikit-build>=0.13.1,<0.17.2", "setuptools>=61.0.0", "tomli", "wheel", From 3637e04edd742b928a55761bda48b8bfbffdc1ff Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 3 May 2023 12:02:23 -0700 Subject: [PATCH 253/675] Build wheels using new single image workflow (#1254) Update wheel builds to use the new version of the workflow. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1254 --- .github/workflows/build.yaml | 4 ++-- .github/workflows/pr.yaml | 4 ++-- .github/workflows/test.yaml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index bd5ad3853..1fb00c9a4 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@manylinux_v2 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -80,7 +80,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@manylinux_v2 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 0e5a92b79..ec5046d24 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -64,7 +64,7 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@manylinux_v2 with: build_type: pull-request package-dir: python @@ -73,7 +73,7 @@ jobs: wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@manylinux_v2 with: build_type: pull-request package-name: rmm diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 039fd3b42..8ff8523a9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@manylinux_v2 with: build_type: nightly branch: ${{ inputs.branch }} From bfbfaa1dca7a134362e43181c5bfb192ff24bd84 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 4 May 2023 13:17:11 -0500 Subject: [PATCH 254/675] Support CUDA 12.0 for pip wheels (#1259) This PR adds CUDA 12.0 CI workflows for pip wheels. Authors: - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) - Divye Gala (https://github.com/divyegala) Approvers: - Ray Douglass (https://github.com/raydouglass) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1259 --- .github/workflows/build.yaml | 4 ++-- .github/workflows/pr.yaml | 4 ++-- .github/workflows/test.yaml | 2 +- ci/release/apply_wheel_modifications.sh | 4 ++++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1fb00c9a4..1639a082f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@manylinux_v2 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@cuda-120-pip with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -80,7 +80,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@manylinux_v2 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@cuda-120-pip with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index ec5046d24..4f9f73ac3 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -64,7 +64,7 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@manylinux_v2 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@cuda-120-pip with: build_type: pull-request package-dir: python @@ -73,7 +73,7 @@ jobs: wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@manylinux_v2 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@cuda-120-pip with: build_type: pull-request package-name: rmm diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8ff8523a9..5944dc3a9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@manylinux_v2 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@cuda-120-pip with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/ci/release/apply_wheel_modifications.sh b/ci/release/apply_wheel_modifications.sh index 6889520a9..cc71389ea 100755 --- a/ci/release/apply_wheel_modifications.sh +++ b/ci/release/apply_wheel_modifications.sh @@ -9,3 +9,7 @@ CUDA_SUFFIX=${2} sed -i "s/^version = .*/version = \"${VERSION}\"/g" python/pyproject.toml sed -i "s/^name = \"rmm\"/name = \"rmm${CUDA_SUFFIX}\"/g" python/pyproject.toml + +if [[ $CUDA_SUFFIX == "-cu12" ]]; then + sed -i "s/cuda-python[<=>\.,0-9]*/cuda-python>=12.0,<13.0/g" python/pyproject.toml +fi From a4aaf8df3bcbd95f136f713a993567a669aa2621 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 9 May 2023 14:57:03 -0500 Subject: [PATCH 255/675] Update recipes to GTest version >=1.13.0 (#1263) This PR updates GTest pinnings to >=1.13.0. This aligns with recent changes in rapids-cmake: https://github.com/rapidsai/rapids-cmake/pull/401. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1263 --- conda/recipes/librmm/conda_build_config.yaml | 2 +- conda/recipes/librmm/meta.yaml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index be4758d36..644924271 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -14,7 +14,7 @@ fmt_version: - ">=9.1.0,<10" gtest_version: - - "=1.10.0" + - ">=1.13.0" spdlog_version: - ">=1.11.0,<1.12" diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index e34448297..a6b31cdcb 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -29,6 +29,8 @@ requirements: # added as a run requirement via the packages' run_exports. - fmt {{ fmt_version }} - spdlog {{ spdlog_version }} + - gtest {{ gtest_version }} + - gmock {{ gtest_version }} build: script_env: From c11ea8a5ed5c30b916008de3594e36665924b672 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 16 May 2023 13:15:58 -0700 Subject: [PATCH 256/675] Switch back to using primary shared-action-workflows branch (#1268) This PR unpins the workflows using the cuda-120-pip branch Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1268 --- .github/workflows/build.yaml | 4 ++-- .github/workflows/pr.yaml | 4 ++-- .github/workflows/test.yaml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1639a082f..bd5ad3853 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@cuda-120-pip + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -80,7 +80,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@cuda-120-pip + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@branch-23.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 4f9f73ac3..0e5a92b79 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -64,7 +64,7 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@cuda-120-pip + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.06 with: build_type: pull-request package-dir: python @@ -73,7 +73,7 @@ jobs: wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@cuda-120-pip + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.06 with: build_type: pull-request package-name: rmm diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5944dc3a9..039fd3b42 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@cuda-120-pip + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.06 with: build_type: nightly branch: ${{ inputs.branch }} From 945f9fba8d4f965a708d33f8ea42afbb179db5c7 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Fri, 19 May 2023 09:49:40 -0400 Subject: [PATCH 257/675] DOC --- .github/workflows/build.yaml | 12 ++++++------ .github/workflows/pr.yaml | 18 +++++++++--------- .github/workflows/test.yaml | 6 +++--- CMakeLists.txt | 4 ++-- ci/build_docs.sh | 2 +- ci/check_style.sh | 2 +- doxygen/Doxyfile | 2 +- python/CMakeLists.txt | 4 ++-- python/docs/conf.py | 4 ++-- python/pyproject.toml | 2 +- python/rmm/__init__.py | 2 +- 11 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index bd5ad3853..27e360bba 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -80,7 +80,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 0e5a92b79..59cce5312 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -21,40 +21,40 @@ jobs: - wheel-build - wheel-tests secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.08 checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.08 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.08 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.08 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.08 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.08 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.08 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -64,7 +64,7 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.08 with: build_type: pull-request package-dir: python @@ -73,7 +73,7 @@ jobs: wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.08 with: build_type: pull-request package-name: rmm diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 039fd3b42..0c22c5daf 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.08 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.08 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.06 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.08 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/CMakeLists.txt b/CMakeLists.txt index b298f3cb2..108d50536 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.06/RAPIDS.cmake + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.08/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) endif() include(${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) @@ -27,7 +27,7 @@ include(rapids-find) project( RMM - VERSION 23.06.00 + VERSION 23.08.00 LANGUAGES CXX) # Write the version header diff --git a/ci/build_docs.sh b/ci/build_docs.sh index c3001f88f..6318eb4c4 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -19,7 +19,7 @@ rapids-print-env rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) -VERSION_NUMBER="23.06" +VERSION_NUMBER="23.08" rapids-mamba-retry install \ --channel "${CPP_CHANNEL}" \ diff --git a/ci/check_style.sh b/ci/check_style.sh index 36b856ae6..4beaca333 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -14,7 +14,7 @@ rapids-dependency-file-generator \ rapids-mamba-retry env create --force -f env.yaml -n checks conda activate checks -FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.06/cmake-format-rapids-cmake.json +FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.08/cmake-format-rapids-cmake.json export RAPIDS_CMAKE_FORMAT_FILE=/tmp/rapids_cmake_ci/cmake-formats-rapids-cmake.json mkdir -p $(dirname ${RAPIDS_CMAKE_FORMAT_FILE}) wget -O ${RAPIDS_CMAKE_FORMAT_FILE} ${FORMAT_FILE_URL} diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index e9323a222..264d99df0 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "RMM" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 23.06 +PROJECT_NUMBER = 23.08 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 5950f3c21..34e12dbf1 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -14,9 +14,9 @@ cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) -set(rmm_version 23.06.00) +set(rmm_version 23.08.00) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.06/RAPIDS.cmake +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.08/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) diff --git a/python/docs/conf.py b/python/docs/conf.py index 8c014d8d5..f6f3adf43 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -23,9 +23,9 @@ # built documents. # # The short X.Y version. -version = "23.06" +version = "23.08" # The full version, including alpha/beta/rc tags. -release = "23.06.00" +release = "23.08.00" # -- General configuration --------------------------------------------------- diff --git a/python/pyproject.toml b/python/pyproject.toml index ea4858ea4..3977314ee 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -27,7 +27,7 @@ requires = [ [project] name = "rmm" -version = "23.06.00" +version = "23.08.00" description = "rmm - RAPIDS Memory Manager" readme = { file = "README.md", content-type = "text/markdown" } authors = [ diff --git a/python/rmm/__init__.py b/python/rmm/__init__.py index 01b037bd8..2616802b0 100644 --- a/python/rmm/__init__.py +++ b/python/rmm/__init__.py @@ -36,7 +36,7 @@ "unregister_reinitialize_hook", ] -__version__ = "23.06.00" +__version__ = "23.08.00" _deprecated_names = { From ecac31b0315df04cc2de49541be767c5a39e9195 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 23 May 2023 16:56:31 -0500 Subject: [PATCH 258/675] Align test_cpp.sh with conventions in other RAPIDS repos. (#1269) Small PR to make RMM's `test_cpp.sh` bash script look like that of other RAPIDS repos. I suspect RMM was the first iteration -- we improved it for other RAPIDS repos but never applied those improvements to RMM. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) - AJ Schmidt (https://github.com/ajschmidt8) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1269 --- ci/test_cpp.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 12b3ab100..3bf915e0a 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -1,29 +1,33 @@ #!/bin/bash # Copyright (c) 2020-2023, NVIDIA CORPORATION. + set -euo pipefail . /opt/conda/etc/profile.d/conda.sh -conda activate base +rapids-logger "Generate C++ testing dependencies" rapids-dependency-file-generator \ --output conda \ --file_key test_cpp \ - --matrix "cuda=${RAPIDS_CUDA_VERSION%.*}" | tee env.yaml + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch)" | tee env.yaml rapids-mamba-retry env create --force -f env.yaml -n test -conda activate test -rapids-print-env +# Temporarily allow unbound variables for conda activation. +set +u +conda activate test +set -u CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) +RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"}/ +mkdir -p "${RAPIDS_TESTS_DIR}" + +rapids-print-env rapids-mamba-retry install \ --channel "${CPP_CHANNEL}" \ librmm librmm-tests -RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"} -mkdir -p "${RAPIDS_TESTS_DIR}" - rapids-logger "Check GPU usage" nvidia-smi @@ -31,7 +35,9 @@ EXITCODE=0 trap "EXITCODE=1" ERR set +e -rapids-logger "Running googletests" +# Run librmm gtests from librmm-tests package +rapids-logger "Run gtests" + cd $CONDA_PREFIX/bin/gtests/librmm/ export GTEST_OUTPUT=xml:${RAPIDS_TESTS_DIR}/ ctest -j20 --output-on-failure From 3c40cbccb2291288cab8e924c734de9a2497ac8c Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 26 May 2023 17:10:37 -0400 Subject: [PATCH 259/675] Unpin scikit-build upper bound (#1275) Remove scikit-build upper bound pinning Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1275 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/recipes/rmm/meta.yaml | 2 +- dependencies.yaml | 2 +- python/pyproject.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 5638d1149..b640b70d6 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -17,7 +17,7 @@ dependencies: - pytest - pytest-cov - python>=3.9,<3.11 -- scikit-build>=0.13.1,<0.17.2 +- scikit-build>=0.13.1 - spdlog>=1.11.0,<1.12 - tomli name: all_cuda-118_arch-x86_64 diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index a2e9487e0..ccf5c780f 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -48,7 +48,7 @@ requirements: - cython >=0.29,<0.30 - librmm ={{ version }} - python - - scikit-build >=0.13.1,<0.17.2 + - scikit-build >=0.13.1 - setuptools >=61.0.0 - tomli # [py<311] run: diff --git a/dependencies.yaml b/dependencies.yaml index a9f6fbfcd..d4bd55fc8 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -65,7 +65,7 @@ dependencies: - &cuda_python cuda-python>=11.7.1,<12.0 - cython>=0.29,<0.30 - ninja - - scikit-build>=0.13.1,<0.17.2 + - scikit-build>=0.13.1 - tomli - output_types: conda packages: diff --git a/python/pyproject.toml b/python/pyproject.toml index 3977314ee..0ba629a18 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -19,7 +19,7 @@ requires = [ "cuda-python>=11.7.1,<12.0", "cython>=0.29,<0.30", "ninja", - "scikit-build>=0.13.1,<0.17.2", + "scikit-build>=0.13.1", "setuptools>=61.0.0", "tomli", "wheel", From 829691cc58e6d135cad5796bfae4bd8ba11ba065 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Wed, 31 May 2023 15:36:17 +0100 Subject: [PATCH 260/675] Remove now-deprecated top-level allocator functions (#1281) We deprecated these functions in 23.04, so there will have been two releases with deprecation warnings. Closes #1225. Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1281 --- python/rmm/__init__.py | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/python/rmm/__init__.py b/python/rmm/__init__.py index 2616802b0..a5467251e 100644 --- a/python/rmm/__init__.py +++ b/python/rmm/__init__.py @@ -37,31 +37,3 @@ ] __version__ = "23.08.00" - - -_deprecated_names = { - "rmm_cupy_allocator": "cupy", - "rmm_torch_allocator": "torch", - "RMMNumbaManager": "numba", - "_numba_memory_manager": "numba", -} - - -def __getattr__(name): - if name in _deprecated_names: - import importlib - import warnings - - package = _deprecated_names[name] - warnings.warn( - f"Use of 'rmm.{name}' is deprecated and will be removed. " - f"'{name}' now lives in the 'rmm.allocators.{package}' sub-module, " - "please update your imports.", - FutureWarning, - ) - module = importlib.import_module( - f".allocators.{package}", package=__name__ - ) - return getattr(module, name) - else: - raise AttributeError(f"Module '{__name__}' has no attribute '{name}'") From c3ab0605271338895c17dff007e27d3817ca61dd Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 31 May 2023 12:48:14 -0400 Subject: [PATCH 261/675] Ensure Logger tests aren't run in parallel (#1277) The logger tests all read and write to the same temporary files so we extend the tests to generate temporary directories to write the files. This will ensure that concurrent execution of the logger test variants is supported. Due to the current limitations of rapids-cmake in 23.06 we can't use the `SERIAL` or `RESOURCE_LOCK` functions of CTest to instead limit execution to be serial. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Bradley Dice (https://github.com/bdice) - Mark Harris (https://github.com/harrism) --- tests/logger_tests.cpp | 43 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/tests/logger_tests.cpp b/tests/logger_tests.cpp index b3d4eb755..49f5f83c6 100644 --- a/tests/logger_tests.cpp +++ b/tests/logger_tests.cpp @@ -23,6 +23,8 @@ #include #include +#include +#include #include namespace rmm::test { @@ -59,6 +61,30 @@ class raii_restore_env { bool is_set_{false}; }; +class raii_temp_directory { + public: + raii_temp_directory() + { + directory_path_ = std::filesystem::temp_directory_path(); + std::string unique_dir_name = "rmm_XXXXXX"; + auto const ptr = mkdtemp(const_cast(unique_dir_name.data())); + EXPECT_TRUE((ptr != nullptr)); + directory_path_ /= unique_dir_name; + } + ~raii_temp_directory() { std::filesystem::remove_all(directory_path_); } + + raii_temp_directory& operator=(raii_temp_directory const&) = delete; + raii_temp_directory(raii_temp_directory const&) = delete; + + [[nodiscard]] std::string generate_path(std::string filename) const + { + return directory_path_ / filename; + } + + private: + std::filesystem::path directory_path_{}; +}; + /** * @brief Verifies the specified log file contains the expected events. * @@ -95,7 +121,8 @@ void expect_log_events(std::string const& filename, TEST(Adaptor, FilenameConstructor) { - std::string filename{"logs/test1.txt"}; + raii_temp_directory temp_dir; + std::string filename{temp_dir.generate_path("test.txt")}; rmm::mr::cuda_memory_resource upstream; rmm::mr::logging_resource_adaptor log_mr{&upstream, filename}; @@ -121,8 +148,9 @@ TEST(Adaptor, FilenameConstructor) TEST(Adaptor, MultiSinkConstructor) { - std::string filename1{"logs/test_multi_1.txt"}; - std::string filename2{"logs/test_multi_2.txt"}; + raii_temp_directory temp_dir; + std::string filename1{temp_dir.generate_path("test_multi_1.txt")}; + std::string filename2{temp_dir.generate_path("test_multi_2.txt")}; rmm::mr::cuda_memory_resource upstream; auto file_sink1 = std::make_shared(filename1, true); @@ -154,7 +182,8 @@ TEST(Adaptor, MultiSinkConstructor) TEST(Adaptor, Factory) { - std::string filename{"logs/test2.txt"}; + raii_temp_directory temp_dir; + std::string filename{temp_dir.generate_path("test.txt")}; rmm::mr::cuda_memory_resource upstream; auto log_mr = rmm::mr::make_logging_adaptor(&upstream, filename); @@ -181,6 +210,7 @@ TEST(Adaptor, Factory) TEST(Adaptor, EnvironmentPath) { + raii_temp_directory temp_dir; rmm::mr::cuda_memory_resource upstream; // restore the original value (or unset) after test @@ -191,7 +221,7 @@ TEST(Adaptor, EnvironmentPath) // expect logging adaptor to fail if RMM_LOG_FILE is unset EXPECT_THROW(rmm::mr::make_logging_adaptor(&upstream), rmm::logic_error); - std::string filename("logs/envtest.txt"); + std::string filename{temp_dir.generate_path("test.txt")}; setenv("RMM_LOG_FILE", filename.c_str(), 1); @@ -218,7 +248,8 @@ TEST(Adaptor, EnvironmentPath) TEST(Adaptor, AllocateFailure) { - std::string filename{"logs/failure.txt"}; + raii_temp_directory temp_dir; + std::string filename{temp_dir.generate_path("failure.txt")}; rmm::mr::cuda_memory_resource upstream; auto log_mr = rmm::mr::make_logging_adaptor(&upstream, filename); From ec67953629beff348edccd83aff39b9bd4c1c456 Mon Sep 17 00:00:00 2001 From: jakirkham Date: Wed, 31 May 2023 09:59:38 -0700 Subject: [PATCH 262/675] Require Numba 0.57.0+ & NumPy 1.21.0+ (#1279) Align with the rest of RAPIDS on these requirements. Also needed for CUDA 12 support. Authors: - https://github.com/jakirkham Approvers: - Bradley Dice (https://github.com/bdice) - Mark Harris (https://github.com/harrism) - Ray Douglass (https://github.com/raydouglass) --- conda/environments/all_cuda-118_arch-x86_64.yaml | 4 ++-- conda/recipes/rmm/meta.yaml | 4 ++-- dependencies.yaml | 4 ++-- python/pyproject.toml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 5638d1149..6df4ed34c 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -11,8 +11,8 @@ dependencies: - fmt>=9.1.0,<10 - gcovr>=5.0 - ninja -- numba>=0.49 -- numpy>=1.19 +- numba>=0.57 +- numpy>=1.21 - pre-commit - pytest - pytest-cov diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index a2e9487e0..2f59e6839 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -53,8 +53,8 @@ requirements: - tomli # [py<311] run: - cuda-python >=11.7.1,<12.0 - - numba >=0.49 - - numpy >=1.19 + - numba >=0.57 + - numpy >=1.21 - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} test: diff --git a/dependencies.yaml b/dependencies.yaml index a9f6fbfcd..5268fcfe6 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -139,8 +139,8 @@ dependencies: common: - output_types: [conda, requirements, pyproject] packages: - - numba>=0.49 - - numpy>=1.19 + - numba>=0.57 + - numpy>=1.21 - *cuda_python test_cpp: common: diff --git a/python/pyproject.toml b/python/pyproject.toml index ea4858ea4..128849888 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -37,8 +37,8 @@ license = { text = "Apache 2.0" } requires-python = ">=3.9" dependencies = [ "cuda-python>=11.7.1,<12.0", - "numba>=0.49", - "numpy>=1.19", + "numba>=0.57", + "numpy>=1.21", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../dependencies.yaml and run `rapids-dependency-file-generator`. classifiers = [ "Intended Audience :: Developers", From 39a528bc18ca7c9d5153615b1c0e4d550616d5c9 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Thu, 1 Jun 2023 17:37:08 -0400 Subject: [PATCH 263/675] Remove documentation build scripts for Jenkins (#1285) We recently created new scripts for building documentation with GitHub Actions. This PR removes the old scripts that were used by Jenkins and are no longer in use. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1285 --- ci/docs/build.sh | 62 ------------------------------------------------ 1 file changed, 62 deletions(-) delete mode 100644 ci/docs/build.sh diff --git a/ci/docs/build.sh b/ci/docs/build.sh deleted file mode 100644 index eed509dc5..000000000 --- a/ci/docs/build.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -# Copyright (c) 2020, NVIDIA CORPORATION. -################################# -# RMM Docs build script for CI # -################################# - -if [ -z "$PROJECT_WORKSPACE" ]; then - echo ">>>> ERROR: Could not detect PROJECT_WORKSPACE in environment" - echo ">>>> WARNING: This script contains git commands meant for automated building, do not run locally" - exit 1 -fi - -export DOCS_WORKSPACE=$WORKSPACE/docs -export PATH=/opt/conda/bin:/usr/local/cuda/bin:$PATH -export HOME=$WORKSPACE -export PROJECT_WORKSPACE=/rapids/rmm -export LIBCUDF_KERNEL_CACHE_PATH="$HOME/.jitify-cache" -export PROJECTS=(librmm rmm) - -gpuci_logger "Check environment" -env - -gpuci_logger "Check GPU usage" -nvidia-smi - -gpuci_logger "Activate conda env" -. /opt/conda/etc/profile.d/conda.sh -conda activate rapids - -gpuci_logger "Check versions" -python --version -$CC --version -$CXX --version - -gpuci_logger "Check conda environment" -conda info -conda config --show-sources -conda list --show-channel-urls - -# Build Doxygen docs -gpuci_logger "Build Doxygen docs" -cd $PROJECT_WORKSPACE/doxygen -doxygen Doxyfile - -# Build Python docs -gpuci_logger "Build Python docs" -cd $PROJECT_WORKSPACE/python/docs -make html - -#Commit to Website -cd $DOCS_WORKSPACE - -for PROJECT in ${PROJECTS[@]}; do - if [ ! -d "api/$PROJECT/$BRANCH_VERSION" ]; then - mkdir -p api/$PROJECT/$BRANCH_VERSION - fi - rm -rf $DOCS_WORKSPACE/api/$PROJECT/$BRANCH_VERSION/* -done - - -mv $PROJECT_WORKSPACE/doxygen/html/* $DOCS_WORKSPACE/api/librmm/$BRANCH_VERSION -mv $PROJECT_WORKSPACE/python/docs/_build/html/* $DOCS_WORKSPACE/api/rmm/$BRANCH_VERSION From 8b3e2c48f51b9b011e693dfd0aebc0defe6975ac Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 2 Jun 2023 14:36:45 -0700 Subject: [PATCH 264/675] Reorder parameters in RMM_EXPECTS (#1286) Resolves https://github.com/rapidsai/rmm/issues/1172 Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Rong Ou (https://github.com/rongou) URL: https://github.com/rapidsai/rmm/pull/1286 --- benchmarks/utilities/simulated_memory_resource.hpp | 2 +- include/rmm/detail/error.hpp | 10 +++++----- include/rmm/device_uvector.hpp | 6 +++--- .../device/detail/stream_ordered_memory_resource.hpp | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/benchmarks/utilities/simulated_memory_resource.hpp b/benchmarks/utilities/simulated_memory_resource.hpp index 489339e69..993ec5ace 100644 --- a/benchmarks/utilities/simulated_memory_resource.hpp +++ b/benchmarks/utilities/simulated_memory_resource.hpp @@ -80,7 +80,7 @@ class simulated_memory_resource final : public device_memory_resource { void* do_allocate(std::size_t bytes, cuda_stream_view) override { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - RMM_EXPECTS(begin_ + bytes <= end_, rmm::bad_alloc, "Simulated memory size exceeded"); + RMM_EXPECTS(begin_ + bytes <= end_, "Simulated memory size exceeded", rmm::bad_alloc); auto* ptr = static_cast(begin_); begin_ += bytes; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) return ptr; diff --git a/include/rmm/detail/error.hpp b/include/rmm/detail/error.hpp index 5d8b340ab..329fa7022 100644 --- a/include/rmm/detail/error.hpp +++ b/include/rmm/detail/error.hpp @@ -95,27 +95,27 @@ class out_of_range : public std::out_of_range { * RMM_EXPECTS(p != nullptr, "Unexpected null pointer"); * * // throws std::runtime_error - * RMM_EXPECTS(p != nullptr, std::runtime_error, "Unexpected nullptr"); + * RMM_EXPECTS(p != nullptr, "Unexpected nullptr", std::runtime_error); * ``` * @param[in] _condition Expression that evaluates to true or false + * @param[in] _what String literal description of why the exception was + * thrown, i.e. why `_condition` was expected to be true. * @param[in] _expection_type The exception type to throw; must inherit * `std::exception`. If not specified (i.e. if only two macro * arguments are provided), defaults to `rmm::logic_error` - * @param[in] _what String literal description of why the exception was - * thrown, i.e. why `_condition` was expected to be true. * @throw `_exception_type` if the condition evaluates to 0 (false). */ #define RMM_EXPECTS(...) \ GET_RMM_EXPECTS_MACRO(__VA_ARGS__, RMM_EXPECTS_3, RMM_EXPECTS_2) \ (__VA_ARGS__) #define GET_RMM_EXPECTS_MACRO(_1, _2, _3, NAME, ...) NAME -#define RMM_EXPECTS_3(_condition, _exception_type, _reason) \ +#define RMM_EXPECTS_3(_condition, _reason, _exception_type) \ (!!(_condition)) ? static_cast(0) \ : throw _exception_type /*NOLINT(bugprone-macro-parentheses)*/ \ { \ "RMM failure at: " __FILE__ ":" RMM_STRINGIFY(__LINE__) ": " _reason \ } -#define RMM_EXPECTS_2(_condition, _reason) RMM_EXPECTS_3(_condition, rmm::logic_error, _reason) +#define RMM_EXPECTS_2(_condition, _reason) RMM_EXPECTS_3(_condition, _reason, rmm::logic_error) /** * @brief Indicates that an erroneous code path has been taken. diff --git a/include/rmm/device_uvector.hpp b/include/rmm/device_uvector.hpp index 93abfa7a7..40f5d8c5d 100644 --- a/include/rmm/device_uvector.hpp +++ b/include/rmm/device_uvector.hpp @@ -208,7 +208,7 @@ class device_uvector { cuda_stream_view stream) { RMM_EXPECTS( - element_index < size(), rmm::out_of_range, "Attempt to access out of bounds element."); + element_index < size(), "Attempt to access out of bounds element.", rmm::out_of_range); if constexpr (std::is_same::value) { RMM_CUDA_TRY( @@ -256,7 +256,7 @@ class device_uvector { void set_element_to_zero_async(std::size_t element_index, cuda_stream_view stream) { RMM_EXPECTS( - element_index < size(), rmm::out_of_range, "Attempt to access out of bounds element."); + element_index < size(), "Attempt to access out of bounds element.", rmm::out_of_range); RMM_CUDA_TRY( cudaMemsetAsync(element_ptr(element_index), 0, sizeof(value_type), stream.value())); } @@ -311,7 +311,7 @@ class device_uvector { [[nodiscard]] value_type element(std::size_t element_index, cuda_stream_view stream) const { RMM_EXPECTS( - element_index < size(), rmm::out_of_range, "Attempt to access out of bounds element."); + element_index < size(), "Attempt to access out of bounds element.", rmm::out_of_range); value_type value; RMM_CUDA_TRY(cudaMemcpyAsync( &value, element_ptr(element_index), sizeof(value), cudaMemcpyDefault, stream.value())); diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index 69932913d..53575e5ce 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -212,8 +212,8 @@ class stream_ordered_memory_resource : public crtp, public device_ size = rmm::detail::align_up(size, rmm::detail::CUDA_ALLOCATION_ALIGNMENT); RMM_EXPECTS(size <= this->underlying().get_maximum_allocation_size(), - rmm::out_of_memory, - "Maximum allocation size exceeded"); + "Maximum allocation size exceeded", + rmm::out_of_memory); auto const block = this->underlying().get_block(size, stream_event); RMM_LOG_TRACE("[A][stream {:p}][{}B][{:p}]", From 64da5fe1dfd8b83d7f3728fd49659f80b6a7f2dc Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 2 Jun 2023 15:10:35 -0700 Subject: [PATCH 265/675] Remove padding from device_memory_resource (#1278) This PR removes the `align_up` call that enforces 8B padding on all RMM device memory allocations. Padding, where needed, should be the responsibility of callers, possibly with the help of a padding adapter. It should not be enforced by rmm. I looked at all other calls to `align_up` in the library but didn't find any others that needed removing. The other calls all seemed to be used to guarantee specific intentional alignment requirements of other memory resources or adapters. I would appreciate verification from reviewers, though. I've labeled this PR as breaking because it could break consumers that were implicitly relying on the current padding behavior. Resolves #865 Resolves #1156 Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Rong Ou (https://github.com/rongou) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1278 --- include/rmm/mr/device/device_memory_resource.hpp | 7 ++----- tests/logger_tests.cpp | 2 +- tests/mr/device/aligned_mr_tests.cpp | 6 ++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index e3ab954b5..4778d9bda 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -105,7 +105,7 @@ class device_memory_resource { */ void* allocate(std::size_t bytes, cuda_stream_view stream = cuda_stream_view{}) { - return do_allocate(rmm::detail::align_up(bytes, allocation_size_alignment), stream); + return do_allocate(bytes, stream); } /** @@ -128,7 +128,7 @@ class device_memory_resource { */ void deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream = cuda_stream_view{}) { - do_deallocate(ptr, rmm::detail::align_up(bytes, allocation_size_alignment), stream); + do_deallocate(ptr, bytes, stream); } /** @@ -178,9 +178,6 @@ class device_memory_resource { } private: - // All allocations are padded to a multiple of allocation_size_alignment bytes. - static constexpr auto allocation_size_alignment = std::size_t{8}; - /** * @brief Allocates memory of size at least \p bytes. * diff --git a/tests/logger_tests.cpp b/tests/logger_tests.cpp index 49f5f83c6..ba1a37605 100644 --- a/tests/logger_tests.cpp +++ b/tests/logger_tests.cpp @@ -113,7 +113,7 @@ void expect_log_events(std::string const& filename, // EXPECT_EQ(expected.stream, actual.stream); EXPECT_EQ(expected.act, actual.act); // device_memory_resource automatically pads an allocation to a multiple of 8 bytes - EXPECT_EQ(rmm::detail::align_up(expected.size, 8), actual.size); + EXPECT_EQ(expected.size, actual.size); EXPECT_EQ(expected.pointer, actual.pointer); return true; }); diff --git a/tests/mr/device/aligned_mr_tests.cpp b/tests/mr/device/aligned_mr_tests.cpp index 62b941d6f..dfcdfa72f 100644 --- a/tests/mr/device/aligned_mr_tests.cpp +++ b/tests/mr/device/aligned_mr_tests.cpp @@ -87,9 +87,8 @@ TEST(AlignedTest, DefaultAllocationAlignmentPassthrough) cuda_stream_view stream; void* const pointer = int_to_address(123); - // device_memory_resource aligns to 8. { - auto const size{8}; + auto const size{5}; EXPECT_CALL(mock, do_allocate(size, stream)).WillOnce(Return(pointer)); EXPECT_CALL(mock, do_deallocate(pointer, size, stream)).Times(1); } @@ -110,9 +109,8 @@ TEST(AlignedTest, BelowAlignmentThresholdPassthrough) cuda_stream_view stream; void* const pointer = int_to_address(123); - // device_memory_resource aligns to 8. { - auto const size{8}; + auto const size{3}; EXPECT_CALL(mock, do_allocate(size, stream)).WillOnce(Return(pointer)); EXPECT_CALL(mock, do_deallocate(pointer, size, stream)).Times(1); } From 53fa74a4ed3703ec7cace95fc5aaed8f28284bea Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Mon, 5 Jun 2023 16:25:49 -0500 Subject: [PATCH 266/675] use rapids-upload-docs script (#1288) This PR updates the `build_docs.sh` script to use the new consolidatory `rapids-upload-script` [shared script](https://github.com/rapidsai/gha-tools/pull/56). The shared script enables docs uploads to applicable S3 buckets for branch. nightly and PR builds. Authors: - Jake Awe (https://github.com/AyodeAwe) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1288 --- ci/build_docs.sh | 20 ++++++++++---------- ci/release/update-version.sh | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 6318eb4c4..7e1efef9a 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -19,29 +19,29 @@ rapids-print-env rapids-logger "Downloading artifacts from previous jobs" CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) -VERSION_NUMBER="23.08" rapids-mamba-retry install \ --channel "${CPP_CHANNEL}" \ --channel "${PYTHON_CHANNEL}" \ rmm librmm -# Build CPP docs -rapids-logger "Build Doxygen docs" +export RAPIDS_VERSION_NUMBER="23.08" +export RAPIDS_DOCS_DIR="$(mktemp -d)" + +rapids-logger "Build CPP docs" pushd doxygen doxygen Doxyfile +mkdir -p "${RAPIDS_DOCS_DIR}/librmm/html" +mv html/* "${RAPIDS_DOCS_DIR}/librmm/html" popd -# Build Python docs rapids-logger "Build Python docs" pushd python/docs sphinx-build -b dirhtml . _html sphinx-build -b text . _text +mkdir -p "${RAPIDS_DOCS_DIR}/rmm/"{html,txt} +mv _html/* "${RAPIDS_DOCS_DIR}/rmm/html" +mv _text/* "${RAPIDS_DOCS_DIR}/rmm/txt" popd -if [[ "${RAPIDS_BUILD_TYPE}" != "pull-request" ]]; then - rapids-logger "Upload Docs to S3" - aws s3 sync --no-progress --delete doxygen/html "s3://rapidsai-docs/librmm/${VERSION_NUMBER}/html" - aws s3 sync --no-progress --delete python/docs/_html "s3://rapidsai-docs/rmm/${VERSION_NUMBER}/html" - aws s3 sync --no-progress --delete python/docs/_text "s3://rapidsai-docs/rmm/${VERSION_NUMBER}/txt" -fi +rapids-upload-docs diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index ff90e410a..7314442ff 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -53,4 +53,4 @@ sed_runner 's/'"release =.*"'/'"release = \"${NEXT_FULL_TAG}\""'/g' python/docs/ for FILE in .github/workflows/*.yaml; do sed_runner "/shared-action-workflows/ s/@.*/@branch-${NEXT_SHORT_TAG}/g" "${FILE}" done -sed_runner "s/VERSION_NUMBER=\".*/VERSION_NUMBER=\"${NEXT_SHORT_TAG}\"/g" ci/build_docs.sh +sed_runner "s/RAPIDS_VERSION_NUMBER=\".*/RAPIDS_VERSION_NUMBER=\"${NEXT_SHORT_TAG}\"/g" ci/build_docs.sh From bd258510911caa36234d90a36f55dc799f0803e6 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Wed, 7 Jun 2023 10:40:26 -0400 Subject: [PATCH 267/675] update changelog --- CHANGELOG.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99f2caece..385798d20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,34 @@ +# RMM 23.06.00 (7 Jun 2023) + +## 🚨 Breaking Changes + +- Update minimum Python version to Python 3.9 ([#1252](https://github.com/rapidsai/rmm/pull/1252)) [@shwina](https://github.com/shwina) + +## 🐛 Bug Fixes + +- Ensure Logger tests aren't run in parallel ([#1277](https://github.com/rapidsai/rmm/pull/1277)) [@robertmaynard](https://github.com/robertmaynard) +- Pin to scikit-build<0.17.2. ([#1262](https://github.com/rapidsai/rmm/pull/1262)) [@bdice](https://github.com/bdice) + +## 🛠️ Improvements + +- Require Numba 0.57.0+ & NumPy 1.21.0+ ([#1279](https://github.com/rapidsai/rmm/pull/1279)) [@jakirkham](https://github.com/jakirkham) +- Align test_cpp.sh with conventions in other RAPIDS repos. ([#1269](https://github.com/rapidsai/rmm/pull/1269)) [@bdice](https://github.com/bdice) +- Switch back to using primary shared-action-workflows branch ([#1268](https://github.com/rapidsai/rmm/pull/1268)) [@vyasr](https://github.com/vyasr) +- Update recipes to GTest version >=1.13.0 ([#1263](https://github.com/rapidsai/rmm/pull/1263)) [@bdice](https://github.com/bdice) +- Support CUDA 12.0 for pip wheels ([#1259](https://github.com/rapidsai/rmm/pull/1259)) [@bdice](https://github.com/bdice) +- Add build vars ([#1258](https://github.com/rapidsai/rmm/pull/1258)) [@AyodeAwe](https://github.com/AyodeAwe) +- Enable sccache hits from local builds ([#1257](https://github.com/rapidsai/rmm/pull/1257)) [@AyodeAwe](https://github.com/AyodeAwe) +- Revert to branch-23.06 for shared-action-workflows ([#1256](https://github.com/rapidsai/rmm/pull/1256)) [@shwina](https://github.com/shwina) +- run docs builds nightly too ([#1255](https://github.com/rapidsai/rmm/pull/1255)) [@AyodeAwe](https://github.com/AyodeAwe) +- Build wheels using new single image workflow ([#1254](https://github.com/rapidsai/rmm/pull/1254)) [@vyasr](https://github.com/vyasr) +- Update minimum Python version to Python 3.9 ([#1252](https://github.com/rapidsai/rmm/pull/1252)) [@shwina](https://github.com/shwina) +- Remove usage of rapids-get-rapids-version-from-git ([#1251](https://github.com/rapidsai/rmm/pull/1251)) [@jjacobelli](https://github.com/jjacobelli) +- Remove wheel pytest verbosity ([#1249](https://github.com/rapidsai/rmm/pull/1249)) [@sevagh](https://github.com/sevagh) +- Update clang-format to 16.0.1. ([#1246](https://github.com/rapidsai/rmm/pull/1246)) [@bdice](https://github.com/bdice) +- Remove uses-setup-env-vars ([#1242](https://github.com/rapidsai/rmm/pull/1242)) [@vyasr](https://github.com/vyasr) +- Move RMM_LOGGING_ASSERT into separate header ([#1241](https://github.com/rapidsai/rmm/pull/1241)) [@ahendriksen](https://github.com/ahendriksen) +- Use ARC V2 self-hosted runners for GPU jobs ([#1239](https://github.com/rapidsai/rmm/pull/1239)) [@jjacobelli](https://github.com/jjacobelli) + # RMM 23.04.00 (6 Apr 2023) ## 🐛 Bug Fixes From b5203f2475987a728434b606eb92147d4e96d691 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 9 Jun 2023 14:57:20 -0400 Subject: [PATCH 268/675] Ensure logger tests don't generate temp directories in build dir (#1289) Corrects a bug introduced in #1277 which caused the logger tests to construct temporary directories in the build directory ( that never go deleted ). Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Mark Harris (https://github.com/harrism) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1289 --- tests/logger_tests.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/logger_tests.cpp b/tests/logger_tests.cpp index ba1a37605..f6531bc59 100644 --- a/tests/logger_tests.cpp +++ b/tests/logger_tests.cpp @@ -65,11 +65,11 @@ class raii_temp_directory { public: raii_temp_directory() { - directory_path_ = std::filesystem::temp_directory_path(); - std::string unique_dir_name = "rmm_XXXXXX"; - auto const ptr = mkdtemp(const_cast(unique_dir_name.data())); + std::string random_path{std::filesystem::temp_directory_path().string()}; + random_path += "/rmm_XXXXXX"; + auto const ptr = mkdtemp(const_cast(random_path.data())); EXPECT_TRUE((ptr != nullptr)); - directory_path_ /= unique_dir_name; + directory_path_ = std::filesystem::path{random_path}; } ~raii_temp_directory() { std::filesystem::remove_all(directory_path_); } From ea50f909ab25817c88e99647f8270b58c9ffb27d Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Tue, 13 Jun 2023 19:05:38 +1000 Subject: [PATCH 269/675] Use gbench `thread_index()` accessor to fix replay bench compilation (#1293) https://github.com/rapidsai/rapids-cmake/pull/425 updated the google benchmark version to a version that is more than 2 years newer, and the API changed. This PR just changes to use an accessor rather than a public (now private) data member to fix the compilation errors. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Rong Ou (https://github.com/rongou) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1293 --- benchmarks/replay/replay.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/benchmarks/replay/replay.cpp b/benchmarks/replay/replay.cpp index 9d2d00cc1..320811875 100644 --- a/benchmarks/replay/replay.cpp +++ b/benchmarks/replay/replay.cpp @@ -173,7 +173,7 @@ struct replay_benchmark { /// Create the memory resource shared by all threads before the benchmark runs void SetUp(const ::benchmark::State& state) { - if (state.thread_index == 0) { + if (state.thread_index() == 0) { rmm::logger().log(spdlog::level::info, "------ Start of Benchmark -----"); mr_ = factory_(simulated_size_); } @@ -182,7 +182,7 @@ struct replay_benchmark { /// Destroy the memory resource and count any unallocated memory void TearDown(const ::benchmark::State& state) { - if (state.thread_index == 0) { + if (state.thread_index() == 0) { rmm::logger().log(spdlog::level::info, "------ End of Benchmark -----"); // clean up any leaked allocations std::size_t total_leaked{0}; @@ -207,7 +207,7 @@ struct replay_benchmark { { SetUp(state); - auto const& my_events = events_.at(state.thread_index); + auto const& my_events = events_.at(state.thread_index()); for (auto _ : state) { // NOLINT(clang-analyzer-deadcode.DeadStores) std::for_each(my_events.begin(), my_events.end(), [this](auto event) { From 0c08dd585031f58e2a9dcfbba5608cce10c423b2 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Jun 2023 10:33:52 -0700 Subject: [PATCH 270/675] Update to CMake 3.26.4 (#1291) Updates minimum required CMake version to 3.26.4 Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1291 --- CMakeLists.txt | 2 +- README.md | 2 +- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/recipes/librmm/conda_build_config.yaml | 2 +- conda/recipes/rmm/conda_build_config.yaml | 3 +++ conda/recipes/rmm/meta.yaml | 2 +- dependencies.yaml | 2 +- python/CMakeLists.txt | 2 +- python/pyproject.toml | 2 +- 9 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 108d50536..2c4453968 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ # the License. # ============================================================================= -cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) +cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.08/RAPIDS.cmake diff --git a/README.md b/README.md index 737f43790..55e519834 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Compiler requirements: * `gcc` version 9.3+ * `nvcc` version 11.2+ -* `cmake` version 3.23.1+ +* `cmake` version 3.26.4+ CUDA/GPU requirements: diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 2a90c570e..7570b6b46 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -4,7 +4,7 @@ channels: - rapidsai - conda-forge dependencies: -- cmake>=3.23.1,!=3.25.0 +- cmake>=3.26.4 - cuda-python>=11.7.1,<12.0 - cudatoolkit=11.8 - cython>=0.29,<0.30 diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index 644924271..eb114b7d8 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -8,7 +8,7 @@ cuda_compiler: - nvcc cmake_version: - - ">=3.23.1,!=3.25.0" + - ">=3.26.4" fmt_version: - ">=9.1.0,<10" diff --git a/conda/recipes/rmm/conda_build_config.yaml b/conda/recipes/rmm/conda_build_config.yaml index ad733ac69..b4b06a9b6 100644 --- a/conda/recipes/rmm/conda_build_config.yaml +++ b/conda/recipes/rmm/conda_build_config.yaml @@ -9,3 +9,6 @@ cuda_compiler: sysroot_version: - "2.17" + +cmake_version: + - ">=3.26.4" diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 6bcfc1323..87d95e01d 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -36,7 +36,7 @@ build: requirements: build: - - cmake >=3.23.1,!=3.25.0 + - cmake {{ cmake_version }} - ninja - {{ compiler('c') }} - {{ compiler('cxx') }} diff --git a/dependencies.yaml b/dependencies.yaml index 5966b4b94..ccd962c8a 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -61,7 +61,7 @@ dependencies: common: - output_types: [conda, requirements, pyproject] packages: - - &cmake_ver cmake>=3.23.1,!=3.25.0 + - &cmake_ver cmake>=3.26.4 - &cuda_python cuda-python>=11.7.1,<12.0 - cython>=0.29,<0.30 - ninja diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 34e12dbf1..b26a6dd43 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -12,7 +12,7 @@ # the License. # ============================================================================= -cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR) +cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) set(rmm_version 23.08.00) diff --git a/python/pyproject.toml b/python/pyproject.toml index 44770877b..0d917afb1 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -15,7 +15,7 @@ [build-system] build-backend = "setuptools.build_meta" requires = [ - "cmake>=3.23.1,!=3.25.0", + "cmake>=3.26.4", "cuda-python>=11.7.1,<12.0", "cython>=0.29,<0.30", "ninja", From e2122569c5399dadf4f29522a81163c8c6b17805 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 21 Jun 2023 00:43:22 +0100 Subject: [PATCH 271/675] Add a missing '#include ' in logger.hpp (#1295) For `std::array units{...}`. Cropped up in https://github.com/conan-io/conan-center-index/pull/17671. Authors: - Martin Valgur (https://github.com/valgur) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1295 --- include/rmm/logger.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/rmm/logger.hpp b/include/rmm/logger.hpp index a12e7238e..d0d6f8fa4 100644 --- a/include/rmm/logger.hpp +++ b/include/rmm/logger.hpp @@ -21,6 +21,7 @@ #include #include +#include #include #include From d6cc9b8599caaea9beb5aad1eaabe80cd363a91d Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 21 Jun 2023 14:48:55 -0500 Subject: [PATCH 272/675] RMM: Build CUDA 12 packages (#1223) This PR builds `librmm` and `rmm` conda packages using CUDA 12. Resolves #1207. Authors: - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) - https://github.com/jakirkham Approvers: - Ray Douglass (https://github.com/raydouglass) - Vyas Ramasubramani (https://github.com/vyasr) - https://github.com/jakirkham - Robert Maynard (https://github.com/robertmaynard) URL: https://github.com/rapidsai/rmm/pull/1223 --- .github/workflows/build.yaml | 12 ++--- .github/workflows/pr.yaml | 18 ++++---- .github/workflows/test.yaml | 6 +-- .../all_cuda-118_arch-x86_64.yaml | 3 +- .../all_cuda-120_arch-x86_64.yaml | 24 ++++++++++ conda/recipes/librmm/conda_build_config.yaml | 3 ++ conda/recipes/librmm/meta.yaml | 32 ++++++++++--- conda/recipes/rmm/conda_build_config.yaml | 3 ++ conda/recipes/rmm/meta.yaml | 25 ++++++++--- dependencies.yaml | 45 +++++++++++++++++-- python/pyproject.toml | 4 +- 11 files changed, 141 insertions(+), 34 deletions(-) create mode 100644 conda/environments/all_cuda-120_arch-x86_64.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 27e360bba..8f50fcbd4 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@cuda-120 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@cuda-120 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@cuda-120 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@cuda-120 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@cuda-120 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -80,7 +80,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@cuda-120 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 59cce5312..b3a3998e8 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -21,40 +21,40 @@ jobs: - wheel-build - wheel-tests secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@cuda-120 checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@cuda-120 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@cuda-120 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-120 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@cuda-120 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@cuda-120 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@cuda-120 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -64,7 +64,7 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@cuda-120 with: build_type: pull-request package-dir: python @@ -73,7 +73,7 @@ jobs: wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@cuda-120 with: build_type: pull-request package-name: rmm diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0c22c5daf..358de7e65 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-120 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@cuda-120 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@cuda-120 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 7570b6b46..9af75b762 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -5,7 +5,7 @@ channels: - conda-forge dependencies: - cmake>=3.26.4 -- cuda-python>=11.7.1,<12.0 +- cuda-python>=11.7.1,<12.0a0 - cudatoolkit=11.8 - cython>=0.29,<0.30 - fmt>=9.1.0,<10 @@ -13,6 +13,7 @@ dependencies: - ninja - numba>=0.57 - numpy>=1.21 +- nvcc_linux-64=11.8 - pre-commit - pytest - pytest-cov diff --git a/conda/environments/all_cuda-120_arch-x86_64.yaml b/conda/environments/all_cuda-120_arch-x86_64.yaml new file mode 100644 index 000000000..ebbdc7758 --- /dev/null +++ b/conda/environments/all_cuda-120_arch-x86_64.yaml @@ -0,0 +1,24 @@ +# This file is generated by `rapids-dependency-file-generator`. +# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. +channels: +- rapidsai +- conda-forge +dependencies: +- cmake>=3.26.4 +- cuda-nvcc +- cuda-python>=12.0,<13.0a0 +- cuda-version=12.0 +- cython>=0.29,<0.30 +- fmt>=9.1.0,<10 +- gcovr>=5.0 +- ninja +- numba>=0.57 +- numpy>=1.21 +- pre-commit +- pytest +- pytest-cov +- python>=3.9,<3.11 +- scikit-build>=0.13.1 +- spdlog>=1.11.0,<1.12 +- tomli +name: all_cuda-120_arch-x86_64 diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index eb114b7d8..59c0a210e 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -5,6 +5,9 @@ cxx_compiler_version: - 11 cuda_compiler: + - cuda-nvcc + +cuda11_compiler: - nvcc cmake_version: diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index a6b31cdcb..7895a4afb 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -18,10 +18,15 @@ requirements: - ninja - {{ compiler('c') }} - {{ compiler('cxx') }} - - {{ compiler('cuda') }} {{ cuda_version }} + {% if cuda_major == "11" %} + - {{ compiler('cuda11') }} {{ cuda_version }} + {% else %} + - {{ compiler('cuda') }} + {% endif %} + - cuda-version ={{ cuda_version }} - sysroot_{{ target_platform }} {{ sysroot_version }} host: - - cudatoolkit ={{ cuda_version }} + - cuda-version ={{ cuda_version }} # We require spdlog and fmt (which was devendored from spdlog # conda-forge packages in 1.11.0) so that the spdlog headers are not # pulled by CPM and installed as a part of the rmm packages. However, @@ -60,12 +65,17 @@ outputs: run_exports: - {{ pin_subpackage("librmm", max_pin="x.x") }} ignore_run_exports_from: - - {{ compiler('cuda') }} + {% if cuda_major == "11" %} + - {{ compiler('cuda11') }} + {% endif %} requirements: build: - cmake {{ cmake_version }} run: + {% if cuda_major == "11" %} - cudatoolkit {{ cuda_spec }} + {% endif %} + - cuda-version {{ cuda_spec }} - fmt {{ fmt_version }} - spdlog {{ spdlog_version }} test: @@ -113,12 +123,24 @@ outputs: number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_{{ date_string }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} ignore_run_exports_from: - - {{ compiler('cuda') }} + {% if cuda_major == "11" %} + - {{ compiler('cuda11') }} + {% endif %} requirements: build: - cmake {{ cmake_version }} + host: + - cuda-version ={{ cuda_version }} + {% if cuda_major == "11" %} + - cudatoolkit ={{ cuda_version }} + {% else %} + - cuda-cudart-dev + {% endif %} run: - - cudatoolkit {{ cuda_spec }} + {% if cuda_major == "11" %} + - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} + {% endif %} + - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - {{ pin_subpackage('librmm', exact=True) }} - gtest {{ gtest_version }} - gmock {{ gtest_version }} diff --git a/conda/recipes/rmm/conda_build_config.yaml b/conda/recipes/rmm/conda_build_config.yaml index b4b06a9b6..e28b98da7 100644 --- a/conda/recipes/rmm/conda_build_config.yaml +++ b/conda/recipes/rmm/conda_build_config.yaml @@ -5,6 +5,9 @@ cxx_compiler_version: - 11 cuda_compiler: + - cuda-nvcc + +cuda11_compiler: - nvcc sysroot_version: diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 87d95e01d..d97871a90 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -32,7 +32,9 @@ build: - SCCACHE_S3_USE_SSL - SCCACHE_S3_NO_CREDENTIALS ignore_run_exports_from: - - {{ compiler('cuda') }} + {% if cuda_major == "11" %} + - {{ compiler('cuda11') }} + {% endif %} requirements: build: @@ -40,11 +42,22 @@ requirements: - ninja - {{ compiler('c') }} - {{ compiler('cxx') }} - - {{ compiler('cuda') }} {{ cuda_version }} + {% if cuda_major == "11" %} + - {{ compiler('cuda11') }} {{ cuda_version }} + {% else %} + - {{ compiler('cuda') }} + {% endif %} + - cuda-version ={{ cuda_version }} - sysroot_{{ target_platform }} {{ sysroot_version }} host: - - cuda-python >=11.7.1,<12.0 + - cuda-version ={{ cuda_version }} + {% if cuda_major == "11" %} - cudatoolkit ={{ cuda_version }} + - cuda-python ==11.7.1 + {% else %} + - cuda-cudart-dev + - cuda-python ==12.0.0 + {% endif %} - cython >=0.29,<0.30 - librmm ={{ version }} - python @@ -52,10 +65,12 @@ requirements: - setuptools >=61.0.0 - tomli # [py<311] run: - - cuda-python >=11.7.1,<12.0 + {% if cuda_major == "11" %} + - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} + {% endif %} + - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - numba >=0.57 - numpy >=1.21 - - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} test: imports: diff --git a/dependencies.yaml b/dependencies.yaml index ccd962c8a..20d9cb8b6 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -3,7 +3,7 @@ files: all: output: conda matrix: - cuda: ["11.8"] + cuda: ["11.8", "12.0"] arch: [x86_64] includes: - build @@ -62,7 +62,6 @@ dependencies: - output_types: [conda, requirements, pyproject] packages: - &cmake_ver cmake>=3.26.4 - - &cuda_python cuda-python>=11.7.1,<12.0 - cython>=0.29,<0.30 - ninja - scikit-build>=0.13.1 @@ -76,6 +75,33 @@ dependencies: packages: - wheel - setuptools>=61.0.0 + specific: + - output_types: conda + matrices: + - matrix: + arch: x86_64 + cuda: "11.8" + packages: + - nvcc_linux-64=11.8 + - matrix: + arch: aarch64 + cuda: "11.8" + packages: + - nvcc_linux-aarch64=11.8 + - matrix: + cuda: "12.0" + packages: + - cuda-version=12.0 + - cuda-nvcc + - output_types: [conda, requirements, pyproject] + matrices: + - matrix: + cuda: "12.0" + packages: + - &cuda_python12 cuda-python>=12.0,<13.0a0 + - matrix: # All CUDA 11 versions + packages: + - &cuda_python11 cuda-python>=11.7.1,<12.0a0 checks: common: - output_types: [conda, requirements] @@ -105,6 +131,10 @@ dependencies: cuda: "11.8" packages: - cudatoolkit=11.8 + - matrix: + cuda: "12.0" + packages: + - cuda-version=12.0 develop: common: - output_types: [conda, requirements] @@ -141,7 +171,16 @@ dependencies: packages: - numba>=0.57 - numpy>=1.21 - - *cuda_python + specific: + - output_types: [conda, requirements, pyproject] + matrices: + - matrix: + cuda: "12.0" + packages: + - *cuda_python12 + - matrix: # All CUDA 11 versions + packages: + - *cuda_python11 test_cpp: common: - output_types: conda diff --git a/python/pyproject.toml b/python/pyproject.toml index 0d917afb1..58ac1d5ad 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -16,7 +16,7 @@ build-backend = "setuptools.build_meta" requires = [ "cmake>=3.26.4", - "cuda-python>=11.7.1,<12.0", + "cuda-python>=11.7.1,<12.0a0", "cython>=0.29,<0.30", "ninja", "scikit-build>=0.13.1", @@ -36,7 +36,7 @@ authors = [ license = { text = "Apache 2.0" } requires-python = ">=3.9" dependencies = [ - "cuda-python>=11.7.1,<12.0", + "cuda-python>=11.7.1,<12.0a0", "numba>=0.57", "numpy>=1.21", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../dependencies.yaml and run `rapids-dependency-file-generator`. From 005992676c9412b724278a91555536635698e3aa Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 26 Jun 2023 13:29:14 -0500 Subject: [PATCH 273/675] Use cuda-version to constrain cudatoolkit. (#1296) This PR changes CUDA 11 packaging to rely on `cuda-version` pinnings to constrain the installed version of `cudatoolkit`. See also: https://github.com/rapidsai/cudf/pull/13615 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - https://github.com/jakirkham - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1296 --- README.md | 7 +------ conda/environments/all_cuda-118_arch-x86_64.yaml | 3 ++- conda/recipes/librmm/meta.yaml | 6 +++--- conda/recipes/rmm/meta.yaml | 4 ++-- dependencies.yaml | 15 ++++++++++----- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 55e519834..8d65b7d33 100644 --- a/README.md +++ b/README.md @@ -37,12 +37,7 @@ RMM can be installed with Conda ([miniconda](https://conda.io/miniconda.html), o [Anaconda distribution](https://www.anaconda.com/download)) from the `rapidsai` channel: ```bash -# for CUDA 11.5 -conda install -c rapidsai -c conda-forge -c nvidia \ - rmm cudatoolkit=11.5 -# for CUDA 11.2 -conda install -c rapidsai -c conda-forge -c nvidia \ - rmm cudatoolkit=11.2 +conda install -c rapidsai -c conda-forge -c nvidia rmm cuda-version=11.8 ``` We also provide [nightly Conda packages](https://anaconda.org/rapidsai-nightly) built from the HEAD diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 9af75b762..36c3573d7 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -6,7 +6,8 @@ channels: dependencies: - cmake>=3.26.4 - cuda-python>=11.7.1,<12.0a0 -- cudatoolkit=11.8 +- cuda-version=11.8 +- cudatoolkit - cython>=0.29,<0.30 - fmt>=9.1.0,<10 - gcovr>=5.0 diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 7895a4afb..1f7ac40d4 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -73,7 +73,7 @@ outputs: - cmake {{ cmake_version }} run: {% if cuda_major == "11" %} - - cudatoolkit {{ cuda_spec }} + - cudatoolkit {% endif %} - cuda-version {{ cuda_spec }} - fmt {{ fmt_version }} @@ -132,13 +132,13 @@ outputs: host: - cuda-version ={{ cuda_version }} {% if cuda_major == "11" %} - - cudatoolkit ={{ cuda_version }} + - cudatoolkit {% else %} - cuda-cudart-dev {% endif %} run: {% if cuda_major == "11" %} - - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} + - cudatoolkit {% endif %} - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - {{ pin_subpackage('librmm', exact=True) }} diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index d97871a90..5d905b853 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -52,7 +52,7 @@ requirements: host: - cuda-version ={{ cuda_version }} {% if cuda_major == "11" %} - - cudatoolkit ={{ cuda_version }} + - cudatoolkit - cuda-python ==11.7.1 {% else %} - cuda-cudart-dev @@ -66,7 +66,7 @@ requirements: - tomli # [py<311] run: {% if cuda_major == "11" %} - - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} + - cudatoolkit {% endif %} - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - numba >=0.57 diff --git a/dependencies.yaml b/dependencies.yaml index 20d9cb8b6..6085088df 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -114,23 +114,28 @@ dependencies: - matrix: cuda: "11.2" packages: - - cudatoolkit=11.2 + - cuda-version=11.2 + - cudatoolkit - matrix: cuda: "11.4" packages: - - cudatoolkit=11.4 + - cuda-version=11.4 + - cudatoolkit - matrix: cuda: "11.5" packages: - - cudatoolkit=11.5 + - cuda-version=11.5 + - cudatoolkit - matrix: cuda: "11.6" packages: - - cudatoolkit=11.6 + - cuda-version=11.6 + - cudatoolkit - matrix: cuda: "11.8" packages: - - cudatoolkit=11.8 + - cuda-version=11.8 + - cudatoolkit - matrix: cuda: "12.0" packages: From 550276724778e3c381c88828315679689d08d27f Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 13 Jul 2023 09:40:04 -0700 Subject: [PATCH 274/675] Stop invoking setup.py (#1300) This PR changes replaces direct invocations of setup.py in build.sh with `pip install` commands since setup.py usage is deprecated. This change will facilitate upcoming changes to our build systems. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1300 --- build.sh | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/build.sh b/build.sh index 5cbe43f6a..ed37b5973 100755 --- a/build.sh +++ b/build.sh @@ -27,7 +27,7 @@ HELP="$0 [clean] [librmm] [rmm] [-v] [-g] [-n] [-s] [--ptds] [--cmake-args=\"\\\" - pass arbitrary list of CMake configuration options (escape all quotes in argument) @@ -142,8 +142,9 @@ if hasArg --ptds; then fi # Append `-DFIND_RMM_CPP=ON` to CMAKE_ARGS unless a user specified the option. +SKBUILD_EXTRA_CMAKE_ARGS="${EXTRA_CMAKE_ARGS}" if [[ "${EXTRA_CMAKE_ARGS}" != *"DFIND_RMM_CPP"* ]]; then - EXTRA_CMAKE_ARGS="${EXTRA_CMAKE_ARGS} -DFIND_RMM_CPP=ON" + SKBUILD_EXTRA_CMAKE_ARGS="${SKBUILD_EXTRA_CMAKE_ARGS} -DFIND_RMM_CPP=ON" fi # If clean given, run it prior to any other steps @@ -174,15 +175,6 @@ fi # Build and install the rmm Python package if (( NUMARGS == 0 )) || hasArg rmm; then - cd "${REPODIR}/python" - export INSTALL_PREFIX - echo "building rmm..." - - python setup.py build_ext --inplace -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} ${EXTRA_CMAKE_ARGS} - - if [[ ${INSTALL_TARGET} != "" ]]; then - echo "installing rmm..." - python setup.py install --single-version-externally-managed --record=record.txt -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} ${EXTRA_CMAKE_ARGS} - fi - + echo "building and installing rmm..." + SKBUILD_CONFIGURE_OPTIONS="${SKBUILD_EXTRA_CMAKE_ARGS}" python -m pip install --no-build-isolation --no-deps ${REPODIR}/python fi From cfbc678c4467a018387cdba3572718ea00608500 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 17 Jul 2023 18:13:18 -0700 Subject: [PATCH 275/675] Update linters: remove flake8, add ruff, update cython-lint (#1302) The cython-lint change is necessary to unblock runs after the Cython 3.0 update, but it is also a QOL improvement that allows us to remove flake8 usage in Cython files since cython-lint now covers a superset of what flake8 could do for Cython. ruff is (nearly) a superset of flake8 for pure Python and has a wide range of advantages, so this switch is beneficial as well. cf. https://github.com/rapidsai/cudf/pull/13699 Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Ashwin Srinath (https://github.com/shwina) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1302 --- .pre-commit-config.yaml | 16 ++++++---------- pyproject.toml | 13 +++++++++++++ python/.flake8 | 24 ------------------------ 3 files changed, 19 insertions(+), 34 deletions(-) delete mode 100644 python/.flake8 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7ee3cc4e7..aa076e6be 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,17 +22,8 @@ repos: hooks: - id: black args: ["--config=python/pyproject.toml"] - - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 - hooks: - - id: flake8 - args: ["--config=python/.flake8"] - files: python/.*$ - types: [file] - types_or: [python, cython] - additional_dependencies: ["flake8-force"] - repo: https://github.com/MarcoGorelli/cython-lint - rev: v0.1.10 + rev: v0.15.0 hooks: - id: cython-lint - repo: https://github.com/pre-commit/mirrors-clang-format @@ -78,6 +69,11 @@ repos: # of dependencies, so we'll have to update this manually. additional_dependencies: - cmakelang==0.6.13 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.0.278 + hooks: + - id: ruff + files: python/.*$ default_language_version: python: python3 diff --git a/pyproject.toml b/pyproject.toml index 8a412773e..285098f99 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,3 +7,16 @@ ignore-regex = "\\b(.{1,4}|[A-Z]\\w*T)\\b" ignore-words-list = "inout" builtin = "clear" quiet-level = 3 + +[tool.ruff] +select = ["E", "F", "W"] +ignore = [ + # whitespace before : + "E203", +] +fixable = ["ALL"] +exclude = [ + # TODO: Remove this in a follow-up where we fix __all__. + "__init__.py", +] +line-length = 79 diff --git a/python/.flake8 b/python/.flake8 deleted file mode 100644 index 4d610ba8e..000000000 --- a/python/.flake8 +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. - -[flake8] -filename = *.py, *.pyx, *.pxd, *.pxi -exclude = __init__.py, *.egg, build, docs, .git -force-check = True -ignore = - # line break before binary operator - W503, - # whitespace before : - E203 -per-file-ignores = - # Rules ignored only in Cython: - # E211: whitespace before '(' (used in multi-line imports) - # E225: Missing whitespace around operators (breaks cython casting syntax like ) - # E226: Missing whitespace around arithmetic operators (breaks cython pointer syntax like int*) - # E227: Missing whitespace around bitwise or shift operator (Can also break casting syntax) - # E275: Missing whitespace after keyword (Doesn't work with Cython except?) - # E402: invalid syntax (works for Python, not Cython) - # E999: invalid syntax (works for Python, not Cython) - # W504: line break after binary operator (breaks lines that end with a pointer) - *.pyx: E211, E225, E226, E227, E275, E402, E999, W504 - *.pxd: E211, E225, E226, E227, E275, E402, E999, W504 - *.pxi: E211, E225, E226, E227, E275, E402, E999, W504 From 4ec6bc6c972aba3b3b3fc642d32eab7425c24f18 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 18 Jul 2023 14:29:21 -0500 Subject: [PATCH 276/675] Revert CUDA 12.0 CI workflows to branch-23.08. (#1303) This PR reverts changes to the branch of `shared-action-workflows` used for CUDA 12 testing. Now that https://github.com/rapidsai/shared-action-workflows/pull/101 is merged, we can revert this. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1303 --- .github/workflows/build.yaml | 12 ++++++------ .github/workflows/pr.yaml | 18 +++++++++--------- .github/workflows/test.yaml | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8f50fcbd4..27e360bba 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -80,7 +80,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index b3a3998e8..59cce5312 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -21,40 +21,40 @@ jobs: - wheel-build - wheel-tests secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.08 checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.08 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.08 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.08 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.08 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.08 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.08 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -64,7 +64,7 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.08 with: build_type: pull-request package-dir: python @@ -73,7 +73,7 @@ jobs: wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.08 with: build_type: pull-request package-name: rmm diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 358de7e65..0c22c5daf 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.08 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.08 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@cuda-120 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.08 with: build_type: nightly branch: ${{ inputs.branch }} From 0a5b86cf9958dc195fb70e63e83095f0aa8b33c5 Mon Sep 17 00:00:00 2001 From: Mike Wilson Date: Tue, 18 Jul 2023 15:39:57 -0400 Subject: [PATCH 277/675] Adding identify minimum version requirement (#1301) I ran into an issue with clang-format not being able to run due to the version of identify I had installed. ``` $ pre-commit An error has occurred: InvalidManifestError: ==> At Hook(id='clang-format') ==> At key: types_or ==> At index 9 =====> Type tag 'textproto' is not recognized. Try upgrading identify and pre-commit? ``` This led me to find out that pre-commit only requires version 1, but we require a newer version to work with clang-format. We don't specify that version anywhere, so I tracked down the minimum requirement and added it in our dependencies.yaml and ran pre-commit to update the conda environment files. I verified that version [2.5.19](https://github.com/pre-commit/identify/blob/v2.5.19/identify/extensions.py#L226) did not have textproto, but [2.5.20](https://github.com/pre-commit/identify/blob/v2.5.20/identify/extensions.py#L226) did have it and that is why 2.5.20 is the minimum required version. Authors: - Mike Wilson (https://github.com/hyperbolic2346) - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1301 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 1 + conda/environments/all_cuda-120_arch-x86_64.yaml | 1 + dependencies.yaml | 3 +++ 3 files changed, 5 insertions(+) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 36c3573d7..f668c4a4c 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -11,6 +11,7 @@ dependencies: - cython>=0.29,<0.30 - fmt>=9.1.0,<10 - gcovr>=5.0 +- identify>=2.5.20 - ninja - numba>=0.57 - numpy>=1.21 diff --git a/conda/environments/all_cuda-120_arch-x86_64.yaml b/conda/environments/all_cuda-120_arch-x86_64.yaml index ebbdc7758..40291ba33 100644 --- a/conda/environments/all_cuda-120_arch-x86_64.yaml +++ b/conda/environments/all_cuda-120_arch-x86_64.yaml @@ -11,6 +11,7 @@ dependencies: - cython>=0.29,<0.30 - fmt>=9.1.0,<10 - gcovr>=5.0 +- identify>=2.5.20 - ninja - numba>=0.57 - numpy>=1.21 diff --git a/dependencies.yaml b/dependencies.yaml index 6085088df..91eed8280 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -107,6 +107,9 @@ dependencies: - output_types: [conda, requirements] packages: - pre-commit + # pre-commit requires identify minimum version 1.0, but clang-format requires textproto support and that was + # added in 2.5.20, so we need to call out the minimum version needed for our plugins + - identify>=2.5.20 cudatoolkit: specific: - output_types: conda From c856005975cf3608502ad6dfe0938b198cd67695 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Thu, 20 Jul 2023 15:33:39 -0400 Subject: [PATCH 278/675] v23.10 --- .github/workflows/build.yaml | 12 ++++++------ .github/workflows/pr.yaml | 18 +++++++++--------- .github/workflows/test.yaml | 6 +++--- CMakeLists.txt | 4 ++-- ci/build_docs.sh | 2 +- ci/check_style.sh | 2 +- doxygen/Doxyfile | 2 +- python/CMakeLists.txt | 4 ++-- python/docs/conf.py | 4 ++-- python/pyproject.toml | 2 +- python/rmm/__init__.py | 2 +- 11 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 27e360bba..61fa9c125 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -80,7 +80,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@branch-23.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 59cce5312..734455772 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -21,40 +21,40 @@ jobs: - wheel-build - wheel-tests secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.10 checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.10 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.10 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.10 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.10 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.10 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.10 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -64,7 +64,7 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.10 with: build_type: pull-request package-dir: python @@ -73,7 +73,7 @@ jobs: wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.10 with: build_type: pull-request package-name: rmm diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0c22c5daf..0cd2b2778 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.10 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.10 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.10 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c4453968..2aeabbdc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.08/RAPIDS.cmake + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.10/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) endif() include(${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) @@ -27,7 +27,7 @@ include(rapids-find) project( RMM - VERSION 23.08.00 + VERSION 23.10.00 LANGUAGES CXX) # Write the version header diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 7e1efef9a..956a7389d 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -25,7 +25,7 @@ rapids-mamba-retry install \ --channel "${PYTHON_CHANNEL}" \ rmm librmm -export RAPIDS_VERSION_NUMBER="23.08" +export RAPIDS_VERSION_NUMBER="23.10" export RAPIDS_DOCS_DIR="$(mktemp -d)" rapids-logger "Build CPP docs" diff --git a/ci/check_style.sh b/ci/check_style.sh index 4beaca333..e96ad8bf1 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -14,7 +14,7 @@ rapids-dependency-file-generator \ rapids-mamba-retry env create --force -f env.yaml -n checks conda activate checks -FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.08/cmake-format-rapids-cmake.json +FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.10/cmake-format-rapids-cmake.json export RAPIDS_CMAKE_FORMAT_FILE=/tmp/rapids_cmake_ci/cmake-formats-rapids-cmake.json mkdir -p $(dirname ${RAPIDS_CMAKE_FORMAT_FILE}) wget -O ${RAPIDS_CMAKE_FORMAT_FILE} ${FORMAT_FILE_URL} diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 264d99df0..9dc1520d7 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "RMM" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 23.08 +PROJECT_NUMBER = 23.10 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index b26a6dd43..a7306924e 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -14,9 +14,9 @@ cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) -set(rmm_version 23.08.00) +set(rmm_version 23.10.00) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.08/RAPIDS.cmake +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.10/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) diff --git a/python/docs/conf.py b/python/docs/conf.py index f6f3adf43..3010fc069 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -23,9 +23,9 @@ # built documents. # # The short X.Y version. -version = "23.08" +version = "23.10" # The full version, including alpha/beta/rc tags. -release = "23.08.00" +release = "23.10.00" # -- General configuration --------------------------------------------------- diff --git a/python/pyproject.toml b/python/pyproject.toml index 58ac1d5ad..3cac6c043 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -27,7 +27,7 @@ requires = [ [project] name = "rmm" -version = "23.08.00" +version = "23.10.00" description = "rmm - RAPIDS Memory Manager" readme = { file = "README.md", content-type = "text/markdown" } authors = [ diff --git a/python/rmm/__init__.py b/python/rmm/__init__.py index a5467251e..38e4c4258 100644 --- a/python/rmm/__init__.py +++ b/python/rmm/__init__.py @@ -36,4 +36,4 @@ "unregister_reinitialize_hook", ] -__version__ = "23.08.00" +__version__ = "23.10.00" From 81e7a38514e66cc8e6cea17590379a278fd3dad5 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 25 Jul 2023 12:12:02 -0700 Subject: [PATCH 279/675] Switch to new CI wheel building pipeline (#1305) Moves the wheel build and test logic out of the workflow into the repo. This matches conda tests more closely and allows each repo to manage its own wheels more easily. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Divye Gala (https://github.com/divyegala) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1305 --- .github/workflows/build.yaml | 8 +++----- .github/workflows/pr.yaml | 12 ++++-------- .github/workflows/test.yaml | 5 ++--- ci/build_wheel.sh | 26 ++++++++++++++++++++++++++ ci/test_wheel.sh | 17 +++++++++++++++++ 5 files changed, 52 insertions(+), 16 deletions(-) create mode 100755 ci/build_wheel.sh create mode 100755 ci/test_wheel.sh diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 27e360bba..67af4dafc 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -68,19 +68,17 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-build.yaml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} sha: ${{ inputs.sha }} date: ${{ inputs.date }} - package-name: rmm - package-dir: python - skbuild-configure-options: "-DRMM_BUILD_WHEELS=ON" + script: ci/build_wheel.sh wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-publish.yml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-publish.yaml@branch-23.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 59cce5312..f5b7e3bf5 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -64,18 +64,14 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-build.yml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-build.yaml@branch-23.08 with: build_type: pull-request - package-dir: python - package-name: rmm - skbuild-configure-options: "-DRMM_BUILD_WHEELS=ON" + script: ci/build_wheel.sh wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yaml@branch-23.08 with: build_type: pull-request - package-name: rmm - test-unittest: "python -m pytest ./python/rmm/tests" - test-smoketest: "python ./ci/wheel_smoke_test.py" + script: ci/test_wheel.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0c22c5daf..544147d98 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -32,11 +32,10 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-manylinux-test.yml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yml@branch-23.08 with: build_type: nightly branch: ${{ inputs.branch }} date: ${{ inputs.date }} sha: ${{ inputs.sha }} - package-name: rmm - test-unittest: "python -m pytest ./python/rmm/tests" + script: ci/test_wheel.sh diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh new file mode 100755 index 000000000..09c1e104e --- /dev/null +++ b/ci/build_wheel.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# Copyright (c) 2023, NVIDIA CORPORATION. + +set -euo pipefail + +source rapids-configure-sccache +source rapids-date-string + +# Use gha-tools rapids-pip-wheel-version to generate wheel version then +# update the necessary files +version_override="$(rapids-pip-wheel-version ${RAPIDS_DATE_STRING})" + +RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" + +ci/release/apply_wheel_modifications.sh ${version_override} "-${RAPIDS_PY_CUDA_SUFFIX}" +echo "The package name and/or version was modified in the package source. The git diff is:" +git diff + +cd python + +SKBUILD_CONFIGURE_OPTIONS="-DRMM_BUILD_WHEELS=ON" python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check + +mkdir -p final_dist +python -m auditwheel repair -w final_dist dist/* + +RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 final_dist diff --git a/ci/test_wheel.sh b/ci/test_wheel.sh new file mode 100755 index 000000000..4b03022f8 --- /dev/null +++ b/ci/test_wheel.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Copyright (c) 2023, NVIDIA CORPORATION. + +set -eou pipefail + +RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" +RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 ./dist + +# echo to expand wildcard before adding `[extra]` requires for pip +python -m pip install $(echo ./dist/rmm*.whl)[test] + +# Run smoke tests for aarch64 pull requests +if [ "$(arch)" == "aarch64" && ${RAPIDS_BUILD_TYPE} == "pull-request" ]; then + python ./ci/wheel_smoke_test.py +else + python -m pytest ./python/rmm/tests +fi From b2ed023b25d855661180fcf955a9fd1589d52531 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 26 Jul 2023 03:39:45 -0500 Subject: [PATCH 280/675] Fix typo in wheels-test.yaml. (#1310) Fixes a typo in the `test.yaml` workflow from #1305. Nightlies failed here: https://github.com/rapidsai/rmm/actions/runs/5665017238 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1310 --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 544147d98..9a26dac4a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yml@branch-23.08 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yaml@branch-23.08 with: build_type: nightly branch: ${{ inputs.branch }} From c4618eb54738965c31030b3427d705c91e73a3f0 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 1 Aug 2023 15:53:24 -0500 Subject: [PATCH 281/675] Use fetch_rapids.cmake. (#1319) This PR migrates RMM to use `fetch_rapids.cmake` like most RAPIDS repos. This makes it easier to define a single source if the upstream branch of rapids-cmake needs to change for testing, like in #1247. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Ray Douglass (https://github.com/raydouglass) - Robert Maynard (https://github.com/robertmaynard) URL: https://github.com/rapidsai/rmm/pull/1319 --- CMakeLists.txt | 6 +----- ci/release/update-version.sh | 5 +++-- fetch_rapids.cmake | 18 ++++++++++++++++++ python/CMakeLists.txt | 4 +--- 4 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 fetch_rapids.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 2aeabbdc0..a0df2ff3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,11 +14,7 @@ cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) -if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.10/RAPIDS.cmake - ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) -endif() -include(${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) +include(fetch_rapids.cmake) include(rapids-cmake) include(rapids-cpm) diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 7314442ff..42378a2fe 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -31,14 +31,15 @@ function sed_runner() { # cpp update sed_runner 's/'" VERSION .*"'/'" VERSION ${NEXT_FULL_TAG}"'/g' CMakeLists.txt -sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' CMakeLists.txt # Python update sed_runner 's/'"rmm_version .*)"'/'"rmm_version ${NEXT_FULL_TAG})"'/g' python/CMakeLists.txt -sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' python/CMakeLists.txt sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/rmm/__init__.py sed_runner "s/^version = .*/version = \"${NEXT_FULL_TAG}\"/g" python/pyproject.toml +# rapids-cmake version +sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' fetch_rapids.cmake + # cmake-format rapids-cmake definitions sed_runner 's/'"branch-.*\/cmake-format-rapids-cmake.json"'/'"branch-${NEXT_SHORT_TAG}\/cmake-format-rapids-cmake.json"'/g' ci/check_style.sh diff --git a/fetch_rapids.cmake b/fetch_rapids.cmake new file mode 100644 index 000000000..1ff8119ba --- /dev/null +++ b/fetch_rapids.cmake @@ -0,0 +1,18 @@ +# ============================================================================= +# Copyright (c) 2023, 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}/RMM_RAPIDS.cmake) + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.10/RAPIDS.cmake + ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) +endif() +include(${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index a7306924e..7920bdd3b 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -16,9 +16,7 @@ cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) set(rmm_version 23.10.00) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.10/RAPIDS.cmake - ${CMAKE_BINARY_DIR}/RAPIDS.cmake) -include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) +include(../fetch_rapids.cmake) project( rmm-python From 2376e08f46cc2dc6c1afbd12e403d3686ddf268b Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 4 Aug 2023 11:39:54 -0700 Subject: [PATCH 282/675] Update to Cython 3.0.0 (#1313) This PR contains the minimal set of changes to compile using Cython 3 without warnings. Future PRs can be made to take advantage of new or improved features. The specific changes are: - Ensuring `nogil` always comes after `except`. `except * nogil` is a compile-time error in Cython 3 - Adding `noexcept` or `except *` to any `cdef ` functions missing them. In Cython 0.29 these would default to `noexcept`, which meant that exceptions would not be properly propagated. In Cython 3.0.0, these default to `except *`, which incurs a performance penalty for reacquiring the GIL to check the exception value even for `nogil` functions. Being explicit here is important. There are a large number of outstanding warnings due to https://github.com/NVIDIA/cuda-python/issues/44. cuda-python for CUDA 12 has the necessary fix, but we will need a cuda-python 11.8.* bugfix with a backport to make those warnings go away. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Ashwin Srinath (https://github.com/shwina) - Lawrence Mitchell (https://github.com/wence-) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1313 --- .../environments/all_cuda-118_arch-x86_64.yaml | 2 +- .../environments/all_cuda-120_arch-x86_64.yaml | 2 +- conda/recipes/rmm/meta.yaml | 2 +- dependencies.yaml | 2 +- python/pyproject.toml | 2 +- python/rmm/_cuda/stream.pxd | 6 +++--- python/rmm/_cuda/stream.pyx | 8 ++++---- python/rmm/_lib/cuda_stream.pxd | 4 ++-- python/rmm/_lib/cuda_stream.pyx | 4 ++-- python/rmm/_lib/device_buffer.pxd | 2 +- python/rmm/_lib/device_buffer.pyx | 4 ++-- python/rmm/_lib/memory_resource.pyx | 18 ++++++++++++++---- 12 files changed, 33 insertions(+), 23 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index f668c4a4c..0240b46e5 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -8,7 +8,7 @@ dependencies: - cuda-python>=11.7.1,<12.0a0 - cuda-version=11.8 - cudatoolkit -- cython>=0.29,<0.30 +- cython>=3.0.0 - fmt>=9.1.0,<10 - gcovr>=5.0 - identify>=2.5.20 diff --git a/conda/environments/all_cuda-120_arch-x86_64.yaml b/conda/environments/all_cuda-120_arch-x86_64.yaml index 40291ba33..96b8c8065 100644 --- a/conda/environments/all_cuda-120_arch-x86_64.yaml +++ b/conda/environments/all_cuda-120_arch-x86_64.yaml @@ -8,7 +8,7 @@ dependencies: - cuda-nvcc - cuda-python>=12.0,<13.0a0 - cuda-version=12.0 -- cython>=0.29,<0.30 +- cython>=3.0.0 - fmt>=9.1.0,<10 - gcovr>=5.0 - identify>=2.5.20 diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 5d905b853..e13254d4c 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -58,7 +58,7 @@ requirements: - cuda-cudart-dev - cuda-python ==12.0.0 {% endif %} - - cython >=0.29,<0.30 + - cython >=3.0.0 - librmm ={{ version }} - python - scikit-build >=0.13.1 diff --git a/dependencies.yaml b/dependencies.yaml index 91eed8280..17fb1d66d 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -62,7 +62,7 @@ dependencies: - output_types: [conda, requirements, pyproject] packages: - &cmake_ver cmake>=3.26.4 - - cython>=0.29,<0.30 + - cython>=3.0.0 - ninja - scikit-build>=0.13.1 - tomli diff --git a/python/pyproject.toml b/python/pyproject.toml index 3cac6c043..f83e4fec4 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -17,7 +17,7 @@ build-backend = "setuptools.build_meta" requires = [ "cmake>=3.26.4", "cuda-python>=11.7.1,<12.0a0", - "cython>=0.29,<0.30", + "cython>=3.0.0", "ninja", "scikit-build>=0.13.1", "setuptools>=61.0.0", diff --git a/python/rmm/_cuda/stream.pxd b/python/rmm/_cuda/stream.pxd index 6aa4e0b24..3c3d3aa6f 100644 --- a/python/rmm/_cuda/stream.pxd +++ b/python/rmm/_cuda/stream.pxd @@ -26,8 +26,8 @@ cdef class Stream: @staticmethod cdef Stream _from_cudaStream_t(cudaStream_t s, object owner=*) - cdef cuda_stream_view view(self) nogil except * - cdef void c_synchronize(self) nogil except * - cdef bool c_is_default(self) nogil except * + cdef cuda_stream_view view(self) except * nogil + cdef void c_synchronize(self) except * nogil + cdef bool c_is_default(self) except * nogil cdef void _init_with_new_cuda_stream(self) except * cdef void _init_from_stream(self, Stream stream) except * diff --git a/python/rmm/_cuda/stream.pyx b/python/rmm/_cuda/stream.pyx index d60dde4e1..4795cbb9f 100644 --- a/python/rmm/_cuda/stream.pyx +++ b/python/rmm/_cuda/stream.pyx @@ -48,7 +48,7 @@ cdef class Stream: self._init_from_cupy_stream(obj) @staticmethod - cdef Stream _from_cudaStream_t(cudaStream_t s, object owner=None): + cdef Stream _from_cudaStream_t(cudaStream_t s, object owner=None) except *: """ Construct a Stream from a cudaStream_t. """ @@ -57,13 +57,13 @@ cdef class Stream: obj._owner = owner return obj - cdef cuda_stream_view view(self) nogil except *: + cdef cuda_stream_view view(self) except * nogil: """ Generate a rmm::cuda_stream_view from this Stream instance """ return cuda_stream_view((self._cuda_stream)) - cdef void c_synchronize(self) nogil except *: + cdef void c_synchronize(self) except * nogil: """ Synchronize the CUDA stream. This function *must* be called in a `with nogil` block @@ -77,7 +77,7 @@ cdef class Stream: with nogil: self.c_synchronize() - cdef bool c_is_default(self) nogil except *: + cdef bool c_is_default(self) except * nogil: """ Check if we are the default CUDA stream """ diff --git a/python/rmm/_lib/cuda_stream.pxd b/python/rmm/_lib/cuda_stream.pxd index 1eed1cefb..e224cf9af 100644 --- a/python/rmm/_lib/cuda_stream.pxd +++ b/python/rmm/_lib/cuda_stream.pxd @@ -33,5 +33,5 @@ cdef extern from "rmm/cuda_stream.hpp" namespace "rmm" nogil: @cython.final cdef class CudaStream: cdef unique_ptr[cuda_stream] c_obj - cdef cudaStream_t value(self) nogil except * - cdef bool is_valid(self) nogil except * + cdef cudaStream_t value(self) except * nogil + cdef bool is_valid(self) except * nogil diff --git a/python/rmm/_lib/cuda_stream.pyx b/python/rmm/_lib/cuda_stream.pyx index fb35ec11f..0861f0663 100644 --- a/python/rmm/_lib/cuda_stream.pyx +++ b/python/rmm/_lib/cuda_stream.pyx @@ -27,8 +27,8 @@ cdef class CudaStream: def __cinit__(self): self.c_obj.reset(new cuda_stream()) - cdef cudaStream_t value(self) nogil except *: + cdef cudaStream_t value(self) except * nogil: return self.c_obj.get()[0].value() - cdef bool is_valid(self) nogil except *: + cdef bool is_valid(self) except * nogil: return self.c_obj.get()[0].is_valid() diff --git a/python/rmm/_lib/device_buffer.pxd b/python/rmm/_lib/device_buffer.pxd index 364dbb2c0..3d5f29f9a 100644 --- a/python/rmm/_lib/device_buffer.pxd +++ b/python/rmm/_lib/device_buffer.pxd @@ -56,7 +56,7 @@ cdef class DeviceBuffer: @staticmethod cdef DeviceBuffer c_to_device(const unsigned char[::1] b, - Stream stream=*) + Stream stream=*) except * cpdef copy_to_host(self, ary=*, Stream stream=*) cpdef copy_from_host(self, ary, Stream stream=*) cpdef copy_from_device(self, cuda_ary, Stream stream=*) diff --git a/python/rmm/_lib/device_buffer.pyx b/python/rmm/_lib/device_buffer.pyx index c2bfd1459..d248d01ab 100644 --- a/python/rmm/_lib/device_buffer.pyx +++ b/python/rmm/_lib/device_buffer.pyx @@ -172,7 +172,7 @@ cdef class DeviceBuffer: @staticmethod cdef DeviceBuffer c_to_device(const unsigned char[::1] b, - Stream stream=DEFAULT_STREAM): + Stream stream=DEFAULT_STREAM) except *: """Calls ``to_device`` function on arguments provided""" return to_device(b, stream) @@ -382,7 +382,7 @@ cdef void _copy_async(const void* src, void* dst, size_t count, ccudart.cudaMemcpyKind kind, - cuda_stream_view stream) nogil except *: + cuda_stream_view stream) except * nogil: """ Asynchronously copy data between host and/or device pointers. diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 774db374a..aa0d21d1f 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -14,10 +14,14 @@ import os import warnings +# This import is needed for Cython typing in translate_python_except_to_cpp +# See https://github.com/cython/cython/issues/5589 +from builtins import BaseException from collections import defaultdict cimport cython from cython.operator cimport dereference as deref +from libc.stddef cimport size_t from libc.stdint cimport int8_t, int64_t, uintptr_t from libcpp cimport bool from libcpp.memory cimport make_unique, unique_ptr @@ -37,7 +41,7 @@ from rmm._lib.per_device_resource cimport ( # Transparent handle of a C++ exception ctypedef pair[int, string] CppExcept -cdef CppExcept translate_python_except_to_cpp(err: BaseException): +cdef CppExcept translate_python_except_to_cpp(err: BaseException) noexcept: """Translate a Python exception into a C++ exception handle The returned exception handle can then be thrown by `throw_cpp_except()`, @@ -526,7 +530,10 @@ cdef void* _allocate_callback_wrapper( size_t nbytes, cuda_stream_view stream, void* ctx -) nogil: + # Note that this function is specifically designed to rethrow Python + # exceptions as C++ exceptions when called as a callback from C++, so it is + # noexcept from Cython's perspective. +) noexcept nogil: cdef CppExcept err with gil: try: @@ -540,7 +547,7 @@ cdef void _deallocate_callback_wrapper( size_t nbytes, cuda_stream_view stream, void* ctx -) with gil: +) except * with gil: (ctx)((ptr), nbytes) @@ -796,7 +803,10 @@ cdef class TrackingResourceAdaptor(UpstreamResourceAdaptor): self.c_obj.get()))[0].log_outstanding_allocations() -cdef bool _oom_callback_function(size_t bytes, void *callback_arg) nogil: +# Note that this function is specifically designed to rethrow Python exceptions +# as C++ exceptions when called as a callback from C++, so it is noexcept from +# Cython's perspective. +cdef bool _oom_callback_function(size_t bytes, void *callback_arg) noexcept nogil: cdef CppExcept err with gil: try: From cd37245eac3b26c2aee9ab4b5116ae86a7451fc9 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 7 Aug 2023 09:14:27 -0700 Subject: [PATCH 283/675] Treat warnings as errors in Python documentation (#1316) This will allow us to more easily audit the quality of our docs in CI going forward. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) - Lawrence Mitchell (https://github.com/wence-) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1316 --- ci/build_docs.sh | 8 +++---- .../all_cuda-118_arch-x86_64.yaml | 10 ++++++++ .../all_cuda-120_arch-x86_64.yaml | 10 ++++++++ dependencies.yaml | 2 ++ python/docs/Makefile | 2 +- python/docs/api.rst | 2 ++ python/docs/basics.md | 2 +- python/docs/conf.py | 12 ++++++++-- python/rmm/_lib/memory_resource.pyx | 23 +++++++++++++++++++ python/rmm/allocators/numba.py | 17 ++++++++++++++ python/rmm/mr.py | 2 ++ 11 files changed, 82 insertions(+), 8 deletions(-) diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 956a7389d..d54947106 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -37,11 +37,11 @@ popd rapids-logger "Build Python docs" pushd python/docs -sphinx-build -b dirhtml . _html -sphinx-build -b text . _text +make dirhtml +make text mkdir -p "${RAPIDS_DOCS_DIR}/rmm/"{html,txt} -mv _html/* "${RAPIDS_DOCS_DIR}/rmm/html" -mv _text/* "${RAPIDS_DOCS_DIR}/rmm/txt" +mv _build/dirhtml/* "${RAPIDS_DOCS_DIR}/rmm/html" +mv _build/text/* "${RAPIDS_DOCS_DIR}/rmm/txt" popd rapids-upload-docs diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 0240b46e5..d56088fbc 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -9,12 +9,18 @@ dependencies: - cuda-version=11.8 - cudatoolkit - cython>=3.0.0 +- doxygen=1.8.20 - fmt>=9.1.0,<10 - gcovr>=5.0 +- graphviz - identify>=2.5.20 +- ipython +- make +- nbsphinx - ninja - numba>=0.57 - numpy>=1.21 +- numpydoc - nvcc_linux-64=11.8 - pre-commit - pytest @@ -22,5 +28,9 @@ dependencies: - python>=3.9,<3.11 - scikit-build>=0.13.1 - spdlog>=1.11.0,<1.12 +- sphinx +- sphinx-copybutton +- sphinx-markdown-tables +- sphinx_rtd_theme - tomli name: all_cuda-118_arch-x86_64 diff --git a/conda/environments/all_cuda-120_arch-x86_64.yaml b/conda/environments/all_cuda-120_arch-x86_64.yaml index 96b8c8065..baa480a1f 100644 --- a/conda/environments/all_cuda-120_arch-x86_64.yaml +++ b/conda/environments/all_cuda-120_arch-x86_64.yaml @@ -9,17 +9,27 @@ dependencies: - cuda-python>=12.0,<13.0a0 - cuda-version=12.0 - cython>=3.0.0 +- doxygen=1.8.20 - fmt>=9.1.0,<10 - gcovr>=5.0 +- graphviz - identify>=2.5.20 +- ipython +- make +- nbsphinx - ninja - numba>=0.57 - numpy>=1.21 +- numpydoc - pre-commit - pytest - pytest-cov - python>=3.9,<3.11 - scikit-build>=0.13.1 - spdlog>=1.11.0,<1.12 +- sphinx +- sphinx-copybutton +- sphinx-markdown-tables +- sphinx_rtd_theme - tomli name: all_cuda-120_arch-x86_64 diff --git a/dependencies.yaml b/dependencies.yaml index 17fb1d66d..e16d7a292 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -10,6 +10,7 @@ files: - checks - cudatoolkit - develop + - docs - run - test_python test_python: @@ -155,6 +156,7 @@ dependencies: - doxygen=1.8.20 - graphviz - ipython + - make - nbsphinx - numpydoc - sphinx diff --git a/python/docs/Makefile b/python/docs/Makefile index d4bb2cbb9..72d1dcd85 100644 --- a/python/docs/Makefile +++ b/python/docs/Makefile @@ -3,7 +3,7 @@ # You can set these variables from the command line, and also # from the environment for the first two. -SPHINXOPTS ?= +SPHINXOPTS = -n -v -W --keep-going SPHINXBUILD ?= sphinx-build SOURCEDIR = . BUILDDIR = _build diff --git a/python/docs/api.rst b/python/docs/api.rst index 73cd5dd81..b229d8214 100644 --- a/python/docs/api.rst +++ b/python/docs/api.rst @@ -15,6 +15,7 @@ Memory Resources .. automodule:: rmm.mr :members: + :inherited-members: :undoc-members: :show-inheritance: @@ -28,6 +29,7 @@ Memory Allocators .. automodule:: rmm.allocators.numba :members: + :inherited-members: :undoc-members: :show-inheritance: diff --git a/python/docs/basics.md b/python/docs/basics.md index 0c47073c1..997745f00 100644 --- a/python/docs/basics.md +++ b/python/docs/basics.md @@ -91,7 +91,7 @@ example, enabling the `ManagedMemoryResource` tells RMM to use > :warning: The default resource must be set for any device **before** > allocating any device memory on that device. Setting or changing the > resource after device allocations have been made can lead to unexpected -> behaviour or crashes. See [Multiple Devices](#multiple-devices) +> behaviour or crashes. As another example, `PoolMemoryResource` allows you to allocate a large "pool" of device memory up-front. Subsequent allocations will diff --git a/python/docs/conf.py b/python/docs/conf.py index 3010fc069..76b95183e 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -113,7 +113,7 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] +html_static_path = [] # -- Options for HTMLHelp output ------------------------------------------ @@ -179,7 +179,10 @@ # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {"https://docs.python.org/": None} +intersphinx_mapping = { + "python": ("https://docs.python.org/3", None), + "numba": ("https://numba.readthedocs.io/en/stable", None), +} # Config numpydoc numpydoc_show_inherited_class_members = True @@ -187,6 +190,11 @@ autoclass_content = "init" +nitpick_ignore = [ + ("py:class", "size_t"), + ("py:class", "void"), +] + def setup(app): app.add_js_file("copybutton_pydocs.js") diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index aa0d21d1f..0e9277f31 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -217,18 +217,41 @@ cdef extern from "rmm/mr/device/failure_callback_resource_adaptor.hpp" \ cdef class DeviceMemoryResource: cdef device_memory_resource* get_mr(self): + """Get the underlying C++ memory resource object.""" return self.c_obj.get() def allocate(self, size_t nbytes): + """Allocate ``nbytes`` bytes of memory. + + Parameters + ---------- + nbytes : size_t + The size of the allocation in bytes + """ return self.c_obj.get().allocate(nbytes) def deallocate(self, uintptr_t ptr, size_t nbytes): + """Deallocate memory pointed to by ``ptr`` of size ``nbytes``. + + Parameters + ---------- + ptr : uintptr_t + Pointer to be deallocated + nbytes : size_t + Size of the allocation in bytes + """ self.c_obj.get().deallocate((ptr), nbytes) # See the note about `no_gc_clear` in `device_buffer.pyx`. @cython.no_gc_clear cdef class UpstreamResourceAdaptor(DeviceMemoryResource): + """Parent class for all memory resources that track an upstream. + + Upstream resource tracking requires maintaining a reference to the upstream + mr so that it is kept alive and may be accessed by any downstream resource + adaptors. + """ def __cinit__(self, DeviceMemoryResource upstream_mr, *args, **kwargs): diff --git a/python/rmm/allocators/numba.py b/python/rmm/allocators/numba.py index 18a010e1c..5e87b87b6 100644 --- a/python/rmm/allocators/numba.py +++ b/python/rmm/allocators/numba.py @@ -13,6 +13,7 @@ # limitations under the License. import ctypes +import inspect from cuda.cuda import CUdeviceptr, cuIpcGetMemHandle from numba import config, cuda @@ -112,6 +113,12 @@ def get_ipc_handle(self, memory): ) def get_memory_info(self): + """Returns ``(free, total)`` memory in bytes in the context. + + This implementation raises `NotImplementedError` because the allocation + will be performed using rmm's currently set default mr, which may be a + pool allocator. + """ raise NotImplementedError() @property @@ -119,6 +126,16 @@ def interface_version(self): return 1 +# The parent class docstrings contain references without fully qualified names, +# so we need to replace them here for our Sphinx docs to render properly. +for _, method in inspect.getmembers(RMMNumbaManager, inspect.isfunction): + if method.__doc__ is not None: + method.__doc__ = method.__doc__.replace( + ":class:`BaseCUDAMemoryManager`", + ":class:`numba.cuda.BaseCUDAMemoryManager`", + ) + + # Enables the use of RMM for Numba via an environment variable setting, # NUMBA_CUDA_MEMORY_MANAGER=rmm. See: # https://numba.readthedocs.io/en/stable/cuda/external-memory.html#environment-variable diff --git a/python/rmm/mr.py b/python/rmm/mr.py index ea0a0cf8c..a00d96184 100644 --- a/python/rmm/mr.py +++ b/python/rmm/mr.py @@ -24,6 +24,7 @@ PoolMemoryResource, StatisticsResourceAdaptor, TrackingResourceAdaptor, + UpstreamResourceAdaptor, _flush_logs, _initialize, disable_logging, @@ -51,6 +52,7 @@ "StatisticsResourceAdaptor", "TrackingResourceAdaptor", "FailureCallbackResourceAdaptor", + "UpstreamResourceAdaptor", "_flush_logs", "_initialize", "set_per_device_resource", From 314b669a0e1747acf6e27b1a41a86459180bdb8d Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Wed, 9 Aug 2023 12:31:00 -0400 Subject: [PATCH 284/675] Update Changelog [skip ci] --- CHANGELOG.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 385798d20..453ab54c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,38 @@ +# RMM 23.08.00 (9 Aug 2023) + +## 🚨 Breaking Changes + +- Stop invoking setup.py ([#1300](https://github.com/rapidsai/rmm/pull/1300)) [@vyasr](https://github.com/vyasr) +- Remove now-deprecated top-level allocator functions ([#1281](https://github.com/rapidsai/rmm/pull/1281)) [@wence-](https://github.com/wence-) +- Remove padding from device_memory_resource ([#1278](https://github.com/rapidsai/rmm/pull/1278)) [@vyasr](https://github.com/vyasr) + +## 🐛 Bug Fixes + +- Fix typo in wheels-test.yaml. ([#1310](https://github.com/rapidsai/rmm/pull/1310)) [@bdice](https://github.com/bdice) +- Add a missing '#include <array>' in logger.hpp ([#1295](https://github.com/rapidsai/rmm/pull/1295)) [@valgur](https://github.com/valgur) +- Use gbench `thread_index()` accessor to fix replay bench compilation ([#1293](https://github.com/rapidsai/rmm/pull/1293)) [@harrism](https://github.com/harrism) +- Ensure logger tests don't generate temp directories in build dir ([#1289](https://github.com/rapidsai/rmm/pull/1289)) [@robertmaynard](https://github.com/robertmaynard) + +## 🚀 New Features + +- Remove now-deprecated top-level allocator functions ([#1281](https://github.com/rapidsai/rmm/pull/1281)) [@wence-](https://github.com/wence-) + +## 🛠️ Improvements + +- Switch to new CI wheel building pipeline ([#1305](https://github.com/rapidsai/rmm/pull/1305)) [@vyasr](https://github.com/vyasr) +- Revert CUDA 12.0 CI workflows to branch-23.08. ([#1303](https://github.com/rapidsai/rmm/pull/1303)) [@bdice](https://github.com/bdice) +- Update linters: remove flake8, add ruff, update cython-lint ([#1302](https://github.com/rapidsai/rmm/pull/1302)) [@vyasr](https://github.com/vyasr) +- Adding identify minimum version requirement ([#1301](https://github.com/rapidsai/rmm/pull/1301)) [@hyperbolic2346](https://github.com/hyperbolic2346) +- Stop invoking setup.py ([#1300](https://github.com/rapidsai/rmm/pull/1300)) [@vyasr](https://github.com/vyasr) +- Use cuda-version to constrain cudatoolkit. ([#1296](https://github.com/rapidsai/rmm/pull/1296)) [@bdice](https://github.com/bdice) +- Update to CMake 3.26.4 ([#1291](https://github.com/rapidsai/rmm/pull/1291)) [@vyasr](https://github.com/vyasr) +- use rapids-upload-docs script ([#1288](https://github.com/rapidsai/rmm/pull/1288)) [@AyodeAwe](https://github.com/AyodeAwe) +- Reorder parameters in RMM_EXPECTS ([#1286](https://github.com/rapidsai/rmm/pull/1286)) [@vyasr](https://github.com/vyasr) +- Remove documentation build scripts for Jenkins ([#1285](https://github.com/rapidsai/rmm/pull/1285)) [@ajschmidt8](https://github.com/ajschmidt8) +- Remove padding from device_memory_resource ([#1278](https://github.com/rapidsai/rmm/pull/1278)) [@vyasr](https://github.com/vyasr) +- Unpin scikit-build upper bound ([#1275](https://github.com/rapidsai/rmm/pull/1275)) [@vyasr](https://github.com/vyasr) +- RMM: Build CUDA 12 packages ([#1223](https://github.com/rapidsai/rmm/pull/1223)) [@bdice](https://github.com/bdice) + # RMM 23.06.00 (7 Jun 2023) ## 🚨 Breaking Changes From 663e659451341505636daa7e05a94ef84290a870 Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Thu, 10 Aug 2023 14:46:11 -0500 Subject: [PATCH 285/675] Fix missing jQuery error in docs (#1321) The latest versions `4.1` and `4.0` of `sphinxcontrib-jquery` have an issue with jQuery installed currently in sphinx. This is causing the search functionality to fail so I've pinned the version to `3.0.0`, this resolves the issue. Authors: - Jake Awe (https://github.com/AyodeAwe) Approvers: - https://github.com/jakirkham - AJ Schmidt (https://github.com/ajschmidt8) --- python/docs/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/docs/conf.py b/python/docs/conf.py index 76b95183e..17c012194 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -35,6 +35,7 @@ # ones. extensions = [ + "sphinxcontrib.jquery", "sphinx.ext.intersphinx", "sphinx.ext.autodoc", "sphinx.ext.autosummary", From 2a9fe714333bb350de131d51cbaeac84879c636f Mon Sep 17 00:00:00 2001 From: Peter Andreas Entschev Date: Mon, 21 Aug 2023 20:55:53 +0200 Subject: [PATCH 286/675] Add Python bindings for `limiting_resource_adaptor` (#1327) Add Python bindings for the `limiting_resource_adaptor` via a new Python memory resource `LimitingResourceAdaptor`. Authors: - Peter Andreas Entschev (https://github.com/pentschev) - Lawrence Mitchell (https://github.com/wence-) - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1327 --- python/rmm/_lib/memory_resource.pxd | 3 ++ python/rmm/_lib/memory_resource.pyx | 65 +++++++++++++++++++++++++++++ python/rmm/mr.py | 2 + python/rmm/tests/test_rmm.py | 35 ++++++++++++++++ 4 files changed, 105 insertions(+) diff --git a/python/rmm/_lib/memory_resource.pxd b/python/rmm/_lib/memory_resource.pxd index 5bb3746bc..0770fb8ed 100644 --- a/python/rmm/_lib/memory_resource.pxd +++ b/python/rmm/_lib/memory_resource.pxd @@ -69,6 +69,9 @@ cdef class CallbackMemoryResource(DeviceMemoryResource): cdef object _allocate_func cdef object _deallocate_func +cdef class LimitingResourceAdaptor(UpstreamResourceAdaptor): + pass + cdef class LoggingResourceAdaptor(UpstreamResourceAdaptor): cdef object _log_file_name cpdef get_file_name(self) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 0e9277f31..ce7f45e19 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -164,6 +164,16 @@ cdef extern from "rmm/mr/device/binning_memory_resource.hpp" \ size_t allocation_size, device_memory_resource* bin_resource) except + +cdef extern from "rmm/mr/device/limiting_resource_adaptor.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass limiting_resource_adaptor[Upstream](device_memory_resource): + limiting_resource_adaptor( + Upstream* upstream_mr, + size_t allocation_limit) except + + + size_t get_allocated_bytes() except + + size_t get_allocation_limit() except + + cdef extern from "rmm/mr/device/logging_resource_adaptor.hpp" \ namespace "rmm::mr" nogil: cdef cppclass logging_resource_adaptor[Upstream](device_memory_resource): @@ -649,6 +659,61 @@ def _append_id(filename, id): return f"{name}.dev{id}{ext}" +cdef class LimitingResourceAdaptor(UpstreamResourceAdaptor): + + def __cinit__( + self, + DeviceMemoryResource upstream_mr, + size_t allocation_limit + ): + self.c_obj.reset( + new limiting_resource_adaptor[device_memory_resource]( + upstream_mr.get_mr(), + allocation_limit + ) + ) + + def __init__( + self, + DeviceMemoryResource upstream_mr, + size_t allocation_limit + ): + """ + Memory resource that limits the total allocation amount possible + performed by an upstream memory resource. + + Parameters + ---------- + upstream_mr : DeviceMemoryResource + The upstream memory resource. + allocation_limit : size_t + Maximum memory allowed for this allocator. + """ + pass + + def get_allocated_bytes(self) -> size_t: + """ + Query the number of bytes that have been allocated. Note that this can + not be used to know how large of an allocation is possible due to both + possible fragmentation and also internal page sizes and alignment that + is not tracked by this allocator. + """ + return (( + self.c_obj.get()) + )[0].get_allocated_bytes() + + def get_allocation_limit(self) -> size_t: + """ + Query the maximum number of bytes that this allocator is allowed to + allocate. This is the limit on the allocator and not a representation + of the underlying device. The device may not be able to support this + limit. + """ + return (( + self.c_obj.get()) + )[0].get_allocation_limit() + + cdef class LoggingResourceAdaptor(UpstreamResourceAdaptor): def __cinit__( self, diff --git a/python/rmm/mr.py b/python/rmm/mr.py index a00d96184..4f6b801f5 100644 --- a/python/rmm/mr.py +++ b/python/rmm/mr.py @@ -19,6 +19,7 @@ DeviceMemoryResource, FailureCallbackResourceAdaptor, FixedSizeMemoryResource, + LimitingResourceAdaptor, LoggingResourceAdaptor, ManagedMemoryResource, PoolMemoryResource, @@ -46,6 +47,7 @@ "CudaMemoryResource", "DeviceMemoryResource", "FixedSizeMemoryResource", + "LimitingResourceAdaptor", "LoggingResourceAdaptor", "ManagedMemoryResource", "PoolMemoryResource", diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index 70aafe601..deaab7f92 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -586,6 +586,41 @@ def test_cuda_async_memory_resource_threshold(nelem, alloc): array_tester("u1", 2 * nelem, alloc) # should trigger release +@pytest.mark.parametrize( + "mr", + [ + rmm.mr.CudaMemoryResource, + pytest.param( + rmm.mr.CudaAsyncMemoryResource, + marks=pytest.mark.skipif( + not _CUDAMALLOC_ASYNC_SUPPORTED, + reason="cudaMallocAsync not supported", + ), + ), + ], +) +def test_limiting_resource_adaptor(mr): + cuda_mr = mr() + + allocation_limit = 1 << 20 + num_buffers = 2 + buffer_size = allocation_limit // num_buffers + + mr = rmm.mr.LimitingResourceAdaptor( + cuda_mr, allocation_limit=allocation_limit + ) + assert mr.get_allocation_limit() == allocation_limit + + rmm.mr.set_current_device_resource(mr) + + buffers = [rmm.DeviceBuffer(size=buffer_size) for _ in range(num_buffers)] + + assert mr.get_allocated_bytes() == sum(b.size for b in buffers) + + with pytest.raises(MemoryError): + rmm.DeviceBuffer(size=1) + + def test_statistics_resource_adaptor(stats_mr): buffers = [rmm.DeviceBuffer(size=1000) for _ in range(10)] From 228330543cba4921e6b71a52dd1fa81c63921420 Mon Sep 17 00:00:00 2001 From: AJ Schmidt Date: Wed, 23 Aug 2023 12:26:23 -0400 Subject: [PATCH 287/675] Use `copy-pr-bot` (#1329) This PR replaces the `copy_prs` functionality from the `ops-bot` with the new dedicated `copy-pr-bot` GitHub application. Docs for `copy-pr-bot` can be viewed below. - https://docs.gha-runners.nvidia.com/apps/copy-pr-bot/ **Important**: `copy-pr-bot` enforces signed commits. If an organization member opens a PR that contains unsigned commits, it will be deemed untrusted and therefore require an `/ok to test` comment. See the GitHub docs [here](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification) for information on how to set up commit signing. Any time a PR is deemed untrusted, it will receive a comment that looks like this: https://github.com/rapidsai/ci-imgs/pull/63#issuecomment-1688973208. Authors: - AJ Schmidt (https://github.com/ajschmidt8) Approvers: - Bradley Dice (https://github.com/bdice) - Jordan Jacobelli (https://github.com/jjacobelli) --- .github/copy-pr-bot.yaml | 4 ++++ .github/ops-bot.yaml | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 .github/copy-pr-bot.yaml diff --git a/.github/copy-pr-bot.yaml b/.github/copy-pr-bot.yaml new file mode 100644 index 000000000..895ba83ee --- /dev/null +++ b/.github/copy-pr-bot.yaml @@ -0,0 +1,4 @@ +# Configuration file for `copy-pr-bot` GitHub App +# https://docs.gha-runners.nvidia.com/apps/copy-pr-bot/ + +enabled: true diff --git a/.github/ops-bot.yaml b/.github/ops-bot.yaml index 57bdd6110..9a0b41550 100644 --- a/.github/ops-bot.yaml +++ b/.github/ops-bot.yaml @@ -5,6 +5,4 @@ auto_merger: true branch_checker: true label_checker: true release_drafter: true -copy_prs: true -rerun_tests: true recently_updated: true From 93e616ac02850cc4671a8bdf9b3d2d6673346eec Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 1 Sep 2023 10:24:33 -0700 Subject: [PATCH 288/675] Fix doxygen warnings (#1317) This PR fixes all doxygen warnings from building the C++ documentation. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Mark Harris (https://github.com/harrism) - Rong Ou (https://github.com/rongou) - Lawrence Mitchell (https://github.com/wence-) URL: https://github.com/rapidsai/rmm/pull/1317 --- doxygen/Doxyfile | 8 +++- include/rmm/cuda_device.hpp | 6 +-- include/rmm/cuda_stream.hpp | 2 + include/rmm/cuda_stream_view.hpp | 26 ++++++----- include/rmm/device_buffer.hpp | 23 +++++----- include/rmm/device_scalar.hpp | 27 +++++++++--- include/rmm/device_uvector.hpp | 39 ++++++++--------- include/rmm/exec_policy.hpp | 20 +++++++-- include/rmm/logger.hpp | 16 +++++-- .../mr/device/callback_memory_resource.hpp | 14 +++--- .../cuda_async_view_memory_resource.hpp | 14 +++--- .../rmm/mr/device/cuda_memory_resource.hpp | 14 +++--- .../rmm/mr/device/device_memory_resource.hpp | 17 +++++--- .../failure_callback_resource_adaptor.hpp | 9 ++-- .../mr/device/fixed_size_memory_resource.hpp | 21 +++++---- .../mr/device/limiting_resource_adaptor.hpp | 21 ++++----- .../mr/device/logging_resource_adaptor.hpp | 28 +++++++++--- .../rmm/mr/device/managed_memory_resource.hpp | 14 +++--- include/rmm/mr/device/owning_wrapper.hpp | 13 +++--- include/rmm/mr/device/per_device_resource.hpp | 12 ++++-- .../rmm/mr/device/polymorphic_allocator.hpp | 16 +++---- .../rmm/mr/device/pool_memory_resource.hpp | 8 ++-- .../mr/device/statistics_resource_adaptor.hpp | 43 ++++++++++++------- .../device/thread_safe_resource_adaptor.hpp | 2 +- .../mr/device/thrust_allocator_adaptor.hpp | 12 +++--- .../mr/device/tracking_resource_adaptor.hpp | 35 +++++++++------ include/rmm/mr/host/host_memory_resource.hpp | 15 ++++--- include/rmm/mr/host/new_delete_resource.hpp | 14 +++--- .../rmm/mr/host/pinned_memory_resource.hpp | 16 ++++--- 29 files changed, 304 insertions(+), 201 deletions(-) diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 9dc1520d7..d03f38b54 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -259,7 +259,11 @@ TAB_SIZE = 4 # commands \{ and \} for these it is advised to use the version @{ and @} or use # a double escape (\\{ and \\}) -ALIASES = +ALIASES += "briefreturn{1}=@brief \1 @return \1" +ALIASES += "default_copy_constructor=Default copy constructor" +ALIASES += "default_move_constructor=Default move constructor" +ALIASES += "default_copy_assignment{1}=@brief Default copy assignment operator @return \1& Reference to the assigned object" +ALIASES += "default_move_assignment{1}=@brief Default move assignment operator @return \1& Reference to the assigned object" # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For @@ -898,7 +902,7 @@ EXCLUDE_SYMLINKS = NO # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = */detail/* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the diff --git a/include/rmm/cuda_device.hpp b/include/rmm/cuda_device.hpp index ab225490e..81d35dc3c 100644 --- a/include/rmm/cuda_device.hpp +++ b/include/rmm/cuda_device.hpp @@ -26,16 +26,16 @@ namespace rmm { * */ struct cuda_device_id { - using value_type = int; + using value_type = int; ///< Integer type used for device identifier /** * @brief Construct a `cuda_device_id` from the specified integer value * - * @param id The device's integer identifier + * @param dev_id The device's integer identifier */ explicit constexpr cuda_device_id(value_type dev_id) noexcept : id_{dev_id} {} - /// Returns the wrapped integer value + /// @briefreturn{The wrapped integer value} [[nodiscard]] constexpr value_type value() const noexcept { return id_; } private: diff --git a/include/rmm/cuda_stream.hpp b/include/rmm/cuda_stream.hpp index 9d2dab4f0..b778cf7bd 100644 --- a/include/rmm/cuda_stream.hpp +++ b/include/rmm/cuda_stream.hpp @@ -46,6 +46,8 @@ class cuda_stream { * * A moved-from cuda_stream is invalid and it is Undefined Behavior to call methods that access * the owned stream. + * + * @return A reference to this cuda_stream */ cuda_stream& operator=(cuda_stream&&) = default; ~cuda_stream() = default; diff --git a/include/rmm/cuda_stream_view.hpp b/include/rmm/cuda_stream_view.hpp index bc30f26d8..150fe3957 100644 --- a/include/rmm/cuda_stream_view.hpp +++ b/include/rmm/cuda_stream_view.hpp @@ -33,41 +33,47 @@ namespace rmm { */ class cuda_stream_view { public: - constexpr cuda_stream_view() = default; - constexpr cuda_stream_view(cuda_stream_view const&) = default; - constexpr cuda_stream_view(cuda_stream_view&&) = default; - constexpr cuda_stream_view& operator=(cuda_stream_view const&) = default; - constexpr cuda_stream_view& operator=(cuda_stream_view&&) = default; - ~cuda_stream_view() = default; + constexpr cuda_stream_view() = default; + ~cuda_stream_view() = default; + constexpr cuda_stream_view(cuda_stream_view const&) = default; ///< @default_copy_constructor + constexpr cuda_stream_view(cuda_stream_view&&) = default; ///< @default_move_constructor + constexpr cuda_stream_view& operator=(cuda_stream_view const&) = + default; ///< @default_copy_assignment{cuda_stream_view} + constexpr cuda_stream_view& operator=(cuda_stream_view&&) = + default; ///< @default_move_assignment{cuda_stream_view} // Disable construction from literal 0 constexpr cuda_stream_view(int) = delete; //< Prevent cast from 0 constexpr cuda_stream_view(std::nullptr_t) = delete; //< Prevent cast from nullptr /** - * @brief Implicit conversion from cudaStream_t. + * @brief Constructor from a cudaStream_t + * + * @param stream The underlying stream for this view */ constexpr cuda_stream_view(cudaStream_t stream) noexcept : stream_{stream} {} /** * @brief Get the wrapped stream. * - * @return cudaStream_t The wrapped stream. + * @return cudaStream_t The underlying stream referenced by this cuda_stream_view */ [[nodiscard]] constexpr cudaStream_t value() const noexcept { return stream_; } /** * @brief Implicit conversion to cudaStream_t. + * + * @return cudaStream_t The underlying stream referenced by this cuda_stream_view */ constexpr operator cudaStream_t() const noexcept { return value(); } /** - * @brief Return true if the wrapped stream is the CUDA per-thread default stream. + * @briefreturn{true if the wrapped stream is the CUDA per-thread default stream} */ [[nodiscard]] inline bool is_per_thread_default() const noexcept; /** - * @brief Return true if the wrapped stream is explicitly the CUDA legacy default stream. + * @briefreturn{true if the wrapped stream is explicitly the CUDA legacy default stream} */ [[nodiscard]] inline bool is_default() const noexcept; diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index bd8a8211a..145fbf891 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -29,7 +29,6 @@ namespace rmm { /** - * @file device_buffer.hpp * @brief RAII construct for device memory allocation * * This class allocates untyped and *uninitialized* device memory using a @@ -202,6 +201,8 @@ class device_buffer { * replaced by the `other.stream()`. * * @param other The `device_buffer` whose contents will be moved. + * + * @return A reference to this `device_buffer` */ device_buffer& operator=(device_buffer&& other) noexcept { @@ -331,22 +332,22 @@ class device_buffer { } /** - * @brief Returns raw pointer to underlying device memory allocation + * @briefreturn{Const pointer to the device memory allocation} */ [[nodiscard]] void const* data() const noexcept { return _data; } /** - * @brief Returns raw pointer to underlying device memory allocation + * @briefreturn{Pointer to the device memory allocation} */ void* data() noexcept { return _data; } /** - * @brief Returns the number of bytes. + * @briefreturn{The number of bytes} */ [[nodiscard]] std::size_t size() const noexcept { return _size; } /** - * @brief Returns the signed number of bytes. + * @briefreturn{The signed number of bytes} */ [[nodiscard]] std::int64_t ssize() const noexcept { @@ -356,11 +357,10 @@ class device_buffer { } /** - * @brief returns the number of bytes that can be held in currently allocated storage. + * @briefreturn{Whether or not the buffer currently holds any data} * * If `is_empty() == true`, the `device_buffer` may still hold an allocation * if `capacity() > 0`. - * */ [[nodiscard]] bool is_empty() const noexcept { return 0 == size(); } @@ -368,11 +368,13 @@ class device_buffer { * @brief Returns actual size in bytes of device memory allocation. * * The invariant `size() <= capacity()` holds. + * + * @return The actual size in bytes of the device memory allocation */ [[nodiscard]] std::size_t capacity() const noexcept { return _capacity; } /** - * @brief Returns stream most recently specified for allocation/deallocation + * @briefreturn{The stream most recently specified for allocation/deallocation} */ [[nodiscard]] cuda_stream_view stream() const noexcept { return _stream; } @@ -384,12 +386,13 @@ class device_buffer { * will be used for deallocation in the `rmm::device_uvector` destructor. * However, if either of `resize()` or `shrink_to_fit()` is called after this, * the later stream parameter will be stored and used in the destructor. + * + * @param stream The stream to use for deallocation */ void set_stream(cuda_stream_view stream) noexcept { _stream = stream; } /** - * @brief Returns pointer to the memory resource used to allocate and - * deallocate the device memory + * @briefreturn{Pointer to the memory resource used to allocate and deallocate} */ [[nodiscard]] mr::device_memory_resource* memory_resource() const noexcept { return _mr; } diff --git a/include/rmm/device_scalar.hpp b/include/rmm/device_scalar.hpp index e476b2d87..83fcdda09 100644 --- a/include/rmm/device_scalar.hpp +++ b/include/rmm/device_scalar.hpp @@ -37,18 +37,25 @@ class device_scalar { public: static_assert(std::is_trivially_copyable::value, "Scalar type must be trivially copyable"); - using value_type = typename device_uvector::value_type; - using reference = typename device_uvector::reference; - using const_reference = typename device_uvector::const_reference; - using pointer = typename device_uvector::pointer; - using const_pointer = typename device_uvector::const_pointer; + using value_type = typename device_uvector::value_type; ///< T, the type of the scalar element + using reference = typename device_uvector::reference; ///< value_type& + using const_reference = typename device_uvector::const_reference; ///< const value_type& + using pointer = + typename device_uvector::pointer; ///< The type of the pointer returned by data() + using const_pointer = typename device_uvector::const_pointer; ///< The type of the iterator + ///< returned by data() const RMM_EXEC_CHECK_DISABLE ~device_scalar() = default; RMM_EXEC_CHECK_DISABLE - device_scalar(device_scalar&&) noexcept = default; + device_scalar(device_scalar&&) noexcept = default; ///< Default move constructor + /** + * @brief Default move assignment operator + * + * @return device_scalar& A reference to the assigned-to object + */ device_scalar& operator=(device_scalar&&) noexcept = default; /** @@ -224,6 +231,8 @@ class device_scalar { * specified to the constructor, then appropriate dependencies must be inserted between the * streams (e.g. using `cudaStreamWaitEvent()` or `cudaStreamSynchronize()`), otherwise there may * be a race condition. + * + * @return Pointer to underlying device memory */ [[nodiscard]] pointer data() noexcept { return static_cast(_storage.data()); } @@ -234,6 +243,8 @@ class device_scalar { * specified to the constructor, then appropriate dependencies must be inserted between the * streams (e.g. using `cudaStreamWaitEvent()` or `cudaStreamSynchronize()`), otherwise there may * be a race condition. + * + * @return Const pointer to underlying device memory */ [[nodiscard]] const_pointer data() const noexcept { @@ -241,12 +252,14 @@ class device_scalar { } /** - * @brief Returns stream most recently specified for allocation/deallocation + * @briefreturn{Stream associated with the device memory allocation} */ [[nodiscard]] cuda_stream_view stream() const noexcept { return _storage.stream(); } /** * @brief Sets the stream to be used for deallocation + * + * @param stream Stream to be used for deallocation */ void set_stream(cuda_stream_view stream) noexcept { _storage.set_stream(stream); } diff --git a/include/rmm/device_uvector.hpp b/include/rmm/device_uvector.hpp index 40f5d8c5d..47ed1adff 100644 --- a/include/rmm/device_uvector.hpp +++ b/include/rmm/device_uvector.hpp @@ -71,22 +71,24 @@ class device_uvector { "device_uvector only supports types that are trivially copyable."); public: - using value_type = T; - using size_type = std::size_t; - using reference = value_type&; - using const_reference = value_type const&; - using pointer = value_type*; - using const_pointer = value_type const*; - using iterator = pointer; - using const_iterator = const_pointer; + using value_type = T; ///< T; stored value type + using size_type = std::size_t; ///< The type used for the size of the vector + using reference = value_type&; ///< value_type&; reference type returned by operator[](size_type) + using const_reference = value_type const&; ///< value_type const&; constant reference type + ///< returned by operator[](size_type) const + using pointer = value_type*; ///< The type of the pointer returned by data() + using const_pointer = value_type const*; ///< The type of the pointer returned by data() const + using iterator = pointer; ///< The type of the iterator returned by begin() + using const_iterator = const_pointer; ///< The type of the const iterator returned by cbegin() RMM_EXEC_CHECK_DISABLE ~device_uvector() = default; RMM_EXEC_CHECK_DISABLE - device_uvector(device_uvector&&) noexcept = default; + device_uvector(device_uvector&&) noexcept = default; ///< @default_move_constructor - device_uvector& operator=(device_uvector&&) noexcept = default; + device_uvector& operator=(device_uvector&&) noexcept = + default; ///< @default_move_assignment{device_uvector} /** * @brief Copy ctor is deleted as it doesn't allow a stream argument @@ -497,12 +499,12 @@ class device_uvector { [[nodiscard]] const_iterator end() const noexcept { return cend(); } /** - * @brief Returns the number of elements. + * @briefreturn{The number of elements in the vector} */ [[nodiscard]] std::size_t size() const noexcept { return bytes_to_elements(_storage.size()); } /** - * @brief Returns the signed number of elements. + * @briefreturn{The signed number of elements in the vector} */ [[nodiscard]] std::int64_t ssize() const noexcept { @@ -512,17 +514,12 @@ class device_uvector { } /** - * @brief Returns true if the vector contains no elements, i.e., `size() == 0`. - * - * @return true The vector is empty - * @return false The vector is not empty + * @briefreturn{true if the vector contains no elements, i.e. `size() == 0`} */ [[nodiscard]] bool is_empty() const noexcept { return size() == 0; } /** - * @brief Returns pointer to the resource used to allocate and deallocate the device storage. - * - * @return Pointer to underlying resource + * @briefreturn{Pointer to underlying resource used to allocate and deallocate the device storage} */ [[nodiscard]] mr::device_memory_resource* memory_resource() const noexcept { @@ -530,7 +527,7 @@ class device_uvector { } /** - * @brief Returns stream most recently specified for allocation/deallocation + * @briefreturn{Stream most recently specified for allocation/deallocation} */ [[nodiscard]] cuda_stream_view stream() const noexcept { return _storage.stream(); } @@ -542,6 +539,8 @@ class device_uvector { * will be used for deallocation in the `rmm::device_uvector destructor. * However, if either of `resize()` or `shrink_to_fit()` is called after this, * the later stream parameter will be stored and used in the destructor. + * + * @param stream The stream to use for deallocation */ void set_stream(cuda_stream_view stream) noexcept { _storage.set_stream(stream); } diff --git a/include/rmm/exec_policy.hpp b/include/rmm/exec_policy.hpp index 015c3646d..2af332971 100644 --- a/include/rmm/exec_policy.hpp +++ b/include/rmm/exec_policy.hpp @@ -30,6 +30,9 @@ namespace rmm { +/** + * @brief Synchronous execution policy for allocations using thrust + */ using thrust_exec_policy_t = thrust::detail::execute_with_allocator, thrust::cuda_cub::execute_on_stream_base>; @@ -40,6 +43,12 @@ using thrust_exec_policy_t = */ class exec_policy : public thrust_exec_policy_t { public: + /** + * @brief Construct a new execution policy object + * + * @param stream The stream on which to allocate temporary memory + * @param mr The resource to use for allocating temporary memory + */ explicit exec_policy(cuda_stream_view stream = cuda_stream_default, rmm::mr::device_memory_resource* mr = mr::get_current_device_resource()) : thrust_exec_policy_t( @@ -50,6 +59,9 @@ class exec_policy : public thrust_exec_policy_t { #if THRUST_VERSION >= 101600 +/** + * @brief Asynchronous execution policy for allocations using thrust + */ using thrust_exec_policy_nosync_t = thrust::detail::execute_with_allocator, thrust::cuda_cub::execute_on_stream_nosync_base>; @@ -72,9 +84,11 @@ class exec_policy_nosync : public thrust_exec_policy_nosync_t { #else -using thrust_exec_policy_nosync_t = thrust_exec_policy_t; -using exec_policy_nosync = exec_policy; - +using thrust_exec_policy_nosync_t = + thrust_exec_policy_t; ///< When used with Thrust < 1.16.0, thrust_exec_policy_nosync_t is an + ///< alias for thrust_exec_policy_t +using exec_policy_nosync = + exec_policy; ///< When used with Thrust < 1.16.0, exec_policy_nosync is an alias for exec_policy #endif } // namespace rmm diff --git a/include/rmm/logger.hpp b/include/rmm/logger.hpp index d0d6f8fa4..f8fbd4c92 100644 --- a/include/rmm/logger.hpp +++ b/include/rmm/logger.hpp @@ -43,9 +43,11 @@ inline std::string default_log_filename() return (filename == nullptr) ? std::string{"rmm_log.txt"} : std::string{filename}; } -// Simple wrapper around a spdlog::logger that performs RMM-specific initialization +/** + * @brief Simple wrapper around a spdlog::logger that performs RMM-specific initialization + */ struct logger_wrapper { - spdlog::logger logger_; + spdlog::logger logger_; ///< The underlying logger logger_wrapper() : logger_{"RMM", @@ -70,8 +72,14 @@ struct logger_wrapper { * @brief Represent a size in number of bytes. */ struct bytes { - std::size_t value; - + std::size_t value; ///< The size in bytes + + /** + * @brief Construct a new bytes object + * + * @param os The output stream + * @param value The size in bytes + */ friend std::ostream& operator<<(std::ostream& os, bytes const& value) { static std::array units{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"}; diff --git a/include/rmm/mr/device/callback_memory_resource.hpp b/include/rmm/mr/device/callback_memory_resource.hpp index 1937e7ef0..2d9695be2 100644 --- a/include/rmm/mr/device/callback_memory_resource.hpp +++ b/include/rmm/mr/device/callback_memory_resource.hpp @@ -90,12 +90,14 @@ class callback_memory_resource final : public device_memory_resource { { } - callback_memory_resource() = delete; - ~callback_memory_resource() override = default; - callback_memory_resource(callback_memory_resource const&) = delete; - callback_memory_resource& operator=(callback_memory_resource const&) = delete; - callback_memory_resource(callback_memory_resource&&) noexcept = default; - callback_memory_resource& operator=(callback_memory_resource&&) noexcept = default; + callback_memory_resource() = delete; + ~callback_memory_resource() override = default; + callback_memory_resource(callback_memory_resource const&) = delete; + callback_memory_resource& operator=(callback_memory_resource const&) = delete; + callback_memory_resource(callback_memory_resource&&) noexcept = + default; ///< @default_move_constructor + callback_memory_resource& operator=(callback_memory_resource&&) noexcept = + default; ///< @default_move_assignment{callback_memory_resource} private: void* do_allocate(std::size_t bytes, cuda_stream_view stream) override diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index 191e4741d..806ace807 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -77,11 +77,15 @@ class cuda_async_view_memory_resource final : public device_memory_resource { [[nodiscard]] cudaMemPool_t pool_handle() const noexcept { return cuda_pool_handle_; } #endif - cuda_async_view_memory_resource() = default; - cuda_async_view_memory_resource(cuda_async_view_memory_resource const&) = default; - cuda_async_view_memory_resource(cuda_async_view_memory_resource&&) = default; - cuda_async_view_memory_resource& operator=(cuda_async_view_memory_resource const&) = default; - cuda_async_view_memory_resource& operator=(cuda_async_view_memory_resource&&) = default; + cuda_async_view_memory_resource() = default; + cuda_async_view_memory_resource(cuda_async_view_memory_resource const&) = + default; ///< @default_copy_constructor + cuda_async_view_memory_resource(cuda_async_view_memory_resource&&) = + default; ///< @default_move_constructor + cuda_async_view_memory_resource& operator=(cuda_async_view_memory_resource const&) = + default; ///< @default_copy_assignment{cuda_async_view_memory_resource} + cuda_async_view_memory_resource& operator=(cuda_async_view_memory_resource&&) = + default; ///< @default_move_assignment{cuda_async_view_memory_resource} /** * @brief Query whether the resource supports use of non-null CUDA streams for diff --git a/include/rmm/mr/device/cuda_memory_resource.hpp b/include/rmm/mr/device/cuda_memory_resource.hpp index 7a5385f4e..b0bf9ae09 100644 --- a/include/rmm/mr/device/cuda_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_memory_resource.hpp @@ -29,12 +29,14 @@ namespace rmm::mr { */ class cuda_memory_resource final : public device_memory_resource { public: - cuda_memory_resource() = default; - ~cuda_memory_resource() override = default; - cuda_memory_resource(cuda_memory_resource const&) = default; - cuda_memory_resource(cuda_memory_resource&&) = default; - cuda_memory_resource& operator=(cuda_memory_resource const&) = default; - cuda_memory_resource& operator=(cuda_memory_resource&&) = default; + cuda_memory_resource() = default; + ~cuda_memory_resource() override = default; + cuda_memory_resource(cuda_memory_resource const&) = default; ///< @default_copy_constructor + cuda_memory_resource(cuda_memory_resource&&) = default; ///< @default_move_constructor + cuda_memory_resource& operator=(cuda_memory_resource const&) = + default; ///< @default_copy_assignment{cuda_memory_resource} + cuda_memory_resource& operator=(cuda_memory_resource&&) = + default; ///< @default_move_assignment{cuda_memory_resource} /** * @brief Query whether the resource supports use of non-null CUDA streams for diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index 4778d9bda..6f3bd943a 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -81,12 +81,15 @@ namespace rmm::mr { */ class device_memory_resource { public: - device_memory_resource() = default; - virtual ~device_memory_resource() = default; - device_memory_resource(device_memory_resource const&) = default; - device_memory_resource& operator=(device_memory_resource const&) = default; - device_memory_resource(device_memory_resource&&) noexcept = default; - device_memory_resource& operator=(device_memory_resource&&) noexcept = default; + device_memory_resource() = default; + virtual ~device_memory_resource() = default; + device_memory_resource(device_memory_resource const&) = default; ///< @default_copy_constructor + device_memory_resource(device_memory_resource&&) noexcept = + default; ///< @default_move_constructor + device_memory_resource& operator=(device_memory_resource const&) = + default; ///< @default_copy_assignment{device_memory_resource} + device_memory_resource& operator=(device_memory_resource&&) noexcept = + default; ///< @default_move_assignment{device_memory_resource} /** * @brief Allocates memory of size at least \p bytes. @@ -121,7 +124,7 @@ class device_memory_resource { * * @throws Nothing. * - * @param p Pointer to be deallocated + * @param ptr Pointer to be deallocated * @param bytes The size in bytes of the allocation. This must be equal to the * value of `bytes` that was passed to the `allocate` call that returned `p`. * @param stream Stream on which to perform deallocation diff --git a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp index 4a46cb660..48f0513d8 100644 --- a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp +++ b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp @@ -109,14 +109,13 @@ class failure_callback_resource_adaptor final : public device_memory_resource { ~failure_callback_resource_adaptor() override = default; failure_callback_resource_adaptor(failure_callback_resource_adaptor const&) = delete; failure_callback_resource_adaptor& operator=(failure_callback_resource_adaptor const&) = delete; - failure_callback_resource_adaptor(failure_callback_resource_adaptor&&) noexcept = default; + failure_callback_resource_adaptor(failure_callback_resource_adaptor&&) noexcept = + default; ///< @default_move_constructor failure_callback_resource_adaptor& operator=(failure_callback_resource_adaptor&&) noexcept = - default; + default; ///< @default_move_assignment{failure_callback_resource_adaptor} /** - * @brief Return pointer to the upstream resource. - * - * @return Upstream* Pointer to the upstream resource. + * @briefreturn{Pointer to the upstream resource} */ Upstream* get_upstream() const noexcept { return upstream_; } diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index 4954415c3..173c23a0c 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -50,10 +50,10 @@ class fixed_size_memory_resource friend class detail::stream_ordered_memory_resource, detail::fixed_size_free_list>; - // A block is the fixed size this resource alloates - static constexpr std::size_t default_block_size = 1 << 20; // 1 MiB - // This is the number of blocks that the pool starts out with, and also the number of - // blocks by which the pool grows when all of its current blocks are allocated + static constexpr std::size_t default_block_size = 1 << 20; ///< Default allocation block size + + /// The number of blocks that the pool starts out with, and also the number of + /// blocks by which the pool grows when all of its current blocks are allocated static constexpr std::size_t default_blocks_to_preallocate = 128; /** @@ -121,11 +121,11 @@ class fixed_size_memory_resource [[nodiscard]] std::size_t get_block_size() const noexcept { return block_size_; } protected: - using free_list = detail::fixed_size_free_list; - using block_type = free_list::block_type; + using free_list = detail::fixed_size_free_list; ///< The free list type + using block_type = free_list::block_type; ///< The type of block managed by the free list using typename detail::stream_ordered_memory_resource, detail::fixed_size_free_list>::split_block; - using lock_guard = std::lock_guard; + using lock_guard = std::lock_guard; ///< Type of lock used to synchronize access /** * @brief Get the (fixed) size of allocations supported by this memory resource @@ -142,6 +142,7 @@ class fixed_size_memory_resource * strategy (see `size_to_grow()`). * * @param size The minimum size to allocate + * @param blocks The set of blocks from which to allocate * @param stream The stream on which the memory is to be used. * @return block_type The allocated block */ @@ -154,7 +155,6 @@ class fixed_size_memory_resource /** * @brief Allocate blocks from upstream to expand the suballocation pool. * - * @param size The minimum size to allocate * @param stream The stream on which the memory is to be used. * @return block_type The allocated block */ @@ -182,7 +182,6 @@ class fixed_size_memory_resource * * @param block The block to allocate from. * @param size The size in bytes of the requested allocation. - * @param stream_event The stream and associated event on which the allocation will be used. * @return A pair comprising the allocated pointer and any unallocated remainder of the input * block. */ @@ -196,7 +195,6 @@ class fixed_size_memory_resource * * @param ptr The pointer to the memory to free. * @param size The size of the memory to free. Must be equal to the original allocation size. - * @param stream The stream-event pair for the stream on which the memory was last used. * @return The (now freed) block associated with `p`. The caller is expected to return the block * to the pool. */ @@ -217,7 +215,8 @@ class fixed_size_memory_resource * @param stream the stream being executed on * @return std::pair with available and free memory for resource */ - [[nodiscard]] std::pair do_get_mem_info(cuda_stream_view) const override + [[nodiscard]] std::pair do_get_mem_info( + [[maybe_unused]] cuda_stream_view stream) const override { return std::make_pair(0, 0); } diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index 6d1843e82..895c404b0 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -44,7 +44,8 @@ class limiting_resource_adaptor final : public device_memory_resource { * @throws `rmm::logic_error` if `upstream == nullptr` * * @param upstream The resource used for allocating/deallocating device memory - * @param allocation_limit Maximum memory allowed for this allocator. + * @param allocation_limit Maximum memory allowed for this allocator + * @param alignment Alignment in bytes for the start of each allocated buffer */ limiting_resource_adaptor(Upstream* upstream, std::size_t allocation_limit, @@ -57,17 +58,17 @@ class limiting_resource_adaptor final : public device_memory_resource { RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); } - limiting_resource_adaptor() = delete; - ~limiting_resource_adaptor() override = default; - limiting_resource_adaptor(limiting_resource_adaptor const&) = delete; - limiting_resource_adaptor(limiting_resource_adaptor&&) noexcept = default; - limiting_resource_adaptor& operator=(limiting_resource_adaptor const&) = delete; - limiting_resource_adaptor& operator=(limiting_resource_adaptor&&) noexcept = default; + limiting_resource_adaptor() = delete; + ~limiting_resource_adaptor() override = default; + limiting_resource_adaptor(limiting_resource_adaptor const&) = delete; + limiting_resource_adaptor(limiting_resource_adaptor&&) noexcept = + default; ///< @default_move_constructor + limiting_resource_adaptor& operator=(limiting_resource_adaptor const&) = delete; + limiting_resource_adaptor& operator=(limiting_resource_adaptor&&) noexcept = + default; ///< @default_move_assignment{limiting_resource_adaptor} /** - * @brief Return pointer to the upstream resource. - * - * @return Upstream* Pointer to the upstream resource. + * @briefreturn{Pointer to the upstream resource} */ [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 71487705a..cdb527405 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -98,6 +98,20 @@ class logging_resource_adaptor final : public device_memory_resource { init_logger(auto_flush); } + /** + * @brief Construct a new logging resource adaptor using `upstream` to satisfy + * allocation requests and logging information about each allocation/free to + * the ostream specified by `stream`. + * + * The logfile will be written using CSV formatting. + * + * @throws `rmm::logic_error` if `upstream == nullptr` + * + * @param upstream The resource used for allocating/deallocating device memory + * @param sinks A list of logging sinks to which log output will be written. + * @param auto_flush If true, flushes the log for every (de)allocation. Warning, this will degrade + * performance. + */ logging_resource_adaptor(Upstream* upstream, spdlog::sinks_init_list sinks, bool auto_flush = false) @@ -108,12 +122,14 @@ class logging_resource_adaptor final : public device_memory_resource { init_logger(auto_flush); } - logging_resource_adaptor() = delete; - ~logging_resource_adaptor() override = default; - logging_resource_adaptor(logging_resource_adaptor const&) = delete; - logging_resource_adaptor& operator=(logging_resource_adaptor const&) = delete; - logging_resource_adaptor(logging_resource_adaptor&&) noexcept = default; - logging_resource_adaptor& operator=(logging_resource_adaptor&&) noexcept = default; + logging_resource_adaptor() = delete; + ~logging_resource_adaptor() override = default; + logging_resource_adaptor(logging_resource_adaptor const&) = delete; + logging_resource_adaptor& operator=(logging_resource_adaptor const&) = delete; + logging_resource_adaptor(logging_resource_adaptor&&) noexcept = + default; ///< @default_move_constructor + logging_resource_adaptor& operator=(logging_resource_adaptor&&) noexcept = + default; ///< @default_move_assignment{logging_resource_adaptor} /** * @brief Return pointer to the upstream resource. diff --git a/include/rmm/mr/device/managed_memory_resource.hpp b/include/rmm/mr/device/managed_memory_resource.hpp index 50317720a..4a0f7701a 100644 --- a/include/rmm/mr/device/managed_memory_resource.hpp +++ b/include/rmm/mr/device/managed_memory_resource.hpp @@ -29,12 +29,14 @@ namespace rmm::mr { */ class managed_memory_resource final : public device_memory_resource { public: - managed_memory_resource() = default; - ~managed_memory_resource() override = default; - managed_memory_resource(managed_memory_resource const&) = default; - managed_memory_resource(managed_memory_resource&&) = default; - managed_memory_resource& operator=(managed_memory_resource const&) = default; - managed_memory_resource& operator=(managed_memory_resource&&) = default; + managed_memory_resource() = default; + ~managed_memory_resource() override = default; + managed_memory_resource(managed_memory_resource const&) = default; ///< @default_copy_constructor + managed_memory_resource(managed_memory_resource&&) = default; ///< @default_move_constructor + managed_memory_resource& operator=(managed_memory_resource const&) = + default; ///< @default_copy_assignment{managed_memory_resource} + managed_memory_resource& operator=(managed_memory_resource&&) = + default; ///< @default_move_assignment{managed_memory_resource} /** * @brief Query whether the resource supports use of non-null streams for diff --git a/include/rmm/mr/device/owning_wrapper.hpp b/include/rmm/mr/device/owning_wrapper.hpp index d7c7b8c46..eca0b3207 100644 --- a/include/rmm/mr/device/owning_wrapper.hpp +++ b/include/rmm/mr/device/owning_wrapper.hpp @@ -73,7 +73,8 @@ auto make_resource(std::tuple...> const& upstreams, A template class owning_wrapper : public device_memory_resource { public: - using upstream_tuple = std::tuple...>; + using upstream_tuple = + std::tuple...>; ///< Tuple of upstream memory resources /** * @brief Constructs the wrapped resource using the provided upstreams and any additional @@ -116,14 +117,12 @@ class owning_wrapper : public device_memory_resource { } /** - * @brief Returns a constant reference to the wrapped resource. - * + * @briefreturn{A constant reference to the wrapped resource} */ [[nodiscard]] Resource const& wrapped() const noexcept { return *wrapped_; } /** - * @brief Returns reference to the wrapped resource. - * + * @briefreturn{A reference to the wrapped resource} */ [[nodiscard]] Resource& wrapped() noexcept { return *wrapped_; } @@ -136,9 +135,7 @@ class owning_wrapper : public device_memory_resource { } /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return true if the wrapped resource supports get_mem_info, false otherwise. + * @briefreturn{true if the wrapped resource supports get_mem_info, false otherwise} */ [[nodiscard]] bool supports_get_mem_info() const noexcept override { diff --git a/include/rmm/mr/device/per_device_resource.hpp b/include/rmm/mr/device/per_device_resource.hpp index 4ddbd874a..371c97fdf 100644 --- a/include/rmm/mr/device/per_device_resource.hpp +++ b/include/rmm/mr/device/per_device_resource.hpp @@ -88,13 +88,19 @@ inline device_memory_resource* initial_resource() return &mr; } +/** + * @briefreturn{Reference to the lock} + */ inline std::mutex& map_lock() { static std::mutex map_lock; return map_lock; } -// Must have default visibility, see: https://github.com/rapidsai/rmm/issues/826 +// This symbol must have default visibility, see: https://github.com/rapidsai/rmm/issues/826 +/** + * @briefreturn{Reference to the map from device id -> resource} + */ RMM_EXPORT inline auto& get_map() { static std::map device_id_to_resource; @@ -121,7 +127,7 @@ RMM_EXPORT inline auto& get_map() * undefined if used while the active CUDA device is a different device from the one that was active * when the device_memory_resource was created. * - * @param id The id of the target device + * @param device_id The id of the target device * @return Pointer to the current `device_memory_resource` for device `id` */ inline device_memory_resource* get_per_device_resource(cuda_device_id device_id) @@ -156,7 +162,7 @@ inline device_memory_resource* get_per_device_resource(cuda_device_id device_id) * undefined if used while the active CUDA device is a different device from the one that was active * when the device_memory_resource was created. * - * @param id The id of the target device + * @param device_id The id of the target device * @param new_mr If not `nullptr`, pointer to new `device_memory_resource` to use as new resource * for `id` * @return Pointer to the previous memory resource for `id` diff --git a/include/rmm/mr/device/polymorphic_allocator.hpp b/include/rmm/mr/device/polymorphic_allocator.hpp index 5c87ef7f7..a52ec14d1 100644 --- a/include/rmm/mr/device/polymorphic_allocator.hpp +++ b/include/rmm/mr/device/polymorphic_allocator.hpp @@ -43,7 +43,7 @@ namespace rmm::mr { template class polymorphic_allocator { public: - using value_type = T; + using value_type = T; ///< T, the value type of objects allocated by this allocator /** * @brief Construct a `polymorphic_allocator` using the return value of * `rmm::mr::get_current_device_resource()` as the underlying memory resource. @@ -148,7 +148,9 @@ bool operator!=(polymorphic_allocator const& lhs, polymorphic_allocator co template class stream_allocator_adaptor { public: - using value_type = typename std::allocator_traits::value_type; + using value_type = + typename std::allocator_traits::value_type; ///< The value type of objects allocated + ///< by this allocator stream_allocator_adaptor() = delete; @@ -187,8 +189,8 @@ class stream_allocator_adaptor { */ template struct rebind { - using other = - stream_allocator_adaptor::template rebind_alloc>; + using other = stream_allocator_adaptor::template rebind_alloc>; ///< The type to bind to }; /** @@ -212,14 +214,12 @@ class stream_allocator_adaptor { void deallocate(value_type* ptr, std::size_t num) { alloc_.deallocate(ptr, num, stream()); } /** - * @brief Returns the underlying stream on which calls to the underlying allocator are made. - * + * @briefreturn{The stream on which calls to the underlying allocator are made} */ [[nodiscard]] cuda_stream_view stream() const noexcept { return stream_; } /** - * @brief Returns the underlying stream-ordered allocator - * + * @briefreturn{The underlying allocator} */ [[nodiscard]] Allocator underlying_allocator() const noexcept { return alloc_; } diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 8955fd958..703ce8ea7 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -143,11 +143,11 @@ class pool_memory_resource final [[nodiscard]] std::size_t pool_size() const noexcept { return current_pool_size_; } protected: - using free_list = detail::coalescing_free_list; - using block_type = free_list::block_type; + using free_list = detail::coalescing_free_list; ///< The free list implementation + using block_type = free_list::block_type; ///< The type of block returned by the free list using typename detail::stream_ordered_memory_resource, detail::coalescing_free_list>::split_block; - using lock_guard = std::lock_guard; + using lock_guard = std::lock_guard; ///< Type of lock used to synchronize access /** * @brief Get the maximum size of allocations supported by this memory resource @@ -306,7 +306,6 @@ class pool_memory_resource final * * @param block The block to allocate from. * @param size The size in bytes of the requested allocation. - * @param stream_event The stream and associated event on which the allocation will be used. * @return A pair comprising the allocated pointer and any unallocated remainder of the input * block. */ @@ -329,7 +328,6 @@ class pool_memory_resource final * * @param ptr The pointer to the memory to free. * @param size The size of the memory to free. Must be equal to the original allocation size. - * @param stream The stream-event pair for the stream on which the memory was last used. * @return The (now freed) block associated with `p`. The caller is expected to return the block * to the pool. */ diff --git a/include/rmm/mr/device/statistics_resource_adaptor.hpp b/include/rmm/mr/device/statistics_resource_adaptor.hpp index c3fe3010f..7af75593d 100644 --- a/include/rmm/mr/device/statistics_resource_adaptor.hpp +++ b/include/rmm/mr/device/statistics_resource_adaptor.hpp @@ -40,17 +40,24 @@ template class statistics_resource_adaptor final : public device_memory_resource { public: // can be a std::shared_mutex once C++17 is adopted - using read_lock_t = std::shared_lock; - using write_lock_t = std::unique_lock; - + using read_lock_t = + std::shared_lock; ///< Type of lock used to synchronize read access + using write_lock_t = + std::unique_lock; ///< Type of lock used to synchronize write access /** * @brief Utility struct for counting the current, peak, and total value of a number */ struct counter { - int64_t value{0}; // Current value - int64_t peak{0}; // Max value of `value` - int64_t total{0}; // Sum of all added values + int64_t value{0}; ///< Current value + int64_t peak{0}; ///< Max value of `value` + int64_t total{0}; ///< Sum of all added values + /** + * @brief Add `val` to the current value and update the peak value if necessary + * + * @param val Value to add + * @return Reference to this object + */ counter& operator+=(int64_t val) { value += val; @@ -59,6 +66,12 @@ class statistics_resource_adaptor final : public device_memory_resource { return *this; } + /** + * @brief Subtract `val` from the current value and update the peak value if necessary + * + * @param val Value to subtract + * @return Reference to this object + */ counter& operator-=(int64_t val) { value -= val; @@ -79,17 +92,17 @@ class statistics_resource_adaptor final : public device_memory_resource { RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); } - statistics_resource_adaptor() = delete; - ~statistics_resource_adaptor() override = default; - statistics_resource_adaptor(statistics_resource_adaptor const&) = delete; - statistics_resource_adaptor& operator=(statistics_resource_adaptor const&) = delete; - statistics_resource_adaptor(statistics_resource_adaptor&&) noexcept = default; - statistics_resource_adaptor& operator=(statistics_resource_adaptor&&) noexcept = default; + statistics_resource_adaptor() = delete; + ~statistics_resource_adaptor() override = default; + statistics_resource_adaptor(statistics_resource_adaptor const&) = delete; + statistics_resource_adaptor& operator=(statistics_resource_adaptor const&) = delete; + statistics_resource_adaptor(statistics_resource_adaptor&&) noexcept = + default; ///< @default_move_constructor + statistics_resource_adaptor& operator=(statistics_resource_adaptor&&) noexcept = + default; ///< @default_move_assignment{statistics_resource_adaptor} /** - * @brief Return pointer to the upstream resource. - * - * @return Upstream* Pointer to the upstream resource. + * @briefreturn{Pointer to the upstream resource} */ Upstream* get_upstream() const noexcept { return upstream_; } diff --git a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp index 37053cd07..0b8570985 100644 --- a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp +++ b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp @@ -35,7 +35,7 @@ namespace rmm::mr { template class thread_safe_resource_adaptor final : public device_memory_resource { public: - using lock_t = std::lock_guard; + using lock_t = std::lock_guard; ///< Type of lock used to synchronize access /** * @brief Construct a new thread safe resource adaptor using `upstream` to satisfy diff --git a/include/rmm/mr/device/thrust_allocator_adaptor.hpp b/include/rmm/mr/device/thrust_allocator_adaptor.hpp index 2b2aee0dd..de2f25043 100644 --- a/include/rmm/mr/device/thrust_allocator_adaptor.hpp +++ b/include/rmm/mr/device/thrust_allocator_adaptor.hpp @@ -38,9 +38,9 @@ namespace rmm::mr { template class thrust_allocator : public thrust::device_malloc_allocator { public: - using Base = thrust::device_malloc_allocator; - using pointer = typename Base::pointer; - using size_type = typename Base::size_type; + using Base = thrust::device_malloc_allocator; ///< The base type of this allocator + using pointer = typename Base::pointer; ///< The pointer type + using size_type = typename Base::size_type; ///< The size type /** * @brief Provides the type of a `thrust_allocator` instantiated with another @@ -50,7 +50,7 @@ class thrust_allocator : public thrust::device_malloc_allocator { */ template struct rebind { - using other = thrust_allocator; + using other = thrust_allocator; ///< The type to bind to }; /** @@ -113,12 +113,12 @@ class thrust_allocator : public thrust::device_malloc_allocator { } /** - * @brief Returns the device memory resource used by this allocator. + * @briefreturn{The device memory resource used by this} */ [[nodiscard]] device_memory_resource* resource() const noexcept { return _mr; } /** - * @brief Returns the stream used by this allocator. + * @briefreturn{The stream used by this allocator} */ [[nodiscard]] cuda_stream_view stream() const noexcept { return _stream; } diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index 0bbdc7468..b87218d12 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -48,9 +48,10 @@ template class tracking_resource_adaptor final : public device_memory_resource { public: // can be a std::shared_mutex once C++17 is adopted - using read_lock_t = std::shared_lock; - using write_lock_t = std::unique_lock; - + using read_lock_t = + std::shared_lock; ///< Type of lock used to synchronize read access + using write_lock_t = + std::unique_lock; ///< Type of lock used to synchronize write access /** * @brief Information stored about an allocation. Includes the size * and a stack trace if the `tracking_resource_adaptor` was initialized @@ -58,10 +59,16 @@ class tracking_resource_adaptor final : public device_memory_resource { * */ struct allocation_info { - std::unique_ptr strace; - std::size_t allocation_size; + std::unique_ptr strace; ///< Stack trace of the allocation + std::size_t allocation_size; ///< Size of the allocation allocation_info() = delete; + /** + * @brief Construct a new allocation info object + * + * @param size Size of the allocation + * @param capture_stack If true, capture the stack trace for the allocation + */ allocation_info(std::size_t size, bool capture_stack) : strace{[&]() { return capture_stack ? std::make_unique() : nullptr; @@ -84,17 +91,17 @@ class tracking_resource_adaptor final : public device_memory_resource { RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); } - tracking_resource_adaptor() = delete; - ~tracking_resource_adaptor() override = default; - tracking_resource_adaptor(tracking_resource_adaptor const&) = delete; - tracking_resource_adaptor& operator=(tracking_resource_adaptor const&) = delete; - tracking_resource_adaptor(tracking_resource_adaptor&&) noexcept = default; - tracking_resource_adaptor& operator=(tracking_resource_adaptor&&) noexcept = default; + tracking_resource_adaptor() = delete; + ~tracking_resource_adaptor() override = default; + tracking_resource_adaptor(tracking_resource_adaptor const&) = delete; + tracking_resource_adaptor(tracking_resource_adaptor&&) noexcept = + default; ///< @default_move_constructor + tracking_resource_adaptor& operator=(tracking_resource_adaptor const&) = delete; + tracking_resource_adaptor& operator=(tracking_resource_adaptor&&) noexcept = + default; ///< @default_move_assignment{tracking_resource_adaptor} /** - * @brief Return pointer to the upstream resource. - * - * @return Upstream* Pointer to the upstream resource. + * @briefreturn{Pointer to the upstream resource} */ Upstream* get_upstream() const noexcept { return upstream_; } diff --git a/include/rmm/mr/host/host_memory_resource.hpp b/include/rmm/mr/host/host_memory_resource.hpp index c0fe85594..3279bfb3f 100644 --- a/include/rmm/mr/host/host_memory_resource.hpp +++ b/include/rmm/mr/host/host_memory_resource.hpp @@ -46,12 +46,14 @@ namespace rmm::mr { */ class host_memory_resource { public: - host_memory_resource() = default; - virtual ~host_memory_resource() = default; - host_memory_resource(host_memory_resource const&) = default; - host_memory_resource& operator=(host_memory_resource const&) = default; - host_memory_resource(host_memory_resource&&) noexcept = default; - host_memory_resource& operator=(host_memory_resource&&) noexcept = default; + host_memory_resource() = default; + virtual ~host_memory_resource() = default; + host_memory_resource(host_memory_resource const&) = default; ///< @default_copy_constructor + host_memory_resource(host_memory_resource&&) noexcept = default; ///< @default_move_constructor + host_memory_resource& operator=(host_memory_resource const&) = + default; ///< @default_copy_assignment{host_memory_resource} + host_memory_resource& operator=(host_memory_resource&&) noexcept = + default; ///< @default_move_assignment{host_memory_resource} /** * @brief Allocates memory on the host of size at least `bytes` bytes. @@ -84,7 +86,6 @@ class host_memory_resource { * that was passed to the `allocate` call that returned `ptr`. * @param alignment Alignment of the allocation. This must be equal to the value of `alignment` * that was passed to the `allocate` call that returned `ptr`. - * @param stream Stream on which to perform deallocation */ void deallocate(void* ptr, std::size_t bytes, std::size_t alignment = alignof(std::max_align_t)) { diff --git a/include/rmm/mr/host/new_delete_resource.hpp b/include/rmm/mr/host/new_delete_resource.hpp index ffd3345bb..68cccc320 100644 --- a/include/rmm/mr/host/new_delete_resource.hpp +++ b/include/rmm/mr/host/new_delete_resource.hpp @@ -30,12 +30,14 @@ namespace rmm::mr { */ class new_delete_resource final : public host_memory_resource { public: - new_delete_resource() = default; - ~new_delete_resource() override = default; - new_delete_resource(new_delete_resource const&) = default; - new_delete_resource(new_delete_resource&&) = default; - new_delete_resource& operator=(new_delete_resource const&) = default; - new_delete_resource& operator=(new_delete_resource&&) = default; + new_delete_resource() = default; + ~new_delete_resource() override = default; + new_delete_resource(new_delete_resource const&) = default; ///< @default_copy_constructor + new_delete_resource(new_delete_resource&&) = default; ///< @default_move_constructor + new_delete_resource& operator=(new_delete_resource const&) = + default; ///< @default_copy_assignment{new_delete_resource} + new_delete_resource& operator=(new_delete_resource&&) = + default; ///< @default_move_assignment{new_delete_resource} private: /** diff --git a/include/rmm/mr/host/pinned_memory_resource.hpp b/include/rmm/mr/host/pinned_memory_resource.hpp index 3e0c5e3e6..fb28ebfb7 100644 --- a/include/rmm/mr/host/pinned_memory_resource.hpp +++ b/include/rmm/mr/host/pinned_memory_resource.hpp @@ -24,7 +24,7 @@ namespace rmm::mr { -/* +/** * @brief A `host_memory_resource` that uses `cudaMallocHost` to allocate * pinned/page-locked host memory. * @@ -32,12 +32,14 @@ namespace rmm::mr { */ class pinned_memory_resource final : public host_memory_resource { public: - pinned_memory_resource() = default; - ~pinned_memory_resource() override = default; - pinned_memory_resource(pinned_memory_resource const&) = default; - pinned_memory_resource(pinned_memory_resource&&) = default; - pinned_memory_resource& operator=(pinned_memory_resource const&) = default; - pinned_memory_resource& operator=(pinned_memory_resource&&) = default; + pinned_memory_resource() = default; + ~pinned_memory_resource() override = default; + pinned_memory_resource(pinned_memory_resource const&) = default; ///< @default_copy_constructor + pinned_memory_resource(pinned_memory_resource&&) = default; ///< @default_move_constructor + pinned_memory_resource& operator=(pinned_memory_resource const&) = + default; ///< @default_copy_assignment{pinned_memory_resource} + pinned_memory_resource& operator=(pinned_memory_resource&&) = + default; ///< @default_move_assignment{pinned_memory_resource} private: /** From 2f3710e6a783002e2cabbb6efd35fc9d5d882b50 Mon Sep 17 00:00:00 2001 From: Divye Gala Date: Wed, 6 Sep 2023 17:16:06 -0400 Subject: [PATCH 289/675] Simplify wheel build scripts and allow alphas of RAPIDS dependencies (#1335) This PR: 1. Removes `ci/apply_wheel_modifications.sh` and uses it inline in wheel build scripts 2. Allows for specifying alpha versioned dependencies of RAPIDS projects Authors: - Divye Gala (https://github.com/divyegala) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1335 --- ci/build_wheel.sh | 32 +++++++++++++++++++++---- ci/release/apply_wheel_modifications.sh | 15 ------------ 2 files changed, 27 insertions(+), 20 deletions(-) delete mode 100755 ci/release/apply_wheel_modifications.sh diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh index 09c1e104e..660c88387 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel.sh @@ -3,6 +3,9 @@ set -euo pipefail +package_name="rmm" +package_dir="python" + source rapids-configure-sccache source rapids-date-string @@ -12,15 +15,34 @@ version_override="$(rapids-pip-wheel-version ${RAPIDS_DATE_STRING})" RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" -ci/release/apply_wheel_modifications.sh ${version_override} "-${RAPIDS_PY_CUDA_SUFFIX}" -echo "The package name and/or version was modified in the package source. The git diff is:" -git diff +# This is the version of the suffix with a preceding hyphen. It's used +# everywhere except in the final wheel name. +PACKAGE_CUDA_SUFFIX="-${RAPIDS_PY_CUDA_SUFFIX}" + +# Patch project metadata files to include the CUDA version suffix and version override. +pyproject_file="${package_dir}/pyproject.toml" + +sed -i "s/^version = .*/version = \"${version_override}\"/g" ${pyproject_file} +sed -i "s/name = \"${package_name}\"/name = \"${package_name}${PACKAGE_CUDA_SUFFIX}\"/g" ${pyproject_file} + +# For nightlies we want to ensure that we're pulling in alphas as well. The +# easiest way to do so is to augment the spec with a constraint containing a +# min alpha version that doesn't affect the version bounds but does allow usage +# of alpha versions for that dependency without --pre +alpha_spec='' +if ! rapids-is-release-build; then + alpha_spec=',>=0.0.0a0' +fi + +if [[ $PACKAGE_CUDA_SUFFIX == "-cu12" ]]; then + sed -i "s/cuda-python[<=>\.,0-9a]*/cuda-python>=12.0,<13.0a0/g" ${pyproject_file} +fi -cd python +cd "${package_dir}" SKBUILD_CONFIGURE_OPTIONS="-DRMM_BUILD_WHEELS=ON" python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check mkdir -p final_dist python -m auditwheel repair -w final_dist dist/* -RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 final_dist +RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 final_dist diff --git a/ci/release/apply_wheel_modifications.sh b/ci/release/apply_wheel_modifications.sh deleted file mode 100755 index cc71389ea..000000000 --- a/ci/release/apply_wheel_modifications.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -# Copyright (c) 2023, NVIDIA CORPORATION. -# -# Usage: bash apply_wheel_modifications.sh - -VERSION=${1} -CUDA_SUFFIX=${2} - -sed -i "s/^version = .*/version = \"${VERSION}\"/g" python/pyproject.toml - -sed -i "s/^name = \"rmm\"/name = \"rmm${CUDA_SUFFIX}\"/g" python/pyproject.toml - -if [[ $CUDA_SUFFIX == "-cu12" ]]; then - sed -i "s/cuda-python[<=>\.,0-9]*/cuda-python>=12.0,<13.0/g" python/pyproject.toml -fi From f3ca1d78cba68b4e11bf4112731c5889b4c8e5db Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 6 Sep 2023 15:35:14 -0700 Subject: [PATCH 290/675] Add pre-commit hook to validate doxygen (#1334) This change ensures that our doxygen documentation stays up to date during development. Since pre-commit also runs during CI, C++ documentation will be validated on every pull request. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1334 --- .pre-commit-config.yaml | 7 +++++++ dependencies.yaml | 3 ++- scripts/doxygen.sh | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100755 scripts/doxygen.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aa076e6be..13ca70440 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -69,6 +69,13 @@ repos: # of dependencies, so we'll have to update this manually. additional_dependencies: - cmakelang==0.6.13 + - id: doxygen-check + name: doxygen-check + entry: ./scripts/doxygen.sh + types_or: [file] + language: system + pass_filenames: false + verbose: true - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.0.278 hooks: diff --git a/dependencies.yaml b/dependencies.yaml index e16d7a292..f0541ce20 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -111,6 +111,7 @@ dependencies: # pre-commit requires identify minimum version 1.0, but clang-format requires textproto support and that was # added in 2.5.20, so we need to call out the minimum version needed for our plugins - identify>=2.5.20 + - &doxygen doxygen=1.8.20 cudatoolkit: specific: - output_types: conda @@ -153,7 +154,7 @@ dependencies: common: - output_types: [conda] packages: - - doxygen=1.8.20 + - *doxygen - graphviz - ipython - make diff --git a/scripts/doxygen.sh b/scripts/doxygen.sh new file mode 100755 index 000000000..5c001fc72 --- /dev/null +++ b/scripts/doxygen.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# Copyright (c) 2023, NVIDIA CORPORATION. +############################## +# RMM doxygen warnings check # +############################## + +# skip if doxygen is not installed +if ! [ -x "$(command -v doxygen)" ]; then + echo -e "warning: doxygen is not installed" + exit 0 +fi + +# Utility to return version as number for comparison +function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } + +# doxygen supported version 1.8.20 to 1.9.1 +DOXYGEN_VERSION=`doxygen --version` +if [ $(version "$DOXYGEN_VERSION") -lt $(version "1.8.20") ] || [ $(version $DOXYGEN_VERSION) -gt $(version "1.9.1") ]; then + echo -e "warning: Unsupported doxygen version $DOXYGEN_VERSION" + echo -e "Expecting doxygen version from 1.8.20 to 1.9.1" + exit 0 +fi + +# Run doxygen, ignore missing tag files error +TAG_ERROR1="error: Tag file '.*.tag' does not exist or is not a file. Skipping it..." +TAG_ERROR2="error: cannot open tag file .*.tag for writing" +DOXYGEN_STDERR=`cd doxygen && { cat Doxyfile ; echo QUIET = YES; echo GENERATE_HTML = NO; } | doxygen - 2>&1 | sed "/\($TAG_ERROR1\|$TAG_ERROR2\)/d"` +RETVAL=$? + +if [ "$RETVAL" != "0" ] || [ ! -z "$DOXYGEN_STDERR" ]; then + echo -e "$DOXYGEN_STDERR" + RETVAL=1 #because return value is not generated by doxygen 1.8.20 +fi + +exit $RETVAL From 9053d622881464902675b38914432daa8aa998ec Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Fri, 8 Sep 2023 16:59:47 +0100 Subject: [PATCH 291/675] Use `conda mambabuild` not `mamba mambabuild` (#1338) With the release of conda 23.7.3, mamba's mambabuild stopped working. With boa installed, `conda mambabuild` uses the mamba solver, so just use that instead. See also rapidsai/cudf#14068. Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Bradley Dice (https://github.com/bdice) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1338 --- ci/build_cpp.sh | 3 ++- ci/build_python.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index bc6e18021..0ae14a88f 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -11,6 +11,7 @@ rapids-print-env rapids-logger "Begin cpp build" -rapids-mamba-retry mambabuild conda/recipes/librmm +# This calls mambabuild when boa is installed (as is the case in the CI images) +rapids-conda-retry mambabuild conda/recipes/librmm rapids-upload-conda-to-s3 cpp diff --git a/ci/build_python.sh b/ci/build_python.sh index b306d3e47..9da4025c7 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -13,6 +13,7 @@ rapids-logger "Begin py build" CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) -rapids-mamba-retry mambabuild -c "${CPP_CHANNEL}" conda/recipes/rmm +# This calls mambabuild when boa is installed (as is the case in the CI images) +rapids-conda-retry mambabuild -c "${CPP_CHANNEL}" conda/recipes/rmm rapids-upload-conda-to-s3 python From ebd423c21efe3e319d228f05a7c7cdca70467b6d Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 11 Sep 2023 12:43:12 -0700 Subject: [PATCH 292/675] Update doxygen to 1.9.1 (#1337) I selected this version as it is what ships with Ubuntu 22.04. I also ran `doxygen -u` to update the Doxyfile. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Ray Douglass (https://github.com/raydouglass) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1337 --- .../all_cuda-118_arch-x86_64.yaml | 2 +- .../all_cuda-120_arch-x86_64.yaml | 2 +- dependencies.yaml | 2 +- doxygen/Doxyfile | 144 ++++++++++++------ include/rmm/logger.hpp | 3 + scripts/doxygen.sh | 6 +- 6 files changed, 103 insertions(+), 56 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index d56088fbc..5c5ecb453 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -9,7 +9,7 @@ dependencies: - cuda-version=11.8 - cudatoolkit - cython>=3.0.0 -- doxygen=1.8.20 +- doxygen=1.9.1 - fmt>=9.1.0,<10 - gcovr>=5.0 - graphviz diff --git a/conda/environments/all_cuda-120_arch-x86_64.yaml b/conda/environments/all_cuda-120_arch-x86_64.yaml index baa480a1f..e01de1ca2 100644 --- a/conda/environments/all_cuda-120_arch-x86_64.yaml +++ b/conda/environments/all_cuda-120_arch-x86_64.yaml @@ -9,7 +9,7 @@ dependencies: - cuda-python>=12.0,<13.0a0 - cuda-version=12.0 - cython>=3.0.0 -- doxygen=1.8.20 +- doxygen=1.9.1 - fmt>=9.1.0,<10 - gcovr>=5.0 - graphviz diff --git a/dependencies.yaml b/dependencies.yaml index f0541ce20..8c81f7b92 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -111,7 +111,7 @@ dependencies: # pre-commit requires identify minimum version 1.0, but clang-format requires textproto support and that was # added in 2.5.20, so we need to call out the minimum version needed for our plugins - identify>=2.5.20 - - &doxygen doxygen=1.8.20 + - &doxygen doxygen=1.9.1 cudatoolkit: specific: - output_types: conda diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index d03f38b54..5d6153f81 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -1,4 +1,4 @@ -# Doxyfile 1.8.20 +# Doxyfile 1.9.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "RMM" +PROJECT_NAME = RMM # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version @@ -259,11 +259,11 @@ TAB_SIZE = 4 # commands \{ and \} for these it is advised to use the version @{ and @} or use # a double escape (\\{ and \\}) -ALIASES += "briefreturn{1}=@brief \1 @return \1" -ALIASES += "default_copy_constructor=Default copy constructor" -ALIASES += "default_move_constructor=Default move constructor" -ALIASES += "default_copy_assignment{1}=@brief Default copy assignment operator @return \1& Reference to the assigned object" -ALIASES += "default_move_assignment{1}=@brief Default move assignment operator @return \1& Reference to the assigned object" +ALIASES = "briefreturn{1}=@brief \1 @return \1" \ + "default_copy_constructor=Default copy constructor" \ + "default_move_constructor=Default move constructor" \ + "default_copy_assignment{1}=@brief Default copy assignment operator @return \1& Reference to the assigned object" \ + "default_move_assignment{1}=@brief Default move assignment operator @return \1& Reference to the assigned object" # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For @@ -317,7 +317,10 @@ OPTIMIZE_OUTPUT_SLICE = NO # Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. EXTENSION_MAPPING = cu=C++ \ cuh=C++ @@ -528,6 +531,13 @@ EXTRACT_LOCAL_METHODS = NO EXTRACT_ANON_NSPACES = NO +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation @@ -565,11 +575,18 @@ HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES, upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# (including Cygwin) and Mac users are advised to set this option to NO. +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. # The default value is: system dependent. CASE_SENSE_NAMES = YES @@ -808,7 +825,10 @@ WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = YES # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when -# a warning is encountered. +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# Possible values are: NO, YES and FAIL_ON_WARNINGS. # The default value is: NO. WARN_AS_ERROR = NO @@ -844,8 +864,8 @@ INPUT = ../include # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: https://www.gnu.org/software/libiconv/) for the list of -# possible encodings. +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. # The default value is: UTF-8. INPUT_ENCODING = UTF-8 @@ -858,13 +878,15 @@ INPUT_ENCODING = UTF-8 # need to set EXTENSION_MAPPING for the extension otherwise the files are not # read by doxygen. # +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, # *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment), -# *.doc (to be provided as doxygen C comment), *.txt (to be provided as doxygen -# C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, -# *.vhdl, *.ucf, *.qsf and *.ice. +# *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl, +# *.ucf, *.qsf and *.ice. FILE_PATTERNS = *.c \ *.cpp \ @@ -1094,13 +1116,6 @@ VERBATIM_HEADERS = YES ALPHABETICAL_INDEX = YES -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored @@ -1271,10 +1286,11 @@ HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: https://developer.apple.com/xcode/), introduced with OSX -# 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at # startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy # genXcode/_index.html for more information. @@ -1316,8 +1332,8 @@ DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: https://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. +# (see: +# https://www.microsoft.com/en-us/download/details.aspx?id=21138) on Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML @@ -1392,7 +1408,8 @@ QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace -# (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1400,8 +1417,8 @@ QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual- -# folders). +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1409,16 +1426,16 @@ QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom -# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = @@ -1430,9 +1447,9 @@ QHP_CUST_FILTER_ATTRS = QHP_SECT_FILTER_ATTRS = -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = @@ -1559,7 +1576,7 @@ USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. # Possible values are: HTML-CSS (which is slower, but has the best # compatibility), NativeMML (i.e. MathML) and SVG. # The default value is: HTML-CSS. @@ -1589,7 +1606,8 @@ MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. @@ -1636,7 +1654,8 @@ SERVER_BASED_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: https://xapian.org/). +# Xapian (see: +# https://xapian.org/). # # See the section "External Indexing and Searching" for details. # The default value is: NO. @@ -1649,8 +1668,9 @@ EXTERNAL_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: https://xapian.org/). See the section "External Indexing and -# Searching" for details. +# Xapian (see: +# https://xapian.org/). See the section "External Indexing and Searching" for +# details. # This tag requires that the tag SEARCHENGINE is set to YES. SEARCHENGINE_URL = @@ -2329,10 +2349,32 @@ UML_LOOK = NO # but if the number exceeds 15, the total amount of fields shown is limited to # 10. # Minimum value: 0, maximum value: 100, default value: 10. -# This tag requires that the tag HAVE_DOT is set to YES. +# This tag requires that the tag UML_LOOK is set to YES. UML_LIMIT_NUM_FIELDS = 10 +# If the DOT_UML_DETAILS tag is set to NO, doxygen will show attributes and +# methods without types and arguments in the UML graphs. If the DOT_UML_DETAILS +# tag is set to YES, doxygen will add type and arguments for attributes and +# methods in the UML graphs. If the DOT_UML_DETAILS tag is set to NONE, doxygen +# will not generate fields with class member information in the UML graphs. The +# class diagrams will look similar to the default class diagrams but using UML +# notation for the relationships. +# Possible values are: NO, YES and NONE. +# The default value is: NO. +# This tag requires that the tag UML_LOOK is set to YES. + +DOT_UML_DETAILS = NO + +# The DOT_WRAP_THRESHOLD tag can be used to set the maximum number of characters +# to display on a single line. If the actual line length exceeds this threshold +# significantly it will wrapped across multiple lines. Some heuristics are apply +# to avoid ugly line breaks. +# Minimum value: 0, maximum value: 1000, default value: 17. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_WRAP_THRESHOLD = 17 + # If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and # collaboration graphs will show the relations between templates and their # instances. @@ -2522,9 +2564,11 @@ DOT_MULTI_TARGETS = NO GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot +# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate # files that are used to generate the various graphs. +# +# Note: This setting is not only used for dot files but also for msc and +# plantuml temporary files. # The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. DOT_CLEANUP = YES diff --git a/include/rmm/logger.hpp b/include/rmm/logger.hpp index f8fbd4c92..4e17878bd 100644 --- a/include/rmm/logger.hpp +++ b/include/rmm/logger.hpp @@ -121,5 +121,8 @@ inline spdlog::logger& logger() } // namespace rmm +// Doxygen doesn't like this because we're overloading something from fmt +//! @cond Doxygen_Suppress template <> struct fmt::formatter : fmt::ostream_formatter {}; +//! @endcond diff --git a/scripts/doxygen.sh b/scripts/doxygen.sh index 5c001fc72..c584723ae 100755 --- a/scripts/doxygen.sh +++ b/scripts/doxygen.sh @@ -13,11 +13,11 @@ fi # Utility to return version as number for comparison function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } -# doxygen supported version 1.8.20 to 1.9.1 +# doxygen supported version 1.9.1 DOXYGEN_VERSION=`doxygen --version` -if [ $(version "$DOXYGEN_VERSION") -lt $(version "1.8.20") ] || [ $(version $DOXYGEN_VERSION) -gt $(version "1.9.1") ]; then +if [ ! $(version "$DOXYGEN_VERSION") -eq $(version "1.9.1") ] ; then echo -e "warning: Unsupported doxygen version $DOXYGEN_VERSION" - echo -e "Expecting doxygen version from 1.8.20 to 1.9.1" + echo -e "Expecting doxygen version 1.9.1" exit 0 fi From 2ff1bd0aca76afda5daaa2f01faa76fa4cb2612d Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Wed, 13 Sep 2023 10:54:08 +1000 Subject: [PATCH 293/675] Fix stream_ordered_memory_resource attempt to record event in stream from another device (#1333) As described in #1306 , stream_ordered_memory_resource maintained thread-local storage of an event to synchronize in the per-thread default stream. However, this caused the event to be recorded on the wrong stream if allocations were made on memory resources associated with different devices, because allocation on the first device on the PTDS would initialize the TLS for that stream, and subsequent device pools would try to use the already initialized TLS. This PR adds a new test that only runs on multidevice systems (more correctly, does nothing on single device systems). The test creates two per-device pools, and creates and destroys a device buffer on each. It also fixes `stream_ordered_memory_resource` to store the ID of the device that is current when it is constructed, and then to store a vector of one event per device in TLS rather than a single event. When the PTDS is passed to `get_event`, the event for the MR's stored device ID is used. This should correctly support PTDS with multiple threads and multiple devices (still one MR per device). The PR also includes some changes to the device ID utilities in `cuda_device.hpp`. There is a new RAII device helper class, and a `get_num_cuda_devices()` function. Finally, there is a small addition to the .clang-tidy to disable warnings about `do...while` loops inside of RMM error checking macros. - Fixes #1306 Authors: - Mark Harris (https://github.com/harrism) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Bradley Dice (https://github.com/bdice) - Jake Hemstad (https://github.com/jrhemstad) URL: https://github.com/rapidsai/rmm/pull/1333 --- .clang-tidy | 2 + .gitignore | 1 + README.md | 31 +++++++++-- include/rmm/cuda_device.hpp | 54 +++++++++++++++++-- include/rmm/detail/dynamic_load_runtime.hpp | 4 +- .../mr/device/cuda_async_memory_resource.hpp | 2 +- .../cuda_async_view_memory_resource.hpp | 2 +- .../detail/stream_ordered_memory_resource.hpp | 35 +++++++----- include/rmm/mr/device/per_device_resource.hpp | 4 +- tests/mr/device/cuda_async_view_mr_tests.cpp | 4 +- tests/mr/device/pool_mr_tests.cpp | 39 ++++++++++++++ 11 files changed, 148 insertions(+), 30 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 04689c330..9b3f844c9 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -64,4 +64,6 @@ CheckOptions: value: '1' - key: readability-magic-numbers.IgnorePowersOf2IntegerValues value: '1' + - key: cppcoreguidelines-avoid-do-while.IgnoreMacros + value: 'true' ... diff --git a/.gitignore b/.gitignore index 1ab57e4d4..ad6c8ebf7 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ DartConfiguration.tcl .DS_Store *.manifest *.spec +compile_commands.json ## Python build directories & artifacts dist/ diff --git a/README.md b/README.md index 8d65b7d33..2fa4761df 100644 --- a/README.md +++ b/README.md @@ -354,11 +354,32 @@ objects for each device and sets them as the per-device resource for that device ```c++ std::vector> per_device_pools; for(int i = 0; i < N; ++i) { - cudaSetDevice(i); // set device i before creating MR - // Use a vector of unique_ptr to maintain the lifetime of the MRs - per_device_pools.push_back(std::make_unique()); - // Set the per-device resource for device i - set_per_device_resource(cuda_device_id{i}, &per_device_pools.back()); + cudaSetDevice(i); // set device i before creating MR + // Use a vector of unique_ptr to maintain the lifetime of the MRs + per_device_pools.push_back(std::make_unique()); + // Set the per-device resource for device i + set_per_device_resource(cuda_device_id{i}, &per_device_pools.back()); +} +``` + +Note that the CUDA device that is current when creating a `device_memory_resource` must also be +current any time that `device_memory_resource` is used to deallocate memory, including in a +destructor. This affects RAII classes like `rmm::device_buffer` and `rmm::device_uvector`. Here's an +(incorrect) example that assumes the above example loop has been run to create a +`pool_memory_resource` for each device. A correct example adds a call to `cudaSetDevice(0)` on the +line of the error comment. + +```c++ +{ + RMM_CUDA_TRY(cudaSetDevice(0)); + rmm::device_buffer buf_a(16); + + { + RMM_CUDA_TRY(cudaSetDevice(1)); + rmm::device_buffer buf_b(16); + } + + // Error: when buf_a is destroyed, the current device must be 0, but it is 1 } ``` diff --git a/include/rmm/cuda_device.hpp b/include/rmm/cuda_device.hpp index 81d35dc3c..8d355ee23 100644 --- a/include/rmm/cuda_device.hpp +++ b/include/rmm/cuda_device.hpp @@ -42,7 +42,6 @@ struct cuda_device_id { value_type id_; }; -namespace detail { /** * @brief Returns a `cuda_device_id` for the current device * @@ -50,11 +49,56 @@ namespace detail { * * @return `cuda_device_id` for the current device */ -inline cuda_device_id current_device() +inline cuda_device_id get_current_cuda_device() { - int dev_id{}; - RMM_CUDA_TRY(cudaGetDevice(&dev_id)); + cuda_device_id::value_type dev_id{-1}; + RMM_ASSERT_CUDA_SUCCESS(cudaGetDevice(&dev_id)); return cuda_device_id{dev_id}; } -} // namespace detail + +/** + * @brief Returns the number of CUDA devices in the system + * + * @return Number of CUDA devices in the system + */ +inline int get_num_cuda_devices() +{ + cuda_device_id::value_type num_dev{-1}; + RMM_ASSERT_CUDA_SUCCESS(cudaGetDeviceCount(&num_dev)); + return num_dev; +} + +/** + * @brief RAII class that sets the current CUDA device to the specified device on construction + * and restores the previous device on destruction. + */ +struct cuda_set_device_raii { + /** + * @brief Construct a new cuda_set_device_raii object and sets the current CUDA device to `dev_id` + * + * @param dev_id The device to set as the current CUDA device + */ + explicit cuda_set_device_raii(cuda_device_id dev_id) + : old_device_{get_current_cuda_device()}, needs_reset_{old_device_.value() != dev_id.value()} + { + if (needs_reset_) RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(dev_id.value())); + } + /** + * @brief Reactivates the previous CUDA device + */ + ~cuda_set_device_raii() noexcept + { + if (needs_reset_) RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(old_device_.value())); + } + + cuda_set_device_raii(cuda_set_device_raii const&) = delete; + cuda_set_device_raii& operator=(cuda_set_device_raii const&) = delete; + cuda_set_device_raii(cuda_set_device_raii&&) = delete; + cuda_set_device_raii& operator=(cuda_set_device_raii&&) = delete; + + private: + cuda_device_id old_device_; + bool needs_reset_; +}; + } // namespace rmm diff --git a/include/rmm/detail/dynamic_load_runtime.hpp b/include/rmm/detail/dynamic_load_runtime.hpp index 28121e6a8..b45dbae25 100644 --- a/include/rmm/detail/dynamic_load_runtime.hpp +++ b/include/rmm/detail/dynamic_load_runtime.hpp @@ -115,7 +115,7 @@ struct async_alloc { int cuda_pool_supported{}; auto result = cudaDeviceGetAttribute(&cuda_pool_supported, cudaDevAttrMemoryPoolsSupported, - rmm::detail::current_device().value()); + rmm::get_current_cuda_device().value()); return result == cudaSuccess and cuda_pool_supported == 1; }()}; return runtime_supports_pool and driver_supports_pool; @@ -139,7 +139,7 @@ struct async_alloc { if (cudaMemHandleTypeNone != handle_type) { auto const result = cudaDeviceGetAttribute(&supported_handle_types_bitmask, cudaDevAttrMemoryPoolSupportedHandleTypes, - rmm::detail::current_device().value()); + rmm::get_current_cuda_device().value()); // Don't throw on cudaErrorInvalidValue auto const unsupported_runtime = (result == cudaErrorInvalidValue); diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index d41eae63e..329d8f29a 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -98,7 +98,7 @@ class cuda_async_memory_resource final : public device_memory_resource { RMM_EXPECTS(rmm::detail::async_alloc::is_export_handle_type_supported(pool_props.handleTypes), "Requested IPC memory handle type not supported"); pool_props.location.type = cudaMemLocationTypeDevice; - pool_props.location.id = rmm::detail::current_device().value(); + pool_props.location.id = rmm::get_current_cuda_device().value(); cudaMemPool_t cuda_pool_handle{}; RMM_CUDA_TRY(rmm::detail::async_alloc::cudaMemPoolCreate(&cuda_pool_handle, &pool_props)); pool_ = cuda_async_view_memory_resource{cuda_pool_handle}; diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index 806ace807..c685cd75f 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -60,7 +60,7 @@ class cuda_async_view_memory_resource final : public device_memory_resource { }()} { // Check if cudaMallocAsync Memory pool supported - auto const device = rmm::detail::current_device(); + auto const device = rmm::get_current_cuda_device(); int cuda_pool_supported{}; auto result = cudaDeviceGetAttribute(&cuda_pool_supported, cudaDevAttrMemoryPoolsSupported, device.value()); diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index 53575e5ce..f071717c0 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -15,15 +15,16 @@ */ #pragma once +#include #include #include #include #include -#include - #include +#include + #include #include #include @@ -288,17 +289,25 @@ class stream_ordered_memory_resource : public crtp, public device_ stream_event_pair get_event(cuda_stream_view stream) { if (stream.is_per_thread_default()) { - // Create a thread-local shared event wrapper. Shared pointers in the thread and in each MR - // instance ensures it is destroyed cleaned up only after all are finished with it. - thread_local auto event_tls = std::make_shared(); - default_stream_events.insert(event_tls); - return stream_event_pair{stream.value(), event_tls->event}; + // Create a thread-local shared event wrapper for each device. Shared pointers in the thread + // and in each MR instance ensure the wrappers are destroyed only after all are finished + // with them. + thread_local std::vector> events_tls( + rmm::get_num_cuda_devices()); + auto event = [&, device_id = this->device_id_]() { + if (events_tls[device_id.value()]) { return events_tls[device_id.value()]->event; } + + auto event = std::make_shared(); + this->default_stream_events.insert(event); + return (events_tls[device_id.value()] = std::move(event))->event; + }(); + return stream_event_pair{stream.value(), event}; } // We use cudaStreamLegacy as the event map key for the default stream for consistency between // PTDS and non-PTDS mode. In PTDS mode, the cudaStreamLegacy map key will only exist if the // user explicitly passes it, so it is used as the default location for the free list - // at construction. For consistency, the same key is used for null stream free lists in non-PTDS - // mode. + // at construction. For consistency, the same key is used for null stream free lists in + // non-PTDS mode. // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) auto* const stream_to_store = stream.is_default() ? cudaStreamLegacy : stream.value(); @@ -496,11 +505,13 @@ class stream_ordered_memory_resource : public crtp, public device_ // bidirectional mapping between non-default streams and events std::unordered_map stream_events_; - // shared pointers to events keeps the events alive as long as either the thread that created them - // or the MR that is using them exists. + // shared pointers to events keeps the events alive as long as either the thread that created + // them or the MR that is using them exists. std::set> default_stream_events; std::mutex mtx_; // mutex for thread-safe access -}; // namespace detail + + rmm::cuda_device_id device_id_{rmm::get_current_cuda_device()}; +}; // namespace detail } // namespace rmm::mr::detail diff --git a/include/rmm/mr/device/per_device_resource.hpp b/include/rmm/mr/device/per_device_resource.hpp index 371c97fdf..aa7217758 100644 --- a/include/rmm/mr/device/per_device_resource.hpp +++ b/include/rmm/mr/device/per_device_resource.hpp @@ -202,7 +202,7 @@ inline device_memory_resource* set_per_device_resource(cuda_device_id device_id, */ inline device_memory_resource* get_current_device_resource() { - return get_per_device_resource(rmm::detail::current_device()); + return get_per_device_resource(rmm::get_current_cuda_device()); } /** @@ -231,6 +231,6 @@ inline device_memory_resource* get_current_device_resource() */ inline device_memory_resource* set_current_device_resource(device_memory_resource* new_mr) { - return set_per_device_resource(rmm::detail::current_device(), new_mr); + return set_per_device_resource(rmm::get_current_cuda_device(), new_mr); } } // namespace rmm::mr diff --git a/tests/mr/device/cuda_async_view_mr_tests.cpp b/tests/mr/device/cuda_async_view_mr_tests.cpp index 86cb6f106..209429b4b 100644 --- a/tests/mr/device/cuda_async_view_mr_tests.cpp +++ b/tests/mr/device/cuda_async_view_mr_tests.cpp @@ -31,7 +31,7 @@ TEST(PoolTest, UsePool) { cudaMemPool_t memPool{}; RMM_CUDA_TRY(rmm::detail::async_alloc::cudaDeviceGetDefaultMemPool( - &memPool, rmm::detail::current_device().value())); + &memPool, rmm::get_current_cuda_device().value())); const auto pool_init_size{100}; cuda_async_view_mr mr{memPool}; @@ -44,7 +44,7 @@ TEST(PoolTest, NotTakingOwnershipOfPool) { cudaMemPoolProps poolProps = {}; poolProps.allocType = cudaMemAllocationTypePinned; - poolProps.location.id = rmm::detail::current_device().value(); + poolProps.location.id = rmm::get_current_cuda_device().value(); poolProps.location.type = cudaMemLocationTypeDevice; cudaMemPool_t memPool{}; diff --git a/tests/mr/device/pool_mr_tests.cpp b/tests/mr/device/pool_mr_tests.cpp index c5df1951c..6bcd90527 100644 --- a/tests/mr/device/pool_mr_tests.cpp +++ b/tests/mr/device/pool_mr_tests.cpp @@ -14,10 +14,12 @@ * limitations under the License. */ +#include #include #include #include #include +#include #include #include #include @@ -150,5 +152,42 @@ TEST(PoolTest, UpstreamDoesntSupportMemInfo) mr2.deallocate(ptr, 1024); } +TEST(PoolTest, MultidevicePool) +{ + using MemoryResource = rmm::mr::pool_memory_resource; + + // Get the number of cuda devices + int num_devices = rmm::get_num_cuda_devices(); + + // only run on multidevice systems + if (num_devices >= 2) { + rmm::mr::cuda_memory_resource general_mr; + + // initializing pool_memory_resource of multiple devices + int devices = 2; + size_t pool_size = 1024; + std::vector> mrs; + + for (int i = 0; i < devices; ++i) { + RMM_CUDA_TRY(cudaSetDevice(i)); + auto mr = std::make_shared(&general_mr, pool_size, pool_size); + rmm::mr::set_per_device_resource(rmm::cuda_device_id{i}, mr.get()); + mrs.emplace_back(mr); + } + + { + RMM_CUDA_TRY(cudaSetDevice(0)); + rmm::device_buffer buf_a(16, rmm::cuda_stream_per_thread, mrs[0].get()); + + { + RMM_CUDA_TRY(cudaSetDevice(1)); + rmm::device_buffer buf_b(16, rmm::cuda_stream_per_thread, mrs[1].get()); + } + + RMM_CUDA_TRY(cudaSetDevice(0)); + } + } +} + } // namespace } // namespace rmm::test From 068f705cfc0404bc209fdd5ae36f5ea35214867c Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 18 Sep 2023 16:45:33 -0500 Subject: [PATCH 294/675] Clean up headers in CMakeLists.txt. (#1341) This PR adds section headers to the CMakeLists.txt to mirror other RAPIDS packages, which makes it easier to follow the logic and compare across packages. This PR replaces #1292. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1341 --- CMakeLists.txt | 54 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0df2ff3b..814f41be0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,10 +29,15 @@ project( # Write the version header rapids_cmake_write_version_file(include/rmm/version_config.hpp) +# ################################################################################################## +# * build type ------------------------------------------------------------------------------------- + # Set a default build type if none was specified rapids_cmake_build_type(Release) -# build options +# ################################################################################################## +# * build options ---------------------------------------------------------------------------------- + option(BUILD_TESTS "Configure CMake to build tests" ON) option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" OFF) set(RMM_LOGGING_LEVEL @@ -48,17 +53,28 @@ message(STATUS "RMM: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'") # cudart can be statically linked or dynamically linked the python ecosystem wants dynamic linking option(CUDA_STATIC_RUNTIME "Statically link the CUDA runtime" OFF) +# ################################################################################################## +# * compiler options ------------------------------------------------------------------------------- + # find packages we depend on rapids_find_package( CUDAToolkit REQUIRED BUILD_EXPORT_SET rmm-exports INSTALL_EXPORT_SET rmm-exports) + +# ################################################################################################## +# * dependencies ----------------------------------------------------------------------------------- + +# add third party dependencies using CPM rapids_cpm_init() + include(cmake/thirdparty/get_fmt.cmake) include(cmake/thirdparty/get_spdlog.cmake) include(cmake/thirdparty/get_thrust.cmake) -# library targets +# ################################################################################################## +# * library targets -------------------------------------------------------------------------------- + add_library(rmm INTERFACE) add_library(rmm::rmm ALIAS rmm) @@ -79,6 +95,9 @@ target_link_libraries(rmm INTERFACE spdlog::spdlog_header_only) target_link_libraries(rmm INTERFACE dl) target_compile_features(rmm INTERFACE cxx_std_17 $) +# ################################################################################################## +# * tests and benchmarks --------------------------------------------------------------------------- + if((BUILD_TESTS OR BUILD_BENCHMARKS) AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) include(rapids-cuda) rapids_cuda_init_architectures(RMM) @@ -90,7 +109,9 @@ if((BUILD_TESTS OR BUILD_BENCHMARKS) AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAM message(STATUS "RMM: Building benchmarks with GPU Architectures: ${CMAKE_CUDA_ARCHITECTURES}") endif() -# optionally build tests +# ################################################################################################## +# * add tests -------------------------------------------------------------------------------------- + if(BUILD_TESTS AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) include(cmake/thirdparty/get_gtest.cmake) include(CTest) # calls enable_testing() @@ -98,19 +119,19 @@ if(BUILD_TESTS AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) add_subdirectory(tests) endif() -# optionally build benchmarks +# ################################################################################################## +# * add benchmarks --------------------------------------------------------------------------------- + if(BUILD_BENCHMARKS AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) include(${rapids-cmake-dir}/cpm/gbench.cmake) rapids_cpm_gbench() add_subdirectory(benchmarks) endif() -include(CPack) +# ################################################################################################## +# * install targets -------------------------------------------------------------------------------- -# optionally assemble Thrust pretty-printers -if(Thrust_SOURCE_DIR) - configure_file(scripts/load-pretty-printers.in load-pretty-printers @ONLY) -endif() +include(CPack) # install export targets install(TARGETS rmm EXPORT rmm-exports) @@ -143,7 +164,9 @@ rapids_export( DOCUMENTATION doc_string FINAL_CODE_BLOCK code_string) -# build export targets +# ################################################################################################## +# * build export ----------------------------------------------------------------------------------- + rapids_export( BUILD rmm EXPORT_SET rmm-exports @@ -152,7 +175,8 @@ rapids_export( DOCUMENTATION doc_string FINAL_CODE_BLOCK code_string) -# make documentation +# ################################################################################################## +# * make documentation ----------------------------------------------------------------------------- add_custom_command( OUTPUT RMM_DOXYGEN @@ -165,3 +189,11 @@ add_custom_target( rmm_doc DEPENDS RMM_DOXYGEN COMMENT "Target for the custom command to build the RMM doxygen docs") + +# ################################################################################################## +# * make gdb helper scripts ------------------------------------------------------------------------ + +# optionally assemble Thrust pretty-printers +if(Thrust_SOURCE_DIR) + configure_file(scripts/load-pretty-printers.in load-pretty-printers @ONLY) +endif() From 144a0baab34eaab85c12c0973ba08bc80c3d8cfa Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 19 Sep 2023 14:20:34 -0500 Subject: [PATCH 295/675] Update to clang 16.0.6. (#1343) This PR updates rmm to use clang 16.0.6. The previous version 16.0.1 has some minor formatting issues affecting several RAPIDS repos. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1343 --- .pre-commit-config.yaml | 2 +- benchmarks/random_allocations/random_allocations.cpp | 2 +- include/rmm/device_buffer.hpp | 8 ++++---- include/rmm/exec_policy.hpp | 2 +- include/rmm/mr/device/device_memory_resource.hpp | 2 +- include/rmm/mr/device/fixed_size_memory_resource.hpp | 2 +- include/rmm/mr/device/logging_resource_adaptor.hpp | 4 ++-- tests/mr/device/arena_mr_tests.cpp | 6 +++--- tests/mr/device/failure_callback_mr_tests.cpp | 2 +- tests/mr/device/pool_mr_tests.cpp | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 13ca70440..7f095025a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: hooks: - id: cython-lint - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v16.0.1 + rev: v16.0.6 hooks: - id: clang-format types_or: [c, c++, cuda] diff --git a/benchmarks/random_allocations/random_allocations.cpp b/benchmarks/random_allocations/random_allocations.cpp index 8c670525d..470442830 100644 --- a/benchmarks/random_allocations/random_allocations.cpp +++ b/benchmarks/random_allocations/random_allocations.cpp @@ -68,7 +68,7 @@ void random_allocation_free(rmm::mr::device_memory_resource& mr, { std::default_random_engine generator; - max_usage *= size_mb; // convert to bytes + max_usage *= size_mb; // convert to bytes constexpr int allocation_probability{73}; // percent constexpr int max_op_chance{99}; diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index 145fbf891..84638ee89 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -397,10 +397,10 @@ class device_buffer { [[nodiscard]] mr::device_memory_resource* memory_resource() const noexcept { return _mr; } private: - void* _data{nullptr}; ///< Pointer to device memory allocation - std::size_t _size{}; ///< Requested size of the device memory allocation - std::size_t _capacity{}; ///< The actual size of the device memory allocation - cuda_stream_view _stream{}; ///< Stream to use for device memory deallocation + void* _data{nullptr}; ///< Pointer to device memory allocation + std::size_t _size{}; ///< Requested size of the device memory allocation + std::size_t _capacity{}; ///< The actual size of the device memory allocation + cuda_stream_view _stream{}; ///< Stream to use for device memory deallocation mr::device_memory_resource* _mr{ mr::get_current_device_resource()}; ///< The memory resource used to ///< allocate/deallocate device memory diff --git a/include/rmm/exec_policy.hpp b/include/rmm/exec_policy.hpp index 2af332971..78c747652 100644 --- a/include/rmm/exec_policy.hpp +++ b/include/rmm/exec_policy.hpp @@ -88,7 +88,7 @@ using thrust_exec_policy_nosync_t = thrust_exec_policy_t; ///< When used with Thrust < 1.16.0, thrust_exec_policy_nosync_t is an ///< alias for thrust_exec_policy_t using exec_policy_nosync = - exec_policy; ///< When used with Thrust < 1.16.0, exec_policy_nosync is an alias for exec_policy + exec_policy; ///< When used with Thrust < 1.16.0, exec_policy_nosync is an alias for exec_policy #endif } // namespace rmm diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index 6f3bd943a..5f511e393 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -85,7 +85,7 @@ class device_memory_resource { virtual ~device_memory_resource() = default; device_memory_resource(device_memory_resource const&) = default; ///< @default_copy_constructor device_memory_resource(device_memory_resource&&) noexcept = - default; ///< @default_move_constructor + default; ///< @default_move_constructor device_memory_resource& operator=(device_memory_resource const&) = default; ///< @default_copy_assignment{device_memory_resource} device_memory_resource& operator=(device_memory_resource&&) noexcept = diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index 173c23a0c..a24ac6ddd 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -271,7 +271,7 @@ class fixed_size_memory_resource } private: - Upstream* upstream_mr_; // The resource from which to allocate new blocks + Upstream* upstream_mr_; // The resource from which to allocate new blocks std::size_t const block_size_; // size of blocks this MR allocates std::size_t const upstream_chunk_size_; // size of chunks allocated from heap MR diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index cdb527405..0ff9e950b 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -317,8 +317,8 @@ class logging_resource_adaptor final : public device_memory_resource { std::shared_ptr logger_; ///< spdlog logger object - Upstream* upstream_; ///< The upstream resource used for satisfying - ///< allocation requests + Upstream* upstream_; ///< The upstream resource used for satisfying + ///< allocation requests }; /** diff --git a/tests/mr/device/arena_mr_tests.cpp b/tests/mr/device/arena_mr_tests.cpp index 23d0c1b85..48967d06a 100644 --- a/tests/mr/device/arena_mr_tests.cpp +++ b/tests/mr/device/arena_mr_tests.cpp @@ -486,7 +486,7 @@ TEST_F(ArenaTest, SizeSmallerThanSuperblockSize) // NOLINT TEST_F(ArenaTest, AllocateNinetyPercent) // NOLINT { - EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) + EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) auto const free = rmm::detail::available_device_memory().first; auto const ninety_percent = rmm::detail::align_up(static_cast(static_cast(free) * 0.9), @@ -497,7 +497,7 @@ TEST_F(ArenaTest, AllocateNinetyPercent) // NOLINT TEST_F(ArenaTest, SmallMediumLarge) // NOLINT { - EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) + EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) arena_mr mr(rmm::mr::get_current_device_resource()); auto* small = mr.allocate(256); auto* medium = mr.allocate(64_MiB); @@ -511,7 +511,7 @@ TEST_F(ArenaTest, SmallMediumLarge) // NOLINT TEST_F(ArenaTest, Defragment) // NOLINT { - EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) + EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) auto const arena_size = superblock::minimum_size * 4; arena_mr mr(rmm::mr::get_current_device_resource(), arena_size); std::vector threads; diff --git a/tests/mr/device/failure_callback_mr_tests.cpp b/tests/mr/device/failure_callback_mr_tests.cpp index 11c119304..bb5484c69 100644 --- a/tests/mr/device/failure_callback_mr_tests.cpp +++ b/tests/mr/device/failure_callback_mr_tests.cpp @@ -40,7 +40,7 @@ bool failure_handler(std::size_t /*bytes*/, void* arg) retried = true; return true; // First time we request an allocation retry } - return false; // Second time we let the adaptor throw std::bad_alloc + return false; // Second time we let the adaptor throw std::bad_alloc } TEST(FailureCallbackTest, RetryAllocationOnce) diff --git a/tests/mr/device/pool_mr_tests.cpp b/tests/mr/device/pool_mr_tests.cpp index 6bcd90527..4a234d2f9 100644 --- a/tests/mr/device/pool_mr_tests.cpp +++ b/tests/mr/device/pool_mr_tests.cpp @@ -102,7 +102,7 @@ TEST(PoolTest, ForceGrowth) EXPECT_NO_THROW(mr.allocate(1000)); EXPECT_THROW(mr.allocate(4000), rmm::out_of_memory); // too much EXPECT_NO_THROW(mr.allocate(500)); - EXPECT_NO_THROW(mr.allocate(2000)); // fits + EXPECT_NO_THROW(mr.allocate(2000)); // fits } } From 0895487f1cf62148fe5acf85cbc353c29331a3c5 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 19 Sep 2023 19:38:20 -0500 Subject: [PATCH 296/675] Make doxygen only a conda dependency. (#1344) This PR fixes a devcontainers issue seen by @miscco. The `doxygen` dependency can only be installed with conda, so we can't specify it in `requirements.txt`. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1344 --- dependencies.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dependencies.yaml b/dependencies.yaml index 8c81f7b92..765a812cb 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -111,6 +111,8 @@ dependencies: # pre-commit requires identify minimum version 1.0, but clang-format requires textproto support and that was # added in 2.5.20, so we need to call out the minimum version needed for our plugins - identify>=2.5.20 + - output_types: conda + packages: - &doxygen doxygen=1.9.1 cudatoolkit: specific: From cd76d414d3bdb4dbaa4b2ccb9087048edb1ff785 Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Thu, 21 Sep 2023 13:53:05 -0500 Subject: [PATCH 297/675] Update image names (#1346) PR updates `rapidsai/ci` references to `rapidsai/ci-conda` Authors: - Jake Awe (https://github.com/AyodeAwe) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1346 --- .github/workflows/build.yaml | 2 +- .github/workflows/pr.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 238847ddc..d80bf1d41 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -64,7 +64,7 @@ jobs: date: ${{ inputs.date }} node_type: "gpu-v100-latest-1" arch: "amd64" - container_image: "rapidsai/ci:latest" + container_image: "rapidsai/ci-conda:latest" run_script: "ci/build_docs.sh" wheel-build: secrets: inherit diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 5cde123ae..863cea8d8 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -59,7 +59,7 @@ jobs: build_type: pull-request node_type: "gpu-v100-latest-1" arch: "amd64" - container_image: "rapidsai/ci:latest" + container_image: "rapidsai/ci-conda:latest" run_script: "ci/build_docs.sh" wheel-build: needs: checks From e13a8a8f4e7db16890b9dc8f37e2c6084c2b5a25 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Fri, 22 Sep 2023 09:46:45 -0400 Subject: [PATCH 298/675] v23.12 Updates [skip ci] --- .github/workflows/build.yaml | 12 ++++++------ .github/workflows/pr.yaml | 18 +++++++++--------- .github/workflows/test.yaml | 6 +++--- CMakeLists.txt | 2 +- ci/build_docs.sh | 2 +- ci/check_style.sh | 2 +- doxygen/Doxyfile | 2 +- fetch_rapids.cmake | 2 +- python/CMakeLists.txt | 2 +- python/docs/conf.py | 4 ++-- python/pyproject.toml | 2 +- python/rmm/__init__.py | 2 +- 12 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d80bf1d41..12f35468d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-build.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-build.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -78,7 +78,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-publish.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-publish.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 863cea8d8..4a7920f52 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -21,40 +21,40 @@ jobs: - wheel-build - wheel-tests secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.12 checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.12 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.12 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.12 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.12 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.12 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.12 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -64,14 +64,14 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-build.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-build.yaml@branch-23.12 with: build_type: pull-request script: ci/build_wheel.sh wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yaml@branch-23.12 with: build_type: pull-request script: ci/test_wheel.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 81f1b791b..31e476650 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.12 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.12 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yaml@branch-23.12 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 814f41be0..4c883bc4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ include(rapids-find) project( RMM - VERSION 23.10.00 + VERSION 23.12.00 LANGUAGES CXX) # Write the version header diff --git a/ci/build_docs.sh b/ci/build_docs.sh index d54947106..7a23b8c83 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -25,7 +25,7 @@ rapids-mamba-retry install \ --channel "${PYTHON_CHANNEL}" \ rmm librmm -export RAPIDS_VERSION_NUMBER="23.10" +export RAPIDS_VERSION_NUMBER="23.12" export RAPIDS_DOCS_DIR="$(mktemp -d)" rapids-logger "Build CPP docs" diff --git a/ci/check_style.sh b/ci/check_style.sh index e96ad8bf1..a01cf4dcc 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -14,7 +14,7 @@ rapids-dependency-file-generator \ rapids-mamba-retry env create --force -f env.yaml -n checks conda activate checks -FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.10/cmake-format-rapids-cmake.json +FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.12/cmake-format-rapids-cmake.json export RAPIDS_CMAKE_FORMAT_FILE=/tmp/rapids_cmake_ci/cmake-formats-rapids-cmake.json mkdir -p $(dirname ${RAPIDS_CMAKE_FORMAT_FILE}) wget -O ${RAPIDS_CMAKE_FORMAT_FILE} ${FORMAT_FILE_URL} diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 5d6153f81..2ace4abba 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = RMM # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 23.10 +PROJECT_NUMBER = 23.12 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/fetch_rapids.cmake b/fetch_rapids.cmake index 1ff8119ba..899db0467 100644 --- a/fetch_rapids.cmake +++ b/fetch_rapids.cmake @@ -12,7 +12,7 @@ # the License. # ============================================================================= if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.10/RAPIDS.cmake + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.12/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) endif() include(${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 7920bdd3b..24928e024 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) -set(rmm_version 23.10.00) +set(rmm_version 23.12.00) include(../fetch_rapids.cmake) diff --git a/python/docs/conf.py b/python/docs/conf.py index 17c012194..d8c7460dc 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -23,9 +23,9 @@ # built documents. # # The short X.Y version. -version = "23.10" +version = "23.12" # The full version, including alpha/beta/rc tags. -release = "23.10.00" +release = "23.12.00" # -- General configuration --------------------------------------------------- diff --git a/python/pyproject.toml b/python/pyproject.toml index f83e4fec4..300f2332c 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -27,7 +27,7 @@ requires = [ [project] name = "rmm" -version = "23.10.00" +version = "23.12.00" description = "rmm - RAPIDS Memory Manager" readme = { file = "README.md", content-type = "text/markdown" } authors = [ diff --git a/python/rmm/__init__.py b/python/rmm/__init__.py index 38e4c4258..e626919d1 100644 --- a/python/rmm/__init__.py +++ b/python/rmm/__init__.py @@ -36,4 +36,4 @@ "unregister_reinitialize_hook", ] -__version__ = "23.10.00" +__version__ = "23.12.00" From 19c44dbe9e555b4e882ebbbb363cd66160c26b78 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 25 Sep 2023 10:48:42 -0700 Subject: [PATCH 299/675] Enable doxygen XML and fix issues (#1348) doxygen catches more doc issues (of the types fixed in https://github.com/rapidsai/rmm/pull/1317) when more build outputs are turned on, which is indicative of some bugs/limitations in doxygen. XML builds will be necessary to leverage Breathe (see #1324) so this PR enables XML builds and fixes the associated issues. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Rong Ou (https://github.com/rongou) URL: https://github.com/rapidsai/rmm/pull/1348 --- .gitignore | 1 + doxygen/Doxyfile | 2 +- include/rmm/cuda_stream_view.hpp | 2 +- .../mr/device/aligned_resource_adaptor.hpp | 2 +- .../rmm/mr/device/arena_memory_resource.hpp | 3 +- .../rmm/mr/device/binning_memory_resource.hpp | 5 ++-- .../mr/device/callback_memory_resource.hpp | 23 +++++++++++++++ .../mr/device/cuda_async_memory_resource.hpp | 22 +++++++------- .../cuda_async_view_memory_resource.hpp | 21 ++++++++------ .../rmm/mr/device/cuda_memory_resource.hpp | 26 +++++++++-------- .../rmm/mr/device/device_memory_resource.hpp | 2 +- .../mr/device/limiting_resource_adaptor.hpp | 5 ++-- .../mr/device/logging_resource_adaptor.hpp | 4 +++ .../rmm/mr/device/managed_memory_resource.hpp | 29 ++++++++++--------- include/rmm/thrust_rmm_allocator.h | 4 +-- 15 files changed, 95 insertions(+), 56 deletions(-) diff --git a/.gitignore b/.gitignore index ad6c8ebf7..8d5823ab2 100644 --- a/.gitignore +++ b/.gitignore @@ -91,6 +91,7 @@ thirdparty/googletest/ ## Doxygen doxygen/html +doxygen/xml #Java target diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 2ace4abba..28a789a9f 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -2012,7 +2012,7 @@ MAN_LINKS = NO # captures the structure of the code including all documentation. # The default value is: NO. -GENERATE_XML = NO +GENERATE_XML = YES # The XML_OUTPUT tag is used to specify where the XML pages will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of diff --git a/include/rmm/cuda_stream_view.hpp b/include/rmm/cuda_stream_view.hpp index 150fe3957..b6e3cc022 100644 --- a/include/rmm/cuda_stream_view.hpp +++ b/include/rmm/cuda_stream_view.hpp @@ -166,7 +166,7 @@ inline bool operator!=(cuda_stream_view lhs, cuda_stream_view rhs) { return not( * @brief Output stream operator for printing / logging streams * * @param os The output ostream - * @param sv The cuda_stream_view to output + * @param stream The cuda_stream_view to output * @return std::ostream& The output ostream */ inline std::ostream& operator<<(std::ostream& os, cuda_stream_view stream) diff --git a/include/rmm/mr/device/aligned_resource_adaptor.hpp b/include/rmm/mr/device/aligned_resource_adaptor.hpp index 0b933fb56..f79f0c15a 100644 --- a/include/rmm/mr/device/aligned_resource_adaptor.hpp +++ b/include/rmm/mr/device/aligned_resource_adaptor.hpp @@ -140,7 +140,7 @@ class aligned_resource_adaptor final : public device_memory_resource { * * @throws Nothing. * - * @param p Pointer to be deallocated + * @param ptr Pointer to be deallocated * @param bytes Size of the allocation * @param stream Stream on which to perform the deallocation */ diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index e16fbaf7c..882cbf694 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -293,7 +293,8 @@ class arena_memory_resource final : public device_memory_resource { * @param stream to execute on. * @return std::pair containing free_size and total_size of memory. */ - std::pair do_get_mem_info(cuda_stream_view) const override + std::pair do_get_mem_info( + [[maybe_unused]] cuda_stream_view stream) const override { return std::make_pair(0, 0); } diff --git a/include/rmm/mr/device/binning_memory_resource.hpp b/include/rmm/mr/device/binning_memory_resource.hpp index 705df63c6..54cccca28 100644 --- a/include/rmm/mr/device/binning_memory_resource.hpp +++ b/include/rmm/mr/device/binning_memory_resource.hpp @@ -182,7 +182,7 @@ class binning_memory_resource final : public device_memory_resource { * * @throws nothing * - * @param p Pointer to be deallocated + * @param ptr Pointer to be deallocated * @param bytes The size in bytes of the allocation. This must be equal to the * value of `bytes` that was passed to the `allocate` call that returned `p`. * @param stream Stream on which to perform deallocation @@ -201,7 +201,8 @@ class binning_memory_resource final : public device_memory_resource { * @param stream the stream being executed on * @return std::pair with available and free memory for resource */ - [[nodiscard]] std::pair do_get_mem_info(cuda_stream_view) const override + [[nodiscard]] std::pair do_get_mem_info( + [[maybe_unused]] cuda_stream_view stream) const override { return std::make_pair(0, 0); } diff --git a/include/rmm/mr/device/callback_memory_resource.hpp b/include/rmm/mr/device/callback_memory_resource.hpp index 2d9695be2..289ceb9d6 100644 --- a/include/rmm/mr/device/callback_memory_resource.hpp +++ b/include/rmm/mr/device/callback_memory_resource.hpp @@ -100,11 +100,34 @@ class callback_memory_resource final : public device_memory_resource { default; ///< @default_move_assignment{callback_memory_resource} private: + /** + * @brief Allocates memory of size at least \p bytes. + * + * The returned pointer will have at minimum 256 byte alignment. + * + * If supported by the callback, this operation may optionally be executed on + * a stream. Otherwise, the stream is ignored and the null stream is used. + * + * @param bytes The size of the allocation + * @param stream Stream on which to perform allocation + * @return void* Pointer to the newly allocated memory + */ void* do_allocate(std::size_t bytes, cuda_stream_view stream) override { return allocate_callback_(bytes, stream, allocate_callback_arg_); } + /** + * @brief Deallocate memory pointed to by \p p. + * + * If supported by the callback, this operation may optionally be executed on + * a stream. Otherwise, the stream is ignored and the null stream is used. + * + * @param ptr Pointer to be deallocated + * @param bytes The size in bytes of the allocation. This must be equal to the + * value of `bytes` that was passed to the `allocate` call that returned `p`. + * @param stream Stream on which to perform deallocation + */ void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override { deallocate_callback_(ptr, bytes, stream, deallocate_callback_arg_); diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 329d8f29a..9bbd9cc09 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -173,13 +173,12 @@ class cuda_async_memory_resource final : public device_memory_resource { #endif /** - * @brief Allocates memory of size at least `bytes` using cudaMalloc. + * @brief Allocates memory of size at least \p bytes. * - * The returned pointer has at least 256B alignment. + * The returned pointer will have at minimum 256 byte alignment. * - * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled - * - * @param bytes The size, in bytes, of the allocation + * @param bytes The size of the allocation + * @param stream Stream on which to perform allocation * @return void* Pointer to the newly allocated memory */ void* do_allocate(std::size_t bytes, rmm::cuda_stream_view stream) override @@ -197,17 +196,18 @@ class cuda_async_memory_resource final : public device_memory_resource { /** * @brief Deallocate memory pointed to by \p p. * - * @throws Nothing. - * - * @param p Pointer to be deallocated + * @param ptr Pointer to be deallocated + * @param bytes The size in bytes of the allocation. This must be equal to the + * value of `bytes` that was passed to the `allocate` call that returned `p`. + * @param stream Stream on which to perform deallocation */ - void do_deallocate(void* ptr, std::size_t size, rmm::cuda_stream_view stream) override + void do_deallocate(void* ptr, std::size_t bytes, rmm::cuda_stream_view stream) override { #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT - pool_.deallocate(ptr, size, stream); + pool_.deallocate(ptr, bytes, stream); #else (void)ptr; - (void)size; + (void)bytes; (void)stream; #endif } diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index c685cd75f..569f65df7 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -108,13 +108,12 @@ class cuda_async_view_memory_resource final : public device_memory_resource { #endif /** - * @brief Allocates memory of size at least `bytes` using cudaMalloc. + * @brief Allocates memory of size at least \p bytes. * - * The returned pointer has at least 256B alignment. + * The returned pointer will have at minimum 256 byte alignment. * - * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled - * - * @param bytes The size, in bytes, of the allocation + * @param bytes The size of the allocation + * @param stream Stream on which to perform allocation * @return void* Pointer to the newly allocated memory */ void* do_allocate(std::size_t bytes, rmm::cuda_stream_view stream) override @@ -135,11 +134,14 @@ class cuda_async_view_memory_resource final : public device_memory_resource { /** * @brief Deallocate memory pointed to by \p p. * - * @throws Nothing. - * - * @param p Pointer to be deallocated + * @param ptr Pointer to be deallocated + * @param bytes The size in bytes of the allocation. This must be equal to the + * value of `bytes` that was passed to the `allocate` call that returned `p`. + * @param stream Stream on which to perform deallocation */ - void do_deallocate(void* ptr, std::size_t, rmm::cuda_stream_view stream) override + void do_deallocate(void* ptr, + [[maybe_unused]] std::size_t bytes, + rmm::cuda_stream_view stream) override { #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT if (ptr != nullptr) { @@ -147,6 +149,7 @@ class cuda_async_view_memory_resource final : public device_memory_resource { } #else (void)ptr; + (void)bytes; (void)stream; #endif } diff --git a/include/rmm/mr/device/cuda_memory_resource.hpp b/include/rmm/mr/device/cuda_memory_resource.hpp index b0bf9ae09..5164bc5c5 100644 --- a/include/rmm/mr/device/cuda_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_memory_resource.hpp @@ -55,18 +55,17 @@ class cuda_memory_resource final : public device_memory_resource { private: /** - * @brief Allocates memory of size at least `bytes` using cudaMalloc. + * @brief Allocates memory of size at least \p bytes. * - * The returned pointer has at least 256B alignment. + * The returned pointer will have at minimum 256 byte alignment. * - * @note Stream argument is ignored + * The stream argument is ignored. * - * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled - * - * @param bytes The size, in bytes, of the allocation + * @param bytes The size of the allocation + * @param stream This argument is ignored * @return void* Pointer to the newly allocated memory */ - void* do_allocate(std::size_t bytes, cuda_stream_view) override + void* do_allocate(std::size_t bytes, [[maybe_unused]] cuda_stream_view stream) override { void* ptr{nullptr}; RMM_CUDA_TRY_ALLOC(cudaMalloc(&ptr, bytes)); @@ -76,13 +75,16 @@ class cuda_memory_resource final : public device_memory_resource { /** * @brief Deallocate memory pointed to by \p p. * - * @note Stream argument is ignored. - * - * @throws Nothing. + * The stream argument is ignored. * - * @param p Pointer to be deallocated + * @param ptr Pointer to be deallocated + * @param bytes The size in bytes of the allocation. This must be equal to the + * value of `bytes` that was passed to the `allocate` call that returned `p`. + * @param stream This argument is ignored. */ - void do_deallocate(void* ptr, std::size_t, cuda_stream_view) override + void do_deallocate(void* ptr, + [[maybe_unused]] std::size_t bytes, + [[maybe_unused]] cuda_stream_view stream) override { RMM_ASSERT_CUDA_SUCCESS(cudaFree(ptr)); } diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index 5f511e393..1813fb726 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -201,7 +201,7 @@ class device_memory_resource { * If supported, this operation may optionally be executed on a stream. * Otherwise, the stream is ignored and the null stream is used. * - * @param p Pointer to be deallocated + * @param ptr Pointer to be deallocated * @param bytes The size in bytes of the allocation. This must be equal to the * value of `bytes` that was passed to the `allocate` call that returned `p`. * @param stream Stream on which to perform deallocation diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index 895c404b0..ebc67fed1 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -185,7 +185,8 @@ class limiting_resource_adaptor final : public device_memory_resource { * @param stream Stream on which to get the mem info. * @return std::pair contaiing free_size and total_size of memory */ - [[nodiscard]] std::pair do_get_mem_info(cuda_stream_view) const override + [[nodiscard]] std::pair do_get_mem_info( + [[maybe_unused]] cuda_stream_view stream) const override { return {allocation_limit_ - allocated_bytes_, allocation_limit_}; } @@ -209,7 +210,7 @@ class limiting_resource_adaptor final : public device_memory_resource { * * @tparam Upstream Type of the upstream `device_memory_resource`. * @param upstream Pointer to the upstream resource - * @param limit Maximum amount of memory to allocate + * @param allocation_limit Maximum amount of memory to allocate */ template limiting_resource_adaptor make_limiting_adaptor(Upstream* upstream, diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 0ff9e950b..c59fdf61a 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -329,6 +329,8 @@ class logging_resource_adaptor final : public device_memory_resource { * @param upstream Pointer to the upstream resource * @param filename Name of the file to write log info. If not specified, * retrieves the log file name from the environment variable "RMM_LOG_FILE". + * @param auto_flush If true, flushes the log for every (de)allocation. Warning, this will degrade + * performance. */ template logging_resource_adaptor make_logging_adaptor( @@ -346,6 +348,8 @@ logging_resource_adaptor make_logging_adaptor( * @tparam Upstream Type of the upstream `device_memory_resource`. * @param upstream Pointer to the upstream resource * @param stream The ostream to write log info. + * @param auto_flush If true, flushes the log for every (de)allocation. Warning, this will degrade + * performance. */ template logging_resource_adaptor make_logging_adaptor(Upstream* upstream, diff --git a/include/rmm/mr/device/managed_memory_resource.hpp b/include/rmm/mr/device/managed_memory_resource.hpp index 4a0f7701a..e987de15d 100644 --- a/include/rmm/mr/device/managed_memory_resource.hpp +++ b/include/rmm/mr/device/managed_memory_resource.hpp @@ -55,18 +55,17 @@ class managed_memory_resource final : public device_memory_resource { private: /** - * @brief Allocates memory of size at least `bytes` using cudaMallocManaged. + * @brief Allocates memory of size at least \p bytes. * - * The returned pointer has at least 256B alignment. + * The returned pointer will have at minimum 256 byte alignment. * - * @note Stream argument is ignored + * The stream is ignored. * - * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled - * - * @param bytes The size, in bytes, of the allocation + * @param bytes The size of the allocation + * @param stream This argument is ignored * @return void* Pointer to the newly allocated memory */ - void* do_allocate(std::size_t bytes, cuda_stream_view) override + void* do_allocate(std::size_t bytes, [[maybe_unused]] cuda_stream_view stream) override { // FIXME: Unlike cudaMalloc, cudaMallocManaged will throw an error for 0 // size allocations. @@ -78,15 +77,18 @@ class managed_memory_resource final : public device_memory_resource { } /** - * @brief Deallocate memory pointed to by `ptr`. - * - * @note Stream argument is ignored. + * @brief Deallocate memory pointed to by \p p. * - * @throws Nothing. + * The stream is ignored. * * @param ptr Pointer to be deallocated + * @param bytes The size in bytes of the allocation. This must be equal to the + * value of `bytes` that was passed to the `allocate` call that returned `p`. + * @param stream This argument is ignored */ - void do_deallocate(void* ptr, std::size_t, cuda_stream_view) override + void do_deallocate(void* ptr, + [[maybe_unused]] std::size_t bytes, + [[maybe_unused]] cuda_stream_view stream) override { RMM_ASSERT_CUDA_SUCCESS(cudaFree(ptr)); } @@ -116,7 +118,8 @@ class managed_memory_resource final : public device_memory_resource { * @param stream to execute on * @return std::pair contaiing free_size and total_size of memory */ - [[nodiscard]] std::pair do_get_mem_info(cuda_stream_view) const override + [[nodiscard]] std::pair do_get_mem_info( + [[maybe_unused]] cuda_stream_view stream) const override { std::size_t free_size{}; std::size_t total_size{}; diff --git a/include/rmm/thrust_rmm_allocator.h b/include/rmm/thrust_rmm_allocator.h index 3bbcab0a5..0b78d5497 100644 --- a/include/rmm/thrust_rmm_allocator.h +++ b/include/rmm/thrust_rmm_allocator.h @@ -33,9 +33,9 @@ using exec_policy_t = std::unique_ptr; * @brief Returns a unique_ptr to a Thrust CUDA execution policy that uses RMM * for temporary memory allocation. * - * @Param stream The stream that the allocator will use + * @param stream The stream that the allocator will use * - * @Returns A Thrust execution policy that will use RMM for temporary memory + * @return A Thrust execution policy that will use RMM for temporary memory * allocation. */ [[deprecated("Use new exec_policy in rmm/exec_policy.hpp")]] inline exec_policy_t exec_policy( From c8acf766d82e3e5f17b04e0cef2db7fd306f8548 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Tue, 26 Sep 2023 14:04:47 +0100 Subject: [PATCH 300/675] Compile cdef public functions from torch_allocator with C ABI (#1350) Since Cython 3, we must explicitly request a C ABI with `-DCYTHON_EXTERN_C='extern "C"'` for `cdef public` functions. - Closes #1349 Before: ``` $ nm -D .../rmm/python/rmm/_lib/torch_allocator.cpython-310-x86_64-linux-gnu.so | grep allocate 00000000000071c0 T _Z10deallocatePvlS_ 0000000000007500 T _Z8allocateliPv ... ``` After: ``` $ nm -D .../rmm/python/rmm/_lib/torch_allocator.cpython-310-x86_64-linux-gnu.so | grep allocate 0000000000007500 T allocate 00000000000071c0 T deallocate ... ``` Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Ashwin Srinath (https://github.com/shwina) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1350 --- python/rmm/_lib/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/rmm/_lib/CMakeLists.txt b/python/rmm/_lib/CMakeLists.txt index 9e90d7e99..61caa0e7e 100644 --- a/python/rmm/_lib/CMakeLists.txt +++ b/python/rmm/_lib/CMakeLists.txt @@ -19,3 +19,5 @@ set(linked_libraries rmm::rmm) # Build all of the Cython targets rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}" CXX) +# The cdef public functions in this file need to have a C ABI +target_compile_definitions(torch_allocator PRIVATE CYTHON_EXTERN_C=extern\ "C") From ec32693967c3fce21a094ad639dc9572529efbe3 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 26 Sep 2023 08:35:06 -0500 Subject: [PATCH 301/675] RMM: Build CUDA 12.0 ARM conda packages. (#1330) This PR builds `librmm` and `rmm` conda packages using CUDA 12 on ARM. Authors: - Bradley Dice (https://github.com/bdice) - Mark Harris (https://github.com/harrism) Approvers: - Ray Douglass (https://github.com/raydouglass) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1330 --- .github/workflows/build.yaml | 12 ++++++------ .github/workflows/pr.yaml | 18 +++++++++--------- .github/workflows/test.yaml | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 12f35468d..f0a60b269 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@cuda-120-arm with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@cuda-120-arm with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@cuda-120-arm with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@cuda-120-arm with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-build.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-build.yaml@cuda-120-arm with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -78,7 +78,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-publish.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-publish.yaml@cuda-120-arm with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 4a7920f52..74948878d 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -21,40 +21,40 @@ jobs: - wheel-build - wheel-tests secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@cuda-120-arm checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@cuda-120-arm with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@cuda-120-arm with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-120-arm with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@cuda-120-arm with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@cuda-120-arm with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@cuda-120-arm with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -64,14 +64,14 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-build.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-build.yaml@cuda-120-arm with: build_type: pull-request script: ci/build_wheel.sh wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yaml@cuda-120-arm with: build_type: pull-request script: ci/test_wheel.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 31e476650..5b872f53e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-120-arm with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@cuda-120-arm with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yaml@branch-23.12 + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yaml@cuda-120-arm with: build_type: nightly branch: ${{ inputs.branch }} From 7a9451d921a3c76eae58d3c54d8e23512411c0fa Mon Sep 17 00:00:00 2001 From: Paul Taylor <178183+trxcllnt@users.noreply.github.com> Date: Tue, 26 Sep 2023 13:52:25 -0700 Subject: [PATCH 302/675] Add RMM devcontainers (#1328) This PR adds some [devcontainers](https://containers.dev/) to help simplify building the RMM C++ and Python libraries. It also adds an optional job to the `pr.yaml` to [build the RMM libs in each devcontainer](https://github.com/trxcllnt/rmm/blob/fea/devcontainers/.github/workflows/pr.yaml#L79-L85), so the build caches are populated for devs by CI. A devcontainer can be launched by clicking the "Reopen in Container" button that VSCode shows when opening the repo (or by using the "Rebuild and Reopen in Container" command from the command palette): ![image](https://user-images.githubusercontent.com/178183/221771999-97ab29d5-e718-4e5f-b32f-2cdd51bba25c.png) Clicking this button will cause VSCode to prompt the user to select one of these devcontainer variants: ![image](https://github.com/rapidsai/rmm/assets/178183/68d4b264-4fc2-4008-92b6-cb4bdd19b29f) On startup, the devcontainer creates or updates the conda/pip environment using `rmm/dependencies.yaml`. The envs/package caches are cached on the host via volume mounts, which are described in more detail in [`.devcontainer/README.md`](https://github.com/trxcllnt/rmm/blob/fea/devcontainers/.devcontainer/README.md). The container includes convenience functions to clean, configure, and build the various RMM components: ```shell $ clean-rmm-cpp # only cleans the C++ build dir $ clean-rmm-python # only cleans the Python build dir $ clean-rmm # cleans both C++ and Python build dirs $ configure-rmm-cpp # only configures rmm C++ lib $ build-rmm-cpp # only builds rmm C++ lib $ build-rmm-python # only builds rmm Python lib $ build-rmm # builds both C++ and Python libs ``` * The C++ build script is a small wrapper around `cmake -S ~/rmm -B ~/rmm/build` and `cmake --build ~/rmm/build` * The Python build script is a small wrapper around `pip install --editable ~/rmm` Unlike `build.sh`, these convenience scripts *don't* install the libraries after building them. Instead, they automatically inject the correct arguments to build the C++ libraries from source and use their build dirs as package roots: ```shell $ cmake -S ~/rmm -B ~/rmm/build $ CMAKE_ARGS="-Drmm_ROOT=~/rmm/build" \ # <-- this argument is automatic pip install -e ~/rmm ``` Authors: - Paul Taylor (https://github.com/trxcllnt) Approvers: - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1328 --- .clangd | 65 +++++++++++++++++++ .devcontainer/Dockerfile | 30 +++++++++ .devcontainer/README.md | 35 ++++++++++ .../cuda11.8-conda/devcontainer.json | 37 +++++++++++ .devcontainer/cuda11.8-pip/devcontainer.json | 36 ++++++++++ .../cuda12.0-conda/devcontainer.json | 37 +++++++++++ .devcontainer/cuda12.0-pip/devcontainer.json | 36 ++++++++++ .github/workflows/pr.yaml | 9 +++ .gitignore | 4 ++ ci/release/update-version.sh | 9 +++ .../all_cuda-118_arch-x86_64.yaml | 6 ++ .../all_cuda-120_arch-x86_64.yaml | 6 ++ dependencies.yaml | 20 +++++- tests/CMakeLists.txt | 8 ++- 14 files changed, 335 insertions(+), 3 deletions(-) create mode 100644 .clangd create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/README.md create mode 100644 .devcontainer/cuda11.8-conda/devcontainer.json create mode 100644 .devcontainer/cuda11.8-pip/devcontainer.json create mode 100644 .devcontainer/cuda12.0-conda/devcontainer.json create mode 100644 .devcontainer/cuda12.0-pip/devcontainer.json diff --git a/.clangd b/.clangd new file mode 100644 index 000000000..7c4fe036d --- /dev/null +++ b/.clangd @@ -0,0 +1,65 @@ +# https://clangd.llvm.org/config + +# Apply a config conditionally to all C files +If: + PathMatch: .*\.(c|h)$ + +--- + +# Apply a config conditionally to all C++ files +If: + PathMatch: .*\.(c|h)pp + +--- + +# Apply a config conditionally to all CUDA files +If: + PathMatch: .*\.cuh? +CompileFlags: + Add: + - "-x" + - "cuda" + # No error on unknown CUDA versions + - "-Wno-unknown-cuda-version" + # Allow variadic CUDA functions + - "-Xclang=-fcuda-allow-variadic-functions" +Diagnostics: + Suppress: + - "variadic_device_fn" + - "attributes_not_allowed" + +--- + +# Tweak the clangd parse settings for all files +CompileFlags: + Add: + # report all errors + - "-ferror-limit=0" + - "-fmacro-backtrace-limit=0" + - "-ftemplate-backtrace-limit=0" + # Skip the CUDA version check + - "--no-cuda-version-check" + Remove: + # remove gcc's -fcoroutines + - -fcoroutines + # remove nvc++ flags unknown to clang + - "-gpu=*" + - "-stdpar*" + # remove nvcc flags unknown to clang + - "-arch*" + - "-gencode*" + - "--generate-code*" + - "-ccbin*" + - "-t=*" + - "--threads*" + - "-Xptxas*" + - "-Xcudafe*" + - "-Xfatbin*" + - "-Xcompiler*" + - "--diag-suppress*" + - "--diag_suppress*" + - "--compiler-options*" + - "--expt-extended-lambda" + - "--expt-relaxed-constexpr" + - "-forward-unknown-to-host-compiler" + - "-Werror=cross-execution-space-call" diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..9d35e3f97 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,30 @@ +# syntax=docker/dockerfile:1.5 + +ARG BASE +ARG PYTHON_PACKAGE_MANAGER=conda + +FROM ${BASE} as pip-base + +ENV DEFAULT_VIRTUAL_ENV=rapids + +FROM ${BASE} as conda-base + +ENV DEFAULT_CONDA_ENV=rapids + +FROM ${PYTHON_PACKAGE_MANAGER}-base + +ARG CUDA +ENV CUDAARCHS="RAPIDS" +ENV CUDA_VERSION="${CUDA_VERSION:-${CUDA}}" + +ARG PYTHON_PACKAGE_MANAGER +ENV PYTHON_PACKAGE_MANAGER="${PYTHON_PACKAGE_MANAGER}" + +ENV PYTHONSAFEPATH="1" +ENV PYTHONUNBUFFERED="1" +ENV PYTHONDONTWRITEBYTECODE="1" + +ENV SCCACHE_REGION="us-east-2" +ENV SCCACHE_BUCKET="rapids-sccache-devs" +ENV VAULT_HOST="https://vault.ops.k8s.rapids.ai" +ENV HISTFILE="/home/coder/.cache/._bash_history" diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 000000000..31ddab9aa --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,35 @@ +# RMM Development Containers + +This directory contains [devcontainer configurations](https://containers.dev/implementors/json_reference/) for using VSCode to [develop in a container](https://code.visualstudio.com/docs/devcontainers/containers) via the `Remote Containers` [extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) or [GitHub Codespaces](https://github.com/codespaces). + +This container is a turnkey development environment for building and testing the RMM C++ and Python libraries. + +## Table of Contents + +* [Prerequisites](#prerequisites) +* [Host bind mounts](#host-bind-mounts) +* [Launch a Dev Container](#launch-a-dev-container) + +## Prerequisites + +* [VSCode](https://code.visualstudio.com/download) +* [VSCode Remote Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) + +## Host bind mounts + +By default, the following directories are bind-mounted into the devcontainer: + +* `${repo}:/home/coder/rmm` +* `${repo}/../.aws:/home/coder/.aws` +* `${repo}/../.local:/home/coder/.local` +* `${repo}/../.cache:/home/coder/.cache` +* `${repo}/../.conda:/home/coder/.conda` +* `${repo}/../.config:/home/coder/.config` + +This ensures caches, configurations, dependencies, and your commits are persisted on the host across container runs. + +## Launch a Dev Container + +To launch a devcontainer from VSCode, open the RMM repo and select the "Reopen in Container" button in the bottom right:
+ +Alternatively, open the VSCode command palette (typically `cmd/ctrl + shift + P`) and run the "Rebuild and Reopen in Container" command. diff --git a/.devcontainer/cuda11.8-conda/devcontainer.json b/.devcontainer/cuda11.8-conda/devcontainer.json new file mode 100644 index 000000000..ba3555a26 --- /dev/null +++ b/.devcontainer/cuda11.8-conda/devcontainer.json @@ -0,0 +1,37 @@ +{ + "build": { + "context": "${localWorkspaceFolder}/.devcontainer", + "dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile", + "args": { + "CUDA": "11.8", + "PYTHON_PACKAGE_MANAGER": "conda", + "BASE": "rapidsai/devcontainers:23.10-cpp-llvm16-cuda11.8-mambaforge-ubuntu22.04" + } + }, + "hostRequirements": {"gpu": "optional"}, + "features": { + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.10": {} + }, + "overrideFeatureInstallOrder": [ + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" + ], + "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config,conda/pkgs,conda/${localWorkspaceFolderBasename}-cuda11.8-envs}"], + "postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"], + "workspaceFolder": "/home/coder", + "workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent", + "mounts": [ + "source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/../.conda/pkgs,target=/home/coder/.conda/pkgs,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/../.conda/${localWorkspaceFolderBasename}-cuda11.8-envs,target=/home/coder/.conda/envs,type=bind,consistency=consistent" + ], + "customizations": { + "vscode": { + "extensions": [ + "ms-python.flake8", + "nvidia.nsight-vscode-edition" + ] + } + } +} diff --git a/.devcontainer/cuda11.8-pip/devcontainer.json b/.devcontainer/cuda11.8-pip/devcontainer.json new file mode 100644 index 000000000..a5b4290e9 --- /dev/null +++ b/.devcontainer/cuda11.8-pip/devcontainer.json @@ -0,0 +1,36 @@ +{ + "build": { + "context": "${localWorkspaceFolder}/.devcontainer", + "dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile", + "args": { + "CUDA": "11.8", + "PYTHON_PACKAGE_MANAGER": "pip", + "BASE": "rapidsai/devcontainers:23.10-cpp-llvm16-cuda11.8-ubuntu22.04" + } + }, + "hostRequirements": {"gpu": "optional"}, + "features": { + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.10": {} + }, + "overrideFeatureInstallOrder": [ + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" + ], + "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config/pip,local/share/${localWorkspaceFolderBasename}-cuda11.8-venvs}"], + "postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"], + "workspaceFolder": "/home/coder", + "workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent", + "mounts": [ + "source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/../.local/share/${localWorkspaceFolderBasename}-cuda11.8-venvs,target=/home/coder/.local/share/venvs,type=bind,consistency=consistent" + ], + "customizations": { + "vscode": { + "extensions": [ + "ms-python.flake8", + "nvidia.nsight-vscode-edition" + ] + } + } +} diff --git a/.devcontainer/cuda12.0-conda/devcontainer.json b/.devcontainer/cuda12.0-conda/devcontainer.json new file mode 100644 index 000000000..03282635e --- /dev/null +++ b/.devcontainer/cuda12.0-conda/devcontainer.json @@ -0,0 +1,37 @@ +{ + "build": { + "context": "${localWorkspaceFolder}/.devcontainer", + "dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile", + "args": { + "CUDA": "12.0", + "PYTHON_PACKAGE_MANAGER": "conda", + "BASE": "rapidsai/devcontainers:23.10-cpp-mambaforge-ubuntu22.04" + } + }, + "hostRequirements": {"gpu": "optional"}, + "features": { + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.10": {} + }, + "overrideFeatureInstallOrder": [ + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" + ], + "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config,conda/pkgs,conda/${localWorkspaceFolderBasename}-cuda12.0-envs}"], + "postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"], + "workspaceFolder": "/home/coder", + "workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent", + "mounts": [ + "source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/../.conda/pkgs,target=/home/coder/.conda/pkgs,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/../.conda/${localWorkspaceFolderBasename}-cuda12.0-envs,target=/home/coder/.conda/envs,type=bind,consistency=consistent" + ], + "customizations": { + "vscode": { + "extensions": [ + "ms-python.flake8", + "nvidia.nsight-vscode-edition" + ] + } + } +} diff --git a/.devcontainer/cuda12.0-pip/devcontainer.json b/.devcontainer/cuda12.0-pip/devcontainer.json new file mode 100644 index 000000000..8dc607f28 --- /dev/null +++ b/.devcontainer/cuda12.0-pip/devcontainer.json @@ -0,0 +1,36 @@ +{ + "build": { + "context": "${localWorkspaceFolder}/.devcontainer", + "dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile", + "args": { + "CUDA": "12.0", + "PYTHON_PACKAGE_MANAGER": "pip", + "BASE": "rapidsai/devcontainers:23.10-cpp-llvm16-cuda12.0-ubuntu22.04" + } + }, + "hostRequirements": {"gpu": "optional"}, + "features": { + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.10": {} + }, + "overrideFeatureInstallOrder": [ + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" + ], + "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config/pip,local/share/${localWorkspaceFolderBasename}-cuda12.0-venvs}"], + "postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"], + "workspaceFolder": "/home/coder", + "workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent", + "mounts": [ + "source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", + "source=${localWorkspaceFolder}/../.local/share/${localWorkspaceFolderBasename}-cuda12.0-venvs,target=/home/coder/.local/share/venvs,type=bind,consistency=consistent" + ], + "customizations": { + "vscode": { + "extensions": [ + "ms-python.flake8", + "nvidia.nsight-vscode-edition" + ] + } + } +} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 863cea8d8..95ac72d59 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -20,6 +20,7 @@ jobs: - docs-build - wheel-build - wheel-tests + - devcontainer secrets: inherit uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.10 checks: @@ -75,3 +76,11 @@ jobs: with: build_type: pull-request script: ci/test_wheel.sh + devcontainer: + secrets: inherit + uses: rapidsai/shared-action-workflows/.github/workflows/build-in-devcontainer.yaml@branch-23.10 + with: + build_command: | + sccache -z; + build-all -DBUILD_BENCHMARKS=ON --verbose; + sccache -s; diff --git a/.gitignore b/.gitignore index ad6c8ebf7..0f98d3e44 100644 --- a/.gitignore +++ b/.gitignore @@ -154,3 +154,7 @@ rmm_log.txt # cibuildwheel /wheelhouse + +# clang tooling +compile_commands.json +.clangd/ diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 42378a2fe..8b7f07167 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -22,6 +22,9 @@ NEXT_MAJOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[1]}') NEXT_MINOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[2]}') NEXT_SHORT_TAG=${NEXT_MAJOR}.${NEXT_MINOR} +# Need to distutils-normalize the original version +NEXT_SHORT_TAG_PEP440=$(python -c "from setuptools.extern import packaging; print(packaging.version.Version('${NEXT_SHORT_TAG}'))") + echo "Preparing release $CURRENT_TAG => $NEXT_FULL_TAG" # Inplace sed replace; workaround for Linux and Mac @@ -55,3 +58,9 @@ for FILE in .github/workflows/*.yaml; do sed_runner "/shared-action-workflows/ s/@.*/@branch-${NEXT_SHORT_TAG}/g" "${FILE}" done sed_runner "s/RAPIDS_VERSION_NUMBER=\".*/RAPIDS_VERSION_NUMBER=\"${NEXT_SHORT_TAG}\"/g" ci/build_docs.sh + +# .devcontainer files +find .devcontainer/ -type f -name devcontainer.json -print0 | while IFS= read -r -d '' filename; do + sed_runner "s@rapidsai/devcontainers:[0-9.]*@rapidsai/devcontainers:${NEXT_SHORT_TAG}@g" "${filename}" + sed_runner "s@rapidsai/devcontainers/features/rapids-build-utils:[0-9.]*@rapidsai/devcontainers/features/rapids-build-utils:${NEXT_SHORT_TAG_PEP440}@" "${filename}" +done diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 5c5ecb453..8571a1928 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -4,13 +4,18 @@ channels: - rapidsai - conda-forge dependencies: +- c-compiler +- clang-tools==16.0.6 +- clang==16.0.6 - cmake>=3.26.4 - cuda-python>=11.7.1,<12.0a0 - cuda-version=11.8 - cudatoolkit +- cxx-compiler - cython>=3.0.0 - doxygen=1.9.1 - fmt>=9.1.0,<10 +- gcc_linux-64=11.* - gcovr>=5.0 - graphviz - identify>=2.5.20 @@ -32,5 +37,6 @@ dependencies: - sphinx-copybutton - sphinx-markdown-tables - sphinx_rtd_theme +- sysroot_linux-64==2.17 - tomli name: all_cuda-118_arch-x86_64 diff --git a/conda/environments/all_cuda-120_arch-x86_64.yaml b/conda/environments/all_cuda-120_arch-x86_64.yaml index e01de1ca2..aec31b3db 100644 --- a/conda/environments/all_cuda-120_arch-x86_64.yaml +++ b/conda/environments/all_cuda-120_arch-x86_64.yaml @@ -4,13 +4,18 @@ channels: - rapidsai - conda-forge dependencies: +- c-compiler +- clang-tools==16.0.6 +- clang==16.0.6 - cmake>=3.26.4 - cuda-nvcc - cuda-python>=12.0,<13.0a0 - cuda-version=12.0 +- cxx-compiler - cython>=3.0.0 - doxygen=1.9.1 - fmt>=9.1.0,<10 +- gcc_linux-64=11.* - gcovr>=5.0 - graphviz - identify>=2.5.20 @@ -31,5 +36,6 @@ dependencies: - sphinx-copybutton - sphinx-markdown-tables - sphinx_rtd_theme +- sysroot_linux-64==2.17 - tomli name: all_cuda-120_arch-x86_64 diff --git a/dependencies.yaml b/dependencies.yaml index 765a812cb..7d9af48cf 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -69,6 +69,8 @@ dependencies: - tomli - output_types: conda packages: + - c-compiler + - cxx-compiler - fmt>=9.1.0,<10 - spdlog>=1.11.0,<1.12 - python>=3.9,<3.11 @@ -77,6 +79,18 @@ dependencies: - wheel - setuptools>=61.0.0 specific: + - output_types: conda + matrices: + - matrix: + arch: x86_64 + packages: + - gcc_linux-64=11.* + - sysroot_linux-64==2.17 + - matrix: + arch: aarch64 + packages: + - gcc_linux-aarch64=11.* + - sysroot_linux-aarch64==2.17 - output_types: conda matrices: - matrix: @@ -152,9 +166,13 @@ dependencies: - output_types: [conda, requirements] packages: - gcovr>=5.0 + - output_types: conda + packages: + - clang==16.0.6 + - clang-tools==16.0.6 docs: common: - - output_types: [conda] + - output_types: conda packages: - *doxygen - graphviz diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 24e9d240d..36c3aa043 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2018-2021, NVIDIA CORPORATION. +# Copyright (c) 2018-2023, 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 @@ -31,7 +31,11 @@ function(ConfigureTestInternal TEST_NAME) PROPERTIES POSITION_INDEPENDENT_CODE ON RUNTIME_OUTPUT_DIRECTORY "$" CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}" - INSTALL_RPATH "\$ORIGIN/../../../lib") + INSTALL_RPATH "\$ORIGIN/../../../lib" + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CUDA_STANDARD 17 + CUDA_STANDARD_REQUIRED ON) target_compile_definitions(${TEST_NAME} PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") target_compile_options(${TEST_NAME} PUBLIC $<$:-Wall -Werror From 9f105431bc1476d013d6fc6f32f97a30ab39a50f Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Wed, 27 Sep 2023 08:36:09 +1000 Subject: [PATCH 303/675] Enable RMM Debug Logging via Python (#1339) Enables RMM debug logging in Python and exposes controls for the level of logging. Fixes #1336. Authors: - Mark Harris (https://github.com/harrism) - Lawrence Mitchell (https://github.com/wence-) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1339 --- README.md | 9 +- python/CMakeLists.txt | 2 + python/rmm/__init__.py | 18 ++- python/rmm/_lib/CMakeLists.txt | 2 +- python/rmm/_lib/logger.pyx | 260 +++++++++++++++++++++++++++++++++ python/rmm/tests/test_rmm.py | 33 +++++ 6 files changed, 319 insertions(+), 5 deletions(-) create mode 100644 python/rmm/_lib/logger.pyx diff --git a/README.md b/README.md index 2fa4761df..4059c9ce0 100644 --- a/README.md +++ b/README.md @@ -581,9 +581,12 @@ of more detailed logging. The default is `INFO`. Available levels are `TRACE`, ` The log relies on the [spdlog](https://github.com/gabime/spdlog.git) library. -Note that to see logging below the `INFO` level, the C++ application must also call -`rmm::logger().set_level()`, e.g. to enable all levels of logging down to `TRACE`, call -`rmm::logger().set_level(spdlog::level::trace)` (and compile with `-DRMM_LOGGING_LEVEL=TRACE`). +Note that to see logging below the `INFO` level, the application must also set the logging level at +run time. C++ applications must must call `rmm::logger().set_level()`, for example to enable all +levels of logging down to `TRACE`, call `rmm::logger().set_level(spdlog::level::trace)` (and compile +librmm with `-DRMM_LOGGING_LEVEL=TRACE`). Python applications must call `rmm.set_logging_level()`, +for example to enable all levels of logging down to `TRACE`, call `rmm.set_logging_level("trace")` +(and compile the RMM Python module with `-DRMM_LOGGING_LEVEL=TRACE`). Note that debug logging is different from the CSV memory allocation logging provided by `rmm::mr::logging_resource_adapter`. The latter is for logging a history of allocation / diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 7920bdd3b..3506bf9a9 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -56,5 +56,7 @@ endif() include(rapids-cython) rapids_cython_init() +add_compile_definitions("SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") + add_subdirectory(rmm/_cuda) add_subdirectory(rmm/_lib) diff --git a/python/rmm/__init__.py b/python/rmm/__init__.py index 38e4c4258..52d232dc2 100644 --- a/python/rmm/__init__.py +++ b/python/rmm/__init__.py @@ -14,6 +14,15 @@ from rmm import mr from rmm._lib.device_buffer import DeviceBuffer +from rmm._lib.logger import ( + flush_logger, + get_flush_level, + get_logging_level, + logging_level, + set_flush_level, + set_logging_level, + should_log, +) from rmm.mr import disable_logging, enable_logging, get_log_filenames from rmm.rmm import ( RMMError, @@ -25,14 +34,21 @@ __all__ = [ "DeviceBuffer", - "RMMError", "disable_logging", + "RMMError", "enable_logging", + "flush_logger", + "get_flush_level", "get_log_filenames", + "get_logging_level", "is_initialized", + "logging_level", "mr", "register_reinitialize_hook", "reinitialize", + "set_flush_level", + "set_logging_level", + "should_log", "unregister_reinitialize_hook", ] diff --git a/python/rmm/_lib/CMakeLists.txt b/python/rmm/_lib/CMakeLists.txt index 61caa0e7e..852dd87c4 100644 --- a/python/rmm/_lib/CMakeLists.txt +++ b/python/rmm/_lib/CMakeLists.txt @@ -12,7 +12,7 @@ # the License. # ============================================================================= -set(cython_sources device_buffer.pyx lib.pyx memory_resource.pyx cuda_stream.pyx +set(cython_sources device_buffer.pyx lib.pyx logger.pyx memory_resource.pyx cuda_stream.pyx torch_allocator.pyx) set(linked_libraries rmm::rmm) diff --git a/python/rmm/_lib/logger.pyx b/python/rmm/_lib/logger.pyx new file mode 100644 index 000000000..029bbdd79 --- /dev/null +++ b/python/rmm/_lib/logger.pyx @@ -0,0 +1,260 @@ +# Copyright (c) 2023, 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. + +import warnings + +from libcpp cimport bool + + +cdef extern from "spdlog/common.h" namespace "spdlog::level" nogil: + cpdef enum logging_level "spdlog::level::level_enum": + """ + The debug logging level for RMM. + + Debug logging prints messages to a log file. See + `Debug Logging `_ + for more information. + + Valid levels, in decreasing order of verbosity, are TRACE, DEBUG, + INFO, WARN, ERR, CRITICAL, and OFF. Default is INFO. + + Examples + -------- + >>> import rmm + >>> rmm.logging_level.DEBUG + + >>> rmm.logging_level.DEBUG.value + 1 + >>> rmm.logging_level.DEBUG.name + 'DEBUG' + + See Also + -------- + set_logging_level : Set the debug logging level + get_logging_level : Get the current debug logging level + """ + TRACE "spdlog::level::trace" + DEBUG "spdlog::level::debug" + INFO "spdlog::level::info" + WARN "spdlog::level::warn" + ERR "spdlog::level::err" + CRITICAL "spdlog::level::critical" + OFF "spdlog::level::off" + + +cdef extern from "spdlog/spdlog.h" namespace "spdlog" nogil: + cdef cppclass spdlog_logger "spdlog::logger": + spdlog_logger() except + + void set_level(logging_level level) + logging_level level() + void flush() except + + void flush_on(logging_level level) + logging_level flush_level() + bool should_log(logging_level msg_level) + + +cdef extern from "rmm/logger.hpp" namespace "rmm" nogil: + cdef spdlog_logger& logger() except + + + +def _validate_level_type(level): + if not isinstance(level, logging_level): + raise TypeError("level must be an instance of the logging_level enum") + + +def should_log(level): + """ + Check if a message at the given level would be logged. + + A message at the given level would be logged if the current debug logging + level is set to a level that is at least as verbose than the given level, + *and* the RMM module is compiled for a logging level at least as verbose. + If these conditions are not both met, this function will return false. + + Debug logging prints messages to a log file. See + `Debug Logging `_ + for more information. + + Parameters + ---------- + level : logging_level + The debug logging level. Valid values are instances of the + ``logging_level`` enum. + + Returns + ------- + should_log : bool + True if a message at the given level would be logged, False otherwise. + + Raises + ------ + TypeError + If the logging level is not an instance of the ``logging_level`` enum. + """ + _validate_level_type(level) + return logger().should_log(level) + + +def set_logging_level(level): + """ + Set the debug logging level. + + Debug logging prints messages to a log file. See + `Debug Logging `_ + for more information. + + Parameters + ---------- + level : logging_level + The debug logging level. Valid values are instances of the + ``logging_level`` enum. + + Raises + ------ + TypeError + If the logging level is not an instance of the ``logging_level`` enum. + + See Also + -------- + get_logging_level : Get the current debug logging level. + + Examples + -------- + >>> import rmm + >>> rmm.set_logging_level(rmm.logging_level.WARN) # set logging level to warn + """ + _validate_level_type(level) + logger().set_level(level) + + if not should_log(level): + warnings.warn(f"RMM will not log logging_level.{level.name}. This " + "may be because the C++ library is compiled for a " + "less-verbose logging level.") + + +def get_logging_level(): + """ + Get the current debug logging level. + + Debug logging prints messages to a log file. See + `Debug Logging `_ + for more information. + + Returns + ------- + level : logging_level + The current debug logging level, an instance of the ``logging_level`` + enum. + + See Also + -------- + set_logging_level : Set the debug logging level. + + Examples + -------- + >>> import rmm + >>> rmm.get_logging_level() # get current logging level + + """ + return logging_level(logger().level()) + + +def flush_logger(): + """ + Flush the debug logger. This will cause any buffered log messages to + be written to the log file. + + Debug logging prints messages to a log file. See + `Debug Logging `_ + for more information. + + See Also + -------- + set_flush_level : Set the flush level for the debug logger. + get_flush_level : Get the current debug logging flush level. + + Examples + -------- + >>> import rmm + >>> rmm.flush_logger() # flush the logger + """ + logger().flush() + + +def set_flush_level(level): + """ + Set the flush level for the debug logger. Messages of this level or higher + will automatically flush to the file. + + Debug logging prints messages to a log file. See + `Debug Logging `_ + for more information. + + Parameters + ---------- + level : logging_level + The debug logging level. Valid values are instances of the + ``logging_level`` enum. + + Raises + ------ + TypeError + If the logging level is not an instance of the ``logging_level`` enum. + + See Also + -------- + get_flush_level : Get the current debug logging flush level. + flush_logger : Flush the logger. + + Examples + -------- + >>> import rmm + >>> rmm.flush_on(rmm.logging_level.WARN) # set flush level to warn + """ + _validate_level_type(level) + logger().flush_on(level) + + if not should_log(level): + warnings.warn(f"RMM will not log logging_level.{level.name}. This " + "may be because the C++ library is compiled for a " + "less-verbose logging level.") + + +def get_flush_level(): + """ + Get the current debug logging flush level for the RMM logger. Messages of + this level or higher will automatically flush to the file. + + Debug logging prints messages to a log file. See + `Debug Logging `_ + for more information. + + Returns + ------- + logging_level + The current flush level, an instance of the ``logging_level`` + enum. + + See Also + -------- + set_flush_level : Set the flush level for the logger. + flush_logger : Flush the logger. + + Examples + -------- + >>> import rmm + >>> rmm.flush_level() # get current flush level + + """ + return logging_level(logger().flush_level()) diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index deaab7f92..fd537749b 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -16,6 +16,7 @@ import gc import os import pickle +import warnings from itertools import product import numpy as np @@ -942,3 +943,35 @@ def test_rmm_device_buffer_copy(cuda_ary, make_copy): result = db_copy.copy_to_host() np.testing.assert_equal(expected, result) + + +@pytest.mark.parametrize("level", rmm.logging_level) +def test_valid_logging_level(level): + with warnings.catch_warnings(): + warnings.filterwarnings( + "ignore", message="RMM will not log logging_level.TRACE." + ) + warnings.filterwarnings( + "ignore", message="RMM will not log logging_level.DEBUG." + ) + rmm.set_logging_level(level) + assert rmm.get_logging_level() == level + rmm.set_logging_level(rmm.logging_level.INFO) # reset to default + + rmm.set_flush_level(level) + assert rmm.get_flush_level() == level + rmm.set_flush_level(rmm.logging_level.INFO) # reset to default + + rmm.should_log(level) + + +@pytest.mark.parametrize( + "level", ["INFO", 3, "invalid", 100, None, 1.2345, [1, 2, 3]] +) +def test_invalid_logging_level(level): + with pytest.raises(TypeError): + rmm.set_logging_level(level) + with pytest.raises(TypeError): + rmm.set_flush_level(level) + with pytest.raises(TypeError): + rmm.should_log(level) From da3ed7b9f987d729cb4f4003acc242ce3e830ca6 Mon Sep 17 00:00:00 2001 From: Ray Douglass <3107146+raydouglass@users.noreply.github.com> Date: Mon, 2 Oct 2023 15:25:09 -0400 Subject: [PATCH 304/675] Update devcontainers to 23.12 (#1355) Since https://github.com/rapidsai/rmm/pull/1328 was merged after `branch-23.12` was created, the files need to be updated manually in `branch-23.12`. Authors: - Ray Douglass (https://github.com/raydouglass) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1355 --- .devcontainer/cuda11.8-conda/devcontainer.json | 4 ++-- .devcontainer/cuda11.8-pip/devcontainer.json | 4 ++-- .devcontainer/cuda12.0-conda/devcontainer.json | 4 ++-- .devcontainer/cuda12.0-pip/devcontainer.json | 4 ++-- .github/workflows/pr.yaml | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.devcontainer/cuda11.8-conda/devcontainer.json b/.devcontainer/cuda11.8-conda/devcontainer.json index ba3555a26..f8546a341 100644 --- a/.devcontainer/cuda11.8-conda/devcontainer.json +++ b/.devcontainer/cuda11.8-conda/devcontainer.json @@ -5,12 +5,12 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:23.10-cpp-llvm16-cuda11.8-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:23.12-cpp-cuda11.8-mambaforge-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.10": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.12": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda11.8-pip/devcontainer.json b/.devcontainer/cuda11.8-pip/devcontainer.json index a5b4290e9..b1e33502f 100644 --- a/.devcontainer/cuda11.8-pip/devcontainer.json +++ b/.devcontainer/cuda11.8-pip/devcontainer.json @@ -5,12 +5,12 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:23.10-cpp-llvm16-cuda11.8-ubuntu22.04" + "BASE": "rapidsai/devcontainers:23.12-cpp-llvm16-cuda11.8-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.10": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.12": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.0-conda/devcontainer.json b/.devcontainer/cuda12.0-conda/devcontainer.json index 03282635e..4834422eb 100644 --- a/.devcontainer/cuda12.0-conda/devcontainer.json +++ b/.devcontainer/cuda12.0-conda/devcontainer.json @@ -5,12 +5,12 @@ "args": { "CUDA": "12.0", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:23.10-cpp-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:23.12-cpp-mambaforge-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.10": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.12": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.0-pip/devcontainer.json b/.devcontainer/cuda12.0-pip/devcontainer.json index 8dc607f28..f40db9312 100644 --- a/.devcontainer/cuda12.0-pip/devcontainer.json +++ b/.devcontainer/cuda12.0-pip/devcontainer.json @@ -5,12 +5,12 @@ "args": { "CUDA": "12.0", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:23.10-cpp-llvm16-cuda12.0-ubuntu22.04" + "BASE": "rapidsai/devcontainers:23.12-cpp-llvm16-cuda12.0-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.10": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.12": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index e29490e0e..dcb611a5f 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -78,7 +78,7 @@ jobs: script: ci/test_wheel.sh devcontainer: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/build-in-devcontainer.yaml@branch-23.10 + uses: rapidsai/shared-action-workflows/.github/workflows/build-in-devcontainer.yaml@cuda-120-arm with: build_command: | sccache -z; From 897313d1505099c1e8b555aab277a20cf6794b19 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 10 Oct 2023 16:49:27 -0400 Subject: [PATCH 305/675] Update rapids-cmake functions to non-deprecated signatures (#1357) Update to use non deprecated signatures for `rapids_export` functions Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1357 --- cmake/thirdparty/get_spdlog.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/thirdparty/get_spdlog.cmake b/cmake/thirdparty/get_spdlog.cmake index 24bbea89d..296370469 100644 --- a/cmake/thirdparty/get_spdlog.cmake +++ b/cmake/thirdparty/get_spdlog.cmake @@ -26,7 +26,8 @@ function(find_and_configure_spdlog) GLOBAL_TARGETS spdlog spdlog_header_only NAMESPACE spdlog::) include("${rapids-cmake-dir}/export/find_package_root.cmake") - rapids_export_find_package_root(BUILD spdlog [=[${CMAKE_CURRENT_LIST_DIR}]=] rmm-exports) + rapids_export_find_package_root(BUILD spdlog [=[${CMAKE_CURRENT_LIST_DIR}]=] + EXPORT_SET rmm-exports) endif() endfunction() From 613bc6a176daf826978d961bf31ec890d9fa7312 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Wed, 11 Oct 2023 10:27:56 -0400 Subject: [PATCH 306/675] Update Changelog [skip ci] --- CHANGELOG.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 453ab54c2..901b3790a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,42 @@ +# RMM 23.10.00 (11 Oct 2023) + +## 🚨 Breaking Changes + +- Update to Cython 3.0.0 ([#1313](https://github.com/rapidsai/rmm/pull/1313)) [@vyasr](https://github.com/vyasr) + +## 🐛 Bug Fixes + +- Compile cdef public functions from torch_allocator with C ABI ([#1350](https://github.com/rapidsai/rmm/pull/1350)) [@wence-](https://github.com/wence-) +- Make doxygen only a conda dependency. ([#1344](https://github.com/rapidsai/rmm/pull/1344)) [@bdice](https://github.com/bdice) +- Use `conda mambabuild` not `mamba mambabuild` ([#1338](https://github.com/rapidsai/rmm/pull/1338)) [@wence-](https://github.com/wence-) +- Fix stream_ordered_memory_resource attempt to record event in stream from another device ([#1333](https://github.com/rapidsai/rmm/pull/1333)) [@harrism](https://github.com/harrism) + +## 📖 Documentation + +- Clean up headers in CMakeLists.txt. ([#1341](https://github.com/rapidsai/rmm/pull/1341)) [@bdice](https://github.com/bdice) +- Add pre-commit hook to validate doxygen ([#1334](https://github.com/rapidsai/rmm/pull/1334)) [@vyasr](https://github.com/vyasr) +- Fix doxygen warnings ([#1317](https://github.com/rapidsai/rmm/pull/1317)) [@vyasr](https://github.com/vyasr) +- Treat warnings as errors in Python documentation ([#1316](https://github.com/rapidsai/rmm/pull/1316)) [@vyasr](https://github.com/vyasr) + +## 🚀 New Features + +- Enable RMM Debug Logging via Python ([#1339](https://github.com/rapidsai/rmm/pull/1339)) [@harrism](https://github.com/harrism) + +## 🛠️ Improvements + +- Update image names ([#1346](https://github.com/rapidsai/rmm/pull/1346)) [@AyodeAwe](https://github.com/AyodeAwe) +- Update to clang 16.0.6. ([#1343](https://github.com/rapidsai/rmm/pull/1343)) [@bdice](https://github.com/bdice) +- Update doxygen to 1.9.1 ([#1337](https://github.com/rapidsai/rmm/pull/1337)) [@vyasr](https://github.com/vyasr) +- Simplify wheel build scripts and allow alphas of RAPIDS dependencies ([#1335](https://github.com/rapidsai/rmm/pull/1335)) [@divyegala](https://github.com/divyegala) +- Use `copy-pr-bot` ([#1329](https://github.com/rapidsai/rmm/pull/1329)) [@ajschmidt8](https://github.com/ajschmidt8) +- Add RMM devcontainers ([#1328](https://github.com/rapidsai/rmm/pull/1328)) [@trxcllnt](https://github.com/trxcllnt) +- Add Python bindings for `limiting_resource_adaptor` ([#1327](https://github.com/rapidsai/rmm/pull/1327)) [@pentschev](https://github.com/pentschev) +- Fix missing jQuery error in docs ([#1321](https://github.com/rapidsai/rmm/pull/1321)) [@AyodeAwe](https://github.com/AyodeAwe) +- Use fetch_rapids.cmake. ([#1319](https://github.com/rapidsai/rmm/pull/1319)) [@bdice](https://github.com/bdice) +- Update to Cython 3.0.0 ([#1313](https://github.com/rapidsai/rmm/pull/1313)) [@vyasr](https://github.com/vyasr) +- Branch 23.10 merge 23.08 ([#1312](https://github.com/rapidsai/rmm/pull/1312)) [@vyasr](https://github.com/vyasr) +- Branch 23.10 merge 23.08 ([#1309](https://github.com/rapidsai/rmm/pull/1309)) [@vyasr](https://github.com/vyasr) + # RMM 23.08.00 (9 Aug 2023) ## 🚨 Breaking Changes From f6ab7b7f5277292c908ff60679a28acddffcdd4f Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 11 Oct 2023 16:27:18 -0500 Subject: [PATCH 307/675] Use branch-23.12 workflows. (#1360) This PR switches back to using `branch-23.12` for CI workflows because the CUDA 12 ARM conda migration is complete. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1360 --- .github/workflows/build.yaml | 12 ++++++------ .github/workflows/pr.yaml | 20 ++++++++++---------- .github/workflows/test.yaml | 6 +++--- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f0a60b269..12f35468d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-build.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-build.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -78,7 +78,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-publish.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-publish.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index dcb611a5f..79ca766d0 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -22,40 +22,40 @@ jobs: - wheel-tests - devcontainer secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.12 checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.12 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.12 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.12 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.12 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.12 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.12 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -65,20 +65,20 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-build.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-build.yaml@branch-23.12 with: build_type: pull-request script: ci/build_wheel.sh wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yaml@branch-23.12 with: build_type: pull-request script: ci/test_wheel.sh devcontainer: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/build-in-devcontainer.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/build-in-devcontainer.yaml@branch-23.12 with: build_command: | sccache -z; diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5b872f53e..31e476650 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.12 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.12 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yaml@cuda-120-arm + uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yaml@branch-23.12 with: build_type: nightly branch: ${{ inputs.branch }} From 48f2382d0bf48144e75bf84e8cb1b3810eca7901 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 12 Oct 2023 16:47:54 -0700 Subject: [PATCH 308/675] Add groups to the doxygen docs (#1358) This PR adds doxygen groups for the various parts of the C++ API to help provide more context. This will also help with improving the docs experience in #1324. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1358 --- doxygen/Doxyfile | 5 ++- doxygen/main_page.md | 13 ++++++ include/doxygen_groups.h | 43 +++++++++++++++++++ include/rmm/cuda_device.hpp | 6 +++ include/rmm/cuda_stream.hpp | 6 +++ include/rmm/cuda_stream_pool.hpp | 6 +++ include/rmm/cuda_stream_view.hpp | 6 +++ include/rmm/device_buffer.hpp | 7 +++ include/rmm/device_scalar.hpp | 7 +++ include/rmm/device_uvector.hpp | 7 +++ include/rmm/device_vector.hpp | 6 +++ include/rmm/exec_policy.hpp | 6 +++ include/rmm/logger.hpp | 12 ++++++ .../mr/device/aligned_resource_adaptor.hpp | 6 +++ .../rmm/mr/device/arena_memory_resource.hpp | 6 +++ .../rmm/mr/device/binning_memory_resource.hpp | 6 +++ .../mr/device/callback_memory_resource.hpp | 6 +++ .../mr/device/cuda_async_memory_resource.hpp | 6 +++ .../cuda_async_view_memory_resource.hpp | 6 +++ .../rmm/mr/device/cuda_memory_resource.hpp | 6 +++ .../rmm/mr/device/device_memory_resource.hpp | 6 +++ .../failure_callback_resource_adaptor.hpp | 6 +++ .../mr/device/fixed_size_memory_resource.hpp | 6 +++ .../mr/device/limiting_resource_adaptor.hpp | 7 +++ .../mr/device/logging_resource_adaptor.hpp | 8 ++++ .../rmm/mr/device/managed_memory_resource.hpp | 6 +++ include/rmm/mr/device/owning_wrapper.hpp | 34 ++++++++++++++- .../rmm/mr/device/pool_memory_resource.hpp | 6 +++ .../mr/device/statistics_resource_adaptor.hpp | 7 +++ .../device/thread_safe_resource_adaptor.hpp | 6 +++ .../mr/device/thrust_allocator_adaptor.hpp | 6 +++ .../mr/device/tracking_resource_adaptor.hpp | 7 +++ include/rmm/mr/host/host_memory_resource.hpp | 6 +++ include/rmm/mr/host/new_delete_resource.hpp | 6 +++ .../rmm/mr/host/pinned_memory_resource.hpp | 6 +++ 35 files changed, 292 insertions(+), 3 deletions(-) create mode 100644 doxygen/main_page.md create mode 100644 include/doxygen_groups.h diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 28a789a9f..24d7e4834 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -859,7 +859,8 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = ../include +INPUT = main_page.md \ + ../include # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses @@ -1017,7 +1018,7 @@ FILTER_SOURCE_PATTERNS = # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. -USE_MDFILE_AS_MAINPAGE = +USE_MDFILE_AS_MAINPAGE = main_page.md #--------------------------------------------------------------------------- # Configuration options related to source browsing diff --git a/doxygen/main_page.md b/doxygen/main_page.md new file mode 100644 index 000000000..535206ec4 --- /dev/null +++ b/doxygen/main_page.md @@ -0,0 +1,13 @@ +# librmm + +Achieving optimal performance in GPU-centric workflows frequently requires customizing how host and +device memory are allocated. For example, using "pinned" host memory for asynchronous +host <-> device memory transfers, or using a device memory pool sub-allocator to reduce the cost of +dynamic device memory allocation. + +The goal of the RAPIDS Memory Manager (RMM) is to provide: +- A common interface that allows customizing device and host memory allocation +- A collection of implementations of the interface +- A collection of data structures that use the interface for memory allocation + +\htmlonly For more information on APIs provided by rmm, see the modules page\endhtmlonly. diff --git a/include/doxygen_groups.h b/include/doxygen_groups.h new file mode 100644 index 000000000..e0f166237 --- /dev/null +++ b/include/doxygen_groups.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023, 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. + */ + +/** + * @file + * @brief Doxygen group definitions + */ + +// This header is only processed by doxygen and does +// not need to be included in any source file. +// Below are the main groups that doxygen uses to build +// the Modules page in the specified order. +// +// To add a new API to an existing group, just use the +// @ingroup tag to the API's doxygen comment. +// Add a new group by first specifying in the hierarchy below. + +/** + * @defgroup memory_resources Memory Resources + * @{ + * @defgroup device_memory_resources Device Memory Resources + * @defgroup host_memory_resources Host Memory Resources + * @defgroup device_resource_adaptors Device Resource Adaptors + * @} + * @defgroup cuda_device_management CUDA Device Management + * @defgroup cuda_streams CUDA Streams + * @defgroup data_containers Data Containers + * @defgroup logging Logging + * @defgroup thrust_integrations Thrust Integrations + */ diff --git a/include/rmm/cuda_device.hpp b/include/rmm/cuda_device.hpp index 8d355ee23..e4a35ee16 100644 --- a/include/rmm/cuda_device.hpp +++ b/include/rmm/cuda_device.hpp @@ -21,6 +21,11 @@ namespace rmm { +/** + * @addtogroup cuda_device_management + * @{ + * @file + */ /** * @brief Strong type for a CUDA device identifier. * @@ -101,4 +106,5 @@ struct cuda_set_device_raii { bool needs_reset_; }; +/** @} */ // end of group } // namespace rmm diff --git a/include/rmm/cuda_stream.hpp b/include/rmm/cuda_stream.hpp index b778cf7bd..cb5654ac3 100644 --- a/include/rmm/cuda_stream.hpp +++ b/include/rmm/cuda_stream.hpp @@ -26,6 +26,11 @@ #include namespace rmm { +/** + * @addtogroup cuda_streams + * @{ + * @file + */ /** * @brief Owning wrapper for a CUDA stream. @@ -133,4 +138,5 @@ class cuda_stream { std::unique_ptr> stream_; }; +/** @} */ // end of group } // namespace rmm diff --git a/include/rmm/cuda_stream_pool.hpp b/include/rmm/cuda_stream_pool.hpp index 71c426817..9eb341057 100644 --- a/include/rmm/cuda_stream_pool.hpp +++ b/include/rmm/cuda_stream_pool.hpp @@ -25,6 +25,11 @@ #include namespace rmm { +/** + * @addtogroup cuda_streams + * @{ + * @file + */ /** * @brief A pool of CUDA streams. @@ -96,4 +101,5 @@ class cuda_stream_pool { mutable std::atomic_size_t next_stream{}; }; +/** @} */ // end of group } // namespace rmm diff --git a/include/rmm/cuda_stream_view.hpp b/include/rmm/cuda_stream_view.hpp index b6e3cc022..fe07fa1b9 100644 --- a/include/rmm/cuda_stream_view.hpp +++ b/include/rmm/cuda_stream_view.hpp @@ -25,6 +25,11 @@ #include namespace rmm { +/** + * @addtogroup cuda_streams + * @{ + * @file + */ /** * @brief Strongly-typed non-owning wrapper for CUDA streams with default constructor. @@ -175,4 +180,5 @@ inline std::ostream& operator<<(std::ostream& os, cuda_stream_view stream) return os; } +/** @} */ // end of group } // namespace rmm diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index 84638ee89..a49f9caa9 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -28,6 +28,11 @@ #include namespace rmm { +/** + * @addtogroup data_containers + * @{ + * @file + */ /** * @brief RAII construct for device memory allocation * @@ -459,4 +464,6 @@ class device_buffer { } } }; + +/** @} */ // end of group } // namespace rmm diff --git a/include/rmm/device_scalar.hpp b/include/rmm/device_scalar.hpp index 83fcdda09..a70071145 100644 --- a/include/rmm/device_scalar.hpp +++ b/include/rmm/device_scalar.hpp @@ -24,6 +24,11 @@ #include namespace rmm { +/** + * @addtogroup data_containers + * @{ + * @file + */ /** * @brief Container for a single object of type `T` in device memory. @@ -266,4 +271,6 @@ class device_scalar { private: rmm::device_uvector _storage; }; + +/** @} */ // end of group } // namespace rmm diff --git a/include/rmm/device_uvector.hpp b/include/rmm/device_uvector.hpp index 47ed1adff..930cda157 100644 --- a/include/rmm/device_uvector.hpp +++ b/include/rmm/device_uvector.hpp @@ -27,6 +27,11 @@ #include namespace rmm { +/** + * @addtogroup data_containers + * @{ + * @file + */ /** * @brief An *uninitialized* vector of elements in device memory. @@ -557,4 +562,6 @@ class device_uvector { return num_bytes / sizeof(value_type); } }; + +/** @} */ // end of group } // namespace rmm diff --git a/include/rmm/device_vector.hpp b/include/rmm/device_vector.hpp index 95fbe3810..7caf5845b 100644 --- a/include/rmm/device_vector.hpp +++ b/include/rmm/device_vector.hpp @@ -22,6 +22,11 @@ #include namespace rmm { +/** + * @addtogroup thrust_integrations + * @{ + * @file + */ /** * @brief Alias for a thrust::device_vector that uses RMM for memory allocation. * @@ -29,4 +34,5 @@ namespace rmm { template using device_vector = thrust::device_vector>; +/** @} */ // end of group } // namespace rmm diff --git a/include/rmm/exec_policy.hpp b/include/rmm/exec_policy.hpp index 78c747652..eacdfa187 100644 --- a/include/rmm/exec_policy.hpp +++ b/include/rmm/exec_policy.hpp @@ -29,6 +29,11 @@ #include namespace rmm { +/** + * @addtogroup thrust_integrations + * @{ + * @file + */ /** * @brief Synchronous execution policy for allocations using thrust @@ -91,4 +96,5 @@ using exec_policy_nosync = exec_policy; ///< When used with Thrust < 1.16.0, exec_policy_nosync is an alias for exec_policy #endif +/** @} */ // end of group } // namespace rmm diff --git a/include/rmm/logger.hpp b/include/rmm/logger.hpp index 4e17878bd..8dc1342db 100644 --- a/include/rmm/logger.hpp +++ b/include/rmm/logger.hpp @@ -96,6 +96,12 @@ struct bytes { } // namespace detail +/** + * @addtogroup logging + * @{ + * @file + */ + /** * @brief Returns the global RMM logger * @@ -109,6 +115,8 @@ inline spdlog::logger& logger() return wrapped.logger_; } +//! @cond Doxygen_Suppress +// // The default is INFO, but it should be used sparingly, so that by default a log file is only // output if there is important information, warnings, errors, and critical failures // Log messages that require computation should only be used at level TRACE and DEBUG @@ -119,10 +127,14 @@ inline spdlog::logger& logger() #define RMM_LOG_ERROR(...) SPDLOG_LOGGER_ERROR(&rmm::logger(), __VA_ARGS__) #define RMM_LOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(&rmm::logger(), __VA_ARGS__) +//! @endcond + } // namespace rmm // Doxygen doesn't like this because we're overloading something from fmt //! @cond Doxygen_Suppress template <> struct fmt::formatter : fmt::ostream_formatter {}; + +/** @} */ // end of group //! @endcond diff --git a/include/rmm/mr/device/aligned_resource_adaptor.hpp b/include/rmm/mr/device/aligned_resource_adaptor.hpp index f79f0c15a..7151861f4 100644 --- a/include/rmm/mr/device/aligned_resource_adaptor.hpp +++ b/include/rmm/mr/device/aligned_resource_adaptor.hpp @@ -26,6 +26,11 @@ #include namespace rmm::mr { +/** + * @addtogroup device_resource_adaptors + * @{ + * @file + */ /** * @brief Resource that adapts `Upstream` memory resource to allocate memory in a specified * alignment size. @@ -214,4 +219,5 @@ class aligned_resource_adaptor final : public device_memory_resource { mutable std::mutex mtx_; ///< Mutex for exclusive lock. }; +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index 882cbf694..0dbd9c90e 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -31,6 +31,11 @@ #include namespace rmm::mr { +/** + * @addtogroup device_memory_resources + * @{ + * @file + */ /** * @brief A suballocator that emphasizes fragmentation avoidance and scalable concurrency support. @@ -343,4 +348,5 @@ class arena_memory_resource final : public device_memory_resource { mutable std::shared_mutex mtx_; }; +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/binning_memory_resource.hpp b/include/rmm/mr/device/binning_memory_resource.hpp index 54cccca28..c2e1621a6 100644 --- a/include/rmm/mr/device/binning_memory_resource.hpp +++ b/include/rmm/mr/device/binning_memory_resource.hpp @@ -28,6 +28,11 @@ #include namespace rmm::mr { +/** + * @addtogroup device_memory_resources + * @{ + * @file + */ /** * @brief Allocates memory from upstream resources associated with bin sizes. @@ -214,4 +219,5 @@ class binning_memory_resource final : public device_memory_resource { std::map resource_bins_; }; +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/callback_memory_resource.hpp b/include/rmm/mr/device/callback_memory_resource.hpp index 289ceb9d6..c6519ed5c 100644 --- a/include/rmm/mr/device/callback_memory_resource.hpp +++ b/include/rmm/mr/device/callback_memory_resource.hpp @@ -22,6 +22,11 @@ #include namespace rmm::mr { +/** + * @addtogroup device_memory_resources + * @{ + * @file + */ /** * @brief Callback function type used by callback memory resource for allocation. @@ -147,4 +152,5 @@ class callback_memory_resource final : public device_memory_resource { void* deallocate_callback_arg_; }; +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 9bbd9cc09..5cada7e6c 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -38,6 +38,11 @@ #endif namespace rmm::mr { +/** + * @addtogroup device_memory_resources + * @{ + * @file + */ /** * @brief `device_memory_resource` derived class that uses `cudaMallocAsync`/`cudaFreeAsync` for @@ -245,4 +250,5 @@ class cuda_async_memory_resource final : public device_memory_resource { } }; +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index 569f65df7..07b601c05 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -35,6 +35,11 @@ #endif namespace rmm::mr { +/** + * @addtogroup device_memory_resources + * @{ + * @file + */ /** * @brief `device_memory_resource` derived class that uses `cudaMallocAsync`/`cudaFreeAsync` for @@ -182,4 +187,5 @@ class cuda_async_view_memory_resource final : public device_memory_resource { } }; +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/cuda_memory_resource.hpp b/include/rmm/mr/device/cuda_memory_resource.hpp index 5164bc5c5..2e73ff0b1 100644 --- a/include/rmm/mr/device/cuda_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_memory_resource.hpp @@ -23,6 +23,11 @@ #include namespace rmm::mr { +/** + * @addtogroup device_memory_resources + * @{ + * @file + */ /** * @brief `device_memory_resource` derived class that uses cudaMalloc/Free for * allocation/deallocation. @@ -121,4 +126,5 @@ class cuda_memory_resource final : public device_memory_resource { return std::make_pair(free_size, total_size); } }; +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index 1813fb726..8ad84644b 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -22,6 +22,11 @@ #include namespace rmm::mr { +/** + * @addtogroup device_memory_resources + * @{ + * @file + */ /** * @brief Base class for all libcudf device memory allocation. @@ -238,4 +243,5 @@ class device_memory_resource { [[nodiscard]] virtual std::pair do_get_mem_info( cuda_stream_view stream) const = 0; }; +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp index 48f0513d8..0df12c23c 100644 --- a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp +++ b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp @@ -23,6 +23,11 @@ #include namespace rmm::mr { +/** + * @addtogroup device_resource_adaptors + * @{ + * @file + */ /** * @brief Callback function type used by failure_callback_resource_adaptor @@ -217,4 +222,5 @@ class failure_callback_resource_adaptor final : public device_memory_resource { void* callback_arg_; }; +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index a24ac6ddd..01fb8a6bc 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -36,6 +36,11 @@ #include namespace rmm::mr { +/** + * @addtogroup device_memory_resources + * @{ + * @file + */ /** * @brief A `device_memory_resource` which allocates memory blocks of a single fixed size. @@ -280,4 +285,5 @@ class fixed_size_memory_resource std::vector upstream_blocks_; }; +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index ebc67fed1..5da152ccf 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -22,6 +22,11 @@ #include namespace rmm::mr { +/** + * @addtogroup device_resource_adaptors + * @{ + * @file + */ /** * @brief Resource that uses `Upstream` to allocate memory and limits the total * allocations possible. @@ -211,6 +216,7 @@ class limiting_resource_adaptor final : public device_memory_resource { * @tparam Upstream Type of the upstream `device_memory_resource`. * @param upstream Pointer to the upstream resource * @param allocation_limit Maximum amount of memory to allocate + * @return The new limiting resource adaptor */ template limiting_resource_adaptor make_limiting_adaptor(Upstream* upstream, @@ -219,4 +225,5 @@ limiting_resource_adaptor make_limiting_adaptor(Upstream* upstream, return limiting_resource_adaptor{upstream, allocation_limit}; } +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index c59fdf61a..26a0b92c8 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -31,6 +31,11 @@ #include namespace rmm::mr { +/** + * @addtogroup device_resource_adaptors + * @{ + * @file + */ /** * @brief Resource that uses `Upstream` to allocate memory and logs information * about the requested allocation/deallocations. @@ -331,6 +336,7 @@ class logging_resource_adaptor final : public device_memory_resource { * retrieves the log file name from the environment variable "RMM_LOG_FILE". * @param auto_flush If true, flushes the log for every (de)allocation. Warning, this will degrade * performance. + * @return The new logging resource adaptor */ template logging_resource_adaptor make_logging_adaptor( @@ -350,6 +356,7 @@ logging_resource_adaptor make_logging_adaptor( * @param stream The ostream to write log info. * @param auto_flush If true, flushes the log for every (de)allocation. Warning, this will degrade * performance. + * @return The new logging resource adaptor */ template logging_resource_adaptor make_logging_adaptor(Upstream* upstream, @@ -359,4 +366,5 @@ logging_resource_adaptor make_logging_adaptor(Upstream* upstream, return logging_resource_adaptor{upstream, stream, auto_flush}; } +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/managed_memory_resource.hpp b/include/rmm/mr/device/managed_memory_resource.hpp index e987de15d..75e91fb24 100644 --- a/include/rmm/mr/device/managed_memory_resource.hpp +++ b/include/rmm/mr/device/managed_memory_resource.hpp @@ -23,6 +23,11 @@ #include namespace rmm::mr { +/** + * @addtogroup device_memory_resources + * @{ + * @file + */ /** * @brief `device_memory_resource` derived class that uses * cudaMallocManaged/Free for allocation/deallocation. @@ -128,4 +133,5 @@ class managed_memory_resource final : public device_memory_resource { } }; +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/owning_wrapper.hpp b/include/rmm/mr/device/owning_wrapper.hpp index eca0b3207..c94bfcf9d 100644 --- a/include/rmm/mr/device/owning_wrapper.hpp +++ b/include/rmm/mr/device/owning_wrapper.hpp @@ -24,7 +24,21 @@ namespace rmm::mr { namespace detail { -/// Converts a tuple into a parameter pack +/** + * @brief Converts a tuple into a parameter pack. + * + * This helper function for make_resource allows passing the upstreams as a + * list of arguments to the Resource's constructor. + * + * @tparam Resource The resource type to create + * @tparam UpstreamTuple A tuple of shared pointers of the types of the upstream resources + * @tparam Args The types of the arguments to the resource's constructor + * @param upstreams Tuple of `std::shared_ptr`s to the upstreams used by the wrapped resource, in + * the same order as expected by `Resource`s constructor. + * @param args Function parameter pack of arguments to forward to the Resource's + * constructor + * @return std::unique_ptr A unique pointer to the created resource. + */ template auto make_resource_impl(UpstreamTuple const& upstreams, std::index_sequence, @@ -34,6 +48,18 @@ auto make_resource_impl(UpstreamTuple const& upstreams, std::forward(args)...); } +/** + * @brief Create a `std::unique_ptr` to a `Resource` with the given upstreams and arguments + * + * @tparam Resource The resource type to create + * @tparam Upstreams The types of the upstream resources + * @tparam Args The types of the arguments to the resource's constructor + * @param upstreams Tuple of `std::shared_ptr`s to the upstreams used by the wrapped resource, in + * the same order as expected by `Resource`s constructor. + * @param args Function parameter pack of arguments to forward to the wrapped resource's + * constructor + * @return std::unique_ptr A unique pointer to the created resource + */ template auto make_resource(std::tuple...> const& upstreams, Args&&... args) { @@ -42,6 +68,11 @@ auto make_resource(std::tuple...> const& upstreams, A } } // namespace detail +/** + * @addtogroup device_resource_adaptors + * @{ + * @file + */ /** * @brief Resource adaptor that maintains the lifetime of upstream resources. * @@ -272,4 +303,5 @@ auto make_owning_wrapper(std::shared_ptr upstream, Args&&... args) std::forward(args)...); } +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 703ce8ea7..f6d3710e9 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -46,6 +46,11 @@ #include namespace rmm::mr { +/** + * @addtogroup device_memory_resources + * @{ + * @file + */ /** * @brief A coalescing best-fit suballocator which uses a pool of memory allocated from @@ -448,4 +453,5 @@ class pool_memory_resource final std::set> upstream_blocks_; }; // namespace mr +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/statistics_resource_adaptor.hpp b/include/rmm/mr/device/statistics_resource_adaptor.hpp index 7af75593d..c74eaf4e6 100644 --- a/include/rmm/mr/device/statistics_resource_adaptor.hpp +++ b/include/rmm/mr/device/statistics_resource_adaptor.hpp @@ -22,6 +22,11 @@ #include namespace rmm::mr { +/** + * @addtogroup device_resource_adaptors + * @{ + * @file + */ /** * @brief Resource that uses `Upstream` to allocate memory and tracks statistics * on memory allocations. @@ -246,6 +251,7 @@ class statistics_resource_adaptor final : public device_memory_resource { * * @tparam Upstream Type of the upstream `device_memory_resource`. * @param upstream Pointer to the upstream resource + * @return The new statistics resource adaptor */ template statistics_resource_adaptor make_statistics_adaptor(Upstream* upstream) @@ -253,4 +259,5 @@ statistics_resource_adaptor make_statistics_adaptor(Upstream* upstream return statistics_resource_adaptor{upstream}; } +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp index 0b8570985..c228427af 100644 --- a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp +++ b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp @@ -23,6 +23,11 @@ #include namespace rmm::mr { +/** + * @addtogroup device_resource_adaptors + * @{ + * @file + */ /** * @brief Resource that adapts `Upstream` memory resource adaptor to be thread safe. * @@ -151,4 +156,5 @@ class thread_safe_resource_adaptor final : public device_memory_resource { Upstream* upstream_; ///< The upstream resource used for satisfying allocation requests }; +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/thrust_allocator_adaptor.hpp b/include/rmm/mr/device/thrust_allocator_adaptor.hpp index de2f25043..a1386a842 100644 --- a/include/rmm/mr/device/thrust_allocator_adaptor.hpp +++ b/include/rmm/mr/device/thrust_allocator_adaptor.hpp @@ -25,6 +25,11 @@ #include namespace rmm::mr { +/** + * @addtogroup device_resource_adaptors + * @{ + * @file + */ /** * @brief An `allocator` compatible with Thrust containers and algorithms using * a `device_memory_resource` for memory (de)allocation. @@ -126,4 +131,5 @@ class thrust_allocator : public thrust::device_malloc_allocator { cuda_stream_view _stream{}; device_memory_resource* _mr{rmm::mr::get_current_device_resource()}; }; +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index b87218d12..eccf878d8 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -29,6 +29,11 @@ #include namespace rmm::mr { +/** + * @addtogroup device_resource_adaptors + * @{ + * @file + */ /** * @brief Resource that uses `Upstream` to allocate memory and tracks allocations. * @@ -302,6 +307,7 @@ class tracking_resource_adaptor final : public device_memory_resource { * * @tparam Upstream Type of the upstream `device_memory_resource`. * @param upstream Pointer to the upstream resource + * @return The new tracking resource adaptor */ template tracking_resource_adaptor make_tracking_adaptor(Upstream* upstream) @@ -309,4 +315,5 @@ tracking_resource_adaptor make_tracking_adaptor(Upstream* upstream) return tracking_resource_adaptor{upstream}; } +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/host/host_memory_resource.hpp b/include/rmm/mr/host/host_memory_resource.hpp index 3279bfb3f..8a5739b2a 100644 --- a/include/rmm/mr/host/host_memory_resource.hpp +++ b/include/rmm/mr/host/host_memory_resource.hpp @@ -19,6 +19,11 @@ #include namespace rmm::mr { +/** + * @addtogroup host_memory_resources + * @{ + * @file + */ /** * @brief Base class for host memory allocation. @@ -161,4 +166,5 @@ class host_memory_resource { return this == &other; } }; +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/host/new_delete_resource.hpp b/include/rmm/mr/host/new_delete_resource.hpp index 68cccc320..d41443c62 100644 --- a/include/rmm/mr/host/new_delete_resource.hpp +++ b/include/rmm/mr/host/new_delete_resource.hpp @@ -23,6 +23,11 @@ #include namespace rmm::mr { +/** + * @addtogroup host_memory_resources + * @{ + * @file + */ /** * @brief A `host_memory_resource` that uses the global `operator new` and `operator delete` to @@ -88,4 +93,5 @@ class new_delete_resource final : public host_memory_resource { } }; +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/host/pinned_memory_resource.hpp b/include/rmm/mr/host/pinned_memory_resource.hpp index fb28ebfb7..514cc1664 100644 --- a/include/rmm/mr/host/pinned_memory_resource.hpp +++ b/include/rmm/mr/host/pinned_memory_resource.hpp @@ -23,6 +23,11 @@ #include namespace rmm::mr { +/** + * @addtogroup host_memory_resources + * @{ + * @file + */ /** * @brief A `host_memory_resource` that uses `cudaMallocHost` to allocate @@ -96,4 +101,5 @@ class pinned_memory_resource final : public host_memory_resource { ptr, bytes, alignment, [](void* ptr) { RMM_ASSERT_CUDA_SUCCESS(cudaFreeHost(ptr)); }); } }; +/** @} */ // end of group } // namespace rmm::mr From 596ccf919bc373e01ab1215e18b28192ef06f8b0 Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Wed, 18 Oct 2023 08:36:44 -0500 Subject: [PATCH 309/675] update workflow links (#1363) --- .github/workflows/build.yaml | 12 ++++++------ .github/workflows/pr.yaml | 20 ++++++++++---------- .github/workflows/test.yaml | 6 +++--- ci/release/update-version.sh | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 12f35468d..be052881c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-build.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -78,7 +78,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-publish.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-23.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 79ca766d0..aecbb9d9e 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -22,40 +22,40 @@ jobs: - wheel-tests - devcontainer secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/pr-builder.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-23.12 checks: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/checks.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-23.12 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.12 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.12 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-build.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-23.12 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-23.12 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/custom-job.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-23.12 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -65,20 +65,20 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-build.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-23.12 with: build_type: pull-request script: ci/build_wheel.sh wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-23.12 with: build_type: pull-request script: ci/test_wheel.sh devcontainer: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/build-in-devcontainer.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-23.12 with: build_command: | sccache -z; diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 31e476650..993852c94 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.12 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/conda-python-tests.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-23.12 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-action-workflows/.github/workflows/wheels-test.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-23.12 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 8b7f07167..6250a4810 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -55,7 +55,7 @@ sed_runner 's/'"release =.*"'/'"release = \"${NEXT_FULL_TAG}\""'/g' python/docs/ # CI files for FILE in .github/workflows/*.yaml; do - sed_runner "/shared-action-workflows/ s/@.*/@branch-${NEXT_SHORT_TAG}/g" "${FILE}" + sed_runner "/shared-workflows/ s/@.*/@branch-${NEXT_SHORT_TAG}/g" "${FILE}" done sed_runner "s/RAPIDS_VERSION_NUMBER=\".*/RAPIDS_VERSION_NUMBER=\"${NEXT_SHORT_TAG}\"/g" ci/build_docs.sh From 39800d3d4aeff80de36d7872ed551243518e25a8 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 24 Oct 2023 15:15:37 -0700 Subject: [PATCH 310/675] Add missing CUDA 12 dependencies and fix dlopen library names (#1366) The dropping of system CTK libraries from our CUDA 12 CI images revealed that we were missing the cuda-nvcc package required to provide nvvm for numba in the Python tests. They also revealed that the list of libraries we searched to dlopen is incomplete; for CUDA 11, the SONAME of the library incorrectly includes an extra `.0` version segment, and rmm was designed to search for that, but CUDA 12 correctly has just `libcudart.so.12` and that needs to be added to the search path. We were previously getting by on finding `libcudart.so`, but the linker name is only present in conda environments if `cuda-cudart-dev` is installed, and that package should not be a runtime requirement for rmm. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Rong Ou (https://github.com/rongou) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1366 --- ci/test_python.sh | 2 ++ .../all_cuda-118_arch-x86_64.yaml | 1 + dependencies.yaml | 4 ++++ include/rmm/detail/dynamic_load_runtime.hpp | 23 +++++++++++++------ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ci/test_python.sh b/ci/test_python.sh index d8c1fdbce..d3b3bdfd8 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -11,7 +11,9 @@ rapids-dependency-file-generator \ --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee env.yaml rapids-mamba-retry env create --force -f env.yaml -n test +set +u conda activate test +set -u rapids-print-env diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 8571a1928..78ddf0503 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -8,6 +8,7 @@ dependencies: - clang-tools==16.0.6 - clang==16.0.6 - cmake>=3.26.4 +- cuda-nvcc - cuda-python>=11.7.1,<12.0a0 - cuda-version=11.8 - cudatoolkit diff --git a/dependencies.yaml b/dependencies.yaml index 7d9af48cf..95f275134 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -223,3 +223,7 @@ dependencies: packages: - pytest - pytest-cov + - output_types: conda + packages: + # Needed for numba in tests + - cuda-nvcc diff --git a/include/rmm/detail/dynamic_load_runtime.hpp b/include/rmm/detail/dynamic_load_runtime.hpp index b45dbae25..43626144a 100644 --- a/include/rmm/detail/dynamic_load_runtime.hpp +++ b/include/rmm/detail/dynamic_load_runtime.hpp @@ -38,13 +38,22 @@ struct dynamic_load_runtime { auto close_cudart = [](void* handle) { ::dlclose(handle); }; auto open_cudart = []() { ::dlerror(); - const int major = CUDART_VERSION / 1000; - const std::string libname_ver = "libcudart.so." + std::to_string(major) + ".0"; - const std::string libname = "libcudart.so"; - - auto ptr = ::dlopen(libname_ver.c_str(), RTLD_LAZY); - if (!ptr) { ptr = ::dlopen(libname.c_str(), RTLD_LAZY); } - if (ptr) { return ptr; } + const int major = CUDART_VERSION / 1000; + + // In CUDA 12 the SONAME is correctly defined as libcudart.12, but for + // CUDA<=11 it includes an extra 0 minor version e.g. libcudart.11.0. We + // also allow finding the linker name. + const std::string libname_ver_cuda_11 = "libcudart.so." + std::to_string(major) + ".0"; + const std::string libname_ver_cuda_12 = "libcudart.so." + std::to_string(major); + const std::string libname = "libcudart.so"; + + void* ptr = nullptr; + for (auto&& name : {libname_ver_cuda_12, libname_ver_cuda_11, libname}) { + ptr = dlopen(name.c_str(), RTLD_LAZY); + if (ptr != nullptr) break; + } + + if (ptr != nullptr) { return ptr; } RMM_FAIL("Unable to dlopen cudart"); }; From 5bdcc05683893c528287d84e4a804b96896541d6 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 26 Oct 2023 09:30:05 -0700 Subject: [PATCH 311/675] Fix more doxygen issues (#1367) This PR: - Adds the errors group to the doxygen so that errors are also contained in a group - Removes invalid `@throws` sections that throw nothing - Remove unnecessary backticks around exception types in contexts where they are already assumed to be types and therefore will link/use the appropriate font automatically Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1367 --- .../utilities/simulated_memory_resource.hpp | 4 +- doxygen/Doxyfile | 5 +- include/doxygen_groups.h | 1 + include/rmm/detail/error.hpp | 63 +++++++++++++++---- include/rmm/device_buffer.hpp | 2 - include/rmm/device_scalar.hpp | 12 ++-- include/rmm/logger.hpp | 9 +-- .../mr/device/aligned_resource_adaptor.hpp | 12 ++-- .../mr/device/cuda_async_memory_resource.hpp | 4 +- .../cuda_async_view_memory_resource.hpp | 4 +- .../rmm/mr/device/cuda_memory_resource.hpp | 4 +- .../rmm/mr/device/device_memory_resource.hpp | 6 +- .../failure_callback_resource_adaptor.hpp | 8 +-- .../mr/device/limiting_resource_adaptor.hpp | 10 +-- .../mr/device/logging_resource_adaptor.hpp | 18 +++--- .../rmm/mr/device/managed_memory_resource.hpp | 4 +- include/rmm/mr/device/owning_wrapper.hpp | 8 +-- .../mr/device/statistics_resource_adaptor.hpp | 10 +-- .../device/thread_safe_resource_adaptor.hpp | 10 +-- .../mr/device/tracking_resource_adaptor.hpp | 10 +-- include/rmm/mr/host/host_memory_resource.hpp | 4 -- include/rmm/mr/host/new_delete_resource.hpp | 2 - .../rmm/mr/host/pinned_memory_resource.hpp | 2 - 23 files changed, 96 insertions(+), 116 deletions(-) diff --git a/benchmarks/utilities/simulated_memory_resource.hpp b/benchmarks/utilities/simulated_memory_resource.hpp index 993ec5ace..b7965a021 100644 --- a/benchmarks/utilities/simulated_memory_resource.hpp +++ b/benchmarks/utilities/simulated_memory_resource.hpp @@ -72,7 +72,7 @@ class simulated_memory_resource final : public device_memory_resource { * * @note Stream argument is ignored * - * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled + * @throws rmm::bad_alloc if the requested allocation could not be fulfilled * * @param bytes The size, in bytes, of the allocation * @return void* Pointer to the newly allocated memory @@ -91,8 +91,6 @@ class simulated_memory_resource final : public device_memory_resource { * * @note This call is ignored. * - * @throws Nothing. - * * @param ptr Pointer to be deallocated */ void do_deallocate(void* ptr, std::size_t, cuda_stream_view) override {} diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 24d7e4834..4e8f339b3 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -859,8 +859,11 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. +# Need to specify the error.hpp file explicitly because it is excluded by the +# EXCLUDE_PATTERNS below. INPUT = main_page.md \ - ../include + ../include \ + ../include/rmm/detail/error.hpp # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/include/doxygen_groups.h b/include/doxygen_groups.h index e0f166237..be5eaf17f 100644 --- a/include/doxygen_groups.h +++ b/include/doxygen_groups.h @@ -38,6 +38,7 @@ * @defgroup cuda_device_management CUDA Device Management * @defgroup cuda_streams CUDA Streams * @defgroup data_containers Data Containers + * @defgroup errors Errors * @defgroup logging Logging * @defgroup thrust_integrations Thrust Integrations */ diff --git a/include/rmm/detail/error.hpp b/include/rmm/detail/error.hpp index 329fa7022..6f74dc0ea 100644 --- a/include/rmm/detail/error.hpp +++ b/include/rmm/detail/error.hpp @@ -24,9 +24,12 @@ #include namespace rmm { + /** * @brief Exception thrown when logical precondition is violated. * + * @ingroup errors + * * This exception should not be thrown directly and is instead thrown by the * RMM_EXPECTS macro. * @@ -38,6 +41,8 @@ struct logic_error : public std::logic_error { /** * @brief Exception thrown when a CUDA error is encountered. * + * @ingroup errors + * */ struct cuda_error : public std::runtime_error { using std::runtime_error::runtime_error; @@ -46,12 +51,28 @@ struct cuda_error : public std::runtime_error { /** * @brief Exception thrown when an RMM allocation fails * + * @ingroup errors + * */ class bad_alloc : public std::bad_alloc { public: + /** + * @brief Constructs a bad_alloc with the error message. + * + * @param msg Message to be associated with the exception + */ bad_alloc(const char* msg) : _what{std::string{std::bad_alloc::what()} + ": " + msg} {} + + /** + * @brief Constructs a bad_alloc with the error message. + * + * @param msg Message to be associated with the exception + */ bad_alloc(std::string const& msg) : bad_alloc{msg.c_str()} {} + /** + * @briefreturn{The explanatory string} + */ [[nodiscard]] const char* what() const noexcept override { return _what.c_str(); } private: @@ -61,17 +82,32 @@ class bad_alloc : public std::bad_alloc { /** * @brief Exception thrown when RMM runs out of memory * + * @ingroup errors + * * This error should only be thrown when we know for sure a resource is out of memory. */ class out_of_memory : public bad_alloc { public: + /** + * @brief Constructs an out_of_memory with the error message. + * + * @param msg Message to be associated with the exception + */ out_of_memory(const char* msg) : bad_alloc{std::string{"out_of_memory: "} + msg} {} + + /** + * @brief Constructs an out_of_memory with the error message. + * + * @param msg Message to be associated with the exception + */ out_of_memory(std::string const& msg) : out_of_memory{msg.c_str()} {} }; /** * @brief Exception thrown when attempting to access outside of a defined range * + * @ingroup errors + * */ class out_of_range : public std::out_of_range { using std::out_of_range::out_of_range; @@ -86,7 +122,7 @@ class out_of_range : public std::out_of_range { * @brief Macro for checking (pre-)conditions that throws an exception when * a condition is violated. * - * Defaults to throwing `rmm::logic_error`, but a custom exception may also be + * Defaults to throwing rmm::logic_error, but a custom exception may also be * specified. * * Example usage: @@ -97,12 +133,13 @@ class out_of_range : public std::out_of_range { * // throws std::runtime_error * RMM_EXPECTS(p != nullptr, "Unexpected nullptr", std::runtime_error); * ``` - * @param[in] _condition Expression that evaluates to true or false - * @param[in] _what String literal description of why the exception was - * thrown, i.e. why `_condition` was expected to be true. - * @param[in] _expection_type The exception type to throw; must inherit - * `std::exception`. If not specified (i.e. if only two macro - * arguments are provided), defaults to `rmm::logic_error` + * @param ... This macro accepts either two or three arguments: + * - The first argument must be an expression that evaluates to true or + * false, and is the condition being checked. + * - The second argument is a string literal used to construct the `what` of + * the exception. + * - When given, the third argument is the exception to be thrown. When not + * specified, defaults to `rmm::logic_error`. * @throw `_exception_type` if the condition evaluates to 0 (false). */ #define RMM_EXPECTS(...) \ @@ -122,7 +159,7 @@ class out_of_range : public std::out_of_range { * * Example usage: * ```c++ - * // Throws `rmm::logic_error` + * // Throws rmm::logic_error * RMM_FAIL("Unsupported code path"); * * // Throws `std::runtime_error` @@ -145,16 +182,16 @@ class out_of_range : public std::out_of_range { * `cudaSuccess`, invokes cudaGetLastError() to clear the error and throws an * exception detailing the CUDA error that occurred * - * Defaults to throwing `rmm::cuda_error`, but a custom exception may also be + * Defaults to throwing rmm::cuda_error, but a custom exception may also be * specified. * * Example: * ```c++ * - * // Throws `rmm::cuda_error` if `cudaMalloc` fails + * // Throws rmm::cuda_error if `cudaMalloc` fails * RMM_CUDA_TRY(cudaMalloc(&p, 100)); * - * // Throws `std::runtime_error` if `cudaMalloc` fails + * // Throws std::runtime_error if `cudaMalloc` fails * RMM_CUDA_TRY(cudaMalloc(&p, 100), std::runtime_error); * ``` * @@ -183,8 +220,8 @@ class out_of_range : public std::out_of_range { * `cudaSuccess`, invokes cudaGetLastError() to clear the error and throws an * exception detailing the CUDA error that occurred * - * Defaults to throwing `rmm::bad_alloc`, but when `cudaErrorMemoryAllocation` is returned, - * `rmm::out_of_memory` is thrown instead. + * Defaults to throwing rmm::bad_alloc, but when `cudaErrorMemoryAllocation` is returned, + * rmm::out_of_memory is thrown instead. */ #define RMM_CUDA_TRY_ALLOC(_call) \ do { \ diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index a49f9caa9..c69b9206b 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -177,8 +177,6 @@ class device_buffer { * valid, empty `device_buffer`, i.e., `data()` returns `nullptr`, and * `size()` and `capacity()` are zero. * - * @throws Nothing - * * @param other The `device_buffer` whose contents will be moved into the * newly constructed one. */ diff --git a/include/rmm/device_scalar.hpp b/include/rmm/device_scalar.hpp index a70071145..8e99905ce 100644 --- a/include/rmm/device_scalar.hpp +++ b/include/rmm/device_scalar.hpp @@ -87,7 +87,7 @@ class device_scalar { * stream, or on another stream only if a dependency is enforced (e.g. using * `cudaStreamWaitEvent()`). * - * @throws `rmm::bad_alloc` if allocating the device memory fails. + * @throws rmm::bad_alloc if allocating the device memory fails. * * @param stream Stream on which to perform asynchronous allocation. * @param mr Optional, resource with which to allocate. @@ -108,8 +108,8 @@ class device_scalar { * stream, or on another stream only if a dependency is enforced (e.g. using * `cudaStreamWaitEvent()`). * - * @throws `rmm::bad_alloc` if allocating the device memory for `initial_value` fails. - * @throws `rmm::cuda_error` if copying `initial_value` to device memory fails. + * @throws rmm::bad_alloc if allocating the device memory for `initial_value` fails. + * @throws rmm::cuda_error if copying `initial_value` to device memory fails. * * @param initial_value The initial value of the object in device memory. * @param stream Optional, stream on which to perform allocation and copy. @@ -153,8 +153,8 @@ class device_scalar { * (e.g. using `cudaStreamWaitEvent()` or `cudaStreamSynchronize()`) before calling this function, * otherwise there may be a race condition. * - * @throws `rmm::cuda_error` If the copy fails. - * @throws `rmm::cuda_error` If synchronizing `stream` fails. + * @throws rmm::cuda_error If the copy fails. + * @throws rmm::cuda_error If synchronizing `stream` fails. * * @return T The value of the scalar. * @param stream CUDA stream on which to perform the copy and synchronize. @@ -196,7 +196,7 @@ class device_scalar { * v = 13; * \endcode * - * @throws `rmm::cuda_error` if copying `host_value` to device memory fails. + * @throws rmm::cuda_error if copying @p value to device memory fails. * * @param value The host value which will be copied to device * @param stream CUDA stream on which to perform the copy diff --git a/include/rmm/logger.hpp b/include/rmm/logger.hpp index 8dc1342db..ce0abc23b 100644 --- a/include/rmm/logger.hpp +++ b/include/rmm/logger.hpp @@ -96,15 +96,9 @@ struct bytes { } // namespace detail -/** - * @addtogroup logging - * @{ - * @file - */ - /** * @brief Returns the global RMM logger - * + * @addtogroup logging * This is a spdlog logger. The easiest way to log messages is to use the `RMM_LOG_*` macros. * * @return spdlog::logger& The logger. @@ -136,5 +130,4 @@ inline spdlog::logger& logger() template <> struct fmt::formatter : fmt::ostream_formatter {}; -/** @} */ // end of group //! @endcond diff --git a/include/rmm/mr/device/aligned_resource_adaptor.hpp b/include/rmm/mr/device/aligned_resource_adaptor.hpp index 7151861f4..f65407b72 100644 --- a/include/rmm/mr/device/aligned_resource_adaptor.hpp +++ b/include/rmm/mr/device/aligned_resource_adaptor.hpp @@ -56,8 +56,8 @@ class aligned_resource_adaptor final : public device_memory_resource { /** * @brief Construct an aligned resource adaptor using `upstream` to satisfy allocation requests. * - * @throws `rmm::logic_error` if `upstream == nullptr` - * @throws `rmm::logic_error` if `allocation_alignment` is not a power of 2 + * @throws rmm::logic_error if `upstream == nullptr` + * @throws rmm::logic_error if `allocation_alignment` is not a power of 2 * * @param upstream The resource used for allocating/deallocating device memory. * @param alignment The size used for allocation alignment. @@ -114,7 +114,7 @@ class aligned_resource_adaptor final : public device_memory_resource { * @brief Allocates memory of size at least `bytes` using the upstream resource with the specified * alignment. * - * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled + * @throws rmm::bad_alloc if the requested allocation could not be fulfilled * by the upstream resource. * * @param bytes The size, in bytes, of the allocation @@ -143,8 +143,6 @@ class aligned_resource_adaptor final : public device_memory_resource { /** * @brief Free allocation of size `bytes` pointed to to by `p` and log the deallocation. * - * @throws Nothing. - * * @param ptr Pointer to be deallocated * @param bytes Size of the allocation * @param stream Stream on which to perform the deallocation @@ -169,8 +167,6 @@ class aligned_resource_adaptor final : public device_memory_resource { /** * @brief Compare this resource to another. * - * @throws Nothing. - * * @param other The other resource to compare to * @return true If the two resources are equivalent * @return false If the two resources are not equivalent @@ -188,7 +184,7 @@ class aligned_resource_adaptor final : public device_memory_resource { * * The free size may not be fully allocatable because of alignment requirements. * - * @throws `rmm::cuda_error` if unable to retrieve memory info. + * @throws rmm::cuda_error if unable to retrieve memory info. * * @param stream Stream on which to get the mem info. * @return std::pair containing free_size and total_size of memory diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 5cada7e6c..527cd3875 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -220,8 +220,6 @@ class cuda_async_memory_resource final : public device_memory_resource { /** * @brief Compare this resource to another. * - * @throws Nothing. - * * @param other The other resource to compare to * @return true If the two resources are equivalent * @return false If the two resources are not equal @@ -239,7 +237,7 @@ class cuda_async_memory_resource final : public device_memory_resource { /** * @brief Get free and available memory for memory resource * - * @throws `rmm::cuda_error` if unable to retrieve memory info. + * @throws rmm::cuda_error if unable to retrieve memory info. * * @return std::pair contaiing free_size and total_size of memory */ diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index 07b601c05..825fcab1e 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -162,8 +162,6 @@ class cuda_async_view_memory_resource final : public device_memory_resource { /** * @brief Compare this resource to another. * - * @throws Nothing. - * * @param other The other resource to compare to * @return true If the two resources are equivalent * @return false If the two resources are not equal @@ -176,7 +174,7 @@ class cuda_async_view_memory_resource final : public device_memory_resource { /** * @brief Get free and available memory for memory resource * - * @throws `rmm::cuda_error` if unable to retrieve memory info. + * @throws rmm::cuda_error if unable to retrieve memory info. * * @return std::pair contaiing free_size and total_size of memory */ diff --git a/include/rmm/mr/device/cuda_memory_resource.hpp b/include/rmm/mr/device/cuda_memory_resource.hpp index 2e73ff0b1..256899776 100644 --- a/include/rmm/mr/device/cuda_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_memory_resource.hpp @@ -100,8 +100,6 @@ class cuda_memory_resource final : public device_memory_resource { * Two cuda_memory_resources always compare equal, because they can each * deallocate memory allocated by the other. * - * @throws Nothing. - * * @param other The other resource to compare to * @return true If the two resources are equivalent * @return false If the two resources are not equal @@ -114,7 +112,7 @@ class cuda_memory_resource final : public device_memory_resource { /** * @brief Get free and available memory for memory resource * - * @throws `rmm::cuda_error` if unable to retrieve memory info. + * @throws rmm::cuda_error if unable to retrieve memory info. * * @return std::pair contaiing free_size and total_size of memory */ diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index 8ad84644b..355042092 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -104,8 +104,8 @@ class device_memory_resource { * If supported, this operation may optionally be executed on a stream. * Otherwise, the stream is ignored and the null stream is used. * - * @throws `rmm::bad_alloc` When the requested `bytes` cannot be allocated on - * the specified `stream`. + * @throws rmm::bad_alloc When the requested `bytes` cannot be allocated on + * the specified @p stream. * * @param bytes The size of the allocation * @param stream Stream on which to perform allocation @@ -127,8 +127,6 @@ class device_memory_resource { * If supported, this operation may optionally be executed on a stream. * Otherwise, the stream is ignored and the null stream is used. * - * @throws Nothing. - * * @param ptr Pointer to be deallocated * @param bytes The size in bytes of the allocation. This must be equal to the * value of `bytes` that was passed to the `allocate` call that returned `p`. diff --git a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp index 0df12c23c..73fd5f3b8 100644 --- a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp +++ b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp @@ -96,7 +96,7 @@ class failure_callback_resource_adaptor final : public device_memory_resource { * @brief Construct a new `failure_callback_resource_adaptor` using `upstream` to satisfy * allocation requests. * - * @throws `rmm::logic_error` if `upstream == nullptr` + * @throws rmm::logic_error if `upstream == nullptr` * * @param upstream The resource used for allocating/deallocating device memory * @param callback Callback function @see failure_callback_t @@ -175,8 +175,6 @@ class failure_callback_resource_adaptor final : public device_memory_resource { /** * @brief Free allocation of size `bytes` pointed to by `ptr` * - * @throws Nothing. - * * @param ptr Pointer to be deallocated * @param bytes Size of the allocation * @param stream Stream on which to perform the deallocation @@ -189,8 +187,6 @@ class failure_callback_resource_adaptor final : public device_memory_resource { /** * @brief Compare the upstream resource to another. * - * @throws Nothing. - * * @param other The other resource to compare to * @return true If the two resources are equivalent * @return false If the two resources are not equal @@ -206,7 +202,7 @@ class failure_callback_resource_adaptor final : public device_memory_resource { /** * @brief Get free and available memory from upstream resource. * - * @throws `rmm::cuda_error` if unable to retrieve memory info. + * @throws rmm::cuda_error if unable to retrieve memory info. * * @param stream Stream on which to get the mem info. * @return std::pair contaiing free_size and total_size of memory diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index 5da152ccf..6573956d0 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -46,7 +46,7 @@ class limiting_resource_adaptor final : public device_memory_resource { * @brief Construct a new limiting resource adaptor using `upstream` to satisfy * allocation requests and limiting the total allocation amount possible. * - * @throws `rmm::logic_error` if `upstream == nullptr` + * @throws rmm::logic_error if `upstream == nullptr` * * @param upstream The resource used for allocating/deallocating device memory * @param allocation_limit Maximum memory allowed for this allocator @@ -125,7 +125,7 @@ class limiting_resource_adaptor final : public device_memory_resource { * * The returned pointer has at least 256B alignment. * - * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled + * @throws rmm::bad_alloc if the requested allocation could not be fulfilled * by the upstream resource. * * @param bytes The size, in bytes, of the allocation @@ -152,8 +152,6 @@ class limiting_resource_adaptor final : public device_memory_resource { /** * @brief Free allocation of size `bytes` pointed to by `ptr` * - * @throws Nothing. - * * @param ptr Pointer to be deallocated * @param bytes Size of the allocation * @param stream Stream on which to perform the deallocation @@ -168,8 +166,6 @@ class limiting_resource_adaptor final : public device_memory_resource { /** * @brief Compare the upstream resource to another. * - * @throws Nothing. - * * @param other The other resource to compare to * @return true If the two resources are equivalent * @return false If the two resources are not equal @@ -185,7 +181,7 @@ class limiting_resource_adaptor final : public device_memory_resource { /** * @brief Get free and available memory from upstream resource. * - * @throws `rmm::cuda_error` if unable to retrieve memory info. + * @throws rmm::cuda_error if unable to retrieve memory info. * * @param stream Stream on which to get the mem info. * @return std::pair contaiing free_size and total_size of memory diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 26a0b92c8..781912022 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -62,8 +62,8 @@ class logging_resource_adaptor final : public device_memory_resource { * Creating multiple `logging_resource_adaptor`s with the same `filename` will * result in undefined behavior. * - * @throws `rmm::logic_error` if `upstream == nullptr` - * @throws `spdlog::spdlog_ex` if opening `filename` failed + * @throws rmm::logic_error if `upstream == nullptr` + * @throws spdlog::spdlog_ex if opening `filename` failed * * @param upstream The resource used for allocating/deallocating device memory * @param filename Name of file to write log info. If not specified, retrieves @@ -88,7 +88,7 @@ class logging_resource_adaptor final : public device_memory_resource { * * The logfile will be written using CSV formatting. * - * @throws `rmm::logic_error` if `upstream == nullptr` + * @throws rmm::logic_error if `upstream == nullptr` * * @param upstream The resource used for allocating/deallocating device memory * @param stream The ostream to write log info. @@ -110,7 +110,7 @@ class logging_resource_adaptor final : public device_memory_resource { * * The logfile will be written using CSV formatting. * - * @throws `rmm::logic_error` if `upstream == nullptr` + * @throws rmm::logic_error if `upstream == nullptr` * * @param upstream The resource used for allocating/deallocating device memory * @param sinks A list of logging sinks to which log output will be written. @@ -183,7 +183,7 @@ class logging_resource_adaptor final : public device_memory_resource { /** * @brief Return the value of the environment variable RMM_LOG_FILE. * - * @throws `rmm::logic_error` if `RMM_LOG_FILE` is not set. + * @throws rmm::logic_error if `RMM_LOG_FILE` is not set. * * @return The value of RMM_LOG_FILE as `std::string`. */ @@ -241,7 +241,7 @@ class logging_resource_adaptor final : public device_memory_resource { * * The returned pointer has at least 256B alignment. * - * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled + * @throws rmm::bad_alloc if the requested allocation could not be fulfilled * by the upstream resource. * * @param bytes The size, in bytes, of the allocation @@ -270,8 +270,6 @@ class logging_resource_adaptor final : public device_memory_resource { * thread_id,*TIMESTAMP*,"free",*bytes*,*stream* * ``` * - * @throws Nothing. - * * @param ptr Pointer to be deallocated * @param bytes Size of the allocation * @param stream Stream on which to perform the deallocation @@ -285,8 +283,6 @@ class logging_resource_adaptor final : public device_memory_resource { /** * @brief Compare the upstream resource to another. * - * @throws Nothing. - * * @param other The other resource to compare to * @return true If the two resources are equivalent * @return false If the two resources are not equal @@ -302,7 +298,7 @@ class logging_resource_adaptor final : public device_memory_resource { /** * @brief Get free and available memory from upstream resource. * - * @throws `rmm::cuda_error` if unable to retrieve memory info. + * @throws rmm::cuda_error if unable to retrieve memory info. * * @param stream Stream on which to get the mem info. * @return std::pair contaiing free_size and total_size of memory diff --git a/include/rmm/mr/device/managed_memory_resource.hpp b/include/rmm/mr/device/managed_memory_resource.hpp index 75e91fb24..dfa7710bf 100644 --- a/include/rmm/mr/device/managed_memory_resource.hpp +++ b/include/rmm/mr/device/managed_memory_resource.hpp @@ -104,8 +104,6 @@ class managed_memory_resource final : public device_memory_resource { * Two `managed_memory_resources` always compare equal, because they can each * deallocate memory allocated by the other. * - * @throws Nothing. - * * @param other The other resource to compare to * @return true If the two resources are equivalent * @return false If the two resources are not equal @@ -118,7 +116,7 @@ class managed_memory_resource final : public device_memory_resource { /** * @brief Get free and available memory for memory resource * - * @throws `rmm::cuda_error` if unable to retrieve memory info + * @throws rmm::cuda_error if unable to retrieve memory info * * @param stream to execute on * @return std::pair contaiing free_size and total_size of memory diff --git a/include/rmm/mr/device/owning_wrapper.hpp b/include/rmm/mr/device/owning_wrapper.hpp index c94bfcf9d..da513796d 100644 --- a/include/rmm/mr/device/owning_wrapper.hpp +++ b/include/rmm/mr/device/owning_wrapper.hpp @@ -177,7 +177,7 @@ class owning_wrapper : public device_memory_resource { /** * @brief Allocates memory using the wrapped resource. * - * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled by the wrapped + * @throws rmm::bad_alloc if the requested allocation could not be fulfilled by the wrapped * resource. * * @param bytes The size, in bytes, of the allocation @@ -194,8 +194,6 @@ class owning_wrapper : public device_memory_resource { * * `ptr` must have been returned from a prior call to `do_allocate(bytes)`. * - * @throws Nothing. - * * @param ptr Pointer to the allocation to free. * @param bytes Size of the allocation * @param stream Stream on which to deallocate the memory @@ -210,8 +208,6 @@ class owning_wrapper : public device_memory_resource { * * Two resources are equal if memory allocated by one resource can be freed by the other. * - * @throws Nothing. - * * @param other The other resource to compare to * @return true If the two resources are equal * @return false If the two resources are not equal @@ -227,7 +223,7 @@ class owning_wrapper : public device_memory_resource { /** * @brief Get free and available memory from upstream resource. * - * @throws `rmm::cuda_error` if unable to retrieve memory info. + * @throws rmm::cuda_error if unable to retrieve memory info. * * @param stream Stream on which to get the mem info. * @return std::pair contaiing free_size and total_size of memory diff --git a/include/rmm/mr/device/statistics_resource_adaptor.hpp b/include/rmm/mr/device/statistics_resource_adaptor.hpp index c74eaf4e6..dd186efc0 100644 --- a/include/rmm/mr/device/statistics_resource_adaptor.hpp +++ b/include/rmm/mr/device/statistics_resource_adaptor.hpp @@ -88,7 +88,7 @@ class statistics_resource_adaptor final : public device_memory_resource { * @brief Construct a new statistics resource adaptor using `upstream` to satisfy * allocation requests. * - * @throws `rmm::logic_error` if `upstream == nullptr` + * @throws rmm::logic_error if `upstream == nullptr` * * @param upstream The resource used for allocating/deallocating device memory */ @@ -164,7 +164,7 @@ class statistics_resource_adaptor final : public device_memory_resource { * * The returned pointer has at least 256B alignment. * - * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled + * @throws rmm::bad_alloc if the requested allocation could not be fulfilled * by the upstream resource. * * @param bytes The size, in bytes, of the allocation @@ -190,8 +190,6 @@ class statistics_resource_adaptor final : public device_memory_resource { /** * @brief Free allocation of size `bytes` pointed to by `ptr` * - * @throws Nothing. - * * @param ptr Pointer to be deallocated * @param bytes Size of the allocation * @param stream Stream on which to perform the deallocation @@ -212,8 +210,6 @@ class statistics_resource_adaptor final : public device_memory_resource { /** * @brief Compare the upstream resource to another. * - * @throws Nothing. - * * @param other The other resource to compare to * @return true If the two resources are equivalent * @return false If the two resources are not equal @@ -229,7 +225,7 @@ class statistics_resource_adaptor final : public device_memory_resource { /** * @brief Get free and available memory from upstream resource. * - * @throws `rmm::cuda_error` if unable to retrieve memory info. + * @throws rmm::cuda_error if unable to retrieve memory info. * * @param stream Stream on which to get the mem info. * @return std::pair contaiing free_size and total_size of memory diff --git a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp index c228427af..13184b257 100644 --- a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp +++ b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp @@ -48,7 +48,7 @@ class thread_safe_resource_adaptor final : public device_memory_resource { * * All allocations and frees are protected by a mutex lock * - * @throws `rmm::logic_error` if `upstream == nullptr` + * @throws rmm::logic_error if `upstream == nullptr` * * @param upstream The resource used for allocating/deallocating device memory. */ @@ -91,7 +91,7 @@ class thread_safe_resource_adaptor final : public device_memory_resource { * @brief Allocates memory of size at least `bytes` using the upstream * resource with thread safety. * - * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled + * @throws rmm::bad_alloc if the requested allocation could not be fulfilled * by the upstream resource. * * @param bytes The size, in bytes, of the allocation @@ -107,8 +107,6 @@ class thread_safe_resource_adaptor final : public device_memory_resource { /** * @brief Free allocation of size `bytes` pointed to to by `ptr`.s * - * @throws Nothing. - * * @param ptr Pointer to be deallocated * @param bytes Size of the allocation * @param stream Stream on which to perform the deallocation @@ -122,8 +120,6 @@ class thread_safe_resource_adaptor final : public device_memory_resource { /** * @brief Compare the upstream resource to another. * - * @throws Nothing. - * * @param other The other resource to compare to * @return true If the two resources are equivalent * @return false If the two resources are not equivalent @@ -141,7 +137,7 @@ class thread_safe_resource_adaptor final : public device_memory_resource { /** * @brief Get free and available memory from upstream resource. * - * @throws `rmm::cuda_error` if unable to retrieve memory info. + * @throws rmm::cuda_error if unable to retrieve memory info. * * @param stream Stream on which to get the mem info. * @return std::pair contaiing free_size and total_size of memory diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index eccf878d8..271ccab23 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -85,7 +85,7 @@ class tracking_resource_adaptor final : public device_memory_resource { * @brief Construct a new tracking resource adaptor using `upstream` to satisfy * allocation requests. * - * @throws `rmm::logic_error` if `upstream == nullptr` + * @throws rmm::logic_error if `upstream == nullptr` * * @param upstream The resource used for allocating/deallocating device memory * @param capture_stacks If true, capture stacks for allocation calls @@ -198,7 +198,7 @@ class tracking_resource_adaptor final : public device_memory_resource { * * The returned pointer has at least 256B alignment. * - * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled + * @throws rmm::bad_alloc if the requested allocation could not be fulfilled * by the upstream resource. * * @param bytes The size, in bytes, of the allocation @@ -222,8 +222,6 @@ class tracking_resource_adaptor final : public device_memory_resource { /** * @brief Free allocation of size `bytes` pointed to by `ptr` * - * @throws Nothing. - * * @param ptr Pointer to be deallocated * @param bytes Size of the allocation * @param stream Stream on which to perform the deallocation @@ -267,8 +265,6 @@ class tracking_resource_adaptor final : public device_memory_resource { /** * @brief Compare the upstream resource to another. * - * @throws Nothing. - * * @param other The other resource to compare to * @return true If the two resources are equivalent * @return false If the two resources are not equal @@ -284,7 +280,7 @@ class tracking_resource_adaptor final : public device_memory_resource { /** * @brief Get free and available memory from upstream resource. * - * @throws `rmm::cuda_error` if unable to retrieve memory info. + * @throws rmm::cuda_error if unable to retrieve memory info. * * @param stream Stream on which to get the mem info. * @return std::pair contaiing free_size and total_size of memory diff --git a/include/rmm/mr/host/host_memory_resource.hpp b/include/rmm/mr/host/host_memory_resource.hpp index 8a5739b2a..3f6f90785 100644 --- a/include/rmm/mr/host/host_memory_resource.hpp +++ b/include/rmm/mr/host/host_memory_resource.hpp @@ -84,8 +84,6 @@ class host_memory_resource { * `host_memory_resource` that compares equal to `*this`, and the storage it points to must not * yet have been deallocated, otherwise behavior is undefined. * - * @throws Nothing. - * * @param ptr Pointer to be deallocated * @param bytes The size in bytes of the allocation. This must be equal to the value of `bytes` * that was passed to the `allocate` call that returned `ptr`. @@ -137,8 +135,6 @@ class host_memory_resource { * `host_memory_resource` that compares equal to `*this`, and the storage it points to must not * yet have been deallocated, otherwise behavior is undefined. * - * @throws Nothing. - * * @param ptr Pointer to be deallocated * @param bytes The size in bytes of the allocation. This must be equal to the value of `bytes` * that was passed to the `allocate` call that returned `ptr`. diff --git a/include/rmm/mr/host/new_delete_resource.hpp b/include/rmm/mr/host/new_delete_resource.hpp index d41443c62..044f74063 100644 --- a/include/rmm/mr/host/new_delete_resource.hpp +++ b/include/rmm/mr/host/new_delete_resource.hpp @@ -76,8 +76,6 @@ class new_delete_resource final : public host_memory_resource { * `host_memory_resource` that compares equal to `*this`, and the storage it points to must not * yet have been deallocated, otherwise behavior is undefined. * - * @throws Nothing. - * * @param ptr Pointer to be deallocated * @param bytes The size in bytes of the allocation. This must be equal to the value of `bytes` * that was passed to the `allocate` call that returned `ptr`. diff --git a/include/rmm/mr/host/pinned_memory_resource.hpp b/include/rmm/mr/host/pinned_memory_resource.hpp index 514cc1664..f8d08f66c 100644 --- a/include/rmm/mr/host/pinned_memory_resource.hpp +++ b/include/rmm/mr/host/pinned_memory_resource.hpp @@ -84,8 +84,6 @@ class pinned_memory_resource final : public host_memory_resource { * `host_memory_resource` that compares equal to `*this`, and the storage it points to must not * yet have been deallocated, otherwise behavior is undefined. * - * @throws Nothing. - * * @param ptr Pointer to be deallocated * @param bytes The size in bytes of the allocation. This must be equal to the value of `bytes` * that was passed to the `allocate` call that returned `ptr`. From 207b8984817198e4214bb1d1fb5bf320352e5104 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 31 Oct 2023 09:59:45 -0700 Subject: [PATCH 312/675] Generate proper, consistent nightly versions for pip and conda packages (#1347) This PR changes conda C++/Python packages and wheels to all generate a consistent version for nightlies. The nightly version is of the form YY.MM.DDaN, where N is the number of commits from the last tag. The version is embedded in both the package metadata and in the `rmm.__version__` attribute. In addition the commit hash itself is embedded into the package as `rmm.__git_commit__`. These changes ensure that 1) the conda Python package for a given nightly will reliably choose the correct C++ package (previously we relied on build strings and build times, which is more fragile w.r.t. the conda solver); 2) wheels are properly considered nightlies and are treated accordingly by pip (e.g. requiring `--pre` for installation, not conflicting with normal releases, etc); and 3) wheels and conda packages are aligned on versions so that they can be easily compared if necessary. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) - Lawrence Mitchell (https://github.com/wence-) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1347 --- VERSION | 1 + ci/build_cpp.sh | 4 +++- ci/build_python.sh | 11 ++++++++++- ci/build_wheel.sh | 17 ++++------------- ci/release/update-version.sh | 5 +++-- ci/test_wheel.sh | 2 +- conda/recipes/librmm/meta.yaml | 4 ++-- conda/recipes/rmm/meta.yaml | 4 ++-- python/pyproject.toml | 5 ++++- python/rmm/VERSION | 1 + python/rmm/__init__.py | 3 +-- python/rmm/_version.py | 20 ++++++++++++++++++++ python/setup.py | 2 +- 13 files changed, 53 insertions(+), 26 deletions(-) create mode 100644 VERSION create mode 120000 python/rmm/VERSION create mode 100644 python/rmm/_version.py diff --git a/VERSION b/VERSION new file mode 100644 index 000000000..a193fff41 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +23.12.00 diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 0ae14a88f..d36fcbbe7 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -9,9 +9,11 @@ export CMAKE_GENERATOR=Ninja rapids-print-env +version=$(rapids-generate-version) + rapids-logger "Begin cpp build" # This calls mambabuild when boa is installed (as is the case in the CI images) -rapids-conda-retry mambabuild conda/recipes/librmm +RAPIDS_PACKAGE_VERSION=${version} rapids-conda-retry mambabuild conda/recipes/librmm rapids-upload-conda-to-s3 cpp diff --git a/ci/build_python.sh b/ci/build_python.sh index 9da4025c7..c1c30da2a 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -9,11 +9,20 @@ export CMAKE_GENERATOR=Ninja rapids-print-env +package_name="rmm" +package_dir="python" + +version=$(rapids-generate-version) +commit=$(git rev-parse HEAD) + +echo "${version}" > VERSION +sed -i "/^__git_commit__/ s/= .*/= \"${commit}\"/g" "${package_dir}/${package_name}/_version.py" + rapids-logger "Begin py build" CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) # This calls mambabuild when boa is installed (as is the case in the CI images) -rapids-conda-retry mambabuild -c "${CPP_CHANNEL}" conda/recipes/rmm +RAPIDS_PACKAGE_VERSION=${version} rapids-conda-retry mambabuild -c "${CPP_CHANNEL}" conda/recipes/rmm rapids-upload-conda-to-s3 python diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh index 660c88387..6d887e5d2 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel.sh @@ -9,9 +9,8 @@ package_dir="python" source rapids-configure-sccache source rapids-date-string -# Use gha-tools rapids-pip-wheel-version to generate wheel version then -# update the necessary files -version_override="$(rapids-pip-wheel-version ${RAPIDS_DATE_STRING})" +version=$(rapids-generate-version) +commit=$(git rev-parse HEAD) RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" @@ -22,17 +21,9 @@ PACKAGE_CUDA_SUFFIX="-${RAPIDS_PY_CUDA_SUFFIX}" # Patch project metadata files to include the CUDA version suffix and version override. pyproject_file="${package_dir}/pyproject.toml" -sed -i "s/^version = .*/version = \"${version_override}\"/g" ${pyproject_file} sed -i "s/name = \"${package_name}\"/name = \"${package_name}${PACKAGE_CUDA_SUFFIX}\"/g" ${pyproject_file} - -# For nightlies we want to ensure that we're pulling in alphas as well. The -# easiest way to do so is to augment the spec with a constraint containing a -# min alpha version that doesn't affect the version bounds but does allow usage -# of alpha versions for that dependency without --pre -alpha_spec='' -if ! rapids-is-release-build; then - alpha_spec=',>=0.0.0a0' -fi +echo "${version}" > VERSION +sed -i "/^__git_commit__/ s/= .*/= \"${commit}\"/g" "${package_dir}/${package_name}/_version.py" if [[ $PACKAGE_CUDA_SUFFIX == "-cu12" ]]; then sed -i "s/cuda-python[<=>\.,0-9a]*/cuda-python>=12.0,<13.0a0/g" ${pyproject_file} diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 6250a4810..b7ea5892f 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -37,8 +37,9 @@ sed_runner 's/'" VERSION .*"'/'" VERSION ${NEXT_FULL_TAG}"'/g' CMakeLists.txt # Python update sed_runner 's/'"rmm_version .*)"'/'"rmm_version ${NEXT_FULL_TAG})"'/g' python/CMakeLists.txt -sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/rmm/__init__.py -sed_runner "s/^version = .*/version = \"${NEXT_FULL_TAG}\"/g" python/pyproject.toml + +# Centralized version file update +echo "${NEXT_FULL_TAG}" > VERSION # rapids-cmake version sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' fetch_rapids.cmake diff --git a/ci/test_wheel.sh b/ci/test_wheel.sh index 4b03022f8..aa2705afe 100755 --- a/ci/test_wheel.sh +++ b/ci/test_wheel.sh @@ -10,7 +10,7 @@ RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from- python -m pip install $(echo ./dist/rmm*.whl)[test] # Run smoke tests for aarch64 pull requests -if [ "$(arch)" == "aarch64" && ${RAPIDS_BUILD_TYPE} == "pull-request" ]; then +if [[ "$(arch)" == "aarch64" && ${RAPIDS_BUILD_TYPE} == "pull-request" ]]; then python ./ci/wheel_smoke_test.py else python -m pytest ./python/rmm/tests diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 1f7ac40d4..9dcc6ccfe 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -1,6 +1,6 @@ # Copyright (c) 2018-2023, NVIDIA CORPORATION. -{% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') %} +{% set version = environ['RAPIDS_PACKAGE_VERSION'].lstrip('v') %} {% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} {% set cuda_major = cuda_version.split('.')[0] %} {% set cuda_spec = ">=" + cuda_major ~ ",<" + (cuda_major | int + 1) ~ ".0a0" %} # i.e. >=11,<12.0a0 @@ -10,7 +10,7 @@ package: name: librmm-split source: - git_url: ../../.. + path: ../../.. requirements: build: diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index e13254d4c..b3457d922 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -1,6 +1,6 @@ # Copyright (c) 2019-2023, NVIDIA CORPORATION. -{% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') %} +{% set version = environ['RAPIDS_PACKAGE_VERSION'].lstrip('v') %} {% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} {% set cuda_major = cuda_version.split('.')[0] %} {% set py_version = environ['CONDA_PY'] %} @@ -11,7 +11,7 @@ package: version: {{ version }} source: - git_url: ../../.. + path: ../../.. build: number: {{ GIT_DESCRIBE_NUMBER }} diff --git a/python/pyproject.toml b/python/pyproject.toml index 300f2332c..751d9a674 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -27,7 +27,7 @@ requires = [ [project] name = "rmm" -version = "23.12.00" +dynamic = ["version"] description = "rmm - RAPIDS Memory Manager" readme = { file = "README.md", content-type = "text/markdown" } authors = [ @@ -114,3 +114,6 @@ skip = [ [tool.setuptools] license-files = ["LICENSE"] + +[tool.setuptools.dynamic] +version = {file = "rmm/VERSION"} diff --git a/python/rmm/VERSION b/python/rmm/VERSION new file mode 120000 index 000000000..558194c5a --- /dev/null +++ b/python/rmm/VERSION @@ -0,0 +1 @@ +../../VERSION \ No newline at end of file diff --git a/python/rmm/__init__.py b/python/rmm/__init__.py index 96e119132..1e3b5c8b1 100644 --- a/python/rmm/__init__.py +++ b/python/rmm/__init__.py @@ -23,6 +23,7 @@ set_logging_level, should_log, ) +from rmm._version import __git_commit__, __version__ from rmm.mr import disable_logging, enable_logging, get_log_filenames from rmm.rmm import ( RMMError, @@ -51,5 +52,3 @@ "should_log", "unregister_reinitialize_hook", ] - -__version__ = "23.12.00" diff --git a/python/rmm/_version.py b/python/rmm/_version.py new file mode 100644 index 000000000..053e51ecd --- /dev/null +++ b/python/rmm/_version.py @@ -0,0 +1,20 @@ +# Copyright (c) 2023, 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. + +import importlib.resources + +__version__ = ( + importlib.resources.files("rmm").joinpath("VERSION").read_text().strip() +) +__git_commit__ = "" diff --git a/python/setup.py b/python/setup.py index 48b35d1bb..af5750044 100644 --- a/python/setup.py +++ b/python/setup.py @@ -6,6 +6,6 @@ packages = find_packages(include=["rmm*"]) setup( packages=packages, - package_data={key: ["*.pxd"] for key in packages}, + package_data={key: ["VERSION", "*.pxd"] for key in packages}, zip_safe=False, ) From f4afa6af3021de57f088dee183f572f3d69caa2c Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 2 Nov 2023 15:31:18 -0700 Subject: [PATCH 313/675] Generate unified Python/C++ docs (#1324) This PR leverages [Breathe](https://breathe.readthedocs.io/en/latest/) to pull the rmm C++ API documentation into the python Sphinx docs build, generating a single unified build of the documentation that supports cross-linking between language libraries and also simplifies cross-linking from other libraries that wish to link here (such as higher-level RAPIDS libraries that use both rmm's Python and C++ APIs). Using Breathe requires changing the doxygen build to generate XML in addition to the usual HTML. It turns out that doxygen catches more doc issues (of the types fixed in #1317) when more build outputs are turned on, which is indicative of some bugs/limitations in doxygen, but nonetheless I've fixed the additional issues in this PR as well. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1324 --- .../all_cuda-118_arch-x86_64.yaml | 1 + .../all_cuda-120_arch-x86_64.yaml | 1 + dependencies.yaml | 1 + include/rmm/cuda_stream_view.hpp | 11 ++- include/rmm/device_uvector.hpp | 2 +- include/rmm/logger.hpp | 4 +- .../mr/device/cuda_async_memory_resource.hpp | 2 +- .../rmm/mr/device/device_memory_resource.hpp | 2 +- .../failure_callback_resource_adaptor.hpp | 2 +- include/rmm/mr/device/per_device_resource.hpp | 7 +- .../rmm/mr/device/polymorphic_allocator.hpp | 2 +- python/docs/conf.py | 68 +++++++++++++++++++ python/docs/cpp.rst | 8 +++ python/docs/cpp_api.rst | 8 +++ python/docs/{basics.md => guide.md} | 2 +- python/docs/index.rst | 4 +- .../librmm_docs/cuda_device_management.rst | 5 ++ python/docs/librmm_docs/cuda_streams.rst | 5 ++ python/docs/librmm_docs/data_containers.rst | 5 ++ python/docs/librmm_docs/errors.rst | 5 ++ python/docs/librmm_docs/index.rst | 29 ++++++++ python/docs/librmm_docs/logging.rst | 5 ++ python/docs/librmm_docs/memory_resources.rst | 17 +++++ .../docs/librmm_docs/thrust_integrations.rst | 5 ++ python/docs/python.rst | 9 +++ python/docs/{api.rst => python_api.rst} | 0 26 files changed, 197 insertions(+), 13 deletions(-) create mode 100644 python/docs/cpp.rst create mode 100644 python/docs/cpp_api.rst rename python/docs/{basics.md => guide.md} (99%) create mode 100644 python/docs/librmm_docs/cuda_device_management.rst create mode 100644 python/docs/librmm_docs/cuda_streams.rst create mode 100644 python/docs/librmm_docs/data_containers.rst create mode 100644 python/docs/librmm_docs/errors.rst create mode 100644 python/docs/librmm_docs/index.rst create mode 100644 python/docs/librmm_docs/logging.rst create mode 100644 python/docs/librmm_docs/memory_resources.rst create mode 100644 python/docs/librmm_docs/thrust_integrations.rst create mode 100644 python/docs/python.rst rename python/docs/{api.rst => python_api.rst} (100%) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 78ddf0503..3a5cb90af 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -4,6 +4,7 @@ channels: - rapidsai - conda-forge dependencies: +- breathe - c-compiler - clang-tools==16.0.6 - clang==16.0.6 diff --git a/conda/environments/all_cuda-120_arch-x86_64.yaml b/conda/environments/all_cuda-120_arch-x86_64.yaml index aec31b3db..f87564b74 100644 --- a/conda/environments/all_cuda-120_arch-x86_64.yaml +++ b/conda/environments/all_cuda-120_arch-x86_64.yaml @@ -4,6 +4,7 @@ channels: - rapidsai - conda-forge dependencies: +- breathe - c-compiler - clang-tools==16.0.6 - clang==16.0.6 diff --git a/dependencies.yaml b/dependencies.yaml index 95f275134..af3f49ef0 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -174,6 +174,7 @@ dependencies: common: - output_types: conda packages: + - breathe - *doxygen - graphviz - ipython diff --git a/include/rmm/cuda_stream_view.hpp b/include/rmm/cuda_stream_view.hpp index fe07fa1b9..7809140fb 100644 --- a/include/rmm/cuda_stream_view.hpp +++ b/include/rmm/cuda_stream_view.hpp @@ -125,6 +125,9 @@ static const cuda_stream_view cuda_stream_per_thread{ cudaStreamPerThread // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) }; +// Need to avoid putting is_per_thread_default and is_default into the group twice. +/** @} */ // end of group + [[nodiscard]] inline bool cuda_stream_view::is_per_thread_default() const noexcept { #ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM @@ -134,9 +137,6 @@ static const cuda_stream_view cuda_stream_per_thread{ #endif } -/** - * @brief Return true if the wrapped stream is explicitly the CUDA legacy default stream. - */ [[nodiscard]] inline bool cuda_stream_view::is_default() const noexcept { #ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM @@ -146,6 +146,11 @@ static const cuda_stream_view cuda_stream_per_thread{ #endif } +/** + * @addtogroup cuda_streams + * @{ + */ + /** * @brief Equality comparison operator for streams * diff --git a/include/rmm/device_uvector.hpp b/include/rmm/device_uvector.hpp index 930cda157..982d2095d 100644 --- a/include/rmm/device_uvector.hpp +++ b/include/rmm/device_uvector.hpp @@ -44,7 +44,7 @@ namespace rmm { * `thrust::uninitialized_fill`. * * Example: - * @code{c++} + * @code{.cpp} * rmm::mr::device_memory_resource * mr = new my_custom_resource(); * rmm::cuda_stream_view s{}; * diff --git a/include/rmm/logger.hpp b/include/rmm/logger.hpp index ce0abc23b..6213221ab 100644 --- a/include/rmm/logger.hpp +++ b/include/rmm/logger.hpp @@ -98,7 +98,9 @@ struct bytes { /** * @brief Returns the global RMM logger - * @addtogroup logging + * + * @ingroup logging + * * This is a spdlog logger. The easiest way to log messages is to use the `RMM_LOG_*` macros. * * @return spdlog::logger& The logger. diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 527cd3875..de31c7dc4 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -75,7 +75,7 @@ class cuda_async_memory_resource final : public device_memory_resource { * If the pool size grows beyond the release threshold, unused memory held by the pool will be * released at the next synchronization event. * - * @throws rmm::runtime_error if the CUDA version does not support `cudaMallocAsync` + * @throws rmm::logic_error if the CUDA version does not support `cudaMallocAsync` * * @param initial_pool_size Optional initial size in bytes of the pool. If no value is provided, * initial pool size is half of the available GPU memory. diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index 355042092..bda52ac67 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -75,7 +75,7 @@ namespace rmm::mr { * pool_memory_resource objects for each device and sets them as the per-device resource for that * device. * - * @code{c++} + * @code{.cpp} * std::vector> per_device_pools; * for(int i = 0; i < N; ++i) { * cudaSetDevice(i); diff --git a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp index 73fd5f3b8..f8cbe8597 100644 --- a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp +++ b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp @@ -60,7 +60,7 @@ using failure_callback_t = std::function; * When implementing a callback function for allocation retry, care must be taken to avoid an * infinite loop. The following example makes sure to only retry the allocation once: * - * @code{c++} + * @code{.cpp} * using failure_callback_adaptor = * rmm::mr::failure_callback_resource_adaptor; * diff --git a/include/rmm/mr/device/per_device_resource.hpp b/include/rmm/mr/device/per_device_resource.hpp index aa7217758..139389f0c 100644 --- a/include/rmm/mr/device/per_device_resource.hpp +++ b/include/rmm/mr/device/per_device_resource.hpp @@ -61,7 +61,7 @@ * pool_memory_resource objects for each device and sets them as the per-device resource for that * device. * - * @code{c++} + * @code{.cpp} * std::vector> per_device_pools; * for(int i = 0; i < N; ++i) { * cudaSetDevice(i); @@ -72,6 +72,10 @@ */ namespace rmm::mr { +/** + * @addtogroup memory_resources + * @{ + */ namespace detail { @@ -233,4 +237,5 @@ inline device_memory_resource* set_current_device_resource(device_memory_resourc { return set_per_device_resource(rmm::get_current_cuda_device(), new_mr); } +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/polymorphic_allocator.hpp b/include/rmm/mr/device/polymorphic_allocator.hpp index a52ec14d1..c3b8ac6ea 100644 --- a/include/rmm/mr/device/polymorphic_allocator.hpp +++ b/include/rmm/mr/device/polymorphic_allocator.hpp @@ -133,7 +133,7 @@ bool operator!=(polymorphic_allocator const& lhs, polymorphic_allocator co *`deallocate` functions. * * Example: - *\code{c++} + *\code{.cpp} * my_stream_ordered_allocator a{...}; * cuda_stream_view s = // create stream; * diff --git a/python/docs/conf.py b/python/docs/conf.py index d8c7460dc..c55d998d6 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -11,6 +11,7 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. # import os +import re # -- Project information ----------------------------------------------------- @@ -46,8 +47,12 @@ "IPython.sphinxext.ipython_directive", "nbsphinx", "recommonmark", + "breathe", ] +# Breathe Configuration +breathe_projects = {"librmm": "../../doxygen/xml"} +breathe_default_project = "librmm" copybutton_prompt_text = ">>> " @@ -197,9 +202,72 @@ ] +def on_missing_reference(app, env, node, contnode): + if (refid := node.get("refid")) is not None and "hpp" in refid: + # We don't want to link to C++ header files directly from the + # Sphinx docs, those are pages that doxygen automatically + # generates. Adding those would clutter the Sphinx output. + return contnode + + names_to_skip = [ + # External names + "cudaStream_t", + "cudaStreamLegacy", + "cudaStreamPerThread", + "thrust", + "spdlog", + # Unknown types + "int64_t", + "int8_t", + # Internal objects + "detail", + "RMM_EXEC_CHECK_DISABLE", + "default_alignment_threshold", + "get_default_filename", + # Template types + "Base", + ] + if ( + node["refdomain"] == "cpp" + and (reftarget := node.get("reftarget")) is not None + ): + if any(toskip in reftarget for toskip in names_to_skip): + return contnode + + # Strip template parameters and just use the base type. + if match := re.search("(.*)<.*>", reftarget): + reftarget = match.group(1) + + # Try to find the target prefixed with e.g. namespaces in case that's + # all that's missing. Include the empty prefix in case we're searching + # for a stripped template. + extra_prefixes = ["rmm::", "rmm::mr::", "mr::", ""] + for (name, dispname, type, docname, anchor, priority) in env.domains[ + "cpp" + ].get_objects(): + + for prefix in extra_prefixes: + if ( + name == f"{prefix}{reftarget}" + or f"{prefix}{name}" == reftarget + ): + return env.domains["cpp"].resolve_xref( + env, + docname, + app.builder, + node["reftype"], + name, + node, + contnode, + ) + + return None + + def setup(app): app.add_js_file("copybutton_pydocs.js") app.add_css_file("https://docs.rapids.ai/assets/css/custom.css") app.add_js_file( "https://docs.rapids.ai/assets/js/custom.js", loading_method="defer" ) + app.connect("missing-reference", on_missing_reference) diff --git a/python/docs/cpp.rst b/python/docs/cpp.rst new file mode 100644 index 000000000..e60f15129 --- /dev/null +++ b/python/docs/cpp.rst @@ -0,0 +1,8 @@ +Welcome to the rmm C++ documentation! +======================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + cpp_api.rst diff --git a/python/docs/cpp_api.rst b/python/docs/cpp_api.rst new file mode 100644 index 000000000..63e435190 --- /dev/null +++ b/python/docs/cpp_api.rst @@ -0,0 +1,8 @@ +API Reference +============= + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + librmm_docs/index diff --git a/python/docs/basics.md b/python/docs/guide.md similarity index 99% rename from python/docs/basics.md rename to python/docs/guide.md index 997745f00..c06135ca8 100644 --- a/python/docs/basics.md +++ b/python/docs/guide.md @@ -1,4 +1,4 @@ -# RMM - the RAPIDS Memory Manager +# User Guide Achieving optimal performance in GPU-centric workflows frequently requires customizing how GPU ("device") memory is allocated. diff --git a/python/docs/index.rst b/python/docs/index.rst index 8dffdeb02..524351253 100644 --- a/python/docs/index.rst +++ b/python/docs/index.rst @@ -10,8 +10,8 @@ Welcome to rmm's documentation! :maxdepth: 2 :caption: Contents: - basics.md - api.rst + Python + C++ Indices and tables diff --git a/python/docs/librmm_docs/cuda_device_management.rst b/python/docs/librmm_docs/cuda_device_management.rst new file mode 100644 index 000000000..096509886 --- /dev/null +++ b/python/docs/librmm_docs/cuda_device_management.rst @@ -0,0 +1,5 @@ +CUDA Device Management +====================== + +.. doxygengroup:: cuda_device_management + :members: diff --git a/python/docs/librmm_docs/cuda_streams.rst b/python/docs/librmm_docs/cuda_streams.rst new file mode 100644 index 000000000..e3e6ed793 --- /dev/null +++ b/python/docs/librmm_docs/cuda_streams.rst @@ -0,0 +1,5 @@ +CUDA Streams +============ + +.. doxygengroup:: cuda_streams + :members: diff --git a/python/docs/librmm_docs/data_containers.rst b/python/docs/librmm_docs/data_containers.rst new file mode 100644 index 000000000..1cfccb7bd --- /dev/null +++ b/python/docs/librmm_docs/data_containers.rst @@ -0,0 +1,5 @@ +Data Containers +=============== + +.. doxygengroup:: data_containers + :members: diff --git a/python/docs/librmm_docs/errors.rst b/python/docs/librmm_docs/errors.rst new file mode 100644 index 000000000..4de0ee40a --- /dev/null +++ b/python/docs/librmm_docs/errors.rst @@ -0,0 +1,5 @@ +Errors +====== + +.. doxygengroup:: errors + :members: diff --git a/python/docs/librmm_docs/index.rst b/python/docs/librmm_docs/index.rst new file mode 100644 index 000000000..6afd94d2e --- /dev/null +++ b/python/docs/librmm_docs/index.rst @@ -0,0 +1,29 @@ +.. rmm documentation master file, created by + sphinx-quickstart on Thu Nov 19 13:16:00 2020. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +librmm Documentation +==================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + memory_resources + data_containers + thrust_integrations + cuda_device_management + cuda_streams + errors + logging + + +.. doxygennamespace:: rmm + :desc-only: + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`search` diff --git a/python/docs/librmm_docs/logging.rst b/python/docs/librmm_docs/logging.rst new file mode 100644 index 000000000..97f961c0c --- /dev/null +++ b/python/docs/librmm_docs/logging.rst @@ -0,0 +1,5 @@ +Logging +======= + +.. doxygengroup:: logging + :members: diff --git a/python/docs/librmm_docs/memory_resources.rst b/python/docs/librmm_docs/memory_resources.rst new file mode 100644 index 000000000..68d33f003 --- /dev/null +++ b/python/docs/librmm_docs/memory_resources.rst @@ -0,0 +1,17 @@ +Memory Resources +================ + +.. doxygennamespace:: rmm::mr + :desc-only: + +.. doxygengroup:: memory_resources + :members: + +.. doxygengroup:: device_memory_resources + :members: + +.. doxygengroup:: host_memory_resources + :members: + +.. doxygengroup:: device_resource_adaptors + :members: diff --git a/python/docs/librmm_docs/thrust_integrations.rst b/python/docs/librmm_docs/thrust_integrations.rst new file mode 100644 index 000000000..8574f482a --- /dev/null +++ b/python/docs/librmm_docs/thrust_integrations.rst @@ -0,0 +1,5 @@ +Thrust Integration +================== + +.. doxygengroup:: thrust_integrations + :members: diff --git a/python/docs/python.rst b/python/docs/python.rst new file mode 100644 index 000000000..bff919627 --- /dev/null +++ b/python/docs/python.rst @@ -0,0 +1,9 @@ +Welcome to the rmm Python documentation! +======================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + guide.md + python_api.rst diff --git a/python/docs/api.rst b/python/docs/python_api.rst similarity index 100% rename from python/docs/api.rst rename to python/docs/python_api.rst From 28abb104b5cdba1c7d2a9b1a25ab7851d7e20ef2 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 6 Nov 2023 08:13:20 -0800 Subject: [PATCH 314/675] Make internally stored default argument values public (#1373) There are a couple of default parameters that are being set, one to a local constexpr and another by a method, both of which were previously private. That made the defaults unintentionally opaque. This change makes both of them publicly visible values. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1373 --- include/rmm/mr/device/aligned_resource_adaptor.hpp | 8 ++++++-- include/rmm/mr/device/logging_resource_adaptor.hpp | 2 +- python/docs/conf.py | 2 -- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/rmm/mr/device/aligned_resource_adaptor.hpp b/include/rmm/mr/device/aligned_resource_adaptor.hpp index f65407b72..05e9915cc 100644 --- a/include/rmm/mr/device/aligned_resource_adaptor.hpp +++ b/include/rmm/mr/device/aligned_resource_adaptor.hpp @@ -106,9 +106,13 @@ class aligned_resource_adaptor final : public device_memory_resource { return upstream_->supports_get_mem_info(); } - private: + /** + * @brief The default alignment used by the adaptor. + */ static constexpr std::size_t default_alignment_threshold = 0; - using lock_guard = std::lock_guard; + + private: + using lock_guard = std::lock_guard; /** * @brief Allocates memory of size at least `bytes` using the upstream resource with the specified diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 781912022..781571157 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -179,7 +179,6 @@ class logging_resource_adaptor final : public device_memory_resource { return std::string{"Thread,Time,Action,Pointer,Size,Stream"}; } - private: /** * @brief Return the value of the environment variable RMM_LOG_FILE. * @@ -195,6 +194,7 @@ class logging_resource_adaptor final : public device_memory_resource { return std::string{filename}; } + private: static auto make_logger(std::ostream& stream) { return std::make_shared( diff --git a/python/docs/conf.py b/python/docs/conf.py index c55d998d6..a063b52eb 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -222,8 +222,6 @@ def on_missing_reference(app, env, node, contnode): # Internal objects "detail", "RMM_EXEC_CHECK_DISABLE", - "default_alignment_threshold", - "get_default_filename", # Template types "Base", ] From d407fd380dd478326ae28a221aa66700d81c78db Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Wed, 8 Nov 2023 23:36:18 +0000 Subject: [PATCH 315/675] Deliberately leak PTDS thread_local events in stream ordered mr (#1375) An object with `thread_local` modifier has thread storage duration, its destructor (if it exists) will after the thread exits, which, on the main thread, is below `main` (https://eel.is/c++draft/basic.start.term). The CUDA runtime sets up (when the first call into the runtime is made) a teardown of the driver that runs `atexit`. Although [basic.start.term#5](https://eel.is/c++draft/basic.start.term#5) provides guarantees on the order in which these destructors are called (thread storage duration objects are destructed _before_ any `atexit` handlers run), it appears that gnu libstdc++ does not always implement this correctly (if not compiled with `_GLIBCXX_HAVE___CXA_THREAD_ATEXIT`). Moreover (possibly consequently) it is considered undefined behaviour to call into the CUDA runtime below `main`. Hence, we cannot call `cudaEventDestroy` to deallocate our `thread_local` events. Since there are a finite number of these event (`ndevices * nparticipating_threads`), rather than attempting to destroy them we choose to leak them, thus avoiding any sequencing problems. - Closes #1371 Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Mark Harris (https://github.com/harrism) - Jake Hemstad (https://github.com/jrhemstad) URL: https://github.com/rapidsai/rmm/pull/1375 --- .../detail/stream_ordered_memory_resource.hpp | 50 ++++++------------- 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index f071717c0..a57bf1c6d 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -26,12 +26,8 @@ #include #include -#include -#include #include #include -#include -#include #include namespace rmm::mr::detail { @@ -259,23 +255,6 @@ class stream_ordered_memory_resource : public crtp, public device_ } private: - /** - * @brief RAII wrapper for a CUDA event. - */ - struct event_wrapper { - event_wrapper() - { - RMM_ASSERT_CUDA_SUCCESS(cudaEventCreateWithFlags(&event, cudaEventDisableTiming)); - } - ~event_wrapper() { RMM_ASSERT_CUDA_SUCCESS(cudaEventDestroy(event)); } - cudaEvent_t event{}; - - event_wrapper(event_wrapper const&) = delete; - event_wrapper& operator=(event_wrapper const&) = delete; - event_wrapper(event_wrapper&&) noexcept = delete; - event_wrapper& operator=(event_wrapper&&) = delete; - }; - /** * @brief get a unique CUDA event (possibly new) associated with `stream` * @@ -289,17 +268,20 @@ class stream_ordered_memory_resource : public crtp, public device_ stream_event_pair get_event(cuda_stream_view stream) { if (stream.is_per_thread_default()) { - // Create a thread-local shared event wrapper for each device. Shared pointers in the thread - // and in each MR instance ensure the wrappers are destroyed only after all are finished - // with them. - thread_local std::vector> events_tls( - rmm::get_num_cuda_devices()); - auto event = [&, device_id = this->device_id_]() { - if (events_tls[device_id.value()]) { return events_tls[device_id.value()]->event; } - - auto event = std::make_shared(); - this->default_stream_events.insert(event); - return (events_tls[device_id.value()] = std::move(event))->event; + // Create a thread-local event for each device. These events are + // deliberately leaked since the destructor needs to call into + // the CUDA runtime and thread_local destructors (can) run below + // main: it is undefined behaviour to call into the CUDA + // runtime below main. + thread_local std::vector events_tls(rmm::get_num_cuda_devices()); + auto event = [device_id = this->device_id_]() { + auto& e = events_tls[device_id.value()]; + if (!e) { + // These events are deliberately not destructed and therefore live until + // program exit. + RMM_ASSERT_CUDA_SUCCESS(cudaEventCreateWithFlags(&e, cudaEventDisableTiming)); + } + return e; }(); return stream_event_pair{stream.value(), event}; } @@ -505,10 +487,6 @@ class stream_ordered_memory_resource : public crtp, public device_ // bidirectional mapping between non-default streams and events std::unordered_map stream_events_; - // shared pointers to events keeps the events alive as long as either the thread that created - // them or the MR that is using them exists. - std::set> default_stream_events; - std::mutex mtx_; // mutex for thread-safe access rmm::cuda_device_id device_id_{rmm::get_current_cuda_device()}; From f2e4e534218fbb6bda0c156efa082f5623e9f291 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Thu, 9 Nov 2023 16:27:16 -0500 Subject: [PATCH 316/675] v24.02 Updates [skip ci] --- .../cuda11.8-conda/devcontainer.json | 4 ++-- .devcontainer/cuda11.8-pip/devcontainer.json | 4 ++-- .../cuda12.0-conda/devcontainer.json | 4 ++-- .devcontainer/cuda12.0-pip/devcontainer.json | 4 ++-- .github/workflows/build.yaml | 12 +++++------ .github/workflows/pr.yaml | 20 +++++++++---------- .github/workflows/test.yaml | 6 +++--- CMakeLists.txt | 2 +- VERSION | 2 +- ci/build_docs.sh | 2 +- ci/check_style.sh | 2 +- doxygen/Doxyfile | 2 +- fetch_rapids.cmake | 2 +- python/CMakeLists.txt | 2 +- python/docs/conf.py | 4 ++-- 15 files changed, 36 insertions(+), 36 deletions(-) diff --git a/.devcontainer/cuda11.8-conda/devcontainer.json b/.devcontainer/cuda11.8-conda/devcontainer.json index f8546a341..663d0072c 100644 --- a/.devcontainer/cuda11.8-conda/devcontainer.json +++ b/.devcontainer/cuda11.8-conda/devcontainer.json @@ -5,12 +5,12 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:23.12-cpp-cuda11.8-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.02-cpp-cuda11.8-mambaforge-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.12": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.2": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda11.8-pip/devcontainer.json b/.devcontainer/cuda11.8-pip/devcontainer.json index b1e33502f..8bdde6a21 100644 --- a/.devcontainer/cuda11.8-pip/devcontainer.json +++ b/.devcontainer/cuda11.8-pip/devcontainer.json @@ -5,12 +5,12 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:23.12-cpp-llvm16-cuda11.8-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.02-cpp-llvm16-cuda11.8-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.12": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.2": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.0-conda/devcontainer.json b/.devcontainer/cuda12.0-conda/devcontainer.json index 4834422eb..1191efca2 100644 --- a/.devcontainer/cuda12.0-conda/devcontainer.json +++ b/.devcontainer/cuda12.0-conda/devcontainer.json @@ -5,12 +5,12 @@ "args": { "CUDA": "12.0", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:23.12-cpp-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.02-cpp-mambaforge-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.12": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.2": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.0-pip/devcontainer.json b/.devcontainer/cuda12.0-pip/devcontainer.json index f40db9312..f7f8ee591 100644 --- a/.devcontainer/cuda12.0-pip/devcontainer.json +++ b/.devcontainer/cuda12.0-pip/devcontainer.json @@ -5,12 +5,12 @@ "args": { "CUDA": "12.0", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:23.12-cpp-llvm16-cuda12.0-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.02-cpp-llvm16-cuda12.0-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:23.12": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.2": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index be052881c..2f2b1464f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -78,7 +78,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index aecbb9d9e..397ebfd15 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -22,40 +22,40 @@ jobs: - wheel-tests - devcontainer secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.02 checks: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.02 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.02 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.02 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.02 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.02 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.02 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -65,20 +65,20 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.02 with: build_type: pull-request script: ci/build_wheel.sh wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.02 with: build_type: pull-request script: ci/test_wheel.sh devcontainer: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.02 with: build_command: | sccache -z; diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 993852c94..a61209d0a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.02 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.02 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-23.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.02 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c883bc4c..e780ad5c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ include(rapids-find) project( RMM - VERSION 23.12.00 + VERSION 24.02.00 LANGUAGES CXX) # Write the version header diff --git a/VERSION b/VERSION index a193fff41..3c6c5e2b7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -23.12.00 +24.02.00 diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 7a23b8c83..e11a9f35b 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -25,7 +25,7 @@ rapids-mamba-retry install \ --channel "${PYTHON_CHANNEL}" \ rmm librmm -export RAPIDS_VERSION_NUMBER="23.12" +export RAPIDS_VERSION_NUMBER="24.02" export RAPIDS_DOCS_DIR="$(mktemp -d)" rapids-logger "Build CPP docs" diff --git a/ci/check_style.sh b/ci/check_style.sh index a01cf4dcc..9eed00298 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -14,7 +14,7 @@ rapids-dependency-file-generator \ rapids-mamba-retry env create --force -f env.yaml -n checks conda activate checks -FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.12/cmake-format-rapids-cmake.json +FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-24.02/cmake-format-rapids-cmake.json export RAPIDS_CMAKE_FORMAT_FILE=/tmp/rapids_cmake_ci/cmake-formats-rapids-cmake.json mkdir -p $(dirname ${RAPIDS_CMAKE_FORMAT_FILE}) wget -O ${RAPIDS_CMAKE_FORMAT_FILE} ${FORMAT_FILE_URL} diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 4e8f339b3..e956411f2 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = RMM # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 23.12 +PROJECT_NUMBER = 24.02 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/fetch_rapids.cmake b/fetch_rapids.cmake index 899db0467..86d447acb 100644 --- a/fetch_rapids.cmake +++ b/fetch_rapids.cmake @@ -12,7 +12,7 @@ # the License. # ============================================================================= if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-23.12/RAPIDS.cmake + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-24.02/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) endif() include(${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 475fa9434..35f034421 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) -set(rmm_version 23.12.00) +set(rmm_version 24.02.00) include(../fetch_rapids.cmake) diff --git a/python/docs/conf.py b/python/docs/conf.py index a063b52eb..88bfee344 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -24,9 +24,9 @@ # built documents. # # The short X.Y version. -version = "23.12" +version = "24.02" # The full version, including alpha/beta/rc tags. -release = "23.12.00" +release = "24.02.00" # -- General configuration --------------------------------------------------- From ba99ff403de8285dda7139fda00ba9acdb2ed709 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Wed, 15 Nov 2023 15:32:14 +1100 Subject: [PATCH 317/675] Store and set the correct CUDA device in device_buffer (#1370) This changes `device_buffer` to store the active CUDA device ID on creation, and (possibly temporarily) set the active device to that ID before allocating or freeing memory. It also adds tests for containers built on `device_buffer` (`device_buffer`, `device_uvector` and `device_scalar`) that ensure correct operation when the device is changed before doing things that alloc/dealloc memory for those containers. This fixes #1342 . HOWEVER, there is an important question yet to answer: `rmm::device_vector` is just an alias for `thrust::device_vector`, which does not use `rmm::device_buffer` for storage. However users may be surprised after this PR because the multidevice semantics of RMM containers will be different from `thrust::device_vector` (and therefore `rmm::device_vector`). Update: opinion is that it's probably OK to diverge from `device_vector`, and some think we should remove `rmm::device_vector`. ~While we discuss this I have set the DO NOT MERGE label.~ Authors: - Mark Harris (https://github.com/harrism) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Jake Hemstad (https://github.com/jrhemstad) URL: https://github.com/rapidsai/rmm/pull/1370 --- include/rmm/cuda_device.hpp | 38 +++++- include/rmm/device_buffer.hpp | 18 ++- tests/CMakeLists.txt | 3 + tests/container_multidevice_tests.cu | 149 ++++++++++++++++++++++++ tests/device_buffer_tests.cu | 7 +- tests/device_check_resource_adaptor.hpp | 77 ++++++++++++ 6 files changed, 283 insertions(+), 9 deletions(-) create mode 100644 tests/container_multidevice_tests.cu create mode 100644 tests/device_check_resource_adaptor.hpp diff --git a/include/rmm/cuda_device.hpp b/include/rmm/cuda_device.hpp index e4a35ee16..054bbb920 100644 --- a/include/rmm/cuda_device.hpp +++ b/include/rmm/cuda_device.hpp @@ -34,7 +34,7 @@ struct cuda_device_id { using value_type = int; ///< Integer type used for device identifier /** - * @brief Construct a `cuda_device_id` from the specified integer value + * @brief Construct a `cuda_device_id` from the specified integer value. * * @param dev_id The device's integer identifier */ @@ -43,6 +43,35 @@ struct cuda_device_id { /// @briefreturn{The wrapped integer value} [[nodiscard]] constexpr value_type value() const noexcept { return id_; } + // TODO re-add doxygen comment specifier /** for these hidden friend operators once this Breathe + // bug is fixed: https://github.com/breathe-doc/breathe/issues/916 + //! @cond Doxygen_Suppress + /** + * @brief Compare two `cuda_device_id`s for equality. + * + * @param lhs The first `cuda_device_id` to compare. + * @param rhs The second `cuda_device_id` to compare. + * @return true if the two `cuda_device_id`s wrap the same integer value, false otherwise. + */ + [[nodiscard]] constexpr friend bool operator==(cuda_device_id const& lhs, + cuda_device_id const& rhs) noexcept + { + return lhs.value() == rhs.value(); + } + + /** + * @brief Compare two `cuda_device_id`s for inequality. + * + * @param lhs The first `cuda_device_id` to compare. + * @param rhs The second `cuda_device_id` to compare. + * @return true if the two `cuda_device_id`s wrap different integer values, false otherwise. + */ + [[nodiscard]] constexpr friend bool operator!=(cuda_device_id const& lhs, + cuda_device_id const& rhs) noexcept + { + return lhs.value() != rhs.value(); + } + //! @endcond private: value_type id_; }; @@ -84,16 +113,17 @@ struct cuda_set_device_raii { * @param dev_id The device to set as the current CUDA device */ explicit cuda_set_device_raii(cuda_device_id dev_id) - : old_device_{get_current_cuda_device()}, needs_reset_{old_device_.value() != dev_id.value()} + : old_device_{get_current_cuda_device()}, + needs_reset_{dev_id.value() >= 0 && old_device_ != dev_id} { - if (needs_reset_) RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(dev_id.value())); + if (needs_reset_) { RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(dev_id.value())); } } /** * @brief Reactivates the previous CUDA device */ ~cuda_set_device_raii() noexcept { - if (needs_reset_) RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(old_device_.value())); + if (needs_reset_) { RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(old_device_.value())); } } cuda_set_device_raii(cuda_set_device_raii const&) = delete; diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index c69b9206b..20fa4f36e 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -15,6 +15,7 @@ */ #pragma once +#include #include #include #include @@ -109,6 +110,7 @@ class device_buffer { mr::device_memory_resource* mr = mr::get_current_device_resource()) : _stream{stream}, _mr{mr} { + cuda_set_device_raii dev{_device}; allocate_async(size); } @@ -137,6 +139,7 @@ class device_buffer { mr::device_memory_resource* mr = mr::get_current_device_resource()) : _stream{stream}, _mr{mr} { + cuda_set_device_raii dev{_device}; allocate_async(size); copy_async(source_data, size); } @@ -185,12 +188,14 @@ class device_buffer { _size{other._size}, _capacity{other._capacity}, _stream{other.stream()}, - _mr{other._mr} + _mr{other._mr}, + _device{other._device} { other._data = nullptr; other._size = 0; other._capacity = 0; other.set_stream(cuda_stream_view{}); + other._device = cuda_device_id{-1}; } /** @@ -210,18 +215,21 @@ class device_buffer { device_buffer& operator=(device_buffer&& other) noexcept { if (&other != this) { + cuda_set_device_raii dev{_device}; deallocate_async(); _data = other._data; _size = other._size; _capacity = other._capacity; set_stream(other.stream()); - _mr = other._mr; + _mr = other._mr; + _device = other._device; other._data = nullptr; other._size = 0; other._capacity = 0; other.set_stream(cuda_stream_view{}); + other._device = cuda_device_id{-1}; } return *this; } @@ -235,6 +243,7 @@ class device_buffer { */ ~device_buffer() noexcept { + cuda_set_device_raii dev{_device}; deallocate_async(); _mr = nullptr; _stream = cuda_stream_view{}; @@ -262,6 +271,7 @@ class device_buffer { { set_stream(stream); if (new_capacity > capacity()) { + cuda_set_device_raii dev{_device}; auto tmp = device_buffer{new_capacity, stream, _mr}; auto const old_size = size(); RMM_CUDA_TRY(cudaMemcpyAsync(tmp.data(), data(), size(), cudaMemcpyDefault, stream.value())); @@ -303,6 +313,7 @@ class device_buffer { if (new_size <= capacity()) { _size = new_size; } else { + cuda_set_device_raii dev{_device}; auto tmp = device_buffer{new_size, stream, _mr}; RMM_CUDA_TRY(cudaMemcpyAsync(tmp.data(), data(), size(), cudaMemcpyDefault, stream.value())); *this = std::move(tmp); @@ -326,6 +337,7 @@ class device_buffer { { set_stream(stream); if (size() != capacity()) { + cuda_set_device_raii dev{_device}; // Invoke copy ctor on self which only copies `[0, size())` and swap it // with self. The temporary `device_buffer` will hold the old contents // which will then be destroyed @@ -407,6 +419,7 @@ class device_buffer { mr::device_memory_resource* _mr{ mr::get_current_device_resource()}; ///< The memory resource used to ///< allocate/deallocate device memory + cuda_device_id _device{get_current_cuda_device()}; /** * @brief Allocates the specified amount of memory and updates the size/capacity accordingly. @@ -457,6 +470,7 @@ class device_buffer { { if (bytes > 0) { RMM_EXPECTS(nullptr != source, "Invalid copy from nullptr."); + RMM_EXPECTS(nullptr != _data, "Invalid copy to nullptr."); RMM_CUDA_TRY(cudaMemcpyAsync(_data, source, bytes, cudaMemcpyDefault, stream().value())); } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 36c3aa043..752496279 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -186,4 +186,7 @@ ConfigureTest(BINNING_MR_TEST mr/device/binning_mr_tests.cpp) # callback memory resource tests ConfigureTest(CALLBACK_MR_TEST mr/device/callback_mr_tests.cpp) +# container multidevice tests +ConfigureTest(CONTAINER_MULTIDEVICE_TEST container_multidevice_tests.cu) + rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing DESTINATION bin/gtests/librmm) diff --git a/tests/container_multidevice_tests.cu b/tests/container_multidevice_tests.cu new file mode 100644 index 000000000..9de9ddf40 --- /dev/null +++ b/tests/container_multidevice_tests.cu @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2023, 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. + */ + +#include "device_check_resource_adaptor.hpp" +#include "rmm/mr/device/per_device_resource.hpp" + +#include +#include +#include +#include + +#include + +#include + +template +struct ContainerMultiDeviceTest : public ::testing::Test {}; + +using containers = + ::testing::Types, rmm::device_scalar>; + +TYPED_TEST_CASE(ContainerMultiDeviceTest, containers); + +TYPED_TEST(ContainerMultiDeviceTest, CreateDestroyDifferentActiveDevice) +{ + // Get the number of cuda devices + int num_devices = rmm::get_num_cuda_devices(); + + // only run on multidevice systems + if (num_devices >= 2) { + rmm::cuda_set_device_raii dev{rmm::cuda_device_id{0}}; + auto* orig_mr = rmm::mr::get_current_device_resource(); + auto check_mr = device_check_resource_adaptor{orig_mr}; + rmm::mr::set_current_device_resource(&check_mr); + + { + if constexpr (std::is_same_v>) { + auto buf = TypeParam(rmm::cuda_stream_view{}); + RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(1)); // force dtor with different active device + } else { + auto buf = TypeParam(128, rmm::cuda_stream_view{}); + RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(1)); // force dtor with different active device + } + } + + RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(0)); + rmm::mr::set_current_device_resource(orig_mr); + } +} + +TYPED_TEST(ContainerMultiDeviceTest, CreateMoveDestroyDifferentActiveDevice) +{ + // Get the number of cuda devices + int num_devices = rmm::get_num_cuda_devices(); + + // only run on multidevice systems + if (num_devices >= 2) { + rmm::cuda_set_device_raii dev{rmm::cuda_device_id{0}}; + auto* orig_mr = rmm::mr::get_current_device_resource(); + auto check_mr = device_check_resource_adaptor{orig_mr}; + rmm::mr::set_current_device_resource(&check_mr); + + { + auto buf_1 = []() { + if constexpr (std::is_same_v>) { + return TypeParam(rmm::cuda_stream_view{}); + } else { + return TypeParam(128, rmm::cuda_stream_view{}); + } + }(); + + { + if constexpr (std::is_same_v>) { + // device_vector does not have a constructor that takes a stream + auto buf_0 = TypeParam(rmm::cuda_stream_view{}); + buf_1 = std::move(buf_0); + } else { + auto buf_0 = TypeParam(128, rmm::cuda_stream_view{}); + buf_1 = std::move(buf_0); + } + } + + RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(1)); // force dtor with different active device + } + + RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(0)); + rmm::mr::set_current_device_resource(orig_mr); + } +} + +TYPED_TEST(ContainerMultiDeviceTest, ResizeDifferentActiveDevice) +{ + // Get the number of cuda devices + int num_devices = rmm::get_num_cuda_devices(); + + // only run on multidevice systems + if (num_devices >= 2) { + rmm::cuda_set_device_raii dev{rmm::cuda_device_id{0}}; + auto* orig_mr = rmm::mr::get_current_device_resource(); + auto check_mr = device_check_resource_adaptor{orig_mr}; + rmm::mr::set_current_device_resource(&check_mr); + + if constexpr (not std::is_same_v>) { + auto buf = TypeParam(128, rmm::cuda_stream_view{}); + RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(1)); // force resize with different active device + buf.resize(1024, rmm::cuda_stream_view{}); + } + + RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(0)); + rmm::mr::set_current_device_resource(orig_mr); + } +} + +TYPED_TEST(ContainerMultiDeviceTest, ShrinkDifferentActiveDevice) +{ + // Get the number of cuda devices + int num_devices = rmm::get_num_cuda_devices(); + + // only run on multidevice systems + if (num_devices >= 2) { + rmm::cuda_set_device_raii dev{rmm::cuda_device_id{0}}; + auto* orig_mr = rmm::mr::get_current_device_resource(); + auto check_mr = device_check_resource_adaptor{orig_mr}; + rmm::mr::set_current_device_resource(&check_mr); + + if constexpr (not std::is_same_v>) { + auto buf = TypeParam(128, rmm::cuda_stream_view{}); + RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(1)); // force resize with different active device + buf.resize(64, rmm::cuda_stream_view{}); + buf.shrink_to_fit(rmm::cuda_stream_view{}); + } + + RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(0)); + rmm::mr::set_current_device_resource(orig_mr); + } +} diff --git a/tests/device_buffer_tests.cu b/tests/device_buffer_tests.cu index d4c34385e..e0d8e5555 100644 --- a/tests/device_buffer_tests.cu +++ b/tests/device_buffer_tests.cu @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include #include #include @@ -29,9 +27,12 @@ #include #include + +#include + namespace testing { namespace thrust = THRUST_NS_QUALIFIER; -} +} // namespace testing using namespace testing; #include diff --git a/tests/device_check_resource_adaptor.hpp b/tests/device_check_resource_adaptor.hpp new file mode 100644 index 000000000..f9ad4cf70 --- /dev/null +++ b/tests/device_check_resource_adaptor.hpp @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2023, 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. + */ + +#include +#include +#include + +#include + +class device_check_resource_adaptor final : public rmm::mr::device_memory_resource { + public: + device_check_resource_adaptor(rmm::mr::device_memory_resource* upstream) + : device_id{rmm::get_current_cuda_device()}, upstream_(upstream) + { + } + + [[nodiscard]] bool supports_streams() const noexcept override + { + return upstream_->supports_streams(); + } + + [[nodiscard]] bool supports_get_mem_info() const noexcept override + { + return upstream_->supports_get_mem_info(); + } + + [[nodiscard]] device_memory_resource* get_upstream() const noexcept { return upstream_; } + + private: + [[nodiscard]] bool check_device_id() const { return device_id == rmm::get_current_cuda_device(); } + + void* do_allocate(std::size_t bytes, rmm::cuda_stream_view stream) override + { + bool const is_correct_device = check_device_id(); + EXPECT_TRUE(is_correct_device); + if (is_correct_device) { return upstream_->allocate(bytes, stream); } + return nullptr; + } + + void do_deallocate(void* ptr, std::size_t bytes, rmm::cuda_stream_view stream) override + { + bool const is_correct_device = check_device_id(); + EXPECT_TRUE(is_correct_device); + if (is_correct_device) { upstream_->deallocate(ptr, bytes, stream); } + } + + [[nodiscard]] bool do_is_equal( + rmm::mr::device_memory_resource const& other) const noexcept override + { + if (this == &other) { return true; } + auto const* cast = dynamic_cast(&other); + if (cast != nullptr) { return upstream_->is_equal(*cast->get_upstream()); } + return upstream_->is_equal(other); + } + + [[nodiscard]] std::pair do_get_mem_info( + rmm::cuda_stream_view stream) const override + { + return upstream_->get_mem_info(stream); + } + + rmm::cuda_device_id device_id; + rmm::mr::device_memory_resource* upstream_{}; +}; From 6acae3c2f41638115a518bf7491c004d8f642489 Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Thu, 16 Nov 2023 16:23:49 -0800 Subject: [PATCH 318/675] Use `cuda::mr::memory_resource` instead of raw `device_memory_resource` (#1095) This introduces `cuda::mr::{async_}resource_ref` as a type erased safe resource wrapper that is meant to replace uses of `{host, device}_memory_resource` We provide both async and classic allocate functions that delegate back to the original resource used to construct the `cuda::mr::{async_}resource_ref` In comparison to `{host, device}_memory_resource` the new feature provides additional compile time checks that will help users avoid common pitfalls with heterogeneous memory allocations. As a first step we provide the properties `cuda::mr::host_accessible` and `cuda::mr::device_accessible`. These properties can be added to an internal or even external type through a free function `get_property` ```cpp // For a user defined resource struct my_resource { friend void get_property(my_resource const&, cuda::mr::device_accessible) noexcept {} }; // For an external resource void get_property(some_external_resource const&, cuda::mr::device_accessible) noexcept {} ``` The advantage is that we can constrain interfaces based on these properties ```cpp void do_some_computation_on_device(cuda::mr::async_resource_ref mr, ...) { ... } ``` This function will fail to compile if it is passed any resource that does not support async allocations or is not tagged as providing device accessible memory. In the same way the following function will only compile if the provided resource provides the classic allocate / deallocate interface and is tagged to provide host accessible memory ```cpp void do_some_computation_on_host(cuda::mr::resource_ref mr, ...) { ... } ``` The property system is highly flexible and can easily be user provided to add their own properties as needed. That gives it both the flexibility of an inheritance based implementation and the security of a strictly type checked interface Authors: - Michael Schellenberger Costa (https://github.com/miscco) - Bradley Dice (https://github.com/bdice) - Mark Harris (https://github.com/harrism) Approvers: - Jake Hemstad (https://github.com/jrhemstad) - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1095 --- CMakeLists.txt | 3 + cmake/thirdparty/get_libcudacxx.cmake | 23 + include/rmm/cuda_stream_view.hpp | 16 + include/rmm/device_buffer.hpp | 26 +- include/rmm/device_uvector.hpp | 21 +- .../mr/device/callback_memory_resource.hpp | 4 +- .../rmm/mr/device/device_memory_resource.hpp | 146 ++++++- .../rmm/mr/device/pool_memory_resource.hpp | 71 ++- .../mr/device/thrust_allocator_adaptor.hpp | 26 +- include/rmm/mr/host/host_memory_resource.hpp | 35 ++ .../rmm/mr/host/pinned_memory_resource.hpp | 81 ++++ python/docs/conf.py | 12 + python/rmm/tests/test_rmm.py | 32 +- tests/CMakeLists.txt | 10 + tests/device_buffer_tests.cu | 47 +- tests/device_uvector_tests.cpp | 5 +- tests/mr/device/adaptor_tests.cpp | 19 + tests/mr/device/cuda_async_mr_tests.cpp | 2 + tests/mr/device/cuda_async_view_mr_tests.cpp | 4 + .../mr/device/mr_ref_multithreaded_tests.cpp | 232 ++++++++++ tests/mr/device/mr_ref_test.hpp | 408 ++++++++++++++++++ tests/mr/device/mr_ref_tests.cpp | 109 +++++ tests/mr/device/mr_test.hpp | 4 - tests/mr/device/pool_mr_tests.cpp | 51 +++ tests/mr/device/thrust_allocator_tests.cu | 4 +- tests/mr/host/mr_ref_tests.cpp | 258 +++++++++++ tests/mr/host/mr_tests.cpp | 8 +- tests/mr/host/pinned_pool_mr_tests.cpp | 96 +++++ 28 files changed, 1664 insertions(+), 89 deletions(-) create mode 100644 cmake/thirdparty/get_libcudacxx.cmake create mode 100644 tests/mr/device/mr_ref_multithreaded_tests.cpp create mode 100644 tests/mr/device/mr_ref_test.hpp create mode 100644 tests/mr/device/mr_ref_tests.cpp create mode 100644 tests/mr/host/mr_ref_tests.cpp create mode 100644 tests/mr/host/pinned_pool_mr_tests.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c883bc4c..93fcdabe9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,7 @@ rapids_cpm_init() include(cmake/thirdparty/get_fmt.cmake) include(cmake/thirdparty/get_spdlog.cmake) +include(cmake/thirdparty/get_libcudacxx.cmake) include(cmake/thirdparty/get_thrust.cmake) # ################################################################################################## @@ -89,11 +90,13 @@ else() target_link_libraries(rmm INTERFACE CUDA::cudart) endif() +target_link_libraries(rmm INTERFACE libcudacxx::libcudacxx) target_link_libraries(rmm INTERFACE rmm::Thrust) target_link_libraries(rmm INTERFACE fmt::fmt-header-only) target_link_libraries(rmm INTERFACE spdlog::spdlog_header_only) target_link_libraries(rmm INTERFACE dl) target_compile_features(rmm INTERFACE cxx_std_17 $) +target_compile_definitions(rmm INTERFACE LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE) # ################################################################################################## # * tests and benchmarks --------------------------------------------------------------------------- diff --git a/cmake/thirdparty/get_libcudacxx.cmake b/cmake/thirdparty/get_libcudacxx.cmake new file mode 100644 index 000000000..14b0d492f --- /dev/null +++ b/cmake/thirdparty/get_libcudacxx.cmake @@ -0,0 +1,23 @@ +# ============================================================================= +# Copyright (c) 2023, 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. +# ============================================================================= + +# Use CPM to find or clone libcudacxx +function(find_and_configure_libcudacxx) + + include(${rapids-cmake-dir}/cpm/libcudacxx.cmake) + rapids_cpm_libcudacxx(BUILD_EXPORT_SET rmm-exports INSTALL_EXPORT_SET rmm-exports) + +endfunction() + +find_and_configure_libcudacxx() diff --git a/include/rmm/cuda_stream_view.hpp b/include/rmm/cuda_stream_view.hpp index 7809140fb..f8564b16b 100644 --- a/include/rmm/cuda_stream_view.hpp +++ b/include/rmm/cuda_stream_view.hpp @@ -20,6 +20,8 @@ #include +#include + #include #include #include @@ -58,6 +60,13 @@ class cuda_stream_view { */ constexpr cuda_stream_view(cudaStream_t stream) noexcept : stream_{stream} {} + /** + * @brief Implicit conversion from stream_ref. + * + * @param stream The underlying stream for this view + */ + constexpr cuda_stream_view(cuda::stream_ref stream) noexcept : stream_{stream.get()} {} + /** * @brief Get the wrapped stream. * @@ -72,6 +81,13 @@ class cuda_stream_view { */ constexpr operator cudaStream_t() const noexcept { return value(); } + /** + * @brief Implicit conversion to stream_ref. + * + * @return stream_ref The underlying stream referenced by this cuda_stream_view + */ + constexpr operator cuda::stream_ref() const noexcept { return value(); } + /** * @briefreturn{true if the wrapped stream is the CUDA per-thread default stream} */ diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index 20fa4f36e..4a780018e 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -28,6 +28,8 @@ #include #include +#include + namespace rmm { /** * @addtogroup data_containers @@ -80,6 +82,8 @@ namespace rmm { *``` */ class device_buffer { + using async_resource_ref = cuda::mr::async_resource_ref; + public: // The copy constructor and copy assignment operator without a stream are deleted because they // provide no way to specify an explicit stream @@ -107,7 +111,7 @@ class device_buffer { */ explicit device_buffer(std::size_t size, cuda_stream_view stream, - mr::device_memory_resource* mr = mr::get_current_device_resource()) + async_resource_ref mr = mr::get_current_device_resource()) : _stream{stream}, _mr{mr} { cuda_set_device_raii dev{_device}; @@ -136,7 +140,7 @@ class device_buffer { device_buffer(void const* source_data, std::size_t size, cuda_stream_view stream, - mr::device_memory_resource* mr = mr::get_current_device_resource()) + async_resource_ref mr = rmm::mr::get_current_device_resource()) : _stream{stream}, _mr{mr} { cuda_set_device_raii dev{_device}; @@ -167,7 +171,7 @@ class device_buffer { */ device_buffer(device_buffer const& other, cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) + async_resource_ref mr = rmm::mr::get_current_device_resource()) : device_buffer{other.data(), other.size(), stream, mr} { } @@ -245,7 +249,6 @@ class device_buffer { { cuda_set_device_raii dev{_device}; deallocate_async(); - _mr = nullptr; _stream = cuda_stream_view{}; } @@ -407,18 +410,19 @@ class device_buffer { void set_stream(cuda_stream_view stream) noexcept { _stream = stream; } /** - * @briefreturn{Pointer to the memory resource used to allocate and deallocate} + * @briefreturn{The async_resource_ref used to allocate and deallocate} */ - [[nodiscard]] mr::device_memory_resource* memory_resource() const noexcept { return _mr; } + [[nodiscard]] async_resource_ref memory_resource() const noexcept { return _mr; } private: void* _data{nullptr}; ///< Pointer to device memory allocation std::size_t _size{}; ///< Requested size of the device memory allocation std::size_t _capacity{}; ///< The actual size of the device memory allocation cuda_stream_view _stream{}; ///< Stream to use for device memory deallocation - mr::device_memory_resource* _mr{ - mr::get_current_device_resource()}; ///< The memory resource used to - ///< allocate/deallocate device memory + + async_resource_ref _mr{ + rmm::mr::get_current_device_resource()}; ///< The memory resource used to + ///< allocate/deallocate device memory cuda_device_id _device{get_current_cuda_device()}; /** @@ -434,7 +438,7 @@ class device_buffer { { _size = bytes; _capacity = bytes; - _data = (bytes > 0) ? memory_resource()->allocate(bytes, stream()) : nullptr; + _data = (bytes > 0) ? _mr.allocate_async(bytes, stream()) : nullptr; } /** @@ -448,7 +452,7 @@ class device_buffer { */ void deallocate_async() noexcept { - if (capacity() > 0) { memory_resource()->deallocate(data(), capacity(), stream()); } + if (capacity() > 0) { _mr.deallocate_async(data(), capacity(), stream()); } _size = 0; _capacity = 0; _data = nullptr; diff --git a/include/rmm/device_uvector.hpp b/include/rmm/device_uvector.hpp index 982d2095d..3f77f59f7 100644 --- a/include/rmm/device_uvector.hpp +++ b/include/rmm/device_uvector.hpp @@ -26,6 +26,8 @@ #include #include +#include + namespace rmm { /** * @addtogroup data_containers @@ -72,6 +74,7 @@ namespace rmm { */ template class device_uvector { + using async_resource_ref = cuda::mr::async_resource_ref; static_assert(std::is_trivially_copyable::value, "device_uvector only supports types that are trivially copyable."); @@ -121,10 +124,9 @@ class device_uvector { * @param stream The stream on which to perform the allocation * @param mr The resource used to allocate the device storage */ - explicit device_uvector( - std::size_t size, - cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) + explicit device_uvector(std::size_t size, + cuda_stream_view stream, + async_resource_ref mr = rmm::mr::get_current_device_resource()) : _storage{elements_to_bytes(size), stream, mr} { } @@ -138,10 +140,9 @@ class device_uvector { * @param stream The stream on which to perform the copy * @param mr The resource used to allocate device memory for the new vector */ - explicit device_uvector( - device_uvector const& other, - cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) + explicit device_uvector(device_uvector const& other, + cuda_stream_view stream, + async_resource_ref mr = rmm::mr::get_current_device_resource()) : _storage{other._storage, stream, mr} { } @@ -524,9 +525,9 @@ class device_uvector { [[nodiscard]] bool is_empty() const noexcept { return size() == 0; } /** - * @briefreturn{Pointer to underlying resource used to allocate and deallocate the device storage} + * @briefreturn{The async_resource_ref used to allocate and deallocate the device storage} */ - [[nodiscard]] mr::device_memory_resource* memory_resource() const noexcept + [[nodiscard]] async_resource_ref memory_resource() const noexcept { return _storage.memory_resource(); } diff --git a/include/rmm/mr/device/callback_memory_resource.hpp b/include/rmm/mr/device/callback_memory_resource.hpp index c6519ed5c..36802c83a 100644 --- a/include/rmm/mr/device/callback_memory_resource.hpp +++ b/include/rmm/mr/device/callback_memory_resource.hpp @@ -143,8 +143,8 @@ class callback_memory_resource final : public device_memory_resource { throw std::runtime_error("cannot get free / total memory"); } - [[nodiscard]] virtual bool supports_streams() const noexcept { return false; } - [[nodiscard]] virtual bool supports_get_mem_info() const noexcept { return false; } + [[nodiscard]] bool supports_streams() const noexcept override { return false; } + [[nodiscard]] bool supports_get_mem_info() const noexcept override { return false; } allocate_callback_t allocate_callback_; deallocate_callback_t deallocate_callback_; diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index bda52ac67..63e5f39a4 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -18,6 +18,8 @@ #include #include +#include + #include #include @@ -119,7 +121,7 @@ class device_memory_resource { /** * @brief Deallocate memory pointed to by \p p. * - * `p` must have been returned by a prior call to `allocate(bytes,stream)` on + * `p` must have been returned by a prior call to `allocate(bytes, stream)` on * a `device_memory_resource` that compares equal to `*this`, and the storage * it points to must not yet have been deallocated, otherwise behavior is * undefined. @@ -155,6 +157,140 @@ class device_memory_resource { return do_is_equal(other); } + /** + * @brief Allocates memory of size at least \p bytes. + * + * The returned pointer will have at minimum 256 byte alignment. + * + * @throws rmm::bad_alloc When the requested `bytes` cannot be allocated on + * the specified `stream`. + * + * @param bytes The size of the allocation + * @param alignment The expected alignment of the allocation + * @return void* Pointer to the newly allocated memory + */ + void* allocate(std::size_t bytes, std::size_t alignment) + { + return do_allocate(rmm::detail::align_up(bytes, alignment), cuda_stream_view{}); + } + + /** + * @brief Deallocate memory pointed to by \p p. + * + * `p` must have been returned by a prior call to `allocate(bytes, stream)` on + * a `device_memory_resource` that compares equal to `*this`, and the storage + * it points to must not yet have been deallocated, otherwise behavior is + * undefined. + * + * @param ptr Pointer to be deallocated + * @param bytes The size in bytes of the allocation. This must be equal to the + * value of `bytes` that was passed to the `allocate` call that returned `p`. + * @param alignment The alignment that was passed to the `allocate` call that returned `p` + */ + void deallocate(void* ptr, std::size_t bytes, std::size_t alignment) + { + do_deallocate(ptr, rmm::detail::align_up(bytes, alignment), cuda_stream_view{}); + } + + /** + * @brief Allocates memory of size at least \p bytes. + * + * The returned pointer will have at minimum 256 byte alignment. + * + * @throws rmm::bad_alloc When the requested `bytes` cannot be allocated on + * the specified `stream`. + * + * @param bytes The size of the allocation + * @param alignment The expected alignment of the allocation + * @param stream Stream on which to perform allocation + * @return void* Pointer to the newly allocated memory + */ + void* allocate_async(std::size_t bytes, std::size_t alignment, cuda_stream_view stream) + { + return do_allocate(rmm::detail::align_up(bytes, alignment), stream); + } + + /** + * @brief Allocates memory of size at least \p bytes. + * + * The returned pointer will have at minimum 256 byte alignment. + * + * @throws rmm::bad_alloc When the requested `bytes` cannot be allocated on + * the specified `stream`. + * + * @param bytes The size of the allocation + * @param stream Stream on which to perform allocation + * @return void* Pointer to the newly allocated memory + */ + void* allocate_async(std::size_t bytes, cuda_stream_view stream) + { + return do_allocate(bytes, stream); + } + + /** + * @brief Deallocate memory pointed to by \p p. + * + * `p` must have been returned by a prior call to `allocate(bytes, stream)` on + * a `device_memory_resource` that compares equal to `*this`, and the storage + * it points to must not yet have been deallocated, otherwise behavior is + * undefined. + * + * @param ptr Pointer to be deallocated + * @param bytes The size in bytes of the allocation. This must be equal to the + * value of `bytes` that was passed to the `allocate` call that returned `p`. + * @param alignment The alignment that was passed to the `allocate` call that returned `p` + * @param stream Stream on which to perform allocation + */ + void deallocate_async(void* ptr, + std::size_t bytes, + std::size_t alignment, + cuda_stream_view stream) + { + do_deallocate(ptr, rmm::detail::align_up(bytes, alignment), stream); + } + + /** + * @brief Deallocate memory pointed to by \p p. + * + * `p` must have been returned by a prior call to `allocate(bytes, stream)` on + * a `device_memory_resource` that compares equal to `*this`, and the storage + * it points to must not yet have been deallocated, otherwise behavior is + * undefined. + * + * @param ptr Pointer to be deallocated + * @param bytes The size in bytes of the allocation. This must be equal to the + * value of `bytes` that was passed to the `allocate` call that returned `p`. + * @param stream Stream on which to perform allocation + */ + void deallocate_async(void* ptr, std::size_t bytes, cuda_stream_view stream) + { + do_deallocate(ptr, bytes, stream); + } + + /** + * @brief Comparison operator with another device_memory_resource + * + * @param other The other resource to compare to + * @return true If the two resources are equivalent + * @return false If the two resources are not equivalent + */ + [[nodiscard]] bool operator==(device_memory_resource const& other) const noexcept + { + return do_is_equal(other); + } + + /** + * @brief Comparison operator with another device_memory_resource + * + * @param other The other resource to compare to + * @return false If the two resources are equivalent + * @return true If the two resources are not equivalent + */ + [[nodiscard]] bool operator!=(device_memory_resource const& other) const noexcept + { + return !do_is_equal(other); + } + /** * @brief Query whether the resource supports use of non-null CUDA streams for * allocation/deallocation. @@ -183,6 +319,13 @@ class device_memory_resource { return do_get_mem_info(stream); } + /** + * @brief Enables the `cuda::mr::device_accessible` property + * + * This property declares that a `device_memory_resource` provides device accessible memory + */ + friend void get_property(device_memory_resource const&, cuda::mr::device_accessible) noexcept {} + private: /** * @brief Allocates memory of size at least \p bytes. @@ -241,5 +384,6 @@ class device_memory_resource { [[nodiscard]] virtual std::pair do_get_mem_info( cuda_stream_view stream) const = 0; }; +static_assert(cuda::mr::async_resource_with); /** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index f6d3710e9..c85408359 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -51,6 +51,36 @@ namespace rmm::mr { * @{ * @file */ +namespace detail { +/** + * @brief A helper class to remove the device_accessible property + * + * We want to be able to use the pool_memory_resource with an upstream that may not + * be device accessible. To avoid rewriting the world, we allow conditionally removing + * the cuda::mr::device_accessible property. + * + * @tparam PoolResource the pool_memory_resource class + * @tparam Upstream memory_resource to use for allocating the pool. + * @tparam Property The property we want to potentially remove. + */ +template +struct maybe_remove_property {}; + +/** + * @brief Specialization of maybe_remove_property to not propagate nonexistent properties + */ +template +struct maybe_remove_property>> { + /** + * @brief Explicit removal of the friend function so we do not pretend to provide device + * accessible memory + */ + friend void get_property(const PoolResource&, Property) = delete; +}; +} // namespace detail /** * @brief A coalescing best-fit suballocator which uses a pool of memory allocated from @@ -64,8 +94,11 @@ namespace rmm::mr { */ template class pool_memory_resource final - : public detail::stream_ordered_memory_resource, - detail::coalescing_free_list> { + : public detail:: + maybe_remove_property, Upstream, cuda::mr::device_accessible>, + public detail::stream_ordered_memory_resource, + detail::coalescing_free_list>, + public cuda::forward_property, Upstream> { public: friend class detail::stream_ordered_memory_resource, detail::coalescing_free_list>; @@ -104,6 +137,31 @@ class pool_memory_resource final initialize_pool(initial_pool_size, maximum_pool_size); } + /** + * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using + * `upstream_mr`. + * + * @throws rmm::logic_error if `upstream_mr == nullptr` + * @throws rmm::logic_error if `initial_pool_size` is neither the default nor aligned to a + * multiple of pool_memory_resource::allocation_alignment bytes. + * @throws rmm::logic_error if `maximum_pool_size` is neither the default nor aligned to a + * multiple of pool_memory_resource::allocation_alignment bytes. + * + * @param upstream_mr The memory_resource from which to allocate blocks for the pool. + * @param initial_pool_size Minimum size, in bytes, of the initial pool. Defaults to half of the + * available memory on the current device. + * @param maximum_pool_size Maximum size, in bytes, that the pool can grow to. Defaults to all + * of the available memory on the current device. + */ + template , int> = 0> + explicit pool_memory_resource(Upstream2& upstream_mr, + thrust::optional initial_pool_size = thrust::nullopt, + thrust::optional maximum_pool_size = thrust::nullopt) + : pool_memory_resource(cuda::std::addressof(upstream_mr), initial_pool_size, maximum_pool_size) + { + } + /** * @brief Destroy the `pool_memory_resource` and deallocate all memory it allocated using * the upstream resource. @@ -131,6 +189,13 @@ class pool_memory_resource final */ [[nodiscard]] bool supports_get_mem_info() const noexcept override { return false; } + /** + * @brief Get the upstream memory_resource object. + * + * @return const reference to the upstream memory resource. + */ + [[nodiscard]] const Upstream& upstream_resource() const noexcept { return *upstream_mr_; } + /** * @brief Get the upstream memory_resource object. * @@ -296,7 +361,7 @@ class pool_memory_resource final if (size == 0) { return {}; } try { - void* ptr = get_upstream()->allocate(size, stream); + void* ptr = get_upstream()->allocate_async(size, stream); return thrust::optional{ *upstream_blocks_.emplace(static_cast(ptr), size, true).first}; } catch (std::exception const& e) { diff --git a/include/rmm/mr/device/thrust_allocator_adaptor.hpp b/include/rmm/mr/device/thrust_allocator_adaptor.hpp index a1386a842..562a0d79e 100644 --- a/include/rmm/mr/device/thrust_allocator_adaptor.hpp +++ b/include/rmm/mr/device/thrust_allocator_adaptor.hpp @@ -24,6 +24,8 @@ #include #include +#include + namespace rmm::mr { /** * @addtogroup device_resource_adaptors @@ -42,6 +44,8 @@ namespace rmm::mr { */ template class thrust_allocator : public thrust::device_malloc_allocator { + using async_resource_ref = cuda::mr::async_resource_ref; + public: using Base = thrust::device_malloc_allocator; ///< The base type of this allocator using pointer = typename Base::pointer; ///< The pointer type @@ -79,9 +83,7 @@ class thrust_allocator : public thrust::device_malloc_allocator { * @param mr The resource to be used for device memory allocation * @param stream The stream to be used for device memory (de)allocation */ - thrust_allocator(cuda_stream_view stream, device_memory_resource* mr) : _stream{stream}, _mr(mr) - { - } + thrust_allocator(cuda_stream_view stream, async_resource_ref mr) : _stream{stream}, _mr(mr) {} /** * @brief Copy constructor. Copies the resource pointer and stream. @@ -102,7 +104,8 @@ class thrust_allocator : public thrust::device_malloc_allocator { */ pointer allocate(size_type num) { - return thrust::device_pointer_cast(static_cast(_mr->allocate(num * sizeof(T), _stream))); + return thrust::device_pointer_cast( + static_cast(_mr.allocate_async(num * sizeof(T), _stream))); } /** @@ -114,22 +117,29 @@ class thrust_allocator : public thrust::device_malloc_allocator { */ void deallocate(pointer ptr, size_type num) { - return _mr->deallocate(thrust::raw_pointer_cast(ptr), num * sizeof(T), _stream); + return _mr.deallocate_async(thrust::raw_pointer_cast(ptr), num * sizeof(T), _stream); } /** - * @briefreturn{The device memory resource used by this} + * @briefreturn{The async_resource_ref used to allocate and deallocate} */ - [[nodiscard]] device_memory_resource* resource() const noexcept { return _mr; } + [[nodiscard]] async_resource_ref memory_resource() const noexcept { return _mr; } /** * @briefreturn{The stream used by this allocator} */ [[nodiscard]] cuda_stream_view stream() const noexcept { return _stream; } + /** + * @brief Enables the `cuda::mr::device_accessible` property + * + * This property declares that a `thrust_allocator` provides device accessible memory + */ + friend void get_property(thrust_allocator const&, cuda::mr::device_accessible) noexcept {} + private: cuda_stream_view _stream{}; - device_memory_resource* _mr{rmm::mr::get_current_device_resource()}; + async_resource_ref _mr{rmm::mr::get_current_device_resource()}; }; /** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/host/host_memory_resource.hpp b/include/rmm/mr/host/host_memory_resource.hpp index 3f6f90785..ce870287c 100644 --- a/include/rmm/mr/host/host_memory_resource.hpp +++ b/include/rmm/mr/host/host_memory_resource.hpp @@ -15,6 +15,8 @@ */ #pragma once +#include + #include #include @@ -112,6 +114,37 @@ class host_memory_resource { return do_is_equal(other); } + /** + * @brief Comparison operator with another device_memory_resource + * + * @param other The other resource to compare to + * @return true If the two resources are equivalent + * @return false If the two resources are not equivalent + */ + [[nodiscard]] bool operator==(host_memory_resource const& other) const noexcept + { + return do_is_equal(other); + } + + /** + * @brief Comparison operator with another device_memory_resource + * + * @param other The other resource to compare to + * @return false If the two resources are equivalent + * @return true If the two resources are not equivalent + */ + [[nodiscard]] bool operator!=(host_memory_resource const& other) const noexcept + { + return !do_is_equal(other); + } + + /** + * @brief Enables the `cuda::mr::host_accessible` property + * + * This property declares that a `host_memory_resource` provides host accessible memory + */ + friend void get_property(host_memory_resource const&, cuda::mr::host_accessible) noexcept {} + private: /** * @brief Allocates memory on the host of size at least `bytes` bytes. @@ -162,5 +195,7 @@ class host_memory_resource { return this == &other; } }; +static_assert(cuda::mr::resource_with); /** @} */ // end of group + } // namespace rmm::mr diff --git a/include/rmm/mr/host/pinned_memory_resource.hpp b/include/rmm/mr/host/pinned_memory_resource.hpp index f8d08f66c..e49767faf 100644 --- a/include/rmm/mr/host/pinned_memory_resource.hpp +++ b/include/rmm/mr/host/pinned_memory_resource.hpp @@ -15,6 +15,7 @@ */ #pragma once +#include #include #include #include @@ -46,6 +47,83 @@ class pinned_memory_resource final : public host_memory_resource { pinned_memory_resource& operator=(pinned_memory_resource&&) = default; ///< @default_move_assignment{pinned_memory_resource} + /** + * @brief Query whether the pinned_memory_resource supports use of non-null CUDA streams for + * allocation/deallocation. + * + * @returns bool false. + */ + [[nodiscard]] bool supports_streams() const noexcept { return false; } + + /** + * @brief Query whether the resource supports the get_mem_info API. + * + * @return bool false. + */ + [[nodiscard]] bool supports_get_mem_info() const noexcept { return false; } + + /** + * @brief Queries the amount of free and total memory for the resource. + * + * @param stream the stream whose memory manager we want to retrieve + * + * @returns a pair containing the free memory in bytes in .first and total amount of memory in + * .second + */ + [[nodiscard]] std::pair get_mem_info(cuda_stream_view stream) const + { + return std::make_pair(0, 0); + } + + /** + * @brief Pretend to support the allocate_async interface, falling back to stream 0 + * + * @throws rmm::bad_alloc When the requested `bytes` cannot be allocated on + * the specified `stream`. + * + * @param bytes The size of the allocation + * @param alignment The expected alignment of the allocation + * @return void* Pointer to the newly allocated memory + */ + [[nodiscard]] void* allocate_async(std::size_t bytes, std::size_t alignment, cuda_stream_view) + { + return do_allocate(bytes, alignment); + } + + /** + * @brief Pretend to support the allocate_async interface, falling back to stream 0 + * + * @throws rmm::bad_alloc When the requested `bytes` cannot be allocated on + * the specified `stream`. + * + * @param bytes The size of the allocation + * @return void* Pointer to the newly allocated memory + */ + [[nodiscard]] void* allocate_async(std::size_t bytes, cuda_stream_view) + { + return do_allocate(bytes); + } + + /** + * @brief Pretend to support the deallocate_async interface, falling back to stream 0 + * + * @param ptr Pointer to be deallocated + * @param bytes The size in bytes of the allocation. This must be equal to the + * value of `bytes` that was passed to the `allocate` call that returned `p`. + * @param alignment The alignment that was passed to the `allocate` call that returned `p` + */ + void deallocate_async(void* ptr, std::size_t bytes, std::size_t alignment, cuda_stream_view) + { + do_deallocate(ptr, rmm::detail::align_up(bytes, alignment)); + } + + /** + * @brief Enables the `cuda::mr::device_accessible` property + * + * This property declares that a `pinned_memory_resource` provides device accessible memory + */ + friend void get_property(pinned_memory_resource const&, cuda::mr::device_accessible) noexcept {} + private: /** * @brief Allocates pinned memory on the host of size at least `bytes` bytes. @@ -99,5 +177,8 @@ class pinned_memory_resource final : public host_memory_resource { ptr, bytes, alignment, [](void* ptr) { RMM_ASSERT_CUDA_SUCCESS(cudaFreeHost(ptr)); }); } }; +static_assert(cuda::mr::async_resource_with); /** @} */ // end of group } // namespace rmm::mr diff --git a/python/docs/conf.py b/python/docs/conf.py index a063b52eb..ec6ddc70a 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -216,6 +216,18 @@ def on_missing_reference(app, env, node, contnode): "cudaStreamPerThread", "thrust", "spdlog", + "stream_ref", + # libcu++ names + "cuda", + "cuda::mr", + "resource", + "resource_ref", + "async_resource", + "async_resource_ref", + "device_accessible", + "host_accessible", + "forward_property", + "enable_if_t", # Unknown types "int64_t", "int8_t", diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index fd537749b..b5dc81c1f 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -630,11 +630,11 @@ def test_statistics_resource_adaptor(stats_mr): del buffers[i] assert stats_mr.allocation_counts == { - "current_bytes": 5000, + "current_bytes": 5040, "current_count": 5, - "peak_bytes": 10000, + "peak_bytes": 10080, "peak_count": 10, - "total_bytes": 10000, + "total_bytes": 10080, "total_count": 10, } @@ -646,19 +646,19 @@ def test_statistics_resource_adaptor(stats_mr): buffers.append(rmm.DeviceBuffer(size=1000)) assert mr2.allocation_counts == { - "current_bytes": 2000, + "current_bytes": 2016, "current_count": 2, - "peak_bytes": 2000, + "peak_bytes": 2016, "peak_count": 2, - "total_bytes": 2000, + "total_bytes": 2016, "total_count": 2, } assert stats_mr.allocation_counts == { - "current_bytes": 7000, + "current_bytes": 7056, "current_count": 7, - "peak_bytes": 10000, + "peak_bytes": 10080, "peak_count": 10, - "total_bytes": 12000, + "total_bytes": 12096, "total_count": 12, } @@ -668,17 +668,17 @@ def test_statistics_resource_adaptor(stats_mr): assert mr2.allocation_counts == { "current_bytes": 0, "current_count": 0, - "peak_bytes": 2000, + "peak_bytes": 2016, "peak_count": 2, - "total_bytes": 2000, + "total_bytes": 2016, "total_count": 2, } assert stats_mr.allocation_counts == { "current_bytes": 0, "current_count": 0, - "peak_bytes": 10000, + "peak_bytes": 10080, "peak_count": 10, - "total_bytes": 12000, + "total_bytes": 12096, "total_count": 12, } gc.collect() @@ -696,7 +696,7 @@ def test_tracking_resource_adaptor(): for i in range(9, 0, -2): del buffers[i] - assert mr.get_allocated_bytes() == 5000 + assert mr.get_allocated_bytes() == 5040 # Push a new Tracking adaptor mr2 = rmm.mr.TrackingResourceAdaptor(mr, capture_stacks=True) @@ -705,8 +705,8 @@ def test_tracking_resource_adaptor(): for _ in range(2): buffers.append(rmm.DeviceBuffer(size=1000)) - assert mr2.get_allocated_bytes() == 2000 - assert mr.get_allocated_bytes() == 7000 + assert mr2.get_allocated_bytes() == 2016 + assert mr.get_allocated_bytes() == 7056 # Ensure we get back a non-empty string for the allocations assert len(mr.get_outstanding_allocations_str()) > 0 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 752496279..a3d493e40 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -126,6 +126,10 @@ endfunction() ConfigureTest(DEVICE_MR_TEST mr/device/mr_tests.cpp mr/device/mr_multithreaded_tests.cpp GPUS 1 PERCENT 90) +# device mr_ref tests +ConfigureTest(DEVICE_MR_REF_TEST mr/device/mr_ref_tests.cpp + mr/device/mr_ref_multithreaded_tests.cpp GPUS 1 PERCENT 100) + # general adaptor tests ConfigureTest(ADAPTOR_TEST mr/device/adaptor_tests.cpp) @@ -162,6 +166,12 @@ ConfigureTest(LIMITING_TEST mr/device/limiting_mr_tests.cpp) # host mr tests ConfigureTest(HOST_MR_TEST mr/host/mr_tests.cpp) +# host mr_ref tests +ConfigureTest(HOST_MR_REF_TEST mr/host/mr_ref_tests.cpp) + +# pinned pool mr tests +ConfigureTest(PINNED_POOL_MR_TEST mr/host/pinned_pool_mr_tests.cpp) + # cuda stream tests ConfigureTest(CUDA_STREAM_TEST cuda_stream_tests.cpp cuda_stream_pool_tests.cpp) diff --git a/tests/device_buffer_tests.cu b/tests/device_buffer_tests.cu index e0d8e5555..f73be0201 100644 --- a/tests/device_buffer_tests.cu +++ b/tests/device_buffer_tests.cu @@ -58,6 +58,7 @@ struct DeviceBufferTest : public ::testing::Test { }; using resources = ::testing::Types; +using async_resource_ref = cuda::mr::async_resource_ref; TYPED_TEST_CASE(DeviceBufferTest, resources); @@ -74,7 +75,7 @@ TYPED_TEST(DeviceBufferTest, DefaultMemoryResource) EXPECT_EQ(this->size, buff.size()); EXPECT_EQ(this->size, buff.ssize()); EXPECT_EQ(this->size, buff.capacity()); - EXPECT_EQ(rmm::mr::get_current_device_resource(), buff.memory_resource()); + EXPECT_EQ(async_resource_ref{rmm::mr::get_current_device_resource()}, buff.memory_resource()); EXPECT_EQ(rmm::cuda_stream_view{}, buff.stream()); } @@ -85,30 +86,28 @@ TYPED_TEST(DeviceBufferTest, DefaultMemoryResourceStream) EXPECT_NE(nullptr, buff.data()); EXPECT_EQ(this->size, buff.size()); EXPECT_EQ(this->size, buff.capacity()); - EXPECT_EQ(rmm::mr::get_current_device_resource(), buff.memory_resource()); + EXPECT_EQ(async_resource_ref{rmm::mr::get_current_device_resource()}, buff.memory_resource()); EXPECT_EQ(this->stream, buff.stream()); } TYPED_TEST(DeviceBufferTest, ExplicitMemoryResource) { - rmm::device_buffer buff(this->size, rmm::cuda_stream_view{}, &this->mr); + rmm::device_buffer buff(this->size, rmm::cuda_stream_view{}, this->mr); EXPECT_NE(nullptr, buff.data()); EXPECT_EQ(this->size, buff.size()); EXPECT_EQ(this->size, buff.capacity()); - EXPECT_EQ(&this->mr, buff.memory_resource()); - EXPECT_TRUE(this->mr.is_equal(*buff.memory_resource())); + EXPECT_EQ(async_resource_ref{this->mr}, buff.memory_resource()); EXPECT_EQ(rmm::cuda_stream_view{}, buff.stream()); } TYPED_TEST(DeviceBufferTest, ExplicitMemoryResourceStream) { - rmm::device_buffer buff(this->size, this->stream, &this->mr); + rmm::device_buffer buff(this->size, this->stream, this->mr); this->stream.synchronize(); EXPECT_NE(nullptr, buff.data()); EXPECT_EQ(this->size, buff.size()); EXPECT_EQ(this->size, buff.capacity()); - EXPECT_EQ(&this->mr, buff.memory_resource()); - EXPECT_TRUE(this->mr.is_equal(*buff.memory_resource())); + EXPECT_EQ(async_resource_ref{this->mr}, buff.memory_resource()); EXPECT_EQ(this->stream, buff.stream()); } @@ -120,7 +119,7 @@ TYPED_TEST(DeviceBufferTest, CopyFromRawDevicePointer) EXPECT_NE(nullptr, buff.data()); EXPECT_EQ(this->size, buff.size()); EXPECT_EQ(this->size, buff.capacity()); - EXPECT_EQ(rmm::mr::get_current_device_resource(), buff.memory_resource()); + EXPECT_EQ(async_resource_ref{rmm::mr::get_current_device_resource()}, buff.memory_resource()); EXPECT_EQ(rmm::cuda_stream_view{}, buff.stream()); // TODO check for equality between the contents of the two allocations @@ -136,7 +135,7 @@ TYPED_TEST(DeviceBufferTest, CopyFromRawHostPointer) EXPECT_NE(nullptr, buff.data()); EXPECT_EQ(this->size, buff.size()); EXPECT_EQ(this->size, buff.capacity()); - EXPECT_EQ(rmm::mr::get_current_device_resource(), buff.memory_resource()); + EXPECT_EQ(async_resource_ref{rmm::mr::get_current_device_resource()}, buff.memory_resource()); EXPECT_EQ(rmm::cuda_stream_view{}, buff.stream()); buff.stream().synchronize(); // TODO check for equality between the contents of the two allocations @@ -149,7 +148,7 @@ TYPED_TEST(DeviceBufferTest, CopyFromNullptr) EXPECT_EQ(nullptr, buff.data()); EXPECT_EQ(0, buff.size()); EXPECT_EQ(0, buff.capacity()); - EXPECT_EQ(rmm::mr::get_current_device_resource(), buff.memory_resource()); + EXPECT_EQ(async_resource_ref{rmm::mr::get_current_device_resource()}, buff.memory_resource()); EXPECT_EQ(rmm::cuda_stream_view{}, buff.stream()); } @@ -175,8 +174,8 @@ TYPED_TEST(DeviceBufferTest, CopyConstructor) EXPECT_NE(buff.data(), buff_copy.data()); EXPECT_EQ(buff.size(), buff_copy.size()); EXPECT_EQ(buff.capacity(), buff_copy.capacity()); - EXPECT_EQ(buff_copy.memory_resource(), rmm::mr::get_current_device_resource()); - EXPECT_TRUE(buff_copy.memory_resource()->is_equal(*rmm::mr::get_current_device_resource())); + EXPECT_EQ(buff_copy.memory_resource(), + async_resource_ref{rmm::mr::get_current_device_resource()}); EXPECT_EQ(buff_copy.stream(), rmm::cuda_stream_view{}); EXPECT_TRUE(thrust::equal(rmm::exec_policy(rmm::cuda_stream_default), @@ -188,7 +187,7 @@ TYPED_TEST(DeviceBufferTest, CopyConstructor) // now use buff's stream and MR rmm::device_buffer buff_copy2(buff, buff.stream(), buff.memory_resource()); EXPECT_EQ(buff_copy2.memory_resource(), buff.memory_resource()); - EXPECT_TRUE(buff_copy2.memory_resource()->is_equal(*buff.memory_resource())); + EXPECT_EQ(buff_copy2.memory_resource(), buff.memory_resource()); EXPECT_EQ(buff_copy2.stream(), buff.stream()); EXPECT_TRUE(thrust::equal(rmm::exec_policy(rmm::cuda_stream_default), @@ -218,8 +217,8 @@ TYPED_TEST(DeviceBufferTest, CopyCapacityLargerThanSize) // The capacity of the copy should be equal to the `size()` of the original EXPECT_EQ(new_size, buff_copy.capacity()); - EXPECT_EQ(buff_copy.memory_resource(), rmm::mr::get_current_device_resource()); - EXPECT_TRUE(buff_copy.memory_resource()->is_equal(*rmm::mr::get_current_device_resource())); + EXPECT_EQ(buff_copy.memory_resource(), + async_resource_ref{rmm::mr::get_current_device_resource()}); EXPECT_EQ(buff_copy.stream(), rmm::cuda_stream_view{}); EXPECT_TRUE(thrust::equal(rmm::exec_policy(rmm::cuda_stream_default), @@ -244,7 +243,6 @@ TYPED_TEST(DeviceBufferTest, CopyConstructorExplicitMr) EXPECT_EQ(buff.size(), buff_copy.size()); EXPECT_EQ(buff.capacity(), buff_copy.capacity()); EXPECT_EQ(buff.memory_resource(), buff_copy.memory_resource()); - EXPECT_TRUE(buff.memory_resource()->is_equal(*buff_copy.memory_resource())); EXPECT_NE(buff.stream(), buff_copy.stream()); EXPECT_TRUE(thrust::equal(rmm::exec_policy(buff_copy.stream()), @@ -276,7 +274,6 @@ TYPED_TEST(DeviceBufferTest, CopyCapacityLargerThanSizeExplicitMr) EXPECT_EQ(new_size, buff_copy.capacity()); EXPECT_NE(buff.capacity(), buff_copy.capacity()); EXPECT_EQ(buff.memory_resource(), buff_copy.memory_resource()); - EXPECT_TRUE(buff.memory_resource()->is_equal(*buff_copy.memory_resource())); EXPECT_NE(buff.stream(), buff_copy.stream()); EXPECT_TRUE(thrust::equal(rmm::exec_policy(buff_copy.stream()), @@ -292,7 +289,7 @@ TYPED_TEST(DeviceBufferTest, MoveConstructor) auto* ptr = buff.data(); auto size = buff.size(); auto capacity = buff.capacity(); - auto* mr = buff.memory_resource(); + auto mr = buff.memory_resource(); auto stream = buff.stream(); // New buffer should have the same contents as the original @@ -310,7 +307,6 @@ TYPED_TEST(DeviceBufferTest, MoveConstructor) EXPECT_EQ(0, buff.size()); // NOLINT(bugprone-use-after-move) EXPECT_EQ(0, buff.capacity()); // NOLINT(bugprone-use-after-move) EXPECT_EQ(rmm::cuda_stream_default, buff.stream()); // NOLINT(bugprone-use-after-move) - EXPECT_NE(nullptr, buff.memory_resource()); // NOLINT(bugprone-use-after-move) } TYPED_TEST(DeviceBufferTest, MoveConstructorStream) @@ -320,7 +316,7 @@ TYPED_TEST(DeviceBufferTest, MoveConstructorStream) auto* ptr = buff.data(); auto size = buff.size(); auto capacity = buff.capacity(); - auto* mr = buff.memory_resource(); + auto mr = buff.memory_resource(); auto stream = buff.stream(); // New buffer should have the same contents as the original @@ -339,7 +335,6 @@ TYPED_TEST(DeviceBufferTest, MoveConstructorStream) EXPECT_EQ(0, buff.size()); // NOLINT(bugprone-use-after-move) EXPECT_EQ(0, buff.capacity()); // NOLINT(bugprone-use-after-move) EXPECT_EQ(rmm::cuda_stream_view{}, buff.stream()); // NOLINT(bugprone-use-after-move) - EXPECT_NE(nullptr, buff.memory_resource()); // NOLINT(bugprone-use-after-move) } TYPED_TEST(DeviceBufferTest, MoveAssignmentToDefault) @@ -348,7 +343,7 @@ TYPED_TEST(DeviceBufferTest, MoveAssignmentToDefault) auto* ptr = src.data(); auto size = src.size(); auto capacity = src.capacity(); - auto* mr = src.memory_resource(); + auto mr = src.memory_resource(); auto stream = src.stream(); rmm::device_buffer dest; @@ -367,7 +362,6 @@ TYPED_TEST(DeviceBufferTest, MoveAssignmentToDefault) EXPECT_EQ(0, src.size()); EXPECT_EQ(0, src.capacity()); EXPECT_EQ(rmm::cuda_stream_default, src.stream()); - EXPECT_NE(nullptr, src.memory_resource()); } TYPED_TEST(DeviceBufferTest, MoveAssignment) @@ -376,7 +370,7 @@ TYPED_TEST(DeviceBufferTest, MoveAssignment) auto* ptr = src.data(); auto size = src.size(); auto capacity = src.capacity(); - auto* mr = src.memory_resource(); + auto mr = src.memory_resource(); auto stream = src.stream(); rmm::device_buffer dest(this->size - 1, rmm::cuda_stream_default, &this->mr); @@ -395,7 +389,6 @@ TYPED_TEST(DeviceBufferTest, MoveAssignment) EXPECT_EQ(0, src.size()); EXPECT_EQ(0, src.capacity()); EXPECT_EQ(rmm::cuda_stream_default, src.stream()); - EXPECT_NE(nullptr, src.memory_resource()); } TYPED_TEST(DeviceBufferTest, SelfMoveAssignment) @@ -404,7 +397,7 @@ TYPED_TEST(DeviceBufferTest, SelfMoveAssignment) auto* ptr = buff.data(); auto size = buff.size(); auto capacity = buff.capacity(); - auto* mr = buff.memory_resource(); + auto mr = buff.memory_resource(); auto stream = buff.stream(); buff = std::move(buff); // self-move-assignment shouldn't modify the buffer diff --git a/tests/device_uvector_tests.cpp b/tests/device_uvector_tests.cpp index 69d89e305..3c042a437 100644 --- a/tests/device_uvector_tests.cpp +++ b/tests/device_uvector_tests.cpp @@ -30,14 +30,15 @@ struct TypedUVectorTest : ::testing::Test { [[nodiscard]] rmm::cuda_stream_view stream() const noexcept { return rmm::cuda_stream_view{}; } }; -using TestTypes = ::testing::Types; +using TestTypes = ::testing::Types; +using async_resource_ref = cuda::mr::async_resource_ref; TYPED_TEST_CASE(TypedUVectorTest, TestTypes); TYPED_TEST(TypedUVectorTest, MemoryResource) { rmm::device_uvector vec(128, this->stream()); - EXPECT_EQ(vec.memory_resource(), rmm::mr::get_current_device_resource()); + EXPECT_EQ(vec.memory_resource(), async_resource_ref{rmm::mr::get_current_device_resource()}); } TYPED_TEST(TypedUVectorTest, ZeroSizeConstructor) diff --git a/tests/mr/device/adaptor_tests.cpp b/tests/mr/device/adaptor_tests.cpp index 44c14240b..98fc3a429 100644 --- a/tests/mr/device/adaptor_tests.cpp +++ b/tests/mr/device/adaptor_tests.cpp @@ -29,6 +29,8 @@ #include #include +#include + #include #include @@ -64,6 +66,23 @@ using adaptors = ::testing::Types, thread_safe_resource_adaptor, tracking_resource_adaptor>; +static_assert( + cuda::mr::resource_with, cuda::mr::device_accessible>); +static_assert(cuda::mr::resource_with, + cuda::mr::device_accessible>); +static_assert(cuda::mr::resource_with, + cuda::mr::device_accessible>); +static_assert( + cuda::mr::resource_with, cuda::mr::device_accessible>); +static_assert( + cuda::mr::resource_with, cuda::mr::device_accessible>); +static_assert(cuda::mr::resource_with, + cuda::mr::device_accessible>); +static_assert(cuda::mr::resource_with, + cuda::mr::device_accessible>); +static_assert(cuda::mr::resource_with, + cuda::mr::device_accessible>); + template struct AdaptorTest : public ::testing::Test { using adaptor_type = MemoryResourceType; diff --git a/tests/mr/device/cuda_async_mr_tests.cpp b/tests/mr/device/cuda_async_mr_tests.cpp index 37ed5c306..90c7b0ff9 100644 --- a/tests/mr/device/cuda_async_mr_tests.cpp +++ b/tests/mr/device/cuda_async_mr_tests.cpp @@ -24,6 +24,8 @@ namespace rmm::test { namespace { using cuda_async_mr = rmm::mr::cuda_async_memory_resource; +static_assert(cuda::mr::resource_with); +static_assert(cuda::mr::async_resource_with); class AsyncMRTest : public ::testing::Test { protected: diff --git a/tests/mr/device/cuda_async_view_mr_tests.cpp b/tests/mr/device/cuda_async_view_mr_tests.cpp index 209429b4b..fe82431a9 100644 --- a/tests/mr/device/cuda_async_view_mr_tests.cpp +++ b/tests/mr/device/cuda_async_view_mr_tests.cpp @@ -18,12 +18,16 @@ #include #include +#include + #include namespace rmm::test { namespace { using cuda_async_view_mr = rmm::mr::cuda_async_view_memory_resource; +static_assert(cuda::mr::resource_with); +static_assert(cuda::mr::async_resource_with); #if defined(RMM_CUDA_MALLOC_ASYNC_SUPPORT) diff --git a/tests/mr/device/mr_ref_multithreaded_tests.cpp b/tests/mr/device/mr_ref_multithreaded_tests.cpp new file mode 100644 index 000000000..76f9e6b61 --- /dev/null +++ b/tests/mr/device/mr_ref_multithreaded_tests.cpp @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2023, 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. + */ + +#include "mr_ref_test.hpp" + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +namespace rmm::test { +namespace { + +struct mr_ref_test_mt : public mr_ref_test {}; + +INSTANTIATE_TEST_CASE_P(MultiThreadResourceTests, + mr_ref_test_mt, + ::testing::Values(mr_factory{"CUDA", &make_cuda}, +#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT + mr_factory{"CUDA_Async", &make_cuda_async}, +#endif + mr_factory{"Managed", &make_managed}, + mr_factory{"Pool", &make_pool}, + mr_factory{"Arena", &make_arena}, + mr_factory{"Binning", &make_binning}), + [](auto const& info) { return info.param.name; }); + +template +void spawn_n(std::size_t num_threads, Task task, Arguments&&... args) +{ + std::vector threads; + threads.reserve(num_threads); + for (std::size_t i = 0; i < num_threads; ++i) { + threads.emplace_back(std::thread(task, std::forward(args)...)); + } + + for (auto& thread : threads) { + thread.join(); + } +} + +template +void spawn(Task task, Arguments&&... args) +{ + spawn_n(4, task, std::forward(args)...); +} + +TEST_P(mr_ref_test_mt, Allocate) { spawn(test_various_allocations, this->ref); } + +TEST_P(mr_ref_test_mt, AllocateDefaultStream) +{ + spawn(test_various_async_allocations, this->ref, rmm::cuda_stream_view{}); +} + +TEST_P(mr_ref_test_mt, AllocateOnStream) +{ + spawn(test_various_async_allocations, this->ref, this->stream.view()); +} + +TEST_P(mr_ref_test_mt, RandomAllocations) +{ + spawn(test_random_allocations, this->ref, default_num_allocations, default_max_size); +} + +TEST_P(mr_ref_test_mt, RandomAllocationsDefaultStream) +{ + spawn(test_random_async_allocations, + this->ref, + default_num_allocations, + default_max_size, + rmm::cuda_stream_view{}); +} + +TEST_P(mr_ref_test_mt, RandomAllocationsStream) +{ + spawn(test_random_async_allocations, + this->ref, + default_num_allocations, + default_max_size, + this->stream.view()); +} + +TEST_P(mr_ref_test_mt, MixedRandomAllocationFree) +{ + spawn(test_mixed_random_allocation_free, this->ref, default_max_size); +} + +TEST_P(mr_ref_test_mt, MixedRandomAllocationFreeDefaultStream) +{ + spawn( + test_mixed_random_async_allocation_free, this->ref, default_max_size, rmm::cuda_stream_view{}); +} + +TEST_P(mr_ref_test_mt, MixedRandomAllocationFreeStream) +{ + spawn(test_mixed_random_async_allocation_free, this->ref, default_max_size, this->stream.view()); +} + +void allocate_async_loop(async_resource_ref ref, + std::size_t num_allocations, + std::list& allocations, + std::mutex& mtx, + std::condition_variable& allocations_ready, + cudaEvent_t& event, + rmm::cuda_stream_view stream) +{ + constexpr std::size_t max_size{1_MiB}; + + std::default_random_engine generator; + std::uniform_int_distribution size_distribution(1, max_size); + + for (std::size_t i = 0; i < num_allocations; ++i) { + std::size_t size = size_distribution(generator); + void* ptr = ref.allocate_async(size, stream); + { + std::lock_guard lock(mtx); + RMM_CUDA_TRY(cudaEventRecord(event, stream.value())); + allocations.emplace_back(ptr, size); + } + allocations_ready.notify_one(); + } + + // Work around for threads going away before cudaEvent has finished async processing + cudaEventSynchronize(event); +} + +void deallocate_async_loop(async_resource_ref ref, + std::size_t num_allocations, + std::list& allocations, + std::mutex& mtx, + std::condition_variable& allocations_ready, + cudaEvent_t& event, + rmm::cuda_stream_view stream) +{ + for (std::size_t i = 0; i < num_allocations; i++) { + std::unique_lock lock(mtx); + allocations_ready.wait(lock, [&allocations] { return !allocations.empty(); }); + RMM_CUDA_TRY(cudaStreamWaitEvent(stream.value(), event)); + allocation alloc = allocations.front(); + allocations.pop_front(); + ref.deallocate_async(alloc.ptr, alloc.size, stream); + } + + // Work around for threads going away before cudaEvent has finished async processing + cudaEventSynchronize(event); +} + +void test_allocate_async_free_different_threads(async_resource_ref ref, + rmm::cuda_stream_view streamA, + rmm::cuda_stream_view streamB) +{ + constexpr std::size_t num_allocations{100}; + + std::mutex mtx; + std::condition_variable allocations_ready; + std::list allocations; + cudaEvent_t event; + + RMM_CUDA_TRY(cudaEventCreate(&event)); + + std::thread producer(allocate_async_loop, + ref, + num_allocations, + std::ref(allocations), + std::ref(mtx), + std::ref(allocations_ready), + std::ref(event), + streamA); + + std::thread consumer(deallocate_async_loop, + ref, + num_allocations, + std::ref(allocations), + std::ref(mtx), + std::ref(allocations_ready), + std::ref(event), + streamB); + + producer.join(); + consumer.join(); + + RMM_CUDA_TRY(cudaEventDestroy(event)); +} + +TEST_P(mr_ref_test_mt, AllocFreeDifferentThreadsDefaultStream) +{ + test_allocate_async_free_different_threads( + this->ref, rmm::cuda_stream_default, rmm::cuda_stream_default); +} + +TEST_P(mr_ref_test_mt, AllocFreeDifferentThreadsPerThreadDefaultStream) +{ + test_allocate_async_free_different_threads( + this->ref, rmm::cuda_stream_per_thread, rmm::cuda_stream_per_thread); +} + +TEST_P(mr_ref_test_mt, AllocFreeDifferentThreadsSameStream) +{ + test_allocate_async_free_different_threads(this->ref, this->stream, this->stream); +} + +TEST_P(mr_ref_test_mt, AllocFreeDifferentThreadsDifferentStream) +{ + rmm::cuda_stream streamB; + test_allocate_async_free_different_threads(this->ref, this->stream, streamB); + streamB.synchronize(); +} + +} // namespace +} // namespace rmm::test diff --git a/tests/mr/device/mr_ref_test.hpp b/tests/mr/device/mr_ref_test.hpp new file mode 100644 index 000000000..804c710a5 --- /dev/null +++ b/tests/mr/device/mr_ref_test.hpp @@ -0,0 +1,408 @@ +/* + * Copyright (c) 2023, 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. + */ + +#pragma once + +#include "../../byte_literals.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +#include +#include +#include +#include +#include + +using resource_ref = cuda::mr::resource_ref; +using async_resource_ref = cuda::mr::async_resource_ref; + +namespace rmm::test { + +/** + * @brief Returns if a pointer points to a device memory or managed memory + * allocation. + */ +inline bool is_device_memory(void* ptr) +{ + cudaPointerAttributes attributes{}; + if (cudaSuccess != cudaPointerGetAttributes(&attributes, ptr)) { return false; } + return (attributes.type == cudaMemoryTypeDevice) or (attributes.type == cudaMemoryTypeManaged); +} + +enum size_in_bytes : size_t {}; + +constexpr auto default_num_allocations{100}; +constexpr size_in_bytes default_max_size{5_MiB}; + +struct allocation { + void* ptr{nullptr}; + std::size_t size{0}; + allocation(void* ptr, std::size_t size) : ptr{ptr}, size{size} {} + allocation() = default; +}; + +// Various test functions, shared between single-threaded and multithreaded tests. +inline void test_allocate(resource_ref ref, std::size_t bytes) +{ + try { + void* ptr = ref.allocate(bytes); + EXPECT_NE(nullptr, ptr); + EXPECT_TRUE(rmm::detail::is_pointer_aligned(ptr)); + EXPECT_TRUE(is_device_memory(ptr)); + ref.deallocate(ptr, bytes); + } catch (rmm::out_of_memory const& e) { + EXPECT_NE(std::string{e.what()}.find("out_of_memory"), std::string::npos); + } +} + +inline void test_allocate_async(async_resource_ref ref, + std::size_t bytes, + cuda_stream_view stream = {}) +{ + try { + void* ptr = ref.allocate_async(bytes, stream); + if (not stream.is_default()) { stream.synchronize(); } + EXPECT_NE(nullptr, ptr); + EXPECT_TRUE(rmm::detail::is_pointer_aligned(ptr)); + EXPECT_TRUE(is_device_memory(ptr)); + ref.deallocate_async(ptr, bytes, stream); + if (not stream.is_default()) { stream.synchronize(); } + } catch (rmm::out_of_memory const& e) { + EXPECT_NE(std::string{e.what()}.find("out_of_memory"), std::string::npos); + } +} + +// Simple reproducer for https://github.com/rapidsai/rmm/issues/861 +inline void concurrent_allocations_are_different(resource_ref ref) +{ + const auto size{8_B}; + void* ptr1 = ref.allocate(size); + void* ptr2 = ref.allocate(size); + + EXPECT_NE(ptr1, ptr2); + + ref.deallocate(ptr1, size); + ref.deallocate(ptr2, size); +} + +inline void concurrent_async_allocations_are_different(async_resource_ref ref, + cuda_stream_view stream) +{ + const auto size{8_B}; + void* ptr1 = ref.allocate_async(size, stream); + void* ptr2 = ref.allocate_async(size, stream); + + EXPECT_NE(ptr1, ptr2); + + ref.deallocate_async(ptr1, size, stream); + ref.deallocate_async(ptr2, size, stream); +} + +inline void test_various_allocations(resource_ref ref) +{ + // test allocating zero bytes on non-default stream + { + void* ptr = ref.allocate(0); + EXPECT_NO_THROW(ref.deallocate(ptr, 0)); + } + + test_allocate(ref, 4_B); + test_allocate(ref, 1_KiB); + test_allocate(ref, 1_MiB); + test_allocate(ref, 1_GiB); + + // should fail to allocate too much + { + void* ptr{nullptr}; + EXPECT_THROW(ptr = ref.allocate(1_PiB), rmm::out_of_memory); + EXPECT_EQ(nullptr, ptr); + + // test e.what(); + try { + ptr = ref.allocate(1_PiB); + } catch (rmm::out_of_memory const& e) { + EXPECT_NE(std::string{e.what()}.find("out_of_memory"), std::string::npos); + } + } +} + +inline void test_various_async_allocations(async_resource_ref ref, cuda_stream_view stream) +{ + // test allocating zero bytes on non-default stream + { + void* ptr = ref.allocate_async(0, stream); + stream.synchronize(); + EXPECT_NO_THROW(ref.deallocate_async(ptr, 0, stream)); + stream.synchronize(); + } + + test_allocate_async(ref, 4_B, stream); + test_allocate_async(ref, 1_KiB, stream); + test_allocate_async(ref, 1_MiB, stream); + test_allocate_async(ref, 1_GiB, stream); + + // should fail to allocate too much + { + void* ptr{nullptr}; + EXPECT_THROW(ptr = ref.allocate_async(1_PiB, stream), rmm::out_of_memory); + EXPECT_EQ(nullptr, ptr); + + // test e.what(); + try { + ptr = ref.allocate_async(1_PiB, stream); + } catch (rmm::out_of_memory const& e) { + EXPECT_NE(std::string{e.what()}.find("out_of_memory"), std::string::npos); + } + } +} + +inline void test_random_allocations(resource_ref ref, + std::size_t num_allocations = default_num_allocations, + size_in_bytes max_size = default_max_size) +{ + std::vector allocations(num_allocations); + + std::default_random_engine generator; + std::uniform_int_distribution distribution(1, max_size); + + // num_allocations allocations from [0,max_size) + std::for_each( + allocations.begin(), allocations.end(), [&generator, &distribution, &ref](allocation& alloc) { + alloc.size = distribution(generator); + EXPECT_NO_THROW(alloc.ptr = ref.allocate(alloc.size)); + EXPECT_NE(nullptr, alloc.ptr); + EXPECT_TRUE(rmm::detail::is_pointer_aligned(alloc.ptr)); + }); + + std::for_each(allocations.begin(), allocations.end(), [&ref](allocation& alloc) { + EXPECT_NO_THROW(ref.deallocate(alloc.ptr, alloc.size)); + }); +} + +inline void test_random_async_allocations(async_resource_ref ref, + std::size_t num_allocations = default_num_allocations, + size_in_bytes max_size = default_max_size, + cuda_stream_view stream = {}) +{ + std::vector allocations(num_allocations); + + std::default_random_engine generator; + std::uniform_int_distribution distribution(1, max_size); + + // num_allocations allocations from [0,max_size) + std::for_each(allocations.begin(), + allocations.end(), + [&generator, &distribution, &ref, stream](allocation& alloc) { + alloc.size = distribution(generator); + EXPECT_NO_THROW(alloc.ptr = ref.allocate(alloc.size)); + if (not stream.is_default()) { stream.synchronize(); } + EXPECT_NE(nullptr, alloc.ptr); + EXPECT_TRUE(rmm::detail::is_pointer_aligned(alloc.ptr)); + }); + + std::for_each(allocations.begin(), allocations.end(), [stream, &ref](allocation& alloc) { + EXPECT_NO_THROW(ref.deallocate(alloc.ptr, alloc.size)); + if (not stream.is_default()) { stream.synchronize(); } + }); +} + +inline void test_mixed_random_allocation_free(resource_ref ref, + size_in_bytes max_size = default_max_size) +{ + std::default_random_engine generator; + constexpr std::size_t num_allocations{100}; + + std::uniform_int_distribution size_distribution(1, max_size); + + constexpr int allocation_probability{53}; // percent + constexpr int max_probability{99}; + std::uniform_int_distribution op_distribution(0, max_probability); + std::uniform_int_distribution index_distribution(0, num_allocations - 1); + + std::size_t active_allocations{0}; + std::size_t allocation_count{0}; + + std::vector allocations; + + for (std::size_t i = 0; i < num_allocations * 2; ++i) { + bool do_alloc = true; + if (active_allocations > 0) { + int chance = op_distribution(generator); + do_alloc = (chance < allocation_probability) && (allocation_count < num_allocations); + } + + if (do_alloc) { + std::size_t size = size_distribution(generator); + active_allocations++; + allocation_count++; + EXPECT_NO_THROW(allocations.emplace_back(ref.allocate(size), size)); + auto new_allocation = allocations.back(); + EXPECT_NE(nullptr, new_allocation.ptr); + EXPECT_TRUE(rmm::detail::is_pointer_aligned(new_allocation.ptr)); + } else { + auto const index = static_cast(index_distribution(generator) % active_allocations); + active_allocations--; + allocation to_free = allocations[index]; + allocations.erase(std::next(allocations.begin(), index)); + EXPECT_NO_THROW(ref.deallocate(to_free.ptr, to_free.size)); + } + } + + EXPECT_EQ(active_allocations, 0); + EXPECT_EQ(allocations.size(), active_allocations); +} + +inline void test_mixed_random_async_allocation_free(async_resource_ref ref, + size_in_bytes max_size = default_max_size, + cuda_stream_view stream = {}) +{ + std::default_random_engine generator; + constexpr std::size_t num_allocations{100}; + + std::uniform_int_distribution size_distribution(1, max_size); + + constexpr int allocation_probability{53}; // percent + constexpr int max_probability{99}; + std::uniform_int_distribution op_distribution(0, max_probability); + std::uniform_int_distribution index_distribution(0, num_allocations - 1); + + std::size_t active_allocations{0}; + std::size_t allocation_count{0}; + + std::vector allocations; + + for (std::size_t i = 0; i < num_allocations * 2; ++i) { + bool do_alloc = true; + if (active_allocations > 0) { + int chance = op_distribution(generator); + do_alloc = (chance < allocation_probability) && (allocation_count < num_allocations); + } + + if (do_alloc) { + std::size_t size = size_distribution(generator); + active_allocations++; + allocation_count++; + EXPECT_NO_THROW(allocations.emplace_back(ref.allocate_async(size, stream), size)); + auto new_allocation = allocations.back(); + EXPECT_NE(nullptr, new_allocation.ptr); + EXPECT_TRUE(rmm::detail::is_pointer_aligned(new_allocation.ptr)); + } else { + auto const index = static_cast(index_distribution(generator) % active_allocations); + active_allocations--; + allocation to_free = allocations[index]; + allocations.erase(std::next(allocations.begin(), index)); + EXPECT_NO_THROW(ref.deallocate_async(to_free.ptr, to_free.size, stream)); + } + } + + EXPECT_EQ(active_allocations, 0); + EXPECT_EQ(allocations.size(), active_allocations); +} + +using MRFactoryFunc = std::function()>; + +/// Encapsulates a `device_memory_resource` factory function and associated name +struct mr_factory { + mr_factory(std::string name, MRFactoryFunc factory) + : name{std::move(name)}, factory{std::move(factory)} + { + } + + std::string name; ///< Name to associate with tests that use this factory + MRFactoryFunc factory; ///< Factory function that returns shared_ptr to `device_memory_resource` + ///< instance to use in test +}; + +/// Test fixture class value-parameterized on different `mr_factory`s +struct mr_ref_test : public ::testing::TestWithParam { + void SetUp() override + { + auto factory = GetParam().factory; + mr = factory(); + if (mr == nullptr) { + GTEST_SKIP() << "Skipping tests since the memory resource is not supported with this CUDA " + << "driver/runtime version"; + } + ref = async_resource_ref{*mr}; + } + + std::shared_ptr mr; ///< Pointer to resource to use in tests + async_resource_ref ref{*mr}; + rmm::cuda_stream stream{}; +}; + +struct mr_ref_allocation_test : public mr_ref_test {}; + +/// MR factory functions +inline auto make_cuda() { return std::make_shared(); } + +inline auto make_cuda_async() +{ + if (rmm::detail::async_alloc::is_supported()) { + return std::make_shared(); + } + return std::shared_ptr{nullptr}; +} + +inline auto make_managed() { return std::make_shared(); } + +inline auto make_pool() +{ + return rmm::mr::make_owning_wrapper(make_cuda()); +} + +inline auto make_arena() +{ + return rmm::mr::make_owning_wrapper(make_cuda()); +} + +inline auto make_fixed_size() +{ + return rmm::mr::make_owning_wrapper(make_cuda()); +} + +inline auto make_binning() +{ + auto pool = make_pool(); + // Add a binning_memory_resource with fixed-size bins of sizes 256, 512, 1024, 2048 and 4096KiB + // Larger allocations will use the pool resource + auto const bin_range_start{18}; + auto const bin_range_end{22}; + + auto mr = rmm::mr::make_owning_wrapper( + pool, bin_range_start, bin_range_end); + return mr; +} + +} // namespace rmm::test diff --git a/tests/mr/device/mr_ref_tests.cpp b/tests/mr/device/mr_ref_tests.cpp new file mode 100644 index 000000000..a9a94696a --- /dev/null +++ b/tests/mr/device/mr_ref_tests.cpp @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2023, 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. + */ + +#include "mr_ref_test.hpp" + +#include + +#include + +#include + +namespace rmm::test { +namespace { + +INSTANTIATE_TEST_SUITE_P(ResourceTests, + mr_ref_test, + ::testing::Values(mr_factory{"CUDA", &make_cuda}, +#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT + mr_factory{"CUDA_Async", &make_cuda_async}, +#endif + mr_factory{"Managed", &make_managed}, + mr_factory{"Pool", &make_pool}, + mr_factory{"Arena", &make_arena}, + mr_factory{"Binning", &make_binning}, + mr_factory{"Fixed_Size", &make_fixed_size}), + [](auto const& info) { return info.param.name; }); + +// Leave out fixed-size MR here because it can't handle the dynamic allocation sizes +INSTANTIATE_TEST_SUITE_P(ResourceAllocationTests, + mr_ref_allocation_test, + ::testing::Values(mr_factory{"CUDA", &make_cuda}, +#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT + mr_factory{"CUDA_Async", &make_cuda_async}, +#endif + mr_factory{"Managed", &make_managed}, + mr_factory{"Pool", &make_pool}, + mr_factory{"Arena", &make_arena}, + mr_factory{"Binning", &make_binning}), + [](auto const& info) { return info.param.name; }); +TEST_P(mr_ref_test, SelfEquality) { EXPECT_TRUE(this->ref == this->ref); } + +// Simple reproducer for https://github.com/rapidsai/rmm/issues/861 +TEST_P(mr_ref_test, AllocationsAreDifferent) { concurrent_allocations_are_different(this->ref); } + +TEST_P(mr_ref_test, AsyncAllocationsAreDifferentDefaultStream) +{ + concurrent_async_allocations_are_different(this->ref, cuda_stream_view{}); +} + +TEST_P(mr_ref_test, AsyncAllocationsAreDifferent) +{ + concurrent_async_allocations_are_different(this->ref, this->stream); +} + +TEST_P(mr_ref_allocation_test, AllocateDefault) { test_various_allocations(this->ref); } + +TEST_P(mr_ref_allocation_test, AllocateDefaultStream) +{ + test_various_async_allocations(this->ref, cuda_stream_view{}); +} + +TEST_P(mr_ref_allocation_test, AllocateOnStream) +{ + test_various_async_allocations(this->ref, this->stream); +} + +TEST_P(mr_ref_allocation_test, RandomAllocations) { test_random_allocations(this->ref); } + +TEST_P(mr_ref_allocation_test, RandomAllocationsDefaultStream) +{ + test_random_async_allocations( + this->ref, default_num_allocations, default_max_size, cuda_stream_view{}); +} + +TEST_P(mr_ref_allocation_test, RandomAllocationsStream) +{ + test_random_async_allocations(this->ref, default_num_allocations, default_max_size, this->stream); +} + +TEST_P(mr_ref_allocation_test, MixedRandomAllocationFree) +{ + test_mixed_random_allocation_free(this->ref, default_max_size); +} + +TEST_P(mr_ref_allocation_test, MixedRandomAllocationFreeDefaultStream) +{ + test_mixed_random_async_allocation_free(this->ref, default_max_size, cuda_stream_view{}); +} + +TEST_P(mr_ref_allocation_test, MixedRandomAllocationFreeStream) +{ + test_mixed_random_async_allocation_free(this->ref, default_max_size, this->stream); +} + +} // namespace +} // namespace rmm::test diff --git a/tests/mr/device/mr_test.hpp b/tests/mr/device/mr_test.hpp index 8c69df215..03f880e72 100644 --- a/tests/mr/device/mr_test.hpp +++ b/tests/mr/device/mr_test.hpp @@ -52,11 +52,7 @@ inline bool is_device_memory(void* ptr) { cudaPointerAttributes attributes{}; if (cudaSuccess != cudaPointerGetAttributes(&attributes, ptr)) { return false; } -#if CUDART_VERSION < 10000 // memoryType is deprecated in CUDA 10 - return attributes.memoryType == cudaMemoryTypeDevice; -#else return (attributes.type == cudaMemoryTypeDevice) or (attributes.type == cudaMemoryTypeManaged); -#endif } enum size_in_bytes : size_t {}; diff --git a/tests/mr/device/pool_mr_tests.cpp b/tests/mr/device/pool_mr_tests.cpp index 4a234d2f9..2f32889d0 100644 --- a/tests/mr/device/pool_mr_tests.cpp +++ b/tests/mr/device/pool_mr_tests.cpp @@ -55,6 +55,18 @@ TEST(PoolTest, ThrowMaxLessThanInitial) EXPECT_THROW(max_less_than_initial(), rmm::logic_error); } +TEST(PoolTest, ReferenceThrowMaxLessThanInitial) +{ + // Make sure first argument is enough larger than the second that alignment rounding doesn't + // make them equal + auto max_less_than_initial = []() { + const auto initial{1024}; + const auto maximum{256}; + pool_mr mr{*rmm::mr::get_current_device_resource(), initial, maximum}; + }; + EXPECT_THROW(max_less_than_initial(), rmm::logic_error); +} + TEST(PoolTest, AllocateNinetyPercent) { auto allocate_ninety = []() { @@ -190,4 +202,43 @@ TEST(PoolTest, MultidevicePool) } } // namespace + +namespace test_properties { +class fake_async_resource { + public: + // To model `async_resource` + void* allocate(std::size_t, std::size_t) { return nullptr; } + void deallocate(void* ptr, std::size_t, std::size_t) {} + void* allocate_async(std::size_t, std::size_t, cuda::stream_ref) { return nullptr; } + void deallocate_async(void* ptr, std::size_t, std::size_t, cuda::stream_ref) {} + + bool operator==(const fake_async_resource& other) const { return true; } + bool operator!=(const fake_async_resource& other) const { return false; } + + // To model stream_resource + [[nodiscard]] bool supports_streams() const noexcept { return false; } + [[nodiscard]] bool supports_get_mem_info() const noexcept { return false; } + + private: + void* do_allocate(std::size_t bytes, cuda_stream_view) { return nullptr; } + void do_deallocate(void* ptr, std::size_t, cuda_stream_view) {} + [[nodiscard]] bool do_is_equal(fake_async_resource const& other) const noexcept { return true; } +}; +static_assert(!cuda::has_property); +static_assert(!cuda::has_property, + cuda::mr::device_accessible>); + +// Ensure that we forward the property if it is there +class fake_async_resource_device_accessible : public fake_async_resource { + friend void get_property(const fake_async_resource_device_accessible&, + cuda::mr::device_accessible) + { + } +}; +static_assert( + cuda::has_property); +static_assert( + cuda::has_property, + cuda::mr::device_accessible>); +} // namespace test_properties } // namespace rmm::test diff --git a/tests/mr/device/thrust_allocator_tests.cu b/tests/mr/device/thrust_allocator_tests.cu index 41fb15973..ed8875cbe 100644 --- a/tests/mr/device/thrust_allocator_tests.cu +++ b/tests/mr/device/thrust_allocator_tests.cu @@ -32,6 +32,7 @@ namespace rmm::test { namespace { struct allocator_test : public mr_test {}; +using async_resource_ref = cuda::mr::async_resource_ref; TEST_P(allocator_test, first) { @@ -44,7 +45,8 @@ TEST_P(allocator_test, defaults) { rmm::mr::thrust_allocator allocator(rmm::cuda_stream_default); EXPECT_EQ(allocator.stream(), rmm::cuda_stream_default); - EXPECT_EQ(allocator.resource(), rmm::mr::get_current_device_resource()); + EXPECT_EQ(allocator.memory_resource(), + async_resource_ref{rmm::mr::get_current_device_resource()}); } INSTANTIATE_TEST_CASE_P(ThrustAllocatorTests, diff --git a/tests/mr/host/mr_ref_tests.cpp b/tests/mr/host/mr_ref_tests.cpp new file mode 100644 index 000000000..6563eb635 --- /dev/null +++ b/tests/mr/host/mr_ref_tests.cpp @@ -0,0 +1,258 @@ +/* + * Copyright (c) 2023, 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. + */ + +#include "../../byte_literals.hpp" + +#include +#include +#include +#include + +#include + +#include + +#include + +#include +#include +#include + +namespace rmm::test { +namespace { +inline bool is_aligned(void* ptr, std::size_t alignment = alignof(std::max_align_t)) +{ + return rmm::detail::is_pointer_aligned(ptr, alignment); +} + +// Returns true if a pointer points to a device memory or managed memory allocation. +inline bool is_device_memory(void* ptr) +{ + cudaPointerAttributes attributes{}; + if (cudaSuccess != cudaPointerGetAttributes(&attributes, ptr)) { return false; } + return (attributes.type == cudaMemoryTypeDevice) or (attributes.type == cudaMemoryTypeManaged); +} + +/** + * @brief Returns if a pointer `p` points to pinned host memory. + */ +inline bool is_pinned_memory(void* ptr) +{ + cudaPointerAttributes attributes{}; + if (cudaSuccess != cudaPointerGetAttributes(&attributes, ptr)) { return false; } + return attributes.type == cudaMemoryTypeHost; +} + +constexpr std::size_t size_word{4_B}; +constexpr std::size_t size_kb{1_KiB}; +constexpr std::size_t size_mb{1_MiB}; +constexpr std::size_t size_gb{1_GiB}; +constexpr std::size_t size_pb{1_PiB}; + +struct allocation { + void* ptr{nullptr}; + std::size_t size{0}; + allocation(void* ptr, std::size_t size) : ptr{ptr}, size{size} {} + allocation() = default; +}; +} // namespace + +template +struct MRRefTest : public ::testing::Test { + MemoryResourceType mr; + cuda::mr::resource_ref ref; + + MRRefTest() : mr{}, ref{mr} {} +}; + +using resources = ::testing::Types; +static_assert(cuda::mr::resource_with); +static_assert(cuda::mr::resource_with); + +TYPED_TEST_CASE(MRRefTest, resources); + +TYPED_TEST(MRRefTest, SelfEquality) { EXPECT_TRUE(this->ref == this->ref); } + +TYPED_TEST(MRRefTest, AllocateZeroBytes) +{ + void* ptr{nullptr}; + EXPECT_NO_THROW(ptr = this->ref.allocate(0)); + EXPECT_NO_THROW(this->ref.deallocate(ptr, 0)); +} + +TYPED_TEST(MRRefTest, AllocateWord) +{ + void* ptr{nullptr}; + EXPECT_NO_THROW(ptr = this->ref.allocate(size_word)); + EXPECT_NE(nullptr, ptr); + EXPECT_TRUE(is_aligned(ptr)); + EXPECT_FALSE(is_device_memory(ptr)); + EXPECT_NO_THROW(this->ref.deallocate(ptr, size_word)); +} + +TYPED_TEST(MRRefTest, AllocateKB) +{ + void* ptr{nullptr}; + EXPECT_NO_THROW(ptr = this->ref.allocate(size_kb)); + EXPECT_NE(nullptr, ptr); + EXPECT_TRUE(is_aligned(ptr)); + EXPECT_FALSE(is_device_memory(ptr)); + EXPECT_NO_THROW(this->ref.deallocate(ptr, size_kb)); +} + +TYPED_TEST(MRRefTest, AllocateMB) +{ + void* ptr{nullptr}; + EXPECT_NO_THROW(ptr = this->ref.allocate(size_mb)); + EXPECT_NE(nullptr, ptr); + EXPECT_TRUE(is_aligned(ptr)); + EXPECT_FALSE(is_device_memory(ptr)); + EXPECT_NO_THROW(this->ref.deallocate(ptr, size_mb)); +} + +TYPED_TEST(MRRefTest, AllocateGB) +{ + void* ptr{nullptr}; + EXPECT_NO_THROW(ptr = this->ref.allocate(size_gb)); + EXPECT_NE(nullptr, ptr); + EXPECT_TRUE(is_aligned(ptr)); + EXPECT_FALSE(is_device_memory(ptr)); + EXPECT_NO_THROW(this->ref.deallocate(ptr, size_gb)); +} + +TYPED_TEST(MRRefTest, AllocateTooMuch) +{ + void* ptr{nullptr}; + EXPECT_THROW(ptr = this->ref.allocate(size_pb), std::bad_alloc); + EXPECT_EQ(nullptr, ptr); +} + +TYPED_TEST(MRRefTest, RandomAllocations) +{ + constexpr std::size_t num_allocations{100}; + std::vector allocations(num_allocations); + + constexpr std::size_t MAX_ALLOCATION_SIZE{5 * size_mb}; + + std::default_random_engine generator; + std::uniform_int_distribution distribution(1, MAX_ALLOCATION_SIZE); + + // 100 allocations from [0,5MB) + std::for_each( + allocations.begin(), allocations.end(), [&generator, &distribution, this](allocation& alloc) { + alloc.size = distribution(generator); + EXPECT_NO_THROW(alloc.ptr = this->ref.allocate(alloc.size)); + EXPECT_NE(nullptr, alloc.ptr); + EXPECT_TRUE(is_aligned(alloc.ptr)); + }); + + std::for_each(allocations.begin(), allocations.end(), [this](allocation& alloc) { + EXPECT_NO_THROW(this->ref.deallocate(alloc.ptr, alloc.size)); + }); +} + +TYPED_TEST(MRRefTest, MixedRandomAllocationFree) +{ + std::default_random_engine generator; + + constexpr std::size_t MAX_ALLOCATION_SIZE{10 * size_mb}; + std::uniform_int_distribution size_distribution(1, MAX_ALLOCATION_SIZE); + + // How often a free will occur. For example, if `1`, then every allocation + // will immediately be free'd. Or, if 4, on average, a free will occur after + // every 4th allocation + constexpr std::size_t FREE_FREQUENCY{4}; + std::uniform_int_distribution free_distribution(1, FREE_FREQUENCY); + + std::deque allocations; + + constexpr std::size_t num_allocations{100}; + for (std::size_t i = 0; i < num_allocations; ++i) { + std::size_t allocation_size = size_distribution(generator); + EXPECT_NO_THROW(allocations.emplace_back(this->ref.allocate(allocation_size), allocation_size)); + auto new_allocation = allocations.back(); + EXPECT_NE(nullptr, new_allocation.ptr); + EXPECT_TRUE(is_aligned(new_allocation.ptr)); + + bool const free_front{free_distribution(generator) == free_distribution.max()}; + + if (free_front) { + auto front = allocations.front(); + EXPECT_NO_THROW(this->ref.deallocate(front.ptr, front.size)); + allocations.pop_front(); + } + } + // free any remaining allocations + for (auto alloc : allocations) { + EXPECT_NO_THROW(this->ref.deallocate(alloc.ptr, alloc.size)); + allocations.pop_front(); + } +} + +static constexpr std::size_t MinTestedAlignment{16}; +static constexpr std::size_t MaxTestedAlignment{4096}; +static constexpr std::size_t TestedAlignmentMultiplier{2}; +static constexpr std::size_t NUM_TRIALS{100}; + +TYPED_TEST(MRRefTest, AlignmentTest) +{ + std::default_random_engine generator(0); + constexpr std::size_t MAX_ALLOCATION_SIZE{10 * size_mb}; + std::uniform_int_distribution size_distribution(1, MAX_ALLOCATION_SIZE); + + for (std::size_t num_trials = 0; num_trials < NUM_TRIALS; ++num_trials) { + for (std::size_t alignment = MinTestedAlignment; alignment <= MaxTestedAlignment; + alignment *= TestedAlignmentMultiplier) { + auto allocation_size = size_distribution(generator); + void* ptr{nullptr}; + EXPECT_NO_THROW(ptr = this->ref.allocate(allocation_size, alignment)); + EXPECT_TRUE(is_aligned(ptr, alignment)); + EXPECT_NO_THROW(this->ref.deallocate(ptr, allocation_size, alignment)); + } + } +} + +TYPED_TEST(MRRefTest, UnsupportedAlignmentTest) +{ + std::default_random_engine generator(0); + constexpr std::size_t MAX_ALLOCATION_SIZE{10 * size_mb}; + std::uniform_int_distribution size_distribution(1, MAX_ALLOCATION_SIZE); + + for (std::size_t num_trials = 0; num_trials < NUM_TRIALS; ++num_trials) { + for (std::size_t alignment = MinTestedAlignment; alignment <= MaxTestedAlignment; + alignment *= TestedAlignmentMultiplier) { + auto allocation_size = size_distribution(generator); + void* ptr{nullptr}; + // An unsupported alignment (like an odd number) should result in an + // alignment of `alignof(std::max_align_t)` + auto const bad_alignment = alignment + 1; + EXPECT_NO_THROW(ptr = this->ref.allocate(allocation_size, bad_alignment)); + EXPECT_TRUE(is_aligned(ptr, alignof(std::max_align_t))); + EXPECT_NO_THROW(this->ref.deallocate(ptr, allocation_size, bad_alignment)); + } + } +} + +TEST(PinnedResource, isPinned) +{ + rmm::mr::pinned_memory_resource mr; + cuda::mr::resource_ref ref{mr}; + void* ptr{nullptr}; + EXPECT_NO_THROW(ptr = ref.allocate(100)); + EXPECT_TRUE(is_pinned_memory(ptr)); + EXPECT_NO_THROW(ref.deallocate(ptr, 100)); +} +} // namespace rmm::test diff --git a/tests/mr/host/mr_tests.cpp b/tests/mr/host/mr_tests.cpp index 1cd59f5a6..678d6aeb8 100644 --- a/tests/mr/host/mr_tests.cpp +++ b/tests/mr/host/mr_tests.cpp @@ -23,6 +23,8 @@ #include +#include + #include #include @@ -41,11 +43,7 @@ inline bool is_device_memory(void* ptr) { cudaPointerAttributes attributes{}; if (cudaSuccess != cudaPointerGetAttributes(&attributes, ptr)) { return false; } -#if CUDART_VERSION < 10000 // memoryType is deprecated in CUDA 10 - return attributes.memoryType == cudaMemoryTypeDevice; -#else return (attributes.type == cudaMemoryTypeDevice) or (attributes.type == cudaMemoryTypeManaged); -#endif } /** @@ -80,6 +78,8 @@ struct MRTest : public ::testing::Test { }; using resources = ::testing::Types; +static_assert(cuda::mr::resource_with); +static_assert(cuda::mr::resource_with); TYPED_TEST_CASE(MRTest, resources); diff --git a/tests/mr/host/pinned_pool_mr_tests.cpp b/tests/mr/host/pinned_pool_mr_tests.cpp new file mode 100644 index 000000000..dcdae37fa --- /dev/null +++ b/tests/mr/host/pinned_pool_mr_tests.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2023, 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. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +// explicit instantiation for test coverage purposes +template class rmm::mr::pool_memory_resource; + +namespace rmm::test { +namespace { +using pool_mr = rmm::mr::pool_memory_resource; + +TEST(PinnedPoolTest, ThrowOnNullUpstream) +{ + auto construct_nullptr = []() { pool_mr mr{nullptr}; }; + EXPECT_THROW(construct_nullptr(), rmm::logic_error); +} + +TEST(PinnedPoolTest, ThrowMaxLessThanInitial) +{ + // Make sure first argument is enough larger than the second that alignment rounding doesn't + // make them equal + auto max_less_than_initial = []() { + rmm::mr::pinned_memory_resource pinned_mr{}; + const auto initial{1024}; + const auto maximum{256}; + pool_mr mr{&pinned_mr, initial, maximum}; + }; + EXPECT_THROW(max_less_than_initial(), rmm::logic_error); +} + +TEST(PinnedPoolTest, ReferenceThrowMaxLessThanInitial) +{ + // Make sure first argument is enough larger than the second that alignment rounding doesn't + // make them equal + auto max_less_than_initial = []() { + rmm::mr::pinned_memory_resource pinned_mr{}; + const auto initial{1024}; + const auto maximum{256}; + pool_mr mr{pinned_mr, initial, maximum}; + }; + EXPECT_THROW(max_less_than_initial(), rmm::logic_error); +} + +// Issue #527 +TEST(PinnedPoolTest, InitialAndMaxPoolSizeEqual) +{ + EXPECT_NO_THROW([]() { + rmm::mr::pinned_memory_resource pinned_mr{}; + pool_mr mr(pinned_mr, 1000192, 1000192); + mr.allocate(1000); + }()); +} + +TEST(PinnedPoolTest, NonAlignedPoolSize) +{ + EXPECT_THROW( + []() { + rmm::mr::pinned_memory_resource pinned_mr{}; + pool_mr mr(pinned_mr, 1000031, 1000192); + mr.allocate(1000); + }(), + rmm::logic_error); + + EXPECT_THROW( + []() { + rmm::mr::pinned_memory_resource pinned_mr{}; + pool_mr mr(pinned_mr, 1000192, 1000200); + mr.allocate(1000); + }(), + rmm::logic_error); +} + +} // namespace +} // namespace rmm::test From c17730ead0ec89526a690f1bc64c6c432e61dcc5 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 17 Nov 2023 10:37:46 -0600 Subject: [PATCH 319/675] Enable build concurrency for nightly and merge triggers. (#1380) --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index be052881c..23fcd0303 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -22,7 +22,7 @@ on: default: nightly concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} cancel-in-progress: true jobs: From 682e2f3e5e4df5f545d0e8bbc692eb29c52f01df Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Fri, 17 Nov 2023 09:13:02 -0800 Subject: [PATCH 320/675] Silence false gcc warning (#1381) gcc has a warning about potential compatibility issues with pre ISO C++ code. There is no danger in us compiling in that mode so silence this warning Authors: - Michael Schellenberger Costa (https://github.com/miscco) Approvers: - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1381 --- include/rmm/mr/device/pool_memory_resource.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index c85408359..20b250524 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -74,11 +74,18 @@ struct maybe_remove_property>> { +#ifdef __GNUC__ // GCC warns about compatibility issues with pre ISO C++ code +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnon-template-friend" +#endif // __GNUC__ /** * @brief Explicit removal of the friend function so we do not pretend to provide device * accessible memory */ friend void get_property(const PoolResource&, Property) = delete; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ }; } // namespace detail From 7f776eff99b65ffe7b41bc547ec5d0a5dde3cb61 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Wed, 22 Nov 2023 09:39:41 +1100 Subject: [PATCH 321/675] Document minimum CUDA version of 11.4 (#1385) \With the addition of libcudacxx 2.1.0, minimum CUDA version required to build RMM is now 11.4. This PR updates the readme to reflect this. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Bradley Dice (https://github.com/bdice) --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4059c9ce0..56bc86632 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ RMM can be installed with Conda ([miniconda](https://conda.io/miniconda.html), o [Anaconda distribution](https://www.anaconda.com/download)) from the `rapidsai` channel: ```bash -conda install -c rapidsai -c conda-forge -c nvidia rmm cuda-version=11.8 +conda install -c rapidsai -c conda-forge -c nvidia rmm cuda-version=12.0 ``` We also provide [nightly Conda packages](https://anaconda.org/rapidsai-nightly) built from the HEAD @@ -45,7 +45,6 @@ of our latest development branch. Note: RMM is supported only on Linux, and only tested with Python versions 3.9 and 3.10. - Note: The RMM package from Conda requires building with GCC 9 or later. Otherwise, your application may fail to build. See the [Get RAPIDS version picker](https://rapids.ai/start.html) for more OS and version info. @@ -57,13 +56,12 @@ See the [Get RAPIDS version picker](https://rapids.ai/start.html) for more OS an Compiler requirements: * `gcc` version 9.3+ -* `nvcc` version 11.2+ +* `nvcc` version 11.4+ * `cmake` version 3.26.4+ CUDA/GPU requirements: -* CUDA 11.2+ -* NVIDIA driver 450.51+ +* CUDA 11.4+ * Pascal architecture or better You can obtain CUDA from [https://developer.nvidia.com/cuda-downloads](https://developer.nvidia.com/cuda-downloads) From da793c5471e2483232df718c8cb1534de8b7c0eb Mon Sep 17 00:00:00 2001 From: Thomas Graves Date: Wed, 29 Nov 2023 16:37:23 -0600 Subject: [PATCH 322/675] Fix Arena MR to support simultaneous access by PTDS and other streams (#1395) Replaces https://github.com/rapidsai/rmm/pull/1394, this is targeted for 24.02. fixes https://github.com/rapidsai/rmm/issues/1393 In Spark with the Spark Rapids accelerator using cudf 23.12 snapshot we have an application that is reading ORC files, doing some light processing and then writing ORC files. It consistently fails while doing the ORC write with: ``` terminate called after throwing an instance of 'rmm::logic_error' what(): RMM failure at:/home/jenkins/agent/workspace/jenkins-spark-rapids-jni_nightly-dev-594-cuda11/thirdparty/cudf/cpp/build/_deps/rmm-src/include/rmm/mr/device/arena_memory_resource.hpp:238: allocation not found ``` The underlying issue is brought about because Spark with the Rapids accelerate is using ARENA allocator with per default streams enabled. CUDF recently added its own stream pool that is used in addition to when per default streams are used. It's now possible to use per thread default streams along with another pool of streams. This means that it's possible for an arena to move from a thread or stream arena back into the global arena during a defragmentation and then move down into another arena type. For instance, thread arena -> global arena -> stream arena. If this happens and there was an allocation from it while it was a thread arena, we now have to check to see if the allocation is part of a stream arena. I added a test here. I was trying to make sure that all the allocations were now in stream arenas, if there is a better way to do this please let me know. Authors: - Thomas Graves (https://github.com/tgravescs) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Bradley Dice (https://github.com/bdice) - Rong Ou (https://github.com/rongou) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1395 --- .../rmm/mr/device/arena_memory_resource.hpp | 21 ++++++++++++- tests/mr/device/arena_mr_tests.cpp | 31 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index 0dbd9c90e..929b8454f 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -235,7 +235,26 @@ class arena_memory_resource final : public device_memory_resource { } } - if (!global_arena_.deallocate(ptr, bytes)) { RMM_FAIL("allocation not found"); } + if (!global_arena_.deallocate(ptr, bytes)) { + // It's possible to use per thread default streams along with another pool of streams. + // This means that it's possible for an allocation to move from a thread or stream arena + // back into the global arena during a defragmentation and then move down into another arena + // type. For instance, thread arena -> global arena -> stream arena. If this happens and + // there was an allocation from it while it was a thread arena, we now have to check to + // see if the allocation is part of a stream arena, and vice versa. + // Only do this in exceptional cases to not affect performance and have to check all + // arenas all the time. + if (use_per_thread_arena(stream)) { + for (auto& stream_arena : stream_arenas_) { + if (stream_arena.second.deallocate(ptr, bytes)) { return; } + } + } else { + for (auto const& thread_arena : thread_arenas_) { + if (thread_arena.second->deallocate(ptr, bytes)) { return; } + } + } + RMM_FAIL("allocation not found"); + } } /** diff --git a/tests/mr/device/arena_mr_tests.cpp b/tests/mr/device/arena_mr_tests.cpp index 48967d06a..7525cac9f 100644 --- a/tests/mr/device/arena_mr_tests.cpp +++ b/tests/mr/device/arena_mr_tests.cpp @@ -533,6 +533,37 @@ TEST_F(ArenaTest, Defragment) // NOLINT }()); } +TEST_F(ArenaTest, PerThreadToStreamDealloc) // NOLINT +{ + // This is testing that deallocation of a ptr still works when + // it was originally allocated in a superblock that was in a thread + // arena that then moved to global arena during a defragmentation + // and then moved to a stream arena. + auto const arena_size = superblock::minimum_size * 2; + arena_mr mr(rmm::mr::get_current_device_resource(), arena_size); + // Create an allocation from a per thread arena + void* thread_ptr = mr.allocate(256, rmm::cuda_stream_per_thread); + // Create an allocation in a stream arena to force global arena + // to be empty + cuda_stream stream{}; + void* ptr = mr.allocate(32_KiB, stream); + mr.deallocate(ptr, 32_KiB, stream); + // at this point the global arena doesn't have any superblocks so + // the next allocation causes defrag. Defrag causes all superblocks + // from the thread and stream arena allocated above to go back to + // global arena and it allocates one superblock to the stream arena. + auto* ptr1 = mr.allocate(superblock::minimum_size, rmm::cuda_stream_view{}); + // Allocate again to make sure all superblocks from + // global arena are owned by a stream arena instead of a thread arena + // or the global arena. + auto* ptr2 = mr.allocate(32_KiB, rmm::cuda_stream_view{}); + // The original thread ptr is now owned by a stream arena so make + // sure deallocation works. + mr.deallocate(thread_ptr, 256, rmm::cuda_stream_per_thread); + mr.deallocate(ptr1, superblock::minimum_size, rmm::cuda_stream_view{}); + mr.deallocate(ptr2, 32_KiB, rmm::cuda_stream_view{}); +} + TEST_F(ArenaTest, DumpLogOnFailure) // NOLINT { arena_mr mr{rmm::mr::get_current_device_resource(), 1_MiB, true}; From ee3817cdde594f19bc665d524b0a3d1d1b588da9 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Thu, 30 Nov 2023 10:38:02 +1000 Subject: [PATCH 323/675] Fix else-after-throw clang tidy error (#1391) Updates code for `RMM_CUDA_TRY_ALLOC` macro in `detail/error.hpp` to eliminate a clang-tidy error. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Rong Ou (https://github.com/rongou) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1391 --- include/rmm/detail/error.hpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/include/rmm/detail/error.hpp b/include/rmm/detail/error.hpp index 6f74dc0ea..bce0d1389 100644 --- a/include/rmm/detail/error.hpp +++ b/include/rmm/detail/error.hpp @@ -230,11 +230,8 @@ class out_of_range : public std::out_of_range { cudaGetLastError(); \ auto const msg = std::string{"CUDA error at: "} + __FILE__ + ":" + RMM_STRINGIFY(__LINE__) + \ ": " + cudaGetErrorName(error) + " " + cudaGetErrorString(error); \ - if (cudaErrorMemoryAllocation == error) { \ - throw rmm::out_of_memory{msg}; \ - } else { \ - throw rmm::bad_alloc{msg}; \ - } \ + if (cudaErrorMemoryAllocation == error) { throw rmm::out_of_memory{msg}; } \ + throw rmm::bad_alloc{msg}; \ } \ } while (0) From d8579b70d7b2ee4714b4e011f266863c3095f0da Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 30 Nov 2023 10:47:18 -0600 Subject: [PATCH 324/675] Update to fmt 10.1.1 and spdlog 1.12.0. (#1374) This PR updates to fmt 10.1.1 and spdlog 1.12. Depends on https://github.com/rapidsai/rapids-cmake/pull/473. Closes https://github.com/rapidsai/rmm/issues/1356 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1374 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 4 ++-- conda/environments/all_cuda-120_arch-x86_64.yaml | 4 ++-- conda/recipes/librmm/conda_build_config.yaml | 4 ++-- dependencies.yaml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 3a5cb90af..09f3ebeed 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -16,7 +16,7 @@ dependencies: - cxx-compiler - cython>=3.0.0 - doxygen=1.9.1 -- fmt>=9.1.0,<10 +- fmt>=10.1.1,<11 - gcc_linux-64=11.* - gcovr>=5.0 - graphviz @@ -34,7 +34,7 @@ dependencies: - pytest-cov - python>=3.9,<3.11 - scikit-build>=0.13.1 -- spdlog>=1.11.0,<1.12 +- spdlog>=1.12.0,<1.13 - sphinx - sphinx-copybutton - sphinx-markdown-tables diff --git a/conda/environments/all_cuda-120_arch-x86_64.yaml b/conda/environments/all_cuda-120_arch-x86_64.yaml index f87564b74..40f1871c2 100644 --- a/conda/environments/all_cuda-120_arch-x86_64.yaml +++ b/conda/environments/all_cuda-120_arch-x86_64.yaml @@ -15,7 +15,7 @@ dependencies: - cxx-compiler - cython>=3.0.0 - doxygen=1.9.1 -- fmt>=9.1.0,<10 +- fmt>=10.1.1,<11 - gcc_linux-64=11.* - gcovr>=5.0 - graphviz @@ -32,7 +32,7 @@ dependencies: - pytest-cov - python>=3.9,<3.11 - scikit-build>=0.13.1 -- spdlog>=1.11.0,<1.12 +- spdlog>=1.12.0,<1.13 - sphinx - sphinx-copybutton - sphinx-markdown-tables diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index 59c0a210e..ed58ac507 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -14,13 +14,13 @@ cmake_version: - ">=3.26.4" fmt_version: - - ">=9.1.0,<10" + - ">=10.1.1,<11" gtest_version: - ">=1.13.0" spdlog_version: - - ">=1.11.0,<1.12" + - ">=1.12.0,<1.13" sysroot_version: - "2.17" diff --git a/dependencies.yaml b/dependencies.yaml index af3f49ef0..805159e62 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -71,8 +71,8 @@ dependencies: packages: - c-compiler - cxx-compiler - - fmt>=9.1.0,<10 - - spdlog>=1.11.0,<1.12 + - fmt>=10.1.1,<11 + - spdlog>=1.12.0,<1.13 - python>=3.9,<3.11 - output_types: pyproject packages: From 22e6a9de0668a5aebe2cc65821346330c500abcd Mon Sep 17 00:00:00 2001 From: Ray Douglass <3107146+raydouglass@users.noreply.github.com> Date: Mon, 4 Dec 2023 14:11:50 -0500 Subject: [PATCH 325/675] Pin actions/labeler to v4 [skip ci] (#1397) RAPIDS repos are using the `main` branch of https://github.com/actions/labeler which recently introduced [breaking changes](https://github.com/actions/labeler/releases/tag/v5.0.0). This PR pins to the latest v4 release of the labeler action until we can evaluate the changes required for v5. Authors: - Ray Douglass (https://github.com/raydouglass) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) --- .github/workflows/labeler.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 7580f81f8..7b0fd52bd 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -7,6 +7,6 @@ jobs: triage: runs-on: ubuntu-latest steps: - - uses: actions/labeler@main + - uses: actions/labeler@v4 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" From 0054957397c3f9faf5dc54ac68350615adf4eab1 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 4 Dec 2023 13:39:20 -0600 Subject: [PATCH 326/675] Fix Arena MR to support simultaneous access by PTDS and other streams (#1395) (#1396) This PR backports #1395 from 24.02 to 23.12. It contains an arena MR fix for simultaneous access by PTDS and other streams. Backport requested by @sameerz @GregoryKimball. Authors: - Thomas Graves (https://github.com/tgravescs) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Mark Harris (https://github.com/harrism) --- .../rmm/mr/device/arena_memory_resource.hpp | 21 ++++++++++++- tests/mr/device/arena_mr_tests.cpp | 31 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index 0dbd9c90e..929b8454f 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -235,7 +235,26 @@ class arena_memory_resource final : public device_memory_resource { } } - if (!global_arena_.deallocate(ptr, bytes)) { RMM_FAIL("allocation not found"); } + if (!global_arena_.deallocate(ptr, bytes)) { + // It's possible to use per thread default streams along with another pool of streams. + // This means that it's possible for an allocation to move from a thread or stream arena + // back into the global arena during a defragmentation and then move down into another arena + // type. For instance, thread arena -> global arena -> stream arena. If this happens and + // there was an allocation from it while it was a thread arena, we now have to check to + // see if the allocation is part of a stream arena, and vice versa. + // Only do this in exceptional cases to not affect performance and have to check all + // arenas all the time. + if (use_per_thread_arena(stream)) { + for (auto& stream_arena : stream_arenas_) { + if (stream_arena.second.deallocate(ptr, bytes)) { return; } + } + } else { + for (auto const& thread_arena : thread_arenas_) { + if (thread_arena.second->deallocate(ptr, bytes)) { return; } + } + } + RMM_FAIL("allocation not found"); + } } /** diff --git a/tests/mr/device/arena_mr_tests.cpp b/tests/mr/device/arena_mr_tests.cpp index 48967d06a..7525cac9f 100644 --- a/tests/mr/device/arena_mr_tests.cpp +++ b/tests/mr/device/arena_mr_tests.cpp @@ -533,6 +533,37 @@ TEST_F(ArenaTest, Defragment) // NOLINT }()); } +TEST_F(ArenaTest, PerThreadToStreamDealloc) // NOLINT +{ + // This is testing that deallocation of a ptr still works when + // it was originally allocated in a superblock that was in a thread + // arena that then moved to global arena during a defragmentation + // and then moved to a stream arena. + auto const arena_size = superblock::minimum_size * 2; + arena_mr mr(rmm::mr::get_current_device_resource(), arena_size); + // Create an allocation from a per thread arena + void* thread_ptr = mr.allocate(256, rmm::cuda_stream_per_thread); + // Create an allocation in a stream arena to force global arena + // to be empty + cuda_stream stream{}; + void* ptr = mr.allocate(32_KiB, stream); + mr.deallocate(ptr, 32_KiB, stream); + // at this point the global arena doesn't have any superblocks so + // the next allocation causes defrag. Defrag causes all superblocks + // from the thread and stream arena allocated above to go back to + // global arena and it allocates one superblock to the stream arena. + auto* ptr1 = mr.allocate(superblock::minimum_size, rmm::cuda_stream_view{}); + // Allocate again to make sure all superblocks from + // global arena are owned by a stream arena instead of a thread arena + // or the global arena. + auto* ptr2 = mr.allocate(32_KiB, rmm::cuda_stream_view{}); + // The original thread ptr is now owned by a stream arena so make + // sure deallocation works. + mr.deallocate(thread_ptr, 256, rmm::cuda_stream_per_thread); + mr.deallocate(ptr1, superblock::minimum_size, rmm::cuda_stream_view{}); + mr.deallocate(ptr2, 32_KiB, rmm::cuda_stream_view{}); +} + TEST_F(ArenaTest, DumpLogOnFailure) // NOLINT { arena_mr mr{rmm::mr::get_current_device_resource(), 1_MiB, true}; From 3d8faff72a1084afde724f9966be0fa911938ad2 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Wed, 6 Dec 2023 09:58:16 -0500 Subject: [PATCH 327/675] Update Changelog [skip ci] --- CHANGELOG.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 901b3790a..930ad9490 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,43 @@ +# RMM 23.12.00 (6 Dec 2023) + +## 🚨 Breaking Changes + +- Document minimum CUDA version of 11.4 ([#1385](https://github.com/rapidsai/rmm/pull/1385)) [@harrism](https://github.com/harrism) +- Store and set the correct CUDA device in device_buffer ([#1370](https://github.com/rapidsai/rmm/pull/1370)) [@harrism](https://github.com/harrism) +- Use `cuda::mr::memory_resource` instead of raw `device_memory_resource` ([#1095](https://github.com/rapidsai/rmm/pull/1095)) [@miscco](https://github.com/miscco) + +## 🐛 Bug Fixes + +- Update actions/labeler to v4 ([#1397](https://github.com/rapidsai/rmm/pull/1397)) [@raydouglass](https://github.com/raydouglass) +- Backport arena MR fix for simultaneous access by PTDS and other streams ([#1396](https://github.com/rapidsai/rmm/pull/1396)) [@bdice](https://github.com/bdice) +- Deliberately leak PTDS thread_local events in stream ordered mr ([#1375](https://github.com/rapidsai/rmm/pull/1375)) [@wence-](https://github.com/wence-) +- Add missing CUDA 12 dependencies and fix dlopen library names ([#1366](https://github.com/rapidsai/rmm/pull/1366)) [@vyasr](https://github.com/vyasr) + +## 📖 Documentation + +- Document minimum CUDA version of 11.4 ([#1385](https://github.com/rapidsai/rmm/pull/1385)) [@harrism](https://github.com/harrism) +- Fix more doxygen issues ([#1367](https://github.com/rapidsai/rmm/pull/1367)) [@vyasr](https://github.com/vyasr) +- Add groups to the doxygen docs ([#1358](https://github.com/rapidsai/rmm/pull/1358)) [@vyasr](https://github.com/vyasr) +- Enable doxygen XML and fix issues ([#1348](https://github.com/rapidsai/rmm/pull/1348)) [@vyasr](https://github.com/vyasr) + +## 🚀 New Features + +- Make internally stored default argument values public ([#1373](https://github.com/rapidsai/rmm/pull/1373)) [@vyasr](https://github.com/vyasr) +- Store and set the correct CUDA device in device_buffer ([#1370](https://github.com/rapidsai/rmm/pull/1370)) [@harrism](https://github.com/harrism) +- Update rapids-cmake functions to non-deprecated signatures ([#1357](https://github.com/rapidsai/rmm/pull/1357)) [@robertmaynard](https://github.com/robertmaynard) +- Generate unified Python/C++ docs ([#1324](https://github.com/rapidsai/rmm/pull/1324)) [@vyasr](https://github.com/vyasr) +- Use `cuda::mr::memory_resource` instead of raw `device_memory_resource` ([#1095](https://github.com/rapidsai/rmm/pull/1095)) [@miscco](https://github.com/miscco) + +## 🛠️ Improvements + +- Silence false gcc warning ([#1381](https://github.com/rapidsai/rmm/pull/1381)) [@miscco](https://github.com/miscco) +- Build concurrency for nightly and merge triggers ([#1380](https://github.com/rapidsai/rmm/pull/1380)) [@bdice](https://github.com/bdice) +- Update `shared-action-workflows` references ([#1363](https://github.com/rapidsai/rmm/pull/1363)) [@AyodeAwe](https://github.com/AyodeAwe) +- Use branch-23.12 workflows. ([#1360](https://github.com/rapidsai/rmm/pull/1360)) [@bdice](https://github.com/bdice) +- Update devcontainers to 23.12 ([#1355](https://github.com/rapidsai/rmm/pull/1355)) [@raydouglass](https://github.com/raydouglass) +- Generate proper, consistent nightly versions for pip and conda packages ([#1347](https://github.com/rapidsai/rmm/pull/1347)) [@vyasr](https://github.com/vyasr) +- RMM: Build CUDA 12.0 ARM conda packages. ([#1330](https://github.com/rapidsai/rmm/pull/1330)) [@bdice](https://github.com/bdice) + # RMM 23.10.00 (11 Oct 2023) ## 🚨 Breaking Changes From cd63a08d3cfb896894a54de9c9fcff5be4b120a0 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 6 Dec 2023 12:36:18 -0800 Subject: [PATCH 328/675] Remove RMM_BUILD_WHEELS and standardize Python builds (#1401) Some minor simplification in advance of the scikit-build-core migration to better align wheel and non-wheel Python builds. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Robert Maynard (https://github.com/robertmaynard) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1401 --- ci/build_wheel.sh | 2 +- python/CMakeLists.txt | 12 ++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh index 6d887e5d2..b2d953361 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel.sh @@ -31,7 +31,7 @@ fi cd "${package_dir}" -SKBUILD_CONFIGURE_OPTIONS="-DRMM_BUILD_WHEELS=ON" python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check +python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check mkdir -p final_dist python -m auditwheel repair -w final_dist dist/* diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 35f034421..dc18af3fd 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -29,7 +29,6 @@ project( option(FIND_RMM_CPP "Search for existing RMM C++ installations before defaulting to local files" OFF) -option(RMM_BUILD_WHEELS "Whether this build is generating a Python wheel." OFF) # If the user requested it we attempt to find RMM. if(FIND_RMM_CPP) @@ -41,16 +40,9 @@ endif() if(NOT rmm_FOUND) set(BUILD_TESTS OFF) set(BUILD_BENCHMARKS OFF) + set(CUDA_STATIC_RUNTIME ON) - set(_exclude_from_all "") - if(RMM_BUILD_WHEELS) - # Statically link dependencies if building wheels - set(CUDA_STATIC_RUNTIME ON) - # Don't install the rmm C++ targets into wheels - set(_exclude_from_all EXCLUDE_FROM_ALL) - endif() - - add_subdirectory(../ rmm-cpp ${_exclude_from_all}) + add_subdirectory(../ rmm-cpp EXCLUDE_FROM_ALL) endif() include(rapids-cython) From 53c80437d80d03b7e07e864a57c9ace55d8736f2 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 11 Dec 2023 11:34:08 -0600 Subject: [PATCH 329/675] Use latest cuda-python within CUDA major version. (#1406) This PR updates cuda-python. The CUDA 11 build was locked to an outdated version (11.7.1). This matches the specifications in dependencies.yaml and also cudf recipes. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1406 --- conda/recipes/rmm/meta.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index b3457d922..477927e27 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -53,10 +53,10 @@ requirements: - cuda-version ={{ cuda_version }} {% if cuda_major == "11" %} - cudatoolkit - - cuda-python ==11.7.1 + - cuda-python >=11.7.1,<12.0a0 {% else %} - cuda-cudart-dev - - cuda-python ==12.0.0 + - cuda-python >=12.0,<13.0a0 {% endif %} - cython >=3.0.0 - librmm ={{ version }} From 57ed533b4f3cf3ccff9b9d2412c445212ebf0861 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 13 Dec 2023 15:08:50 -0800 Subject: [PATCH 330/675] Switch to scikit-build-core (#1287) Contributes to rapidsai/build-planning#2 Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1287 --- README.md | 2 +- build.sh | 2 +- .../all_cuda-118_arch-x86_64.yaml | 3 +-- .../all_cuda-120_arch-x86_64.yaml | 3 +-- conda/recipes/rmm/meta.yaml | 4 +--- dependencies.yaml | 8 +++---- python/CMakeLists.txt | 8 ++----- python/pyproject.toml | 22 +++++++++++-------- python/setup.py | 11 ---------- 9 files changed, 23 insertions(+), 40 deletions(-) delete mode 100644 python/setup.py diff --git a/README.md b/README.md index 56bc86632..a5c626253 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ CUDA/GPU requirements: You can obtain CUDA from [https://developer.nvidia.com/cuda-downloads](https://developer.nvidia.com/cuda-downloads) Python requirements: -* `scikit-build` +* `scikit-build-core` * `cuda-python` * `cython` diff --git a/build.sh b/build.sh index ed37b5973..ec08fa402 100755 --- a/build.sh +++ b/build.sh @@ -176,5 +176,5 @@ fi # Build and install the rmm Python package if (( NUMARGS == 0 )) || hasArg rmm; then echo "building and installing rmm..." - SKBUILD_CONFIGURE_OPTIONS="${SKBUILD_EXTRA_CMAKE_ARGS}" python -m pip install --no-build-isolation --no-deps ${REPODIR}/python + SKBUILD_CMAKE_ARGS="${SKBUILD_EXTRA_CMAKE_ARGS}" python -m pip install --no-build-isolation --no-deps ${REPODIR}/python fi diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 09f3ebeed..595c9fae3 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -33,12 +33,11 @@ dependencies: - pytest - pytest-cov - python>=3.9,<3.11 -- scikit-build>=0.13.1 +- scikit-build-core>=0.7.0 - spdlog>=1.12.0,<1.13 - sphinx - sphinx-copybutton - sphinx-markdown-tables - sphinx_rtd_theme - sysroot_linux-64==2.17 -- tomli name: all_cuda-118_arch-x86_64 diff --git a/conda/environments/all_cuda-120_arch-x86_64.yaml b/conda/environments/all_cuda-120_arch-x86_64.yaml index 40f1871c2..2f9c9297c 100644 --- a/conda/environments/all_cuda-120_arch-x86_64.yaml +++ b/conda/environments/all_cuda-120_arch-x86_64.yaml @@ -31,12 +31,11 @@ dependencies: - pytest - pytest-cov - python>=3.9,<3.11 -- scikit-build>=0.13.1 +- scikit-build-core>=0.7.0 - spdlog>=1.12.0,<1.13 - sphinx - sphinx-copybutton - sphinx-markdown-tables - sphinx_rtd_theme - sysroot_linux-64==2.17 -- tomli name: all_cuda-120_arch-x86_64 diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 477927e27..1e50853b6 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -61,9 +61,7 @@ requirements: - cython >=3.0.0 - librmm ={{ version }} - python - - scikit-build >=0.13.1 - - setuptools >=61.0.0 - - tomli # [py<311] + - scikit-build-core >=0.7.0 run: {% if cuda_major == "11" %} - cudatoolkit diff --git a/dependencies.yaml b/dependencies.yaml index 805159e62..336852d53 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -65,19 +65,17 @@ dependencies: - &cmake_ver cmake>=3.26.4 - cython>=3.0.0 - ninja - - scikit-build>=0.13.1 - - tomli - output_types: conda packages: - c-compiler - cxx-compiler - fmt>=10.1.1,<11 + - scikit-build-core>=0.7.0 - spdlog>=1.12.0,<1.13 - python>=3.9,<3.11 - - output_types: pyproject + - output_types: [requirements, pyproject] packages: - - wheel - - setuptools>=61.0.0 + - scikit-build-core[pyproject]>=0.7.0 specific: - output_types: conda matrices: diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index dc18af3fd..635c4d3b5 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -21,11 +21,7 @@ include(../fetch_rapids.cmake) project( rmm-python VERSION ${rmm_version} - LANGUAGES # TODO: Building Python extension modules via the python_extension_module requires the C - # language to be enabled here. The test project that is built in scikit-build to verify - # various linking options for the python library is hardcoded to build with C, so until - # that is fixed we need to keep C. - C CXX) + LANGUAGES CXX) option(FIND_RMM_CPP "Search for existing RMM C++ installations before defaulting to local files" OFF) @@ -45,7 +41,7 @@ if(NOT rmm_FOUND) add_subdirectory(../ rmm-cpp EXCLUDE_FROM_ALL) endif() -include(rapids-cython) +include(rapids-cython-core) rapids_cython_init() add_compile_definitions("SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") diff --git a/python/pyproject.toml b/python/pyproject.toml index 751d9a674..1e901b1ab 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -13,16 +13,13 @@ # limitations under the License. [build-system] -build-backend = "setuptools.build_meta" +build-backend = "scikit_build_core.build" requires = [ "cmake>=3.26.4", "cuda-python>=11.7.1,<12.0a0", "cython>=3.0.0", "ninja", - "scikit-build>=0.13.1", - "setuptools>=61.0.0", - "tomli", - "wheel", + "scikit-build-core[pyproject]>=0.7.0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../dependencies.yaml and run `rapids-dependency-file-generator`. [project] @@ -112,8 +109,15 @@ skip = [ "__init__.py", ] -[tool.setuptools] -license-files = ["LICENSE"] +[tool.scikit-build] +build-dir = "build/{wheel_tag}" +cmake.build-type = "Release" +cmake.minimum-version = "3.26.4" +ninja.make-fallback = true +sdist.reproducible = true +wheel.packages = ["rmm"] -[tool.setuptools.dynamic] -version = {file = "rmm/VERSION"} +[tool.scikit-build.metadata.version] +provider = "scikit_build_core.metadata.regex" +input = "rmm/VERSION" +regex = "(?P.*)" diff --git a/python/setup.py b/python/setup.py deleted file mode 100644 index af5750044..000000000 --- a/python/setup.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2019-2023, NVIDIA CORPORATION. - -from setuptools import find_packages -from skbuild import setup - -packages = find_packages(include=["rmm*"]) -setup( - packages=packages, - package_data={key: ["VERSION", "*.pxd"] for key in packages}, - zip_safe=False, -) From 362b9352bb71145ef6c449697dd4e81ecffb2475 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 13 Dec 2023 19:07:34 -0600 Subject: [PATCH 331/675] Define python dependency range as a matrix fallback. (#1409) This PR moves the definition of `python>=3.9,<3.11` into the `py_version` dependency list, under the empty (fallback) matrix. This change aligns RMM's `dependencies.yaml` with other RAPIDS repositories. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1409 --- dependencies.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dependencies.yaml b/dependencies.yaml index 336852d53..0be702c60 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -11,6 +11,7 @@ files: - cudatoolkit - develop - docs + - py_version - run - test_python test_python: @@ -72,7 +73,6 @@ dependencies: - fmt>=10.1.1,<11 - scikit-build-core>=0.7.0 - spdlog>=1.12.0,<1.13 - - python>=3.9,<3.11 - output_types: [requirements, pyproject] packages: - scikit-build-core[pyproject]>=0.7.0 @@ -195,6 +195,9 @@ dependencies: py: "3.10" packages: - python=3.10 + - matrix: + packages: + - python>=3.9,<3.11 run: common: - output_types: [conda, requirements, pyproject] From 0b931f6615ee31d54b26810a1eb5223f4ac57e31 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Thu, 14 Dec 2023 12:29:59 +0000 Subject: [PATCH 332/675] Correct signatures for torch allocator plug in (#1407) Since https://github.com/pytorch/pytorch/pull/91398, the signature of the pluggable allocate and deallocate functions must accept the device id. The current version only accepts a device id for allocate, which means that when using a stream ordered allocator with devices other than device zero, we pass an invalid stream into the deallocation function. To fix this, adapt the signature to match the one pytorch expects. Now, since we have the device available during allocation and deallocation, we would like to use that device to obtain the appropriate memory resource. Unfortunately, since RMM's cuda_device_id does not have a nullary constructor, we can't use it in Cython without some hacky workarounds. However, since we don't actually need to build a Python module, but rather just a single shared library that offers two extern "C" functions, let's just write our allocator hooks directly in C++. - Closes #1405 Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Mark Harris (https://github.com/harrism) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1407 --- .gitignore | 1 + python/rmm/_lib/CMakeLists.txt | 13 ++++-- python/rmm/_lib/_torch_allocator.cpp | 60 ++++++++++++++++++++++++++++ python/rmm/_lib/torch_allocator.pyx | 24 ----------- python/rmm/allocators/torch.py | 9 +++-- 5 files changed, 76 insertions(+), 31 deletions(-) create mode 100644 python/rmm/_lib/_torch_allocator.cpp delete mode 100644 python/rmm/_lib/torch_allocator.pyx diff --git a/.gitignore b/.gitignore index af14a9534..f4993502b 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ rmm.egg-info/ python/build python/*/build python/rmm/**/_lib/**/*.cpp +!python/rmm/_lib/_torch_allocator.cpp python/rmm/**/_lib/**/*.h python/rmm/**/_lib/.nfs* python/rmm/_cuda/*.cpp diff --git a/python/rmm/_lib/CMakeLists.txt b/python/rmm/_lib/CMakeLists.txt index 852dd87c4..980217f0c 100644 --- a/python/rmm/_lib/CMakeLists.txt +++ b/python/rmm/_lib/CMakeLists.txt @@ -12,12 +12,17 @@ # the License. # ============================================================================= -set(cython_sources device_buffer.pyx lib.pyx logger.pyx memory_resource.pyx cuda_stream.pyx - torch_allocator.pyx) +set(cython_sources device_buffer.pyx lib.pyx logger.pyx memory_resource.pyx cuda_stream.pyx) set(linked_libraries rmm::rmm) # Build all of the Cython targets rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}" CXX) -# The cdef public functions in this file need to have a C ABI -target_compile_definitions(torch_allocator PRIVATE CYTHON_EXTERN_C=extern\ "C") + +add_library(_torch_allocator SHARED _torch_allocator.cpp) +# Want the output to be called _torch_allocator.so +set_target_properties(_torch_allocator PROPERTIES PREFIX "" SUFFIX ".so") +target_link_libraries(_torch_allocator PRIVATE rmm::rmm) +cmake_path(RELATIVE_PATH CMAKE_CURRENT_SOURCE_DIR BASE_DIRECTORY "${PROJECT_SOURCE_DIR}" + OUTPUT_VARIABLE _torch_allocator_location) +install(TARGETS _torch_allocator DESTINATION "${_torch_allocator_location}") diff --git a/python/rmm/_lib/_torch_allocator.cpp b/python/rmm/_lib/_torch_allocator.cpp new file mode 100644 index 000000000..5e5b2dcb4 --- /dev/null +++ b/python/rmm/_lib/_torch_allocator.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2023, 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. + */ + +#include + +#include +#include +#include + +// These signatures must match those required by CUDAPluggableAllocator in +// github.com/pytorch/pytorch/blob/main/torch/csrc/cuda/CUDAPluggableAllocator.h +// Since the loading is done at runtime via dlopen, no error checking +// can be performed for mismatching signatures. + +/** + * @brief Allocate memory of at least \p size bytes. + * + * @throws rmm::bad_alloc When the requested allocation cannot be satisfied. + * + * @param size The number of bytes to allocate + * @param device The device whose memory resource one should use + * @param stream CUDA stream to perform allocation on + * @return Pointer to the newly allocated memory + */ +extern "C" void* allocate(std::size_t size, int device, void* stream) +{ + rmm::cuda_device_id const device_id{device}; + rmm::cuda_set_device_raii with_device{device_id}; + auto mr = rmm::mr::get_per_device_resource(device_id); + return mr->allocate(size, rmm::cuda_stream_view{static_cast(stream)}); +} + +/** + * @brief Deallocate memory pointed to by \p ptr. + * + * @param ptr Pointer to be deallocated + * @param size The number of bytes in the allocation + * @param device The device whose memory resource one should use + * @param stream CUDA stream to perform deallocation on + */ +extern "C" void deallocate(void* ptr, std::size_t size, int device, void* stream) +{ + rmm::cuda_device_id const device_id{device}; + rmm::cuda_set_device_raii with_device{device_id}; + auto mr = rmm::mr::get_per_device_resource(device_id); + mr->deallocate(ptr, size, rmm::cuda_stream_view{static_cast(stream)}); +} diff --git a/python/rmm/_lib/torch_allocator.pyx b/python/rmm/_lib/torch_allocator.pyx deleted file mode 100644 index 12dc9fe11..000000000 --- a/python/rmm/_lib/torch_allocator.pyx +++ /dev/null @@ -1,24 +0,0 @@ -from cuda.ccudart cimport cudaStream_t - -from rmm._lib.cuda_stream_view cimport cuda_stream_view -from rmm._lib.memory_resource cimport device_memory_resource -from rmm._lib.per_device_resource cimport get_current_device_resource - - -cdef public void* allocate( - ssize_t size, int device, void* stream -) except * with gil: - cdef device_memory_resource* mr = get_current_device_resource() - cdef cuda_stream_view stream_view = cuda_stream_view( - (stream) - ) - return mr[0].allocate(size, stream_view) - -cdef public void deallocate( - void* ptr, ssize_t size, void* stream -) except * with gil: - cdef device_memory_resource* mr = get_current_device_resource() - cdef cuda_stream_view stream_view = cuda_stream_view( - (stream) - ) - mr[0].deallocate(ptr, size, stream_view) diff --git a/python/rmm/allocators/torch.py b/python/rmm/allocators/torch.py index 65b310a89..35081f7f5 100644 --- a/python/rmm/allocators/torch.py +++ b/python/rmm/allocators/torch.py @@ -16,11 +16,14 @@ except ImportError: rmm_torch_allocator = None else: - import rmm._lib.torch_allocator + import pathlib - _alloc_free_lib_path = rmm._lib.torch_allocator.__file__ + sofile = ( + pathlib.Path(__file__).parent.parent / "_lib" / "_torch_allocator.so" + ) rmm_torch_allocator = CUDAPluggableAllocator( - _alloc_free_lib_path, + str(sofile.absolute()), alloc_fn_name="allocate", free_fn_name="deallocate", ) + del pathlib, sofile From ec7b164419809afe7edfcecf89c863681d373d7b Mon Sep 17 00:00:00 2001 From: Ray Douglass <3107146+raydouglass@users.noreply.github.com> Date: Thu, 14 Dec 2023 09:41:51 -0500 Subject: [PATCH 333/675] Update CODEOWNERS (#1410) --- .github/CODEOWNERS | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 3c02b406c..c9a4cba83 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -14,5 +14,4 @@ python/ @rapidsai/rmm-python-codeowners .github/ @rapidsai/ops-codeowners ci/ @rapidsai/ops-codeowners conda/ @rapidsai/ops-codeowners -**/Dockerfile @rapidsai/ops-codeowners -**/.dockerignore @rapidsai/ops-codeowners +dependencies.yaml @rapidsai/ops-codeowners From cf146178b532dbacc88fdf5cadb1b351f0bdec5b Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Mon, 18 Dec 2023 15:36:47 +1000 Subject: [PATCH 334/675] Update GPU support docs to drop Pascal (#1413) We are dropping Pascal support in 24.02 (see https://github.com/rapidsai/rapids-cmake/pull/482) This PR changes the way we document GPU support in RMM to explain what is tested and supported rather than what is required (since it may work on earlier hardware than we test/support). Authors: - Mark Harris (https://github.com/harrism) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1413 --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a5c626253..5aa7daab9 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,12 @@ Compiler requirements: CUDA/GPU requirements: -* CUDA 11.4+ -* Pascal architecture or better +* CUDA 11.4+. You can obtain CUDA from + [https://developer.nvidia.com/cuda-downloads](https://developer.nvidia.com/cuda-downloads) -You can obtain CUDA from [https://developer.nvidia.com/cuda-downloads](https://developer.nvidia.com/cuda-downloads) +GPU Support: +* RMM is tested and supported only on Volta architecture and newer (Compute Capability 7.0+). It + may work on earlier architectures. Python requirements: * `scikit-build-core` From 77b55003b5ae598b7c26553ff39c5dde369c73d8 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 18 Dec 2023 14:47:17 -0800 Subject: [PATCH 335/675] Remove HTML builds of librmm (#1415) We no longer require separate librmm doc builds since they are incorporated into the Sphinx build now. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1415 --- ci/build_docs.sh | 2 -- doxygen/Doxyfile | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/ci/build_docs.sh b/ci/build_docs.sh index e11a9f35b..64c17fec8 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -31,8 +31,6 @@ export RAPIDS_DOCS_DIR="$(mktemp -d)" rapids-logger "Build CPP docs" pushd doxygen doxygen Doxyfile -mkdir -p "${RAPIDS_DOCS_DIR}/librmm/html" -mv html/* "${RAPIDS_DOCS_DIR}/librmm/html" popd rapids-logger "Build Python docs" diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index e956411f2..149603f59 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -1135,7 +1135,7 @@ IGNORE_PREFIX = # If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output # The default value is: YES. -GENERATE_HTML = YES +GENERATE_HTML = NO # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of From a4dd4f5001a25b0fc1a1e35380c9c8564f3f7354 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 19 Dec 2023 10:03:19 -0600 Subject: [PATCH 336/675] Update to CCCL 2.2.0. (#1404) This PR updates RMM to CCCL 2.2.0. Do not merge until all of RAPIDS is ready to update. Depends on https://github.com/rapidsai/rapids-cmake/pull/495. Replaces #1247. Authors: - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Mark Harris (https://github.com/harrism) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1404 --- CMakeLists.txt | 21 ++++----------- .../{get_libcudacxx.cmake => get_cccl.cmake} | 10 +++---- cmake/thirdparty/get_thrust.cmake | 26 ------------------- scripts/load-pretty-printers.in | 2 +- 4 files changed, 11 insertions(+), 48 deletions(-) rename cmake/thirdparty/{get_libcudacxx.cmake => get_cccl.cmake} (75%) delete mode 100644 cmake/thirdparty/get_thrust.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 795969a5c..744307a06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,8 +70,7 @@ rapids_cpm_init() include(cmake/thirdparty/get_fmt.cmake) include(cmake/thirdparty/get_spdlog.cmake) -include(cmake/thirdparty/get_libcudacxx.cmake) -include(cmake/thirdparty/get_thrust.cmake) +include(cmake/thirdparty/get_cccl.cmake) # ################################################################################################## # * library targets -------------------------------------------------------------------------------- @@ -90,8 +89,7 @@ else() target_link_libraries(rmm INTERFACE CUDA::cudart) endif() -target_link_libraries(rmm INTERFACE libcudacxx::libcudacxx) -target_link_libraries(rmm INTERFACE rmm::Thrust) +target_link_libraries(rmm INTERFACE CCCL::CCCL) target_link_libraries(rmm INTERFACE fmt::fmt-header-only) target_link_libraries(rmm INTERFACE spdlog::spdlog_header_only) target_link_libraries(rmm INTERFACE dl) @@ -152,20 +150,12 @@ The goal of the [RMM](https://github.com/rapidsai/rmm) is to provide: A collection of data structures that use the interface for memory allocation ]=]) -set(code_string - [=[ -if(NOT TARGET rmm::Thrust) - thrust_create_target(rmm::Thrust FROM_OPTIONS) -endif() -]=]) - rapids_export( INSTALL rmm EXPORT_SET rmm-exports GLOBAL_TARGETS rmm NAMESPACE rmm:: - DOCUMENTATION doc_string - FINAL_CODE_BLOCK code_string) + DOCUMENTATION doc_string) # ################################################################################################## # * build export ----------------------------------------------------------------------------------- @@ -175,8 +165,7 @@ rapids_export( EXPORT_SET rmm-exports GLOBAL_TARGETS rmm NAMESPACE rmm:: - DOCUMENTATION doc_string - FINAL_CODE_BLOCK code_string) + DOCUMENTATION doc_string) # ################################################################################################## # * make documentation ----------------------------------------------------------------------------- @@ -197,6 +186,6 @@ add_custom_target( # * make gdb helper scripts ------------------------------------------------------------------------ # optionally assemble Thrust pretty-printers -if(Thrust_SOURCE_DIR) +if(CCCL_SOURCE_DIR) configure_file(scripts/load-pretty-printers.in load-pretty-printers @ONLY) endif() diff --git a/cmake/thirdparty/get_libcudacxx.cmake b/cmake/thirdparty/get_cccl.cmake similarity index 75% rename from cmake/thirdparty/get_libcudacxx.cmake rename to cmake/thirdparty/get_cccl.cmake index 14b0d492f..ca6a8654e 100644 --- a/cmake/thirdparty/get_libcudacxx.cmake +++ b/cmake/thirdparty/get_cccl.cmake @@ -12,12 +12,12 @@ # the License. # ============================================================================= -# Use CPM to find or clone libcudacxx -function(find_and_configure_libcudacxx) +# Use CPM to find or clone CCCL +function(find_and_configure_cccl) - include(${rapids-cmake-dir}/cpm/libcudacxx.cmake) - rapids_cpm_libcudacxx(BUILD_EXPORT_SET rmm-exports INSTALL_EXPORT_SET rmm-exports) + include(${rapids-cmake-dir}/cpm/cccl.cmake) + rapids_cpm_cccl(BUILD_EXPORT_SET rmm-exports INSTALL_EXPORT_SET rmm-exports) endfunction() -find_and_configure_libcudacxx() +find_and_configure_cccl() diff --git a/cmake/thirdparty/get_thrust.cmake b/cmake/thirdparty/get_thrust.cmake deleted file mode 100644 index f4125e512..000000000 --- a/cmake/thirdparty/get_thrust.cmake +++ /dev/null @@ -1,26 +0,0 @@ -# ============================================================================= -# Copyright (c) 2021, 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. -# ============================================================================= - -# Use CPM to find or clone thrust -function(find_and_configure_thrust) - - include(${rapids-cmake-dir}/cpm/thrust.cmake) - rapids_cpm_thrust( - NAMESPACE rmm - BUILD_EXPORT_SET rmm-exports - INSTALL_EXPORT_SET rmm-exports) - -endfunction() - -find_and_configure_thrust() diff --git a/scripts/load-pretty-printers.in b/scripts/load-pretty-printers.in index bd59968cc..a473bc5ad 100644 --- a/scripts/load-pretty-printers.in +++ b/scripts/load-pretty-printers.in @@ -1,2 +1,2 @@ -source @Thrust_SOURCE_DIR@/scripts/gdb-pretty-printers.py +source @CCCL_SOURCE_DIR@/thrust/scripts/gdb-pretty-printers.py source @PROJECT_SOURCE_DIR@/scripts/gdb-pretty-printers.py From e2dc7279d9a6bed2860697bcb5155a0ee6e57efe Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 2 Jan 2024 15:33:45 -0600 Subject: [PATCH 337/675] Update dependencies.yaml to support CUDA 12.*. (#1414) This PR updates `dependencies.yaml` so that generic CUDA 12.* dependencies can be specified with a glob, like `cuda: "12.*"`. This feature requires `rapids-dependency-file-generator>=1.8.0`, so the pre-commit hook has been updated. I have not yet added support for a specific CUDA version like 12.1 or 12.2. That can be done separately. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1414 --- .pre-commit-config.yaml | 2 +- dependencies.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7f095025a..4df64d11a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - repo: https://github.com/rapidsai/dependency-file-generator - rev: v1.5.1 + rev: v1.8.0 hooks: - id: rapids-dependency-file-generator args: ["--clean"] diff --git a/dependencies.yaml b/dependencies.yaml index 0be702c60..99bb73808 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -109,7 +109,7 @@ dependencies: - output_types: [conda, requirements, pyproject] matrices: - matrix: - cuda: "12.0" + cuda: "12.*" packages: - &cuda_python12 cuda-python>=12.0,<13.0a0 - matrix: # All CUDA 11 versions @@ -208,7 +208,7 @@ dependencies: - output_types: [conda, requirements, pyproject] matrices: - matrix: - cuda: "12.0" + cuda: "12.*" packages: - *cuda_python12 - matrix: # All CUDA 11 versions From 9265976815ffe00ab24eb23d0746c62918d96213 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 8 Jan 2024 16:02:33 -0600 Subject: [PATCH 338/675] remove references to setup.py in docs (#1420) Removes remaining references to `setup.py` in documentation. This project no longer has a `setup.py` as of its switch to `pyproject.toml` + `scikit-build-core` (see #1287, #1300). Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1420 --- CONTRIBUTING.md | 2 +- README.md | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 61ac5873a..e24b94f14 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,7 +37,7 @@ are required. To set up a development environment, follow the steps in the [README](https://github.com/rapidsai/rmm/blob/main/README.md) for cloning the repository and creating the conda environment. Once the environment is created, you can build and install RMM using ```bash -$ python setup.py develop +$ python -m pip install ./python ``` This command will build the RMM Python library inside the clone and automatically make it importable when running Python anywhere on your machine. Remember, if you are unsure about anything, don't hesitate to comment on issues diff --git a/README.md b/README.md index 5aa7daab9..e033ef56f 100644 --- a/README.md +++ b/README.md @@ -127,8 +127,7 @@ $ make test - Build, install, and test the `rmm` python package, in the `python` folder: ```bash -$ python setup.py build_ext --inplace -$ python setup.py install +$ python -m pip install -e ./python $ pytest -v ``` From 5c30e876e63f0e6972fcd0982803490cb90dd9c6 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 11 Jan 2024 10:23:45 -0600 Subject: [PATCH 339/675] Refactor CUDA versions in dependencies.yaml. (#1422) This is a follow-up PR to #1414. I thought some more about how to separate `cuda-version` pinnings (which control the CUDA version we use to build and test in conda) from actual CUDA Toolkit package dependencies (which we can handle according to only the major version 11/12). I discussed this PR on a call with @jameslamb in the context of upgrading to CUDA 12.2 (https://github.com/rapidsai/build-planning/issues/6). This set of changes is mostly important for conda builds/tests, since `cuda-version` only controls conda. The pip wheel build/test process is unchanged, since its CUDA versions are controlled by the `shared-workflows` CI images. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - https://github.com/jakirkham - Vyas Ramasubramani (https://github.com/vyasr) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1422 --- dependencies.yaml | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/dependencies.yaml b/dependencies.yaml index 99bb73808..4d1a0ec49 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -8,7 +8,8 @@ files: includes: - build - checks - - cudatoolkit + - cuda + - cuda_version - develop - docs - py_version @@ -17,13 +18,13 @@ files: test_python: output: none includes: - - cudatoolkit + - cuda_version - py_version - test_python test_cpp: output: none includes: - - cudatoolkit + - cuda_version - test_cpp checks: output: none @@ -33,7 +34,7 @@ files: docs: output: none includes: - - cudatoolkit + - cuda_version - docs - py_version py_build: @@ -102,9 +103,8 @@ dependencies: packages: - nvcc_linux-aarch64=11.8 - matrix: - cuda: "12.0" + cuda: "12.*" packages: - - cuda-version=12.0 - cuda-nvcc - output_types: [conda, requirements, pyproject] matrices: @@ -126,7 +126,7 @@ dependencies: - output_types: conda packages: - &doxygen doxygen=1.9.1 - cudatoolkit: + cuda_version: specific: - output_types: conda matrices: @@ -134,31 +134,37 @@ dependencies: cuda: "11.2" packages: - cuda-version=11.2 - - cudatoolkit - matrix: cuda: "11.4" packages: - cuda-version=11.4 - - cudatoolkit - matrix: cuda: "11.5" packages: - cuda-version=11.5 - - cudatoolkit - matrix: cuda: "11.6" packages: - cuda-version=11.6 - - cudatoolkit - matrix: cuda: "11.8" packages: - cuda-version=11.8 - - cudatoolkit - matrix: cuda: "12.0" packages: - cuda-version=12.0 + cuda: + specific: + - output_types: conda + matrices: + - matrix: + cuda: "11.*" + packages: + - cudatoolkit + - matrix: + cuda: "12.*" + packages: develop: common: - output_types: [conda, requirements] From 40ce29509a1e33e1fdb8e786413f06d35c26ea80 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Fri, 12 Jan 2024 11:59:05 -0500 Subject: [PATCH 340/675] Remove usages of rapids-env-update (#1423) Reference: https://github.com/rapidsai/ops/issues/2766 Replace rapids-env-update with rapids-configure-conda-channels, rapids-configure-sccache, and rapids-date-string. Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1423 --- ci/build_cpp.sh | 6 +++++- ci/build_python.sh | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index d36fcbbe7..7329d4a34 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -3,7 +3,11 @@ set -euo pipefail -source rapids-env-update +rapids-configure-conda-channels + +source rapids-configure-sccache + +source rapids-date-string export CMAKE_GENERATOR=Ninja diff --git a/ci/build_python.sh b/ci/build_python.sh index c1c30da2a..b197b1ae1 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -3,7 +3,11 @@ set -euo pipefail -source rapids-env-update +rapids-configure-conda-channels + +source rapids-configure-sccache + +source rapids-date-string export CMAKE_GENERATOR=Ninja From 64aa9410ec942312f924964647efc7e9e34b392d Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Tue, 16 Jan 2024 07:49:27 +1100 Subject: [PATCH 341/675] Require explicit pool size in `pool_memory_resource` and move some things out of detail namespace (#1417) Fixes #1416. - ~Deprecates existing ctors of `pool_memory_resource` that provide optional parameter for the initial pool size.~ - Adds new ctors that require an explicit initial pool size. - We don't yet deprecate anything in this PR because that would break builds of some RAPIDS libraries. We will follow up with PRs to cuDF, cuGraph and anything else needed to remove deprecated usages after this PR is merged. - Adds a new utility `fraction_of_available_device_memory` that calculates the specified fraction of free memory on the current CUDA device. This is now used in tests to provide an explicit pool size and can be used to produce the previous behavior of `pool_memory_resource` for consumers of the library. - Moves `available_device_memory` from a detail header to `cuda_device.hpp` so it is now publicly usable, along with the above utility. - Temporarily adds `detail::available_device_memory` as an alias of the above in order to keep cudf and cugraph building until we can update them. - Duplicates commonly externally used alignment functions that are currently in `rmm::detail` to the public `rmm` namespace. The detail versions will be removed after cuDF and cuGraph are updated to not use them. Authors: - Mark Harris (https://github.com/harrism) - Lawrence Mitchell (https://github.com/wence-) Approvers: - Michael Schellenberger Costa (https://github.com/miscco) - Lawrence Mitchell (https://github.com/wence-) - Jake Hemstad (https://github.com/jrhemstad) URL: https://github.com/rapidsai/rmm/pull/1417 --- .clang-tidy | 4 +- README.md | 10 +- .../device_uvector/device_uvector_bench.cu | 9 +- .../multi_stream_allocations_bench.cu | 6 +- .../random_allocations/random_allocations.cpp | 8 +- benchmarks/replay/replay.cpp | 4 +- doxygen/Doxyfile | 2 +- include/doxygen_groups.h | 3 +- include/rmm/aligned.hpp | 119 +++++++++++++++++ include/rmm/cuda_device.hpp | 46 ++++++- include/rmm/detail/aligned.hpp | 12 +- include/rmm/detail/cuda_util.hpp | 31 ----- .../mr/device/aligned_resource_adaptor.hpp | 18 +-- .../rmm/mr/device/arena_memory_resource.hpp | 7 +- .../rmm/mr/device/binning_memory_resource.hpp | 7 +- .../mr/device/cuda_async_memory_resource.hpp | 5 +- .../cuda_async_view_memory_resource.hpp | 3 +- include/rmm/mr/device/detail/arena.hpp | 12 +- .../detail/stream_ordered_memory_resource.hpp | 8 +- .../rmm/mr/device/device_memory_resource.hpp | 8 +- .../mr/device/fixed_size_memory_resource.hpp | 9 +- .../mr/device/limiting_resource_adaptor.hpp | 10 +- include/rmm/mr/device/per_device_resource.hpp | 12 +- .../rmm/mr/device/pool_memory_resource.hpp | 121 +++++++++++------- include/rmm/mr/host/new_delete_resource.hpp | 12 +- .../rmm/mr/host/pinned_memory_resource.hpp | 10 +- python/docs/conf.py | 8 +- python/docs/librmm_docs/deprecated.rst | 5 + python/docs/librmm_docs/index.rst | 2 + python/docs/librmm_docs/utilities.rst | 5 + python/rmm/_lib/memory_resource.pyx | 11 +- tests/container_multidevice_tests.cu | 4 +- tests/mr/device/aligned_mr_tests.cpp | 7 +- tests/mr/device/arena_mr_tests.cpp | 16 +-- tests/mr/device/failure_callback_mr_tests.cpp | 9 +- tests/mr/device/mr_ref_test.hpp | 20 +-- tests/mr/device/mr_test.hpp | 16 ++- tests/mr/device/pool_mr_tests.cpp | 22 ++-- tests/mr/host/mr_ref_tests.cpp | 6 +- tests/mr/host/mr_tests.cpp | 6 +- tests/mr/host/pinned_pool_mr_tests.cpp | 5 +- 41 files changed, 420 insertions(+), 218 deletions(-) create mode 100644 include/rmm/aligned.hpp delete mode 100644 include/rmm/detail/cuda_util.hpp create mode 100644 python/docs/librmm_docs/deprecated.rst create mode 100644 python/docs/librmm_docs/utilities.rst diff --git a/.clang-tidy b/.clang-tidy index 9b3f844c9..70a0bea16 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -62,8 +62,8 @@ CheckOptions: value: 'alignment' - key: cppcoreguidelines-avoid-magic-numbers.IgnorePowersOf2IntegerValues value: '1' - - key: readability-magic-numbers.IgnorePowersOf2IntegerValues - value: '1' + - key: cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues + value: "0;1;2;3;4;50;100" - key: cppcoreguidelines-avoid-do-while.IgnoreMacros value: 'true' ... diff --git a/README.md b/README.md index e033ef56f..a1b85d33c 100644 --- a/README.md +++ b/README.md @@ -332,7 +332,9 @@ Accessing and modifying the default resource is done through two functions: ```c++ rmm::mr::cuda_memory_resource cuda_mr; // Construct a resource that uses a coalescing best-fit pool allocator -rmm::mr::pool_memory_resource pool_mr{&cuda_mr}; +// With the pool initially half of available device memory +auto initial_size = rmm::percent_of_free_device_memory(50); +rmm::mr::pool_memory_resource pool_mr{&cuda_mr, initial_size}; rmm::mr::set_current_device_resource(&pool_mr); // Updates the current device resource pointer to `pool_mr` rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource(); // Points to `pool_mr` ``` @@ -351,11 +353,13 @@ per-device resources. Here is an example loop that creates `unique_ptr`s to `poo objects for each device and sets them as the per-device resource for that device. ```c++ -std::vector> per_device_pools; +using pool_mr = rmm::mr::pool_memory_resource; +std::vector> per_device_pools; for(int i = 0; i < N; ++i) { cudaSetDevice(i); // set device i before creating MR // Use a vector of unique_ptr to maintain the lifetime of the MRs - per_device_pools.push_back(std::make_unique()); + // Note: for brevity, omitting creation of upstream and computing initial_size + per_device_pools.push_back(std::make_unique(upstream, initial_size)); // Set the per-device resource for device i set_per_device_resource(cuda_device_id{i}, &per_device_pools.back()); } diff --git a/benchmarks/device_uvector/device_uvector_bench.cu b/benchmarks/device_uvector/device_uvector_bench.cu index 454db81a5..8b7f9a5ba 100644 --- a/benchmarks/device_uvector/device_uvector_bench.cu +++ b/benchmarks/device_uvector/device_uvector_bench.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -16,6 +16,7 @@ #include "../synchronization/synchronization.hpp" +#include #include #include #include @@ -38,7 +39,8 @@ void BM_UvectorSizeConstruction(benchmark::State& state) { rmm::mr::cuda_memory_resource cuda_mr{}; - rmm::mr::pool_memory_resource mr{&cuda_mr}; + rmm::mr::pool_memory_resource mr{ + &cuda_mr, rmm::percent_of_free_device_memory(50)}; rmm::mr::set_current_device_resource(&mr); for (auto _ : state) { // NOLINT(clang-analyzer-deadcode.DeadStores) @@ -59,7 +61,8 @@ BENCHMARK(BM_UvectorSizeConstruction) void BM_ThrustVectorSizeConstruction(benchmark::State& state) { rmm::mr::cuda_memory_resource cuda_mr{}; - rmm::mr::pool_memory_resource mr{&cuda_mr}; + rmm::mr::pool_memory_resource mr{ + &cuda_mr, rmm::percent_of_free_device_memory(50)}; rmm::mr::set_current_device_resource(&mr); for (auto _ : state) { // NOLINT(clang-analyzer-deadcode.DeadStores) diff --git a/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu b/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu index 5ed1b31f9..4943e507f 100644 --- a/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu +++ b/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-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. @@ -16,6 +16,7 @@ #include +#include #include #include #include @@ -100,7 +101,8 @@ inline auto make_cuda_async() { return std::make_shared(make_cuda()); + return rmm::mr::make_owning_wrapper( + make_cuda(), rmm::percent_of_free_device_memory(50)); } inline auto make_arena() diff --git a/benchmarks/random_allocations/random_allocations.cpp b/benchmarks/random_allocations/random_allocations.cpp index 470442830..2856cd323 100644 --- a/benchmarks/random_allocations/random_allocations.cpp +++ b/benchmarks/random_allocations/random_allocations.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -16,6 +16,7 @@ #include +#include #include #include #include @@ -165,12 +166,13 @@ inline auto make_cuda_async() { return std::make_shared(make_cuda()); + return rmm::mr::make_owning_wrapper( + make_cuda(), rmm::percent_of_free_device_memory(50)); } inline auto make_arena() { - auto free = rmm::detail::available_device_memory().first; + auto free = rmm::available_device_memory().first; constexpr auto reserve{64UL << 20}; // Leave some space for CUDA overhead. return rmm::mr::make_owning_wrapper(make_cuda(), free - reserve); } diff --git a/benchmarks/replay/replay.cpp b/benchmarks/replay/replay.cpp index 320811875..253708ace 100644 --- a/benchmarks/replay/replay.cpp +++ b/benchmarks/replay/replay.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -61,7 +61,7 @@ inline auto make_pool(std::size_t simulated_size) return rmm::mr::make_owning_wrapper( make_simulated(simulated_size), simulated_size, simulated_size); } - return rmm::mr::make_owning_wrapper(make_cuda()); + return rmm::mr::make_owning_wrapper(make_cuda(), 0); } inline auto make_arena(std::size_t simulated_size) diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 149603f59..513f15875 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -504,7 +504,7 @@ EXTRACT_PACKAGE = NO # included in the documentation. # The default value is: NO. -EXTRACT_STATIC = NO +EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined # locally in source files will be included in the documentation. If set to NO, diff --git a/include/doxygen_groups.h b/include/doxygen_groups.h index be5eaf17f..70ec0cd68 100644 --- a/include/doxygen_groups.h +++ b/include/doxygen_groups.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, NVIDIA CORPORATION. + * 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. @@ -41,4 +41,5 @@ * @defgroup errors Errors * @defgroup logging Logging * @defgroup thrust_integrations Thrust Integrations + * @defgroup utilities Utilities */ diff --git a/include/rmm/aligned.hpp b/include/rmm/aligned.hpp new file mode 100644 index 000000000..7a0feaabf --- /dev/null +++ b/include/rmm/aligned.hpp @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2020-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. + */ + +#pragma once + +#include +#include +#include + +namespace rmm { + +/** + * @addtogroup utilities + * @{ + * @file + */ + +/** + * @brief Default alignment used for host memory allocated by RMM. + * + */ +static constexpr std::size_t RMM_DEFAULT_HOST_ALIGNMENT{alignof(std::max_align_t)}; + +/** + * @brief Default alignment used for CUDA memory allocation. + * + */ +static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; + +/** + * @brief Returns whether or not `value` is a power of 2. + * + * @param[in] value to check. + * + * @return Whether the input a power of two with non-negative exponent + */ +constexpr bool is_pow2(std::size_t value) { return (value != 0U) && ((value & (value - 1)) == 0U); } + +/** + * @brief Returns whether or not `alignment` is a valid memory alignment. + * + * @param[in] alignment to check + * + * @return Whether the alignment is valid + */ +constexpr bool is_supported_alignment(std::size_t alignment) { return is_pow2(alignment); } + +/** + * @brief Align up to nearest multiple of specified power of 2 + * + * @param[in] value value to align + * @param[in] alignment amount, in bytes, must be a power of 2 + * + * @return Return the aligned value, as one would expect + */ +constexpr std::size_t align_up(std::size_t value, std::size_t alignment) noexcept +{ + assert(is_supported_alignment(alignment)); + return (value + (alignment - 1)) & ~(alignment - 1); +} + +/** + * @brief Align down to the nearest multiple of specified power of 2 + * + * @param[in] value value to align + * @param[in] alignment amount, in bytes, must be a power of 2 + * + * @return Return the aligned value, as one would expect + */ +constexpr std::size_t align_down(std::size_t value, std::size_t alignment) noexcept +{ + assert(is_supported_alignment(alignment)); + return value & ~(alignment - 1); +} + +/** + * @brief Checks whether a value is aligned to a multiple of a specified power of 2 + * + * @param[in] value value to check for alignment + * @param[in] alignment amount, in bytes, must be a power of 2 + * + * @return true if aligned + */ +constexpr bool is_aligned(std::size_t value, std::size_t alignment) noexcept +{ + assert(is_supported_alignment(alignment)); + return value == align_down(value, alignment); +} + +/** + * @brief Checks whether the provided pointer is aligned to a specified @p alignment + * + * @param[in] ptr pointer to check for alignment + * @param[in] alignment required alignment in bytes, must be a power of 2 + * + * @return true if the pointer is aligned + */ +inline bool is_pointer_aligned(void* ptr, std::size_t alignment = CUDA_ALLOCATION_ALIGNMENT) +{ + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) + return is_aligned(reinterpret_cast(ptr), alignment); +} + +/** @} */ // end of group + +} // namespace rmm diff --git a/include/rmm/cuda_device.hpp b/include/rmm/cuda_device.hpp index 054bbb920..565d86926 100644 --- a/include/rmm/cuda_device.hpp +++ b/include/rmm/cuda_device.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-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. @@ -15,6 +15,7 @@ */ #pragma once +#include #include #include @@ -102,6 +103,49 @@ inline int get_num_cuda_devices() return num_dev; } +/** + * @brief Returns the available and total device memory in bytes for the current device + * + * @return The available and total device memory in bytes for the current device as a std::pair. + */ +inline std::pair available_device_memory() +{ + std::size_t free{}; + std::size_t total{}; + RMM_CUDA_TRY(cudaMemGetInfo(&free, &total)); + return {free, total}; +} + +namespace detail { + +/** + * @brief Returns the available and total device memory in bytes for the current device + * + * @deprecated Use rmm::available_device_memory() instead. + * + * @return The available and total device memory in bytes for the current device as a std::pair. + */ +//[[deprecated("Use `rmm::available_device_memory` instead.")]] // +const auto available_device_memory = rmm::available_device_memory; + +} // namespace detail + +/** + * @brief Returns the approximate specified percent of available device memory on the current CUDA + * device, aligned (down) to the nearest CUDA allocation size. + * + * @param percent The percent of free memory to return. + * + * @return The recommended initial device memory pool size in bytes. + */ +inline std::size_t percent_of_free_device_memory(int percent) +{ + [[maybe_unused]] auto const [free, total] = rmm::available_device_memory(); + auto fraction = static_cast(percent) / 100.0; + return rmm::align_down(static_cast(static_cast(free) * fraction), + rmm::CUDA_ALLOCATION_ALIGNMENT); +} + /** * @brief RAII class that sets the current CUDA device to the specified device on construction * and restores the previous device on destruction. diff --git a/include/rmm/detail/aligned.hpp b/include/rmm/detail/aligned.hpp index 321be53b5..54d287bfb 100644 --- a/include/rmm/detail/aligned.hpp +++ b/include/rmm/detail/aligned.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -40,7 +40,7 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; * @brief Returns whether or not `n` is a power of 2. * */ -constexpr bool is_pow2(std::size_t value) { return (0 == (value & (value - 1))); } +constexpr bool is_pow2(std::size_t value) { return (value != 0U) && ((value & (value - 1)) == 0U); } /** * @brief Returns whether or not `alignment` is a valid memory alignment. @@ -51,7 +51,7 @@ constexpr bool is_supported_alignment(std::size_t alignment) { return is_pow2(al /** * @brief Align up to nearest multiple of specified power of 2 * - * @param[in] v value to align + * @param[in] value value to align * @param[in] alignment amount, in bytes, must be a power of 2 * * @return Return the aligned value, as one would expect @@ -65,7 +65,7 @@ constexpr std::size_t align_up(std::size_t value, std::size_t alignment) noexcep /** * @brief Align down to the nearest multiple of specified power of 2 * - * @param[in] v value to align + * @param[in] value value to align * @param[in] alignment amount, in bytes, must be a power of 2 * * @return Return the aligned value, as one would expect @@ -79,7 +79,7 @@ constexpr std::size_t align_down(std::size_t value, std::size_t alignment) noexc /** * @brief Checks whether a value is aligned to a multiple of a specified power of 2 * - * @param[in] v value to check for alignment + * @param[in] value value to check for alignment * @param[in] alignment amount, in bytes, must be a power of 2 * * @return true if aligned @@ -93,7 +93,7 @@ constexpr bool is_aligned(std::size_t value, std::size_t alignment) noexcept inline bool is_pointer_aligned(void* ptr, std::size_t alignment = CUDA_ALLOCATION_ALIGNMENT) { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) - return rmm::detail::is_aligned(reinterpret_cast(ptr), alignment); + return rmm::detail::is_aligned(reinterpret_cast(ptr), alignment); } /** diff --git a/include/rmm/detail/cuda_util.hpp b/include/rmm/detail/cuda_util.hpp deleted file mode 100644 index 613b8d156..000000000 --- a/include/rmm/detail/cuda_util.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2021, 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. - */ -#pragma once - -#include - -namespace rmm::detail { - -/// Gets the available and total device memory in bytes for the current device -inline std::pair available_device_memory() -{ - std::size_t free{}; - std::size_t total{}; - RMM_CUDA_TRY(cudaMemGetInfo(&free, &total)); - return {free, total}; -} - -} // namespace rmm::detail diff --git a/include/rmm/mr/device/aligned_resource_adaptor.hpp b/include/rmm/mr/device/aligned_resource_adaptor.hpp index 05e9915cc..be7c3036c 100644 --- a/include/rmm/mr/device/aligned_resource_adaptor.hpp +++ b/include/rmm/mr/device/aligned_resource_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-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. @@ -15,8 +15,8 @@ */ #pragma once +#include #include -#include #include #include @@ -65,12 +65,12 @@ class aligned_resource_adaptor final : public device_memory_resource { * are aligned. */ explicit aligned_resource_adaptor(Upstream* upstream, - std::size_t alignment = rmm::detail::CUDA_ALLOCATION_ALIGNMENT, + std::size_t alignment = rmm::CUDA_ALLOCATION_ALIGNMENT, std::size_t alignment_threshold = default_alignment_threshold) : upstream_{upstream}, alignment_{alignment}, alignment_threshold_{alignment_threshold} { RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); - RMM_EXPECTS(rmm::detail::is_supported_alignment(alignment), + RMM_EXPECTS(rmm::is_supported_alignment(alignment), "Allocation alignment is not a power of 2."); } @@ -127,14 +127,14 @@ class aligned_resource_adaptor final : public device_memory_resource { */ void* do_allocate(std::size_t bytes, cuda_stream_view stream) override { - if (alignment_ == rmm::detail::CUDA_ALLOCATION_ALIGNMENT || bytes < alignment_threshold_) { + if (alignment_ == rmm::CUDA_ALLOCATION_ALIGNMENT || bytes < alignment_threshold_) { return upstream_->allocate(bytes, stream); } auto const size = upstream_allocation_size(bytes); void* pointer = upstream_->allocate(size, stream); // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) auto const address = reinterpret_cast(pointer); - auto const aligned_address = rmm::detail::align_up(address, alignment_); + auto const aligned_address = rmm::align_up(address, alignment_); // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast,performance-no-int-to-ptr) void* aligned_pointer = reinterpret_cast(aligned_address); if (pointer != aligned_pointer) { @@ -153,7 +153,7 @@ class aligned_resource_adaptor final : public device_memory_resource { */ void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override { - if (alignment_ == rmm::detail::CUDA_ALLOCATION_ALIGNMENT || bytes < alignment_threshold_) { + if (alignment_ == rmm::CUDA_ALLOCATION_ALIGNMENT || bytes < alignment_threshold_) { upstream_->deallocate(ptr, bytes, stream); } else { { @@ -208,8 +208,8 @@ class aligned_resource_adaptor final : public device_memory_resource { */ std::size_t upstream_allocation_size(std::size_t bytes) const { - auto const aligned_size = rmm::detail::align_up(bytes, alignment_); - return aligned_size + alignment_ - rmm::detail::CUDA_ALLOCATION_ALIGNMENT; + auto const aligned_size = rmm::align_up(bytes, alignment_); + return aligned_size + alignment_ - rmm::CUDA_ALLOCATION_ALIGNMENT; } Upstream* upstream_; ///< The upstream resource used for satisfying allocation requests diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index 929b8454f..1b821b440 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -15,6 +15,7 @@ */ #pragma once +#include #include #include #include @@ -145,7 +146,7 @@ class arena_memory_resource final : public device_memory_resource { #ifdef RMM_ARENA_USE_SIZE_CLASSES bytes = rmm::mr::detail::arena::align_to_size_class(bytes); #else - bytes = rmm::detail::align_up(bytes, rmm::detail::CUDA_ALLOCATION_ALIGNMENT); + bytes = rmm::align_up(bytes, rmm::CUDA_ALLOCATION_ALIGNMENT); #endif auto& arena = get_arena(stream); @@ -195,7 +196,7 @@ class arena_memory_resource final : public device_memory_resource { #ifdef RMM_ARENA_USE_SIZE_CLASSES bytes = rmm::mr::detail::arena::align_to_size_class(bytes); #else - bytes = rmm::detail::align_up(bytes, rmm::detail::CUDA_ALLOCATION_ALIGNMENT); + bytes = rmm::align_up(bytes, rmm::CUDA_ALLOCATION_ALIGNMENT); #endif auto& arena = get_arena(stream); diff --git a/include/rmm/mr/device/binning_memory_resource.hpp b/include/rmm/mr/device/binning_memory_resource.hpp index c2e1621a6..2a9975b18 100644 --- a/include/rmm/mr/device/binning_memory_resource.hpp +++ b/include/rmm/mr/device/binning_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -15,7 +15,7 @@ */ #pragma once -#include +#include #include #include @@ -138,8 +138,7 @@ class binning_memory_resource final : public device_memory_resource { */ void add_bin(std::size_t allocation_size, device_memory_resource* bin_resource = nullptr) { - allocation_size = - rmm::detail::align_up(allocation_size, rmm::detail::CUDA_ALLOCATION_ALIGNMENT); + allocation_size = rmm::align_up(allocation_size, rmm::CUDA_ALLOCATION_ALIGNMENT); if (nullptr != bin_resource) { resource_bins_.insert({allocation_size, bin_resource}); diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index de31c7dc4..f8295c6f6 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-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. @@ -17,7 +17,6 @@ #include #include -#include #include #include #include @@ -120,7 +119,7 @@ class cuda_async_memory_resource final : public device_memory_resource { pool_handle(), cudaMemPoolReuseAllowOpportunistic, &disabled)); } - auto const [free, total] = rmm::detail::available_device_memory(); + auto const [free, total] = rmm::available_device_memory(); // Need an l-value to take address to pass to cudaMemPoolSetAttribute uint64_t threshold = release_threshold.value_or(total); diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index 825fcab1e..562944669 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-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. @@ -17,7 +17,6 @@ #include #include -#include #include #include #include diff --git a/include/rmm/mr/device/detail/arena.hpp b/include/rmm/mr/device/detail/arena.hpp index d8da58493..c7965ca34 100644 --- a/include/rmm/mr/device/detail/arena.hpp +++ b/include/rmm/mr/device/detail/arena.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2023, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -16,9 +16,9 @@ #pragma once +#include +#include #include -#include -#include #include #include #include @@ -508,8 +508,8 @@ class global_arena final { : upstream_mr_{upstream_mr} { RMM_EXPECTS(nullptr != upstream_mr_, "Unexpected null upstream pointer."); - auto const size = rmm::detail::align_down(arena_size.value_or(default_size()), - rmm::detail::CUDA_ALLOCATION_ALIGNMENT); + auto const size = + rmm::align_down(arena_size.value_or(default_size()), rmm::CUDA_ALLOCATION_ALIGNMENT); RMM_EXPECTS(size >= superblock::minimum_size, "Arena size smaller than minimum superblock size."); initialize(size); @@ -692,7 +692,7 @@ class global_arena final { */ constexpr std::size_t default_size() const { - auto const [free, total] = rmm::detail::available_device_memory(); + auto const [free, total] = rmm::available_device_memory(); return free / 2; } diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index a57bf1c6d..1d6829cb5 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2023, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -15,8 +15,8 @@ */ #pragma once +#include #include -#include #include #include #include @@ -207,7 +207,7 @@ class stream_ordered_memory_resource : public crtp, public device_ auto stream_event = get_event(stream); - size = rmm::detail::align_up(size, rmm::detail::CUDA_ALLOCATION_ALIGNMENT); + size = rmm::align_up(size, rmm::CUDA_ALLOCATION_ALIGNMENT); RMM_EXPECTS(size <= this->underlying().get_maximum_allocation_size(), "Maximum allocation size exceeded", rmm::out_of_memory); @@ -241,7 +241,7 @@ class stream_ordered_memory_resource : public crtp, public device_ lock_guard lock(mtx_); auto stream_event = get_event(stream); - size = rmm::detail::align_up(size, rmm::detail::CUDA_ALLOCATION_ALIGNMENT); + size = rmm::align_up(size, rmm::CUDA_ALLOCATION_ALIGNMENT); auto const block = this->underlying().free_block(ptr, size); // TODO: cudaEventRecord has significant overhead on deallocations. For the non-PTDS case diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index 63e5f39a4..e3014b6c3 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -78,10 +78,12 @@ namespace rmm::mr { * device. * * @code{.cpp} - * std::vector> per_device_pools; + * using pool_mr = rmm::mr::pool_memory_resource; + * std::vector> per_device_pools; * for(int i = 0; i < N; ++i) { * cudaSetDevice(i); - * per_device_pools.push_back(std::make_unique()); + * // Note: for brevity, omitting creation of upstream and computing initial_size + * per_device_pools.push_back(std::make_unique(upstream, initial_size)); * set_per_device_resource(cuda_device_id{i}, &per_device_pools.back()); * } * @endcode diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index 01fb8a6bc..91cc95c53 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -15,8 +15,8 @@ */ #pragma once +#include #include -#include #include #include #include @@ -77,7 +77,7 @@ class fixed_size_memory_resource std::size_t block_size = default_block_size, std::size_t blocks_to_preallocate = default_blocks_to_preallocate) : upstream_mr_{upstream_mr}, - block_size_{rmm::detail::align_up(block_size, rmm::detail::CUDA_ALLOCATION_ALIGNMENT)}, + block_size_{rmm::align_up(block_size, rmm::CUDA_ALLOCATION_ALIGNMENT)}, upstream_chunk_size_{block_size * blocks_to_preallocate} { // allocate initial blocks and insert into free list @@ -207,8 +207,7 @@ class fixed_size_memory_resource { // Deallocating a fixed-size block just inserts it in the free list, which is // handled by the parent class - RMM_LOGGING_ASSERT(rmm::detail::align_up(size, rmm::detail::CUDA_ALLOCATION_ALIGNMENT) <= - block_size_); + RMM_LOGGING_ASSERT(rmm::align_up(size, rmm::CUDA_ALLOCATION_ALIGNMENT) <= block_size_); return block_type{ptr}; } diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index 6573956d0..2123c3cac 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-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. @@ -15,7 +15,7 @@ */ #pragma once -#include +#include #include #include @@ -54,7 +54,7 @@ class limiting_resource_adaptor final : public device_memory_resource { */ limiting_resource_adaptor(Upstream* upstream, std::size_t allocation_limit, - std::size_t alignment = rmm::detail::CUDA_ALLOCATION_ALIGNMENT) + std::size_t alignment = rmm::CUDA_ALLOCATION_ALIGNMENT) : allocation_limit_{allocation_limit}, allocated_bytes_(0), alignment_(alignment), @@ -134,7 +134,7 @@ class limiting_resource_adaptor final : public device_memory_resource { */ void* do_allocate(std::size_t bytes, cuda_stream_view stream) override { - auto const proposed_size = rmm::detail::align_up(bytes, alignment_); + auto const proposed_size = rmm::align_up(bytes, alignment_); auto const old = allocated_bytes_.fetch_add(proposed_size); if (old + proposed_size <= allocation_limit_) { try { @@ -158,7 +158,7 @@ class limiting_resource_adaptor final : public device_memory_resource { */ void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override { - std::size_t allocated_size = rmm::detail::align_up(bytes, alignment_); + std::size_t allocated_size = rmm::align_up(bytes, alignment_); upstream_->deallocate(ptr, bytes, stream); allocated_bytes_ -= allocated_size; } diff --git a/include/rmm/mr/device/per_device_resource.hpp b/include/rmm/mr/device/per_device_resource.hpp index 139389f0c..a56a784a1 100644 --- a/include/rmm/mr/device/per_device_resource.hpp +++ b/include/rmm/mr/device/per_device_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -69,6 +69,16 @@ * set_per_device_resource(cuda_device_id{i}, &per_device_pools.back()); * } * @endcode + * @code{.cpp} + * using pool_mr = rmm::mr::pool_memory_resource; + * std::vector> per_device_pools; + * for(int i = 0; i < N; ++i) { + * cudaSetDevice(i); + * // Note: for brevity, omitting creation of upstream and computing initial_size + * per_device_pools.push_back(std::make_unique(upstream, initial_size)); + * set_per_device_resource(cuda_device_id{i}, &per_device_pools.back()); + * } + * @endcode */ namespace rmm::mr { diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 20b250524..c0317cf57 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2023, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -15,9 +15,8 @@ */ #pragma once +#include #include -#include -#include #include #include #include @@ -110,10 +109,37 @@ class pool_memory_resource final friend class detail::stream_ordered_memory_resource, detail::coalescing_free_list>; + /** + * @brief Construct a `pool_memory_resource` and allocate the initial device memory + * pool using `upstream_mr`. + * + * @deprecated Use the constructor that takes an explicit initial pool size instead. + * + * @throws rmm::logic_error if `upstream_mr == nullptr` + * @throws rmm::logic_error if `initial_pool_size` is neither the default nor aligned to a + * multiple of pool_memory_resource::allocation_alignment bytes. + * @throws rmm::logic_error if `maximum_pool_size` is neither the default nor aligned to a + * multiple of pool_memory_resource::allocation_alignment bytes. + * + * @param upstream_mr The memory_resource from which to allocate blocks for the pool. + * @param initial_pool_size Minimum size, in bytes, of the initial pool. Defaults to zero. + * @param maximum_pool_size Maximum size, in bytes, that the pool can grow to. Defaults to all + * of the available memory from the upstream resource. + */ + //[[deprecated("Must specify initial_pool_size")]] // + explicit pool_memory_resource(Upstream* upstream_mr, + thrust::optional initial_pool_size = thrust::nullopt, + thrust::optional maximum_pool_size = thrust::nullopt) + : pool_memory_resource(upstream_mr, initial_pool_size.value_or(0), maximum_pool_size) + { + } + /** * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using * `upstream_mr`. * + * @deprecated Use the constructor that takes an explicit initial pool size instead. + * * @throws rmm::logic_error if `upstream_mr == nullptr` * @throws rmm::logic_error if `initial_pool_size` is neither the default nor aligned to a * multiple of pool_memory_resource::allocation_alignment bytes. @@ -121,24 +147,46 @@ class pool_memory_resource final * multiple of pool_memory_resource::allocation_alignment bytes. * * @param upstream_mr The memory_resource from which to allocate blocks for the pool. - * @param initial_pool_size Minimum size, in bytes, of the initial pool. Defaults to half of the - * available memory on the current device. + * @param initial_pool_size Minimum size, in bytes, of the initial pool. Defaults to zero. * @param maximum_pool_size Maximum size, in bytes, that the pool can grow to. Defaults to all - * of the available memory on the current device. + * of the available memory from the upstream resource. */ - explicit pool_memory_resource(Upstream* upstream_mr, + template , int> = 0> + //[[deprecated("Must specify initial_pool_size")]] // + explicit pool_memory_resource(Upstream2& upstream_mr, thrust::optional initial_pool_size = thrust::nullopt, thrust::optional maximum_pool_size = thrust::nullopt) + : pool_memory_resource(upstream_mr, initial_pool_size.value_or(0), maximum_pool_size) + { + } + + /** + * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using + * `upstream_mr`. + * + * @throws rmm::logic_error if `upstream_mr == nullptr` + * @throws rmm::logic_error if `initial_pool_size` is not aligned to a multiple of + * pool_memory_resource::allocation_alignment bytes. + * @throws rmm::logic_error if `maximum_pool_size` is neither the default nor aligned to a + * multiple of pool_memory_resource::allocation_alignment bytes. + * + * @param upstream_mr The memory_resource from which to allocate blocks for the pool. + * @param initial_pool_size Minimum size, in bytes, of the initial pool. + * @param maximum_pool_size Maximum size, in bytes, that the pool can grow to. Defaults to all + * of the available from the upstream resource. + */ + explicit pool_memory_resource(Upstream* upstream_mr, + std::size_t initial_pool_size, + thrust::optional maximum_pool_size = thrust::nullopt) : upstream_mr_{[upstream_mr]() { RMM_EXPECTS(nullptr != upstream_mr, "Unexpected null upstream pointer."); return upstream_mr; }()} { - RMM_EXPECTS(rmm::detail::is_aligned(initial_pool_size.value_or(0), - rmm::detail::CUDA_ALLOCATION_ALIGNMENT), + RMM_EXPECTS(rmm::is_aligned(initial_pool_size, rmm::CUDA_ALLOCATION_ALIGNMENT), "Error, Initial pool size required to be a multiple of 256 bytes"); - RMM_EXPECTS(rmm::detail::is_aligned(maximum_pool_size.value_or(0), - rmm::detail::CUDA_ALLOCATION_ALIGNMENT), + RMM_EXPECTS(rmm::is_aligned(maximum_pool_size.value_or(0), rmm::CUDA_ALLOCATION_ALIGNMENT), "Error, Maximum pool size required to be a multiple of 256 bytes"); initialize_pool(initial_pool_size, maximum_pool_size); @@ -149,21 +197,20 @@ class pool_memory_resource final * `upstream_mr`. * * @throws rmm::logic_error if `upstream_mr == nullptr` - * @throws rmm::logic_error if `initial_pool_size` is neither the default nor aligned to a - * multiple of pool_memory_resource::allocation_alignment bytes. + * @throws rmm::logic_error if `initial_pool_size` is not aligned to a multiple of + * pool_memory_resource::allocation_alignment bytes. * @throws rmm::logic_error if `maximum_pool_size` is neither the default nor aligned to a * multiple of pool_memory_resource::allocation_alignment bytes. * * @param upstream_mr The memory_resource from which to allocate blocks for the pool. - * @param initial_pool_size Minimum size, in bytes, of the initial pool. Defaults to half of the - * available memory on the current device. + * @param initial_pool_size Minimum size, in bytes, of the initial pool. * @param maximum_pool_size Maximum size, in bytes, that the pool can grow to. Defaults to all - * of the available memory on the current device. + * of the available memory from the upstream resource. */ template , int> = 0> explicit pool_memory_resource(Upstream2& upstream_mr, - thrust::optional initial_pool_size = thrust::nullopt, + std::size_t initial_pool_size, thrust::optional maximum_pool_size = thrust::nullopt) : pool_memory_resource(cuda::std::addressof(upstream_mr), initial_pool_size, maximum_pool_size) { @@ -276,38 +323,22 @@ class pool_memory_resource final /** * @brief Allocate initial memory for the pool * - * If initial_size is unset, then queries the upstream memory resource for available memory if - * upstream supports `get_mem_info`, or queries the device (using CUDA API) for available memory - * if not. Then attempts to initialize to half the available memory. - * - * If initial_size is set, then tries to initialize the pool to that size. - * * @param initial_size The optional initial size for the pool * @param maximum_size The optional maximum size for the pool + * + * @throws logic_error if @p initial_size is larger than @p maximum_size (if set). */ - // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) - void initialize_pool(thrust::optional initial_size, - thrust::optional maximum_size) + void initialize_pool(std::size_t initial_size, thrust::optional maximum_size) { - auto const try_size = [&]() { - if (not initial_size.has_value()) { - auto const [free, total] = (get_upstream()->supports_get_mem_info()) - ? get_upstream()->get_mem_info(cuda_stream_legacy) - : rmm::detail::available_device_memory(); - return rmm::detail::align_up(std::min(free, total / 2), - rmm::detail::CUDA_ALLOCATION_ALIGNMENT); - } - return initial_size.value(); - }(); - current_pool_size_ = 0; // try_to_expand will set this if it succeeds maximum_pool_size_ = maximum_size; - RMM_EXPECTS(try_size <= maximum_pool_size_.value_or(std::numeric_limits::max()), - "Initial pool size exceeds the maximum pool size!"); + RMM_EXPECTS( + initial_size <= maximum_pool_size_.value_or(std::numeric_limits::max()), + "Initial pool size exceeds the maximum pool size!"); - if (try_size > 0) { - auto const block = try_to_expand(try_size, try_size, cuda_stream_legacy); + if (initial_size > 0) { + auto const block = try_to_expand(initial_size, initial_size, cuda_stream_legacy); this->insert_block(block, cuda_stream_legacy); } } @@ -346,9 +377,9 @@ class pool_memory_resource final { if (maximum_pool_size_.has_value()) { auto const unaligned_remaining = maximum_pool_size_.value() - pool_size(); - using rmm::detail::align_up; - auto const remaining = align_up(unaligned_remaining, rmm::detail::CUDA_ALLOCATION_ALIGNMENT); - auto const aligned_size = align_up(size, rmm::detail::CUDA_ALLOCATION_ALIGNMENT); + using rmm::align_up; + auto const remaining = align_up(unaligned_remaining, rmm::CUDA_ALLOCATION_ALIGNMENT); + auto const aligned_size = align_up(size, rmm::CUDA_ALLOCATION_ALIGNMENT); return (aligned_size <= remaining) ? std::max(aligned_size, remaining / 2) : 0; } return std::max(size, pool_size()); @@ -416,7 +447,7 @@ class pool_memory_resource final RMM_LOGGING_ASSERT(iter != allocated_blocks_.end()); auto block = *iter; - RMM_LOGGING_ASSERT(block.size() == rmm::detail::align_up(size, allocation_alignment)); + RMM_LOGGING_ASSERT(block.size() == rmm::align_up(size, allocation_alignment)); allocated_blocks_.erase(iter); return block; diff --git a/include/rmm/mr/host/new_delete_resource.hpp b/include/rmm/mr/host/new_delete_resource.hpp index 044f74063..4bb272df3 100644 --- a/include/rmm/mr/host/new_delete_resource.hpp +++ b/include/rmm/mr/host/new_delete_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -17,6 +17,7 @@ #include +#include #include #include @@ -58,12 +59,11 @@ class new_delete_resource final : public host_memory_resource { * @return Pointer to the newly allocated memory */ void* do_allocate(std::size_t bytes, - std::size_t alignment = rmm::detail::RMM_DEFAULT_HOST_ALIGNMENT) override + std::size_t alignment = rmm::RMM_DEFAULT_HOST_ALIGNMENT) override { // If the requested alignment isn't supported, use default - alignment = (rmm::detail::is_supported_alignment(alignment)) - ? alignment - : rmm::detail::RMM_DEFAULT_HOST_ALIGNMENT; + alignment = + (rmm::is_supported_alignment(alignment)) ? alignment : rmm::RMM_DEFAULT_HOST_ALIGNMENT; return rmm::detail::aligned_allocate( bytes, alignment, [](std::size_t size) { return ::operator new(size); }); @@ -84,7 +84,7 @@ class new_delete_resource final : public host_memory_resource { */ void do_deallocate(void* ptr, std::size_t bytes, - std::size_t alignment = rmm::detail::RMM_DEFAULT_HOST_ALIGNMENT) override + std::size_t alignment = rmm::RMM_DEFAULT_HOST_ALIGNMENT) override { rmm::detail::aligned_deallocate( ptr, bytes, alignment, [](void* ptr) { ::operator delete(ptr); }); diff --git a/include/rmm/mr/host/pinned_memory_resource.hpp b/include/rmm/mr/host/pinned_memory_resource.hpp index e49767faf..b5c273ef5 100644 --- a/include/rmm/mr/host/pinned_memory_resource.hpp +++ b/include/rmm/mr/host/pinned_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -15,6 +15,7 @@ */ #pragma once +#include #include #include #include @@ -114,7 +115,7 @@ class pinned_memory_resource final : public host_memory_resource { */ void deallocate_async(void* ptr, std::size_t bytes, std::size_t alignment, cuda_stream_view) { - do_deallocate(ptr, rmm::detail::align_up(bytes, alignment)); + do_deallocate(ptr, rmm::align_up(bytes, alignment)); } /** @@ -143,9 +144,8 @@ class pinned_memory_resource final : public host_memory_resource { if (0 == bytes) { return nullptr; } // If the requested alignment isn't supported, use default - alignment = (rmm::detail::is_supported_alignment(alignment)) - ? alignment - : rmm::detail::RMM_DEFAULT_HOST_ALIGNMENT; + alignment = + (rmm::is_supported_alignment(alignment)) ? alignment : rmm::RMM_DEFAULT_HOST_ALIGNMENT; return rmm::detail::aligned_allocate(bytes, alignment, [](std::size_t size) { void* ptr{nullptr}; diff --git a/python/docs/conf.py b/python/docs/conf.py index ba5aa6d20..b4c141eb4 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -248,14 +248,16 @@ def on_missing_reference(app, env, node, contnode): if match := re.search("(.*)<.*>", reftarget): reftarget = match.group(1) + # This is the document we're linking _from_, and hence where + # we should try and resolve the xref wrt. + refdoc = node.get("refdoc") # Try to find the target prefixed with e.g. namespaces in case that's # all that's missing. Include the empty prefix in case we're searching # for a stripped template. extra_prefixes = ["rmm::", "rmm::mr::", "mr::", ""] - for (name, dispname, type, docname, anchor, priority) in env.domains[ + for (name, dispname, typ, docname, anchor, priority) in env.domains[ "cpp" ].get_objects(): - for prefix in extra_prefixes: if ( name == f"{prefix}{reftarget}" @@ -263,7 +265,7 @@ def on_missing_reference(app, env, node, contnode): ): return env.domains["cpp"].resolve_xref( env, - docname, + refdoc, app.builder, node["reftype"], name, diff --git a/python/docs/librmm_docs/deprecated.rst b/python/docs/librmm_docs/deprecated.rst new file mode 100644 index 000000000..b5ed90caa --- /dev/null +++ b/python/docs/librmm_docs/deprecated.rst @@ -0,0 +1,5 @@ +Deprecated functionality +======================== + +.. doxygenpage:: deprecated + :content-only: diff --git a/python/docs/librmm_docs/index.rst b/python/docs/librmm_docs/index.rst index 6afd94d2e..2b61deb9f 100644 --- a/python/docs/librmm_docs/index.rst +++ b/python/docs/librmm_docs/index.rst @@ -17,6 +17,8 @@ librmm Documentation cuda_streams errors logging + utilities + deprecated .. doxygennamespace:: rmm diff --git a/python/docs/librmm_docs/utilities.rst b/python/docs/librmm_docs/utilities.rst new file mode 100644 index 000000000..25b455746 --- /dev/null +++ b/python/docs/librmm_docs/utilities.rst @@ -0,0 +1,5 @@ +Utilities +============ + +.. doxygengroup:: utilities + :members: diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index ce7f45e19..690e2e338 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -120,12 +120,15 @@ cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ win32 win32_kmt +cdef extern from "rmm/cuda_device.hpp" namespace "rmm" nogil: + size_t percent_of_free_device_memory(int percent) except + + cdef extern from "rmm/mr/device/pool_memory_resource.hpp" \ namespace "rmm::mr" nogil: cdef cppclass pool_memory_resource[Upstream](device_memory_resource): pool_memory_resource( Upstream* upstream_mr, - optional[size_t] initial_pool_size, + size_t initial_pool_size, optional[size_t] maximum_pool_size) except + size_t pool_size() @@ -369,12 +372,12 @@ cdef class PoolMemoryResource(UpstreamResourceAdaptor): initial_pool_size=None, maximum_pool_size=None ): - cdef optional[size_t] c_initial_pool_size + cdef size_t c_initial_pool_size cdef optional[size_t] c_maximum_pool_size c_initial_pool_size = ( - optional[size_t]() if + percent_of_free_device_memory(50) if initial_pool_size is None - else make_optional[size_t](initial_pool_size) + else initial_pool_size ) c_maximum_pool_size = ( optional[size_t]() if diff --git a/tests/container_multidevice_tests.cu b/tests/container_multidevice_tests.cu index 9de9ddf40..e58ba53a2 100644 --- a/tests/container_multidevice_tests.cu +++ b/tests/container_multidevice_tests.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, NVIDIA CORPORATION. + * 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. @@ -15,12 +15,12 @@ */ #include "device_check_resource_adaptor.hpp" -#include "rmm/mr/device/per_device_resource.hpp" #include #include #include #include +#include #include diff --git a/tests/mr/device/aligned_mr_tests.cpp b/tests/mr/device/aligned_mr_tests.cpp index dfcdfa72f..5fbb4b8f1 100644 --- a/tests/mr/device/aligned_mr_tests.cpp +++ b/tests/mr/device/aligned_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-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. @@ -15,7 +15,8 @@ */ #include "../../mock_resource.hpp" -#include + +#include #include #include #include @@ -223,7 +224,7 @@ TEST(AlignedTest, AlignRealPointer) auto const threshold{65536}; aligned_real mr{rmm::mr::get_current_device_resource(), alignment, threshold}; void* alloc = mr.allocate(threshold); - EXPECT_TRUE(rmm::detail::is_pointer_aligned(alloc, alignment)); + EXPECT_TRUE(rmm::is_pointer_aligned(alloc, alignment)); mr.deallocate(alloc, threshold); } diff --git a/tests/mr/device/arena_mr_tests.cpp b/tests/mr/device/arena_mr_tests.cpp index 7525cac9f..1068e0cf0 100644 --- a/tests/mr/device/arena_mr_tests.cpp +++ b/tests/mr/device/arena_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-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. @@ -15,9 +15,10 @@ */ #include "../../byte_literals.hpp" + +#include +#include #include -#include -#include #include #include #include @@ -487,10 +488,9 @@ TEST_F(ArenaTest, SizeSmallerThanSuperblockSize) // NOLINT TEST_F(ArenaTest, AllocateNinetyPercent) // NOLINT { EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) - auto const free = rmm::detail::available_device_memory().first; - auto const ninety_percent = - rmm::detail::align_up(static_cast(static_cast(free) * 0.9), - rmm::detail::CUDA_ALLOCATION_ALIGNMENT); + auto const free = rmm::available_device_memory().first; + auto const ninety_percent = rmm::align_up( + static_cast(static_cast(free) * 0.9), rmm::CUDA_ALLOCATION_ALIGNMENT); arena_mr mr(rmm::mr::get_current_device_resource(), ninety_percent); }()); } @@ -501,7 +501,7 @@ TEST_F(ArenaTest, SmallMediumLarge) // NOLINT arena_mr mr(rmm::mr::get_current_device_resource()); auto* small = mr.allocate(256); auto* medium = mr.allocate(64_MiB); - auto const free = rmm::detail::available_device_memory().first; + auto const free = rmm::available_device_memory().first; auto* large = mr.allocate(free / 3); mr.deallocate(small, 256); mr.deallocate(medium, 64_MiB); diff --git a/tests/mr/device/failure_callback_mr_tests.cpp b/tests/mr/device/failure_callback_mr_tests.cpp index bb5484c69..79acd5c7e 100644 --- a/tests/mr/device/failure_callback_mr_tests.cpp +++ b/tests/mr/device/failure_callback_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-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. @@ -15,16 +15,17 @@ */ #include "../../byte_literals.hpp" -#include "rmm/cuda_stream_view.hpp" -#include "rmm/mr/device/device_memory_resource.hpp" -#include +#include #include #include +#include #include #include +#include + namespace rmm::test { namespace { diff --git a/tests/mr/device/mr_ref_test.hpp b/tests/mr/device/mr_ref_test.hpp index 804c710a5..25ff76891 100644 --- a/tests/mr/device/mr_ref_test.hpp +++ b/tests/mr/device/mr_ref_test.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, NVIDIA CORPORATION. + * 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. @@ -18,9 +18,10 @@ #include "../../byte_literals.hpp" +#include +#include #include #include -#include #include #include #include @@ -78,7 +79,7 @@ inline void test_allocate(resource_ref ref, std::size_t bytes) try { void* ptr = ref.allocate(bytes); EXPECT_NE(nullptr, ptr); - EXPECT_TRUE(rmm::detail::is_pointer_aligned(ptr)); + EXPECT_TRUE(rmm::is_pointer_aligned(ptr)); EXPECT_TRUE(is_device_memory(ptr)); ref.deallocate(ptr, bytes); } catch (rmm::out_of_memory const& e) { @@ -94,7 +95,7 @@ inline void test_allocate_async(async_resource_ref ref, void* ptr = ref.allocate_async(bytes, stream); if (not stream.is_default()) { stream.synchronize(); } EXPECT_NE(nullptr, ptr); - EXPECT_TRUE(rmm::detail::is_pointer_aligned(ptr)); + EXPECT_TRUE(rmm::is_pointer_aligned(ptr)); EXPECT_TRUE(is_device_memory(ptr)); ref.deallocate_async(ptr, bytes, stream); if (not stream.is_default()) { stream.synchronize(); } @@ -202,7 +203,7 @@ inline void test_random_allocations(resource_ref ref, alloc.size = distribution(generator); EXPECT_NO_THROW(alloc.ptr = ref.allocate(alloc.size)); EXPECT_NE(nullptr, alloc.ptr); - EXPECT_TRUE(rmm::detail::is_pointer_aligned(alloc.ptr)); + EXPECT_TRUE(rmm::is_pointer_aligned(alloc.ptr)); }); std::for_each(allocations.begin(), allocations.end(), [&ref](allocation& alloc) { @@ -228,7 +229,7 @@ inline void test_random_async_allocations(async_resource_ref ref, EXPECT_NO_THROW(alloc.ptr = ref.allocate(alloc.size)); if (not stream.is_default()) { stream.synchronize(); } EXPECT_NE(nullptr, alloc.ptr); - EXPECT_TRUE(rmm::detail::is_pointer_aligned(alloc.ptr)); + EXPECT_TRUE(rmm::is_pointer_aligned(alloc.ptr)); }); std::for_each(allocations.begin(), allocations.end(), [stream, &ref](allocation& alloc) { @@ -269,7 +270,7 @@ inline void test_mixed_random_allocation_free(resource_ref ref, EXPECT_NO_THROW(allocations.emplace_back(ref.allocate(size), size)); auto new_allocation = allocations.back(); EXPECT_NE(nullptr, new_allocation.ptr); - EXPECT_TRUE(rmm::detail::is_pointer_aligned(new_allocation.ptr)); + EXPECT_TRUE(rmm::is_pointer_aligned(new_allocation.ptr)); } else { auto const index = static_cast(index_distribution(generator) % active_allocations); active_allocations--; @@ -316,7 +317,7 @@ inline void test_mixed_random_async_allocation_free(async_resource_ref ref, EXPECT_NO_THROW(allocations.emplace_back(ref.allocate_async(size, stream), size)); auto new_allocation = allocations.back(); EXPECT_NE(nullptr, new_allocation.ptr); - EXPECT_TRUE(rmm::detail::is_pointer_aligned(new_allocation.ptr)); + EXPECT_TRUE(rmm::is_pointer_aligned(new_allocation.ptr)); } else { auto const index = static_cast(index_distribution(generator) % active_allocations); active_allocations--; @@ -379,7 +380,8 @@ inline auto make_managed() { return std::make_shared(make_cuda()); + return rmm::mr::make_owning_wrapper( + make_cuda(), rmm::percent_of_free_device_memory(50)); } inline auto make_arena() diff --git a/tests/mr/device/mr_test.hpp b/tests/mr/device/mr_test.hpp index 03f880e72..ef4b4bc80 100644 --- a/tests/mr/device/mr_test.hpp +++ b/tests/mr/device/mr_test.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -18,9 +18,10 @@ #include "../../byte_literals.hpp" +#include +#include #include #include -#include #include #include #include @@ -74,7 +75,7 @@ inline void test_get_current_device_resource() EXPECT_NE(nullptr, rmm::mr::get_current_device_resource()); void* ptr = rmm::mr::get_current_device_resource()->allocate(1_MiB); EXPECT_NE(nullptr, ptr); - EXPECT_TRUE(rmm::detail::is_pointer_aligned(ptr)); + EXPECT_TRUE(rmm::is_pointer_aligned(ptr)); EXPECT_TRUE(is_device_memory(ptr)); rmm::mr::get_current_device_resource()->deallocate(ptr, 1_MiB); } @@ -86,7 +87,7 @@ inline void test_allocate(rmm::mr::device_memory_resource* mr, void* ptr = mr->allocate(bytes); if (not stream.is_default()) { stream.synchronize(); } EXPECT_NE(nullptr, ptr); - EXPECT_TRUE(rmm::detail::is_pointer_aligned(ptr)); + EXPECT_TRUE(rmm::is_pointer_aligned(ptr)); EXPECT_TRUE(is_device_memory(ptr)); mr->deallocate(ptr, bytes); if (not stream.is_default()) { stream.synchronize(); } @@ -154,7 +155,7 @@ inline void test_random_allocations(rmm::mr::device_memory_resource* mr, EXPECT_NO_THROW(alloc.ptr = mr->allocate(alloc.size, stream)); if (not stream.is_default()) { stream.synchronize(); } EXPECT_NE(nullptr, alloc.ptr); - EXPECT_TRUE(rmm::detail::is_pointer_aligned(alloc.ptr)); + EXPECT_TRUE(rmm::is_pointer_aligned(alloc.ptr)); }); std::for_each(allocations.begin(), allocations.end(), [stream, mr](allocation& alloc) { @@ -196,7 +197,7 @@ inline void test_mixed_random_allocation_free(rmm::mr::device_memory_resource* m EXPECT_NO_THROW(allocations.emplace_back(mr->allocate(size, stream), size)); auto new_allocation = allocations.back(); EXPECT_NE(nullptr, new_allocation.ptr); - EXPECT_TRUE(rmm::detail::is_pointer_aligned(new_allocation.ptr)); + EXPECT_TRUE(rmm::is_pointer_aligned(new_allocation.ptr)); } else { auto const index = static_cast(index_distribution(generator) % active_allocations); active_allocations--; @@ -257,7 +258,8 @@ inline auto make_managed() { return std::make_shared(make_cuda()); + return rmm::mr::make_owning_wrapper( + make_cuda(), rmm::percent_of_free_device_memory(50)); } inline auto make_arena() diff --git a/tests/mr/device/pool_mr_tests.cpp b/tests/mr/device/pool_mr_tests.cpp index 2f32889d0..a2793386f 100644 --- a/tests/mr/device/pool_mr_tests.cpp +++ b/tests/mr/device/pool_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -14,9 +14,8 @@ * limitations under the License. */ +#include #include -#include -#include #include #include #include @@ -39,7 +38,7 @@ using limiting_mr = rmm::mr::limiting_resource_adaptor(static_cast(free) * 0.9), - rmm::detail::CUDA_ALLOCATION_ALIGNMENT); + auto const ninety_percent_pool = rmm::percent_of_free_device_memory(90); pool_mr mr{rmm::mr::get_current_device_resource(), ninety_percent_pool}; }; EXPECT_NO_THROW(allocate_ninety()); @@ -83,9 +80,8 @@ TEST(PoolTest, AllocateNinetyPercent) TEST(PoolTest, TwoLargeBuffers) { auto two_large = []() { - auto const [free, total] = rmm::detail::available_device_memory(); - (void)total; - pool_mr mr{rmm::mr::get_current_device_resource()}; + [[maybe_unused]] auto const [free, total] = rmm::available_device_memory(); + pool_mr mr{rmm::mr::get_current_device_resource(), rmm::percent_of_free_device_memory(50)}; auto* ptr1 = mr.allocate(free / 4); auto* ptr2 = mr.allocate(free / 4); mr.deallocate(ptr1, free / 4); @@ -158,8 +154,8 @@ TEST(PoolTest, NonAlignedPoolSize) TEST(PoolTest, UpstreamDoesntSupportMemInfo) { cuda_mr cuda; - pool_mr mr1(&cuda); - pool_mr mr2(&mr1); + pool_mr mr1(&cuda, 0); + pool_mr mr2(&mr1, 0); auto* ptr = mr2.allocate(1024); mr2.deallocate(ptr, 1024); } diff --git a/tests/mr/host/mr_ref_tests.cpp b/tests/mr/host/mr_ref_tests.cpp index 6563eb635..416641f18 100644 --- a/tests/mr/host/mr_ref_tests.cpp +++ b/tests/mr/host/mr_ref_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, NVIDIA CORPORATION. + * 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. @@ -16,7 +16,7 @@ #include "../../byte_literals.hpp" -#include +#include #include #include #include @@ -35,7 +35,7 @@ namespace rmm::test { namespace { inline bool is_aligned(void* ptr, std::size_t alignment = alignof(std::max_align_t)) { - return rmm::detail::is_pointer_aligned(ptr, alignment); + return rmm::is_pointer_aligned(ptr, alignment); } // Returns true if a pointer points to a device memory or managed memory allocation. diff --git a/tests/mr/host/mr_tests.cpp b/tests/mr/host/mr_tests.cpp index 678d6aeb8..e0078c920 100644 --- a/tests/mr/host/mr_tests.cpp +++ b/tests/mr/host/mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -16,7 +16,7 @@ #include "../../byte_literals.hpp" -#include +#include #include #include #include @@ -35,7 +35,7 @@ namespace rmm::test { namespace { inline bool is_aligned(void* ptr, std::size_t alignment = alignof(std::max_align_t)) { - return rmm::detail::is_pointer_aligned(ptr, alignment); + return rmm::is_pointer_aligned(ptr, alignment); } // Returns true if a pointer points to a device memory or managed memory allocation. diff --git a/tests/mr/host/pinned_pool_mr_tests.cpp b/tests/mr/host/pinned_pool_mr_tests.cpp index dcdae37fa..d10b85e72 100644 --- a/tests/mr/host/pinned_pool_mr_tests.cpp +++ b/tests/mr/host/pinned_pool_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 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. @@ -16,7 +16,6 @@ #include #include -#include #include #include #include @@ -33,7 +32,7 @@ using pool_mr = rmm::mr::pool_memory_resource; TEST(PinnedPoolTest, ThrowOnNullUpstream) { - auto construct_nullptr = []() { pool_mr mr{nullptr}; }; + auto construct_nullptr = []() { pool_mr mr{nullptr, 1024}; }; EXPECT_THROW(construct_nullptr(), rmm::logic_error); } From bb8fdf1eaaf1b3245eb2d7e16da745a715ce04f8 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Thu, 18 Jan 2024 06:52:46 +1100 Subject: [PATCH 342/675] Deprecate detail::available_device_memory, most detail/aligned.hpp utilities, and optional pool_memory_resource initial size (#1424) Follow-on to #1417, this PR deprecates the following: - `rmm::detail::available_device_memory` in favor of rmm::available_device_memory - `rmm::detail::is_aligned`, `rmm::detail::align_up` and related alignment utility functions in favor of the `rmm::` top level namespace versions. - The `rmm::pool_memory_resource` constructors that take an optional initial size parameter. Should be merged after the following: - https://github.com/rapidsai/cugraph/pull/4086 - https://github.com/rapidsai/cudf/pull/14741 - https://github.com/rapidsai/raft/pull/2088 Authors: - Mark Harris (https://github.com/harrism) Approvers: - Michael Schellenberger Costa (https://github.com/miscco) - Rong Ou (https://github.com/rongou) URL: https://github.com/rapidsai/rmm/pull/1424 --- include/rmm/aligned.hpp | 19 +++++--- include/rmm/cuda_device.hpp | 2 +- include/rmm/detail/aligned.hpp | 45 ++++++++++++------- .../rmm/mr/device/device_memory_resource.hpp | 8 ++-- .../rmm/mr/device/pool_memory_resource.hpp | 4 +- 5 files changed, 48 insertions(+), 30 deletions(-) diff --git a/include/rmm/aligned.hpp b/include/rmm/aligned.hpp index 7a0feaabf..bd39d7949 100644 --- a/include/rmm/aligned.hpp +++ b/include/rmm/aligned.hpp @@ -47,7 +47,10 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; * * @return Whether the input a power of two with non-negative exponent */ -constexpr bool is_pow2(std::size_t value) { return (value != 0U) && ((value & (value - 1)) == 0U); } +[[nodiscard]] constexpr bool is_pow2(std::size_t value) noexcept +{ + return (value != 0U) && ((value & (value - 1)) == 0U); +} /** * @brief Returns whether or not `alignment` is a valid memory alignment. @@ -56,7 +59,10 @@ constexpr bool is_pow2(std::size_t value) { return (value != 0U) && ((value & (v * * @return Whether the alignment is valid */ -constexpr bool is_supported_alignment(std::size_t alignment) { return is_pow2(alignment); } +[[nodiscard]] constexpr bool is_supported_alignment(std::size_t alignment) noexcept +{ + return is_pow2(alignment); +} /** * @brief Align up to nearest multiple of specified power of 2 @@ -66,7 +72,7 @@ constexpr bool is_supported_alignment(std::size_t alignment) { return is_pow2(al * * @return Return the aligned value, as one would expect */ -constexpr std::size_t align_up(std::size_t value, std::size_t alignment) noexcept +[[nodiscard]] constexpr std::size_t align_up(std::size_t value, std::size_t alignment) noexcept { assert(is_supported_alignment(alignment)); return (value + (alignment - 1)) & ~(alignment - 1); @@ -80,7 +86,7 @@ constexpr std::size_t align_up(std::size_t value, std::size_t alignment) noexcep * * @return Return the aligned value, as one would expect */ -constexpr std::size_t align_down(std::size_t value, std::size_t alignment) noexcept +[[nodiscard]] constexpr std::size_t align_down(std::size_t value, std::size_t alignment) noexcept { assert(is_supported_alignment(alignment)); return value & ~(alignment - 1); @@ -94,7 +100,7 @@ constexpr std::size_t align_down(std::size_t value, std::size_t alignment) noexc * * @return true if aligned */ -constexpr bool is_aligned(std::size_t value, std::size_t alignment) noexcept +[[nodiscard]] constexpr bool is_aligned(std::size_t value, std::size_t alignment) noexcept { assert(is_supported_alignment(alignment)); return value == align_down(value, alignment); @@ -108,7 +114,8 @@ constexpr bool is_aligned(std::size_t value, std::size_t alignment) noexcept * * @return true if the pointer is aligned */ -inline bool is_pointer_aligned(void* ptr, std::size_t alignment = CUDA_ALLOCATION_ALIGNMENT) +[[nodiscard]] inline bool is_pointer_aligned( + void* ptr, std::size_t alignment = CUDA_ALLOCATION_ALIGNMENT) noexcept { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) return is_aligned(reinterpret_cast(ptr), alignment); diff --git a/include/rmm/cuda_device.hpp b/include/rmm/cuda_device.hpp index 565d86926..02017c3da 100644 --- a/include/rmm/cuda_device.hpp +++ b/include/rmm/cuda_device.hpp @@ -125,7 +125,7 @@ namespace detail { * * @return The available and total device memory in bytes for the current device as a std::pair. */ -//[[deprecated("Use `rmm::available_device_memory` instead.")]] // +[[deprecated("Use `rmm::available_device_memory` instead.")]] // const auto available_device_memory = rmm::available_device_memory; } // namespace detail diff --git a/include/rmm/detail/aligned.hpp b/include/rmm/detail/aligned.hpp index 54d287bfb..7e7b42a18 100644 --- a/include/rmm/detail/aligned.hpp +++ b/include/rmm/detail/aligned.hpp @@ -16,6 +16,8 @@ #pragma once +#include + #include #include #include @@ -28,25 +30,34 @@ namespace rmm::detail { * @brief Default alignment used for host memory allocated by RMM. * */ -static constexpr std::size_t RMM_DEFAULT_HOST_ALIGNMENT{alignof(std::max_align_t)}; +[[deprecated("Use rmm::RMM_DEFAULT_HOST_ALIGNMENT instead.")]] static constexpr std::size_t + RMM_DEFAULT_HOST_ALIGNMENT{rmm::RMM_DEFAULT_HOST_ALIGNMENT}; /** * @brief Default alignment used for CUDA memory allocation. * */ -static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; +[[deprecated("Use rmm::CUDA_ALLOCATION_ALIGNMENT instead.")]] static constexpr std::size_t + CUDA_ALLOCATION_ALIGNMENT{rmm::CUDA_ALLOCATION_ALIGNMENT}; /** * @brief Returns whether or not `n` is a power of 2. * */ -constexpr bool is_pow2(std::size_t value) { return (value != 0U) && ((value & (value - 1)) == 0U); } +[[deprecated("Use rmm::is_pow2 instead.")]] constexpr bool is_pow2(std::size_t value) noexcept +{ + return rmm::is_pow2(value); +} /** * @brief Returns whether or not `alignment` is a valid memory alignment. * */ -constexpr bool is_supported_alignment(std::size_t alignment) { return is_pow2(alignment); } +[[deprecated("Use rmm::is_supported_alignment instead.")]] constexpr bool is_supported_alignment( + std::size_t alignment) noexcept +{ + return rmm::is_pow2(alignment); +} /** * @brief Align up to nearest multiple of specified power of 2 @@ -56,10 +67,10 @@ constexpr bool is_supported_alignment(std::size_t alignment) { return is_pow2(al * * @return Return the aligned value, as one would expect */ -constexpr std::size_t align_up(std::size_t value, std::size_t alignment) noexcept +[[deprecated("Use rmm::align_up instead.")]] constexpr std::size_t align_up( + std::size_t value, std::size_t alignment) noexcept { - assert(is_supported_alignment(alignment)); - return (value + (alignment - 1)) & ~(alignment - 1); + return rmm::align_up(value, alignment); } /** @@ -70,10 +81,10 @@ constexpr std::size_t align_up(std::size_t value, std::size_t alignment) noexcep * * @return Return the aligned value, as one would expect */ -constexpr std::size_t align_down(std::size_t value, std::size_t alignment) noexcept +[[deprecated("Use rmm::align_down instead.")]] constexpr std::size_t align_down( + std::size_t value, std::size_t alignment) noexcept { - assert(is_supported_alignment(alignment)); - return value & ~(alignment - 1); + return rmm::align_down(value, alignment); } /** @@ -84,16 +95,16 @@ constexpr std::size_t align_down(std::size_t value, std::size_t alignment) noexc * * @return true if aligned */ -constexpr bool is_aligned(std::size_t value, std::size_t alignment) noexcept +[[deprecated("Use rmm::is_aligned instead.")]] constexpr bool is_aligned( + std::size_t value, std::size_t alignment) noexcept { - assert(is_supported_alignment(alignment)); - return value == align_down(value, alignment); + return rmm::is_aligned(value, alignment); } -inline bool is_pointer_aligned(void* ptr, std::size_t alignment = CUDA_ALLOCATION_ALIGNMENT) +[[deprecated("Use rmm::is_pointer_aligned instead.")]] inline bool is_pointer_aligned( + void* ptr, std::size_t alignment = rmm::CUDA_ALLOCATION_ALIGNMENT) { - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) - return rmm::detail::is_aligned(reinterpret_cast(ptr), alignment); + return rmm::is_pointer_aligned(ptr, alignment); } /** @@ -126,7 +137,7 @@ inline bool is_pointer_aligned(void* ptr, std::size_t alignment = CUDA_ALLOCATIO template void* aligned_allocate(std::size_t bytes, std::size_t alignment, Alloc alloc) { - assert(is_pow2(alignment)); + assert(rmm::is_pow2(alignment)); // allocate memory for bytes, plus potential alignment correction, // plus store of the correction offset diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index e3014b6c3..55006f9b0 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -173,7 +173,7 @@ class device_memory_resource { */ void* allocate(std::size_t bytes, std::size_t alignment) { - return do_allocate(rmm::detail::align_up(bytes, alignment), cuda_stream_view{}); + return do_allocate(rmm::align_up(bytes, alignment), cuda_stream_view{}); } /** @@ -191,7 +191,7 @@ class device_memory_resource { */ void deallocate(void* ptr, std::size_t bytes, std::size_t alignment) { - do_deallocate(ptr, rmm::detail::align_up(bytes, alignment), cuda_stream_view{}); + do_deallocate(ptr, rmm::align_up(bytes, alignment), cuda_stream_view{}); } /** @@ -209,7 +209,7 @@ class device_memory_resource { */ void* allocate_async(std::size_t bytes, std::size_t alignment, cuda_stream_view stream) { - return do_allocate(rmm::detail::align_up(bytes, alignment), stream); + return do_allocate(rmm::align_up(bytes, alignment), stream); } /** @@ -248,7 +248,7 @@ class device_memory_resource { std::size_t alignment, cuda_stream_view stream) { - do_deallocate(ptr, rmm::detail::align_up(bytes, alignment), stream); + do_deallocate(ptr, rmm::align_up(bytes, alignment), stream); } /** diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index c0317cf57..63239e750 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -126,7 +126,7 @@ class pool_memory_resource final * @param maximum_pool_size Maximum size, in bytes, that the pool can grow to. Defaults to all * of the available memory from the upstream resource. */ - //[[deprecated("Must specify initial_pool_size")]] // + [[deprecated("Must specify initial_pool_size")]] // explicit pool_memory_resource(Upstream* upstream_mr, thrust::optional initial_pool_size = thrust::nullopt, thrust::optional maximum_pool_size = thrust::nullopt) @@ -153,7 +153,7 @@ class pool_memory_resource final */ template , int> = 0> - //[[deprecated("Must specify initial_pool_size")]] // + [[deprecated("Must specify initial_pool_size")]] // explicit pool_memory_resource(Upstream2& upstream_mr, thrust::optional initial_pool_size = thrust::nullopt, thrust::optional maximum_pool_size = thrust::nullopt) From d4e67493d0ad80e6c95fbaee34a7eea47ce93bad Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Thu, 18 Jan 2024 14:52:12 -0500 Subject: [PATCH 343/675] DOC v24.04 Updates [skip ci] --- .../cuda11.8-conda/devcontainer.json | 4 ++-- .devcontainer/cuda11.8-pip/devcontainer.json | 4 ++-- .../cuda12.0-conda/devcontainer.json | 4 ++-- .devcontainer/cuda12.0-pip/devcontainer.json | 4 ++-- .github/workflows/build.yaml | 12 +++++------ .github/workflows/pr.yaml | 20 +++++++++---------- .github/workflows/test.yaml | 6 +++--- CMakeLists.txt | 2 +- VERSION | 2 +- ci/build_docs.sh | 2 +- ci/check_style.sh | 2 +- doxygen/Doxyfile | 2 +- fetch_rapids.cmake | 2 +- python/CMakeLists.txt | 2 +- python/docs/conf.py | 4 ++-- 15 files changed, 36 insertions(+), 36 deletions(-) diff --git a/.devcontainer/cuda11.8-conda/devcontainer.json b/.devcontainer/cuda11.8-conda/devcontainer.json index 663d0072c..1403b8cc4 100644 --- a/.devcontainer/cuda11.8-conda/devcontainer.json +++ b/.devcontainer/cuda11.8-conda/devcontainer.json @@ -5,12 +5,12 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:24.02-cpp-cuda11.8-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.04-cpp-cuda11.8-mambaforge-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.2": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.4": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda11.8-pip/devcontainer.json b/.devcontainer/cuda11.8-pip/devcontainer.json index 8bdde6a21..f3284441c 100644 --- a/.devcontainer/cuda11.8-pip/devcontainer.json +++ b/.devcontainer/cuda11.8-pip/devcontainer.json @@ -5,12 +5,12 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:24.02-cpp-llvm16-cuda11.8-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.04-cpp-llvm16-cuda11.8-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.2": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.4": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.0-conda/devcontainer.json b/.devcontainer/cuda12.0-conda/devcontainer.json index 1191efca2..8699f13d3 100644 --- a/.devcontainer/cuda12.0-conda/devcontainer.json +++ b/.devcontainer/cuda12.0-conda/devcontainer.json @@ -5,12 +5,12 @@ "args": { "CUDA": "12.0", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:24.02-cpp-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.04-cpp-mambaforge-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.2": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.4": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.0-pip/devcontainer.json b/.devcontainer/cuda12.0-pip/devcontainer.json index f7f8ee591..dc1784738 100644 --- a/.devcontainer/cuda12.0-pip/devcontainer.json +++ b/.devcontainer/cuda12.0-pip/devcontainer.json @@ -5,12 +5,12 @@ "args": { "CUDA": "12.0", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:24.02-cpp-llvm16-cuda12.0-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.04-cpp-llvm16-cuda12.0-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.2": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.4": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b3d8a9fa0..e4113d5c5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -78,7 +78,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 397ebfd15..da32eb12b 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -22,40 +22,40 @@ jobs: - wheel-tests - devcontainer secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.04 checks: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.04 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.04 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.04 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.04 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.04 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.04 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -65,20 +65,20 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.04 with: build_type: pull-request script: ci/build_wheel.sh wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.04 with: build_type: pull-request script: ci/test_wheel.sh devcontainer: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.04 with: build_command: | sccache -z; diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a61209d0a..0e7938310 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.04 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.04 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.04 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 744307a06..086069b09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ include(rapids-find) project( RMM - VERSION 24.02.00 + VERSION 24.04.00 LANGUAGES CXX) # Write the version header diff --git a/VERSION b/VERSION index 3c6c5e2b7..4a2fe8aa5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -24.02.00 +24.04.00 diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 64c17fec8..1979e9a2c 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -25,7 +25,7 @@ rapids-mamba-retry install \ --channel "${PYTHON_CHANNEL}" \ rmm librmm -export RAPIDS_VERSION_NUMBER="24.02" +export RAPIDS_VERSION_NUMBER="24.04" export RAPIDS_DOCS_DIR="$(mktemp -d)" rapids-logger "Build CPP docs" diff --git a/ci/check_style.sh b/ci/check_style.sh index 9eed00298..66c7e36f3 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -14,7 +14,7 @@ rapids-dependency-file-generator \ rapids-mamba-retry env create --force -f env.yaml -n checks conda activate checks -FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-24.02/cmake-format-rapids-cmake.json +FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-24.04/cmake-format-rapids-cmake.json export RAPIDS_CMAKE_FORMAT_FILE=/tmp/rapids_cmake_ci/cmake-formats-rapids-cmake.json mkdir -p $(dirname ${RAPIDS_CMAKE_FORMAT_FILE}) wget -O ${RAPIDS_CMAKE_FORMAT_FILE} ${FORMAT_FILE_URL} diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 513f15875..d1a5e8869 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = RMM # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 24.02 +PROJECT_NUMBER = 24.04 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/fetch_rapids.cmake b/fetch_rapids.cmake index 86d447acb..684b1e140 100644 --- a/fetch_rapids.cmake +++ b/fetch_rapids.cmake @@ -12,7 +12,7 @@ # the License. # ============================================================================= if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-24.02/RAPIDS.cmake + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-24.04/RAPIDS.cmake ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) endif() include(${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 635c4d3b5..6a7490133 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) -set(rmm_version 24.02.00) +set(rmm_version 24.04.00) include(../fetch_rapids.cmake) diff --git a/python/docs/conf.py b/python/docs/conf.py index b4c141eb4..2919639af 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -24,9 +24,9 @@ # built documents. # # The short X.Y version. -version = "24.02" +version = "24.04" # The full version, including alpha/beta/rc tags. -release = "24.02.00" +release = "24.04.00" # -- General configuration --------------------------------------------------- From 12f8de30531fb2bd64184390c3a2c12b88a3d692 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:39:58 +1100 Subject: [PATCH 344/675] Add a host-pinned memory resource that can be used as upstream for `pool_memory_resource`. (#1392) Depends on #1417 Adds a new `host_pinned_memory_resource` that implements the new `cuda::mr::memory_resource` and `cuda::mr::async_memory_resource` concepts which makes it usable as an upstream MR for `rmm::mr::device_memory_resource`. Also tests a pool made with this new MR as the upstream. Note that the tests explicitly set the initial and maximum pool sizes as using the defaults does not currently work. See #1388 . Closes #618 Authors: - Mark Harris (https://github.com/harrism) - Lawrence Mitchell (https://github.com/wence-) Approvers: - Michael Schellenberger Costa (https://github.com/miscco) - Alessandro Bellina (https://github.com/abellina) - Lawrence Mitchell (https://github.com/wence-) - Jake Hemstad (https://github.com/jrhemstad) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1392 --- include/rmm/aligned.hpp | 10 +- include/rmm/detail/aligned.hpp | 55 ++--- include/rmm/mr/host/new_delete_resource.hpp | 4 +- .../rmm/mr/host/pinned_memory_resource.hpp | 4 +- .../rmm/mr/pinned_host_memory_resource.hpp | 222 ++++++++++++++++++ tests/mr/device/mr_ref_test.hpp | 30 +-- tests/mr/device/mr_test.hpp | 35 ++- tests/mr/device/mr_tests.cpp | 2 + tests/mr/device/test_utils.hpp | 50 ++++ 9 files changed, 336 insertions(+), 76 deletions(-) create mode 100644 include/rmm/mr/pinned_host_memory_resource.hpp create mode 100644 tests/mr/device/test_utils.hpp diff --git a/include/rmm/aligned.hpp b/include/rmm/aligned.hpp index bd39d7949..6e9970ab8 100644 --- a/include/rmm/aligned.hpp +++ b/include/rmm/aligned.hpp @@ -43,9 +43,9 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; /** * @brief Returns whether or not `value` is a power of 2. * - * @param[in] value to check. + * @param[in] value value to check. * - * @return Whether the input a power of two with non-negative exponent + * @return True if the input is a power of two with non-negative integer exponent, false otherwise. */ [[nodiscard]] constexpr bool is_pow2(std::size_t value) noexcept { @@ -57,7 +57,7 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; * * @param[in] alignment to check * - * @return Whether the alignment is valid + * @return True if the alignment is valid, false otherwise. */ [[nodiscard]] constexpr bool is_supported_alignment(std::size_t alignment) noexcept { @@ -70,7 +70,7 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; * @param[in] value value to align * @param[in] alignment amount, in bytes, must be a power of 2 * - * @return Return the aligned value, as one would expect + * @return the aligned value */ [[nodiscard]] constexpr std::size_t align_up(std::size_t value, std::size_t alignment) noexcept { @@ -84,7 +84,7 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; * @param[in] value value to align * @param[in] alignment amount, in bytes, must be a power of 2 * - * @return Return the aligned value, as one would expect + * @return the aligned value */ [[nodiscard]] constexpr std::size_t align_down(std::size_t value, std::size_t alignment) noexcept { diff --git a/include/rmm/detail/aligned.hpp b/include/rmm/detail/aligned.hpp index 7e7b42a18..eb31658e9 100644 --- a/include/rmm/detail/aligned.hpp +++ b/include/rmm/detail/aligned.hpp @@ -108,36 +108,35 @@ namespace rmm::detail { } /** - * @brief Allocates sufficient memory to satisfy the requested size `bytes` with + * @brief Allocates sufficient host-accessible memory to satisfy the requested size `bytes` with * alignment `alignment` using the unary callable `alloc` to allocate memory. * - * Given a pointer `p` to an allocation of size `n` returned from the unary - * callable `alloc`, the pointer `q` returned from `aligned_alloc` points to a - * location within the `n` bytes with sufficient space for `bytes` that - * satisfies `alignment`. + * Given a pointer `p` to an allocation of size `n` returned from the unary callable `alloc`, the + * pointer `q` returned from `aligned_alloc` points to a location within the `n` bytes with + * sufficient space for `bytes` that satisfies `alignment`. * - * In order to retrieve the original allocation pointer `p`, the offset - * between `p` and `q` is stored at `q - sizeof(std::ptrdiff_t)`. + * In order to retrieve the original allocation pointer `p`, the offset between `p` and `q` is + * stored at `q - sizeof(std::ptrdiff_t)`. * - * Allocations returned from `aligned_allocate` *MUST* be freed by calling - * `aligned_deallocate` with the same arguments for `bytes` and `alignment` with - * a compatible unary `dealloc` callable capable of freeing the memory returned - * from `alloc`. + * Allocations returned from `aligned_host_allocate` *MUST* be freed by calling + * `aligned_host_deallocate` with the same arguments for `bytes` and `alignment` with a compatible + * unary `dealloc` callable capable of freeing the memory returned from `alloc`. * * If `alignment` is not a power of 2, behavior is undefined. + * If `Alloc` does not allocate host-accessible memory, behavior is undefined. * * @param bytes The desired size of the allocation * @param alignment Desired alignment of allocation * @param alloc Unary callable given a size `n` will allocate at least `n` bytes - * of host memory. - * @tparam Alloc a unary callable type that allocates memory. + * of host-accessible memory. + * @tparam Alloc a unary callable type that allocates host-accessible memory. * @return void* Pointer into allocation of at least `bytes` with desired * `alignment`. */ template -void* aligned_allocate(std::size_t bytes, std::size_t alignment, Alloc alloc) +void* aligned_host_allocate(std::size_t bytes, std::size_t alignment, Alloc alloc) { - assert(rmm::is_pow2(alignment)); + assert(rmm::is_supported_alignment(alignment)); // allocate memory for bytes, plus potential alignment correction, // plus store of the correction offset @@ -163,25 +162,27 @@ void* aligned_allocate(std::size_t bytes, std::size_t alignment, Alloc alloc) } /** - * @brief Frees an allocation returned from `aligned_allocate`. + * @brief Frees an allocation of host-accessible returned from `aligned_host_allocate`. * - * Allocations returned from `aligned_allocate` *MUST* be freed by calling - * `aligned_deallocate` with the same arguments for `bytes` and `alignment` - * with a compatible unary `dealloc` callable capable of freeing the memory - * returned from `alloc`. + * Allocations returned from `aligned_host_allocate` *MUST* be freed by calling + * `aligned_host_deallocate` with the same arguments for `bytes` and `alignment` with a compatible + * unary `dealloc` callable capable of freeing the memory returned from `alloc`. * * @param p The aligned pointer to deallocate - * @param bytes The number of bytes requested from `aligned_allocate` - * @param alignment The alignment required from `aligned_allocate` - * @param dealloc A unary callable capable of freeing memory returned from - * `alloc` in `aligned_allocate`. - * @tparam Dealloc A unary callable type that deallocates memory. + * @param bytes The number of bytes requested from `aligned_host_allocate` + * @param alignment The alignment required from `aligned_host_allocate` + * @param dealloc A unary callable capable of freeing host-accessible memory returned from `alloc` + * in `aligned_host_allocate`. + * @tparam Dealloc A unary callable type that deallocates host-accessible memory. */ template // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) -void aligned_deallocate(void* ptr, std::size_t bytes, std::size_t alignment, Dealloc dealloc) +void aligned_host_deallocate(void* ptr, + [[maybe_unused]] std::size_t bytes, + [[maybe_unused]] std::size_t alignment, + Dealloc dealloc) noexcept { - (void)alignment; + assert(rmm::is_supported_alignment(alignment)); // Get offset from the location immediately prior to the aligned pointer // NOLINTNEXTLINE diff --git a/include/rmm/mr/host/new_delete_resource.hpp b/include/rmm/mr/host/new_delete_resource.hpp index 4bb272df3..ccb294d21 100644 --- a/include/rmm/mr/host/new_delete_resource.hpp +++ b/include/rmm/mr/host/new_delete_resource.hpp @@ -65,7 +65,7 @@ class new_delete_resource final : public host_memory_resource { alignment = (rmm::is_supported_alignment(alignment)) ? alignment : rmm::RMM_DEFAULT_HOST_ALIGNMENT; - return rmm::detail::aligned_allocate( + return rmm::detail::aligned_host_allocate( bytes, alignment, [](std::size_t size) { return ::operator new(size); }); } @@ -86,7 +86,7 @@ class new_delete_resource final : public host_memory_resource { std::size_t bytes, std::size_t alignment = rmm::RMM_DEFAULT_HOST_ALIGNMENT) override { - rmm::detail::aligned_deallocate( + rmm::detail::aligned_host_deallocate( ptr, bytes, alignment, [](void* ptr) { ::operator delete(ptr); }); } }; diff --git a/include/rmm/mr/host/pinned_memory_resource.hpp b/include/rmm/mr/host/pinned_memory_resource.hpp index b5c273ef5..cb8524999 100644 --- a/include/rmm/mr/host/pinned_memory_resource.hpp +++ b/include/rmm/mr/host/pinned_memory_resource.hpp @@ -147,7 +147,7 @@ class pinned_memory_resource final : public host_memory_resource { alignment = (rmm::is_supported_alignment(alignment)) ? alignment : rmm::RMM_DEFAULT_HOST_ALIGNMENT; - return rmm::detail::aligned_allocate(bytes, alignment, [](std::size_t size) { + return rmm::detail::aligned_host_allocate(bytes, alignment, [](std::size_t size) { void* ptr{nullptr}; auto status = cudaMallocHost(&ptr, size); if (cudaSuccess != status) { throw std::bad_alloc{}; } @@ -173,7 +173,7 @@ class pinned_memory_resource final : public host_memory_resource { std::size_t alignment = alignof(std::max_align_t)) override { if (nullptr == ptr) { return; } - rmm::detail::aligned_deallocate( + rmm::detail::aligned_host_deallocate( ptr, bytes, alignment, [](void* ptr) { RMM_ASSERT_CUDA_SUCCESS(cudaFreeHost(ptr)); }); } }; diff --git a/include/rmm/mr/pinned_host_memory_resource.hpp b/include/rmm/mr/pinned_host_memory_resource.hpp new file mode 100644 index 000000000..c51af4182 --- /dev/null +++ b/include/rmm/mr/pinned_host_memory_resource.hpp @@ -0,0 +1,222 @@ +/* + * 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. + */ +#pragma once + +#include +#include +#include + +#include +#include + +#include + +#include +#include + +namespace rmm::mr { + +/** + * @brief Memory resource class for allocating pinned host memory. + * + * This class uses CUDA's `cudaHostAlloc` to allocate pinned host memory. It implements the + * `cuda::mr::memory_resource` and `cuda::mr::device_memory_resource` concepts, and + * the `cuda::mr::host_accessible` and `cuda::mr::device_accessible` properties. + */ +class pinned_host_memory_resource { + public: + // Disable clang-tidy complaining about the easily swappable size and alignment parameters + // of allocate and deallocate + // NOLINTBEGIN(bugprone-easily-swappable-parameters) + + /** + * @brief Allocates pinned host memory of size at least \p bytes bytes. + * + * @throws `rmm::out_of_memory` if the requested allocation could not be fulfilled due to to a + * CUDA out of memory error. + * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled due to any other + * reason. + * + * @param bytes The size, in bytes, of the allocation. + * @param alignment Alignment in bytes. Default alignment is used if unspecified. + * + * @return Pointer to the newly allocated memory. + */ + static void* allocate(std::size_t bytes, + [[maybe_unused]] std::size_t alignment = rmm::RMM_DEFAULT_HOST_ALIGNMENT) + { + // don't allocate anything if the user requested zero bytes + if (0 == bytes) { return nullptr; } + + return rmm::detail::aligned_host_allocate(bytes, alignment, [](std::size_t size) { + void* ptr{nullptr}; + RMM_CUDA_TRY_ALLOC(cudaHostAlloc(&ptr, size, cudaHostAllocDefault)); + return ptr; + }); + } + + /** + * @brief Deallocate memory pointed to by \p ptr of size \p bytes bytes. + * + * @throws Nothing. + * + * @param ptr Pointer to be deallocated. + * @param bytes Size of the allocation. + * @param alignment Alignment in bytes. Default alignment is used if unspecified. + */ + static void deallocate(void* ptr, + std::size_t bytes, + std::size_t alignment = rmm::RMM_DEFAULT_HOST_ALIGNMENT) noexcept + { + rmm::detail::aligned_host_deallocate( + ptr, bytes, alignment, [](void* ptr) { RMM_ASSERT_CUDA_SUCCESS(cudaFreeHost(ptr)); }); + } + + /** + * @brief Allocates pinned host memory of size at least \p bytes bytes. + * + * @note Stream argument is ignored and behavior is identical to allocate. + * + * @throws `rmm::out_of_memory` if the requested allocation could not be fulfilled due to to a + * CUDA out of memory error. + * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled due to any other + * error. + * + * @param bytes The size, in bytes, of the allocation. + * @param stream CUDA stream on which to perform the allocation (ignored). + * @return Pointer to the newly allocated memory. + */ + static void* allocate_async(std::size_t bytes, [[maybe_unused]] cuda::stream_ref stream) + { + return allocate(bytes); + } + + /** + * @brief Allocates pinned host memory of size at least \p bytes bytes and alignment \p alignment. + * + * @note Stream argument is ignored and behavior is identical to allocate. + * + * @throws `rmm::out_of_memory` if the requested allocation could not be fulfilled due to to a + * CUDA out of memory error. + * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled due to any other + * error. + * + * @param bytes The size, in bytes, of the allocation. + * @param alignment Alignment in bytes. + * @param stream CUDA stream on which to perform the allocation (ignored). + * @return Pointer to the newly allocated memory. + */ + static void* allocate_async(std::size_t bytes, + std::size_t alignment, + [[maybe_unused]] cuda::stream_ref stream) + { + return allocate(bytes, alignment); + } + + /** + * @brief Deallocate memory pointed to by \p ptr of size \p bytes bytes. + * + * @note Stream argument is ignored and behavior is identical to deallocate. + * + * @throws Nothing. + * + * @param ptr Pointer to be deallocated. + * @param bytes Size of the allocation. + * @param stream CUDA stream on which to perform the deallocation (ignored). + */ + static void deallocate_async(void* ptr, + std::size_t bytes, + [[maybe_unused]] cuda::stream_ref stream) noexcept + { + return deallocate(ptr, bytes); + } + + /** + * @brief Deallocate memory pointed to by \p ptr of size \p bytes bytes and alignment \p + * alignment bytes. + * + * @note Stream argument is ignored and behavior is identical to deallocate. + * + * @throws Nothing. + * + * @param ptr Pointer to be deallocated. + * @param bytes Size of the allocation. + * @param alignment Alignment in bytes. + * @param stream CUDA stream on which to perform the deallocation (ignored). + */ + static void deallocate_async(void* ptr, + std::size_t bytes, + std::size_t alignment, + [[maybe_unused]] cuda::stream_ref stream) noexcept + { + return deallocate(ptr, bytes, alignment); + } + // NOLINTEND(bugprone-easily-swappable-parameters) + + /** + * @briefreturn{true if the specified resource is the same type as this resource.} + */ + bool operator==(const pinned_host_memory_resource&) const { return true; } + + /** + * @briefreturn{true if the specified resource is not the same type as this resource, otherwise + * false.} + */ + bool operator!=(const pinned_host_memory_resource&) const { return false; } + + /** + * @brief Query whether the resource supports reporting free and available memory. + * + * @return false + */ + static bool supports_get_mem_info() { return false; } + + /** + * @brief Query the total amount of memory and free memory available for allocation by this + * resource. + * + * @throws nothing + * + * @return std::pair containing 0 for both total and free memory. + */ + [[nodiscard]] static std::pair get_mem_info(cuda::stream_ref) noexcept + { + return {0, 0}; + } + + /** + * @brief Enables the `cuda::mr::device_accessible` property + * + * This property declares that a `pinned_host_memory_resource` provides device accessible memory + */ + friend void get_property(pinned_host_memory_resource const&, cuda::mr::device_accessible) noexcept + { + } + + /** + * @brief Enables the `cuda::mr::host_accessible` property + * + * This property declares that a `pinned_host_memory_resource` provides host accessible memory + */ + friend void get_property(pinned_host_memory_resource const&, cuda::mr::host_accessible) noexcept + { + } +}; + +static_assert(cuda::mr::async_resource_with); +} // namespace rmm::mr diff --git a/tests/mr/device/mr_ref_test.hpp b/tests/mr/device/mr_ref_test.hpp index 25ff76891..9826c10be 100644 --- a/tests/mr/device/mr_ref_test.hpp +++ b/tests/mr/device/mr_ref_test.hpp @@ -17,6 +17,7 @@ #pragma once #include "../../byte_literals.hpp" +#include "test_utils.hpp" #include #include @@ -35,8 +36,6 @@ #include -#include - #include #include @@ -50,17 +49,6 @@ using async_resource_ref = cuda::mr::async_resource_ref(index_distribution(generator) % active_allocations); active_allocations--; @@ -317,7 +305,7 @@ inline void test_mixed_random_async_allocation_free(async_resource_ref ref, EXPECT_NO_THROW(allocations.emplace_back(ref.allocate_async(size, stream), size)); auto new_allocation = allocations.back(); EXPECT_NE(nullptr, new_allocation.ptr); - EXPECT_TRUE(rmm::is_pointer_aligned(new_allocation.ptr)); + EXPECT_TRUE(is_properly_aligned(new_allocation.ptr)); } else { auto const index = static_cast(index_distribution(generator) % active_allocations); active_allocations--; diff --git a/tests/mr/device/mr_test.hpp b/tests/mr/device/mr_test.hpp index ef4b4bc80..3808ec6f3 100644 --- a/tests/mr/device/mr_test.hpp +++ b/tests/mr/device/mr_test.hpp @@ -17,6 +17,7 @@ #pragma once #include "../../byte_literals.hpp" +#include "test_utils.hpp" #include #include @@ -32,11 +33,10 @@ #include #include #include +#include #include -#include - #include #include #include @@ -45,17 +45,6 @@ namespace rmm::test { -/** - * @brief Returns if a pointer points to a device memory or managed memory - * allocation. - */ -inline bool is_device_memory(void* ptr) -{ - cudaPointerAttributes attributes{}; - if (cudaSuccess != cudaPointerGetAttributes(&attributes, ptr)) { return false; } - return (attributes.type == cudaMemoryTypeDevice) or (attributes.type == cudaMemoryTypeManaged); -} - enum size_in_bytes : size_t {}; constexpr auto default_num_allocations{100}; @@ -75,8 +64,8 @@ inline void test_get_current_device_resource() EXPECT_NE(nullptr, rmm::mr::get_current_device_resource()); void* ptr = rmm::mr::get_current_device_resource()->allocate(1_MiB); EXPECT_NE(nullptr, ptr); - EXPECT_TRUE(rmm::is_pointer_aligned(ptr)); - EXPECT_TRUE(is_device_memory(ptr)); + EXPECT_TRUE(is_properly_aligned(ptr)); + EXPECT_TRUE(is_device_accessible_memory(ptr)); rmm::mr::get_current_device_resource()->deallocate(ptr, 1_MiB); } @@ -87,8 +76,8 @@ inline void test_allocate(rmm::mr::device_memory_resource* mr, void* ptr = mr->allocate(bytes); if (not stream.is_default()) { stream.synchronize(); } EXPECT_NE(nullptr, ptr); - EXPECT_TRUE(rmm::is_pointer_aligned(ptr)); - EXPECT_TRUE(is_device_memory(ptr)); + EXPECT_TRUE(is_properly_aligned(ptr)); + EXPECT_TRUE(is_device_accessible_memory(ptr)); mr->deallocate(ptr, bytes); if (not stream.is_default()) { stream.synchronize(); } } @@ -155,7 +144,7 @@ inline void test_random_allocations(rmm::mr::device_memory_resource* mr, EXPECT_NO_THROW(alloc.ptr = mr->allocate(alloc.size, stream)); if (not stream.is_default()) { stream.synchronize(); } EXPECT_NE(nullptr, alloc.ptr); - EXPECT_TRUE(rmm::is_pointer_aligned(alloc.ptr)); + EXPECT_TRUE(is_properly_aligned(alloc.ptr)); }); std::for_each(allocations.begin(), allocations.end(), [stream, mr](allocation& alloc) { @@ -197,7 +186,7 @@ inline void test_mixed_random_allocation_free(rmm::mr::device_memory_resource* m EXPECT_NO_THROW(allocations.emplace_back(mr->allocate(size, stream), size)); auto new_allocation = allocations.back(); EXPECT_NE(nullptr, new_allocation.ptr); - EXPECT_TRUE(rmm::is_pointer_aligned(new_allocation.ptr)); + EXPECT_TRUE(is_properly_aligned(new_allocation.ptr)); } else { auto const index = static_cast(index_distribution(generator) % active_allocations); active_allocations--; @@ -246,6 +235,8 @@ struct mr_allocation_test : public mr_test {}; /// MR factory functions inline auto make_cuda() { return std::make_shared(); } +inline auto make_host_pinned() { return std::make_shared(); } + inline auto make_cuda_async() { if (rmm::detail::async_alloc::is_supported()) { @@ -262,6 +253,12 @@ inline auto make_pool() make_cuda(), rmm::percent_of_free_device_memory(50)); } +inline auto make_host_pinned_pool() +{ + return rmm::mr::make_owning_wrapper( + make_host_pinned(), 2_GiB, 8_GiB); +} + inline auto make_arena() { return rmm::mr::make_owning_wrapper(make_cuda()); diff --git a/tests/mr/device/mr_tests.cpp b/tests/mr/device/mr_tests.cpp index f6141e90f..bf513adda 100644 --- a/tests/mr/device/mr_tests.cpp +++ b/tests/mr/device/mr_tests.cpp @@ -31,6 +31,7 @@ INSTANTIATE_TEST_SUITE_P(ResourceTests, #endif mr_factory{"Managed", &make_managed}, mr_factory{"Pool", &make_pool}, + mr_factory{"HostPinnedPool", &make_host_pinned_pool}, mr_factory{"Arena", &make_arena}, mr_factory{"Binning", &make_binning}, mr_factory{"Fixed_Size", &make_fixed_size}), @@ -45,6 +46,7 @@ INSTANTIATE_TEST_SUITE_P(ResourceAllocationTests, #endif mr_factory{"Managed", &make_managed}, mr_factory{"Pool", &make_pool}, + mr_factory{"HostPinnedPool", &make_host_pinned_pool}, mr_factory{"Arena", &make_arena}, mr_factory{"Binning", &make_binning}), [](auto const& info) { return info.param.name; }); diff --git a/tests/mr/device/test_utils.hpp b/tests/mr/device/test_utils.hpp new file mode 100644 index 000000000..932a72a7e --- /dev/null +++ b/tests/mr/device/test_utils.hpp @@ -0,0 +1,50 @@ +/* + * 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. + */ + +#pragma once + +#include + +#include + +namespace rmm::test { + +/** + * @brief Returns if a pointer points to a device memory or managed memory + * allocation. + */ +inline bool is_device_accessible_memory(void* ptr) +{ + cudaPointerAttributes attributes{}; + if (cudaSuccess != cudaPointerGetAttributes(&attributes, ptr)) { return false; } + return (attributes.type == cudaMemoryTypeDevice) or (attributes.type == cudaMemoryTypeManaged) or + ((attributes.type == cudaMemoryTypeHost) and (attributes.devicePointer != nullptr)); +} + +inline bool is_host_memory(void* ptr) +{ + cudaPointerAttributes attributes{}; + if (cudaSuccess != cudaPointerGetAttributes(&attributes, ptr)) { return false; } + return attributes.type == cudaMemoryTypeHost; +} + +inline bool is_properly_aligned(void* ptr) +{ + if (is_host_memory(ptr)) { return rmm::is_pointer_aligned(ptr, rmm::RMM_DEFAULT_HOST_ALIGNMENT); } + return rmm::is_pointer_aligned(ptr, rmm::CUDA_ALLOCATION_ALIGNMENT); +} + +} // namespace rmm::test From 6c904f7b960c3b4944ea19281a6c7e0e16b55275 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Tue, 23 Jan 2024 20:27:54 +1100 Subject: [PATCH 345/675] Make device_memory_resource::do_get_mem_info() and supports_get_mem_info() nonvirtual. Remove derived implementations and calls in RMM (#1430) Closes #1426 As part of #1388, this PR contributes to deprecating and removing all `get_mem_info` functionality from memory resources. This first PR makes these methods optional without deprecating them. - Makes `rmm::mr::device_memory_resource::supports_get_mem_info()` nonvirtual (and always return false) - Makes `rmm::mr::device_memory_resource::do_get_mem_info()` nonvirtual (and always return `{0, 0}`). - Removes all derived implementations of the above. - Removes all calls to the above. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1430 --- .../utilities/simulated_memory_resource.hpp | 21 +-------------- .../mr/device/aligned_resource_adaptor.hpp | 26 ------------------- .../rmm/mr/device/arena_memory_resource.hpp | 19 -------------- .../rmm/mr/device/binning_memory_resource.hpp | 21 --------------- .../mr/device/callback_memory_resource.hpp | 8 +----- .../mr/device/cuda_async_memory_resource.hpp | 20 -------------- .../cuda_async_view_memory_resource.hpp | 20 -------------- .../rmm/mr/device/cuda_memory_resource.hpp | 24 +---------------- .../rmm/mr/device/device_memory_resource.hpp | 7 +++-- .../failure_callback_resource_adaptor.hpp | 26 +------------------ .../mr/device/fixed_size_memory_resource.hpp | 23 +--------------- .../mr/device/limiting_resource_adaptor.hpp | 24 ----------------- .../mr/device/logging_resource_adaptor.hpp | 26 +------------------ .../rmm/mr/device/managed_memory_resource.hpp | 26 +------------------ include/rmm/mr/device/owning_wrapper.hpp | 24 +---------------- .../rmm/mr/device/pool_memory_resource.hpp | 24 +---------------- .../mr/device/statistics_resource_adaptor.hpp | 25 +----------------- .../device/thread_safe_resource_adaptor.hpp | 26 +------------------ .../mr/device/tracking_resource_adaptor.hpp | 25 +----------------- .../rmm/mr/host/pinned_memory_resource.hpp | 20 -------------- tests/device_check_resource_adaptor.hpp | 13 +--------- tests/mock_resource.hpp | 2 -- tests/mr/device/adaptor_tests.cpp | 16 +----------- tests/mr/device/aligned_mr_tests.cpp | 6 ----- tests/mr/device/arena_mr_tests.cpp | 4 --- tests/mr/device/failure_callback_mr_tests.cpp | 6 ----- tests/mr/device/mr_tests.cpp | 25 ------------------ tests/mr/device/pool_mr_tests.cpp | 1 - 28 files changed, 19 insertions(+), 489 deletions(-) diff --git a/benchmarks/utilities/simulated_memory_resource.hpp b/benchmarks/utilities/simulated_memory_resource.hpp index b7965a021..00f6a5649 100644 --- a/benchmarks/utilities/simulated_memory_resource.hpp +++ b/benchmarks/utilities/simulated_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -59,13 +59,6 @@ class simulated_memory_resource final : public device_memory_resource { */ [[nodiscard]] bool supports_streams() const noexcept override { return false; } - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return false - */ - [[nodiscard]] bool supports_get_mem_info() const noexcept override { return false; } - private: /** * @brief Allocates memory of size at least `bytes`. @@ -95,18 +88,6 @@ class simulated_memory_resource final : public device_memory_resource { */ void do_deallocate(void* ptr, std::size_t, cuda_stream_view) override {} - /** - * @brief Get free and available memory for memory resource. - * - * @param stream to execute on. - * @return std::pair containing free_size and total_size of memory. - */ - [[nodiscard]] std::pair do_get_mem_info( - cuda_stream_view stream) const override - { - return std::make_pair(0, 0); - } - char* begin_{}; char* end_{}; }; diff --git a/include/rmm/mr/device/aligned_resource_adaptor.hpp b/include/rmm/mr/device/aligned_resource_adaptor.hpp index be7c3036c..dda510e52 100644 --- a/include/rmm/mr/device/aligned_resource_adaptor.hpp +++ b/include/rmm/mr/device/aligned_resource_adaptor.hpp @@ -96,16 +96,6 @@ class aligned_resource_adaptor final : public device_memory_resource { return upstream_->supports_streams(); } - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return bool true if the upstream resource supports get_mem_info, false otherwise. - */ - [[nodiscard]] bool supports_get_mem_info() const noexcept override - { - return upstream_->supports_get_mem_info(); - } - /** * @brief The default alignment used by the adaptor. */ @@ -183,22 +173,6 @@ class aligned_resource_adaptor final : public device_memory_resource { alignment_ == cast->alignment_ && alignment_threshold_ == cast->alignment_threshold_; } - /** - * @brief Get free and available memory from upstream resource. - * - * The free size may not be fully allocatable because of alignment requirements. - * - * @throws rmm::cuda_error if unable to retrieve memory info. - * - * @param stream Stream on which to get the mem info. - * @return std::pair containing free_size and total_size of memory - */ - [[nodiscard]] std::pair do_get_mem_info( - cuda_stream_view stream) const override - { - return upstream_->get_mem_info(stream); - } - /** * @brief Calculate the allocation size needed from upstream to account for alignments of both the * size and the base pointer. diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index 1b821b440..658a107d6 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -118,13 +118,6 @@ class arena_memory_resource final : public device_memory_resource { */ bool supports_streams() const noexcept override { return true; } - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return bool false. - */ - bool supports_get_mem_info() const noexcept override { return false; } - private: using global_arena = rmm::mr::detail::arena::global_arena; using arena = rmm::mr::detail::arena::arena; @@ -312,18 +305,6 @@ class arena_memory_resource final : public device_memory_resource { } } - /** - * @brief Get free and available memory for memory resource. - * - * @param stream to execute on. - * @return std::pair containing free_size and total_size of memory. - */ - std::pair do_get_mem_info( - [[maybe_unused]] cuda_stream_view stream) const override - { - return std::make_pair(0, 0); - } - /** * Dump memory to log. * diff --git a/include/rmm/mr/device/binning_memory_resource.hpp b/include/rmm/mr/device/binning_memory_resource.hpp index 2a9975b18..33b92d4d7 100644 --- a/include/rmm/mr/device/binning_memory_resource.hpp +++ b/include/rmm/mr/device/binning_memory_resource.hpp @@ -106,13 +106,6 @@ class binning_memory_resource final : public device_memory_resource { */ [[nodiscard]] bool supports_streams() const noexcept override { return true; } - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return false - */ - [[nodiscard]] bool supports_get_mem_info() const noexcept override { return false; } - /** * @brief Get the upstream memory_resource object. * @@ -197,20 +190,6 @@ class binning_memory_resource final : public device_memory_resource { if (res != nullptr) { res->deallocate(ptr, bytes, stream); } } - /** - * @brief Get free and available memory for memory resource - * - * @throws std::runtime_error if we could not get free / total memory - * - * @param stream the stream being executed on - * @return std::pair with available and free memory for resource - */ - [[nodiscard]] std::pair do_get_mem_info( - [[maybe_unused]] cuda_stream_view stream) const override - { - return std::make_pair(0, 0); - } - Upstream* upstream_mr_; // The upstream memory_resource from which to allocate blocks. std::vector>> owned_bin_resources_; diff --git a/include/rmm/mr/device/callback_memory_resource.hpp b/include/rmm/mr/device/callback_memory_resource.hpp index 36802c83a..11270ebe2 100644 --- a/include/rmm/mr/device/callback_memory_resource.hpp +++ b/include/rmm/mr/device/callback_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -138,13 +138,7 @@ class callback_memory_resource final : public device_memory_resource { deallocate_callback_(ptr, bytes, stream, deallocate_callback_arg_); } - [[nodiscard]] std::pair do_get_mem_info(cuda_stream_view) const override - { - throw std::runtime_error("cannot get free / total memory"); - } - [[nodiscard]] bool supports_streams() const noexcept override { return false; } - [[nodiscard]] bool supports_get_mem_info() const noexcept override { return false; } allocate_callback_t allocate_callback_; deallocate_callback_t deallocate_callback_; diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index f8295c6f6..b1d010cd6 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -164,13 +164,6 @@ class cuda_async_memory_resource final : public device_memory_resource { */ [[nodiscard]] bool supports_streams() const noexcept override { return true; } - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return false - */ - [[nodiscard]] bool supports_get_mem_info() const noexcept override { return false; } - private: #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT cuda_async_view_memory_resource pool_{}; @@ -232,19 +225,6 @@ class cuda_async_memory_resource final : public device_memory_resource { return async_mr != nullptr; #endif } - - /** - * @brief Get free and available memory for memory resource - * - * @throws rmm::cuda_error if unable to retrieve memory info. - * - * @return std::pair contaiing free_size and total_size of memory - */ - [[nodiscard]] std::pair do_get_mem_info( - rmm::cuda_stream_view) const override - { - return std::make_pair(0, 0); - } }; /** @} */ // end of group diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index 562944669..553c9a708 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -99,13 +99,6 @@ class cuda_async_view_memory_resource final : public device_memory_resource { */ [[nodiscard]] bool supports_streams() const noexcept override { return true; } - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return true - */ - [[nodiscard]] bool supports_get_mem_info() const noexcept override { return false; } - private: #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT cudaMemPool_t cuda_pool_handle_{}; @@ -169,19 +162,6 @@ class cuda_async_view_memory_resource final : public device_memory_resource { { return dynamic_cast(&other) != nullptr; } - - /** - * @brief Get free and available memory for memory resource - * - * @throws rmm::cuda_error if unable to retrieve memory info. - * - * @return std::pair contaiing free_size and total_size of memory - */ - [[nodiscard]] std::pair do_get_mem_info( - rmm::cuda_stream_view) const override - { - return std::make_pair(0, 0); - } }; /** @} */ // end of group diff --git a/include/rmm/mr/device/cuda_memory_resource.hpp b/include/rmm/mr/device/cuda_memory_resource.hpp index 256899776..284e49793 100644 --- a/include/rmm/mr/device/cuda_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -51,13 +51,6 @@ class cuda_memory_resource final : public device_memory_resource { */ [[nodiscard]] bool supports_streams() const noexcept override { return false; } - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return true - */ - [[nodiscard]] bool supports_get_mem_info() const noexcept override { return true; } - private: /** * @brief Allocates memory of size at least \p bytes. @@ -108,21 +101,6 @@ class cuda_memory_resource final : public device_memory_resource { { return dynamic_cast(&other) != nullptr; } - - /** - * @brief Get free and available memory for memory resource - * - * @throws rmm::cuda_error if unable to retrieve memory info. - * - * @return std::pair contaiing free_size and total_size of memory - */ - [[nodiscard]] std::pair do_get_mem_info(cuda_stream_view) const override - { - std::size_t free_size{}; - std::size_t total_size{}; - RMM_CUDA_TRY(cudaMemGetInfo(&free_size, &total_size)); - return std::make_pair(free_size, total_size); - } }; /** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index 55006f9b0..fd8a71c80 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -306,7 +306,7 @@ class device_memory_resource { * * @return bool true if the resource supports get_mem_info, false otherwise. */ - [[nodiscard]] virtual bool supports_get_mem_info() const noexcept = 0; + [[nodiscard]] virtual bool supports_get_mem_info() const noexcept { return false; }; /** * @brief Queries the amount of free and total memory for the resource. @@ -384,7 +384,10 @@ class device_memory_resource { * @return std::pair with available and free memory for resource */ [[nodiscard]] virtual std::pair do_get_mem_info( - cuda_stream_view stream) const = 0; + cuda_stream_view stream) const + { + return {0, 0}; + } }; static_assert(cuda::mr::async_resource_with); /** @} */ // end of group diff --git a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp index f8cbe8597..0f8c4b020 100644 --- a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp +++ b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -135,16 +135,6 @@ class failure_callback_resource_adaptor final : public device_memory_resource { return upstream_->supports_streams(); } - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return bool true if the upstream resource supports get_mem_info, false otherwise. - */ - [[nodiscard]] bool supports_get_mem_info() const noexcept override - { - return upstream_->supports_get_mem_info(); - } - private: /** * @brief Allocates memory of size at least `bytes` using the upstream @@ -199,20 +189,6 @@ class failure_callback_resource_adaptor final : public device_memory_resource { : upstream_->is_equal(other); } - /** - * @brief Get free and available memory from upstream resource. - * - * @throws rmm::cuda_error if unable to retrieve memory info. - * - * @param stream Stream on which to get the mem info. - * @return std::pair contaiing free_size and total_size of memory - */ - [[nodiscard]] std::pair do_get_mem_info( - cuda_stream_view stream) const override - { - return upstream_->get_mem_info(stream); - } - Upstream* upstream_; // the upstream resource used for satisfying allocation requests failure_callback_t callback_; void* callback_arg_; diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index 91cc95c53..b7a3babee 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -104,13 +104,6 @@ class fixed_size_memory_resource */ [[nodiscard]] bool supports_streams() const noexcept override { return true; } - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return false - */ - [[nodiscard]] bool supports_get_mem_info() const noexcept override { return false; } - /** * @brief Get the upstream memory_resource object. * @@ -211,20 +204,6 @@ class fixed_size_memory_resource return block_type{ptr}; } - /** - * @brief Get free and available memory for memory resource - * - * @throws std::runtime_error if we could not get free / total memory - * - * @param stream the stream being executed on - * @return std::pair with available and free memory for resource - */ - [[nodiscard]] std::pair do_get_mem_info( - [[maybe_unused]] cuda_stream_view stream) const override - { - return std::make_pair(0, 0); - } - /** * @brief free all memory allocated using the upstream resource. * @@ -244,7 +223,7 @@ class fixed_size_memory_resource { lock_guard lock(this->get_mutex()); - auto const [free, total] = get_upstream()->get_mem_info(rmm::cuda_stream_default); + auto const [free, total] = rmm::available_device_memory(); std::cout << "GPU free memory: " << free << " total: " << total << "\n"; std::cout << "upstream_blocks: " << upstream_blocks_.size() << "\n"; diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index 2123c3cac..e10a453c5 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -88,16 +88,6 @@ class limiting_resource_adaptor final : public device_memory_resource { return upstream_->supports_streams(); } - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return bool true if the upstream resource supports get_mem_info, false otherwise. - */ - [[nodiscard]] bool supports_get_mem_info() const noexcept override - { - return upstream_->supports_get_mem_info(); - } - /** * @brief Query the number of bytes that have been allocated. Note that * this can not be used to know how large of an allocation is possible due @@ -178,20 +168,6 @@ class limiting_resource_adaptor final : public device_memory_resource { return upstream_->is_equal(other); } - /** - * @brief Get free and available memory from upstream resource. - * - * @throws rmm::cuda_error if unable to retrieve memory info. - * - * @param stream Stream on which to get the mem info. - * @return std::pair contaiing free_size and total_size of memory - */ - [[nodiscard]] std::pair do_get_mem_info( - [[maybe_unused]] cuda_stream_view stream) const override - { - return {allocation_limit_ - allocated_bytes_, allocation_limit_}; - } - // maximum bytes this allocator is allowed to allocate. std::size_t allocation_limit_; diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 781571157..455cde4c6 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2023, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -154,16 +154,6 @@ class logging_resource_adaptor final : public device_memory_resource { return upstream_->supports_streams(); } - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return bool true if the upstream resource supports get_mem_info, false otherwise. - */ - [[nodiscard]] bool supports_get_mem_info() const noexcept override - { - return upstream_->supports_get_mem_info(); - } - /** * @brief Flush logger contents. */ @@ -295,20 +285,6 @@ class logging_resource_adaptor final : public device_memory_resource { return upstream_->is_equal(other); } - /** - * @brief Get free and available memory from upstream resource. - * - * @throws rmm::cuda_error if unable to retrieve memory info. - * - * @param stream Stream on which to get the mem info. - * @return std::pair contaiing free_size and total_size of memory - */ - [[nodiscard]] std::pair do_get_mem_info( - cuda_stream_view stream) const override - { - return upstream_->get_mem_info(stream); - } - // make_logging_adaptor needs access to private get_default_filename template // NOLINTNEXTLINE(readability-redundant-declaration) diff --git a/include/rmm/mr/device/managed_memory_resource.hpp b/include/rmm/mr/device/managed_memory_resource.hpp index dfa7710bf..5b0a80426 100644 --- a/include/rmm/mr/device/managed_memory_resource.hpp +++ b/include/rmm/mr/device/managed_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -51,13 +51,6 @@ class managed_memory_resource final : public device_memory_resource { */ [[nodiscard]] bool supports_streams() const noexcept override { return false; } - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return true - */ - [[nodiscard]] bool supports_get_mem_info() const noexcept override { return true; } - private: /** * @brief Allocates memory of size at least \p bytes. @@ -112,23 +105,6 @@ class managed_memory_resource final : public device_memory_resource { { return dynamic_cast(&other) != nullptr; } - - /** - * @brief Get free and available memory for memory resource - * - * @throws rmm::cuda_error if unable to retrieve memory info - * - * @param stream to execute on - * @return std::pair contaiing free_size and total_size of memory - */ - [[nodiscard]] std::pair do_get_mem_info( - [[maybe_unused]] cuda_stream_view stream) const override - { - std::size_t free_size{}; - std::size_t total_size{}; - RMM_CUDA_TRY(cudaMemGetInfo(&free_size, &total_size)); - return std::make_pair(free_size, total_size); - } }; /** @} */ // end of group diff --git a/include/rmm/mr/device/owning_wrapper.hpp b/include/rmm/mr/device/owning_wrapper.hpp index da513796d..7dd160265 100644 --- a/include/rmm/mr/device/owning_wrapper.hpp +++ b/include/rmm/mr/device/owning_wrapper.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -165,14 +165,6 @@ class owning_wrapper : public device_memory_resource { return wrapped().supports_streams(); } - /** - * @briefreturn{true if the wrapped resource supports get_mem_info, false otherwise} - */ - [[nodiscard]] bool supports_get_mem_info() const noexcept override - { - return wrapped().supports_get_mem_info(); - } - private: /** * @brief Allocates memory using the wrapped resource. @@ -220,20 +212,6 @@ class owning_wrapper : public device_memory_resource { return wrapped().is_equal(other); } - /** - * @brief Get free and available memory from upstream resource. - * - * @throws rmm::cuda_error if unable to retrieve memory info. - * - * @param stream Stream on which to get the mem info. - * @return std::pair contaiing free_size and total_size of memory - */ - [[nodiscard]] std::pair do_get_mem_info( - cuda_stream_view stream) const override - { - return wrapped().get_mem_info(stream); - } - upstream_tuple upstreams_; ///< The owned upstream resources std::unique_ptr wrapped_; ///< The wrapped resource that uses the upstreams }; diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 63239e750..44f8f96c4 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -236,13 +236,6 @@ class pool_memory_resource final */ [[nodiscard]] bool supports_streams() const noexcept override { return true; } - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return bool false - */ - [[nodiscard]] bool supports_get_mem_info() const noexcept override { return false; } - /** * @brief Get the upstream memory_resource object. * @@ -487,7 +480,7 @@ class pool_memory_resource final { lock_guard lock(this->get_mutex()); - auto const [free, total] = upstream_mr_->get_mem_info(rmm::cuda_stream_default); + auto const [free, total] = rmm::available_device_memory(); std::cout << "GPU free memory: " << free << " total: " << total << "\n"; std::cout << "upstream_blocks: " << upstream_blocks_.size() << "\n"; @@ -528,21 +521,6 @@ class pool_memory_resource final return {largest, total}; } - /** - * @brief Get free and available memory for memory resource - * - * @throws nothing - * - * @param stream to execute on - * @return std::pair contaiing free_size and total_size of memory - */ - [[nodiscard]] std::pair do_get_mem_info( - cuda_stream_view stream) const override - { - // TODO implement this - return {0, 0}; - } - private: Upstream* upstream_mr_; // The "heap" to allocate the pool from std::size_t current_pool_size_{}; diff --git a/include/rmm/mr/device/statistics_resource_adaptor.hpp b/include/rmm/mr/device/statistics_resource_adaptor.hpp index dd186efc0..ed38a20f4 100644 --- a/include/rmm/mr/device/statistics_resource_adaptor.hpp +++ b/include/rmm/mr/device/statistics_resource_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -119,16 +119,6 @@ class statistics_resource_adaptor final : public device_memory_resource { */ bool supports_streams() const noexcept override { return upstream_->supports_streams(); } - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return bool true if the upstream resource supports get_mem_info, false otherwise. - */ - bool supports_get_mem_info() const noexcept override - { - return upstream_->supports_get_mem_info(); - } - /** * @brief Returns a `counter` struct for this adaptor containing the current, * peak, and total number of allocated bytes for this @@ -222,19 +212,6 @@ class statistics_resource_adaptor final : public device_memory_resource { : upstream_->is_equal(other); } - /** - * @brief Get free and available memory from upstream resource. - * - * @throws rmm::cuda_error if unable to retrieve memory info. - * - * @param stream Stream on which to get the mem info. - * @return std::pair contaiing free_size and total_size of memory - */ - std::pair do_get_mem_info(cuda_stream_view stream) const override - { - return upstream_->get_mem_info(stream); - } - counter bytes_; // peak, current and total allocated bytes counter allocations_; // peak, current and total allocation count std::shared_timed_mutex mutable mtx_; // mutex for thread safe access to allocations_ diff --git a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp index 13184b257..15ad3f0a5 100644 --- a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp +++ b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -76,16 +76,6 @@ class thread_safe_resource_adaptor final : public device_memory_resource { */ bool supports_streams() const noexcept override { return upstream_->supports_streams(); } - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return bool true if the upstream resource supports get_mem_info, false otherwise. - */ - bool supports_get_mem_info() const noexcept override - { - return upstream_->supports_get_mem_info(); - } - private: /** * @brief Allocates memory of size at least `bytes` using the upstream @@ -134,20 +124,6 @@ class thread_safe_resource_adaptor final : public device_memory_resource { return upstream_->is_equal(other); } - /** - * @brief Get free and available memory from upstream resource. - * - * @throws rmm::cuda_error if unable to retrieve memory info. - * - * @param stream Stream on which to get the mem info. - * @return std::pair contaiing free_size and total_size of memory - */ - std::pair do_get_mem_info(cuda_stream_view stream) const override - { - lock_t lock(mtx); - return upstream_->get_mem_info(stream); - } - std::mutex mutable mtx; // mutex for thread safe access to upstream Upstream* upstream_; ///< The upstream resource used for satisfying allocation requests }; diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index 271ccab23..2ad88f079 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2023, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -118,16 +118,6 @@ class tracking_resource_adaptor final : public device_memory_resource { */ bool supports_streams() const noexcept override { return upstream_->supports_streams(); } - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return bool true if the upstream resource supports get_mem_info, false otherwise. - */ - bool supports_get_mem_info() const noexcept override - { - return upstream_->supports_get_mem_info(); - } - /** * @brief Get the outstanding allocations map * @@ -277,19 +267,6 @@ class tracking_resource_adaptor final : public device_memory_resource { : upstream_->is_equal(other); } - /** - * @brief Get free and available memory from upstream resource. - * - * @throws rmm::cuda_error if unable to retrieve memory info. - * - * @param stream Stream on which to get the mem info. - * @return std::pair contaiing free_size and total_size of memory - */ - std::pair do_get_mem_info(cuda_stream_view stream) const override - { - return upstream_->get_mem_info(stream); - } - bool capture_stacks_; // whether or not to capture call stacks std::map allocations_; // map of active allocations std::atomic allocated_bytes_; // number of bytes currently allocated diff --git a/include/rmm/mr/host/pinned_memory_resource.hpp b/include/rmm/mr/host/pinned_memory_resource.hpp index cb8524999..9f68b70fa 100644 --- a/include/rmm/mr/host/pinned_memory_resource.hpp +++ b/include/rmm/mr/host/pinned_memory_resource.hpp @@ -56,26 +56,6 @@ class pinned_memory_resource final : public host_memory_resource { */ [[nodiscard]] bool supports_streams() const noexcept { return false; } - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @return bool false. - */ - [[nodiscard]] bool supports_get_mem_info() const noexcept { return false; } - - /** - * @brief Queries the amount of free and total memory for the resource. - * - * @param stream the stream whose memory manager we want to retrieve - * - * @returns a pair containing the free memory in bytes in .first and total amount of memory in - * .second - */ - [[nodiscard]] std::pair get_mem_info(cuda_stream_view stream) const - { - return std::make_pair(0, 0); - } - /** * @brief Pretend to support the allocate_async interface, falling back to stream 0 * diff --git a/tests/device_check_resource_adaptor.hpp b/tests/device_check_resource_adaptor.hpp index f9ad4cf70..6ff82e77a 100644 --- a/tests/device_check_resource_adaptor.hpp +++ b/tests/device_check_resource_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, NVIDIA CORPORATION. + * 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. @@ -32,11 +32,6 @@ class device_check_resource_adaptor final : public rmm::mr::device_memory_resour return upstream_->supports_streams(); } - [[nodiscard]] bool supports_get_mem_info() const noexcept override - { - return upstream_->supports_get_mem_info(); - } - [[nodiscard]] device_memory_resource* get_upstream() const noexcept { return upstream_; } private: @@ -66,12 +61,6 @@ class device_check_resource_adaptor final : public rmm::mr::device_memory_resour return upstream_->is_equal(other); } - [[nodiscard]] std::pair do_get_mem_info( - rmm::cuda_stream_view stream) const override - { - return upstream_->get_mem_info(stream); - } - rmm::cuda_device_id device_id; rmm::mr::device_memory_resource* upstream_{}; }; diff --git a/tests/mock_resource.hpp b/tests/mock_resource.hpp index 0436e2a2a..d8eb4e5b9 100644 --- a/tests/mock_resource.hpp +++ b/tests/mock_resource.hpp @@ -24,11 +24,9 @@ namespace rmm::test { class mock_resource : public rmm::mr::device_memory_resource { public: MOCK_METHOD(bool, supports_streams, (), (const, override, noexcept)); - MOCK_METHOD(bool, supports_get_mem_info, (), (const, override, noexcept)); MOCK_METHOD(void*, do_allocate, (std::size_t, cuda_stream_view), (override)); MOCK_METHOD(void, do_deallocate, (void*, std::size_t, cuda_stream_view), (override)); using size_pair = std::pair; - MOCK_METHOD(size_pair, do_get_mem_info, (cuda_stream_view), (const, override)); }; } // namespace rmm::test diff --git a/tests/mr/device/adaptor_tests.cpp b/tests/mr/device/adaptor_tests.cpp index 98fc3a429..e43818091 100644 --- a/tests/mr/device/adaptor_tests.cpp +++ b/tests/mr/device/adaptor_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-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. @@ -147,20 +147,6 @@ TYPED_TEST(AdaptorTest, SupportsStreams) EXPECT_EQ(this->mr->supports_streams(), this->cuda.supports_streams()); } -TYPED_TEST(AdaptorTest, MemInfo) -{ - EXPECT_EQ(this->mr->supports_get_mem_info(), this->cuda.supports_get_mem_info()); - - auto [free, total] = this->mr->get_mem_info(rmm::cuda_stream_default); - - if (this->mr->supports_get_mem_info()) { - EXPECT_NE(total, 0); - } else { - EXPECT_EQ(free, 0); - EXPECT_EQ(total, 0); - } -} - TYPED_TEST(AdaptorTest, AllocFree) { void* ptr{nullptr}; diff --git a/tests/mr/device/aligned_mr_tests.cpp b/tests/mr/device/aligned_mr_tests.cpp index 5fbb4b8f1..4d149c182 100644 --- a/tests/mr/device/aligned_mr_tests.cpp +++ b/tests/mr/device/aligned_mr_tests.cpp @@ -72,12 +72,6 @@ TEST(AlignedTest, SupportsGetMemInfo) { mock_resource mock; aligned_mock mr{&mock}; - - EXPECT_CALL(mock, supports_get_mem_info()).WillOnce(Return(true)); - EXPECT_TRUE(mr.supports_get_mem_info()); - - EXPECT_CALL(mock, supports_get_mem_info()).WillOnce(Return(false)); - EXPECT_FALSE(mr.supports_get_mem_info()); } TEST(AlignedTest, DefaultAllocationAlignmentPassthrough) diff --git a/tests/mr/device/arena_mr_tests.cpp b/tests/mr/device/arena_mr_tests.cpp index 1068e0cf0..fbd96599e 100644 --- a/tests/mr/device/arena_mr_tests.cpp +++ b/tests/mr/device/arena_mr_tests.cpp @@ -596,10 +596,6 @@ TEST_F(ArenaTest, FeatureSupport) // NOLINT { arena_mr mr{rmm::mr::get_current_device_resource(), 1_MiB}; EXPECT_TRUE(mr.supports_streams()); - EXPECT_FALSE(mr.supports_get_mem_info()); - auto [free, total] = mr.get_mem_info(rmm::cuda_stream_default); - EXPECT_EQ(free, 0); - EXPECT_EQ(total, 0); } } // namespace diff --git a/tests/mr/device/failure_callback_mr_tests.cpp b/tests/mr/device/failure_callback_mr_tests.cpp index 79acd5c7e..12fbff268 100644 --- a/tests/mr/device/failure_callback_mr_tests.cpp +++ b/tests/mr/device/failure_callback_mr_tests.cpp @@ -61,14 +61,8 @@ class always_throw_memory_resource final : public mr::device_memory_resource { throw ExceptionType{"foo"}; } void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override{}; - [[nodiscard]] std::pair do_get_mem_info( - cuda_stream_view stream) const override - { - return {0, 0}; - } [[nodiscard]] bool supports_streams() const noexcept override { return false; } - [[nodiscard]] bool supports_get_mem_info() const noexcept override { return false; } }; TEST(FailureCallbackTest, DifferentExceptionTypes) diff --git a/tests/mr/device/mr_tests.cpp b/tests/mr/device/mr_tests.cpp index bf513adda..5f9be9f54 100644 --- a/tests/mr/device/mr_tests.cpp +++ b/tests/mr/device/mr_tests.cpp @@ -97,31 +97,6 @@ TEST_P(mr_test, SupportsStreams) } } -TEST_P(mr_test, GetMemInfo) -{ - if (this->mr->supports_get_mem_info()) { - const auto allocation_size{16 * 256}; - { - auto const [free, total] = this->mr->get_mem_info(rmm::cuda_stream_view{}); - EXPECT_TRUE(free >= allocation_size); - } - - void* ptr{nullptr}; - ptr = this->mr->allocate(allocation_size); - - { - auto const [free, total] = this->mr->get_mem_info(rmm::cuda_stream_view{}); - EXPECT_TRUE(free >= allocation_size); - } - - this->mr->deallocate(ptr, allocation_size); - } else { - auto const [free, total] = this->mr->get_mem_info(rmm::cuda_stream_view{}); - EXPECT_EQ(free, 0); - EXPECT_EQ(total, 0); - } -} - // Simple reproducer for https://github.com/rapidsai/rmm/issues/861 TEST_P(mr_test, AllocationsAreDifferentDefaultStream) { diff --git a/tests/mr/device/pool_mr_tests.cpp b/tests/mr/device/pool_mr_tests.cpp index a2793386f..7193ef301 100644 --- a/tests/mr/device/pool_mr_tests.cpp +++ b/tests/mr/device/pool_mr_tests.cpp @@ -213,7 +213,6 @@ class fake_async_resource { // To model stream_resource [[nodiscard]] bool supports_streams() const noexcept { return false; } - [[nodiscard]] bool supports_get_mem_info() const noexcept { return false; } private: void* do_allocate(std::size_t bytes, cuda_stream_view) { return nullptr; } From 19d8ef9641402651dce79787d7f057876d826733 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Fri, 26 Jan 2024 21:33:17 +1100 Subject: [PATCH 346/675] Make device_memory_resource::supports_streams() not pure virtual. Remove derived implementations and calls in RMM (#1437) Closes #1432. Part of #1389 - Make supports_streams() nonpure - Remove supports_streams() from all MRs and tests. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Michael Schellenberger Costa (https://github.com/miscco) URL: https://github.com/rapidsai/rmm/pull/1437 --- benchmarks/utilities/simulated_memory_resource.hpp | 8 -------- include/rmm/mr/device/aligned_resource_adaptor.hpp | 8 -------- include/rmm/mr/device/arena_memory_resource.hpp | 8 -------- include/rmm/mr/device/binning_memory_resource.hpp | 8 -------- include/rmm/mr/device/callback_memory_resource.hpp | 2 -- include/rmm/mr/device/cuda_async_memory_resource.hpp | 8 -------- .../mr/device/cuda_async_view_memory_resource.hpp | 8 -------- include/rmm/mr/device/cuda_memory_resource.hpp | 8 -------- include/rmm/mr/device/device_memory_resource.hpp | 2 +- .../mr/device/failure_callback_resource_adaptor.hpp | 11 ----------- include/rmm/mr/device/fixed_size_memory_resource.hpp | 8 -------- include/rmm/mr/device/limiting_resource_adaptor.hpp | 11 ----------- include/rmm/mr/device/logging_resource_adaptor.hpp | 11 ----------- include/rmm/mr/device/managed_memory_resource.hpp | 8 -------- include/rmm/mr/device/owning_wrapper.hpp | 8 -------- include/rmm/mr/device/pool_memory_resource.hpp | 8 -------- .../rmm/mr/device/statistics_resource_adaptor.hpp | 8 -------- .../rmm/mr/device/thread_safe_resource_adaptor.hpp | 5 ----- include/rmm/mr/device/tracking_resource_adaptor.hpp | 8 -------- include/rmm/mr/host/pinned_memory_resource.hpp | 8 -------- tests/device_check_resource_adaptor.hpp | 5 ----- tests/mr/device/adaptor_tests.cpp | 5 ----- tests/mr/device/aligned_mr_tests.cpp | 12 ------------ tests/mr/device/arena_mr_tests.cpp | 6 ------ tests/mr/device/failure_callback_mr_tests.cpp | 2 -- tests/mr/device/mr_tests.cpp | 10 ---------- tests/mr/device/pool_mr_tests.cpp | 3 --- 27 files changed, 1 insertion(+), 196 deletions(-) diff --git a/benchmarks/utilities/simulated_memory_resource.hpp b/benchmarks/utilities/simulated_memory_resource.hpp index 00f6a5649..556afb889 100644 --- a/benchmarks/utilities/simulated_memory_resource.hpp +++ b/benchmarks/utilities/simulated_memory_resource.hpp @@ -51,14 +51,6 @@ class simulated_memory_resource final : public device_memory_resource { simulated_memory_resource(simulated_memory_resource&&) = delete; simulated_memory_resource& operator=(simulated_memory_resource&&) = delete; - /** - * @brief Query whether the resource supports use of non-null CUDA streams for - * allocation/deallocation. - * - * @returns bool false - */ - [[nodiscard]] bool supports_streams() const noexcept override { return false; } - private: /** * @brief Allocates memory of size at least `bytes`. diff --git a/include/rmm/mr/device/aligned_resource_adaptor.hpp b/include/rmm/mr/device/aligned_resource_adaptor.hpp index dda510e52..88c870366 100644 --- a/include/rmm/mr/device/aligned_resource_adaptor.hpp +++ b/include/rmm/mr/device/aligned_resource_adaptor.hpp @@ -88,14 +88,6 @@ class aligned_resource_adaptor final : public device_memory_resource { */ Upstream* get_upstream() const noexcept { return upstream_; } - /** - * @copydoc rmm::mr::device_memory_resource::supports_streams() - */ - [[nodiscard]] bool supports_streams() const noexcept override - { - return upstream_->supports_streams(); - } - /** * @brief The default alignment used by the adaptor. */ diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index 658a107d6..b274e0c18 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -110,14 +110,6 @@ class arena_memory_resource final : public device_memory_resource { arena_memory_resource(arena_memory_resource&&) noexcept = delete; arena_memory_resource& operator=(arena_memory_resource&&) noexcept = delete; - /** - * @brief Queries whether the resource supports use of non-null CUDA streams for - * allocation/deallocation. - * - * @returns bool true. - */ - bool supports_streams() const noexcept override { return true; } - private: using global_arena = rmm::mr::detail::arena::global_arena; using arena = rmm::mr::detail::arena::arena; diff --git a/include/rmm/mr/device/binning_memory_resource.hpp b/include/rmm/mr/device/binning_memory_resource.hpp index 33b92d4d7..a0cf6bf40 100644 --- a/include/rmm/mr/device/binning_memory_resource.hpp +++ b/include/rmm/mr/device/binning_memory_resource.hpp @@ -98,14 +98,6 @@ class binning_memory_resource final : public device_memory_resource { binning_memory_resource& operator=(binning_memory_resource const&) = delete; binning_memory_resource& operator=(binning_memory_resource&&) = delete; - /** - * @brief Query whether the resource supports use of non-null streams for - * allocation/deallocation. - * - * @returns true - */ - [[nodiscard]] bool supports_streams() const noexcept override { return true; } - /** * @brief Get the upstream memory_resource object. * diff --git a/include/rmm/mr/device/callback_memory_resource.hpp b/include/rmm/mr/device/callback_memory_resource.hpp index 11270ebe2..1483925de 100644 --- a/include/rmm/mr/device/callback_memory_resource.hpp +++ b/include/rmm/mr/device/callback_memory_resource.hpp @@ -138,8 +138,6 @@ class callback_memory_resource final : public device_memory_resource { deallocate_callback_(ptr, bytes, stream, deallocate_callback_arg_); } - [[nodiscard]] bool supports_streams() const noexcept override { return false; } - allocate_callback_t allocate_callback_; deallocate_callback_t deallocate_callback_; void* allocate_callback_arg_; diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index b1d010cd6..69e23624d 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -156,14 +156,6 @@ class cuda_async_memory_resource final : public device_memory_resource { cuda_async_memory_resource& operator=(cuda_async_memory_resource const&) = delete; cuda_async_memory_resource& operator=(cuda_async_memory_resource&&) = delete; - /** - * @brief Query whether the resource supports use of non-null CUDA streams for - * allocation/deallocation. `cuda_memory_resource` does not support streams. - * - * @returns bool true - */ - [[nodiscard]] bool supports_streams() const noexcept override { return true; } - private: #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT cuda_async_view_memory_resource pool_{}; diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index 553c9a708..6c24cccc3 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -91,14 +91,6 @@ class cuda_async_view_memory_resource final : public device_memory_resource { cuda_async_view_memory_resource& operator=(cuda_async_view_memory_resource&&) = default; ///< @default_move_assignment{cuda_async_view_memory_resource} - /** - * @brief Query whether the resource supports use of non-null CUDA streams for - * allocation/deallocation. `cuda_memory_resource` does not support streams. - * - * @returns bool true - */ - [[nodiscard]] bool supports_streams() const noexcept override { return true; } - private: #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT cudaMemPool_t cuda_pool_handle_{}; diff --git a/include/rmm/mr/device/cuda_memory_resource.hpp b/include/rmm/mr/device/cuda_memory_resource.hpp index 284e49793..0652d6360 100644 --- a/include/rmm/mr/device/cuda_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_memory_resource.hpp @@ -43,14 +43,6 @@ class cuda_memory_resource final : public device_memory_resource { cuda_memory_resource& operator=(cuda_memory_resource&&) = default; ///< @default_move_assignment{cuda_memory_resource} - /** - * @brief Query whether the resource supports use of non-null CUDA streams for - * allocation/deallocation. `cuda_memory_resource` does not support streams. - * - * @returns bool false - */ - [[nodiscard]] bool supports_streams() const noexcept override { return false; } - private: /** * @brief Allocates memory of size at least \p bytes. diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index fd8a71c80..5d7894995 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -299,7 +299,7 @@ class device_memory_resource { * * @returns bool true if the resource supports non-null CUDA streams. */ - [[nodiscard]] virtual bool supports_streams() const noexcept = 0; + [[nodiscard]] virtual bool supports_streams() const noexcept { return false; } /** * @brief Query whether the resource supports the get_mem_info API. diff --git a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp index 0f8c4b020..a0232fd5b 100644 --- a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp +++ b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp @@ -124,17 +124,6 @@ class failure_callback_resource_adaptor final : public device_memory_resource { */ Upstream* get_upstream() const noexcept { return upstream_; } - /** - * @brief Checks whether the upstream resource supports streams. - * - * @return true The upstream resource supports streams - * @return false The upstream resource does not support streams. - */ - [[nodiscard]] bool supports_streams() const noexcept override - { - return upstream_->supports_streams(); - } - private: /** * @brief Allocates memory of size at least `bytes` using the upstream diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index b7a3babee..296ef103c 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -96,14 +96,6 @@ class fixed_size_memory_resource fixed_size_memory_resource& operator=(fixed_size_memory_resource const&) = delete; fixed_size_memory_resource& operator=(fixed_size_memory_resource&&) = delete; - /** - * @brief Query whether the resource supports use of non-null streams for - * allocation/deallocation. - * - * @returns true - */ - [[nodiscard]] bool supports_streams() const noexcept override { return true; } - /** * @brief Get the upstream memory_resource object. * diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index e10a453c5..4d5f9829f 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -77,17 +77,6 @@ class limiting_resource_adaptor final : public device_memory_resource { */ [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } - /** - * @brief Checks whether the upstream resource supports streams. - * - * @return true The upstream resource supports streams - * @return false The upstream resource does not support streams. - */ - [[nodiscard]] bool supports_streams() const noexcept override - { - return upstream_->supports_streams(); - } - /** * @brief Query the number of bytes that have been allocated. Note that * this can not be used to know how large of an allocation is possible due diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 455cde4c6..252ea813f 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -143,17 +143,6 @@ class logging_resource_adaptor final : public device_memory_resource { */ [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } - /** - * @brief Checks whether the upstream resource supports streams. - * - * @return true The upstream resource supports streams - * @return false The upstream resource does not support streams. - */ - [[nodiscard]] bool supports_streams() const noexcept override - { - return upstream_->supports_streams(); - } - /** * @brief Flush logger contents. */ diff --git a/include/rmm/mr/device/managed_memory_resource.hpp b/include/rmm/mr/device/managed_memory_resource.hpp index 5b0a80426..708adad8e 100644 --- a/include/rmm/mr/device/managed_memory_resource.hpp +++ b/include/rmm/mr/device/managed_memory_resource.hpp @@ -43,14 +43,6 @@ class managed_memory_resource final : public device_memory_resource { managed_memory_resource& operator=(managed_memory_resource&&) = default; ///< @default_move_assignment{managed_memory_resource} - /** - * @brief Query whether the resource supports use of non-null streams for - * allocation/deallocation. - * - * @returns false - */ - [[nodiscard]] bool supports_streams() const noexcept override { return false; } - private: /** * @brief Allocates memory of size at least \p bytes. diff --git a/include/rmm/mr/device/owning_wrapper.hpp b/include/rmm/mr/device/owning_wrapper.hpp index 7dd160265..f8c10e76d 100644 --- a/include/rmm/mr/device/owning_wrapper.hpp +++ b/include/rmm/mr/device/owning_wrapper.hpp @@ -157,14 +157,6 @@ class owning_wrapper : public device_memory_resource { */ [[nodiscard]] Resource& wrapped() noexcept { return *wrapped_; } - /** - * @copydoc rmm::mr::device_memory_resource::supports_streams() - */ - [[nodiscard]] bool supports_streams() const noexcept override - { - return wrapped().supports_streams(); - } - private: /** * @brief Allocates memory using the wrapped resource. diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 44f8f96c4..5f70e73d1 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -228,14 +228,6 @@ class pool_memory_resource final pool_memory_resource& operator=(pool_memory_resource const&) = delete; pool_memory_resource& operator=(pool_memory_resource&&) = delete; - /** - * @brief Queries whether the resource supports use of non-null CUDA streams for - * allocation/deallocation. - * - * @returns bool true. - */ - [[nodiscard]] bool supports_streams() const noexcept override { return true; } - /** * @brief Get the upstream memory_resource object. * diff --git a/include/rmm/mr/device/statistics_resource_adaptor.hpp b/include/rmm/mr/device/statistics_resource_adaptor.hpp index ed38a20f4..8e379159b 100644 --- a/include/rmm/mr/device/statistics_resource_adaptor.hpp +++ b/include/rmm/mr/device/statistics_resource_adaptor.hpp @@ -111,14 +111,6 @@ class statistics_resource_adaptor final : public device_memory_resource { */ Upstream* get_upstream() const noexcept { return upstream_; } - /** - * @brief Checks whether the upstream resource supports streams. - * - * @return true The upstream resource supports streams - * @return false The upstream resource does not support streams. - */ - bool supports_streams() const noexcept override { return upstream_->supports_streams(); } - /** * @brief Returns a `counter` struct for this adaptor containing the current, * peak, and total number of allocated bytes for this diff --git a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp index 15ad3f0a5..5dcd2d7a8 100644 --- a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp +++ b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp @@ -71,11 +71,6 @@ class thread_safe_resource_adaptor final : public device_memory_resource { */ Upstream* get_upstream() const noexcept { return upstream_; } - /** - * @copydoc rmm::mr::device_memory_resource::supports_streams() - */ - bool supports_streams() const noexcept override { return upstream_->supports_streams(); } - private: /** * @brief Allocates memory of size at least `bytes` using the upstream diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index 2ad88f079..4635e5d3a 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -110,14 +110,6 @@ class tracking_resource_adaptor final : public device_memory_resource { */ Upstream* get_upstream() const noexcept { return upstream_; } - /** - * @brief Checks whether the upstream resource supports streams. - * - * @return true The upstream resource supports streams - * @return false The upstream resource does not support streams. - */ - bool supports_streams() const noexcept override { return upstream_->supports_streams(); } - /** * @brief Get the outstanding allocations map * diff --git a/include/rmm/mr/host/pinned_memory_resource.hpp b/include/rmm/mr/host/pinned_memory_resource.hpp index 9f68b70fa..75af35343 100644 --- a/include/rmm/mr/host/pinned_memory_resource.hpp +++ b/include/rmm/mr/host/pinned_memory_resource.hpp @@ -48,14 +48,6 @@ class pinned_memory_resource final : public host_memory_resource { pinned_memory_resource& operator=(pinned_memory_resource&&) = default; ///< @default_move_assignment{pinned_memory_resource} - /** - * @brief Query whether the pinned_memory_resource supports use of non-null CUDA streams for - * allocation/deallocation. - * - * @returns bool false. - */ - [[nodiscard]] bool supports_streams() const noexcept { return false; } - /** * @brief Pretend to support the allocate_async interface, falling back to stream 0 * diff --git a/tests/device_check_resource_adaptor.hpp b/tests/device_check_resource_adaptor.hpp index 6ff82e77a..6fac83a21 100644 --- a/tests/device_check_resource_adaptor.hpp +++ b/tests/device_check_resource_adaptor.hpp @@ -27,11 +27,6 @@ class device_check_resource_adaptor final : public rmm::mr::device_memory_resour { } - [[nodiscard]] bool supports_streams() const noexcept override - { - return upstream_->supports_streams(); - } - [[nodiscard]] device_memory_resource* get_upstream() const noexcept { return upstream_; } private: diff --git a/tests/mr/device/adaptor_tests.cpp b/tests/mr/device/adaptor_tests.cpp index e43818091..76c84d37d 100644 --- a/tests/mr/device/adaptor_tests.cpp +++ b/tests/mr/device/adaptor_tests.cpp @@ -142,11 +142,6 @@ TYPED_TEST(AdaptorTest, GetUpstream) } } -TYPED_TEST(AdaptorTest, SupportsStreams) -{ - EXPECT_EQ(this->mr->supports_streams(), this->cuda.supports_streams()); -} - TYPED_TEST(AdaptorTest, AllocFree) { void* ptr{nullptr}; diff --git a/tests/mr/device/aligned_mr_tests.cpp b/tests/mr/device/aligned_mr_tests.cpp index 4d149c182..b9ecbc8ca 100644 --- a/tests/mr/device/aligned_mr_tests.cpp +++ b/tests/mr/device/aligned_mr_tests.cpp @@ -56,18 +56,6 @@ TEST(AlignedTest, ThrowOnInvalidAllocationAlignment) EXPECT_THROW(construct_alignment(&mock, 768), rmm::logic_error); } -TEST(AlignedTest, SupportsStreams) -{ - mock_resource mock; - aligned_mock mr{&mock}; - - EXPECT_CALL(mock, supports_streams()).WillOnce(Return(true)); - EXPECT_TRUE(mr.supports_streams()); - - EXPECT_CALL(mock, supports_streams()).WillOnce(Return(false)); - EXPECT_FALSE(mr.supports_streams()); -} - TEST(AlignedTest, SupportsGetMemInfo) { mock_resource mock; diff --git a/tests/mr/device/arena_mr_tests.cpp b/tests/mr/device/arena_mr_tests.cpp index fbd96599e..c8c60f7fb 100644 --- a/tests/mr/device/arena_mr_tests.cpp +++ b/tests/mr/device/arena_mr_tests.cpp @@ -592,11 +592,5 @@ TEST_F(ArenaTest, DumpLogOnFailure) // NOLINT EXPECT_GE(file_status.st_size, 0); } -TEST_F(ArenaTest, FeatureSupport) // NOLINT -{ - arena_mr mr{rmm::mr::get_current_device_resource(), 1_MiB}; - EXPECT_TRUE(mr.supports_streams()); -} - } // namespace } // namespace rmm::test diff --git a/tests/mr/device/failure_callback_mr_tests.cpp b/tests/mr/device/failure_callback_mr_tests.cpp index 12fbff268..683aee86e 100644 --- a/tests/mr/device/failure_callback_mr_tests.cpp +++ b/tests/mr/device/failure_callback_mr_tests.cpp @@ -61,8 +61,6 @@ class always_throw_memory_resource final : public mr::device_memory_resource { throw ExceptionType{"foo"}; } void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override{}; - - [[nodiscard]] bool supports_streams() const noexcept override { return false; } }; TEST(FailureCallbackTest, DifferentExceptionTypes) diff --git a/tests/mr/device/mr_tests.cpp b/tests/mr/device/mr_tests.cpp index 5f9be9f54..5e496d2ee 100644 --- a/tests/mr/device/mr_tests.cpp +++ b/tests/mr/device/mr_tests.cpp @@ -87,16 +87,6 @@ TEST_P(mr_test, SetCurrentDeviceResource) TEST_P(mr_test, SelfEquality) { EXPECT_TRUE(this->mr->is_equal(*this->mr)); } -TEST_P(mr_test, SupportsStreams) -{ - if (this->mr->is_equal(rmm::mr::cuda_memory_resource{}) || - this->mr->is_equal(rmm::mr::managed_memory_resource{})) { - EXPECT_FALSE(this->mr->supports_streams()); - } else { - EXPECT_TRUE(this->mr->supports_streams()); - } -} - // Simple reproducer for https://github.com/rapidsai/rmm/issues/861 TEST_P(mr_test, AllocationsAreDifferentDefaultStream) { diff --git a/tests/mr/device/pool_mr_tests.cpp b/tests/mr/device/pool_mr_tests.cpp index 7193ef301..c63a61844 100644 --- a/tests/mr/device/pool_mr_tests.cpp +++ b/tests/mr/device/pool_mr_tests.cpp @@ -211,9 +211,6 @@ class fake_async_resource { bool operator==(const fake_async_resource& other) const { return true; } bool operator!=(const fake_async_resource& other) const { return false; } - // To model stream_resource - [[nodiscard]] bool supports_streams() const noexcept { return false; } - private: void* do_allocate(std::size_t bytes, cuda_stream_view) { return nullptr; } void do_deallocate(void* ptr, std::size_t, cuda_stream_view) {} From e374a27316eff35774bfb47383fbdd978eb3fcc1 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Sat, 27 Jan 2024 02:43:57 +1100 Subject: [PATCH 347/675] Deprecate rmm::mr::device_memory_resource::get_mem_info() and supports_get_mem_info(). (#1436) Closes #1427 . Part of #1388. #1430 made these functions non-virtual and removed them from all MRs and tests. This PR completes the next step of deprecating them. Merge after - https://github.com/rapidsai/raft/pull/2108 - https://github.com/rapidsai/cudf/pull/14832 Authors: - Mark Harris (https://github.com/harrism) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Michael Schellenberger Costa (https://github.com/miscco) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1436 --- .../rmm/mr/device/device_memory_resource.hpp | 31 +++++++++---------- .../rmm/mr/pinned_host_memory_resource.hpp | 20 ------------ 2 files changed, 14 insertions(+), 37 deletions(-) diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index 5d7894995..97ae85449 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -304,21 +304,32 @@ class device_memory_resource { /** * @brief Query whether the resource supports the get_mem_info API. * + * @deprecated Use rmm::available_device_memory instead. + * * @return bool true if the resource supports get_mem_info, false otherwise. */ - [[nodiscard]] virtual bool supports_get_mem_info() const noexcept { return false; }; + [[deprecated("Use rmm::available_device_memory instead.")]] // + [[nodiscard]] virtual bool + supports_get_mem_info() const noexcept + { + return false; + }; /** * @brief Queries the amount of free and total memory for the resource. * + * @deprecated Use rmm::available_device_memory instead. + * * @param stream the stream whose memory manager we want to retrieve * * @returns a pair containing the free memory in bytes in .first and total amount of memory in * .second */ - [[nodiscard]] std::pair get_mem_info(cuda_stream_view stream) const + [[deprecated("Use rmm::available_device_memory instead.")]] // + [[nodiscard]] std::pair + get_mem_info(cuda_stream_view stream) const { - return do_get_mem_info(stream); + return {0, 0}; } /** @@ -374,20 +385,6 @@ class device_memory_resource { { return this == &other; } - - /** - * @brief Get free and available memory for memory resource - * - * @throws std::runtime_error if we could not get free / total memory - * - * @param stream the stream being executed on - * @return std::pair with available and free memory for resource - */ - [[nodiscard]] virtual std::pair do_get_mem_info( - cuda_stream_view stream) const - { - return {0, 0}; - } }; static_assert(cuda::mr::async_resource_with); /** @} */ // end of group diff --git a/include/rmm/mr/pinned_host_memory_resource.hpp b/include/rmm/mr/pinned_host_memory_resource.hpp index c51af4182..0748302c2 100644 --- a/include/rmm/mr/pinned_host_memory_resource.hpp +++ b/include/rmm/mr/pinned_host_memory_resource.hpp @@ -177,26 +177,6 @@ class pinned_host_memory_resource { */ bool operator!=(const pinned_host_memory_resource&) const { return false; } - /** - * @brief Query whether the resource supports reporting free and available memory. - * - * @return false - */ - static bool supports_get_mem_info() { return false; } - - /** - * @brief Query the total amount of memory and free memory available for allocation by this - * resource. - * - * @throws nothing - * - * @return std::pair containing 0 for both total and free memory. - */ - [[nodiscard]] static std::pair get_mem_info(cuda::stream_ref) noexcept - { - return {0, 0}; - } - /** * @brief Enables the `cuda::mr::device_accessible` property * From f259b882aea9d883c825f96a3514c48e0f9d2650 Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Mon, 29 Jan 2024 20:54:27 +0000 Subject: [PATCH 348/675] Refactor error.hpp out of detail (#1439) I've moved the public part of error.hpp out of the detail header as described in https://github.com/rapidsai/rmm/issues/1369 Fixes #1369 Authors: - Basit Ayantunde (https://github.com/lamarrr) - Lawrence Mitchell (https://github.com/wence-) - Mark Harris (https://github.com/harrism) Approvers: - Michael Schellenberger Costa (https://github.com/miscco) - Lawrence Mitchell (https://github.com/wence-) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1439 --- include/rmm/detail/error.hpp | 97 +----------------------------- include/rmm/error.hpp | 112 +++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 94 deletions(-) create mode 100644 include/rmm/error.hpp diff --git a/include/rmm/detail/error.hpp b/include/rmm/detail/error.hpp index bce0d1389..79219eff0 100644 --- a/include/rmm/detail/error.hpp +++ b/include/rmm/detail/error.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -16,105 +16,14 @@ #pragma once +#include + #include #include #include -#include #include -namespace rmm { - -/** - * @brief Exception thrown when logical precondition is violated. - * - * @ingroup errors - * - * This exception should not be thrown directly and is instead thrown by the - * RMM_EXPECTS macro. - * - */ -struct logic_error : public std::logic_error { - using std::logic_error::logic_error; -}; - -/** - * @brief Exception thrown when a CUDA error is encountered. - * - * @ingroup errors - * - */ -struct cuda_error : public std::runtime_error { - using std::runtime_error::runtime_error; -}; - -/** - * @brief Exception thrown when an RMM allocation fails - * - * @ingroup errors - * - */ -class bad_alloc : public std::bad_alloc { - public: - /** - * @brief Constructs a bad_alloc with the error message. - * - * @param msg Message to be associated with the exception - */ - bad_alloc(const char* msg) : _what{std::string{std::bad_alloc::what()} + ": " + msg} {} - - /** - * @brief Constructs a bad_alloc with the error message. - * - * @param msg Message to be associated with the exception - */ - bad_alloc(std::string const& msg) : bad_alloc{msg.c_str()} {} - - /** - * @briefreturn{The explanatory string} - */ - [[nodiscard]] const char* what() const noexcept override { return _what.c_str(); } - - private: - std::string _what; -}; - -/** - * @brief Exception thrown when RMM runs out of memory - * - * @ingroup errors - * - * This error should only be thrown when we know for sure a resource is out of memory. - */ -class out_of_memory : public bad_alloc { - public: - /** - * @brief Constructs an out_of_memory with the error message. - * - * @param msg Message to be associated with the exception - */ - out_of_memory(const char* msg) : bad_alloc{std::string{"out_of_memory: "} + msg} {} - - /** - * @brief Constructs an out_of_memory with the error message. - * - * @param msg Message to be associated with the exception - */ - out_of_memory(std::string const& msg) : out_of_memory{msg.c_str()} {} -}; - -/** - * @brief Exception thrown when attempting to access outside of a defined range - * - * @ingroup errors - * - */ -class out_of_range : public std::out_of_range { - using std::out_of_range::out_of_range; -}; - -} // namespace rmm - #define STRINGIFY_DETAIL(x) #x #define RMM_STRINGIFY(x) STRINGIFY_DETAIL(x) diff --git a/include/rmm/error.hpp b/include/rmm/error.hpp new file mode 100644 index 000000000..18ba9303e --- /dev/null +++ b/include/rmm/error.hpp @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2020-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. + */ + +#pragma once + +#include +#include + +namespace rmm { + +/** + * @brief Exception thrown when logical precondition is violated. + * + * @ingroup errors + * + * This exception should not be thrown directly and is instead thrown by the + * RMM_EXPECTS macro. + * + */ +struct logic_error : public std::logic_error { + using std::logic_error::logic_error; +}; + +/** + * @brief Exception thrown when a CUDA error is encountered. + * + * @ingroup errors + * + */ +struct cuda_error : public std::runtime_error { + using std::runtime_error::runtime_error; +}; + +/** + * @brief Exception thrown when an RMM allocation fails + * + * @ingroup errors + * + */ +class bad_alloc : public std::bad_alloc { + public: + /** + * @brief Constructs a bad_alloc with the error message. + * + * @param msg Message to be associated with the exception + */ + bad_alloc(const char* msg) : _what{std::string{std::bad_alloc::what()} + ": " + msg} {} + + /** + * @brief Constructs a bad_alloc with the error message. + * + * @param msg Message to be associated with the exception + */ + bad_alloc(std::string const& msg) : bad_alloc{msg.c_str()} {} + + /** + * @briefreturn{The explanatory string} + */ + [[nodiscard]] const char* what() const noexcept override { return _what.c_str(); } + + private: + std::string _what; +}; + +/** + * @brief Exception thrown when RMM runs out of memory + * + * @ingroup errors + * + * This error should only be thrown when we know for sure a resource is out of memory. + */ +class out_of_memory : public bad_alloc { + public: + /** + * @brief Constructs an out_of_memory with the error message. + * + * @param msg Message to be associated with the exception + */ + out_of_memory(const char* msg) : bad_alloc{std::string{"out_of_memory: "} + msg} {} + + /** + * @brief Constructs an out_of_memory with the error message. + * + * @param msg Message to be associated with the exception + */ + out_of_memory(std::string const& msg) : out_of_memory{msg.c_str()} {} +}; + +/** + * @brief Exception thrown when attempting to access outside of a defined range + * + * @ingroup errors + * + */ +class out_of_range : public std::out_of_range { + using std::out_of_range::out_of_range; +}; + +} // namespace rmm From 0234f232be5afb0905affd77270b4adb696c2898 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Tue, 30 Jan 2024 10:46:11 +1100 Subject: [PATCH 349/675] Remove deprecated rmm::detail::available_device_memory (#1438) `rmm::available_device_memory` was added and the former `rmm::detail::available_device_memory` was deprecated in #1417. This PR removes the deprecated function. Closes #1425 Authors: - Mark Harris (https://github.com/harrism) Approvers: - Rong Ou (https://github.com/rongou) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1438 --- include/rmm/cuda_device.hpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/include/rmm/cuda_device.hpp b/include/rmm/cuda_device.hpp index 02017c3da..56520518a 100644 --- a/include/rmm/cuda_device.hpp +++ b/include/rmm/cuda_device.hpp @@ -116,20 +116,6 @@ inline std::pair available_device_memory() return {free, total}; } -namespace detail { - -/** - * @brief Returns the available and total device memory in bytes for the current device - * - * @deprecated Use rmm::available_device_memory() instead. - * - * @return The available and total device memory in bytes for the current device as a std::pair. - */ -[[deprecated("Use `rmm::available_device_memory` instead.")]] // -const auto available_device_memory = rmm::available_device_memory; - -} // namespace detail - /** * @brief Returns the approximate specified percent of available device memory on the current CUDA * device, aligned (down) to the nearest CUDA allocation size. From d32e665d960107b5db30e3889af438c241e1d8f9 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Thu, 1 Feb 2024 09:27:15 +1100 Subject: [PATCH 350/675] Add device_async_resource_ref convenience alias (#1441) Adds a new header `include/rmm/resource_ref.hpp` that currently just contains a single `using` alias to make it easier to spell a device-accessible async_resource_ref. Closes #1442 `rmm::device_async_resource_ref` is an alias for `cuda::mr::async_resource_ref`. This is 30 characters vs. 57. It is shorter than the currently used resource pointer spelling: `rmm::mr::device_memory_resource*`. Also updates tests to use this alias. Also makes one unrelated doc change, I noticed `pinned_host_memory_resource` was not added to a doxygen group, so I fixed that. I was going to put this in cuDF, but @bdice [suggested maybe it would be useful to have it in RMM](https://github.com/rapidsai/cudf/pull/14873#issuecomment-1911196690). Authors: - Mark Harris (https://github.com/harrism) - Michael Schellenberger Costa (https://github.com/miscco) Approvers: - Bradley Dice (https://github.com/bdice) - Michael Schellenberger Costa (https://github.com/miscco) URL: https://github.com/rapidsai/rmm/pull/1441 --- .../rmm/mr/device/binning_memory_resource.hpp | 2 -- .../detail/stream_ordered_memory_resource.hpp | 2 -- .../rmm/mr/pinned_host_memory_resource.hpp | 26 +++++++------- include/rmm/resource_ref.hpp | 35 +++++++++++++++++++ tests/device_buffer_tests.cu | 5 +-- tests/device_uvector_tests.cpp | 11 +++--- tests/mr/device/mr_ref_test.hpp | 3 +- tests/mr/device/thrust_allocator_tests.cu | 5 +-- 8 files changed, 63 insertions(+), 26 deletions(-) create mode 100644 include/rmm/resource_ref.hpp diff --git a/include/rmm/mr/device/binning_memory_resource.hpp b/include/rmm/mr/device/binning_memory_resource.hpp index a0cf6bf40..56e2958e8 100644 --- a/include/rmm/mr/device/binning_memory_resource.hpp +++ b/include/rmm/mr/device/binning_memory_resource.hpp @@ -169,8 +169,6 @@ class binning_memory_resource final : public device_memory_resource { /** * @brief Deallocate memory pointed to by \p p. * - * @throws nothing - * * @param ptr Pointer to be deallocated * @param bytes The size in bytes of the allocation. This must be equal to the * value of `bytes` that was passed to the `allocate` call that returned `p`. diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index 1d6829cb5..c7c8d9178 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -226,8 +226,6 @@ class stream_ordered_memory_resource : public crtp, public device_ /** * @brief Deallocate memory pointed to by `p`. * - * @throws nothing - * * @param p Pointer to be deallocated * @param size The size in bytes of the allocation to deallocate * @param stream The stream in which to order this deallocation diff --git a/include/rmm/mr/pinned_host_memory_resource.hpp b/include/rmm/mr/pinned_host_memory_resource.hpp index 0748302c2..e92b2985e 100644 --- a/include/rmm/mr/pinned_host_memory_resource.hpp +++ b/include/rmm/mr/pinned_host_memory_resource.hpp @@ -29,6 +29,12 @@ namespace rmm::mr { +/** + * @addtogroup memory_resources + * @{ + * @file + */ + /** * @brief Memory resource class for allocating pinned host memory. * @@ -45,9 +51,9 @@ class pinned_host_memory_resource { /** * @brief Allocates pinned host memory of size at least \p bytes bytes. * - * @throws `rmm::out_of_memory` if the requested allocation could not be fulfilled due to to a + * @throws rmm::out_of_memory if the requested allocation could not be fulfilled due to to a * CUDA out of memory error. - * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled due to any other + * @throws rmm::bad_alloc if the requested allocation could not be fulfilled due to any other * reason. * * @param bytes The size, in bytes, of the allocation. @@ -71,8 +77,6 @@ class pinned_host_memory_resource { /** * @brief Deallocate memory pointed to by \p ptr of size \p bytes bytes. * - * @throws Nothing. - * * @param ptr Pointer to be deallocated. * @param bytes Size of the allocation. * @param alignment Alignment in bytes. Default alignment is used if unspecified. @@ -90,9 +94,9 @@ class pinned_host_memory_resource { * * @note Stream argument is ignored and behavior is identical to allocate. * - * @throws `rmm::out_of_memory` if the requested allocation could not be fulfilled due to to a + * @throws rmm::out_of_memory if the requested allocation could not be fulfilled due to to a * CUDA out of memory error. - * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled due to any other + * @throws rmm::bad_alloc if the requested allocation could not be fulfilled due to any other * error. * * @param bytes The size, in bytes, of the allocation. @@ -109,9 +113,9 @@ class pinned_host_memory_resource { * * @note Stream argument is ignored and behavior is identical to allocate. * - * @throws `rmm::out_of_memory` if the requested allocation could not be fulfilled due to to a + * @throws rmm::out_of_memory if the requested allocation could not be fulfilled due to to a * CUDA out of memory error. - * @throws `rmm::bad_alloc` if the requested allocation could not be fulfilled due to any other + * @throws rmm::bad_alloc if the requested allocation could not be fulfilled due to any other * error. * * @param bytes The size, in bytes, of the allocation. @@ -131,8 +135,6 @@ class pinned_host_memory_resource { * * @note Stream argument is ignored and behavior is identical to deallocate. * - * @throws Nothing. - * * @param ptr Pointer to be deallocated. * @param bytes Size of the allocation. * @param stream CUDA stream on which to perform the deallocation (ignored). @@ -150,8 +152,6 @@ class pinned_host_memory_resource { * * @note Stream argument is ignored and behavior is identical to deallocate. * - * @throws Nothing. - * * @param ptr Pointer to be deallocated. * @param bytes Size of the allocation. * @param alignment Alignment in bytes. @@ -199,4 +199,6 @@ class pinned_host_memory_resource { static_assert(cuda::mr::async_resource_with); + +/** @} */ // end of group } // namespace rmm::mr diff --git a/include/rmm/resource_ref.hpp b/include/rmm/resource_ref.hpp new file mode 100644 index 000000000..a363f9b50 --- /dev/null +++ b/include/rmm/resource_ref.hpp @@ -0,0 +1,35 @@ +/* + * 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. + */ +#pragma once + +#include + +namespace rmm { + +/** + * @addtogroup memory_resources + * @{ + * @file + */ + +/** + * @brief Alias for a `cuda::mr::async_resource_ref` with the property + * `cuda::mr::device_accessible`. + */ +using device_async_resource_ref = cuda::mr::async_resource_ref; + +/** @} */ // end of group +} // namespace rmm diff --git a/tests/device_buffer_tests.cu b/tests/device_buffer_tests.cu index f73be0201..ef858bc62 100644 --- a/tests/device_buffer_tests.cu +++ b/tests/device_buffer_tests.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -58,7 +59,7 @@ struct DeviceBufferTest : public ::testing::Test { }; using resources = ::testing::Types; -using async_resource_ref = cuda::mr::async_resource_ref; +using async_resource_ref = rmm::device_async_resource_ref; TYPED_TEST_CASE(DeviceBufferTest, resources); diff --git a/tests/device_uvector_tests.cpp b/tests/device_uvector_tests.cpp index 3c042a437..590b857aa 100644 --- a/tests/device_uvector_tests.cpp +++ b/tests/device_uvector_tests.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -15,12 +15,13 @@ * limitations under the License. */ -#include -#include - #include #include #include +#include + +#include +#include // explicit instantiation for test coverage purposes. template class rmm::device_uvector; @@ -31,7 +32,7 @@ struct TypedUVectorTest : ::testing::Test { }; using TestTypes = ::testing::Types; -using async_resource_ref = cuda::mr::async_resource_ref; +using async_resource_ref = rmm::device_async_resource_ref; TYPED_TEST_CASE(TypedUVectorTest, TestTypes); diff --git a/tests/mr/device/mr_ref_test.hpp b/tests/mr/device/mr_ref_test.hpp index 9826c10be..2684042d7 100644 --- a/tests/mr/device/mr_ref_test.hpp +++ b/tests/mr/device/mr_ref_test.hpp @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -45,7 +46,7 @@ #include using resource_ref = cuda::mr::resource_ref; -using async_resource_ref = cuda::mr::async_resource_ref; +using async_resource_ref = rmm::device_async_resource_ref; namespace rmm::test { diff --git a/tests/mr/device/thrust_allocator_tests.cu b/tests/mr/device/thrust_allocator_tests.cu index ed8875cbe..4f5c76b09 100644 --- a/tests/mr/device/thrust_allocator_tests.cu +++ b/tests/mr/device/thrust_allocator_tests.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -32,7 +33,7 @@ namespace rmm::test { namespace { struct allocator_test : public mr_test {}; -using async_resource_ref = cuda::mr::async_resource_ref; +using async_resource_ref = rmm::device_async_resource_ref; TEST_P(allocator_test, first) { From c583fa1351ddfaea74a5d3142ccd6e7998406f50 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Fri, 2 Feb 2024 07:44:38 +1100 Subject: [PATCH 351/675] Deprecate rmm::mr::device_memory_resource::supports_streams() (#1452) Deprecates now unused `device_memory_resource::supports_streams()`. Will be removed in next release (24.06). Merge after: * https://github.com/rapidsai/raft/pull/2121 * https://github.com/rapidsai/cudf/pull/14857 Closes #1433 Authors: - Mark Harris (https://github.com/harrism) Approvers: - Michael Schellenberger Costa (https://github.com/miscco) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1452 --- include/rmm/mr/device/device_memory_resource.hpp | 9 ++++++++- tests/mock_resource.hpp | 3 +-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index 97ae85449..24190f2b4 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -297,9 +297,16 @@ class device_memory_resource { * @brief Query whether the resource supports use of non-null CUDA streams for * allocation/deallocation. * + * @deprecated Functionality removed in favor of cuda::mr::async_memory_resource. + * * @returns bool true if the resource supports non-null CUDA streams. */ - [[nodiscard]] virtual bool supports_streams() const noexcept { return false; } + [[deprecated("Functionality removed in favor of cuda::mr::async_memory_resource.")]] // + [[nodiscard]] virtual bool + supports_streams() const noexcept + { + return false; + } /** * @brief Query whether the resource supports the get_mem_info API. diff --git a/tests/mock_resource.hpp b/tests/mock_resource.hpp index d8eb4e5b9..e06148d3a 100644 --- a/tests/mock_resource.hpp +++ b/tests/mock_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -23,7 +23,6 @@ namespace rmm::test { class mock_resource : public rmm::mr::device_memory_resource { public: - MOCK_METHOD(bool, supports_streams, (), (const, override, noexcept)); MOCK_METHOD(void*, do_allocate, (std::size_t, cuda_stream_view), (override)); MOCK_METHOD(void, do_deallocate, (void*, std::size_t, cuda_stream_view), (override)); using size_pair = std::pair; From 9caab391e84a28b3eb01b18a759ab3726199929c Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Fri, 2 Feb 2024 00:18:48 -0800 Subject: [PATCH 352/675] Adopt the `rmm::device_async_resource_ref` alias (#1454) Before we had that alias we would introduce one locally. This is not needed anymore, so remove the local ones, as this helps readability. Authors: - Michael Schellenberger Costa (https://github.com/miscco) Approvers: - Rong Ou (https://github.com/rongou) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1454 --- include/rmm/device_buffer.hpp | 18 +++++++------- include/rmm/device_uvector.hpp | 12 +++++----- .../mr/device/thrust_allocator_adaptor.hpp | 19 ++++++++------- tests/device_buffer_tests.cu | 24 +++++++++++-------- tests/device_uvector_tests.cpp | 6 ++--- .../mr/device/mr_ref_multithreaded_tests.cpp | 6 ++--- tests/mr/device/mr_ref_test.hpp | 18 +++++++------- tests/mr/device/thrust_allocator_tests.cu | 3 +-- 8 files changed, 54 insertions(+), 52 deletions(-) diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index 4a780018e..167d07c4b 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -18,8 +18,8 @@ #include #include #include -#include #include +#include #include @@ -40,7 +40,7 @@ namespace rmm { * @brief RAII construct for device memory allocation * * This class allocates untyped and *uninitialized* device memory using a - * `device_memory_resource`. If not explicitly specified, the memory resource + * `device_async_resource_ref`. If not explicitly specified, the memory resource * returned from `get_current_device_resource()` is used. * * @note Unlike `std::vector` or `thrust::device_vector`, the device memory @@ -82,8 +82,6 @@ namespace rmm { *``` */ class device_buffer { - using async_resource_ref = cuda::mr::async_resource_ref; - public: // The copy constructor and copy assignment operator without a stream are deleted because they // provide no way to specify an explicit stream @@ -111,7 +109,7 @@ class device_buffer { */ explicit device_buffer(std::size_t size, cuda_stream_view stream, - async_resource_ref mr = mr::get_current_device_resource()) + device_async_resource_ref mr = mr::get_current_device_resource()) : _stream{stream}, _mr{mr} { cuda_set_device_raii dev{_device}; @@ -140,7 +138,7 @@ class device_buffer { device_buffer(void const* source_data, std::size_t size, cuda_stream_view stream, - async_resource_ref mr = rmm::mr::get_current_device_resource()) + device_async_resource_ref mr = mr::get_current_device_resource()) : _stream{stream}, _mr{mr} { cuda_set_device_raii dev{_device}; @@ -171,7 +169,7 @@ class device_buffer { */ device_buffer(device_buffer const& other, cuda_stream_view stream, - async_resource_ref mr = rmm::mr::get_current_device_resource()) + device_async_resource_ref mr = mr::get_current_device_resource()) : device_buffer{other.data(), other.size(), stream, mr} { } @@ -410,9 +408,9 @@ class device_buffer { void set_stream(cuda_stream_view stream) noexcept { _stream = stream; } /** - * @briefreturn{The async_resource_ref used to allocate and deallocate} + * @briefreturn{The resource used to allocate and deallocate} */ - [[nodiscard]] async_resource_ref memory_resource() const noexcept { return _mr; } + [[nodiscard]] rmm::device_async_resource_ref memory_resource() const noexcept { return _mr; } private: void* _data{nullptr}; ///< Pointer to device memory allocation @@ -420,7 +418,7 @@ class device_buffer { std::size_t _capacity{}; ///< The actual size of the device memory allocation cuda_stream_view _stream{}; ///< Stream to use for device memory deallocation - async_resource_ref _mr{ + rmm::device_async_resource_ref _mr{ rmm::mr::get_current_device_resource()}; ///< The memory resource used to ///< allocate/deallocate device memory cuda_device_id _device{get_current_cuda_device()}; diff --git a/include/rmm/device_uvector.hpp b/include/rmm/device_uvector.hpp index 3f77f59f7..0750ef796 100644 --- a/include/rmm/device_uvector.hpp +++ b/include/rmm/device_uvector.hpp @@ -20,8 +20,8 @@ #include #include #include -#include #include +#include #include #include @@ -74,7 +74,6 @@ namespace rmm { */ template class device_uvector { - using async_resource_ref = cuda::mr::async_resource_ref; static_assert(std::is_trivially_copyable::value, "device_uvector only supports types that are trivially copyable."); @@ -126,7 +125,7 @@ class device_uvector { */ explicit device_uvector(std::size_t size, cuda_stream_view stream, - async_resource_ref mr = rmm::mr::get_current_device_resource()) + device_async_resource_ref mr = mr::get_current_device_resource()) : _storage{elements_to_bytes(size), stream, mr} { } @@ -142,7 +141,7 @@ class device_uvector { */ explicit device_uvector(device_uvector const& other, cuda_stream_view stream, - async_resource_ref mr = rmm::mr::get_current_device_resource()) + device_async_resource_ref mr = mr::get_current_device_resource()) : _storage{other._storage, stream, mr} { } @@ -525,9 +524,10 @@ class device_uvector { [[nodiscard]] bool is_empty() const noexcept { return size() == 0; } /** - * @briefreturn{The async_resource_ref used to allocate and deallocate the device storage} + * @briefreturn{The resource used to allocate and deallocate the device + * storage} */ - [[nodiscard]] async_resource_ref memory_resource() const noexcept + [[nodiscard]] rmm::device_async_resource_ref memory_resource() const noexcept { return _storage.memory_resource(); } diff --git a/include/rmm/mr/device/thrust_allocator_adaptor.hpp b/include/rmm/mr/device/thrust_allocator_adaptor.hpp index 562a0d79e..ece495c37 100644 --- a/include/rmm/mr/device/thrust_allocator_adaptor.hpp +++ b/include/rmm/mr/device/thrust_allocator_adaptor.hpp @@ -16,8 +16,8 @@ #pragma once -#include #include +#include #include #include @@ -34,9 +34,9 @@ namespace rmm::mr { */ /** * @brief An `allocator` compatible with Thrust containers and algorithms using - * a `device_memory_resource` for memory (de)allocation. + * a `device_async_resource_ref` for memory (de)allocation. * - * Unlike a `device_memory_resource`, `thrust_allocator` is typed and bound to + * Unlike a `device_async_resource_ref`, `thrust_allocator` is typed and bound to * allocate objects of a specific type `T`, but can be freely rebound to other * types. * @@ -44,8 +44,6 @@ namespace rmm::mr { */ template class thrust_allocator : public thrust::device_malloc_allocator { - using async_resource_ref = cuda::mr::async_resource_ref; - public: using Base = thrust::device_malloc_allocator; ///< The base type of this allocator using pointer = typename Base::pointer; ///< The pointer type @@ -83,7 +81,10 @@ class thrust_allocator : public thrust::device_malloc_allocator { * @param mr The resource to be used for device memory allocation * @param stream The stream to be used for device memory (de)allocation */ - thrust_allocator(cuda_stream_view stream, async_resource_ref mr) : _stream{stream}, _mr(mr) {} + thrust_allocator(cuda_stream_view stream, rmm::device_async_resource_ref mr) + : _stream{stream}, _mr(mr) + { + } /** * @brief Copy constructor. Copies the resource pointer and stream. @@ -121,9 +122,9 @@ class thrust_allocator : public thrust::device_malloc_allocator { } /** - * @briefreturn{The async_resource_ref used to allocate and deallocate} + * @briefreturn{The resource used to allocate and deallocate} */ - [[nodiscard]] async_resource_ref memory_resource() const noexcept { return _mr; } + [[nodiscard]] rmm::device_async_resource_ref memory_resource() const noexcept { return _mr; } /** * @briefreturn{The stream used by this allocator} @@ -139,7 +140,7 @@ class thrust_allocator : public thrust::device_malloc_allocator { private: cuda_stream_view _stream{}; - async_resource_ref _mr{rmm::mr::get_current_device_resource()}; + rmm::device_async_resource_ref _mr{rmm::mr::get_current_device_resource()}; }; /** @} */ // end of group } // namespace rmm::mr diff --git a/tests/device_buffer_tests.cu b/tests/device_buffer_tests.cu index ef858bc62..c095eecf8 100644 --- a/tests/device_buffer_tests.cu +++ b/tests/device_buffer_tests.cu @@ -59,7 +59,6 @@ struct DeviceBufferTest : public ::testing::Test { }; using resources = ::testing::Types; -using async_resource_ref = rmm::device_async_resource_ref; TYPED_TEST_CASE(DeviceBufferTest, resources); @@ -76,7 +75,8 @@ TYPED_TEST(DeviceBufferTest, DefaultMemoryResource) EXPECT_EQ(this->size, buff.size()); EXPECT_EQ(this->size, buff.ssize()); EXPECT_EQ(this->size, buff.capacity()); - EXPECT_EQ(async_resource_ref{rmm::mr::get_current_device_resource()}, buff.memory_resource()); + EXPECT_EQ(rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}, + buff.memory_resource()); EXPECT_EQ(rmm::cuda_stream_view{}, buff.stream()); } @@ -87,7 +87,8 @@ TYPED_TEST(DeviceBufferTest, DefaultMemoryResourceStream) EXPECT_NE(nullptr, buff.data()); EXPECT_EQ(this->size, buff.size()); EXPECT_EQ(this->size, buff.capacity()); - EXPECT_EQ(async_resource_ref{rmm::mr::get_current_device_resource()}, buff.memory_resource()); + EXPECT_EQ(rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}, + buff.memory_resource()); EXPECT_EQ(this->stream, buff.stream()); } @@ -97,7 +98,7 @@ TYPED_TEST(DeviceBufferTest, ExplicitMemoryResource) EXPECT_NE(nullptr, buff.data()); EXPECT_EQ(this->size, buff.size()); EXPECT_EQ(this->size, buff.capacity()); - EXPECT_EQ(async_resource_ref{this->mr}, buff.memory_resource()); + EXPECT_EQ(rmm::device_async_resource_ref{this->mr}, buff.memory_resource()); EXPECT_EQ(rmm::cuda_stream_view{}, buff.stream()); } @@ -108,7 +109,7 @@ TYPED_TEST(DeviceBufferTest, ExplicitMemoryResourceStream) EXPECT_NE(nullptr, buff.data()); EXPECT_EQ(this->size, buff.size()); EXPECT_EQ(this->size, buff.capacity()); - EXPECT_EQ(async_resource_ref{this->mr}, buff.memory_resource()); + EXPECT_EQ(rmm::device_async_resource_ref{this->mr}, buff.memory_resource()); EXPECT_EQ(this->stream, buff.stream()); } @@ -120,7 +121,8 @@ TYPED_TEST(DeviceBufferTest, CopyFromRawDevicePointer) EXPECT_NE(nullptr, buff.data()); EXPECT_EQ(this->size, buff.size()); EXPECT_EQ(this->size, buff.capacity()); - EXPECT_EQ(async_resource_ref{rmm::mr::get_current_device_resource()}, buff.memory_resource()); + EXPECT_EQ(rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}, + buff.memory_resource()); EXPECT_EQ(rmm::cuda_stream_view{}, buff.stream()); // TODO check for equality between the contents of the two allocations @@ -136,7 +138,8 @@ TYPED_TEST(DeviceBufferTest, CopyFromRawHostPointer) EXPECT_NE(nullptr, buff.data()); EXPECT_EQ(this->size, buff.size()); EXPECT_EQ(this->size, buff.capacity()); - EXPECT_EQ(async_resource_ref{rmm::mr::get_current_device_resource()}, buff.memory_resource()); + EXPECT_EQ(rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}, + buff.memory_resource()); EXPECT_EQ(rmm::cuda_stream_view{}, buff.stream()); buff.stream().synchronize(); // TODO check for equality between the contents of the two allocations @@ -149,7 +152,8 @@ TYPED_TEST(DeviceBufferTest, CopyFromNullptr) EXPECT_EQ(nullptr, buff.data()); EXPECT_EQ(0, buff.size()); EXPECT_EQ(0, buff.capacity()); - EXPECT_EQ(async_resource_ref{rmm::mr::get_current_device_resource()}, buff.memory_resource()); + EXPECT_EQ(rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}, + buff.memory_resource()); EXPECT_EQ(rmm::cuda_stream_view{}, buff.stream()); } @@ -176,7 +180,7 @@ TYPED_TEST(DeviceBufferTest, CopyConstructor) EXPECT_EQ(buff.size(), buff_copy.size()); EXPECT_EQ(buff.capacity(), buff_copy.capacity()); EXPECT_EQ(buff_copy.memory_resource(), - async_resource_ref{rmm::mr::get_current_device_resource()}); + rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}); EXPECT_EQ(buff_copy.stream(), rmm::cuda_stream_view{}); EXPECT_TRUE(thrust::equal(rmm::exec_policy(rmm::cuda_stream_default), @@ -219,7 +223,7 @@ TYPED_TEST(DeviceBufferTest, CopyCapacityLargerThanSize) // The capacity of the copy should be equal to the `size()` of the original EXPECT_EQ(new_size, buff_copy.capacity()); EXPECT_EQ(buff_copy.memory_resource(), - async_resource_ref{rmm::mr::get_current_device_resource()}); + rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}); EXPECT_EQ(buff_copy.stream(), rmm::cuda_stream_view{}); EXPECT_TRUE(thrust::equal(rmm::exec_policy(rmm::cuda_stream_default), diff --git a/tests/device_uvector_tests.cpp b/tests/device_uvector_tests.cpp index 590b857aa..1c93ef138 100644 --- a/tests/device_uvector_tests.cpp +++ b/tests/device_uvector_tests.cpp @@ -31,15 +31,15 @@ struct TypedUVectorTest : ::testing::Test { [[nodiscard]] rmm::cuda_stream_view stream() const noexcept { return rmm::cuda_stream_view{}; } }; -using TestTypes = ::testing::Types; -using async_resource_ref = rmm::device_async_resource_ref; +using TestTypes = ::testing::Types; TYPED_TEST_CASE(TypedUVectorTest, TestTypes); TYPED_TEST(TypedUVectorTest, MemoryResource) { rmm::device_uvector vec(128, this->stream()); - EXPECT_EQ(vec.memory_resource(), async_resource_ref{rmm::mr::get_current_device_resource()}); + EXPECT_EQ(vec.memory_resource(), + rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}); } TYPED_TEST(TypedUVectorTest, ZeroSizeConstructor) diff --git a/tests/mr/device/mr_ref_multithreaded_tests.cpp b/tests/mr/device/mr_ref_multithreaded_tests.cpp index 76f9e6b61..48d642a32 100644 --- a/tests/mr/device/mr_ref_multithreaded_tests.cpp +++ b/tests/mr/device/mr_ref_multithreaded_tests.cpp @@ -118,7 +118,7 @@ TEST_P(mr_ref_test_mt, MixedRandomAllocationFreeStream) spawn(test_mixed_random_async_allocation_free, this->ref, default_max_size, this->stream.view()); } -void allocate_async_loop(async_resource_ref ref, +void allocate_async_loop(rmm::device_async_resource_ref ref, std::size_t num_allocations, std::list& allocations, std::mutex& mtx, @@ -146,7 +146,7 @@ void allocate_async_loop(async_resource_ref ref, cudaEventSynchronize(event); } -void deallocate_async_loop(async_resource_ref ref, +void deallocate_async_loop(rmm::device_async_resource_ref ref, std::size_t num_allocations, std::list& allocations, std::mutex& mtx, @@ -167,7 +167,7 @@ void deallocate_async_loop(async_resource_ref ref, cudaEventSynchronize(event); } -void test_allocate_async_free_different_threads(async_resource_ref ref, +void test_allocate_async_free_different_threads(rmm::device_async_resource_ref ref, rmm::cuda_stream_view streamA, rmm::cuda_stream_view streamB) { diff --git a/tests/mr/device/mr_ref_test.hpp b/tests/mr/device/mr_ref_test.hpp index 2684042d7..f999e08f4 100644 --- a/tests/mr/device/mr_ref_test.hpp +++ b/tests/mr/device/mr_ref_test.hpp @@ -45,8 +45,7 @@ #include #include -using resource_ref = cuda::mr::resource_ref; -using async_resource_ref = rmm::device_async_resource_ref; +using resource_ref = cuda::mr::resource_ref; namespace rmm::test { @@ -76,7 +75,7 @@ inline void test_allocate(resource_ref ref, std::size_t bytes) } } -inline void test_allocate_async(async_resource_ref ref, +inline void test_allocate_async(rmm::device_async_resource_ref ref, std::size_t bytes, cuda_stream_view stream = {}) { @@ -106,7 +105,7 @@ inline void concurrent_allocations_are_different(resource_ref ref) ref.deallocate(ptr2, size); } -inline void concurrent_async_allocations_are_different(async_resource_ref ref, +inline void concurrent_async_allocations_are_different(rmm::device_async_resource_ref ref, cuda_stream_view stream) { const auto size{8_B}; @@ -147,7 +146,8 @@ inline void test_various_allocations(resource_ref ref) } } -inline void test_various_async_allocations(async_resource_ref ref, cuda_stream_view stream) +inline void test_various_async_allocations(rmm::device_async_resource_ref ref, + cuda_stream_view stream) { // test allocating zero bytes on non-default stream { @@ -200,7 +200,7 @@ inline void test_random_allocations(resource_ref ref, }); } -inline void test_random_async_allocations(async_resource_ref ref, +inline void test_random_async_allocations(rmm::device_async_resource_ref ref, std::size_t num_allocations = default_num_allocations, size_in_bytes max_size = default_max_size, cuda_stream_view stream = {}) @@ -273,7 +273,7 @@ inline void test_mixed_random_allocation_free(resource_ref ref, EXPECT_EQ(allocations.size(), active_allocations); } -inline void test_mixed_random_async_allocation_free(async_resource_ref ref, +inline void test_mixed_random_async_allocation_free(rmm::device_async_resource_ref ref, size_in_bytes max_size = default_max_size, cuda_stream_view stream = {}) { @@ -344,11 +344,11 @@ struct mr_ref_test : public ::testing::TestWithParam { GTEST_SKIP() << "Skipping tests since the memory resource is not supported with this CUDA " << "driver/runtime version"; } - ref = async_resource_ref{*mr}; + ref = rmm::device_async_resource_ref{*mr}; } std::shared_ptr mr; ///< Pointer to resource to use in tests - async_resource_ref ref{*mr}; + rmm::device_async_resource_ref ref{*mr}; rmm::cuda_stream stream{}; }; diff --git a/tests/mr/device/thrust_allocator_tests.cu b/tests/mr/device/thrust_allocator_tests.cu index 4f5c76b09..038f4b664 100644 --- a/tests/mr/device/thrust_allocator_tests.cu +++ b/tests/mr/device/thrust_allocator_tests.cu @@ -33,7 +33,6 @@ namespace rmm::test { namespace { struct allocator_test : public mr_test {}; -using async_resource_ref = rmm::device_async_resource_ref; TEST_P(allocator_test, first) { @@ -47,7 +46,7 @@ TEST_P(allocator_test, defaults) rmm::mr::thrust_allocator allocator(rmm::cuda_stream_default); EXPECT_EQ(allocator.stream(), rmm::cuda_stream_default); EXPECT_EQ(allocator.memory_resource(), - async_resource_ref{rmm::mr::get_current_device_resource()}); + rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}); } INSTANTIATE_TEST_CASE_P(ThrustAllocatorTests, From b85f482bbebbff4a33417009801dd1d17f7e7400 Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Fri, 2 Feb 2024 00:20:57 -0800 Subject: [PATCH 353/675] Change `device_scalar` to take `async_resource_ref` (#1447) This rewrite `device_scalar` to take `async_resource_ref` instead of a plain `device_memory_resource*`. This is completely opaque to the user as the underlying `device_uvector` already takes a `async_resource_ref` Authors: - Michael Schellenberger Costa (https://github.com/miscco) Approvers: - Rong Ou (https://github.com/rongou) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1447 --- include/rmm/device_scalar.hpp | 18 ++++++++---------- tests/device_scalar_tests.cpp | 5 ++++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/rmm/device_scalar.hpp b/include/rmm/device_scalar.hpp index 8e99905ce..762ba1612 100644 --- a/include/rmm/device_scalar.hpp +++ b/include/rmm/device_scalar.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -18,8 +18,8 @@ #include #include -#include #include +#include #include @@ -92,9 +92,8 @@ class device_scalar { * @param stream Stream on which to perform asynchronous allocation. * @param mr Optional, resource with which to allocate. */ - explicit device_scalar( - cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) + explicit device_scalar(cuda_stream_view stream, + device_async_resource_ref mr = mr::get_current_device_resource()) : _storage{1, stream, mr} { } @@ -115,10 +114,9 @@ class device_scalar { * @param stream Optional, stream on which to perform allocation and copy. * @param mr Optional, resource with which to allocate. */ - explicit device_scalar( - value_type const& initial_value, - cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) + explicit device_scalar(value_type const& initial_value, + cuda_stream_view stream, + device_async_resource_ref mr = mr::get_current_device_resource()) : _storage{1, stream, mr} { set_value_async(initial_value, stream); @@ -138,7 +136,7 @@ class device_scalar { */ device_scalar(device_scalar const& other, cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) + device_async_resource_ref mr = mr::get_current_device_resource()) : _storage{other._storage, stream, mr} { } diff --git a/tests/device_scalar_tests.cpp b/tests/device_scalar_tests.cpp index 7fbdaec29..5a7825533 100644 --- a/tests/device_scalar_tests.cpp +++ b/tests/device_scalar_tests.cpp @@ -20,9 +20,12 @@ #include #include #include +#include #include +#include + #include #include #include @@ -36,7 +39,7 @@ struct DeviceScalarTest : public ::testing::Test { std::default_random_engine generator{}; T value{}; rmm::cuda_stream stream{}; - rmm::mr::device_memory_resource* mr{rmm::mr::get_current_device_resource()}; + rmm::device_async_resource_ref mr{rmm::mr::get_current_device_resource()}; DeviceScalarTest() : value{random_value()} {} From beb6c36d3cc1aa655f5f311113ed033dca8c23fb Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Fri, 2 Feb 2024 00:28:36 -0800 Subject: [PATCH 354/675] Change `rmm::exec_policy` to take `async_resource_ref` (#1449) Authors: - Michael Schellenberger Costa (https://github.com/miscco) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1449 --- include/rmm/exec_policy.hpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/rmm/exec_policy.hpp b/include/rmm/exec_policy.hpp index eacdfa187..5acd062e3 100644 --- a/include/rmm/exec_policy.hpp +++ b/include/rmm/exec_policy.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -39,7 +40,7 @@ namespace rmm { * @brief Synchronous execution policy for allocations using thrust */ using thrust_exec_policy_t = - thrust::detail::execute_with_allocator, + thrust::detail::execute_with_allocator, thrust::cuda_cub::execute_on_stream_base>; /** @@ -54,10 +55,10 @@ class exec_policy : public thrust_exec_policy_t { * @param stream The stream on which to allocate temporary memory * @param mr The resource to use for allocating temporary memory */ - explicit exec_policy(cuda_stream_view stream = cuda_stream_default, - rmm::mr::device_memory_resource* mr = mr::get_current_device_resource()) + explicit exec_policy(cuda_stream_view stream = cuda_stream_default, + device_async_resource_ref mr = mr::get_current_device_resource()) : thrust_exec_policy_t( - thrust::cuda::par(rmm::mr::thrust_allocator(stream, mr)).on(stream.value())) + thrust::cuda::par(mr::thrust_allocator(stream, mr)).on(stream.value())) { } }; @@ -68,7 +69,7 @@ class exec_policy : public thrust_exec_policy_t { * @brief Asynchronous execution policy for allocations using thrust */ using thrust_exec_policy_nosync_t = - thrust::detail::execute_with_allocator, + thrust::detail::execute_with_allocator, thrust::cuda_cub::execute_on_stream_nosync_base>; /** * @brief Helper class usable as a Thrust CUDA execution policy @@ -78,11 +79,10 @@ using thrust_exec_policy_nosync_t = */ class exec_policy_nosync : public thrust_exec_policy_nosync_t { public: - explicit exec_policy_nosync( - cuda_stream_view stream = cuda_stream_default, - rmm::mr::device_memory_resource* mr = mr::get_current_device_resource()) + explicit exec_policy_nosync(cuda_stream_view stream = cuda_stream_default, + device_async_resource_ref mr = mr::get_current_device_resource()) : thrust_exec_policy_nosync_t( - thrust::cuda::par_nosync(rmm::mr::thrust_allocator(stream, mr)).on(stream.value())) + thrust::cuda::par_nosync(mr::thrust_allocator(stream, mr)).on(stream.value())) { } }; From f32d35b48fe9c7ad680cd2c78535a2d463d2e73b Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 6 Feb 2024 17:40:07 -0800 Subject: [PATCH 355/675] Exclude tests from builds (#1459) --- python/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/python/pyproject.toml b/python/pyproject.toml index 1e901b1ab..204d81c3c 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -114,6 +114,7 @@ build-dir = "build/{wheel_tag}" cmake.build-type = "Release" cmake.minimum-version = "3.26.4" ninja.make-fallback = true +sdist.exclude = ["*tests*"] sdist.reproducible = true wheel.packages = ["rmm"] From 49f70580111cb10eeb1d0222216d356df70cd8c0 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 7 Feb 2024 10:30:45 -0600 Subject: [PATCH 356/675] Ensure that `ctest` is called with `--no-tests=error`. (#1460) This PR ensures that all calls to `ctest` include the flag `--no-tests=error`. See https://github.com/rapidsai/build-planning/issues/18. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1460 --- ci/test_cpp.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 3bf915e0a..fddd71b9d 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2020-2023, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. set -euo pipefail @@ -40,7 +40,7 @@ rapids-logger "Run gtests" cd $CONDA_PREFIX/bin/gtests/librmm/ export GTEST_OUTPUT=xml:${RAPIDS_TESTS_DIR}/ -ctest -j20 --output-on-failure +ctest -j20 --output-on-failure --no-tests=error rapids-logger "Test script exiting with value: $EXITCODE" exit ${EXITCODE} From a9dbf9ae0932cb93713684dcdc6211c9bce6bddf Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 9 Feb 2024 15:31:03 -0600 Subject: [PATCH 357/675] Support CUDA 12.2 (#1419) * switches to CUDA 12.2.2 for building conda packages and wheels * adds new tests running against CUDA 12.2.2 ### Notes for Reviewers This is part of ongoing work to build and test packages against CUDA 12.2.2 across all of RAPIDS. For more details see: * https://github.com/rapidsai/build-planning/issues/7 * https://github.com/rapidsai/shared-workflows/pull/166 Authors: - James Lamb (https://github.com/jameslamb) - Bradley Dice (https://github.com/bdice) - https://github.com/jakirkham Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1419 --- .github/workflows/build.yaml | 12 +++++------ .github/workflows/pr.yaml | 20 +++++++++---------- .github/workflows/test.yaml | 6 +++--- ..._64.yaml => all_cuda-122_arch-x86_64.yaml} | 4 ++-- conda/recipes/librmm/meta.yaml | 12 +++++++++-- conda/recipes/rmm/meta.yaml | 5 +++++ dependencies.yaml | 6 +++++- 7 files changed, 41 insertions(+), 24 deletions(-) rename conda/environments/{all_cuda-120_arch-x86_64.yaml => all_cuda-122_arch-x86_64.yaml} (93%) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e4113d5c5..1de34cbfd 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@test-cuda-12.2 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@test-cuda-12.2 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@test-cuda-12.2 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@test-cuda-12.2 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@test-cuda-12.2 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -78,7 +78,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@test-cuda-12.2 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index da32eb12b..56257eee6 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -22,40 +22,40 @@ jobs: - wheel-tests - devcontainer secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@test-cuda-12.2 checks: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@test-cuda-12.2 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@test-cuda-12.2 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@test-cuda-12.2 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@test-cuda-12.2 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@test-cuda-12.2 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@test-cuda-12.2 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -65,20 +65,20 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@test-cuda-12.2 with: build_type: pull-request script: ci/build_wheel.sh wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@test-cuda-12.2 with: build_type: pull-request script: ci/test_wheel.sh devcontainer: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@test-cuda-12.2 with: build_command: | sccache -z; diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0e7938310..0f4ac8cad 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@test-cuda-12.2 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@test-cuda-12.2 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@test-cuda-12.2 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/conda/environments/all_cuda-120_arch-x86_64.yaml b/conda/environments/all_cuda-122_arch-x86_64.yaml similarity index 93% rename from conda/environments/all_cuda-120_arch-x86_64.yaml rename to conda/environments/all_cuda-122_arch-x86_64.yaml index 2f9c9297c..d5d6275a8 100644 --- a/conda/environments/all_cuda-120_arch-x86_64.yaml +++ b/conda/environments/all_cuda-122_arch-x86_64.yaml @@ -11,7 +11,7 @@ dependencies: - cmake>=3.26.4 - cuda-nvcc - cuda-python>=12.0,<13.0a0 -- cuda-version=12.0 +- cuda-version=12.2 - cxx-compiler - cython>=3.0.0 - doxygen=1.9.1 @@ -38,4 +38,4 @@ dependencies: - sphinx-markdown-tables - sphinx_rtd_theme - sysroot_linux-64==2.17 -name: all_cuda-120_arch-x86_64 +name: all_cuda-122_arch-x86_64 diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 9dcc6ccfe..60cd6ffae 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -3,7 +3,6 @@ {% set version = environ['RAPIDS_PACKAGE_VERSION'].lstrip('v') %} {% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} {% set cuda_major = cuda_version.split('.')[0] %} -{% set cuda_spec = ">=" + cuda_major ~ ",<" + (cuda_major | int + 1) ~ ".0a0" %} # i.e. >=11,<12.0a0 {% set date_string = environ['RAPIDS_DATE_STRING'] %} package: @@ -67,15 +66,19 @@ outputs: ignore_run_exports_from: {% if cuda_major == "11" %} - {{ compiler('cuda11') }} + {% else %} + - {{ compiler('cuda') }} {% endif %} requirements: build: - cmake {{ cmake_version }} + host: + - cuda-version ={{ cuda_version }} run: + - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} {% if cuda_major == "11" %} - cudatoolkit {% endif %} - - cuda-version {{ cuda_spec }} - fmt {{ fmt_version }} - spdlog {{ spdlog_version }} test: @@ -125,6 +128,9 @@ outputs: ignore_run_exports_from: {% if cuda_major == "11" %} - {{ compiler('cuda11') }} + {% else %} + - {{ compiler('cuda') }} + - cuda-cudart-dev {% endif %} requirements: build: @@ -139,6 +145,8 @@ outputs: run: {% if cuda_major == "11" %} - cudatoolkit + {% else %} + - cuda-cudart {% endif %} - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - {{ pin_subpackage('librmm', exact=True) }} diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 1e50853b6..83975d0f2 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -34,6 +34,9 @@ build: ignore_run_exports_from: {% if cuda_major == "11" %} - {{ compiler('cuda11') }} + {% else %} + - {{ compiler('cuda') }} + - cuda-cudart-dev {% endif %} requirements: @@ -65,6 +68,8 @@ requirements: run: {% if cuda_major == "11" %} - cudatoolkit + {% else %} + - cuda-cudart {% endif %} - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - numba >=0.57 diff --git a/dependencies.yaml b/dependencies.yaml index 4d1a0ec49..1bf4e1034 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -3,7 +3,7 @@ files: all: output: conda matrix: - cuda: ["11.8", "12.0"] + cuda: ["11.8", "12.2"] arch: [x86_64] includes: - build @@ -154,6 +154,10 @@ dependencies: cuda: "12.0" packages: - cuda-version=12.0 + - matrix: + cuda: "12.2" + packages: + - cuda-version=12.2 cuda: specific: - output_types: conda From 0f1ff2749cdec780227d5e75f8e10e608007054a Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Mon, 12 Feb 2024 15:44:04 -0500 Subject: [PATCH 358/675] Update Changelog [skip ci] --- CHANGELOG.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 930ad9490..9d9ccfd94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,47 @@ +# RMM 24.02.00 (12 Feb 2024) + +## 🚨 Breaking Changes + +- Make device_memory_resource::do_get_mem_info() and supports_get_mem_info() not pure virtual. Remove derived implementations and calls in RMM ([#1430](https://github.com/rapidsai/rmm/pull/1430)) [@harrism](https://github.com/harrism) +- Deprecate detail::available_device_memory, most detail/aligned.hpp utilities, and optional pool_memory_resource initial size ([#1424](https://github.com/rapidsai/rmm/pull/1424)) [@harrism](https://github.com/harrism) +- Require explicit pool size in `pool_memory_resource` and move some things out of detail namespace ([#1417](https://github.com/rapidsai/rmm/pull/1417)) [@harrism](https://github.com/harrism) +- Remove HTML builds of librmm ([#1415](https://github.com/rapidsai/rmm/pull/1415)) [@vyasr](https://github.com/vyasr) +- Update to CCCL 2.2.0. ([#1404](https://github.com/rapidsai/rmm/pull/1404)) [@bdice](https://github.com/bdice) +- Switch to scikit-build-core ([#1287](https://github.com/rapidsai/rmm/pull/1287)) [@vyasr](https://github.com/vyasr) + +## 🐛 Bug Fixes + +- Exclude tests from builds ([#1459](https://github.com/rapidsai/rmm/pull/1459)) [@vyasr](https://github.com/vyasr) +- Update CODEOWNERS ([#1410](https://github.com/rapidsai/rmm/pull/1410)) [@raydouglass](https://github.com/raydouglass) +- Correct signatures for torch allocator plug in ([#1407](https://github.com/rapidsai/rmm/pull/1407)) [@wence-](https://github.com/wence-) +- Fix Arena MR to support simultaneous access by PTDS and other streams ([#1395](https://github.com/rapidsai/rmm/pull/1395)) [@tgravescs](https://github.com/tgravescs) +- Fix else-after-throw clang tidy error ([#1391](https://github.com/rapidsai/rmm/pull/1391)) [@harrism](https://github.com/harrism) + +## 📖 Documentation + +- remove references to setup.py in docs ([#1420](https://github.com/rapidsai/rmm/pull/1420)) [@jameslamb](https://github.com/jameslamb) +- Remove HTML builds of librmm ([#1415](https://github.com/rapidsai/rmm/pull/1415)) [@vyasr](https://github.com/vyasr) +- Update GPU support docs to drop Pascal ([#1413](https://github.com/rapidsai/rmm/pull/1413)) [@harrism](https://github.com/harrism) + +## 🚀 New Features + +- Make device_memory_resource::do_get_mem_info() and supports_get_mem_info() not pure virtual. Remove derived implementations and calls in RMM ([#1430](https://github.com/rapidsai/rmm/pull/1430)) [@harrism](https://github.com/harrism) +- Deprecate detail::available_device_memory, most detail/aligned.hpp utilities, and optional pool_memory_resource initial size ([#1424](https://github.com/rapidsai/rmm/pull/1424)) [@harrism](https://github.com/harrism) +- Add a host-pinned memory resource that can be used as upstream for `pool_memory_resource`. ([#1392](https://github.com/rapidsai/rmm/pull/1392)) [@harrism](https://github.com/harrism) + +## 🛠️ Improvements + +- Remove usages of rapids-env-update ([#1423](https://github.com/rapidsai/rmm/pull/1423)) [@KyleFromNVIDIA](https://github.com/KyleFromNVIDIA) +- Refactor CUDA versions in dependencies.yaml. ([#1422](https://github.com/rapidsai/rmm/pull/1422)) [@bdice](https://github.com/bdice) +- Require explicit pool size in `pool_memory_resource` and move some things out of detail namespace ([#1417](https://github.com/rapidsai/rmm/pull/1417)) [@harrism](https://github.com/harrism) +- Update dependencies.yaml to support CUDA 12.*. ([#1414](https://github.com/rapidsai/rmm/pull/1414)) [@bdice](https://github.com/bdice) +- Define python dependency range as a matrix fallback. ([#1409](https://github.com/rapidsai/rmm/pull/1409)) [@bdice](https://github.com/bdice) +- Use latest cuda-python within CUDA major version. ([#1406](https://github.com/rapidsai/rmm/pull/1406)) [@bdice](https://github.com/bdice) +- Update to CCCL 2.2.0. ([#1404](https://github.com/rapidsai/rmm/pull/1404)) [@bdice](https://github.com/bdice) +- Remove RMM_BUILD_WHEELS and standardize Python builds ([#1401](https://github.com/rapidsai/rmm/pull/1401)) [@vyasr](https://github.com/vyasr) +- Update to fmt 10.1.1 and spdlog 1.12.0. ([#1374](https://github.com/rapidsai/rmm/pull/1374)) [@bdice](https://github.com/bdice) +- Switch to scikit-build-core ([#1287](https://github.com/rapidsai/rmm/pull/1287)) [@vyasr](https://github.com/vyasr) + # RMM 23.12.00 (6 Dec 2023) ## 🚨 Breaking Changes From ce3af2c46b8b6466b240ba5529b48f0ad5b6e0b7 Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Wed, 14 Feb 2024 16:32:18 -0800 Subject: [PATCH 359/675] Remove duplicated memory_resource_tests (#1451) During the initial introduction of `async_resource_ref` we duplicated all tests that take a `device_memory_resource*`. Now that we have already some experience with running it in production and are moving more of the interfaces to `async resource_ref` remove those duplicated tests. closes #1450 Authors: - Michael Schellenberger Costa (https://github.com/miscco) Approvers: - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1451 --- tests/CMakeLists.txt | 7 - tests/mr/device/mr_multithreaded_tests.cpp | 286 ------------------ .../mr/device/mr_ref_multithreaded_tests.cpp | 70 +++++ tests/mr/device/mr_ref_test.hpp | 20 ++ tests/mr/device/mr_ref_tests.cpp | 37 +++ tests/mr/device/mr_test.hpp | 285 ----------------- tests/mr/device/mr_tests.cpp | 129 -------- tests/mr/device/thrust_allocator_tests.cu | 4 +- tests/mr/host/mr_tests.cpp | 256 ---------------- 9 files changed, 129 insertions(+), 965 deletions(-) delete mode 100644 tests/mr/device/mr_multithreaded_tests.cpp delete mode 100644 tests/mr/device/mr_test.hpp delete mode 100644 tests/mr/device/mr_tests.cpp delete mode 100644 tests/mr/host/mr_tests.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a3d493e40..0d0561098 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -122,10 +122,6 @@ endfunction() # test sources -# device mr tests -ConfigureTest(DEVICE_MR_TEST mr/device/mr_tests.cpp mr/device/mr_multithreaded_tests.cpp GPUS 1 - PERCENT 90) - # device mr_ref tests ConfigureTest(DEVICE_MR_REF_TEST mr/device/mr_ref_tests.cpp mr/device/mr_ref_multithreaded_tests.cpp GPUS 1 PERCENT 100) @@ -163,9 +159,6 @@ ConfigureTest(ALIGNED_TEST mr/device/aligned_mr_tests.cpp) # limiting adaptor tests ConfigureTest(LIMITING_TEST mr/device/limiting_mr_tests.cpp) -# host mr tests -ConfigureTest(HOST_MR_TEST mr/host/mr_tests.cpp) - # host mr_ref tests ConfigureTest(HOST_MR_REF_TEST mr/host/mr_ref_tests.cpp) diff --git a/tests/mr/device/mr_multithreaded_tests.cpp b/tests/mr/device/mr_multithreaded_tests.cpp deleted file mode 100644 index 113b59e8f..000000000 --- a/tests/mr/device/mr_multithreaded_tests.cpp +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright (c) 2020-2021, 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. - */ - -#include "mr_test.hpp" - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace rmm::test { -namespace { - -struct mr_test_mt : public mr_test {}; - -INSTANTIATE_TEST_CASE_P(MultiThreadResourceTests, - mr_test_mt, - ::testing::Values(mr_factory{"CUDA", &make_cuda}, -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT - mr_factory{"CUDA_Async", &make_cuda_async}, -#endif - mr_factory{"Managed", &make_managed}, - mr_factory{"Pool", &make_pool}, - mr_factory{"Arena", &make_arena}, - mr_factory{"Binning", &make_binning}), - [](auto const& info) { return info.param.name; }); - -template -void spawn_n(std::size_t num_threads, Task task, Arguments&&... args) -{ - std::vector threads; - threads.reserve(num_threads); - for (std::size_t i = 0; i < num_threads; ++i) { - threads.emplace_back(std::thread(task, std::forward(args)...)); - } - - for (auto& thread : threads) { - thread.join(); - } -} - -template -void spawn(Task task, Arguments&&... args) -{ - spawn_n(4, task, std::forward(args)...); -} - -TEST(DefaultTest, UseCurrentDeviceResource_mt) { spawn(test_get_current_device_resource); } - -TEST(DefaultTest, CurrentDeviceResourceIsCUDA_mt) -{ - spawn([]() { - EXPECT_NE(nullptr, rmm::mr::get_current_device_resource()); - EXPECT_TRUE(rmm::mr::get_current_device_resource()->is_equal(rmm::mr::cuda_memory_resource{})); - }); -} - -TEST(DefaultTest, GetCurrentDeviceResource_mt) -{ - spawn([]() { - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource(); - EXPECT_NE(nullptr, mr); - EXPECT_TRUE(mr->is_equal(rmm::mr::cuda_memory_resource{})); - }); -} - -TEST_P(mr_test_mt, SetCurrentDeviceResource_mt) -{ - // single thread changes default resource, then multiple threads use it - - rmm::mr::device_memory_resource* old = rmm::mr::set_current_device_resource(this->mr.get()); - EXPECT_NE(nullptr, old); - - spawn([mr = this->mr.get()]() { - EXPECT_EQ(mr, rmm::mr::get_current_device_resource()); - test_get_current_device_resource(); // test allocating with the new default resource - }); - - // setting default resource w/ nullptr should reset to initial - rmm::mr::set_current_device_resource(nullptr); - EXPECT_TRUE(old->is_equal(*rmm::mr::get_current_device_resource())); -} - -TEST_P(mr_test_mt, SetCurrentDeviceResourcePerThread_mt) -{ - int num_devices{}; - RMM_CUDA_TRY(cudaGetDeviceCount(&num_devices)); - - std::vector threads; - threads.reserve(num_devices); - for (int i = 0; i < num_devices; ++i) { - threads.emplace_back(std::thread{[mr = this->mr.get()](auto dev_id) { - RMM_CUDA_TRY(cudaSetDevice(dev_id)); - rmm::mr::device_memory_resource* old = - rmm::mr::set_current_device_resource(mr); - EXPECT_NE(nullptr, old); - // initial resource for this device should be CUDA mr - EXPECT_TRUE(old->is_equal(rmm::mr::cuda_memory_resource{})); - // get_current_device_resource should equal the resource we - // just set - EXPECT_EQ(mr, rmm::mr::get_current_device_resource()); - // Setting current dev resource to nullptr should reset to - // cuda MR and return the MR we previously set - old = rmm::mr::set_current_device_resource(nullptr); - EXPECT_NE(nullptr, old); - EXPECT_EQ(old, mr); - EXPECT_TRUE(rmm::mr::get_current_device_resource()->is_equal( - rmm::mr::cuda_memory_resource{})); - }, - i}); - } - - for (auto& thread : threads) { - thread.join(); - } -} - -TEST_P(mr_test_mt, AllocateDefaultStream) -{ - spawn(test_various_allocations, this->mr.get(), rmm::cuda_stream_view{}); -} - -TEST_P(mr_test_mt, AllocateOnStream) -{ - spawn(test_various_allocations, this->mr.get(), this->stream.view()); -} - -TEST_P(mr_test_mt, RandomAllocationsDefaultStream) -{ - spawn(test_random_allocations, - this->mr.get(), - default_num_allocations, - default_max_size, - rmm::cuda_stream_view{}); -} - -TEST_P(mr_test_mt, RandomAllocationsStream) -{ - spawn(test_random_allocations, - this->mr.get(), - default_num_allocations, - default_max_size, - this->stream.view()); -} - -TEST_P(mr_test_mt, MixedRandomAllocationFreeDefaultStream) -{ - spawn( - test_mixed_random_allocation_free, this->mr.get(), default_max_size, rmm::cuda_stream_view{}); -} - -TEST_P(mr_test_mt, MixedRandomAllocationFreeStream) -{ - spawn(test_mixed_random_allocation_free, this->mr.get(), default_max_size, this->stream.view()); -} - -void allocate_loop(rmm::mr::device_memory_resource* mr, - std::size_t num_allocations, - std::list& allocations, - std::mutex& mtx, - std::condition_variable& allocations_ready, - cudaEvent_t& event, - rmm::cuda_stream_view stream) -{ - constexpr std::size_t max_size{1_MiB}; - - std::default_random_engine generator; - std::uniform_int_distribution size_distribution(1, max_size); - - for (std::size_t i = 0; i < num_allocations; ++i) { - std::size_t size = size_distribution(generator); - void* ptr = mr->allocate(size, stream); - { - std::lock_guard lock(mtx); - RMM_CUDA_TRY(cudaEventRecord(event, stream.value())); - allocations.emplace_back(ptr, size); - } - allocations_ready.notify_one(); - } - // Work around for threads going away before cudaEvent has finished async processing - cudaEventSynchronize(event); -} - -void deallocate_loop(rmm::mr::device_memory_resource* mr, - std::size_t num_allocations, - std::list& allocations, - std::mutex& mtx, - std::condition_variable& allocations_ready, - cudaEvent_t& event, - rmm::cuda_stream_view stream) -{ - for (std::size_t i = 0; i < num_allocations; i++) { - std::unique_lock lock(mtx); - allocations_ready.wait(lock, [&allocations] { return !allocations.empty(); }); - RMM_CUDA_TRY(cudaStreamWaitEvent(stream.value(), event)); - allocation alloc = allocations.front(); - allocations.pop_front(); - mr->deallocate(alloc.ptr, alloc.size, stream); - } - - // Work around for threads going away before cudaEvent has finished async processing - cudaEventSynchronize(event); -} -void test_allocate_free_different_threads(rmm::mr::device_memory_resource* mr, - rmm::cuda_stream_view streamA, - rmm::cuda_stream_view streamB) -{ - constexpr std::size_t num_allocations{100}; - - std::mutex mtx; - std::condition_variable allocations_ready; - std::list allocations; - cudaEvent_t event; - - RMM_CUDA_TRY(cudaEventCreate(&event)); - - std::thread producer(allocate_loop, - mr, - num_allocations, - std::ref(allocations), - std::ref(mtx), - std::ref(allocations_ready), - std::ref(event), - streamA); - - std::thread consumer(deallocate_loop, - mr, - num_allocations, - std::ref(allocations), - std::ref(mtx), - std::ref(allocations_ready), - std::ref(event), - streamB); - - producer.join(); - consumer.join(); - - RMM_CUDA_TRY(cudaEventDestroy(event)); -} - -TEST_P(mr_test_mt, AllocFreeDifferentThreadsDefaultStream) -{ - test_allocate_free_different_threads( - this->mr.get(), rmm::cuda_stream_default, rmm::cuda_stream_default); -} - -TEST_P(mr_test_mt, AllocFreeDifferentThreadsPerThreadDefaultStream) -{ - test_allocate_free_different_threads( - this->mr.get(), rmm::cuda_stream_per_thread, rmm::cuda_stream_per_thread); -} - -TEST_P(mr_test_mt, AllocFreeDifferentThreadsSameStream) -{ - test_allocate_free_different_threads(this->mr.get(), this->stream, this->stream); -} - -TEST_P(mr_test_mt, AllocFreeDifferentThreadsDifferentStream) -{ - rmm::cuda_stream streamB; - test_allocate_free_different_threads(this->mr.get(), this->stream, streamB); - streamB.synchronize(); -} - -} // namespace -} // namespace rmm::test diff --git a/tests/mr/device/mr_ref_multithreaded_tests.cpp b/tests/mr/device/mr_ref_multithreaded_tests.cpp index 48d642a32..352a9fa16 100644 --- a/tests/mr/device/mr_ref_multithreaded_tests.cpp +++ b/tests/mr/device/mr_ref_multithreaded_tests.cpp @@ -67,6 +67,76 @@ void spawn(Task task, Arguments&&... args) spawn_n(4, task, std::forward(args)...); } +TEST(DefaultTest, UseCurrentDeviceResource_mt) { spawn(test_get_current_device_resource); } + +TEST(DefaultTest, CurrentDeviceResourceIsCUDA_mt) +{ + spawn([]() { + EXPECT_NE(nullptr, rmm::mr::get_current_device_resource()); + EXPECT_TRUE(rmm::mr::get_current_device_resource()->is_equal(rmm::mr::cuda_memory_resource{})); + }); +} + +TEST(DefaultTest, GetCurrentDeviceResource_mt) +{ + spawn([]() { + rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource(); + EXPECT_NE(nullptr, mr); + EXPECT_TRUE(mr->is_equal(rmm::mr::cuda_memory_resource{})); + }); +} + +TEST_P(mr_ref_test_mt, SetCurrentDeviceResource_mt) +{ + // single thread changes default resource, then multiple threads use it + + rmm::mr::device_memory_resource* old = rmm::mr::set_current_device_resource(this->mr.get()); + EXPECT_NE(nullptr, old); + + spawn([mr = this->mr.get()]() { + EXPECT_EQ(mr, rmm::mr::get_current_device_resource()); + test_get_current_device_resource(); // test allocating with the new default resource + }); + + // setting default resource w/ nullptr should reset to initial + rmm::mr::set_current_device_resource(nullptr); + EXPECT_TRUE(old->is_equal(*rmm::mr::get_current_device_resource())); +} + +TEST_P(mr_ref_test_mt, SetCurrentDeviceResourcePerThread_mt) +{ + int num_devices{}; + RMM_CUDA_TRY(cudaGetDeviceCount(&num_devices)); + + std::vector threads; + threads.reserve(num_devices); + for (int i = 0; i < num_devices; ++i) { + threads.emplace_back(std::thread{[mr = this->mr.get()](auto dev_id) { + RMM_CUDA_TRY(cudaSetDevice(dev_id)); + rmm::mr::device_memory_resource* old = + rmm::mr::set_current_device_resource(mr); + EXPECT_NE(nullptr, old); + // initial resource for this device should be CUDA mr + EXPECT_TRUE(old->is_equal(rmm::mr::cuda_memory_resource{})); + // get_current_device_resource should equal the resource we + // just set + EXPECT_EQ(mr, rmm::mr::get_current_device_resource()); + // Setting current dev resource to nullptr should reset to + // cuda MR and return the MR we previously set + old = rmm::mr::set_current_device_resource(nullptr); + EXPECT_NE(nullptr, old); + EXPECT_EQ(old, mr); + EXPECT_TRUE(rmm::mr::get_current_device_resource()->is_equal( + rmm::mr::cuda_memory_resource{})); + }, + i}); + } + + for (auto& thread : threads) { + thread.join(); + } +} + TEST_P(mr_ref_test_mt, Allocate) { spawn(test_various_allocations, this->ref); } TEST_P(mr_ref_test_mt, AllocateDefaultStream) diff --git a/tests/mr/device/mr_ref_test.hpp b/tests/mr/device/mr_ref_test.hpp index f999e08f4..0beea8656 100644 --- a/tests/mr/device/mr_ref_test.hpp +++ b/tests/mr/device/mr_ref_test.hpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -62,6 +63,17 @@ struct allocation { }; // Various test functions, shared between single-threaded and multithreaded tests. + +inline void test_get_current_device_resource() +{ + EXPECT_NE(nullptr, rmm::mr::get_current_device_resource()); + void* ptr = rmm::mr::get_current_device_resource()->allocate(1_MiB); + EXPECT_NE(nullptr, ptr); + EXPECT_TRUE(is_properly_aligned(ptr)); + EXPECT_TRUE(is_device_accessible_memory(ptr)); + rmm::mr::get_current_device_resource()->deallocate(ptr, 1_MiB); +} + inline void test_allocate(resource_ref ref, std::size_t bytes) { try { @@ -357,6 +369,8 @@ struct mr_ref_allocation_test : public mr_ref_test {}; /// MR factory functions inline auto make_cuda() { return std::make_shared(); } +inline auto make_host_pinned() { return std::make_shared(); } + inline auto make_cuda_async() { if (rmm::detail::async_alloc::is_supported()) { @@ -373,6 +387,12 @@ inline auto make_pool() make_cuda(), rmm::percent_of_free_device_memory(50)); } +inline auto make_host_pinned_pool() +{ + return rmm::mr::make_owning_wrapper( + make_host_pinned(), 2_GiB, 8_GiB); +} + inline auto make_arena() { return rmm::mr::make_owning_wrapper(make_cuda()); diff --git a/tests/mr/device/mr_ref_tests.cpp b/tests/mr/device/mr_ref_tests.cpp index a9a94696a..c7c37d4cc 100644 --- a/tests/mr/device/mr_ref_tests.cpp +++ b/tests/mr/device/mr_ref_tests.cpp @@ -33,6 +33,7 @@ INSTANTIATE_TEST_SUITE_P(ResourceTests, #endif mr_factory{"Managed", &make_managed}, mr_factory{"Pool", &make_pool}, + mr_factory{"HostPinnedPool", &make_host_pinned_pool}, mr_factory{"Arena", &make_arena}, mr_factory{"Binning", &make_binning}, mr_factory{"Fixed_Size", &make_fixed_size}), @@ -47,9 +48,45 @@ INSTANTIATE_TEST_SUITE_P(ResourceAllocationTests, #endif mr_factory{"Managed", &make_managed}, mr_factory{"Pool", &make_pool}, + mr_factory{"HostPinnedPool", &make_host_pinned_pool}, mr_factory{"Arena", &make_arena}, mr_factory{"Binning", &make_binning}), [](auto const& info) { return info.param.name; }); + +TEST(DefaultTest, CurrentDeviceResourceIsCUDA) +{ + EXPECT_NE(nullptr, rmm::mr::get_current_device_resource()); + EXPECT_TRUE(rmm::mr::get_current_device_resource()->is_equal(rmm::mr::cuda_memory_resource{})); +} + +TEST(DefaultTest, UseCurrentDeviceResource) { test_get_current_device_resource(); } + +TEST(DefaultTest, GetCurrentDeviceResource) +{ + auto* mr = rmm::mr::get_current_device_resource(); + EXPECT_NE(nullptr, mr); + EXPECT_TRUE(mr->is_equal(rmm::mr::cuda_memory_resource{})); +} + +TEST_P(mr_ref_test, SetCurrentDeviceResource) +{ + rmm::mr::device_memory_resource* old{}; + old = rmm::mr::set_current_device_resource(this->mr.get()); + EXPECT_NE(nullptr, old); + + // old mr should equal a cuda mr + EXPECT_TRUE(old->is_equal(rmm::mr::cuda_memory_resource{})); + + // current dev resource should equal this resource + EXPECT_TRUE(this->mr->is_equal(*rmm::mr::get_current_device_resource())); + + test_get_current_device_resource(); + + // setting to `nullptr` should reset to initial cuda resource + rmm::mr::set_current_device_resource(nullptr); + EXPECT_TRUE(rmm::mr::get_current_device_resource()->is_equal(rmm::mr::cuda_memory_resource{})); +} + TEST_P(mr_ref_test, SelfEquality) { EXPECT_TRUE(this->ref == this->ref); } // Simple reproducer for https://github.com/rapidsai/rmm/issues/861 diff --git a/tests/mr/device/mr_test.hpp b/tests/mr/device/mr_test.hpp deleted file mode 100644 index 3808ec6f3..000000000 --- a/tests/mr/device/mr_test.hpp +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright (c) 2019-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. - */ - -#pragma once - -#include "../../byte_literals.hpp" -#include "test_utils.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -namespace rmm::test { - -enum size_in_bytes : size_t {}; - -constexpr auto default_num_allocations{100}; -constexpr size_in_bytes default_max_size{5_MiB}; - -struct allocation { - void* ptr{nullptr}; - std::size_t size{0}; - allocation(void* ptr, std::size_t size) : ptr{ptr}, size{size} {} - allocation() = default; -}; - -// Various test functions, shared between single-threaded and multithreaded tests. - -inline void test_get_current_device_resource() -{ - EXPECT_NE(nullptr, rmm::mr::get_current_device_resource()); - void* ptr = rmm::mr::get_current_device_resource()->allocate(1_MiB); - EXPECT_NE(nullptr, ptr); - EXPECT_TRUE(is_properly_aligned(ptr)); - EXPECT_TRUE(is_device_accessible_memory(ptr)); - rmm::mr::get_current_device_resource()->deallocate(ptr, 1_MiB); -} - -inline void test_allocate(rmm::mr::device_memory_resource* mr, - std::size_t bytes, - cuda_stream_view stream = {}) -{ - void* ptr = mr->allocate(bytes); - if (not stream.is_default()) { stream.synchronize(); } - EXPECT_NE(nullptr, ptr); - EXPECT_TRUE(is_properly_aligned(ptr)); - EXPECT_TRUE(is_device_accessible_memory(ptr)); - mr->deallocate(ptr, bytes); - if (not stream.is_default()) { stream.synchronize(); } -} - -// Simple reproducer for https://github.com/rapidsai/rmm/issues/861 -inline void concurrent_allocations_are_different(rmm::mr::device_memory_resource* mr, - cuda_stream_view stream) -{ - const auto size{8_B}; - void* ptr1 = mr->allocate(size, stream); - void* ptr2 = mr->allocate(size, stream); - - EXPECT_NE(ptr1, ptr2); - - mr->deallocate(ptr1, size, stream); - mr->deallocate(ptr2, size, stream); -} - -inline void test_various_allocations(rmm::mr::device_memory_resource* mr, cuda_stream_view stream) -{ - // test allocating zero bytes on non-default stream - { - void* ptr = mr->allocate(0, stream); - stream.synchronize(); - EXPECT_NO_THROW(mr->deallocate(ptr, 0, stream)); - stream.synchronize(); - } - - test_allocate(mr, 4_B, stream); - test_allocate(mr, 1_KiB, stream); - test_allocate(mr, 1_MiB, stream); - test_allocate(mr, 1_GiB, stream); - - // should fail to allocate too much - { - void* ptr{nullptr}; - EXPECT_THROW(ptr = mr->allocate(1_PiB, stream), rmm::out_of_memory); - EXPECT_EQ(nullptr, ptr); - - // test e.what(); - try { - ptr = mr->allocate(1_PiB, stream); - } catch (rmm::out_of_memory const& e) { - EXPECT_NE(std::string{e.what()}.find("out_of_memory"), std::string::npos); - } - } -} - -inline void test_random_allocations(rmm::mr::device_memory_resource* mr, - std::size_t num_allocations = default_num_allocations, - size_in_bytes max_size = default_max_size, - cuda_stream_view stream = {}) -{ - std::vector allocations(num_allocations); - - std::default_random_engine generator; - std::uniform_int_distribution distribution(1, max_size); - - // num_allocations allocations from [0,max_size) - std::for_each(allocations.begin(), - allocations.end(), - [&generator, &distribution, stream, mr](allocation& alloc) { - alloc.size = distribution(generator); - EXPECT_NO_THROW(alloc.ptr = mr->allocate(alloc.size, stream)); - if (not stream.is_default()) { stream.synchronize(); } - EXPECT_NE(nullptr, alloc.ptr); - EXPECT_TRUE(is_properly_aligned(alloc.ptr)); - }); - - std::for_each(allocations.begin(), allocations.end(), [stream, mr](allocation& alloc) { - EXPECT_NO_THROW(mr->deallocate(alloc.ptr, alloc.size, stream)); - if (not stream.is_default()) { stream.synchronize(); } - }); -} - -inline void test_mixed_random_allocation_free(rmm::mr::device_memory_resource* mr, - size_in_bytes max_size = default_max_size, - cuda_stream_view stream = {}) -{ - std::default_random_engine generator; - constexpr std::size_t num_allocations{100}; - - std::uniform_int_distribution size_distribution(1, max_size); - - constexpr int allocation_probability{53}; // percent - constexpr int max_probability{99}; - std::uniform_int_distribution op_distribution(0, max_probability); - std::uniform_int_distribution index_distribution(0, num_allocations - 1); - - std::size_t active_allocations{0}; - std::size_t allocation_count{0}; - - std::vector allocations; - - for (std::size_t i = 0; i < num_allocations * 2; ++i) { - bool do_alloc = true; - if (active_allocations > 0) { - int chance = op_distribution(generator); - do_alloc = (chance < allocation_probability) && (allocation_count < num_allocations); - } - - if (do_alloc) { - std::size_t size = size_distribution(generator); - active_allocations++; - allocation_count++; - EXPECT_NO_THROW(allocations.emplace_back(mr->allocate(size, stream), size)); - auto new_allocation = allocations.back(); - EXPECT_NE(nullptr, new_allocation.ptr); - EXPECT_TRUE(is_properly_aligned(new_allocation.ptr)); - } else { - auto const index = static_cast(index_distribution(generator) % active_allocations); - active_allocations--; - allocation to_free = allocations[index]; - allocations.erase(std::next(allocations.begin(), index)); - EXPECT_NO_THROW(mr->deallocate(to_free.ptr, to_free.size, stream)); - } - } - - EXPECT_EQ(active_allocations, 0); - EXPECT_EQ(allocations.size(), active_allocations); -} - -using MRFactoryFunc = std::function()>; - -/// Encapsulates a `device_memory_resource` factory function and associated name -struct mr_factory { - mr_factory(std::string name, MRFactoryFunc factory) - : name{std::move(name)}, factory{std::move(factory)} - { - } - - std::string name; ///< Name to associate with tests that use this factory - MRFactoryFunc factory; ///< Factory function that returns shared_ptr to `device_memory_resource` - ///< instance to use in test -}; - -/// Test fixture class value-parameterized on different `mr_factory`s -struct mr_test : public ::testing::TestWithParam { - void SetUp() override - { - auto factory = GetParam().factory; - mr = factory(); - if (mr == nullptr) { - GTEST_SKIP() << "Skipping tests since the memory resource is not supported with this CUDA " - << "driver/runtime version"; - } - } - - std::shared_ptr mr; ///< Pointer to resource to use in tests - rmm::cuda_stream stream{}; -}; - -struct mr_allocation_test : public mr_test {}; - -/// MR factory functions -inline auto make_cuda() { return std::make_shared(); } - -inline auto make_host_pinned() { return std::make_shared(); } - -inline auto make_cuda_async() -{ - if (rmm::detail::async_alloc::is_supported()) { - return std::make_shared(); - } - return std::shared_ptr{nullptr}; -} - -inline auto make_managed() { return std::make_shared(); } - -inline auto make_pool() -{ - return rmm::mr::make_owning_wrapper( - make_cuda(), rmm::percent_of_free_device_memory(50)); -} - -inline auto make_host_pinned_pool() -{ - return rmm::mr::make_owning_wrapper( - make_host_pinned(), 2_GiB, 8_GiB); -} - -inline auto make_arena() -{ - return rmm::mr::make_owning_wrapper(make_cuda()); -} - -inline auto make_fixed_size() -{ - return rmm::mr::make_owning_wrapper(make_cuda()); -} - -inline auto make_binning() -{ - auto pool = make_pool(); - // Add a binning_memory_resource with fixed-size bins of sizes 256, 512, 1024, 2048 and 4096KiB - // Larger allocations will use the pool resource - auto const bin_range_start{18}; - auto const bin_range_end{22}; - - auto mr = rmm::mr::make_owning_wrapper( - pool, bin_range_start, bin_range_end); - return mr; -} - -} // namespace rmm::test diff --git a/tests/mr/device/mr_tests.cpp b/tests/mr/device/mr_tests.cpp deleted file mode 100644 index 5e496d2ee..000000000 --- a/tests/mr/device/mr_tests.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2019-2021, 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. - */ - -#include "mr_test.hpp" - -#include - -#include - -namespace rmm::test { -namespace { - -INSTANTIATE_TEST_SUITE_P(ResourceTests, - mr_test, - ::testing::Values(mr_factory{"CUDA", &make_cuda}, -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT - mr_factory{"CUDA_Async", &make_cuda_async}, -#endif - mr_factory{"Managed", &make_managed}, - mr_factory{"Pool", &make_pool}, - mr_factory{"HostPinnedPool", &make_host_pinned_pool}, - mr_factory{"Arena", &make_arena}, - mr_factory{"Binning", &make_binning}, - mr_factory{"Fixed_Size", &make_fixed_size}), - [](auto const& info) { return info.param.name; }); - -// Leave out fixed-size MR here because it can't handle the dynamic allocation sizes -INSTANTIATE_TEST_SUITE_P(ResourceAllocationTests, - mr_allocation_test, - ::testing::Values(mr_factory{"CUDA", &make_cuda}, -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT - mr_factory{"CUDA_Async", &make_cuda_async}, -#endif - mr_factory{"Managed", &make_managed}, - mr_factory{"Pool", &make_pool}, - mr_factory{"HostPinnedPool", &make_host_pinned_pool}, - mr_factory{"Arena", &make_arena}, - mr_factory{"Binning", &make_binning}), - [](auto const& info) { return info.param.name; }); - -TEST(DefaultTest, CurrentDeviceResourceIsCUDA) -{ - EXPECT_NE(nullptr, rmm::mr::get_current_device_resource()); - EXPECT_TRUE(rmm::mr::get_current_device_resource()->is_equal(rmm::mr::cuda_memory_resource{})); -} - -TEST(DefaultTest, UseCurrentDeviceResource) { test_get_current_device_resource(); } - -TEST(DefaultTest, GetCurrentDeviceResource) -{ - auto* mr = rmm::mr::get_current_device_resource(); - EXPECT_NE(nullptr, mr); - EXPECT_TRUE(mr->is_equal(rmm::mr::cuda_memory_resource{})); -} - -TEST_P(mr_test, SetCurrentDeviceResource) -{ - rmm::mr::device_memory_resource* old{}; - old = rmm::mr::set_current_device_resource(this->mr.get()); - EXPECT_NE(nullptr, old); - - // old mr should equal a cuda mr - EXPECT_TRUE(old->is_equal(rmm::mr::cuda_memory_resource{})); - - // current dev resource should equal this resource - EXPECT_TRUE(this->mr->is_equal(*rmm::mr::get_current_device_resource())); - - test_get_current_device_resource(); - - // setting to `nullptr` should reset to initial cuda resource - rmm::mr::set_current_device_resource(nullptr); - EXPECT_TRUE(rmm::mr::get_current_device_resource()->is_equal(rmm::mr::cuda_memory_resource{})); -} - -TEST_P(mr_test, SelfEquality) { EXPECT_TRUE(this->mr->is_equal(*this->mr)); } - -// Simple reproducer for https://github.com/rapidsai/rmm/issues/861 -TEST_P(mr_test, AllocationsAreDifferentDefaultStream) -{ - concurrent_allocations_are_different(this->mr.get(), cuda_stream_view{}); -} - -TEST_P(mr_test, AllocationsAreDifferent) -{ - concurrent_allocations_are_different(this->mr.get(), this->stream); -} - -TEST_P(mr_allocation_test, AllocateDefaultStream) -{ - test_various_allocations(this->mr.get(), cuda_stream_view{}); -} - -TEST_P(mr_allocation_test, AllocateOnStream) -{ - test_various_allocations(this->mr.get(), this->stream); -} - -TEST_P(mr_allocation_test, RandomAllocations) { test_random_allocations(this->mr.get()); } - -TEST_P(mr_allocation_test, RandomAllocationsStream) -{ - test_random_allocations(this->mr.get(), default_num_allocations, default_max_size, this->stream); -} - -TEST_P(mr_allocation_test, MixedRandomAllocationFree) -{ - test_mixed_random_allocation_free(this->mr.get(), default_max_size, cuda_stream_view{}); -} - -TEST_P(mr_allocation_test, MixedRandomAllocationFreeStream) -{ - test_mixed_random_allocation_free(this->mr.get(), default_max_size, this->stream); -} - -} // namespace -} // namespace rmm::test diff --git a/tests/mr/device/thrust_allocator_tests.cu b/tests/mr/device/thrust_allocator_tests.cu index 038f4b664..cabfe9661 100644 --- a/tests/mr/device/thrust_allocator_tests.cu +++ b/tests/mr/device/thrust_allocator_tests.cu @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "mr_test.hpp" +#include "mr_ref_test.hpp" #include #include @@ -32,7 +32,7 @@ template class rmm::mr::thrust_allocator; namespace rmm::test { namespace { -struct allocator_test : public mr_test {}; +struct allocator_test : public mr_ref_test {}; TEST_P(allocator_test, first) { diff --git a/tests/mr/host/mr_tests.cpp b/tests/mr/host/mr_tests.cpp deleted file mode 100644 index e0078c920..000000000 --- a/tests/mr/host/mr_tests.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright (c) 2019-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. - */ - -#include "../../byte_literals.hpp" - -#include -#include -#include -#include - -#include - -#include - -#include - -#include -#include -#include - -namespace rmm::test { -namespace { -inline bool is_aligned(void* ptr, std::size_t alignment = alignof(std::max_align_t)) -{ - return rmm::is_pointer_aligned(ptr, alignment); -} - -// Returns true if a pointer points to a device memory or managed memory allocation. -inline bool is_device_memory(void* ptr) -{ - cudaPointerAttributes attributes{}; - if (cudaSuccess != cudaPointerGetAttributes(&attributes, ptr)) { return false; } - return (attributes.type == cudaMemoryTypeDevice) or (attributes.type == cudaMemoryTypeManaged); -} - -/** - * @brief Returns if a pointer `p` points to pinned host memory. - */ -inline bool is_pinned_memory(void* ptr) -{ - cudaPointerAttributes attributes{}; - if (cudaSuccess != cudaPointerGetAttributes(&attributes, ptr)) { return false; } - return attributes.type == cudaMemoryTypeHost; -} - -constexpr std::size_t size_word{4_B}; -constexpr std::size_t size_kb{1_KiB}; -constexpr std::size_t size_mb{1_MiB}; -constexpr std::size_t size_gb{1_GiB}; -constexpr std::size_t size_pb{1_PiB}; - -struct allocation { - void* ptr{nullptr}; - std::size_t size{0}; - allocation(void* ptr, std::size_t size) : ptr{ptr}, size{size} {} - allocation() = default; -}; -} // namespace - -template -struct MRTest : public ::testing::Test { - std::unique_ptr mr; - - MRTest() : mr{new MemoryResourceType} {} -}; - -using resources = ::testing::Types; -static_assert(cuda::mr::resource_with); -static_assert(cuda::mr::resource_with); - -TYPED_TEST_CASE(MRTest, resources); - -TYPED_TEST(MRTest, SelfEquality) { EXPECT_TRUE(this->mr->is_equal(*this->mr)); } - -TYPED_TEST(MRTest, AllocateZeroBytes) -{ - void* ptr{nullptr}; - EXPECT_NO_THROW(ptr = this->mr->allocate(0)); - EXPECT_NO_THROW(this->mr->deallocate(ptr, 0)); -} - -TYPED_TEST(MRTest, AllocateWord) -{ - void* ptr{nullptr}; - EXPECT_NO_THROW(ptr = this->mr->allocate(size_word)); - EXPECT_NE(nullptr, ptr); - EXPECT_TRUE(is_aligned(ptr)); - EXPECT_FALSE(is_device_memory(ptr)); - EXPECT_NO_THROW(this->mr->deallocate(ptr, size_word)); -} - -TYPED_TEST(MRTest, AllocateKB) -{ - void* ptr{nullptr}; - EXPECT_NO_THROW(ptr = this->mr->allocate(size_kb)); - EXPECT_NE(nullptr, ptr); - EXPECT_TRUE(is_aligned(ptr)); - EXPECT_FALSE(is_device_memory(ptr)); - EXPECT_NO_THROW(this->mr->deallocate(ptr, size_kb)); -} - -TYPED_TEST(MRTest, AllocateMB) -{ - void* ptr{nullptr}; - EXPECT_NO_THROW(ptr = this->mr->allocate(size_mb)); - EXPECT_NE(nullptr, ptr); - EXPECT_TRUE(is_aligned(ptr)); - EXPECT_FALSE(is_device_memory(ptr)); - EXPECT_NO_THROW(this->mr->deallocate(ptr, size_mb)); -} - -TYPED_TEST(MRTest, AllocateGB) -{ - void* ptr{nullptr}; - EXPECT_NO_THROW(ptr = this->mr->allocate(size_gb)); - EXPECT_NE(nullptr, ptr); - EXPECT_TRUE(is_aligned(ptr)); - EXPECT_FALSE(is_device_memory(ptr)); - EXPECT_NO_THROW(this->mr->deallocate(ptr, size_gb)); -} - -TYPED_TEST(MRTest, AllocateTooMuch) -{ - void* ptr{nullptr}; - EXPECT_THROW(ptr = this->mr->allocate(size_pb), std::bad_alloc); - EXPECT_EQ(nullptr, ptr); -} - -TYPED_TEST(MRTest, RandomAllocations) -{ - constexpr std::size_t num_allocations{100}; - std::vector allocations(num_allocations); - - constexpr std::size_t MAX_ALLOCATION_SIZE{5 * size_mb}; - - std::default_random_engine generator; - std::uniform_int_distribution distribution(1, MAX_ALLOCATION_SIZE); - - // 100 allocations from [0,5MB) - std::for_each( - allocations.begin(), allocations.end(), [&generator, &distribution, this](allocation& alloc) { - alloc.size = distribution(generator); - EXPECT_NO_THROW(alloc.ptr = this->mr->allocate(alloc.size)); - EXPECT_NE(nullptr, alloc.ptr); - EXPECT_TRUE(is_aligned(alloc.ptr)); - }); - - std::for_each(allocations.begin(), allocations.end(), [this](allocation& alloc) { - EXPECT_NO_THROW(this->mr->deallocate(alloc.ptr, alloc.size)); - }); -} - -TYPED_TEST(MRTest, MixedRandomAllocationFree) -{ - std::default_random_engine generator; - - constexpr std::size_t MAX_ALLOCATION_SIZE{10 * size_mb}; - std::uniform_int_distribution size_distribution(1, MAX_ALLOCATION_SIZE); - - // How often a free will occur. For example, if `1`, then every allocation - // will immediately be free'd. Or, if 4, on average, a free will occur after - // every 4th allocation - constexpr std::size_t FREE_FREQUENCY{4}; - std::uniform_int_distribution free_distribution(1, FREE_FREQUENCY); - - std::deque allocations; - - constexpr std::size_t num_allocations{100}; - for (std::size_t i = 0; i < num_allocations; ++i) { - std::size_t allocation_size = size_distribution(generator); - EXPECT_NO_THROW(allocations.emplace_back(this->mr->allocate(allocation_size), allocation_size)); - auto new_allocation = allocations.back(); - EXPECT_NE(nullptr, new_allocation.ptr); - EXPECT_TRUE(is_aligned(new_allocation.ptr)); - - bool const free_front{free_distribution(generator) == free_distribution.max()}; - - if (free_front) { - auto front = allocations.front(); - EXPECT_NO_THROW(this->mr->deallocate(front.ptr, front.size)); - allocations.pop_front(); - } - } - // free any remaining allocations - for (auto alloc : allocations) { - EXPECT_NO_THROW(this->mr->deallocate(alloc.ptr, alloc.size)); - allocations.pop_front(); - } -} - -static constexpr std::size_t MinTestedAlignment{16}; -static constexpr std::size_t MaxTestedAlignment{4096}; -static constexpr std::size_t TestedAlignmentMultiplier{2}; -static constexpr std::size_t NUM_TRIALS{100}; - -TYPED_TEST(MRTest, AlignmentTest) -{ - std::default_random_engine generator(0); - constexpr std::size_t MAX_ALLOCATION_SIZE{10 * size_mb}; - std::uniform_int_distribution size_distribution(1, MAX_ALLOCATION_SIZE); - - for (std::size_t num_trials = 0; num_trials < NUM_TRIALS; ++num_trials) { - for (std::size_t alignment = MinTestedAlignment; alignment <= MaxTestedAlignment; - alignment *= TestedAlignmentMultiplier) { - auto allocation_size = size_distribution(generator); - void* ptr{nullptr}; - EXPECT_NO_THROW(ptr = this->mr->allocate(allocation_size, alignment)); - EXPECT_TRUE(is_aligned(ptr, alignment)); - EXPECT_NO_THROW(this->mr->deallocate(ptr, allocation_size, alignment)); - } - } -} - -TYPED_TEST(MRTest, UnsupportedAlignmentTest) -{ - std::default_random_engine generator(0); - constexpr std::size_t MAX_ALLOCATION_SIZE{10 * size_mb}; - std::uniform_int_distribution size_distribution(1, MAX_ALLOCATION_SIZE); - - for (std::size_t num_trials = 0; num_trials < NUM_TRIALS; ++num_trials) { - for (std::size_t alignment = MinTestedAlignment; alignment <= MaxTestedAlignment; - alignment *= TestedAlignmentMultiplier) { - auto allocation_size = size_distribution(generator); - void* ptr{nullptr}; - // An unsupported alignment (like an odd number) should result in an - // alignment of `alignof(std::max_align_t)` - auto const bad_alignment = alignment + 1; - EXPECT_NO_THROW(ptr = this->mr->allocate(allocation_size, bad_alignment)); - EXPECT_TRUE(is_aligned(ptr, alignof(std::max_align_t))); - EXPECT_NO_THROW(this->mr->deallocate(ptr, allocation_size, bad_alignment)); - } - } -} - -TEST(PinnedResource, isPinned) -{ - rmm::mr::pinned_memory_resource mr; - void* ptr{nullptr}; - EXPECT_NO_THROW(ptr = mr.allocate(100)); - EXPECT_TRUE(is_pinned_memory(ptr)); - EXPECT_NO_THROW(mr.deallocate(ptr, 100)); -} -} // namespace rmm::test From 76bd29d1e5e096e33752980c76a60c206b46843b Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 20 Feb 2024 12:16:34 -0600 Subject: [PATCH 360/675] target branch-24.04 for GitHub Actions workflows (#1468) Follow-up to #1419 For all GitHub Actions configs, replaces uses of the `test-cuda-12.2` branch on `shared-workflows` with `branch-24.04`, now that https://github.com/rapidsai/shared-workflows/pull/166 has been merged. ### Notes for Reviewers This is part of ongoing work to build and test packages against CUDA 12.2 across all of RAPIDS. For more details see: * https://github.com/rapidsai/build-planning/issues/7 *(created with `rapids-reviser`)* Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1468 --- .github/workflows/build.yaml | 12 ++++++------ .github/workflows/pr.yaml | 20 ++++++++++---------- .github/workflows/test.yaml | 6 +++--- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1de34cbfd..e4113d5c5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -78,7 +78,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 56257eee6..da32eb12b 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -22,40 +22,40 @@ jobs: - wheel-tests - devcontainer secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.04 checks: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.04 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.04 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.04 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.04 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.04 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.04 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -65,20 +65,20 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.04 with: build_type: pull-request script: ci/build_wheel.sh wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.04 with: build_type: pull-request script: ci/test_wheel.sh devcontainer: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.04 with: build_command: | sccache -z; diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0f4ac8cad..0e7938310 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.04 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.04 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@test-cuda-12.2 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.04 with: build_type: nightly branch: ${{ inputs.branch }} From 9997ecc175f0fb9ddbbfa7a47bf7af4bd50c81a0 Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Wed, 21 Feb 2024 09:06:38 -0600 Subject: [PATCH 361/675] updating ops-bot.yaml (#1458) --- .github/ops-bot.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ops-bot.yaml b/.github/ops-bot.yaml index 9a0b41550..2ed5231ae 100644 --- a/.github/ops-bot.yaml +++ b/.github/ops-bot.yaml @@ -6,3 +6,4 @@ branch_checker: true label_checker: true release_drafter: true recently_updated: true +forward_merger: true From 51f04390791fc9d47b3155919edaecada36a2087 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:33:08 +1100 Subject: [PATCH 362/675] Automate include grouping using clang-format (#1463) This uses the IncludeCategories settings in .clang-format to attempt to enforce our documented #include order in librmm. For discussion, see https://github.com/rapidsai/cudf/pull/15063. This PR uses a subset of the header grouping categories used in that PR. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Michael Schellenberger Costa (https://github.com/miscco) - Lawrence Mitchell (https://github.com/wence-) - Rong Ou (https://github.com/rongou) URL: https://github.com/rapidsai/rmm/pull/1463 --- .clang-format | 16 ++++++++++++++-- .../device_uvector/device_uvector_bench.cu | 5 ++--- .../multi_stream_allocations_bench.cu | 3 +-- .../random_allocations/random_allocations.cpp | 3 +-- benchmarks/replay/replay.cpp | 8 +++----- benchmarks/synchronization/synchronization.hpp | 3 ++- benchmarks/utilities/log_parser.hpp | 6 +++--- include/rmm/cuda_stream.hpp | 2 +- include/rmm/cuda_stream_view.hpp | 3 +-- include/rmm/detail/logging_assert.hpp | 3 ++- include/rmm/device_buffer.hpp | 3 +-- include/rmm/device_uvector.hpp | 4 ++-- include/rmm/device_vector.hpp | 2 +- include/rmm/exec_policy.hpp | 2 +- .../rmm/mr/device/cuda_async_memory_resource.hpp | 5 ++--- .../device/cuda_async_view_memory_resource.hpp | 5 ++--- include/rmm/mr/device/cuda_memory_resource.hpp | 3 +-- .../rmm/mr/device/fixed_size_memory_resource.hpp | 5 ++--- .../rmm/mr/device/managed_memory_resource.hpp | 3 +-- include/rmm/mr/device/pool_memory_resource.hpp | 5 ++--- .../rmm/mr/device/thrust_allocator_adaptor.hpp | 5 ++--- include/rmm/mr/host/new_delete_resource.hpp | 3 +-- include/rmm/mr/pinned_host_memory_resource.hpp | 1 - include/rmm/thrust_rmm_allocator.h | 2 +- python/rmm/_lib/_torch_allocator.cpp | 4 ++-- tests/cuda_stream_pool_tests.cpp | 4 ++-- tests/cuda_stream_tests.cpp | 3 ++- tests/device_scalar_tests.cpp | 5 ++--- tests/logger_tests.cpp | 2 +- tests/mr/device/arena_mr_tests.cpp | 3 +-- tests/mr/device/callback_mr_tests.cpp | 6 +++--- tests/mr/device/mr_ref_multithreaded_tests.cpp | 4 ++-- tests/mr/device/mr_ref_test.hpp | 4 ++-- tests/mr/device/polymorphic_allocator_tests.cpp | 7 ++++--- tests/mr/device/thrust_allocator_tests.cu | 4 ++-- tests/mr/device/tracking_mr_tests.cpp | 1 - tests/mr/host/mr_ref_tests.cpp | 3 +-- 37 files changed, 73 insertions(+), 77 deletions(-) diff --git a/.clang-format b/.clang-format index 26b9a5bf4..35ebdbfae 100644 --- a/.clang-format +++ b/.clang-format @@ -71,8 +71,20 @@ ForEachMacros: - foreach - Q_FOREACH - BOOST_FOREACH -IncludeBlocks: Preserve -IncludeIsMainRegex: '([-_](test|unittest))?$' +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^"' # quoted includes + Priority: 1 + - Regex: '^ #include -#include - #include - #include #include +#include + #include #include diff --git a/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu b/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu index 4943e507f..d38e89a3b 100644 --- a/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu +++ b/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include #include #include @@ -31,6 +29,7 @@ #include #include +#include #include diff --git a/benchmarks/random_allocations/random_allocations.cpp b/benchmarks/random_allocations/random_allocations.cpp index 2856cd323..57116743b 100644 --- a/benchmarks/random_allocations/random_allocations.cpp +++ b/benchmarks/random_allocations/random_allocations.cpp @@ -14,8 +14,6 @@ * limitations under the License. */ -#include - #include #include #include @@ -26,6 +24,7 @@ #include #include +#include #include #include diff --git a/benchmarks/replay/replay.cpp b/benchmarks/replay/replay.cpp index 253708ace..5afed036a 100644 --- a/benchmarks/replay/replay.cpp +++ b/benchmarks/replay/replay.cpp @@ -14,10 +14,6 @@ * limitations under the License. */ -#include -#include -#include - #include #include #include @@ -33,7 +29,9 @@ #include #include - +#include +#include +#include #include #include diff --git a/benchmarks/synchronization/synchronization.hpp b/benchmarks/synchronization/synchronization.hpp index 1f26beb37..596b3684b 100644 --- a/benchmarks/synchronization/synchronization.hpp +++ b/benchmarks/synchronization/synchronization.hpp @@ -61,9 +61,10 @@ #include // Google Benchmark library -#include #include +#include + class cuda_event_timer { public: /** diff --git a/benchmarks/utilities/log_parser.hpp b/benchmarks/utilities/log_parser.hpp index bc1aee47c..2283ace93 100644 --- a/benchmarks/utilities/log_parser.hpp +++ b/benchmarks/utilities/log_parser.hpp @@ -16,12 +16,12 @@ #pragma once -#include +#include "rapidcsv.h" + #include #include -#include "rapidcsv.h" - +#include #include #include #include diff --git a/include/rmm/cuda_stream.hpp b/include/rmm/cuda_stream.hpp index cb5654ac3..197095c39 100644 --- a/include/rmm/cuda_stream.hpp +++ b/include/rmm/cuda_stream.hpp @@ -16,13 +16,13 @@ #pragma once -#include #include #include #include #include +#include #include namespace rmm { diff --git a/include/rmm/cuda_stream_view.hpp b/include/rmm/cuda_stream_view.hpp index f8564b16b..a34897df6 100644 --- a/include/rmm/cuda_stream_view.hpp +++ b/include/rmm/cuda_stream_view.hpp @@ -18,9 +18,8 @@ #include -#include - #include +#include #include #include diff --git a/include/rmm/detail/logging_assert.hpp b/include/rmm/detail/logging_assert.hpp index 321bddab8..7eb667211 100644 --- a/include/rmm/detail/logging_assert.hpp +++ b/include/rmm/detail/logging_assert.hpp @@ -20,9 +20,10 @@ // logger can be extremely expensive to compile, so we want to avoid including // it. #if !defined(NDEBUG) -#include #include #include + +#include #endif /** diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index 167d07c4b..4663b5733 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -28,8 +29,6 @@ #include #include -#include - namespace rmm { /** * @addtogroup data_containers diff --git a/include/rmm/device_uvector.hpp b/include/rmm/device_uvector.hpp index 0750ef796..ff6a7d837 100644 --- a/include/rmm/device_uvector.hpp +++ b/include/rmm/device_uvector.hpp @@ -23,11 +23,11 @@ #include #include +#include + #include #include -#include - namespace rmm { /** * @addtogroup data_containers diff --git a/include/rmm/device_vector.hpp b/include/rmm/device_vector.hpp index 7caf5845b..64fd8b993 100644 --- a/include/rmm/device_vector.hpp +++ b/include/rmm/device_vector.hpp @@ -16,9 +16,9 @@ #pragma once +#include #include -#include #include namespace rmm { diff --git a/include/rmm/exec_policy.hpp b/include/rmm/exec_policy.hpp index 5acd062e3..a343afb8b 100644 --- a/include/rmm/exec_policy.hpp +++ b/include/rmm/exec_policy.hpp @@ -22,10 +22,10 @@ #pragma once #include +#include #include #include -#include #include #include diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 69e23624d..1bd761eb2 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -19,13 +19,12 @@ #include #include #include +#include #include #include -#include -#include - #include +#include #include #include diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index 6c24cccc3..c07730f70 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -19,12 +19,11 @@ #include #include #include -#include - #include -#include +#include #include +#include #include #include diff --git a/include/rmm/mr/device/cuda_memory_resource.hpp b/include/rmm/mr/device/cuda_memory_resource.hpp index 0652d6360..16100b06a 100644 --- a/include/rmm/mr/device/cuda_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_memory_resource.hpp @@ -15,10 +15,9 @@ */ #pragma once -#include - #include #include +#include #include diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index 296ef103c..d34ad8d7e 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -19,15 +19,14 @@ #include #include #include +#include #include #include -#include +#include #include #include -#include - #include #include #include diff --git a/include/rmm/mr/device/managed_memory_resource.hpp b/include/rmm/mr/device/managed_memory_resource.hpp index 708adad8e..ea43315de 100644 --- a/include/rmm/mr/device/managed_memory_resource.hpp +++ b/include/rmm/mr/device/managed_memory_resource.hpp @@ -15,10 +15,9 @@ */ #pragma once -#include - #include #include +#include #include diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 5f70e73d1..4f2d46a7c 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -19,20 +19,19 @@ #include #include #include +#include #include #include #include #include -#include +#include #include #include #include #include -#include - #include #include #include diff --git a/include/rmm/mr/device/thrust_allocator_adaptor.hpp b/include/rmm/mr/device/thrust_allocator_adaptor.hpp index ece495c37..f2b1a6027 100644 --- a/include/rmm/mr/device/thrust_allocator_adaptor.hpp +++ b/include/rmm/mr/device/thrust_allocator_adaptor.hpp @@ -16,16 +16,15 @@ #pragma once +#include #include #include -#include +#include #include #include #include -#include - namespace rmm::mr { /** * @addtogroup device_resource_adaptors diff --git a/include/rmm/mr/host/new_delete_resource.hpp b/include/rmm/mr/host/new_delete_resource.hpp index ccb294d21..a48f61447 100644 --- a/include/rmm/mr/host/new_delete_resource.hpp +++ b/include/rmm/mr/host/new_delete_resource.hpp @@ -15,10 +15,9 @@ */ #pragma once -#include - #include #include +#include #include #include diff --git a/include/rmm/mr/pinned_host_memory_resource.hpp b/include/rmm/mr/pinned_host_memory_resource.hpp index e92b2985e..ee409dbac 100644 --- a/include/rmm/mr/pinned_host_memory_resource.hpp +++ b/include/rmm/mr/pinned_host_memory_resource.hpp @@ -21,7 +21,6 @@ #include #include - #include #include diff --git a/include/rmm/thrust_rmm_allocator.h b/include/rmm/thrust_rmm_allocator.h index 0b78d5497..ad71e107a 100644 --- a/include/rmm/thrust_rmm_allocator.h +++ b/include/rmm/thrust_rmm_allocator.h @@ -17,10 +17,10 @@ #pragma once #include +#include #include #include -#include #include namespace rmm { diff --git a/python/rmm/_lib/_torch_allocator.cpp b/python/rmm/_lib/_torch_allocator.cpp index 5e5b2dcb4..dc92e4639 100644 --- a/python/rmm/_lib/_torch_allocator.cpp +++ b/python/rmm/_lib/_torch_allocator.cpp @@ -14,12 +14,12 @@ * limitations under the License. */ -#include - #include #include #include +#include + // These signatures must match those required by CUDAPluggableAllocator in // github.com/pytorch/pytorch/blob/main/torch/csrc/cuda/CUDAPluggableAllocator.h // Since the loading is done at runtime via dlopen, no error checking diff --git a/tests/cuda_stream_pool_tests.cpp b/tests/cuda_stream_pool_tests.cpp index de17f8c3c..ad1d421d7 100644 --- a/tests/cuda_stream_pool_tests.cpp +++ b/tests/cuda_stream_pool_tests.cpp @@ -18,10 +18,10 @@ #include #include -#include - #include +#include + struct CudaStreamPoolTest : public ::testing::Test { rmm::cuda_stream_pool pool{}; }; diff --git a/tests/cuda_stream_tests.cpp b/tests/cuda_stream_tests.cpp index 465e5d4c5..1cc068434 100644 --- a/tests/cuda_stream_tests.cpp +++ b/tests/cuda_stream_tests.cpp @@ -17,13 +17,14 @@ #include #include #include -#include #include #include #include +#include + struct CudaStreamTest : public ::testing::Test {}; TEST_F(CudaStreamTest, Equality) diff --git a/tests/device_scalar_tests.cpp b/tests/device_scalar_tests.cpp index 5a7825533..6f80a5de1 100644 --- a/tests/device_scalar_tests.cpp +++ b/tests/device_scalar_tests.cpp @@ -14,17 +14,16 @@ * limitations under the License. */ -#include - #include #include #include #include #include +#include #include -#include +#include #include #include diff --git a/tests/logger_tests.cpp b/tests/logger_tests.cpp index f6531bc59..5e3b2f899 100644 --- a/tests/logger_tests.cpp +++ b/tests/logger_tests.cpp @@ -15,11 +15,11 @@ */ #include "./byte_literals.hpp" -#include #include #include +#include #include #include diff --git a/tests/mr/device/arena_mr_tests.cpp b/tests/mr/device/arena_mr_tests.cpp index c8c60f7fb..1eb38888e 100644 --- a/tests/mr/device/arena_mr_tests.cpp +++ b/tests/mr/device/arena_mr_tests.cpp @@ -26,10 +26,9 @@ #include #include - -#include #include +#include #include #include diff --git a/tests/mr/device/callback_mr_tests.cpp b/tests/mr/device/callback_mr_tests.cpp index 95dac93ec..34a2cc8cc 100644 --- a/tests/mr/device/callback_mr_tests.cpp +++ b/tests/mr/device/callback_mr_tests.cpp @@ -16,19 +16,19 @@ #include "../../byte_literals.hpp" #include "../../mock_resource.hpp" + #include #include #include #include #include -#include - #include - #include #include +#include + namespace rmm::test { namespace { diff --git a/tests/mr/device/mr_ref_multithreaded_tests.cpp b/tests/mr/device/mr_ref_multithreaded_tests.cpp index 352a9fa16..d0d11ccbe 100644 --- a/tests/mr/device/mr_ref_multithreaded_tests.cpp +++ b/tests/mr/device/mr_ref_multithreaded_tests.cpp @@ -16,8 +16,6 @@ #include "mr_ref_test.hpp" -#include - #include #include #include @@ -27,6 +25,8 @@ #include +#include + #include #include diff --git a/tests/mr/device/mr_ref_test.hpp b/tests/mr/device/mr_ref_test.hpp index 0beea8656..a8a6226f1 100644 --- a/tests/mr/device/mr_ref_test.hpp +++ b/tests/mr/device/mr_ref_test.hpp @@ -36,10 +36,10 @@ #include #include -#include - #include +#include + #include #include #include diff --git a/tests/mr/device/polymorphic_allocator_tests.cpp b/tests/mr/device/polymorphic_allocator_tests.cpp index 4c8346730..3b73d4a49 100644 --- a/tests/mr/device/polymorphic_allocator_tests.cpp +++ b/tests/mr/device/polymorphic_allocator_tests.cpp @@ -14,15 +14,16 @@ * limitations under the License. */ -#include - -#include #include #include #include #include #include +#include + +#include + namespace { struct allocator_test : public ::testing::Test { diff --git a/tests/mr/device/thrust_allocator_tests.cu b/tests/mr/device/thrust_allocator_tests.cu index cabfe9661..ed66c220c 100644 --- a/tests/mr/device/thrust_allocator_tests.cu +++ b/tests/mr/device/thrust_allocator_tests.cu @@ -22,10 +22,10 @@ #include #include -#include - #include +#include + // explicit instantiation for test coverage purposes template class rmm::mr::thrust_allocator; diff --git a/tests/mr/device/tracking_mr_tests.cpp b/tests/mr/device/tracking_mr_tests.cpp index 2af720d3f..65d2f955c 100644 --- a/tests/mr/device/tracking_mr_tests.cpp +++ b/tests/mr/device/tracking_mr_tests.cpp @@ -23,7 +23,6 @@ #include #include - #include namespace rmm::test { diff --git a/tests/mr/host/mr_ref_tests.cpp b/tests/mr/host/mr_ref_tests.cpp index 416641f18..49b5bf061 100644 --- a/tests/mr/host/mr_ref_tests.cpp +++ b/tests/mr/host/mr_ref_tests.cpp @@ -21,9 +21,8 @@ #include #include -#include - #include +#include #include From c408a3275b5e223f4b8deeab23393808a07c182e Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Mon, 26 Feb 2024 12:38:29 -0800 Subject: [PATCH 363/675] [FEA]: Use `std::optional` instead of `thrust::optional` (#1464) We already require c++17, so there is no benefit on pulling in `thrust::optional` as a dependency. In addition thrust versiones its types with the cuda architecture, so using those types in API boundaries is not recommended. This could be a potentially breaking change if a user would explicitly pass in `thrust::optional` into those APIs which seems unlikely Authors: - Michael Schellenberger Costa (https://github.com/miscco) - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1464 --- .../mr/device/cuda_async_memory_resource.hpp | 42 +++++- .../rmm/mr/device/pool_memory_resource.hpp | 142 ++++++++++++++++-- python/rmm/_lib/memory_resource.pyx | 20 +-- 3 files changed, 174 insertions(+), 30 deletions(-) diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 1bd761eb2..ac6b72076 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -23,11 +23,13 @@ #include #include +#include #include #include #include #include +#include #if CUDART_VERSION >= 11020 // 11.2 introduced cudaMallocAsync #ifndef RMM_DISABLE_CUDA_MALLOC_ASYNC @@ -84,9 +86,43 @@ class cuda_async_memory_resource final : public device_memory_resource { * `cudaMemHandleTypeNone` for no IPC support. */ // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) - cuda_async_memory_resource(thrust::optional initial_pool_size = {}, - thrust::optional release_threshold = {}, - thrust::optional export_handle_type = {}) + template , + thrust::optional>, + int> = 0> + [[deprecated("Use std::optional instead of thrust::optional.")]] // + explicit cuda_async_memory_resource( + Optional initial_pool_size, + Optional release_threshold = {}, + thrust::optional export_handle_type = {}) + : cuda_async_memory_resource(initial_pool_size.value_or(std::nullopt), + release_threshold.value_or(std::nullopt), + export_handle_type.value_or(std::nullopt)) + + { + } + + /** + * @brief Constructs a cuda_async_memory_resource with the optionally specified initial pool size + * and release threshold. + * + * If the pool size grows beyond the release threshold, unused memory held by the pool will be + * released at the next synchronization event. + * + * @throws rmm::logic_error if the CUDA version does not support `cudaMallocAsync` + * + * @param initial_pool_size Optional initial size in bytes of the pool. If no value is provided, + * initial pool size is half of the available GPU memory. + * @param release_threshold Optional release threshold size in bytes of the pool. If no value is + * provided, the release threshold is set to the total amount of memory on the current device. + * @param export_handle_type Optional `cudaMemAllocationHandleType` that allocations from this + * resource should support interprocess communication (IPC). Default is + * `cudaMemHandleTypeNone` for no IPC support. + */ + // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) + cuda_async_memory_resource(std::optional initial_pool_size = {}, + std::optional release_threshold = {}, + std::optional export_handle_type = {}) { #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT // Check if cudaMallocAsync Memory pool supported diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 4f2d46a7c..cbd499021 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -38,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -108,6 +110,37 @@ class pool_memory_resource final friend class detail::stream_ordered_memory_resource, detail::coalescing_free_list>; + /** + * @brief Construct a `pool_memory_resource` and allocate the initial device memory + * pool using `upstream_mr`. + * + * @deprecated Use the constructor that takes an explicit initial pool size instead. + * + * @throws rmm::logic_error if `upstream_mr == nullptr` + * @throws rmm::logic_error if `initial_pool_size` is neither the default nor aligned to a + * multiple of pool_memory_resource::allocation_alignment bytes. + * @throws rmm::logic_error if `maximum_pool_size` is neither the default nor aligned to a + * multiple of pool_memory_resource::allocation_alignment bytes. + * + * @param upstream_mr The memory_resource from which to allocate blocks for the pool. + * @param initial_pool_size Minimum size, in bytes, of the initial pool. Defaults to zero. + * @param maximum_pool_size Maximum size, in bytes, that the pool can grow to. Defaults to all + * of the available memory from the upstream resource. + */ + template , + thrust::optional>, + int> = 0> + [[deprecated( + "Must specify initial_pool_size and use std::optional instead of thrust::optional.")]] // + explicit pool_memory_resource(Upstream* upstream_mr, + Optional initial_pool_size, + Optional maximum_pool_size = thrust::nullopt) + : pool_memory_resource( + upstream_mr, initial_pool_size.value_or(0), maximum_pool_size.value_or(std::nullopt)) + { + } + /** * @brief Construct a `pool_memory_resource` and allocate the initial device memory * pool using `upstream_mr`. @@ -127,12 +160,43 @@ class pool_memory_resource final */ [[deprecated("Must specify initial_pool_size")]] // explicit pool_memory_resource(Upstream* upstream_mr, - thrust::optional initial_pool_size = thrust::nullopt, - thrust::optional maximum_pool_size = thrust::nullopt) + std::optional initial_pool_size = std::nullopt, + std::optional maximum_pool_size = std::nullopt) : pool_memory_resource(upstream_mr, initial_pool_size.value_or(0), maximum_pool_size) { } + /** + * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using + * `upstream_mr`. + * + * @deprecated Use the constructor that takes an explicit initial pool size instead. + * + * @throws rmm::logic_error if `upstream_mr == nullptr` + * @throws rmm::logic_error if `initial_pool_size` is neither the default nor aligned to a + * multiple of pool_memory_resource::allocation_alignment bytes. + * @throws rmm::logic_error if `maximum_pool_size` is neither the default nor aligned to a + * multiple of pool_memory_resource::allocation_alignment bytes. + * + * @param upstream_mr The memory_resource from which to allocate blocks for the pool. + * @param initial_pool_size Minimum size, in bytes, of the initial pool. Defaults to zero. + * @param maximum_pool_size Maximum size, in bytes, that the pool can grow to. Defaults to all + * of the available memory from the upstream resource. + */ + template , + thrust::optional>, + int> = 0> + [[deprecated( + "Must specify initial_pool_size and use std::optional instead of thrust::optional.")]] // + explicit pool_memory_resource(Upstream& upstream_mr, + Optional initial_pool_size, + Optional maximum_pool_size = thrust::nullopt) + : pool_memory_resource( + upstream_mr, initial_pool_size.value_or(0), maximum_pool_size.value_or(std::nullopt)) + { + } + /** * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using * `upstream_mr`. @@ -154,12 +218,39 @@ class pool_memory_resource final cuda::std::enable_if_t, int> = 0> [[deprecated("Must specify initial_pool_size")]] // explicit pool_memory_resource(Upstream2& upstream_mr, - thrust::optional initial_pool_size = thrust::nullopt, - thrust::optional maximum_pool_size = thrust::nullopt) + std::optional initial_pool_size = std::nullopt, + std::optional maximum_pool_size = std::nullopt) : pool_memory_resource(upstream_mr, initial_pool_size.value_or(0), maximum_pool_size) { } + /** + * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using + * `upstream_mr`. + * + * @throws rmm::logic_error if `upstream_mr == nullptr` + * @throws rmm::logic_error if `initial_pool_size` is not aligned to a multiple of + * pool_memory_resource::allocation_alignment bytes. + * @throws rmm::logic_error if `maximum_pool_size` is neither the default nor aligned to a + * multiple of pool_memory_resource::allocation_alignment bytes. + * + * @param upstream_mr The memory_resource from which to allocate blocks for the pool. + * @param initial_pool_size Minimum size, in bytes, of the initial pool. + * @param maximum_pool_size Maximum size, in bytes, that the pool can grow to. Defaults to all + * of the available from the upstream resource. + */ + template , + thrust::optional>, + int> = 0> + [[deprecated("Use std::optional instead of thrust::optional.")]] // + explicit pool_memory_resource(Upstream* upstream_mr, + std::size_t initial_pool_size, + Optional maximum_pool_size) + : pool_memory_resource(upstream_mr, initial_pool_size, maximum_pool_size.value_or(std::nullopt)) + { + } + /** * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using * `upstream_mr`. @@ -177,7 +268,7 @@ class pool_memory_resource final */ explicit pool_memory_resource(Upstream* upstream_mr, std::size_t initial_pool_size, - thrust::optional maximum_pool_size = thrust::nullopt) + std::optional maximum_pool_size = std::nullopt) : upstream_mr_{[upstream_mr]() { RMM_EXPECTS(nullptr != upstream_mr, "Unexpected null upstream pointer."); return upstream_mr; @@ -191,6 +282,35 @@ class pool_memory_resource final initialize_pool(initial_pool_size, maximum_pool_size); } + /** + * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using + * `upstream_mr`. + * + * @throws rmm::logic_error if `upstream_mr == nullptr` + * @throws rmm::logic_error if `initial_pool_size` is not aligned to a multiple of + * pool_memory_resource::allocation_alignment bytes. + * @throws rmm::logic_error if `maximum_pool_size` is neither the default nor aligned to a + * multiple of pool_memory_resource::allocation_alignment bytes. + * + * @param upstream_mr The memory_resource from which to allocate blocks for the pool. + * @param initial_pool_size Minimum size, in bytes, of the initial pool. + * @param maximum_pool_size Maximum size, in bytes, that the pool can grow to. Defaults to all + * of the available memory from the upstream resource. + */ + template , + thrust::optional>, + int> = 0> + [[deprecated("Use std::optional instead of thrust::optional.")]] // + explicit pool_memory_resource(Upstream& upstream_mr, + std::size_t initial_pool_size, + Optional maximum_pool_size) + : pool_memory_resource(cuda::std::addressof(upstream_mr), + initial_pool_size, + maximum_pool_size.value_or(std::nullopt)) + { + } + /** * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using * `upstream_mr`. @@ -210,7 +330,7 @@ class pool_memory_resource final cuda::std::enable_if_t, int> = 0> explicit pool_memory_resource(Upstream2& upstream_mr, std::size_t initial_pool_size, - thrust::optional maximum_pool_size = thrust::nullopt) + std::optional maximum_pool_size = std::nullopt) : pool_memory_resource(cuda::std::addressof(upstream_mr), initial_pool_size, maximum_pool_size) { } @@ -312,7 +432,7 @@ class pool_memory_resource final * * @throws logic_error if @p initial_size is larger than @p maximum_size (if set). */ - void initialize_pool(std::size_t initial_size, thrust::optional maximum_size) + void initialize_pool(std::size_t initial_size, std::optional maximum_size) { current_pool_size_ = 0; // try_to_expand will set this if it succeeds maximum_pool_size_ = maximum_size; @@ -376,7 +496,7 @@ class pool_memory_resource final * @param stream The stream on which the memory is to be used. * @return block_type The allocated block */ - thrust::optional block_from_upstream(std::size_t size, cuda_stream_view stream) + std::optional block_from_upstream(std::size_t size, cuda_stream_view stream) { RMM_LOG_DEBUG("[A][Stream {}][Upstream {}B]", fmt::ptr(stream.value()), size); @@ -384,10 +504,10 @@ class pool_memory_resource final try { void* ptr = get_upstream()->allocate_async(size, stream); - return thrust::optional{ + return std::optional{ *upstream_blocks_.emplace(static_cast(ptr), size, true).first}; } catch (std::exception const& e) { - return thrust::nullopt; + return std::nullopt; } } @@ -515,7 +635,7 @@ class pool_memory_resource final private: Upstream* upstream_mr_; // The "heap" to allocate the pool from std::size_t current_pool_size_{}; - thrust::optional maximum_pool_size_{}; + std::optional maximum_pool_size_{}; #ifdef RMM_POOL_TRACK_ALLOCATIONS std::set> allocated_blocks_; diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 690e2e338..0d68bc4bc 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -25,6 +25,7 @@ from libc.stddef cimport size_t from libc.stdint cimport int8_t, int64_t, uintptr_t from libcpp cimport bool from libcpp.memory cimport make_unique, unique_ptr +from libcpp.optional cimport optional from libcpp.pair cimport pair from libcpp.string cimport string @@ -76,19 +77,6 @@ cdef extern from *: # NOTE: Keep extern declarations in .pyx file as much as possible to avoid # leaking dependencies when importing RMM Cython .pxd files -cdef extern from "thrust/optional.h" namespace "thrust" nogil: - - struct nullopt_t: - pass - - cdef nullopt_t nullopt - - cdef cppclass optional[T]: - optional() - optional(T v) - - cdef optional[T] make_optional[T](T v) - cdef extern from "rmm/mr/device/cuda_memory_resource.hpp" \ namespace "rmm::mr" nogil: cdef cppclass cuda_memory_resource(device_memory_resource): @@ -322,13 +310,13 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): cdef optional[size_t] c_initial_pool_size = ( optional[size_t]() if initial_pool_size is None - else optional[size_t](initial_pool_size) + else optional[size_t]( initial_pool_size) ) cdef optional[size_t] c_release_threshold = ( optional[size_t]() if release_threshold is None - else optional[size_t](release_threshold) + else optional[size_t]( release_threshold) ) # If IPC memory handles are not supported, the constructor below will @@ -382,7 +370,7 @@ cdef class PoolMemoryResource(UpstreamResourceAdaptor): c_maximum_pool_size = ( optional[size_t]() if maximum_pool_size is None - else make_optional[size_t](maximum_pool_size) + else optional[size_t]( maximum_pool_size) ) self.c_obj.reset( new pool_memory_resource[device_memory_resource]( From 1226ef05d74e3804c58c3558807f1ed5ee9f909d Mon Sep 17 00:00:00 2001 From: nvdbaranec <56695930+nvdbaranec@users.noreply.github.com> Date: Mon, 26 Feb 2024 16:15:09 -0600 Subject: [PATCH 364/675] Add host_resource_ref and async_host_resource ref as aliases to cudf resource types. (#1479) Adds new aliases to `resource_ref.hpp` `using host_resource_ref = cuda::mr::resource_ref;` `using host_async_resource_ref = cuda::mr::async_resource_ref;` Authors: - https://github.com/nvdbaranec Approvers: - Michael Schellenberger Costa (https://github.com/miscco) - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1479 --- include/rmm/resource_ref.hpp | 32 ++++++++++++++++++++++++++++++++ tests/mr/host/mr_ref_tests.cpp | 5 +++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/include/rmm/resource_ref.hpp b/include/rmm/resource_ref.hpp index a363f9b50..e71613fe9 100644 --- a/include/rmm/resource_ref.hpp +++ b/include/rmm/resource_ref.hpp @@ -25,11 +25,43 @@ namespace rmm { * @file */ +/** + * @brief Alias for a `cuda::mr::resource_ref` with the property + * `cuda::mr::device_accessible`. + */ +using device_resource_ref = cuda::mr::resource_ref; + /** * @brief Alias for a `cuda::mr::async_resource_ref` with the property * `cuda::mr::device_accessible`. */ using device_async_resource_ref = cuda::mr::async_resource_ref; +/** + * @brief Alias for a `cuda::mr::resource_ref` with the property + * `cuda::mr::host_accessible`. + */ +using host_resource_ref = cuda::mr::resource_ref; + +/** + * @brief Alias for a `cuda::mr::async_resource_ref` with the property + * `cuda::mr::host_accessible`. + */ +using host_async_resource_ref = cuda::mr::async_resource_ref; + +/** + * @brief Alias for a `cuda::mr::resource_ref` with the properties + * `cuda::mr::host_accessible` and `cuda::mr::device_accessible`. + */ +using host_device_resource_ref = + cuda::mr::resource_ref; + +/** + * @brief Alias for a `cuda::mr::async_resource_ref` with the properties + * `cuda::mr::host_accessible` and `cuda::mr::device_accessible`. + */ +using host_device_async_resource_ref = + cuda::mr::async_resource_ref; + /** @} */ // end of group } // namespace rmm diff --git a/tests/mr/host/mr_ref_tests.cpp b/tests/mr/host/mr_ref_tests.cpp index 49b5bf061..3755a8a29 100644 --- a/tests/mr/host/mr_ref_tests.cpp +++ b/tests/mr/host/mr_ref_tests.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -72,7 +73,7 @@ struct allocation { template struct MRRefTest : public ::testing::Test { MemoryResourceType mr; - cuda::mr::resource_ref ref; + rmm::host_resource_ref ref; MRRefTest() : mr{}, ref{mr} {} }; @@ -248,7 +249,7 @@ TYPED_TEST(MRRefTest, UnsupportedAlignmentTest) TEST(PinnedResource, isPinned) { rmm::mr::pinned_memory_resource mr; - cuda::mr::resource_ref ref{mr}; + rmm::host_resource_ref ref{mr}; void* ptr{nullptr}; EXPECT_NO_THROW(ptr = ref.allocate(100)); EXPECT_TRUE(is_pinned_memory(ptr)); From 23fa632fa4234545fa37e48b78c0c6109e699c16 Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Tue, 27 Feb 2024 00:23:05 -0800 Subject: [PATCH 365/675] Use `rmm::device_async_resource_ref` in multi_stream_allocation benchmark (#1482) We want to move away from using raw `device_memory_resource*` in code, so adapt the code to use `rmm::device_async_resource_ref`. Fixes #1481 Authors: - Michael Schellenberger Costa (https://github.com/miscco) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1482 --- .../multi_stream_allocations_bench.cu | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu b/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu index d38e89a3b..b73ef54f8 100644 --- a/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu +++ b/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -50,7 +51,7 @@ __global__ void compute_bound_kernel(int64_t* out) using MRFactoryFunc = std::function()>; -static void run_prewarm(rmm::cuda_stream_pool& stream_pool, rmm::mr::device_memory_resource* mr) +static void run_prewarm(rmm::cuda_stream_pool& stream_pool, rmm::device_async_resource_ref mr) { auto buffers = std::vector>(); for (int32_t i = 0; i < stream_pool.get_pool_size(); i++) { @@ -61,7 +62,7 @@ static void run_prewarm(rmm::cuda_stream_pool& stream_pool, rmm::mr::device_memo static void run_test(std::size_t num_kernels, rmm::cuda_stream_pool& stream_pool, - rmm::mr::device_memory_resource* mr) + rmm::device_async_resource_ref mr) { for (int32_t i = 0; i < num_kernels; i++) { auto stream = stream_pool.get_stream(i); From e2f54a0e63a38f24a2a6f3d990ed9d340331ba83 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 27 Feb 2024 09:18:01 -0600 Subject: [PATCH 366/675] Add support for Python 3.11 (#1469) Contributes to https://github.com/rapidsai/build-planning/issues/3 This PR adds support for Python 3.11. ## Notes for Reviewers This is part of ongoing work to add Python 3.11 support across RAPIDS. The Python 3.11 CI workflows introduced in https://github.com/rapidsai/shared-workflows/pull/176 are *optional*... they are not yet required to run successfully for PRs to be merged. This PR can be merged once all jobs are running successfully (including the non-required jobs for Python 3.11). The CI logs should be verified that the jobs are building and testing with Python 3.11. See https://github.com/rapidsai/shared-workflows/pull/176 for more details. Authors: - James Lamb (https://github.com/jameslamb) - Bradley Dice (https://github.com/bdice) Approvers: - Bradley Dice (https://github.com/bdice) - Kyle Edwards (https://github.com/KyleFromNVIDIA) - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1469 --- README.md | 2 +- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-122_arch-x86_64.yaml | 2 +- dependencies.yaml | 6 +++++- python/pyproject.toml | 1 + 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a1b85d33c..9ec8cbf47 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ conda install -c rapidsai -c conda-forge -c nvidia rmm cuda-version=12.0 We also provide [nightly Conda packages](https://anaconda.org/rapidsai-nightly) built from the HEAD of our latest development branch. -Note: RMM is supported only on Linux, and only tested with Python versions 3.9 and 3.10. +Note: RMM is supported only on Linux, and only tested with Python versions 3.9, 3.10, and 3.11. Note: The RMM package from Conda requires building with GCC 9 or later. Otherwise, your application may fail to build. diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 595c9fae3..9590a77ce 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -32,7 +32,7 @@ dependencies: - pre-commit - pytest - pytest-cov -- python>=3.9,<3.11 +- python>=3.9,<3.12 - scikit-build-core>=0.7.0 - spdlog>=1.12.0,<1.13 - sphinx diff --git a/conda/environments/all_cuda-122_arch-x86_64.yaml b/conda/environments/all_cuda-122_arch-x86_64.yaml index d5d6275a8..7b28ad71e 100644 --- a/conda/environments/all_cuda-122_arch-x86_64.yaml +++ b/conda/environments/all_cuda-122_arch-x86_64.yaml @@ -30,7 +30,7 @@ dependencies: - pre-commit - pytest - pytest-cov -- python>=3.9,<3.11 +- python>=3.9,<3.12 - scikit-build-core>=0.7.0 - spdlog>=1.12.0,<1.13 - sphinx diff --git a/dependencies.yaml b/dependencies.yaml index 1bf4e1034..4fed4976b 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -206,8 +206,12 @@ dependencies: packages: - python=3.10 - matrix: + py: "3.11" packages: - - python>=3.9,<3.11 + - python=3.11 + - matrix: + packages: + - python>=3.9,<3.12 run: common: - output_types: [conda, requirements, pyproject] diff --git a/python/pyproject.toml b/python/pyproject.toml index 204d81c3c..1005ac2db 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -45,6 +45,7 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ] [project.optional-dependencies] From 742d2883aed744df546d6aef5bdb2e0bdd028eae Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 27 Feb 2024 10:43:44 -0600 Subject: [PATCH 367/675] Run STATISTICS_TEST and TRACKING_TEST in serial to avoid OOM errors. (#1487) There have been out-of-memory errors reported in `STATISTICS_TEST` and `TRACKING_TEST`. This PR serializes the execution of those tests, in an attempt to avoid the reported failures. Closes https://github.com/rapidsai/rmm/issues/1486. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Kyle Edwards (https://github.com/KyleFromNVIDIA) - Robert Maynard (https://github.com/robertmaynard) URL: https://github.com/rapidsai/rmm/pull/1487 --- tests/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0d0561098..1a14ed1fb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -145,10 +145,10 @@ ConfigureTest(POLYMORPHIC_ALLOCATOR_TEST mr/device/polymorphic_allocator_tests.c ConfigureTest(STREAM_ADAPTOR_TEST mr/device/stream_allocator_adaptor_tests.cpp) # statistics adaptor tests -ConfigureTest(STATISTICS_TEST mr/device/statistics_mr_tests.cpp) +ConfigureTest(STATISTICS_TEST mr/device/statistics_mr_tests.cpp GPUS 1 PERCENT 100) # tracking adaptor tests -ConfigureTest(TRACKING_TEST mr/device/tracking_mr_tests.cpp) +ConfigureTest(TRACKING_TEST mr/device/tracking_mr_tests.cpp GPUS 1 PERCENT 100) # out-of-memory callback adaptor tests ConfigureTest(FAILURE_CALLBACK_TEST mr/device/failure_callback_mr_tests.cpp) From cdeb7852052c6d1e49bfe29392ee0eaa418651f0 Mon Sep 17 00:00:00 2001 From: Paul Taylor <178183+trxcllnt@users.noreply.github.com> Date: Tue, 27 Feb 2024 08:44:11 -0800 Subject: [PATCH 368/675] Add environment-agnostic scripts for running ctests and pytests (#1462) This PR adds environment-agnostic `run_{ctests,pytests}.sh` scripts, and updates `test_{cpp,python}.sh` to call them. The `test_{cpp,python}.sh` scripts assume they're running in our CI environment, and they do more than just run the tests. This PR allows devs and downstream consumers to only run the tests, and skip the unrelated logic in `test_{cpp,python}.sh`. Authors: - Paul Taylor (https://github.com/trxcllnt) Approvers: - Jake Awe (https://github.com/AyodeAwe) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1462 --- ci/run_ctests.sh | 9 +++++++++ ci/run_pytests.sh | 9 +++++++++ ci/test_cpp.sh | 10 ++++------ ci/test_python.sh | 28 +++++++++++++--------------- 4 files changed, 35 insertions(+), 21 deletions(-) create mode 100755 ci/run_ctests.sh create mode 100755 ci/run_pytests.sh diff --git a/ci/run_ctests.sh b/ci/run_ctests.sh new file mode 100755 index 000000000..13d61a71e --- /dev/null +++ b/ci/run_ctests.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Copyright (c) 2024, NVIDIA CORPORATION. + +set -euo pipefail + +# Support customizing the ctests' install location +cd "${INSTALL_PREFIX:-${CONDA_PREFIX:-/usr}}/bin/gtests/librmm/" + +ctest --no-tests=error --output-on-failure "$@" diff --git a/ci/run_pytests.sh b/ci/run_pytests.sh new file mode 100755 index 000000000..73780fcc3 --- /dev/null +++ b/ci/run_pytests.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Copyright (c) 2024, NVIDIA CORPORATION. + +set -euo pipefail + +# Support invoking run_pytests.sh outside the script directory +cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/ + +pytest --cache-clear -v "$@" . diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index fddd71b9d..1adef8778 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -3,6 +3,9 @@ set -euo pipefail +# Support invoking test_cpp.sh outside the script directory +cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../ + . /opt/conda/etc/profile.d/conda.sh rapids-logger "Generate C++ testing dependencies" @@ -31,16 +34,11 @@ rapids-mamba-retry install \ rapids-logger "Check GPU usage" nvidia-smi -EXITCODE=0 -trap "EXITCODE=1" ERR -set +e - # Run librmm gtests from librmm-tests package rapids-logger "Run gtests" -cd $CONDA_PREFIX/bin/gtests/librmm/ export GTEST_OUTPUT=xml:${RAPIDS_TESTS_DIR}/ -ctest -j20 --output-on-failure --no-tests=error +./ci/run_ctests.sh -j20 && EXITCODE=$? || EXITCODE=$?; rapids-logger "Test script exiting with value: $EXITCODE" exit ${EXITCODE} diff --git a/ci/test_python.sh b/ci/test_python.sh index d3b3bdfd8..d549a44b5 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -1,7 +1,11 @@ #!/bin/bash -# Copyright (c) 2020-2023, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. + set -euo pipefail +# Support invoking test_python.sh outside the script directory +cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../ + rapids-logger "Create test conda environment" . /opt/conda/etc/profile.d/conda.sh @@ -33,21 +37,15 @@ mkdir -p "${RAPIDS_TESTS_DIR}" "${RAPIDS_COVERAGE_DIR}" rapids-logger "Check GPU usage" nvidia-smi -cd python - -EXITCODE=0 -trap "EXITCODE=1" ERR -set +e - rapids-logger "pytest rmm" -pytest \ - --cache-clear \ - --junitxml="${RAPIDS_TESTS_DIR}/junit-rmm.xml" \ - -v \ - --cov-config=.coveragerc \ - --cov=rmm \ - --cov-report=xml:"${RAPIDS_COVERAGE_DIR}/rmm-coverage.xml" \ - --cov-report term + +./ci/run_pytests.sh \ + --junitxml="${RAPIDS_TESTS_DIR}/junit-rmm.xml" \ + --cov-config=.coveragerc \ + --cov=rmm \ + --cov-report=xml:"${RAPIDS_COVERAGE_DIR}/rmm-coverage.xml" \ + --cov-report term \ + && EXITCODE=$? || EXITCODE=$?; rapids-logger "Test script exiting with value: $EXITCODE" exit ${EXITCODE} From 63335f23b277b02a39ce031ed4f22a576b06e6c5 Mon Sep 17 00:00:00 2001 From: Paul Taylor <178183+trxcllnt@users.noreply.github.com> Date: Tue, 27 Feb 2024 08:45:08 -0800 Subject: [PATCH 369/675] Update devcontainers to CUDA Toolkit 12.2 (#1470) Authors: - Paul Taylor (https://github.com/trxcllnt) Approvers: - Jake Awe (https://github.com/AyodeAwe) - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1470 --- .devcontainer/cuda11.8-pip/devcontainer.json | 2 +- .../{cuda12.0-conda => cuda12.2-conda}/devcontainer.json | 6 +++--- .../{cuda12.0-pip => cuda12.2-pip}/devcontainer.json | 8 ++++---- .github/workflows/pr.yaml | 4 +++- 4 files changed, 11 insertions(+), 9 deletions(-) rename .devcontainer/{cuda12.0-conda => cuda12.2-conda}/devcontainer.json (92%) rename .devcontainer/{cuda12.0-pip => cuda12.2-pip}/devcontainer.json (87%) diff --git a/.devcontainer/cuda11.8-pip/devcontainer.json b/.devcontainer/cuda11.8-pip/devcontainer.json index f3284441c..90a3732f4 100644 --- a/.devcontainer/cuda11.8-pip/devcontainer.json +++ b/.devcontainer/cuda11.8-pip/devcontainer.json @@ -5,7 +5,7 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:24.04-cpp-llvm16-cuda11.8-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.04-cpp-cuda11.8-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, diff --git a/.devcontainer/cuda12.0-conda/devcontainer.json b/.devcontainer/cuda12.2-conda/devcontainer.json similarity index 92% rename from .devcontainer/cuda12.0-conda/devcontainer.json rename to .devcontainer/cuda12.2-conda/devcontainer.json index 8699f13d3..8dc4f8be9 100644 --- a/.devcontainer/cuda12.0-conda/devcontainer.json +++ b/.devcontainer/cuda12.2-conda/devcontainer.json @@ -3,7 +3,7 @@ "context": "${localWorkspaceFolder}/.devcontainer", "dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile", "args": { - "CUDA": "12.0", + "CUDA": "12.2", "PYTHON_PACKAGE_MANAGER": "conda", "BASE": "rapidsai/devcontainers:24.04-cpp-mambaforge-ubuntu22.04" } @@ -15,7 +15,7 @@ "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" ], - "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config,conda/pkgs,conda/${localWorkspaceFolderBasename}-cuda12.0-envs}"], + "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config,conda/pkgs,conda/${localWorkspaceFolderBasename}-cuda12.2-envs}"], "postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"], "workspaceFolder": "/home/coder", "workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent", @@ -24,7 +24,7 @@ "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.conda/pkgs,target=/home/coder/.conda/pkgs,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.conda/${localWorkspaceFolderBasename}-cuda12.0-envs,target=/home/coder/.conda/envs,type=bind,consistency=consistent" + "source=${localWorkspaceFolder}/../.conda/${localWorkspaceFolderBasename}-cuda12.2-envs,target=/home/coder/.conda/envs,type=bind,consistency=consistent" ], "customizations": { "vscode": { diff --git a/.devcontainer/cuda12.0-pip/devcontainer.json b/.devcontainer/cuda12.2-pip/devcontainer.json similarity index 87% rename from .devcontainer/cuda12.0-pip/devcontainer.json rename to .devcontainer/cuda12.2-pip/devcontainer.json index dc1784738..66d332573 100644 --- a/.devcontainer/cuda12.0-pip/devcontainer.json +++ b/.devcontainer/cuda12.2-pip/devcontainer.json @@ -3,9 +3,9 @@ "context": "${localWorkspaceFolder}/.devcontainer", "dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile", "args": { - "CUDA": "12.0", + "CUDA": "12.2", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:24.04-cpp-llvm16-cuda12.0-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.04-cpp-cuda12.2-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, @@ -15,7 +15,7 @@ "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" ], - "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config/pip,local/share/${localWorkspaceFolderBasename}-cuda12.0-venvs}"], + "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config/pip,local/share/${localWorkspaceFolderBasename}-cuda12.2-venvs}"], "postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"], "workspaceFolder": "/home/coder", "workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent", @@ -23,7 +23,7 @@ "source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.local/share/${localWorkspaceFolderBasename}-cuda12.0-venvs,target=/home/coder/.local/share/venvs,type=bind,consistency=consistent" + "source=${localWorkspaceFolder}/../.local/share/${localWorkspaceFolderBasename}-cuda12.2-venvs,target=/home/coder/.local/share/venvs,type=bind,consistency=consistent" ], "customizations": { "vscode": { diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index da32eb12b..c0a9a0841 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -78,8 +78,10 @@ jobs: script: ci/test_wheel.sh devcontainer: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@fix/devcontainer-json-location with: + arch: '["amd64"]' + cuda: '["12.2"]' build_command: | sccache -z; build-all -DBUILD_BENCHMARKS=ON --verbose; From 06002f3008c55a3803077760a68ec87e31dccfa4 Mon Sep 17 00:00:00 2001 From: jakirkham Date: Wed, 28 Feb 2024 13:02:22 -0800 Subject: [PATCH 370/675] Requre NumPy 1.23+ (#1488) As NumPy 1.23 is needed for Python 3.11 support, go ahead and bump the minimum NumPy version used by RMM to match that. xref: https://github.com/rapidsai/rmm/pull/1469
Authors: - https://github.com/jakirkham Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1488 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-122_arch-x86_64.yaml | 2 +- conda/recipes/rmm/meta.yaml | 2 +- dependencies.yaml | 2 +- python/pyproject.toml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 9590a77ce..6b1a1acf1 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -26,7 +26,7 @@ dependencies: - nbsphinx - ninja - numba>=0.57 -- numpy>=1.21 +- numpy>=1.23 - numpydoc - nvcc_linux-64=11.8 - pre-commit diff --git a/conda/environments/all_cuda-122_arch-x86_64.yaml b/conda/environments/all_cuda-122_arch-x86_64.yaml index 7b28ad71e..2756d4ae3 100644 --- a/conda/environments/all_cuda-122_arch-x86_64.yaml +++ b/conda/environments/all_cuda-122_arch-x86_64.yaml @@ -25,7 +25,7 @@ dependencies: - nbsphinx - ninja - numba>=0.57 -- numpy>=1.21 +- numpy>=1.23 - numpydoc - pre-commit - pytest diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 83975d0f2..01ac8cea8 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -73,7 +73,7 @@ requirements: {% endif %} - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - numba >=0.57 - - numpy >=1.21 + - numpy >=1.23 test: imports: diff --git a/dependencies.yaml b/dependencies.yaml index 4fed4976b..bc80a1d26 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -217,7 +217,7 @@ dependencies: - output_types: [conda, requirements, pyproject] packages: - numba>=0.57 - - numpy>=1.21 + - numpy>=1.23 specific: - output_types: [conda, requirements, pyproject] matrices: diff --git a/python/pyproject.toml b/python/pyproject.toml index 1005ac2db..f9151ff8d 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -35,7 +35,7 @@ requires-python = ">=3.9" dependencies = [ "cuda-python>=11.7.1,<12.0a0", "numba>=0.57", - "numpy>=1.21", + "numpy>=1.23", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../dependencies.yaml and run `rapids-dependency-file-generator`. classifiers = [ "Intended Audience :: Developers", From f132d4b0daa976e1ec6cbcef24f5454fe510a394 Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Thu, 29 Feb 2024 02:37:38 -0800 Subject: [PATCH 371/675] Add `get_upstream_resource` to resource adaptors (#1456) We want to get rid of the raw `get_upstream` method. In order to achieve that we need to add an alternative that is based on our new `rmm::device_async_resource_ref` I am a stickler to consistency so I also cleaned the documentation of `get_upstream` up and added `[[nodiscard]]` closes #1455 Authors: - Michael Schellenberger Costa (https://github.com/miscco) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1456 --- .../mr/device/aligned_resource_adaptor.hpp | 15 +++++-- .../rmm/mr/device/binning_memory_resource.hpp | 13 ++++-- .../failure_callback_resource_adaptor.hpp | 13 +++++- .../mr/device/fixed_size_memory_resource.hpp | 15 +++++-- .../mr/device/limiting_resource_adaptor.hpp | 11 ++++- .../mr/device/logging_resource_adaptor.hpp | 13 ++++-- .../rmm/mr/device/polymorphic_allocator.hpp | 9 ++++ .../rmm/mr/device/pool_memory_resource.hpp | 16 +++---- .../mr/device/statistics_resource_adaptor.hpp | 13 +++++- .../device/thread_safe_resource_adaptor.hpp | 15 +++++-- .../mr/device/thrust_allocator_adaptor.hpp | 7 ++- .../mr/device/tracking_resource_adaptor.hpp | 13 +++++- include/rmm/mr/is_resource_adaptor.hpp | 43 +++++++++++++++++++ tests/device_check_resource_adaptor.hpp | 12 ++++++ tests/mr/device/adaptor_tests.cpp | 14 ++++++ tests/mr/device/thrust_allocator_tests.cu | 2 +- 16 files changed, 188 insertions(+), 36 deletions(-) create mode 100644 include/rmm/mr/is_resource_adaptor.hpp diff --git a/include/rmm/mr/device/aligned_resource_adaptor.hpp b/include/rmm/mr/device/aligned_resource_adaptor.hpp index 88c870366..c3213afdf 100644 --- a/include/rmm/mr/device/aligned_resource_adaptor.hpp +++ b/include/rmm/mr/device/aligned_resource_adaptor.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -82,11 +83,17 @@ class aligned_resource_adaptor final : public device_memory_resource { aligned_resource_adaptor& operator=(aligned_resource_adaptor&&) = delete; /** - * @brief Get the upstream memory resource. - * - * @return Upstream* pointer to a memory resource object. + * @briefreturn{rmm::device_async_resource_ref to the upstream resource} + */ + [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + { + return upstream_; + } + + /** + * @briefreturn{Upstream* to the upstream memory resource} */ - Upstream* get_upstream() const noexcept { return upstream_; } + [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } /** * @brief The default alignment used by the adaptor. diff --git a/include/rmm/mr/device/binning_memory_resource.hpp b/include/rmm/mr/device/binning_memory_resource.hpp index 56e2958e8..9b0c04f3d 100644 --- a/include/rmm/mr/device/binning_memory_resource.hpp +++ b/include/rmm/mr/device/binning_memory_resource.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -99,9 +100,15 @@ class binning_memory_resource final : public device_memory_resource { binning_memory_resource& operator=(binning_memory_resource&&) = delete; /** - * @brief Get the upstream memory_resource object. - * - * @return UpstreamResource* the upstream memory resource. + * @briefreturn{rmm::device_async_resource_ref to the upstream resource} + */ + [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + { + return upstream_mr_; + } + + /** + * @briefreturn{Upstream* to the upstream memory resource} */ [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_mr_; } diff --git a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp index a0232fd5b..5a1a09b82 100644 --- a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp +++ b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -120,9 +121,17 @@ class failure_callback_resource_adaptor final : public device_memory_resource { default; ///< @default_move_assignment{failure_callback_resource_adaptor} /** - * @briefreturn{Pointer to the upstream resource} + * @briefreturn{rmm::device_async_resource_ref to the upstream resource} */ - Upstream* get_upstream() const noexcept { return upstream_; } + [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + { + return upstream_; + } + + /** + * @briefreturn{Upstream* to the upstream memory resource} + */ + [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } private: /** diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index d34ad8d7e..8318dbfa1 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -96,11 +97,17 @@ class fixed_size_memory_resource fixed_size_memory_resource& operator=(fixed_size_memory_resource&&) = delete; /** - * @brief Get the upstream memory_resource object. - * - * @return UpstreamResource* the upstream memory resource. + * @briefreturn{rmm::device_async_resource_ref to the upstream resource} + */ + [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + { + return upstream_mr_; + } + + /** + * @briefreturn{Upstream* to the upstream memory resource} */ - Upstream* get_upstream() const noexcept { return upstream_mr_; } + [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_mr_; } /** * @brief Get the size of blocks allocated by this memory resource. diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index 4d5f9829f..174ada34b 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -73,7 +74,15 @@ class limiting_resource_adaptor final : public device_memory_resource { default; ///< @default_move_assignment{limiting_resource_adaptor} /** - * @briefreturn{Pointer to the upstream resource} + * @briefreturn{rmm::device_async_resource_ref to the upstream resource} + */ + [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + { + return upstream_; + } + + /** + * @briefreturn{Upstream* to the upstream memory resource} */ [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 252ea813f..885908937 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -137,9 +138,15 @@ class logging_resource_adaptor final : public device_memory_resource { default; ///< @default_move_assignment{logging_resource_adaptor} /** - * @brief Return pointer to the upstream resource. - * - * @return Upstream* Pointer to the upstream resource. + * @briefreturn{rmm::device_async_resource_ref to the upstream resource} + */ + [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + { + return upstream_; + } + + /** + * @briefreturn{Upstream* to the upstream memory resource} */ [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } diff --git a/include/rmm/mr/device/polymorphic_allocator.hpp b/include/rmm/mr/device/polymorphic_allocator.hpp index c3b8ac6ea..e2fb4b0cf 100644 --- a/include/rmm/mr/device/polymorphic_allocator.hpp +++ b/include/rmm/mr/device/polymorphic_allocator.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -99,6 +100,14 @@ class polymorphic_allocator { resource()->deallocate(ptr, num * sizeof(T), stream); } + /** + * @briefreturn{rmm::device_async_resource_ref to the upstream resource} + */ + [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + { + return mr_; + } + /** * @brief Returns pointer to the underlying `rmm::mr::device_memory_resource`. * diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index cbd499021..61ef75bd0 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -348,18 +349,17 @@ class pool_memory_resource final pool_memory_resource& operator=(pool_memory_resource&&) = delete; /** - * @brief Get the upstream memory_resource object. - * - * @return const reference to the upstream memory resource. + * @briefreturn{rmm::device_async_resource_ref to the upstream resource} */ - [[nodiscard]] const Upstream& upstream_resource() const noexcept { return *upstream_mr_; } + [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + { + return upstream_mr_; + } /** - * @brief Get the upstream memory_resource object. - * - * @return UpstreamResource* the upstream memory resource. + * @briefreturn{Upstream* to the upstream memory resource} */ - Upstream* get_upstream() const noexcept { return upstream_mr_; } + [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_mr_; } /** * @brief Computes the size of the current pool diff --git a/include/rmm/mr/device/statistics_resource_adaptor.hpp b/include/rmm/mr/device/statistics_resource_adaptor.hpp index 8e379159b..9febf9ef5 100644 --- a/include/rmm/mr/device/statistics_resource_adaptor.hpp +++ b/include/rmm/mr/device/statistics_resource_adaptor.hpp @@ -16,6 +16,7 @@ #pragma once #include +#include #include #include @@ -107,9 +108,17 @@ class statistics_resource_adaptor final : public device_memory_resource { default; ///< @default_move_assignment{statistics_resource_adaptor} /** - * @briefreturn{Pointer to the upstream resource} + * @briefreturn{rmm::device_async_resource_ref to the upstream resource} */ - Upstream* get_upstream() const noexcept { return upstream_; } + [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + { + return upstream_; + } + + /** + * @briefreturn{Upstream* to the upstream memory resource} + */ + [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } /** * @brief Returns a `counter` struct for this adaptor containing the current, diff --git a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp index 5dcd2d7a8..5daf5f3f9 100644 --- a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp +++ b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -65,11 +66,17 @@ class thread_safe_resource_adaptor final : public device_memory_resource { thread_safe_resource_adaptor& operator=(thread_safe_resource_adaptor&&) = delete; /** - * @brief Get the upstream memory resource. - * - * @return Upstream* pointer to a memory resource object. + * @briefreturn{rmm::device_async_resource_ref to the upstream resource} + */ + [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + { + return upstream_; + } + + /** + * @briefreturn{Upstream* to the upstream memory resource} */ - Upstream* get_upstream() const noexcept { return upstream_; } + [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } private: /** diff --git a/include/rmm/mr/device/thrust_allocator_adaptor.hpp b/include/rmm/mr/device/thrust_allocator_adaptor.hpp index f2b1a6027..41973e04b 100644 --- a/include/rmm/mr/device/thrust_allocator_adaptor.hpp +++ b/include/rmm/mr/device/thrust_allocator_adaptor.hpp @@ -121,9 +121,12 @@ class thrust_allocator : public thrust::device_malloc_allocator { } /** - * @briefreturn{The resource used to allocate and deallocate} + * @briefreturn{rmm::device_async_resource_ref to the upstream resource} */ - [[nodiscard]] rmm::device_async_resource_ref memory_resource() const noexcept { return _mr; } + [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + { + return _mr; + } /** * @briefreturn{The stream used by this allocator} diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index 4635e5d3a..d337da21c 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -106,9 +107,17 @@ class tracking_resource_adaptor final : public device_memory_resource { default; ///< @default_move_assignment{tracking_resource_adaptor} /** - * @briefreturn{Pointer to the upstream resource} + * @briefreturn{rmm::device_async_resource_ref to the upstream resource} */ - Upstream* get_upstream() const noexcept { return upstream_; } + [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + { + return upstream_; + } + + /** + * @briefreturn{Upstream* to the upstream memory resource} + */ + [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } /** * @brief Get the outstanding allocations map diff --git a/include/rmm/mr/is_resource_adaptor.hpp b/include/rmm/mr/is_resource_adaptor.hpp new file mode 100644 index 000000000..96989c14f --- /dev/null +++ b/include/rmm/mr/is_resource_adaptor.hpp @@ -0,0 +1,43 @@ +/* + * 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. + */ +#pragma once + +#include +#include + +namespace rmm::mr { + +/** + * @addtogroup memory_resources + * @{ + * @file + */ + +/** + * @brief Concept to check whether a resource is a resource adaptor by checking for + * `get_upstream_resource`. + */ +template +inline constexpr bool is_resource_adaptor = false; + +template +inline constexpr bool is_resource_adaptor< + Resource, + cuda::std::void_t().get_upstream_resource())>> = + cuda::mr::resource; + +/** @} */ // end of group +} // namespace rmm::mr diff --git a/tests/device_check_resource_adaptor.hpp b/tests/device_check_resource_adaptor.hpp index 6fac83a21..4f75b191c 100644 --- a/tests/device_check_resource_adaptor.hpp +++ b/tests/device_check_resource_adaptor.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -27,6 +28,17 @@ class device_check_resource_adaptor final : public rmm::mr::device_memory_resour { } + /** + * @briefreturn{rmm::device_async_resource_ref to the upstream resource} + */ + [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + { + return upstream_; + } + + /** + * @briefreturn{device_memory_resource* to the upstream memory resource} + */ [[nodiscard]] device_memory_resource* get_upstream() const noexcept { return upstream_; } private: diff --git a/tests/mr/device/adaptor_tests.cpp b/tests/mr/device/adaptor_tests.cpp index 76c84d37d..c05c9b641 100644 --- a/tests/mr/device/adaptor_tests.cpp +++ b/tests/mr/device/adaptor_tests.cpp @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include @@ -142,6 +144,18 @@ TYPED_TEST(AdaptorTest, GetUpstream) } } +TYPED_TEST(AdaptorTest, GetUpstreamResource) +{ + rmm::device_async_resource_ref expected{this->cuda}; + if constexpr (std::is_same_v) { + EXPECT_TRUE(this->mr->wrapped().get_upstream_resource() == expected); + EXPECT_TRUE(rmm::mr::is_resource_adaptormr->wrapped())>); + } else { + EXPECT_TRUE(this->mr->get_upstream_resource() == expected); + EXPECT_TRUE(rmm::mr::is_resource_adaptormr)>); + } +} + TYPED_TEST(AdaptorTest, AllocFree) { void* ptr{nullptr}; diff --git a/tests/mr/device/thrust_allocator_tests.cu b/tests/mr/device/thrust_allocator_tests.cu index ed66c220c..b94d6b3e1 100644 --- a/tests/mr/device/thrust_allocator_tests.cu +++ b/tests/mr/device/thrust_allocator_tests.cu @@ -45,7 +45,7 @@ TEST_P(allocator_test, defaults) { rmm::mr::thrust_allocator allocator(rmm::cuda_stream_default); EXPECT_EQ(allocator.stream(), rmm::cuda_stream_default); - EXPECT_EQ(allocator.memory_resource(), + EXPECT_EQ(allocator.get_upstream_resource(), rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}); } From 26a941b8fb4c05223976a8c924439948db6da295 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 6 Mar 2024 06:54:56 -0800 Subject: [PATCH 372/675] Pin to recent breathe, to prevent getting an unsupported sphinx version. (#1495) The RMM nightly docs builds failed. https://github.com/rapidsai/rmm/actions/runs/8151286975/job/22279173933#step:9:973 It ran into an error reported in https://github.com/sphinx-doc/sphinx/issues/11490. It seems like a viable fix (that is also minimal and somewhat future-proof) is to pin to a recent version of `breathe`, which in turn forces a compatible version of sphinx. This is the same pinning used by cudf. Authors: - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Mark Harris (https://github.com/harrism) - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1495 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-122_arch-x86_64.yaml | 2 +- dependencies.yaml | 2 +- python/docs/conf.py | 12 ++++++++++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 6b1a1acf1..d555eb104 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -4,7 +4,7 @@ channels: - rapidsai - conda-forge dependencies: -- breathe +- breathe>=4.35.0 - c-compiler - clang-tools==16.0.6 - clang==16.0.6 diff --git a/conda/environments/all_cuda-122_arch-x86_64.yaml b/conda/environments/all_cuda-122_arch-x86_64.yaml index 2756d4ae3..7c58c0024 100644 --- a/conda/environments/all_cuda-122_arch-x86_64.yaml +++ b/conda/environments/all_cuda-122_arch-x86_64.yaml @@ -4,7 +4,7 @@ channels: - rapidsai - conda-forge dependencies: -- breathe +- breathe>=4.35.0 - c-compiler - clang-tools==16.0.6 - clang==16.0.6 diff --git a/dependencies.yaml b/dependencies.yaml index bc80a1d26..ec6e33e68 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -182,7 +182,7 @@ dependencies: common: - output_types: conda packages: - - breathe + - breathe>=4.35.0 - *doxygen - graphviz - ipython diff --git a/python/docs/conf.py b/python/docs/conf.py index 2919639af..3595a8f36 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -209,7 +209,15 @@ def on_missing_reference(app, env, node, contnode): # generates. Adding those would clutter the Sphinx output. return contnode - names_to_skip = [ + python_names_to_skip = [x for x in dir(int) if not x.startswith("__")] + if ( + node["refdomain"] == "py" + and (reftarget := node.get("reftarget")) is not None + and any(toskip in reftarget for toskip in python_names_to_skip) + ): + return contnode + + cpp_names_to_skip = [ # External names "cudaStream_t", "cudaStreamLegacy", @@ -241,7 +249,7 @@ def on_missing_reference(app, env, node, contnode): node["refdomain"] == "cpp" and (reftarget := node.get("reftarget")) is not None ): - if any(toskip in reftarget for toskip in names_to_skip): + if any(toskip in reftarget for toskip in cpp_names_to_skip): return contnode # Strip template parameters and just use the base type. From e173101d49a02f9c7abd29e888584e94f127b89c Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Thu, 7 Mar 2024 12:27:09 +0000 Subject: [PATCH 373/675] Accept stream argument in DeviceMemoryResource allocate/deallocate (#1494) In #980, the DeviceMemoryResource class in Python gained allocation and deallocation routines. This was to facilitate writing Python allocate/deallocate callbacks for the CallbackMemoryResource. These routines should, to match the C++ API, accept a stream parameter such that one can use them for stream-ordered allocation. Although we recommend that users allocate on the Python side using the DeviceBuffer interface, exposing these routines implicitly makes them public. To fix this, add an optional stream argument defaulting to the default stream. - Closes #1493 Authors: - Lawrence Mitchell (https://github.com/wence-) - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1494 --- python/rmm/_lib/memory_resource.pyx | 48 +++++++++++++++++------------ python/rmm/tests/test_rmm.py | 12 ++++---- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 0d68bc4bc..7458ca025 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -32,7 +32,8 @@ from libcpp.string cimport string from cuda.cudart import cudaError_t from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice - +from rmm._cuda.stream cimport Stream +from rmm._cuda.stream import DEFAULT_STREAM from rmm._lib.cuda_stream_view cimport cuda_stream_view from rmm._lib.per_device_resource cimport ( cuda_device_id, @@ -130,8 +131,8 @@ cdef extern from "rmm/mr/device/fixed_size_memory_resource.hpp" \ cdef extern from "rmm/mr/device/callback_memory_resource.hpp" \ namespace "rmm::mr" nogil: - ctypedef void* (*allocate_callback_t)(size_t, void*) - ctypedef void (*deallocate_callback_t)(void*, size_t, void*) + ctypedef void* (*allocate_callback_t)(size_t, cuda_stream_view, void*) + ctypedef void (*deallocate_callback_t)(void*, size_t, cuda_stream_view, void*) cdef cppclass callback_memory_resource(device_memory_resource): callback_memory_resource( @@ -221,17 +222,19 @@ cdef class DeviceMemoryResource: """Get the underlying C++ memory resource object.""" return self.c_obj.get() - def allocate(self, size_t nbytes): + def allocate(self, size_t nbytes, Stream stream=DEFAULT_STREAM): """Allocate ``nbytes`` bytes of memory. Parameters ---------- nbytes : size_t The size of the allocation in bytes + stream : Stream + Optional stream for the allocation """ - return self.c_obj.get().allocate(nbytes) + return self.c_obj.get().allocate(nbytes, stream.view()) - def deallocate(self, uintptr_t ptr, size_t nbytes): + def deallocate(self, uintptr_t ptr, size_t nbytes, Stream stream=DEFAULT_STREAM): """Deallocate memory pointed to by ``ptr`` of size ``nbytes``. Parameters @@ -240,8 +243,10 @@ cdef class DeviceMemoryResource: Pointer to be deallocated nbytes : size_t Size of the allocation in bytes + stream : Stream + Optional stream for the deallocation """ - self.c_obj.get().deallocate((ptr), nbytes) + self.c_obj.get().deallocate((ptr), nbytes, stream.view()) # See the note about `no_gc_clear` in `device_buffer.pyx`. @@ -561,7 +566,10 @@ cdef void* _allocate_callback_wrapper( cdef CppExcept err with gil: try: - return ((ctx)(nbytes)) + return ((ctx)( + nbytes, + Stream._from_cudaStream_t(stream.value()) + )) except BaseException as e: err = translate_python_except_to_cpp(e) throw_cpp_except(err) @@ -572,7 +580,7 @@ cdef void _deallocate_callback_wrapper( cuda_stream_view stream, void* ctx ) except * with gil: - (ctx)((ptr), nbytes) + (ctx)((ptr), nbytes, Stream._from_cudaStream_t(stream.value())) cdef class CallbackMemoryResource(DeviceMemoryResource): @@ -588,25 +596,27 @@ cdef class CallbackMemoryResource(DeviceMemoryResource): Parameters ---------- allocate_func: callable - The allocation function must accept a single integer argument, - representing the number of bytes to allocate, and return an - integer representing the pointer to the allocated memory. + The allocation function must accept two arguments. An integer + representing the number of bytes to allocate and a Stream on + which to perform the allocation, and return an integer + representing the pointer to the allocated memory. deallocate_func: callable - The deallocation function must accept two arguments, an integer - representing the pointer to the memory to free, and a second - integer representing the number of bytes to free. + The deallocation function must accept three arguments. an integer + representing the pointer to the memory to free, a second + integer representing the number of bytes to free, and a Stream + on which to perform the deallocation. Examples -------- >>> import rmm >>> base_mr = rmm.mr.CudaMemoryResource() - >>> def allocate_func(size): + >>> def allocate_func(size, stream): ... print(f"Allocating {size} bytes") - ... return base_mr.allocate(size) + ... return base_mr.allocate(size, stream) ... - >>> def deallocate_func(ptr, size): + >>> def deallocate_func(ptr, size, stream): ... print(f"Deallocating {size} bytes") - ... return base_mr.deallocate(ptr, size) + ... return base_mr.deallocate(ptr, size, stream) ... >>> rmm.mr.set_current_device_resource( rmm.mr.CallbackMemoryResource(allocate_func, deallocate_func) diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/tests/test_rmm.py index b5dc81c1f..25ff9a7a6 100644 --- a/python/rmm/tests/test_rmm.py +++ b/python/rmm/tests/test_rmm.py @@ -806,13 +806,13 @@ def test_mr_allocate_deallocate(): def test_custom_mr(capsys): base_mr = rmm.mr.CudaMemoryResource() - def allocate_func(size): + def allocate_func(size, stream): print(f"Allocating {size} bytes") - return base_mr.allocate(size) + return base_mr.allocate(size, stream) - def deallocate_func(ptr, size): + def deallocate_func(ptr, size, stream): print(f"Deallocating {size} bytes") - return base_mr.deallocate(ptr, size) + return base_mr.deallocate(ptr, size, stream) rmm.mr.set_current_device_resource( rmm.mr.CallbackMemoryResource(allocate_func, deallocate_func) @@ -836,10 +836,10 @@ def deallocate_func(ptr, size): def test_callback_mr_error(err_raise, err_catch): base_mr = rmm.mr.CudaMemoryResource() - def allocate_func(size): + def allocate_func(size, stream): raise err_raise("My alloc error") - def deallocate_func(ptr, size): + def deallocate_func(ptr, size, stream): return base_mr.deallocate(ptr, size) rmm.mr.set_current_device_resource( From c299fc1bdd4207dc92ddab4cb901ce3f6650db92 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 7 Mar 2024 20:22:39 -0800 Subject: [PATCH 374/675] Fix search path for torch allocator in editable installs and ensure CUDA support is available (#1498) The current logic for finding the allocator .so file presumes that torch.py is in the same directory tree as the compiled allocator. While this is true when the package is installed, it is not true for editable installs of the package where py files are left in the source tree while compiled modules are placed into a build tree (both are found by indirection). The current allocator logic also assumes that if pytorch is available it is a version compiled with CUDA support. This PR also adds a check to verify that we don't try to set the allocator on a CPU-only build of torch. Authors: - Vyas Ramasubramani (https://github.com/vyasr) - Bradley Dice (https://github.com/bdice) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1498 --- python/rmm/allocators/torch.py | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/python/rmm/allocators/torch.py b/python/rmm/allocators/torch.py index 35081f7f5..753da66da 100644 --- a/python/rmm/allocators/torch.py +++ b/python/rmm/allocators/torch.py @@ -11,19 +11,31 @@ # 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. + +rmm_torch_allocator = None + try: from torch.cuda.memory import CUDAPluggableAllocator except ImportError: - rmm_torch_allocator = None + pass else: - import pathlib + from torch.cuda import is_available + + if is_available(): + import pathlib + + # To support editable installs, we cannot search for the compiled torch + # allocator .so relative to the current file because the current file + # is pure Python and will therefore be in the source directory. + # Instead, we search relative to an arbitrary file in the compiled + # package. We use the _lib.lib module because it is small. + from rmm._lib import lib - sofile = ( - pathlib.Path(__file__).parent.parent / "_lib" / "_torch_allocator.so" - ) - rmm_torch_allocator = CUDAPluggableAllocator( - str(sofile.absolute()), - alloc_fn_name="allocate", - free_fn_name="deallocate", - ) - del pathlib, sofile + sofile = pathlib.Path(lib.__file__).parent / "_torch_allocator.so" + rmm_torch_allocator = CUDAPluggableAllocator( + str(sofile.absolute()), + alloc_fn_name="allocate", + free_fn_name="deallocate", + ) + del pathlib, sofile + del is_available From 2cb1ac7ffe85443492abc5529eb32d0277abe74d Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Fri, 8 Mar 2024 09:33:47 -0500 Subject: [PATCH 375/675] Remove hard-coding of RAPIDS version where possible (#1496) * Read `VERSION` file from CMake * Read `rmm.__version__` from docs build * Read `VERSION` file from shell scripts * Remove updates from `ci/release/update-version.sh` Issue: https://github.com/rapidsai/build-planning/issues/15 Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1496 --- CMakeLists.txt | 7 ++++--- ci/build_docs.sh | 4 +++- ci/check_style.sh | 3 ++- ci/release/update-version.sh | 19 ------------------- doxygen/Doxyfile | 2 +- fetch_rapids.cmake | 18 ------------------ python/CMakeLists.txt | 8 +++----- python/docs/conf.py | 11 +++++++++-- rapids_config.cmake | 34 ++++++++++++++++++++++++++++++++++ scripts/doxygen.sh | 3 +++ 10 files changed, 59 insertions(+), 50 deletions(-) delete mode 100644 fetch_rapids.cmake create mode 100644 rapids_config.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 086069b09..56454d4b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) -include(fetch_rapids.cmake) +include(rapids_config.cmake) include(rapids-cmake) include(rapids-cpm) @@ -23,7 +23,7 @@ include(rapids-find) project( RMM - VERSION 24.04.00 + VERSION "${RAPIDS_VERSION}" LANGUAGES CXX) # Write the version header @@ -173,7 +173,8 @@ rapids_export( add_custom_command( OUTPUT RMM_DOXYGEN WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doxygen - COMMAND doxygen Doxyfile + COMMAND ${CMAKE_COMMAND} -E env "RAPIDS_VERSION=${RAPIDS_VERSION}" + "RAPIDS_VERSION_MAJOR_MINOR=${RAPIDS_VERSION_MAJOR_MINOR}" doxygen Doxyfile VERBATIM COMMENT "Custom command for RMM doxygen docs") diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 1979e9a2c..d5be5d33b 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -25,7 +25,9 @@ rapids-mamba-retry install \ --channel "${PYTHON_CHANNEL}" \ rmm librmm -export RAPIDS_VERSION_NUMBER="24.04" +export RAPIDS_VERSION="$(rapids-version)" +export RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)" +export RAPIDS_VERSION_NUMBER="$RAPIDS_VERSION_MAJOR_MINOR" export RAPIDS_DOCS_DIR="$(mktemp -d)" rapids-logger "Build CPP docs" diff --git a/ci/check_style.sh b/ci/check_style.sh index 66c7e36f3..860cd56f9 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -14,7 +14,8 @@ rapids-dependency-file-generator \ rapids-mamba-retry env create --force -f env.yaml -n checks conda activate checks -FORMAT_FILE_URL=https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-24.04/cmake-format-rapids-cmake.json +RAPIDS_VERSION_NUMBER="$(rapids-version-major-minor)" +FORMAT_FILE_URL="https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${RAPIDS_VERSION_NUMBER}/cmake-format-rapids-cmake.json" export RAPIDS_CMAKE_FORMAT_FILE=/tmp/rapids_cmake_ci/cmake-formats-rapids-cmake.json mkdir -p $(dirname ${RAPIDS_CMAKE_FORMAT_FILE}) wget -O ${RAPIDS_CMAKE_FORMAT_FILE} ${FORMAT_FILE_URL} diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index b7ea5892f..2a6e550df 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -32,28 +32,9 @@ function sed_runner() { sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak } -# cpp update -sed_runner 's/'" VERSION .*"'/'" VERSION ${NEXT_FULL_TAG}"'/g' CMakeLists.txt - -# Python update -sed_runner 's/'"rmm_version .*)"'/'"rmm_version ${NEXT_FULL_TAG})"'/g' python/CMakeLists.txt - # Centralized version file update echo "${NEXT_FULL_TAG}" > VERSION -# rapids-cmake version -sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' fetch_rapids.cmake - -# cmake-format rapids-cmake definitions -sed_runner 's/'"branch-.*\/cmake-format-rapids-cmake.json"'/'"branch-${NEXT_SHORT_TAG}\/cmake-format-rapids-cmake.json"'/g' ci/check_style.sh - -# doxyfile update -sed_runner 's/'"PROJECT_NUMBER = .*"'/'"PROJECT_NUMBER = ${NEXT_SHORT_TAG}"'/g' doxygen/Doxyfile - -# sphinx docs update -sed_runner 's/'"version =.*"'/'"version = \"${NEXT_SHORT_TAG}\""'/g' python/docs/conf.py -sed_runner 's/'"release =.*"'/'"release = \"${NEXT_FULL_TAG}\""'/g' python/docs/conf.py - # CI files for FILE in .github/workflows/*.yaml; do sed_runner "/shared-workflows/ s/@.*/@branch-${NEXT_SHORT_TAG}/g" "${FILE}" diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index d1a5e8869..a5c183236 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = RMM # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 24.04 +PROJECT_NUMBER = $(RAPIDS_VERSION_MAJOR_MINOR) # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/fetch_rapids.cmake b/fetch_rapids.cmake deleted file mode 100644 index 684b1e140..000000000 --- a/fetch_rapids.cmake +++ /dev/null @@ -1,18 +0,0 @@ -# ============================================================================= -# Copyright (c) 2023, 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}/RMM_RAPIDS.cmake) - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-24.04/RAPIDS.cmake - ${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) -endif() -include(${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS.cmake) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 6a7490133..87752ff24 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -14,13 +14,11 @@ cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) -set(rmm_version 24.04.00) - -include(../fetch_rapids.cmake) +include(../rapids_config.cmake) project( rmm-python - VERSION ${rmm_version} + VERSION "${RAPIDS_VERSION}" LANGUAGES CXX) option(FIND_RMM_CPP "Search for existing RMM C++ installations before defaulting to local files" @@ -28,7 +26,7 @@ option(FIND_RMM_CPP "Search for existing RMM C++ installations before defaulting # If the user requested it we attempt to find RMM. if(FIND_RMM_CPP) - find_package(rmm ${rmm_version}) + find_package(rmm "${RAPIDS_VERSION}") else() set(rmm_FOUND OFF) endif() diff --git a/python/docs/conf.py b/python/docs/conf.py index 3595a8f36..d66e9d30c 100644 --- a/python/docs/conf.py +++ b/python/docs/conf.py @@ -13,6 +13,10 @@ import os import re +from packaging.version import Version + +import rmm + # -- Project information ----------------------------------------------------- project = "rmm" @@ -23,10 +27,13 @@ # |version| and |release|, also used in various other places throughout the # built documents. # +RMM_VERSION = Version(rmm.__version__) # The short X.Y version. -version = "24.04" +version = f"{RMM_VERSION.major:02}.{RMM_VERSION.minor:02}" # The full version, including alpha/beta/rc tags. -release = "24.04.00" +release = ( + f"{RMM_VERSION.major:02}.{RMM_VERSION.minor:02}.{RMM_VERSION.micro:02}" +) # -- General configuration --------------------------------------------------- diff --git a/rapids_config.cmake b/rapids_config.cmake new file mode 100644 index 000000000..84c20c01e --- /dev/null +++ b/rapids_config.cmake @@ -0,0 +1,34 @@ +# ============================================================================= +# Copyright (c) 2018-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. +# ============================================================================= +file(READ "${CMAKE_CURRENT_LIST_DIR}/VERSION" _rapids_version) +if(_rapids_version MATCHES [[^([0-9][0-9])\.([0-9][0-9])\.([0-9][0-9])]]) + set(RAPIDS_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(RAPIDS_VERSION_MINOR "${CMAKE_MATCH_2}") + set(RAPIDS_VERSION_PATCH "${CMAKE_MATCH_3}") + set(RAPIDS_VERSION_MAJOR_MINOR "${RAPIDS_VERSION_MAJOR}.${RAPIDS_VERSION_MINOR}") + set(RAPIDS_VERSION "${RAPIDS_VERSION_MAJOR}.${RAPIDS_VERSION_MINOR}.${RAPIDS_VERSION_PATCH}") +else() + string(REPLACE "\n" "\n " _rapids_version_formatted " ${_rapids_version}") + message( + FATAL_ERROR + "Could not determine RAPIDS version. Contents of VERSION file:\n${_rapids_version_formatted}") +endif() + +if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake") + file( + DOWNLOAD + "https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${RAPIDS_VERSION_MAJOR_MINOR}/RAPIDS.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake") +endif() +include("${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake") diff --git a/scripts/doxygen.sh b/scripts/doxygen.sh index c584723ae..372a9f27d 100755 --- a/scripts/doxygen.sh +++ b/scripts/doxygen.sh @@ -21,6 +21,9 @@ if [ ! $(version "$DOXYGEN_VERSION") -eq $(version "1.9.1") ] ; then exit 0 fi +export RAPIDS_VERSION="$(sed -E -e 's/^([0-9]{2})\.([0-9]{2})\.([0-9]{2}).*$/\1.\2.\3/' VERSION)" +export RAPIDS_VERSION_MAJOR_MINOR="$(sed -E -e 's/^([0-9]{2})\.([0-9]{2})\.([0-9]{2}).*$/\1.\2/' VERSION)" + # Run doxygen, ignore missing tag files error TAG_ERROR1="error: Tag file '.*.tag' does not exist or is not a file. Skipping it..." TAG_ERROR2="error: cannot open tag file .*.tag for writing" From 2c161dad4aa732e7a6901ab512aa9a0fac85afc4 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 13 Mar 2024 08:31:43 -0500 Subject: [PATCH 376/675] Add upper bound to prevent usage of NumPy 2 (#1501) NumPy 2 is expected to be released in the near future. For the RAPIDS 24.04 release, we will pin to `numpy>=1.23,<2.0a0`. This PR adds an upper bound to affected RAPIDS repositories. xref: https://github.com/rapidsai/build-planning/issues/29 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) - Mark Harris (https://github.com/harrism) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1501 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-122_arch-x86_64.yaml | 2 +- conda/recipes/rmm/meta.yaml | 2 +- dependencies.yaml | 2 +- python/pyproject.toml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index d555eb104..c4bbcccd2 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -26,7 +26,7 @@ dependencies: - nbsphinx - ninja - numba>=0.57 -- numpy>=1.23 +- numpy>=1.23,<2.0a0 - numpydoc - nvcc_linux-64=11.8 - pre-commit diff --git a/conda/environments/all_cuda-122_arch-x86_64.yaml b/conda/environments/all_cuda-122_arch-x86_64.yaml index 7c58c0024..63876715a 100644 --- a/conda/environments/all_cuda-122_arch-x86_64.yaml +++ b/conda/environments/all_cuda-122_arch-x86_64.yaml @@ -25,7 +25,7 @@ dependencies: - nbsphinx - ninja - numba>=0.57 -- numpy>=1.23 +- numpy>=1.23,<2.0a0 - numpydoc - pre-commit - pytest diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 01ac8cea8..764c3f75b 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -73,7 +73,7 @@ requirements: {% endif %} - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - numba >=0.57 - - numpy >=1.23 + - numpy >=1.23,<2.0a0 test: imports: diff --git a/dependencies.yaml b/dependencies.yaml index ec6e33e68..548999f1b 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -217,7 +217,7 @@ dependencies: - output_types: [conda, requirements, pyproject] packages: - numba>=0.57 - - numpy>=1.23 + - numpy>=1.23,<2.0a0 specific: - output_types: [conda, requirements, pyproject] matrices: diff --git a/python/pyproject.toml b/python/pyproject.toml index f9151ff8d..3f294d180 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -35,7 +35,7 @@ requires-python = ">=3.9" dependencies = [ "cuda-python>=11.7.1,<12.0a0", "numba>=0.57", - "numpy>=1.23", + "numpy>=1.23,<2.0a0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../dependencies.yaml and run `rapids-dependency-file-generator`. classifiers = [ "Intended Audience :: Developers", From a98931b91ae8109f478469fd4eec388cf86b81fb Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Thu, 14 Mar 2024 09:13:18 -0700 Subject: [PATCH 377/675] Replace all internal usage of `get_upstream` with `get_upstream_resource` (#1491) We want to get away from raw resources, so prepare deprecation of it by replacing all internal usages This PR relies on preparation in downstream repositories Authors: - Michael Schellenberger Costa (https://github.com/miscco) - Bradley Dice (https://github.com/bdice) Approvers: - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1491 --- include/rmm/mr/device/aligned_resource_adaptor.hpp | 3 ++- include/rmm/mr/device/binning_memory_resource.hpp | 13 ++++++------- .../mr/device/failure_callback_resource_adaptor.hpp | 4 ++-- .../rmm/mr/device/fixed_size_memory_resource.hpp | 4 ++-- include/rmm/mr/device/limiting_resource_adaptor.hpp | 4 ++-- include/rmm/mr/device/logging_resource_adaptor.hpp | 4 ++-- include/rmm/mr/device/pool_memory_resource.hpp | 4 ++-- .../rmm/mr/device/statistics_resource_adaptor.hpp | 4 ++-- .../rmm/mr/device/thread_safe_resource_adaptor.hpp | 8 +++----- include/rmm/mr/device/tracking_resource_adaptor.hpp | 4 ++-- tests/device_check_resource_adaptor.hpp | 4 ++-- tests/mr/device/adaptor_tests.cpp | 9 --------- tests/mr/device/statistics_mr_tests.cpp | 5 +++-- tests/mr/device/tracking_mr_tests.cpp | 5 +++-- 14 files changed, 33 insertions(+), 42 deletions(-) diff --git a/include/rmm/mr/device/aligned_resource_adaptor.hpp b/include/rmm/mr/device/aligned_resource_adaptor.hpp index c3213afdf..a91056dfa 100644 --- a/include/rmm/mr/device/aligned_resource_adaptor.hpp +++ b/include/rmm/mr/device/aligned_resource_adaptor.hpp @@ -168,7 +168,8 @@ class aligned_resource_adaptor final : public device_memory_resource { { if (this == &other) { return true; } auto cast = dynamic_cast const*>(&other); - return cast != nullptr && upstream_->is_equal(*cast->get_upstream()) && + if (cast == nullptr) { return false; } + return get_upstream_resource() == cast->get_upstream_resource() && alignment_ == cast->alignment_ && alignment_threshold_ == cast->alignment_threshold_; } diff --git a/include/rmm/mr/device/binning_memory_resource.hpp b/include/rmm/mr/device/binning_memory_resource.hpp index 9b0c04f3d..2649a17b8 100644 --- a/include/rmm/mr/device/binning_memory_resource.hpp +++ b/include/rmm/mr/device/binning_memory_resource.hpp @@ -149,13 +149,13 @@ class binning_memory_resource final : public device_memory_resource { * Chooses a memory_resource that allocates the smallest blocks at least as large as `bytes`. * * @param bytes Requested allocation size in bytes - * @return rmm::mr::device_memory_resource& memory_resource that can allocate the requested size. + * @return Get the resource reference for the requested size. */ - device_memory_resource* get_resource(std::size_t bytes) + rmm::device_async_resource_ref get_resource_ref(std::size_t bytes) { auto iter = resource_bins_.lower_bound(bytes); - return (iter != resource_bins_.cend()) ? iter->second - : static_cast(get_upstream()); + return (iter != resource_bins_.cend()) ? rmm::device_async_resource_ref{iter->second} + : get_upstream_resource(); } /** @@ -170,7 +170,7 @@ class binning_memory_resource final : public device_memory_resource { void* do_allocate(std::size_t bytes, cuda_stream_view stream) override { if (bytes <= 0) { return nullptr; } - return get_resource(bytes)->allocate(bytes, stream); + return get_resource_ref(bytes).allocate_async(bytes, stream); } /** @@ -183,8 +183,7 @@ class binning_memory_resource final : public device_memory_resource { */ void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override { - auto res = get_resource(bytes); - if (res != nullptr) { res->deallocate(ptr, bytes, stream); } + get_resource_ref(bytes).deallocate_async(ptr, bytes, stream); } Upstream* upstream_mr_; // The upstream memory_resource from which to allocate blocks. diff --git a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp index 5a1a09b82..53bc572c2 100644 --- a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp +++ b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp @@ -183,8 +183,8 @@ class failure_callback_resource_adaptor final : public device_memory_resource { { if (this == &other) { return true; } auto cast = dynamic_cast const*>(&other); - return cast != nullptr ? upstream_->is_equal(*cast->get_upstream()) - : upstream_->is_equal(other); + if (cast == nullptr) { return upstream_->is_equal(other); } + return get_upstream_resource() == cast->get_upstream_resource(); } Upstream* upstream_; // the upstream resource used for satisfying allocation requests diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index 8318dbfa1..da9476b1e 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -156,7 +156,7 @@ class fixed_size_memory_resource */ free_list blocks_from_upstream(cuda_stream_view stream) { - void* ptr = get_upstream()->allocate(upstream_chunk_size_, stream); + void* ptr = get_upstream_resource().allocate_async(upstream_chunk_size_, stream); block_type block{ptr}; upstream_blocks_.push_back(block); @@ -211,7 +211,7 @@ class fixed_size_memory_resource lock_guard lock(this->get_mutex()); for (auto block : upstream_blocks_) { - get_upstream()->deallocate(block.pointer(), upstream_chunk_size_); + get_upstream_resource().deallocate(block.pointer(), upstream_chunk_size_); } upstream_blocks_.clear(); } diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index 174ada34b..aa2361d1f 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -162,8 +162,8 @@ class limiting_resource_adaptor final : public device_memory_resource { { if (this == &other) { return true; } auto const* cast = dynamic_cast const*>(&other); - if (cast != nullptr) { return upstream_->is_equal(*cast->get_upstream()); } - return upstream_->is_equal(other); + if (cast == nullptr) { return upstream_->is_equal(other); } + return get_upstream_resource() == cast->get_upstream_resource(); } // maximum bytes this allocator is allowed to allocate. diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 885908937..61d00cafc 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -277,8 +277,8 @@ class logging_resource_adaptor final : public device_memory_resource { { if (this == &other) { return true; } auto const* cast = dynamic_cast const*>(&other); - if (cast != nullptr) { return upstream_->is_equal(*cast->get_upstream()); } - return upstream_->is_equal(other); + if (cast == nullptr) { return upstream_->is_equal(other); } + return get_upstream_resource() == cast->get_upstream_resource(); } // make_logging_adaptor needs access to private get_default_filename diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 61ef75bd0..4cbdeef4a 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -503,7 +503,7 @@ class pool_memory_resource final if (size == 0) { return {}; } try { - void* ptr = get_upstream()->allocate_async(size, stream); + void* ptr = get_upstream_resource().allocate_async(size, stream); return std::optional{ *upstream_blocks_.emplace(static_cast(ptr), size, true).first}; } catch (std::exception const& e) { @@ -570,7 +570,7 @@ class pool_memory_resource final lock_guard lock(this->get_mutex()); for (auto block : upstream_blocks_) { - get_upstream()->deallocate(block.pointer(), block.size()); + get_upstream_resource().deallocate(block.pointer(), block.size()); } upstream_blocks_.clear(); #ifdef RMM_POOL_TRACK_ALLOCATIONS diff --git a/include/rmm/mr/device/statistics_resource_adaptor.hpp b/include/rmm/mr/device/statistics_resource_adaptor.hpp index 9febf9ef5..d072d5886 100644 --- a/include/rmm/mr/device/statistics_resource_adaptor.hpp +++ b/include/rmm/mr/device/statistics_resource_adaptor.hpp @@ -209,8 +209,8 @@ class statistics_resource_adaptor final : public device_memory_resource { { if (this == &other) { return true; } auto cast = dynamic_cast const*>(&other); - return cast != nullptr ? upstream_->is_equal(*cast->get_upstream()) - : upstream_->is_equal(other); + if (cast == nullptr) { return upstream_->is_equal(other); } + return get_upstream_resource() == cast->get_upstream_resource(); } counter bytes_; // peak, current and total allocated bytes diff --git a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp index 5daf5f3f9..64a6f8ad5 100644 --- a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp +++ b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp @@ -119,11 +119,9 @@ class thread_safe_resource_adaptor final : public device_memory_resource { bool do_is_equal(device_memory_resource const& other) const noexcept override { if (this == &other) { return true; } - auto thread_safe_other = dynamic_cast const*>(&other); - if (thread_safe_other != nullptr) { - return upstream_->is_equal(*thread_safe_other->get_upstream()); - } - return upstream_->is_equal(other); + auto cast = dynamic_cast const*>(&other); + if (cast == nullptr) { return upstream_->is_equal(other); } + return get_upstream_resource() == cast->get_upstream_resource(); } std::mutex mutable mtx; // mutex for thread safe access to upstream diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index d337da21c..c49674849 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -264,8 +264,8 @@ class tracking_resource_adaptor final : public device_memory_resource { { if (this == &other) { return true; } auto cast = dynamic_cast const*>(&other); - return cast != nullptr ? upstream_->is_equal(*cast->get_upstream()) - : upstream_->is_equal(other); + if (cast == nullptr) { return upstream_->is_equal(other); } + return get_upstream_resource() == cast->get_upstream_resource(); } bool capture_stacks_; // whether or not to capture call stacks diff --git a/tests/device_check_resource_adaptor.hpp b/tests/device_check_resource_adaptor.hpp index 4f75b191c..fcb578fdf 100644 --- a/tests/device_check_resource_adaptor.hpp +++ b/tests/device_check_resource_adaptor.hpp @@ -64,8 +64,8 @@ class device_check_resource_adaptor final : public rmm::mr::device_memory_resour { if (this == &other) { return true; } auto const* cast = dynamic_cast(&other); - if (cast != nullptr) { return upstream_->is_equal(*cast->get_upstream()); } - return upstream_->is_equal(other); + if (cast == nullptr) { return upstream_->is_equal(other); } + return get_upstream_resource() == cast->get_upstream_resource(); } rmm::cuda_device_id device_id; diff --git a/tests/mr/device/adaptor_tests.cpp b/tests/mr/device/adaptor_tests.cpp index c05c9b641..a757a78b0 100644 --- a/tests/mr/device/adaptor_tests.cpp +++ b/tests/mr/device/adaptor_tests.cpp @@ -135,15 +135,6 @@ TYPED_TEST(AdaptorTest, Equality) } } -TYPED_TEST(AdaptorTest, GetUpstream) -{ - if constexpr (std::is_same_v) { - EXPECT_TRUE(this->mr->wrapped().get_upstream()->is_equal(this->cuda)); - } else { - EXPECT_TRUE(this->mr->get_upstream()->is_equal(this->cuda)); - } -} - TYPED_TEST(AdaptorTest, GetUpstreamResource) { rmm::device_async_resource_ref expected{this->cuda}; diff --git a/tests/mr/device/statistics_mr_tests.cpp b/tests/mr/device/statistics_mr_tests.cpp index 59c356b1e..8fd12f49b 100644 --- a/tests/mr/device/statistics_mr_tests.cpp +++ b/tests/mr/device/statistics_mr_tests.cpp @@ -127,7 +127,8 @@ TEST(StatisticsTest, PeakAllocations) TEST(StatisticsTest, MultiTracking) { - statistics_adaptor mr{rmm::mr::get_current_device_resource()}; + auto* orig_device_resource = rmm::mr::get_current_device_resource(); + statistics_adaptor mr{orig_device_resource}; rmm::mr::set_current_device_resource(&mr); std::vector> allocations; @@ -171,7 +172,7 @@ TEST(StatisticsTest, MultiTracking) EXPECT_EQ(inner_mr.get_allocations_counter().peak, 5); // Reset the current device resource - rmm::mr::set_current_device_resource(mr.get_upstream()); + rmm::mr::set_current_device_resource(orig_device_resource); } TEST(StatisticsTest, NegativeInnerTracking) diff --git a/tests/mr/device/tracking_mr_tests.cpp b/tests/mr/device/tracking_mr_tests.cpp index 65d2f955c..7c2532c60 100644 --- a/tests/mr/device/tracking_mr_tests.cpp +++ b/tests/mr/device/tracking_mr_tests.cpp @@ -101,7 +101,8 @@ TEST(TrackingTest, AllocationsLeftWithoutStacks) TEST(TrackingTest, MultiTracking) { - tracking_adaptor mr{rmm::mr::get_current_device_resource(), true}; + auto* orig_device_resource = rmm::mr::get_current_device_resource(); + tracking_adaptor mr{orig_device_resource, true}; rmm::mr::set_current_device_resource(&mr); std::vector> allocations; @@ -140,7 +141,7 @@ TEST(TrackingTest, MultiTracking) EXPECT_EQ(inner_mr.get_allocated_bytes(), 0); // Reset the current device resource - rmm::mr::set_current_device_resource(mr.get_upstream()); + rmm::mr::set_current_device_resource(orig_device_resource); } TEST(TrackingTest, NegativeInnerTracking) From fb23a13ad8390e4ecfb8ebbf7c13c72d52f4a0dd Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Fri, 15 Mar 2024 12:03:48 -0400 Subject: [PATCH 378/675] DOC v24.06 Updates [skip ci] --- .../cuda11.8-conda/devcontainer.json | 4 ++-- .devcontainer/cuda11.8-pip/devcontainer.json | 4 ++-- .../cuda12.2-conda/devcontainer.json | 4 ++-- .devcontainer/cuda12.2-pip/devcontainer.json | 4 ++-- .github/workflows/build.yaml | 12 +++++------ .github/workflows/pr.yaml | 20 +++++++++---------- .github/workflows/test.yaml | 6 +++--- VERSION | 2 +- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.devcontainer/cuda11.8-conda/devcontainer.json b/.devcontainer/cuda11.8-conda/devcontainer.json index 1403b8cc4..260e93e10 100644 --- a/.devcontainer/cuda11.8-conda/devcontainer.json +++ b/.devcontainer/cuda11.8-conda/devcontainer.json @@ -5,12 +5,12 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:24.04-cpp-cuda11.8-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.06-cpp-cuda11.8-mambaforge-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.4": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.6": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda11.8-pip/devcontainer.json b/.devcontainer/cuda11.8-pip/devcontainer.json index 90a3732f4..667519658 100644 --- a/.devcontainer/cuda11.8-pip/devcontainer.json +++ b/.devcontainer/cuda11.8-pip/devcontainer.json @@ -5,12 +5,12 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:24.04-cpp-cuda11.8-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.06-cpp-cuda11.8-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.4": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.6": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.2-conda/devcontainer.json b/.devcontainer/cuda12.2-conda/devcontainer.json index 8dc4f8be9..8ca9ac220 100644 --- a/.devcontainer/cuda12.2-conda/devcontainer.json +++ b/.devcontainer/cuda12.2-conda/devcontainer.json @@ -5,12 +5,12 @@ "args": { "CUDA": "12.2", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:24.04-cpp-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.06-cpp-mambaforge-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.4": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.6": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.2-pip/devcontainer.json b/.devcontainer/cuda12.2-pip/devcontainer.json index 66d332573..0309a478a 100644 --- a/.devcontainer/cuda12.2-pip/devcontainer.json +++ b/.devcontainer/cuda12.2-pip/devcontainer.json @@ -5,12 +5,12 @@ "args": { "CUDA": "12.2", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:24.04-cpp-cuda12.2-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.06-cpp-cuda12.2-ubuntu22.04" } }, "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.4": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.6": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e4113d5c5..f22d60673 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -78,7 +78,7 @@ jobs: wheel-publish: needs: wheel-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index c0a9a0841..2abbfd078 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -22,40 +22,40 @@ jobs: - wheel-tests - devcontainer secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.06 checks: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.06 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.06 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.06 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.06 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.06 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.06 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -65,20 +65,20 @@ jobs: wheel-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.06 with: build_type: pull-request script: ci/build_wheel.sh wheel-tests: needs: wheel-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.06 with: build_type: pull-request script: ci/test_wheel.sh devcontainer: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@fix/devcontainer-json-location + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.06 with: arch: '["amd64"]' cuda: '["12.2"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0e7938310..747f9f544 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.06 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.06 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.06 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/VERSION b/VERSION index 4a2fe8aa5..0bff6981a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -24.04.00 +24.06.00 From 0651edf0fce5ebf53528382b475fc29a2f3afa67 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 27 Mar 2024 13:40:37 -0500 Subject: [PATCH 379/675] Use `conda env create --yes` instead of `--force`. (#1509) --- ci/build_docs.sh | 2 +- ci/check_style.sh | 2 +- ci/test_cpp.sh | 2 +- ci/test_python.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ci/build_docs.sh b/ci/build_docs.sh index d5be5d33b..1239bdac3 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -11,7 +11,7 @@ rapids-dependency-file-generator \ --file_key docs \ --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee env.yaml -rapids-mamba-retry env create --force -f env.yaml -n docs +rapids-mamba-retry env create --yes -f env.yaml -n docs conda activate docs rapids-print-env diff --git a/ci/check_style.sh b/ci/check_style.sh index 860cd56f9..b8478f312 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -11,7 +11,7 @@ rapids-dependency-file-generator \ --file_key checks \ --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee env.yaml -rapids-mamba-retry env create --force -f env.yaml -n checks +rapids-mamba-retry env create --yes -f env.yaml -n checks conda activate checks RAPIDS_VERSION_NUMBER="$(rapids-version-major-minor)" diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 1adef8778..e3ff28d9f 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -14,7 +14,7 @@ rapids-dependency-file-generator \ --file_key test_cpp \ --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch)" | tee env.yaml -rapids-mamba-retry env create --force -f env.yaml -n test +rapids-mamba-retry env create --yes -f env.yaml -n test # Temporarily allow unbound variables for conda activation. set +u diff --git a/ci/test_python.sh b/ci/test_python.sh index d549a44b5..b4e2791db 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -14,7 +14,7 @@ rapids-dependency-file-generator \ --file_key test_python \ --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee env.yaml -rapids-mamba-retry env create --force -f env.yaml -n test +rapids-mamba-retry env create --yes -f env.yaml -n test set +u conda activate test set -u From bd3f0d85c287bbc017b10f8c6177f60804c849aa Mon Sep 17 00:00:00 2001 From: GALI PREM SAGAR Date: Tue, 2 Apr 2024 01:09:37 -0500 Subject: [PATCH 380/675] Enable all tests for `arm` arch (#1510) This PR enables running all pytests for `arm64` jobs. Authors: - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - Jake Awe (https://github.com/AyodeAwe) - Mark Harris (https://github.com/harrism) - https://github.com/jakirkham URL: https://github.com/rapidsai/rmm/pull/1510 --- ci/test_wheel.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ci/test_wheel.sh b/ci/test_wheel.sh index aa2705afe..708b1d930 100755 --- a/ci/test_wheel.sh +++ b/ci/test_wheel.sh @@ -9,9 +9,4 @@ RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from- # echo to expand wildcard before adding `[extra]` requires for pip python -m pip install $(echo ./dist/rmm*.whl)[test] -# Run smoke tests for aarch64 pull requests -if [[ "$(arch)" == "aarch64" && ${RAPIDS_BUILD_TYPE} == "pull-request" ]]; then - python ./ci/wheel_smoke_test.py -else - python -m pytest ./python/rmm/tests -fi +python -m pytest ./python/rmm/tests From 8675b2c9ccaa33130cc2e5a291f3fff31f7c903d Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Wed, 3 Apr 2024 13:26:37 +0100 Subject: [PATCH 381/675] Explicitly use the current device resource in DeviceBuffer (#1514) Previously we were relying on the C++ and Python-level device resources to agree. But this need not be the case. To avoid this, first get the current device resource and then use it when allocating the wrapped C++ device_buffer when creating DeviceBuffers. - Closes #1506 Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1514 --- python/rmm/_lib/device_buffer.pxd | 26 ++++++++++++++++++++------ python/rmm/_lib/device_buffer.pyx | 22 ++++++++++++---------- python/rmm/_lib/memory_resource.pxd | 2 +- python/rmm/_lib/memory_resource.pyx | 2 +- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/python/rmm/_lib/device_buffer.pxd b/python/rmm/_lib/device_buffer.pxd index 3d5f29f9a..b48df21e7 100644 --- a/python/rmm/_lib/device_buffer.pxd +++ b/python/rmm/_lib/device_buffer.pxd @@ -17,17 +17,31 @@ from libcpp.memory cimport unique_ptr from rmm._cuda.stream cimport Stream from rmm._lib.cuda_stream_view cimport cuda_stream_view -from rmm._lib.memory_resource cimport DeviceMemoryResource +from rmm._lib.memory_resource cimport ( + DeviceMemoryResource, + device_memory_resource, +) cdef extern from "rmm/device_buffer.hpp" namespace "rmm" nogil: cdef cppclass device_buffer: device_buffer() - device_buffer(size_t size, cuda_stream_view stream) except + - device_buffer(const void* source_data, - size_t size, cuda_stream_view stream) except + - device_buffer(const device_buffer buf, - cuda_stream_view stream) except + + device_buffer( + size_t size, + cuda_stream_view stream, + device_memory_resource * + ) except + + device_buffer( + const void* source_data, + size_t size, + cuda_stream_view stream, + device_memory_resource * + ) except + + device_buffer( + const device_buffer buf, + cuda_stream_view stream, + device_memory_resource * + ) except + void reserve(size_t new_capacity, cuda_stream_view stream) except + void resize(size_t new_size, cuda_stream_view stream) except + void shrink_to_fit(cuda_stream_view stream) except + diff --git a/python/rmm/_lib/device_buffer.pyx b/python/rmm/_lib/device_buffer.pyx index d248d01ab..3ce10c5f6 100644 --- a/python/rmm/_lib/device_buffer.pyx +++ b/python/rmm/_lib/device_buffer.pyx @@ -32,7 +32,10 @@ from cuda.ccudart cimport ( cudaStream_t, ) -from rmm._lib.memory_resource cimport get_current_device_resource +from rmm._lib.memory_resource cimport ( + device_memory_resource, + get_current_device_resource, +) # The DeviceMemoryResource attribute could be released prematurely @@ -75,24 +78,23 @@ cdef class DeviceBuffer: >>> db = rmm.DeviceBuffer(size=5) """ cdef const void* c_ptr + cdef device_memory_resource * mr_ptr + # Save a reference to the MR and stream used for allocation + self.mr = get_current_device_resource() + self.stream = stream + mr_ptr = self.mr.get_mr() with nogil: c_ptr = ptr - if size == 0: - self.c_obj.reset(new device_buffer()) - elif c_ptr == NULL: - self.c_obj.reset(new device_buffer(size, stream.view())) + if c_ptr == NULL or size == 0: + self.c_obj.reset(new device_buffer(size, stream.view(), mr_ptr)) else: - self.c_obj.reset(new device_buffer(c_ptr, size, stream.view())) + self.c_obj.reset(new device_buffer(c_ptr, size, stream.view(), mr_ptr)) if stream.c_is_default(): stream.c_synchronize() - # Save a reference to the MR and stream used for allocation - self.mr = get_current_device_resource() - self.stream = stream - def __len__(self): return self.size diff --git a/python/rmm/_lib/memory_resource.pxd b/python/rmm/_lib/memory_resource.pxd index 0770fb8ed..f9c2e91de 100644 --- a/python/rmm/_lib/memory_resource.pxd +++ b/python/rmm/_lib/memory_resource.pxd @@ -34,7 +34,7 @@ cdef extern from "rmm/mr/device/device_memory_resource.hpp" \ cdef class DeviceMemoryResource: cdef shared_ptr[device_memory_resource] c_obj - cdef device_memory_resource* get_mr(self) + cdef device_memory_resource* get_mr(self) noexcept nogil cdef class UpstreamResourceAdaptor(DeviceMemoryResource): cdef readonly DeviceMemoryResource upstream_mr diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/_lib/memory_resource.pyx index 7458ca025..100d18b56 100644 --- a/python/rmm/_lib/memory_resource.pyx +++ b/python/rmm/_lib/memory_resource.pyx @@ -218,7 +218,7 @@ cdef extern from "rmm/mr/device/failure_callback_resource_adaptor.hpp" \ cdef class DeviceMemoryResource: - cdef device_memory_resource* get_mr(self): + cdef device_memory_resource* get_mr(self) noexcept nogil: """Get the underlying C++ memory resource object.""" return self.c_obj.get() From 48820cb6279be8d3781be046595e83197faa9e71 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Fri, 5 Apr 2024 16:52:27 +1100 Subject: [PATCH 382/675] Remove deprecated supports_streams and get_mem_info methods. (#1519) Fixes #1388 Fixes #1389 Fixes #1428 Fixes #1434 Removes the previously deprecated functions - `rmm::mr::device_memory_resource::supports_streams()` - `rmm::mr::device_memory_resource::supports_get_mem_info()` - `rmm::mr::device_memory_resource::get_mem_info()` Authors: - Mark Harris (https://github.com/harrism) Approvers: - Michael Schellenberger Costa (https://github.com/miscco) - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1519 --- .../rmm/mr/device/device_memory_resource.hpp | 46 ------------------- 1 file changed, 46 deletions(-) diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index 24190f2b4..5d7a60e2c 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -293,52 +293,6 @@ class device_memory_resource { return !do_is_equal(other); } - /** - * @brief Query whether the resource supports use of non-null CUDA streams for - * allocation/deallocation. - * - * @deprecated Functionality removed in favor of cuda::mr::async_memory_resource. - * - * @returns bool true if the resource supports non-null CUDA streams. - */ - [[deprecated("Functionality removed in favor of cuda::mr::async_memory_resource.")]] // - [[nodiscard]] virtual bool - supports_streams() const noexcept - { - return false; - } - - /** - * @brief Query whether the resource supports the get_mem_info API. - * - * @deprecated Use rmm::available_device_memory instead. - * - * @return bool true if the resource supports get_mem_info, false otherwise. - */ - [[deprecated("Use rmm::available_device_memory instead.")]] // - [[nodiscard]] virtual bool - supports_get_mem_info() const noexcept - { - return false; - }; - - /** - * @brief Queries the amount of free and total memory for the resource. - * - * @deprecated Use rmm::available_device_memory instead. - * - * @param stream the stream whose memory manager we want to retrieve - * - * @returns a pair containing the free memory in bytes in .first and total amount of memory in - * .second - */ - [[deprecated("Use rmm::available_device_memory instead.")]] // - [[nodiscard]] std::pair - get_mem_info(cuda_stream_view stream) const - { - return {0, 0}; - } - /** * @brief Enables the `cuda::mr::device_accessible` property * From cdf20a665cc3a0bc0da96975de336ce70408dcf6 Mon Sep 17 00:00:00 2001 From: GALI PREM SAGAR Date: Fri, 5 Apr 2024 17:00:43 -0500 Subject: [PATCH 383/675] Remove a file not being used (#1521) We removed using this file in : https://github.com/rapidsai/rmm/pull/1510, this pr deletes the file. Authors: - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - https://github.com/jakirkham - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1521 --- ci/wheel_smoke_test.py | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 ci/wheel_smoke_test.py diff --git a/ci/wheel_smoke_test.py b/ci/wheel_smoke_test.py deleted file mode 100644 index 737c0b605..000000000 --- a/ci/wheel_smoke_test.py +++ /dev/null @@ -1,5 +0,0 @@ -import rmm - -if __name__ == "__main__": - buf = rmm.DeviceBuffer(size=100) - assert buf.size == 100 From 6771b7174a3c0535eca2ca2e4099e87c6d715c22 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Wed, 10 Apr 2024 20:02:25 +1000 Subject: [PATCH 384/675] Fix ordering / heading levels in README.md and python example in guide.md (#1513) This is a minor fix to reorder some of the C++ docs in README.md and fix heading levels. It also adds prompt characters to the pytorch allocator example in the Python guide.md to be consistent with other examples in the doc. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Lawrence Mitchell (https://github.com/wence-) URL: https://github.com/rapidsai/rmm/pull/1513 --- README.md | 102 +++++++++++++++++++++---------------------- python/docs/guide.md | 6 +-- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 9ec8cbf47..0fe848fea 100644 --- a/README.md +++ b/README.md @@ -207,38 +207,7 @@ alignment argument. All allocations are required to be aligned to at least 256B. `device_memory_resource` adds an additional `cuda_stream_view` argument to allow specifying the stream on which to perform the (de)allocation. -## `cuda_stream_view` and `cuda_stream` - -`rmm::cuda_stream_view` is a simple non-owning wrapper around a CUDA `cudaStream_t`. This wrapper's -purpose is to provide strong type safety for stream types. (`cudaStream_t` is an alias for a pointer, -which can lead to ambiguity in APIs when it is assigned `0`.) All RMM stream-ordered APIs take a -`rmm::cuda_stream_view` argument. - -`rmm::cuda_stream` is a simple owning wrapper around a CUDA `cudaStream_t`. This class provides -RAII semantics (constructor creates the CUDA stream, destructor destroys it). An `rmm::cuda_stream` -can never represent the CUDA default stream or per-thread default stream; it only ever represents -a single non-default stream. `rmm::cuda_stream` cannot be copied, but can be moved. - -## `cuda_stream_pool` - -`rmm::cuda_stream_pool` provides fast access to a pool of CUDA streams. This class can be used to -create a set of `cuda_stream` objects whose lifetime is equal to the `cuda_stream_pool`. Using the -stream pool can be faster than creating the streams on the fly. The size of the pool is configurable. -Depending on this size, multiple calls to `cuda_stream_pool::get_stream()` may return instances of -`rmm::cuda_stream_view` that represent identical CUDA streams. - -### Thread Safety - -All current device memory resources are thread safe unless documented otherwise. More specifically, -calls to memory resource `allocate()` and `deallocate()` methods are safe with respect to calls to -either of these functions from other threads. They are _not_ thread safe with respect to -construction and destruction of the memory resource object. - -Note that a class `thread_safe_resource_adapter` is provided which can be used to adapt a memory -resource that is not thread safe to be thread safe (as described above). This adapter is not needed -with any current RMM device memory resources. - -### Stream-ordered Memory Allocation +## Stream-ordered Memory Allocation `rmm::mr::device_memory_resource` is a base class that provides stream-ordered memory allocation. This allows optimizations such as re-using memory deallocated on the same stream without the @@ -270,16 +239,16 @@ For further information about stream-ordered memory allocation semantics, read Allocator](https://developer.nvidia.com/blog/using-cuda-stream-ordered-memory-allocator-part-1/) on the NVIDIA Developer Blog. -### Available Resources +## Available Device Resources RMM provides several `device_memory_resource` derived classes to satisfy various user requirements. For more detailed information about these resources, see their respective documentation. -#### `cuda_memory_resource` +### `cuda_memory_resource` Allocates and frees device memory using `cudaMalloc` and `cudaFree`. -#### `managed_memory_resource` +### `managed_memory_resource` Allocates and frees device memory using `cudaMallocManaged` and `cudaFree`. @@ -287,22 +256,22 @@ Note that `managed_memory_resource` cannot be used with NVIDIA Virtual GPU Softw with virtual machines or hypervisors) because [NVIDIA CUDA Unified Memory is not supported by NVIDIA vGPU](https://docs.nvidia.com/grid/latest/grid-vgpu-user-guide/index.html#cuda-open-cl-support-vgpu). -#### `pool_memory_resource` +### `pool_memory_resource` A coalescing, best-fit pool sub-allocator. -#### `fixed_size_memory_resource` +### `fixed_size_memory_resource` A memory resource that can only allocate a single fixed size. Average allocation and deallocation cost is constant. -#### `binning_memory_resource` +### `binning_memory_resource` Configurable to use multiple upstream memory resources for allocations that fall within different bin sizes. Often configured with multiple bins backed by `fixed_size_memory_resource`s and a single `pool_memory_resource` for allocations larger than the largest bin size. -### Default Resources and Per-device Resources +## Default Resources and Per-device Resources RMM users commonly need to configure a `device_memory_resource` object to use for all allocations where another resource has not explicitly been provided. A common example is configuring a @@ -327,7 +296,7 @@ Accessing and modifying the default resource is done through two functions: `get_current_device_resource()` - For more explicit control, you can use `set_per_device_resource()`, which takes a device ID. -#### Example +### Example ```c++ rmm::mr::cuda_memory_resource cuda_mr; @@ -339,7 +308,7 @@ rmm::mr::set_current_device_resource(&pool_mr); // Updates the current device re rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource(); // Points to `pool_mr` ``` -#### Multiple Devices +### Multiple Devices A `device_memory_resource` should only be used when the active CUDA device is the same device that was active when the `device_memory_resource` was created. Otherwise behavior is undefined. @@ -386,17 +355,48 @@ line of the error comment. } ``` -### Allocators +## `cuda_stream_view` and `cuda_stream` + +`rmm::cuda_stream_view` is a simple non-owning wrapper around a CUDA `cudaStream_t`. This wrapper's +purpose is to provide strong type safety for stream types. (`cudaStream_t` is an alias for a pointer, +which can lead to ambiguity in APIs when it is assigned `0`.) All RMM stream-ordered APIs take a +`rmm::cuda_stream_view` argument. + +`rmm::cuda_stream` is a simple owning wrapper around a CUDA `cudaStream_t`. This class provides +RAII semantics (constructor creates the CUDA stream, destructor destroys it). An `rmm::cuda_stream` +can never represent the CUDA default stream or per-thread default stream; it only ever represents +a single non-default stream. `rmm::cuda_stream` cannot be copied, but can be moved. + +## `cuda_stream_pool` + +`rmm::cuda_stream_pool` provides fast access to a pool of CUDA streams. This class can be used to +create a set of `cuda_stream` objects whose lifetime is equal to the `cuda_stream_pool`. Using the +stream pool can be faster than creating the streams on the fly. The size of the pool is configurable. +Depending on this size, multiple calls to `cuda_stream_pool::get_stream()` may return instances of +`rmm::cuda_stream_view` that represent identical CUDA streams. + +## Thread Safety + +All current device memory resources are thread safe unless documented otherwise. More specifically, +calls to memory resource `allocate()` and `deallocate()` methods are safe with respect to calls to +either of these functions from other threads. They are _not_ thread safe with respect to +construction and destruction of the memory resource object. + +Note that a class `thread_safe_resource_adapter` is provided which can be used to adapt a memory +resource that is not thread safe to be thread safe (as described above). This adapter is not needed +with any current RMM device memory resources. + +## Allocators C++ interfaces commonly allow customizable memory allocation through an [`Allocator`](https://en.cppreference.com/w/cpp/named_req/Allocator) object. RMM provides several `Allocator` and `Allocator`-like classes. -#### `polymorphic_allocator` +### `polymorphic_allocator` A [stream-ordered](#stream-ordered-memory-allocation) allocator similar to [`std::pmr::polymorphic_allocator`](https://en.cppreference.com/w/cpp/memory/polymorphic_allocator). Unlike the standard C++ `Allocator` interface, the `allocate` and `deallocate` functions take a `cuda_stream_view` indicating the stream on which the (de)allocation occurs. -#### `stream_allocator_adaptor` +### `stream_allocator_adaptor` `stream_allocator_adaptor` can be used to adapt a stream-ordered allocator to present a standard `Allocator` interface to consumers that may not be designed to work with a stream-ordered interface. @@ -415,7 +415,7 @@ auto p = adapted.allocate(100); adapted.deallocate(p,100); ``` -#### `thrust_allocator` +### `thrust_allocator` `thrust_allocator` is a device memory allocator that uses the strongly typed `thrust::device_ptr`, making it usable with containers like `thrust::device_vector`. @@ -497,13 +497,13 @@ Similar to `device_memory_resource`, it has two key functions for (de)allocation Unlike `device_memory_resource`, the `host_memory_resource` interface and behavior is identical to `std::pmr::memory_resource`. -### Available Resources +## Available Host Resources -#### `new_delete_resource` +### `new_delete_resource` Uses the global `operator new` and `operator delete` to allocate host memory. -#### `pinned_memory_resource` +### `pinned_memory_resource` Allocates "pinned" host memory using `cuda(Malloc/Free)Host`. @@ -611,7 +611,7 @@ resources are detectable with Compute Sanitizer Memcheck. It may be possible in the future to add support for memory bounds checking with other memory resources using NVTX APIs. -## Using RMM in Python Code +# Using RMM in Python There are two ways to use RMM in Python code: @@ -622,7 +622,7 @@ There are two ways to use RMM in Python code: RMM provides a `MemoryResource` abstraction to control _how_ device memory is allocated in both the above uses. -### DeviceBuffers +## DeviceBuffer A DeviceBuffer represents an **untyped, uninitialized device memory allocation**. DeviceBuffers can be created by providing the @@ -662,7 +662,7 @@ host: array([1., 2., 3.]) ``` -### MemoryResource objects +## MemoryResource objects `MemoryResource` objects are used to configure how device memory allocations are made by RMM. diff --git a/python/docs/guide.md b/python/docs/guide.md index c06135ca8..968be8586 100644 --- a/python/docs/guide.md +++ b/python/docs/guide.md @@ -182,8 +182,8 @@ for memory allocations using their by configuring the current allocator. ```python -from rmm.allocators.torch import rmm_torch_allocator -import torch +>>> from rmm.allocators.torch import rmm_torch_allocator +>>> import torch -torch.cuda.memory.change_current_allocator(rmm_torch_allocator) +>>> torch.cuda.memory.change_current_allocator(rmm_torch_allocator) ``` From e14a2291301ce9c8ef76b2b2404eb02336584724 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Wed, 10 Apr 2024 10:10:57 -0400 Subject: [PATCH 385/675] Update Changelog [skip ci] --- CHANGELOG.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d9ccfd94..4d870908d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,57 @@ +# RMM 24.04.00 (10 Apr 2024) + +## 🚨 Breaking Changes + +- Accept stream argument in DeviceMemoryResource allocate/deallocate ([#1494](https://github.com/rapidsai/rmm/pull/1494)) [@wence-](https://github.com/wence-) +- Replace all internal usage of `get_upstream` with `get_upstream_resource` ([#1491](https://github.com/rapidsai/rmm/pull/1491)) [@miscco](https://github.com/miscco) +- Deprecate rmm::mr::device_memory_resource::supports_streams() ([#1452](https://github.com/rapidsai/rmm/pull/1452)) [@harrism](https://github.com/harrism) +- Remove deprecated rmm::detail::available_device_memory ([#1438](https://github.com/rapidsai/rmm/pull/1438)) [@harrism](https://github.com/harrism) +- Make device_memory_resource::supports_streams() not pure virtual. Remove derived implementations and calls in RMM ([#1437](https://github.com/rapidsai/rmm/pull/1437)) [@harrism](https://github.com/harrism) +- Deprecate rmm::mr::device_memory_resource::get_mem_info() and supports_get_mem_info(). ([#1436](https://github.com/rapidsai/rmm/pull/1436)) [@harrism](https://github.com/harrism) + +## 🐛 Bug Fixes + +- Fix search path for torch allocator in editable installs and ensure CUDA support is available ([#1498](https://github.com/rapidsai/rmm/pull/1498)) [@vyasr](https://github.com/vyasr) +- Accept stream argument in DeviceMemoryResource allocate/deallocate ([#1494](https://github.com/rapidsai/rmm/pull/1494)) [@wence-](https://github.com/wence-) +- Run STATISTICS_TEST and TRACKING_TEST in serial to avoid OOM errors. ([#1487](https://github.com/rapidsai/rmm/pull/1487)) [@bdice](https://github.com/bdice) + +## 📖 Documentation + +- Pin to recent breathe, to prevent getting an unsupported sphinx version. ([#1495](https://github.com/rapidsai/rmm/pull/1495)) [@bdice](https://github.com/bdice) + +## 🚀 New Features + +- Replace all internal usage of `get_upstream` with `get_upstream_resource` ([#1491](https://github.com/rapidsai/rmm/pull/1491)) [@miscco](https://github.com/miscco) +- Add complete set of resource ref aliases ([#1479](https://github.com/rapidsai/rmm/pull/1479)) [@nvdbaranec](https://github.com/nvdbaranec) +- Automate include grouping using clang-format ([#1463](https://github.com/rapidsai/rmm/pull/1463)) [@harrism](https://github.com/harrism) +- Add `get_upstream_resource` to resource adaptors ([#1456](https://github.com/rapidsai/rmm/pull/1456)) [@miscco](https://github.com/miscco) +- Deprecate rmm::mr::device_memory_resource::supports_streams() ([#1452](https://github.com/rapidsai/rmm/pull/1452)) [@harrism](https://github.com/harrism) +- Remove duplicated memory_resource_tests ([#1451](https://github.com/rapidsai/rmm/pull/1451)) [@miscco](https://github.com/miscco) +- Change `rmm::exec_policy` to take `async_resource_ref` ([#1449](https://github.com/rapidsai/rmm/pull/1449)) [@miscco](https://github.com/miscco) +- Change `device_scalar` to take `async_resource_ref` ([#1447](https://github.com/rapidsai/rmm/pull/1447)) [@miscco](https://github.com/miscco) +- Add device_async_resource_ref convenience alias ([#1441](https://github.com/rapidsai/rmm/pull/1441)) [@harrism](https://github.com/harrism) +- Remove deprecated rmm::detail::available_device_memory ([#1438](https://github.com/rapidsai/rmm/pull/1438)) [@harrism](https://github.com/harrism) +- Make device_memory_resource::supports_streams() not pure virtual. Remove derived implementations and calls in RMM ([#1437](https://github.com/rapidsai/rmm/pull/1437)) [@harrism](https://github.com/harrism) +- Deprecate rmm::mr::device_memory_resource::get_mem_info() and supports_get_mem_info(). ([#1436](https://github.com/rapidsai/rmm/pull/1436)) [@harrism](https://github.com/harrism) +- Support CUDA 12.2 ([#1419](https://github.com/rapidsai/rmm/pull/1419)) [@jameslamb](https://github.com/jameslamb) + +## 🛠️ Improvements + +- Use `conda env create --yes` instead of `--force` ([#1509](https://github.com/rapidsai/rmm/pull/1509)) [@bdice](https://github.com/bdice) +- Add upper bound to prevent usage of NumPy 2 ([#1501](https://github.com/rapidsai/rmm/pull/1501)) [@bdice](https://github.com/bdice) +- Remove hard-coding of RAPIDS version where possible ([#1496](https://github.com/rapidsai/rmm/pull/1496)) [@KyleFromNVIDIA](https://github.com/KyleFromNVIDIA) +- Requre NumPy 1.23+ ([#1488](https://github.com/rapidsai/rmm/pull/1488)) [@jakirkham](https://github.com/jakirkham) +- Use `rmm::device_async_resource_ref` in multi_stream_allocation benchmark ([#1482](https://github.com/rapidsai/rmm/pull/1482)) [@miscco](https://github.com/miscco) +- Update devcontainers to CUDA Toolkit 12.2 ([#1470](https://github.com/rapidsai/rmm/pull/1470)) [@trxcllnt](https://github.com/trxcllnt) +- Add support for Python 3.11 ([#1469](https://github.com/rapidsai/rmm/pull/1469)) [@jameslamb](https://github.com/jameslamb) +- target branch-24.04 for GitHub Actions workflows ([#1468](https://github.com/rapidsai/rmm/pull/1468)) [@jameslamb](https://github.com/jameslamb) +- [FEA]: Use `std::optional` instead of `thrust::optional` ([#1464](https://github.com/rapidsai/rmm/pull/1464)) [@miscco](https://github.com/miscco) +- Add environment-agnostic scripts for running ctests and pytests ([#1462](https://github.com/rapidsai/rmm/pull/1462)) [@trxcllnt](https://github.com/trxcllnt) +- Ensure that `ctest` is called with `--no-tests=error`. ([#1460](https://github.com/rapidsai/rmm/pull/1460)) [@bdice](https://github.com/bdice) +- Update ops-bot.yaml ([#1458](https://github.com/rapidsai/rmm/pull/1458)) [@AyodeAwe](https://github.com/AyodeAwe) +- Adopt the `rmm::device_async_resource_ref` alias ([#1454](https://github.com/rapidsai/rmm/pull/1454)) [@miscco](https://github.com/miscco) +- Refactor error.hpp out of detail ([#1439](https://github.com/rapidsai/rmm/pull/1439)) [@lamarrr](https://github.com/lamarrr) + # RMM 24.02.00 (12 Feb 2024) ## 🚨 Breaking Changes From 7d7d65ab115b3e96b0ebc51d45a90020d8037439 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Thu, 11 Apr 2024 09:12:56 +0100 Subject: [PATCH 386/675] Update multi-gpu discussion for device_buffer and device_vector dtors (#1524) Since #1370, the dtor for device_buffer ensures that the correct device is active when the deallocation occurs. We therefore update the example to discuss this. Since device_vector still requires the user to manage the active device correctly by hand, call this out explicitly in the documentation. - Closes #1523 Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1524 --- README.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0fe848fea..5b7dc69c0 100644 --- a/README.md +++ b/README.md @@ -336,25 +336,68 @@ for(int i = 0; i < N; ++i) { Note that the CUDA device that is current when creating a `device_memory_resource` must also be current any time that `device_memory_resource` is used to deallocate memory, including in a -destructor. This affects RAII classes like `rmm::device_buffer` and `rmm::device_uvector`. Here's an -(incorrect) example that assumes the above example loop has been run to create a -`pool_memory_resource` for each device. A correct example adds a call to `cudaSetDevice(0)` on the -line of the error comment. +destructor. The RAII class `rmm::device_buffer` and classes that use it as a backing store +(`rmm::device_scalar` and `rmm::device_uvector`) handle this by storing the active device when the +constructor is called, and then ensuring that the stored device is active whenever an allocation or +deallocation is performed (including in the destructor). The user must therefore only ensure that +the device active during _creation_ of an `rmm::device_buffer` matches the active device of the +memory resource being used. + +Here is an incorrect example that creates a memory resource on device zero and then uses it to +allocate a `device_buffer` on device one: ```c++ { RMM_CUDA_TRY(cudaSetDevice(0)); - rmm::device_buffer buf_a(16); - + auto mr = rmm::mr::cuda_memory_resource{}; { RMM_CUDA_TRY(cudaSetDevice(1)); - rmm::device_buffer buf_b(16); + // Invalid, current device is 1, but MR is only valid for device 0 + rmm::device_buffer buf(16, rmm::cuda_stream_default, &mr); } +} +``` + +A correct example creates the device buffer with device zero active. After that it is safe to switch +devices and let the buffer go out of scope and destruct with a different device active. For example, +this code is correct: + +```c++ +{ + RMM_CUDA_TRY(cudaSetDevice(0)); + auto mr = rmm::mr::cuda_memory_resource{}; + rmm::device_buffer buf(16, rmm::cuda_stream_default, &mr); + RMM_CUDA_TRY(cudaSetDevice(1)); + ... + // No need to switch back to device 0 before ~buf runs +} +``` + +#### Use of `rmm::device_vector` with multiple devices + +> [!CAUTION] In contrast to the uninitialized `rmm:device_uvector`, `rmm::device_vector` **DOES +> NOT** store the active device during construction, and therefore cannot arrange for it to be +> active when the destructor runs. It is therefore the responsibility of the user to ensure the +> currently active device is correct. + +`rmm::device_vector` is therefore slightly less ergonomic to use in a multiple device setting since +the caller must arrange that active devices on allocation and deallocation match. Recapitulating the +previous example using `rmm::device_vector`: - // Error: when buf_a is destroyed, the current device must be 0, but it is 1 +```c++ +{ + RMM_CUDA_TRY(cudaSetDevice(0)); + auto mr = rmm::mr::cuda_memory_resource{}; + rmm::device_vector vec(16, rmm::mr::thrust_allocator(rmm::cuda_stream_default, &mr)); + RMM_CUDA_TRY(cudaSetDevice(1)); + ... + // ERROR: ~vec runs with device 1 active, but needs device 0 to be active } ``` +A correct example adds a call to `cudaSetDevice(0)` on the line of the error comment before the dtor +for `~vec` runs. + ## `cuda_stream_view` and `cuda_stream` `rmm::cuda_stream_view` is a simple non-owning wrapper around a CUDA `cudaStream_t`. This wrapper's From 9e02f34a03153650b7bf5ce398ee3f374c240476 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 11 Apr 2024 15:50:06 -0700 Subject: [PATCH 387/675] Move rmm Python package to subdirectory (#1526) This change is in preparation for #1512. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1526 --- .pre-commit-config.yaml | 4 ++-- CHANGELOG.md | 2 +- build.sh | 2 +- ci/build_docs.sh | 2 +- ci/build_python.sh | 2 +- ci/build_wheel.sh | 3 +-- ci/run_pytests.sh | 2 +- ci/test_wheel.sh | 2 +- dependencies.yaml | 12 +++++++++++- python/LICENSE | 1 - python/README.md | 1 - python/{ => rmm}/.coveragerc | 0 python/{ => rmm}/CMakeLists.txt | 4 ++-- python/rmm/LICENSE | 1 + python/rmm/README.md | 1 + python/rmm/VERSION | 1 - python/{ => rmm}/docs/Makefile | 0 python/{ => rmm}/docs/conf.py | 2 +- python/{ => rmm}/docs/cpp.rst | 0 python/{ => rmm}/docs/cpp_api.rst | 0 python/{ => rmm}/docs/guide.md | 0 python/{ => rmm}/docs/index.rst | 0 .../docs/librmm_docs/cuda_device_management.rst | 0 python/{ => rmm}/docs/librmm_docs/cuda_streams.rst | 0 .../{ => rmm}/docs/librmm_docs/data_containers.rst | 0 python/{ => rmm}/docs/librmm_docs/deprecated.rst | 0 python/{ => rmm}/docs/librmm_docs/errors.rst | 0 python/{ => rmm}/docs/librmm_docs/index.rst | 0 python/{ => rmm}/docs/librmm_docs/logging.rst | 0 .../{ => rmm}/docs/librmm_docs/memory_resources.rst | 0 .../docs/librmm_docs/thrust_integrations.rst | 0 python/{ => rmm}/docs/librmm_docs/utilities.rst | 0 python/{ => rmm}/docs/python.rst | 0 python/{ => rmm}/docs/python_api.rst | 0 python/{ => rmm}/pyproject.toml | 6 +++--- python/rmm/rmm/VERSION | 1 + python/rmm/{ => rmm}/__init__.py | 0 python/rmm/{ => rmm}/_cuda/CMakeLists.txt | 0 python/rmm/{ => rmm}/_cuda/__init__.pxd | 0 python/rmm/{ => rmm}/_cuda/__init__.py | 0 python/rmm/{ => rmm}/_cuda/gpu.py | 0 python/rmm/{ => rmm}/_cuda/stream.pxd | 0 python/rmm/{ => rmm}/_cuda/stream.pyx | 0 python/rmm/{ => rmm}/_lib/CMakeLists.txt | 0 python/rmm/{ => rmm}/_lib/__init__.pxd | 0 python/rmm/{ => rmm}/_lib/__init__.py | 0 python/rmm/{ => rmm}/_lib/_torch_allocator.cpp | 0 python/rmm/{ => rmm}/_lib/cuda_stream.pxd | 0 python/rmm/{ => rmm}/_lib/cuda_stream.pyx | 0 python/rmm/{ => rmm}/_lib/cuda_stream_pool.pxd | 0 python/rmm/{ => rmm}/_lib/cuda_stream_view.pxd | 0 python/rmm/{ => rmm}/_lib/device_buffer.pxd | 0 python/rmm/{ => rmm}/_lib/device_buffer.pyx | 0 python/rmm/{ => rmm}/_lib/device_uvector.pxd | 0 python/rmm/{ => rmm}/_lib/lib.pxd | 0 python/rmm/{ => rmm}/_lib/lib.pyx | 0 python/rmm/{ => rmm}/_lib/logger.pyx | 0 python/rmm/{ => rmm}/_lib/memory_resource.pxd | 0 python/rmm/{ => rmm}/_lib/memory_resource.pyx | 0 python/rmm/{ => rmm}/_lib/per_device_resource.pxd | 0 python/rmm/{ => rmm}/_lib/tests/__init__.py | 0 .../rmm/{ => rmm}/_lib/tests/test_device_buffer.pyx | 0 python/rmm/{ => rmm}/_version.py | 0 python/rmm/{ => rmm}/allocators/__init__.py | 0 python/rmm/{ => rmm}/allocators/cupy.py | 0 python/rmm/{ => rmm}/allocators/numba.py | 0 python/rmm/{ => rmm}/allocators/torch.py | 0 python/rmm/{ => rmm}/mr.py | 0 python/rmm/{ => rmm}/rmm.py | 0 python/rmm/{ => rmm}/tests/conftest.py | 0 python/rmm/{ => rmm}/tests/test_cython.py | 0 python/rmm/{ => rmm}/tests/test_rmm.py | 0 python/rmm/{ => rmm}/tests/test_rmm_pytorch.py | 0 73 files changed, 29 insertions(+), 20 deletions(-) delete mode 120000 python/LICENSE delete mode 120000 python/README.md rename python/{ => rmm}/.coveragerc (100%) rename python/{ => rmm}/CMakeLists.txt (94%) create mode 120000 python/rmm/LICENSE create mode 120000 python/rmm/README.md delete mode 120000 python/rmm/VERSION rename python/{ => rmm}/docs/Makefile (100%) rename python/{ => rmm}/docs/conf.py (99%) rename python/{ => rmm}/docs/cpp.rst (100%) rename python/{ => rmm}/docs/cpp_api.rst (100%) rename python/{ => rmm}/docs/guide.md (100%) rename python/{ => rmm}/docs/index.rst (100%) rename python/{ => rmm}/docs/librmm_docs/cuda_device_management.rst (100%) rename python/{ => rmm}/docs/librmm_docs/cuda_streams.rst (100%) rename python/{ => rmm}/docs/librmm_docs/data_containers.rst (100%) rename python/{ => rmm}/docs/librmm_docs/deprecated.rst (100%) rename python/{ => rmm}/docs/librmm_docs/errors.rst (100%) rename python/{ => rmm}/docs/librmm_docs/index.rst (100%) rename python/{ => rmm}/docs/librmm_docs/logging.rst (100%) rename python/{ => rmm}/docs/librmm_docs/memory_resources.rst (100%) rename python/{ => rmm}/docs/librmm_docs/thrust_integrations.rst (100%) rename python/{ => rmm}/docs/librmm_docs/utilities.rst (100%) rename python/{ => rmm}/docs/python.rst (100%) rename python/{ => rmm}/docs/python_api.rst (100%) rename python/{ => rmm}/pyproject.toml (91%) create mode 120000 python/rmm/rmm/VERSION rename python/rmm/{ => rmm}/__init__.py (100%) rename python/rmm/{ => rmm}/_cuda/CMakeLists.txt (100%) rename python/rmm/{ => rmm}/_cuda/__init__.pxd (100%) rename python/rmm/{ => rmm}/_cuda/__init__.py (100%) rename python/rmm/{ => rmm}/_cuda/gpu.py (100%) rename python/rmm/{ => rmm}/_cuda/stream.pxd (100%) rename python/rmm/{ => rmm}/_cuda/stream.pyx (100%) rename python/rmm/{ => rmm}/_lib/CMakeLists.txt (100%) rename python/rmm/{ => rmm}/_lib/__init__.pxd (100%) rename python/rmm/{ => rmm}/_lib/__init__.py (100%) rename python/rmm/{ => rmm}/_lib/_torch_allocator.cpp (100%) rename python/rmm/{ => rmm}/_lib/cuda_stream.pxd (100%) rename python/rmm/{ => rmm}/_lib/cuda_stream.pyx (100%) rename python/rmm/{ => rmm}/_lib/cuda_stream_pool.pxd (100%) rename python/rmm/{ => rmm}/_lib/cuda_stream_view.pxd (100%) rename python/rmm/{ => rmm}/_lib/device_buffer.pxd (100%) rename python/rmm/{ => rmm}/_lib/device_buffer.pyx (100%) rename python/rmm/{ => rmm}/_lib/device_uvector.pxd (100%) rename python/rmm/{ => rmm}/_lib/lib.pxd (100%) rename python/rmm/{ => rmm}/_lib/lib.pyx (100%) rename python/rmm/{ => rmm}/_lib/logger.pyx (100%) rename python/rmm/{ => rmm}/_lib/memory_resource.pxd (100%) rename python/rmm/{ => rmm}/_lib/memory_resource.pyx (100%) rename python/rmm/{ => rmm}/_lib/per_device_resource.pxd (100%) rename python/rmm/{ => rmm}/_lib/tests/__init__.py (100%) rename python/rmm/{ => rmm}/_lib/tests/test_device_buffer.pyx (100%) rename python/rmm/{ => rmm}/_version.py (100%) rename python/rmm/{ => rmm}/allocators/__init__.py (100%) rename python/rmm/{ => rmm}/allocators/cupy.py (100%) rename python/rmm/{ => rmm}/allocators/numba.py (100%) rename python/rmm/{ => rmm}/allocators/torch.py (100%) rename python/rmm/{ => rmm}/mr.py (100%) rename python/rmm/{ => rmm}/rmm.py (100%) rename python/rmm/{ => rmm}/tests/conftest.py (100%) rename python/rmm/{ => rmm}/tests/test_cython.py (100%) rename python/rmm/{ => rmm}/tests/test_rmm.py (100%) rename python/rmm/{ => rmm}/tests/test_rmm_pytorch.py (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4df64d11a..c266be0bd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,14 +14,14 @@ repos: rev: 5.12.0 hooks: - id: isort - args: ["--settings-path=python/pyproject.toml"] + args: ["--settings-path=python/rmm/pyproject.toml"] files: python/.* types_or: [python, cython, pyi] - repo: https://github.com/ambv/black rev: 22.3.0 hooks: - id: black - args: ["--config=python/pyproject.toml"] + args: ["--config=python/rmm/pyproject.toml"] - repo: https://github.com/MarcoGorelli/cython-lint rev: v0.15.0 hooks: diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d870908d..f78aa7692 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,7 +40,7 @@ - Use `conda env create --yes` instead of `--force` ([#1509](https://github.com/rapidsai/rmm/pull/1509)) [@bdice](https://github.com/bdice) - Add upper bound to prevent usage of NumPy 2 ([#1501](https://github.com/rapidsai/rmm/pull/1501)) [@bdice](https://github.com/bdice) - Remove hard-coding of RAPIDS version where possible ([#1496](https://github.com/rapidsai/rmm/pull/1496)) [@KyleFromNVIDIA](https://github.com/KyleFromNVIDIA) -- Requre NumPy 1.23+ ([#1488](https://github.com/rapidsai/rmm/pull/1488)) [@jakirkham](https://github.com/jakirkham) +- Require NumPy 1.23+ ([#1488](https://github.com/rapidsai/rmm/pull/1488)) [@jakirkham](https://github.com/jakirkham) - Use `rmm::device_async_resource_ref` in multi_stream_allocation benchmark ([#1482](https://github.com/rapidsai/rmm/pull/1482)) [@miscco](https://github.com/miscco) - Update devcontainers to CUDA Toolkit 12.2 ([#1470](https://github.com/rapidsai/rmm/pull/1470)) [@trxcllnt](https://github.com/trxcllnt) - Add support for Python 3.11 ([#1469](https://github.com/rapidsai/rmm/pull/1469)) [@jameslamb](https://github.com/jameslamb) diff --git a/build.sh b/build.sh index ec08fa402..fce8e0586 100755 --- a/build.sh +++ b/build.sh @@ -176,5 +176,5 @@ fi # Build and install the rmm Python package if (( NUMARGS == 0 )) || hasArg rmm; then echo "building and installing rmm..." - SKBUILD_CMAKE_ARGS="${SKBUILD_EXTRA_CMAKE_ARGS}" python -m pip install --no-build-isolation --no-deps ${REPODIR}/python + SKBUILD_CMAKE_ARGS="${SKBUILD_EXTRA_CMAKE_ARGS}" python -m pip install --no-build-isolation --no-deps ${REPODIR}/python/rmm fi diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 1239bdac3..5519a3c35 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -36,7 +36,7 @@ doxygen Doxyfile popd rapids-logger "Build Python docs" -pushd python/docs +pushd python/rmm/docs make dirhtml make text mkdir -p "${RAPIDS_DOCS_DIR}/rmm/"{html,txt} diff --git a/ci/build_python.sh b/ci/build_python.sh index b197b1ae1..394b3a453 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -14,7 +14,7 @@ export CMAKE_GENERATOR=Ninja rapids-print-env package_name="rmm" -package_dir="python" +package_dir="python/rmm" version=$(rapids-generate-version) commit=$(git rev-parse HEAD) diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh index b2d953361..b76e882b3 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel.sh @@ -4,7 +4,7 @@ set -euo pipefail package_name="rmm" -package_dir="python" +package_dir="python/rmm" source rapids-configure-sccache source rapids-date-string @@ -18,7 +18,6 @@ RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" # everywhere except in the final wheel name. PACKAGE_CUDA_SUFFIX="-${RAPIDS_PY_CUDA_SUFFIX}" -# Patch project metadata files to include the CUDA version suffix and version override. pyproject_file="${package_dir}/pyproject.toml" sed -i "s/name = \"${package_name}\"/name = \"${package_name}${PACKAGE_CUDA_SUFFIX}\"/g" ${pyproject_file} diff --git a/ci/run_pytests.sh b/ci/run_pytests.sh index 73780fcc3..6bda50870 100755 --- a/ci/run_pytests.sh +++ b/ci/run_pytests.sh @@ -4,6 +4,6 @@ set -euo pipefail # Support invoking run_pytests.sh outside the script directory -cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/ +cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/rmm/ pytest --cache-clear -v "$@" . diff --git a/ci/test_wheel.sh b/ci/test_wheel.sh index 708b1d930..3faf15ba2 100755 --- a/ci/test_wheel.sh +++ b/ci/test_wheel.sh @@ -9,4 +9,4 @@ RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from- # echo to expand wildcard before adding `[extra]` requires for pip python -m pip install $(echo ./dist/rmm*.whl)[test] -python -m pytest ./python/rmm/tests +python -m pytest ./python/rmm/rmm/tests diff --git a/dependencies.yaml b/dependencies.yaml index 548999f1b..10d0eab2d 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -7,6 +7,7 @@ files: arch: [x86_64] includes: - build + - cython_build - checks - cuda - cuda_version @@ -39,18 +40,22 @@ files: - py_version py_build: output: pyproject + pyproject_dir: python/rmm extras: table: build-system includes: - build + - cython_build py_run: output: pyproject + pyproject_dir: python/rmm extras: table: project includes: - run py_optional_test: output: pyproject + pyproject_dir: python/rmm extras: table: project.optional-dependencies key: test @@ -65,7 +70,6 @@ dependencies: - output_types: [conda, requirements, pyproject] packages: - &cmake_ver cmake>=3.26.4 - - cython>=3.0.0 - ninja - output_types: conda packages: @@ -106,6 +110,12 @@ dependencies: cuda: "12.*" packages: - cuda-nvcc + cython_build: + common: + - output_types: [conda, requirements, pyproject] + packages: + - cython>=3.0.0 + specific: - output_types: [conda, requirements, pyproject] matrices: - matrix: diff --git a/python/LICENSE b/python/LICENSE deleted file mode 120000 index ea5b60640..000000000 --- a/python/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../LICENSE \ No newline at end of file diff --git a/python/README.md b/python/README.md deleted file mode 120000 index 32d46ee88..000000000 --- a/python/README.md +++ /dev/null @@ -1 +0,0 @@ -../README.md \ No newline at end of file diff --git a/python/.coveragerc b/python/rmm/.coveragerc similarity index 100% rename from python/.coveragerc rename to python/rmm/.coveragerc diff --git a/python/CMakeLists.txt b/python/rmm/CMakeLists.txt similarity index 94% rename from python/CMakeLists.txt rename to python/rmm/CMakeLists.txt index 87752ff24..22b5ea282 100644 --- a/python/CMakeLists.txt +++ b/python/rmm/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) -include(../rapids_config.cmake) +include(../../rapids_config.cmake) project( rmm-python @@ -36,7 +36,7 @@ if(NOT rmm_FOUND) set(BUILD_BENCHMARKS OFF) set(CUDA_STATIC_RUNTIME ON) - add_subdirectory(../ rmm-cpp EXCLUDE_FROM_ALL) + add_subdirectory(../../ rmm-cpp EXCLUDE_FROM_ALL) endif() include(rapids-cython-core) diff --git a/python/rmm/LICENSE b/python/rmm/LICENSE new file mode 120000 index 000000000..30cff7403 --- /dev/null +++ b/python/rmm/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/python/rmm/README.md b/python/rmm/README.md new file mode 120000 index 000000000..fe8400541 --- /dev/null +++ b/python/rmm/README.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/python/rmm/VERSION b/python/rmm/VERSION deleted file mode 120000 index 558194c5a..000000000 --- a/python/rmm/VERSION +++ /dev/null @@ -1 +0,0 @@ -../../VERSION \ No newline at end of file diff --git a/python/docs/Makefile b/python/rmm/docs/Makefile similarity index 100% rename from python/docs/Makefile rename to python/rmm/docs/Makefile diff --git a/python/docs/conf.py b/python/rmm/docs/conf.py similarity index 99% rename from python/docs/conf.py rename to python/rmm/docs/conf.py index d66e9d30c..0140c84b2 100644 --- a/python/docs/conf.py +++ b/python/rmm/docs/conf.py @@ -58,7 +58,7 @@ ] # Breathe Configuration -breathe_projects = {"librmm": "../../doxygen/xml"} +breathe_projects = {"librmm": "../../../doxygen/xml"} breathe_default_project = "librmm" copybutton_prompt_text = ">>> " diff --git a/python/docs/cpp.rst b/python/rmm/docs/cpp.rst similarity index 100% rename from python/docs/cpp.rst rename to python/rmm/docs/cpp.rst diff --git a/python/docs/cpp_api.rst b/python/rmm/docs/cpp_api.rst similarity index 100% rename from python/docs/cpp_api.rst rename to python/rmm/docs/cpp_api.rst diff --git a/python/docs/guide.md b/python/rmm/docs/guide.md similarity index 100% rename from python/docs/guide.md rename to python/rmm/docs/guide.md diff --git a/python/docs/index.rst b/python/rmm/docs/index.rst similarity index 100% rename from python/docs/index.rst rename to python/rmm/docs/index.rst diff --git a/python/docs/librmm_docs/cuda_device_management.rst b/python/rmm/docs/librmm_docs/cuda_device_management.rst similarity index 100% rename from python/docs/librmm_docs/cuda_device_management.rst rename to python/rmm/docs/librmm_docs/cuda_device_management.rst diff --git a/python/docs/librmm_docs/cuda_streams.rst b/python/rmm/docs/librmm_docs/cuda_streams.rst similarity index 100% rename from python/docs/librmm_docs/cuda_streams.rst rename to python/rmm/docs/librmm_docs/cuda_streams.rst diff --git a/python/docs/librmm_docs/data_containers.rst b/python/rmm/docs/librmm_docs/data_containers.rst similarity index 100% rename from python/docs/librmm_docs/data_containers.rst rename to python/rmm/docs/librmm_docs/data_containers.rst diff --git a/python/docs/librmm_docs/deprecated.rst b/python/rmm/docs/librmm_docs/deprecated.rst similarity index 100% rename from python/docs/librmm_docs/deprecated.rst rename to python/rmm/docs/librmm_docs/deprecated.rst diff --git a/python/docs/librmm_docs/errors.rst b/python/rmm/docs/librmm_docs/errors.rst similarity index 100% rename from python/docs/librmm_docs/errors.rst rename to python/rmm/docs/librmm_docs/errors.rst diff --git a/python/docs/librmm_docs/index.rst b/python/rmm/docs/librmm_docs/index.rst similarity index 100% rename from python/docs/librmm_docs/index.rst rename to python/rmm/docs/librmm_docs/index.rst diff --git a/python/docs/librmm_docs/logging.rst b/python/rmm/docs/librmm_docs/logging.rst similarity index 100% rename from python/docs/librmm_docs/logging.rst rename to python/rmm/docs/librmm_docs/logging.rst diff --git a/python/docs/librmm_docs/memory_resources.rst b/python/rmm/docs/librmm_docs/memory_resources.rst similarity index 100% rename from python/docs/librmm_docs/memory_resources.rst rename to python/rmm/docs/librmm_docs/memory_resources.rst diff --git a/python/docs/librmm_docs/thrust_integrations.rst b/python/rmm/docs/librmm_docs/thrust_integrations.rst similarity index 100% rename from python/docs/librmm_docs/thrust_integrations.rst rename to python/rmm/docs/librmm_docs/thrust_integrations.rst diff --git a/python/docs/librmm_docs/utilities.rst b/python/rmm/docs/librmm_docs/utilities.rst similarity index 100% rename from python/docs/librmm_docs/utilities.rst rename to python/rmm/docs/librmm_docs/utilities.rst diff --git a/python/docs/python.rst b/python/rmm/docs/python.rst similarity index 100% rename from python/docs/python.rst rename to python/rmm/docs/python.rst diff --git a/python/docs/python_api.rst b/python/rmm/docs/python_api.rst similarity index 100% rename from python/docs/python_api.rst rename to python/rmm/docs/python_api.rst diff --git a/python/pyproject.toml b/python/rmm/pyproject.toml similarity index 91% rename from python/pyproject.toml rename to python/rmm/pyproject.toml index 3f294d180..ea8639feb 100644 --- a/python/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -20,7 +20,7 @@ requires = [ "cython>=3.0.0", "ninja", "scikit-build-core[pyproject]>=0.7.0", -] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../dependencies.yaml and run `rapids-dependency-file-generator`. +] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. [project] name = "rmm" @@ -36,7 +36,7 @@ dependencies = [ "cuda-python>=11.7.1,<12.0a0", "numba>=0.57", "numpy>=1.23,<2.0a0", -] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../dependencies.yaml and run `rapids-dependency-file-generator`. +] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. classifiers = [ "Intended Audience :: Developers", "Topic :: Database", @@ -52,7 +52,7 @@ classifiers = [ test = [ "pytest", "pytest-cov", -] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../dependencies.yaml and run `rapids-dependency-file-generator`. +] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. [project.urls] Homepage = "https://github.com/rapidsai/rmm" diff --git a/python/rmm/rmm/VERSION b/python/rmm/rmm/VERSION new file mode 120000 index 000000000..d62dc733e --- /dev/null +++ b/python/rmm/rmm/VERSION @@ -0,0 +1 @@ +../../../VERSION \ No newline at end of file diff --git a/python/rmm/__init__.py b/python/rmm/rmm/__init__.py similarity index 100% rename from python/rmm/__init__.py rename to python/rmm/rmm/__init__.py diff --git a/python/rmm/_cuda/CMakeLists.txt b/python/rmm/rmm/_cuda/CMakeLists.txt similarity index 100% rename from python/rmm/_cuda/CMakeLists.txt rename to python/rmm/rmm/_cuda/CMakeLists.txt diff --git a/python/rmm/_cuda/__init__.pxd b/python/rmm/rmm/_cuda/__init__.pxd similarity index 100% rename from python/rmm/_cuda/__init__.pxd rename to python/rmm/rmm/_cuda/__init__.pxd diff --git a/python/rmm/_cuda/__init__.py b/python/rmm/rmm/_cuda/__init__.py similarity index 100% rename from python/rmm/_cuda/__init__.py rename to python/rmm/rmm/_cuda/__init__.py diff --git a/python/rmm/_cuda/gpu.py b/python/rmm/rmm/_cuda/gpu.py similarity index 100% rename from python/rmm/_cuda/gpu.py rename to python/rmm/rmm/_cuda/gpu.py diff --git a/python/rmm/_cuda/stream.pxd b/python/rmm/rmm/_cuda/stream.pxd similarity index 100% rename from python/rmm/_cuda/stream.pxd rename to python/rmm/rmm/_cuda/stream.pxd diff --git a/python/rmm/_cuda/stream.pyx b/python/rmm/rmm/_cuda/stream.pyx similarity index 100% rename from python/rmm/_cuda/stream.pyx rename to python/rmm/rmm/_cuda/stream.pyx diff --git a/python/rmm/_lib/CMakeLists.txt b/python/rmm/rmm/_lib/CMakeLists.txt similarity index 100% rename from python/rmm/_lib/CMakeLists.txt rename to python/rmm/rmm/_lib/CMakeLists.txt diff --git a/python/rmm/_lib/__init__.pxd b/python/rmm/rmm/_lib/__init__.pxd similarity index 100% rename from python/rmm/_lib/__init__.pxd rename to python/rmm/rmm/_lib/__init__.pxd diff --git a/python/rmm/_lib/__init__.py b/python/rmm/rmm/_lib/__init__.py similarity index 100% rename from python/rmm/_lib/__init__.py rename to python/rmm/rmm/_lib/__init__.py diff --git a/python/rmm/_lib/_torch_allocator.cpp b/python/rmm/rmm/_lib/_torch_allocator.cpp similarity index 100% rename from python/rmm/_lib/_torch_allocator.cpp rename to python/rmm/rmm/_lib/_torch_allocator.cpp diff --git a/python/rmm/_lib/cuda_stream.pxd b/python/rmm/rmm/_lib/cuda_stream.pxd similarity index 100% rename from python/rmm/_lib/cuda_stream.pxd rename to python/rmm/rmm/_lib/cuda_stream.pxd diff --git a/python/rmm/_lib/cuda_stream.pyx b/python/rmm/rmm/_lib/cuda_stream.pyx similarity index 100% rename from python/rmm/_lib/cuda_stream.pyx rename to python/rmm/rmm/_lib/cuda_stream.pyx diff --git a/python/rmm/_lib/cuda_stream_pool.pxd b/python/rmm/rmm/_lib/cuda_stream_pool.pxd similarity index 100% rename from python/rmm/_lib/cuda_stream_pool.pxd rename to python/rmm/rmm/_lib/cuda_stream_pool.pxd diff --git a/python/rmm/_lib/cuda_stream_view.pxd b/python/rmm/rmm/_lib/cuda_stream_view.pxd similarity index 100% rename from python/rmm/_lib/cuda_stream_view.pxd rename to python/rmm/rmm/_lib/cuda_stream_view.pxd diff --git a/python/rmm/_lib/device_buffer.pxd b/python/rmm/rmm/_lib/device_buffer.pxd similarity index 100% rename from python/rmm/_lib/device_buffer.pxd rename to python/rmm/rmm/_lib/device_buffer.pxd diff --git a/python/rmm/_lib/device_buffer.pyx b/python/rmm/rmm/_lib/device_buffer.pyx similarity index 100% rename from python/rmm/_lib/device_buffer.pyx rename to python/rmm/rmm/_lib/device_buffer.pyx diff --git a/python/rmm/_lib/device_uvector.pxd b/python/rmm/rmm/_lib/device_uvector.pxd similarity index 100% rename from python/rmm/_lib/device_uvector.pxd rename to python/rmm/rmm/_lib/device_uvector.pxd diff --git a/python/rmm/_lib/lib.pxd b/python/rmm/rmm/_lib/lib.pxd similarity index 100% rename from python/rmm/_lib/lib.pxd rename to python/rmm/rmm/_lib/lib.pxd diff --git a/python/rmm/_lib/lib.pyx b/python/rmm/rmm/_lib/lib.pyx similarity index 100% rename from python/rmm/_lib/lib.pyx rename to python/rmm/rmm/_lib/lib.pyx diff --git a/python/rmm/_lib/logger.pyx b/python/rmm/rmm/_lib/logger.pyx similarity index 100% rename from python/rmm/_lib/logger.pyx rename to python/rmm/rmm/_lib/logger.pyx diff --git a/python/rmm/_lib/memory_resource.pxd b/python/rmm/rmm/_lib/memory_resource.pxd similarity index 100% rename from python/rmm/_lib/memory_resource.pxd rename to python/rmm/rmm/_lib/memory_resource.pxd diff --git a/python/rmm/_lib/memory_resource.pyx b/python/rmm/rmm/_lib/memory_resource.pyx similarity index 100% rename from python/rmm/_lib/memory_resource.pyx rename to python/rmm/rmm/_lib/memory_resource.pyx diff --git a/python/rmm/_lib/per_device_resource.pxd b/python/rmm/rmm/_lib/per_device_resource.pxd similarity index 100% rename from python/rmm/_lib/per_device_resource.pxd rename to python/rmm/rmm/_lib/per_device_resource.pxd diff --git a/python/rmm/_lib/tests/__init__.py b/python/rmm/rmm/_lib/tests/__init__.py similarity index 100% rename from python/rmm/_lib/tests/__init__.py rename to python/rmm/rmm/_lib/tests/__init__.py diff --git a/python/rmm/_lib/tests/test_device_buffer.pyx b/python/rmm/rmm/_lib/tests/test_device_buffer.pyx similarity index 100% rename from python/rmm/_lib/tests/test_device_buffer.pyx rename to python/rmm/rmm/_lib/tests/test_device_buffer.pyx diff --git a/python/rmm/_version.py b/python/rmm/rmm/_version.py similarity index 100% rename from python/rmm/_version.py rename to python/rmm/rmm/_version.py diff --git a/python/rmm/allocators/__init__.py b/python/rmm/rmm/allocators/__init__.py similarity index 100% rename from python/rmm/allocators/__init__.py rename to python/rmm/rmm/allocators/__init__.py diff --git a/python/rmm/allocators/cupy.py b/python/rmm/rmm/allocators/cupy.py similarity index 100% rename from python/rmm/allocators/cupy.py rename to python/rmm/rmm/allocators/cupy.py diff --git a/python/rmm/allocators/numba.py b/python/rmm/rmm/allocators/numba.py similarity index 100% rename from python/rmm/allocators/numba.py rename to python/rmm/rmm/allocators/numba.py diff --git a/python/rmm/allocators/torch.py b/python/rmm/rmm/allocators/torch.py similarity index 100% rename from python/rmm/allocators/torch.py rename to python/rmm/rmm/allocators/torch.py diff --git a/python/rmm/mr.py b/python/rmm/rmm/mr.py similarity index 100% rename from python/rmm/mr.py rename to python/rmm/rmm/mr.py diff --git a/python/rmm/rmm.py b/python/rmm/rmm/rmm.py similarity index 100% rename from python/rmm/rmm.py rename to python/rmm/rmm/rmm.py diff --git a/python/rmm/tests/conftest.py b/python/rmm/rmm/tests/conftest.py similarity index 100% rename from python/rmm/tests/conftest.py rename to python/rmm/rmm/tests/conftest.py diff --git a/python/rmm/tests/test_cython.py b/python/rmm/rmm/tests/test_cython.py similarity index 100% rename from python/rmm/tests/test_cython.py rename to python/rmm/rmm/tests/test_cython.py diff --git a/python/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py similarity index 100% rename from python/rmm/tests/test_rmm.py rename to python/rmm/rmm/tests/test_rmm.py diff --git a/python/rmm/tests/test_rmm_pytorch.py b/python/rmm/rmm/tests/test_rmm_pytorch.py similarity index 100% rename from python/rmm/tests/test_rmm_pytorch.py rename to python/rmm/rmm/tests/test_rmm_pytorch.py From 7ed529fb7b94d5639deb0f04efc08ab7ae7fd045 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:08:39 +1000 Subject: [PATCH 388/675] Remove deprecated cuda_async_memory_resource constructor that takes thrust::optional parameters (#1535) Fixes #1534 Fixes #1530 Authors: - Mark Harris (https://github.com/harrism) Approvers: - Bradley Dice (https://github.com/bdice) - Michael Schellenberger Costa (https://github.com/miscco) URL: https://github.com/rapidsai/rmm/pull/1535 --- .../mr/device/cuda_async_memory_resource.hpp | 35 ------------------- .../cuda_async_view_memory_resource.hpp | 1 - 2 files changed, 36 deletions(-) diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index ac6b72076..a51e6b886 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -25,7 +25,6 @@ #include #include -#include #include #include @@ -68,40 +67,6 @@ class cuda_async_memory_resource final : public device_memory_resource { win32_kmt = 0x4 ///< Allows a Win32 KMT handle to be used for exporting. (D3DKMT_HANDLE) }; - /** - * @brief Constructs a cuda_async_memory_resource with the optionally specified initial pool size - * and release threshold. - * - * If the pool size grows beyond the release threshold, unused memory held by the pool will be - * released at the next synchronization event. - * - * @throws rmm::logic_error if the CUDA version does not support `cudaMallocAsync` - * - * @param initial_pool_size Optional initial size in bytes of the pool. If no value is provided, - * initial pool size is half of the available GPU memory. - * @param release_threshold Optional release threshold size in bytes of the pool. If no value is - * provided, the release threshold is set to the total amount of memory on the current device. - * @param export_handle_type Optional `cudaMemAllocationHandleType` that allocations from this - * resource should support interprocess communication (IPC). Default is - * `cudaMemHandleTypeNone` for no IPC support. - */ - // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) - template , - thrust::optional>, - int> = 0> - [[deprecated("Use std::optional instead of thrust::optional.")]] // - explicit cuda_async_memory_resource( - Optional initial_pool_size, - Optional release_threshold = {}, - thrust::optional export_handle_type = {}) - : cuda_async_memory_resource(initial_pool_size.value_or(std::nullopt), - release_threshold.value_or(std::nullopt), - export_handle_type.value_or(std::nullopt)) - - { - } - /** * @brief Constructs a cuda_async_memory_resource with the optionally specified initial pool size * and release threshold. diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index c07730f70..9ca695b9d 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -23,7 +23,6 @@ #include #include -#include #include #include From 588928f5ff2418aadcec8e6c91fcea4dd8cb9265 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Tue, 16 Apr 2024 15:27:18 +0100 Subject: [PATCH 389/675] Make thrust_allocator deallocate safe in multi-device setting (#1533) Previously, the user had to arrange that the device active when a thrust_allocator object was created was also active when allocate and deallocate was called. This is hard to manage if exceptions are thrown. Instead, save the active device on construction and ensure that it is active when calling deallocate and deallocate. This means that device_vector is safe to destruct with RAII semantics in a multi-device setting. Add tests of this facility, and correct the parameterization usage in the other thrust allocator tests such that we actually check the MRs we're parameterizing over. - Closes #1527 Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Rong Ou (https://github.com/rongou) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1533 --- README.md | 26 ++++++++++++------- .../mr/device/thrust_allocator_adaptor.hpp | 9 ++++++- tests/mr/device/thrust_allocator_tests.cu | 19 ++++++++++++++ 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5b7dc69c0..f378cfe50 100644 --- a/README.md +++ b/README.md @@ -375,14 +375,16 @@ this code is correct: #### Use of `rmm::device_vector` with multiple devices -> [!CAUTION] In contrast to the uninitialized `rmm:device_uvector`, `rmm::device_vector` **DOES -> NOT** store the active device during construction, and therefore cannot arrange for it to be -> active when the destructor runs. It is therefore the responsibility of the user to ensure the -> currently active device is correct. +`rmm:device_vector` uses an `rmm::mr::thrust_allocator` to enable `thrust::device_vector` to +allocate and deallocate memory using RMM. As such, the usual rules for usage of the backing memory +resource apply: the active device must match the active device at resource construction time. To +facilitate use in an RAII setting, `rmm::mr::thrust_allocator` records the active device at +construction time and ensures that device is active whenever it allocates or deallocates memory. +Usage of `rmm::device_vector` with multiple devices is therefore the same as `rmm::device_buffer`. +One must _create_ `device_vector`s with the correct device active, but it is safe to destroy them +with a different active device. -`rmm::device_vector` is therefore slightly less ergonomic to use in a multiple device setting since -the caller must arrange that active devices on allocation and deallocation match. Recapitulating the -previous example using `rmm::device_vector`: +For example, recapitulating the previous example using `rmm::device_vector`: ```c++ { @@ -391,12 +393,16 @@ previous example using `rmm::device_vector`: rmm::device_vector vec(16, rmm::mr::thrust_allocator(rmm::cuda_stream_default, &mr)); RMM_CUDA_TRY(cudaSetDevice(1)); ... - // ERROR: ~vec runs with device 1 active, but needs device 0 to be active + // No need to switch back to device 0 before ~vec runs } ``` -A correct example adds a call to `cudaSetDevice(0)` on the line of the error comment before the dtor -for `~vec` runs. +> [!NOTE] +> Although allocation and deallocation in the `thrust_allocator` run with the correct active device, +> modification of `rmm::device_vector` might necessitate a kernel launch, and this must run with the +> correct device active. For example, `.resize()` might both allocate _and_ launch a kernel to +> initialize new elements: the user must arrange for this kernel launch to occur with the correct +> device for the memory resource active. ## `cuda_stream_view` and `cuda_stream` diff --git a/include/rmm/mr/device/thrust_allocator_adaptor.hpp b/include/rmm/mr/device/thrust_allocator_adaptor.hpp index 41973e04b..3bfd65996 100644 --- a/include/rmm/mr/device/thrust_allocator_adaptor.hpp +++ b/include/rmm/mr/device/thrust_allocator_adaptor.hpp @@ -16,6 +16,7 @@ #pragma once +#include #include #include #include @@ -39,6 +40,9 @@ namespace rmm::mr { * allocate objects of a specific type `T`, but can be freely rebound to other * types. * + * The allocator records the current cuda device and may only be used with a backing + * `device_async_resource_ref` valid for the same device. + * * @tparam T The type of the objects that will be allocated by this allocator */ template @@ -92,7 +96,7 @@ class thrust_allocator : public thrust::device_malloc_allocator { */ template thrust_allocator(thrust_allocator const& other) - : _mr(other.resource()), _stream{other.stream()} + : _mr(other.resource()), _stream{other.stream()}, _device{other._device} { } @@ -104,6 +108,7 @@ class thrust_allocator : public thrust::device_malloc_allocator { */ pointer allocate(size_type num) { + cuda_set_device_raii dev{_device}; return thrust::device_pointer_cast( static_cast(_mr.allocate_async(num * sizeof(T), _stream))); } @@ -117,6 +122,7 @@ class thrust_allocator : public thrust::device_malloc_allocator { */ void deallocate(pointer ptr, size_type num) { + cuda_set_device_raii dev{_device}; return _mr.deallocate_async(thrust::raw_pointer_cast(ptr), num * sizeof(T), _stream); } @@ -143,6 +149,7 @@ class thrust_allocator : public thrust::device_malloc_allocator { private: cuda_stream_view _stream{}; rmm::device_async_resource_ref _mr{rmm::mr::get_current_device_resource()}; + cuda_device_id _device{get_current_cuda_device()}; }; /** @} */ // end of group } // namespace rmm::mr diff --git a/tests/mr/device/thrust_allocator_tests.cu b/tests/mr/device/thrust_allocator_tests.cu index b94d6b3e1..e855d1036 100644 --- a/tests/mr/device/thrust_allocator_tests.cu +++ b/tests/mr/device/thrust_allocator_tests.cu @@ -16,7 +16,9 @@ #include "mr_ref_test.hpp" +#include #include +#include #include #include #include @@ -36,6 +38,7 @@ struct allocator_test : public mr_ref_test {}; TEST_P(allocator_test, first) { + rmm::mr::set_current_device_resource(this->mr.get()); auto const num_ints{100}; rmm::device_vector ints(num_ints, 1); EXPECT_EQ(num_ints, thrust::reduce(ints.begin(), ints.end())); @@ -43,12 +46,28 @@ TEST_P(allocator_test, first) TEST_P(allocator_test, defaults) { + rmm::mr::set_current_device_resource(this->mr.get()); rmm::mr::thrust_allocator allocator(rmm::cuda_stream_default); EXPECT_EQ(allocator.stream(), rmm::cuda_stream_default); EXPECT_EQ(allocator.get_upstream_resource(), rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}); } +TEST_P(allocator_test, multi_device) +{ + if (rmm::get_num_cuda_devices() < 2) { GTEST_SKIP() << "Needs at least two devices"; } + cuda_set_device_raii with_device{rmm::get_current_cuda_device()}; + rmm::cuda_stream stream{}; + // make allocator on device-0 + rmm::mr::thrust_allocator allocator(stream.view(), this->ref); + auto const size{100}; + EXPECT_NO_THROW([&]() { + auto vec = rmm::device_vector(size, allocator); + // Destruct with device-1 active + RMM_CUDA_TRY(cudaSetDevice(1)); + }()); +} + INSTANTIATE_TEST_CASE_P(ThrustAllocatorTests, allocator_test, ::testing::Values(mr_factory{"CUDA", &make_cuda}, From 9e6db746f1a4a6361fb9fadf381f749dc52faaea Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 17 Apr 2024 11:18:24 -0400 Subject: [PATCH 390/675] Always use a static gtest (#1532) Removes the need for us to install GTest in our rmm CI containers. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Bradley Dice (https://github.com/bdice) - Mark Harris (https://github.com/harrism) - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1532 --- CMakeLists.txt | 3 ++- cmake/thirdparty/get_gtest.cmake | 22 -------------------- conda/recipes/librmm/conda_build_config.yaml | 3 --- conda/recipes/librmm/meta.yaml | 4 ---- 4 files changed, 2 insertions(+), 30 deletions(-) delete mode 100644 cmake/thirdparty/get_gtest.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 56454d4b1..fd0ab3422 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,7 +114,8 @@ endif() # * add tests -------------------------------------------------------------------------------------- if(BUILD_TESTS AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) - include(cmake/thirdparty/get_gtest.cmake) + include(${rapids-cmake-dir}/cpm/gtest.cmake) + rapids_cpm_gtest(BUILD_STATIC) include(CTest) # calls enable_testing() add_subdirectory(tests) diff --git a/cmake/thirdparty/get_gtest.cmake b/cmake/thirdparty/get_gtest.cmake deleted file mode 100644 index 4d4daff44..000000000 --- a/cmake/thirdparty/get_gtest.cmake +++ /dev/null @@ -1,22 +0,0 @@ -# ============================================================================= -# Copyright (c) 2021, 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. -# ============================================================================= - -# Use CPM to find or clone gtest -function(find_and_configure_gtest) - include(${rapids-cmake-dir}/cpm/gtest.cmake) - rapids_cpm_gtest() - -endfunction() - -find_and_configure_gtest() diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index ed58ac507..e44698952 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -16,9 +16,6 @@ cmake_version: fmt_version: - ">=10.1.1,<11" -gtest_version: - - ">=1.13.0" - spdlog_version: - ">=1.12.0,<1.13" diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 60cd6ffae..8263e0f3d 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -33,8 +33,6 @@ requirements: # added as a run requirement via the packages' run_exports. - fmt {{ fmt_version }} - spdlog {{ spdlog_version }} - - gtest {{ gtest_version }} - - gmock {{ gtest_version }} build: script_env: @@ -150,8 +148,6 @@ outputs: {% endif %} - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - {{ pin_subpackage('librmm', exact=True) }} - - gtest {{ gtest_version }} - - gmock {{ gtest_version }} about: home: https://rapids.ai/ license: Apache-2.0 From 3caaa08ecec0b4dd054f07c19ba02353138521f8 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Tue, 30 Apr 2024 22:38:23 +1000 Subject: [PATCH 391/675] Remove deprecated functionality (#1537) Closes #1536 Authors: - Mark Harris (https://github.com/harrism) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Vyas Ramasubramani (https://github.com/vyasr) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1537 --- conda/recipes/librmm/meta.yaml | 1 - include/rmm/detail/aligned.hpp | 81 --------- .../rmm/mr/device/pool_memory_resource.hpp | 170 ------------------ include/rmm/thrust_rmm_allocator.h | 55 ------ python/rmm/docs/conf.py | 12 ++ 5 files changed, 12 insertions(+), 307 deletions(-) delete mode 100644 include/rmm/thrust_rmm_allocator.h diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 8263e0f3d..0d3bd0add 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -81,7 +81,6 @@ outputs: - spdlog {{ spdlog_version }} test: commands: - - test -f $PREFIX/include/rmm/thrust_rmm_allocator.h - test -f $PREFIX/include/rmm/logger.hpp - test -f $PREFIX/include/rmm/cuda_stream.hpp - test -f $PREFIX/include/rmm/cuda_stream_view.hpp diff --git a/include/rmm/detail/aligned.hpp b/include/rmm/detail/aligned.hpp index eb31658e9..1206a1983 100644 --- a/include/rmm/detail/aligned.hpp +++ b/include/rmm/detail/aligned.hpp @@ -26,87 +26,6 @@ namespace rmm::detail { -/** - * @brief Default alignment used for host memory allocated by RMM. - * - */ -[[deprecated("Use rmm::RMM_DEFAULT_HOST_ALIGNMENT instead.")]] static constexpr std::size_t - RMM_DEFAULT_HOST_ALIGNMENT{rmm::RMM_DEFAULT_HOST_ALIGNMENT}; - -/** - * @brief Default alignment used for CUDA memory allocation. - * - */ -[[deprecated("Use rmm::CUDA_ALLOCATION_ALIGNMENT instead.")]] static constexpr std::size_t - CUDA_ALLOCATION_ALIGNMENT{rmm::CUDA_ALLOCATION_ALIGNMENT}; - -/** - * @brief Returns whether or not `n` is a power of 2. - * - */ -[[deprecated("Use rmm::is_pow2 instead.")]] constexpr bool is_pow2(std::size_t value) noexcept -{ - return rmm::is_pow2(value); -} - -/** - * @brief Returns whether or not `alignment` is a valid memory alignment. - * - */ -[[deprecated("Use rmm::is_supported_alignment instead.")]] constexpr bool is_supported_alignment( - std::size_t alignment) noexcept -{ - return rmm::is_pow2(alignment); -} - -/** - * @brief Align up to nearest multiple of specified power of 2 - * - * @param[in] value value to align - * @param[in] alignment amount, in bytes, must be a power of 2 - * - * @return Return the aligned value, as one would expect - */ -[[deprecated("Use rmm::align_up instead.")]] constexpr std::size_t align_up( - std::size_t value, std::size_t alignment) noexcept -{ - return rmm::align_up(value, alignment); -} - -/** - * @brief Align down to the nearest multiple of specified power of 2 - * - * @param[in] value value to align - * @param[in] alignment amount, in bytes, must be a power of 2 - * - * @return Return the aligned value, as one would expect - */ -[[deprecated("Use rmm::align_down instead.")]] constexpr std::size_t align_down( - std::size_t value, std::size_t alignment) noexcept -{ - return rmm::align_down(value, alignment); -} - -/** - * @brief Checks whether a value is aligned to a multiple of a specified power of 2 - * - * @param[in] value value to check for alignment - * @param[in] alignment amount, in bytes, must be a power of 2 - * - * @return true if aligned - */ -[[deprecated("Use rmm::is_aligned instead.")]] constexpr bool is_aligned( - std::size_t value, std::size_t alignment) noexcept -{ - return rmm::is_aligned(value, alignment); -} - -[[deprecated("Use rmm::is_pointer_aligned instead.")]] inline bool is_pointer_aligned( - void* ptr, std::size_t alignment = rmm::CUDA_ALLOCATION_ALIGNMENT) -{ - return rmm::is_pointer_aligned(ptr, alignment); -} - /** * @brief Allocates sufficient host-accessible memory to satisfy the requested size `bytes` with * alignment `alignment` using the unary callable `alloc` to allocate memory. diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 4cbdeef4a..5c0b9a29f 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -111,147 +111,6 @@ class pool_memory_resource final friend class detail::stream_ordered_memory_resource, detail::coalescing_free_list>; - /** - * @brief Construct a `pool_memory_resource` and allocate the initial device memory - * pool using `upstream_mr`. - * - * @deprecated Use the constructor that takes an explicit initial pool size instead. - * - * @throws rmm::logic_error if `upstream_mr == nullptr` - * @throws rmm::logic_error if `initial_pool_size` is neither the default nor aligned to a - * multiple of pool_memory_resource::allocation_alignment bytes. - * @throws rmm::logic_error if `maximum_pool_size` is neither the default nor aligned to a - * multiple of pool_memory_resource::allocation_alignment bytes. - * - * @param upstream_mr The memory_resource from which to allocate blocks for the pool. - * @param initial_pool_size Minimum size, in bytes, of the initial pool. Defaults to zero. - * @param maximum_pool_size Maximum size, in bytes, that the pool can grow to. Defaults to all - * of the available memory from the upstream resource. - */ - template , - thrust::optional>, - int> = 0> - [[deprecated( - "Must specify initial_pool_size and use std::optional instead of thrust::optional.")]] // - explicit pool_memory_resource(Upstream* upstream_mr, - Optional initial_pool_size, - Optional maximum_pool_size = thrust::nullopt) - : pool_memory_resource( - upstream_mr, initial_pool_size.value_or(0), maximum_pool_size.value_or(std::nullopt)) - { - } - - /** - * @brief Construct a `pool_memory_resource` and allocate the initial device memory - * pool using `upstream_mr`. - * - * @deprecated Use the constructor that takes an explicit initial pool size instead. - * - * @throws rmm::logic_error if `upstream_mr == nullptr` - * @throws rmm::logic_error if `initial_pool_size` is neither the default nor aligned to a - * multiple of pool_memory_resource::allocation_alignment bytes. - * @throws rmm::logic_error if `maximum_pool_size` is neither the default nor aligned to a - * multiple of pool_memory_resource::allocation_alignment bytes. - * - * @param upstream_mr The memory_resource from which to allocate blocks for the pool. - * @param initial_pool_size Minimum size, in bytes, of the initial pool. Defaults to zero. - * @param maximum_pool_size Maximum size, in bytes, that the pool can grow to. Defaults to all - * of the available memory from the upstream resource. - */ - [[deprecated("Must specify initial_pool_size")]] // - explicit pool_memory_resource(Upstream* upstream_mr, - std::optional initial_pool_size = std::nullopt, - std::optional maximum_pool_size = std::nullopt) - : pool_memory_resource(upstream_mr, initial_pool_size.value_or(0), maximum_pool_size) - { - } - - /** - * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using - * `upstream_mr`. - * - * @deprecated Use the constructor that takes an explicit initial pool size instead. - * - * @throws rmm::logic_error if `upstream_mr == nullptr` - * @throws rmm::logic_error if `initial_pool_size` is neither the default nor aligned to a - * multiple of pool_memory_resource::allocation_alignment bytes. - * @throws rmm::logic_error if `maximum_pool_size` is neither the default nor aligned to a - * multiple of pool_memory_resource::allocation_alignment bytes. - * - * @param upstream_mr The memory_resource from which to allocate blocks for the pool. - * @param initial_pool_size Minimum size, in bytes, of the initial pool. Defaults to zero. - * @param maximum_pool_size Maximum size, in bytes, that the pool can grow to. Defaults to all - * of the available memory from the upstream resource. - */ - template , - thrust::optional>, - int> = 0> - [[deprecated( - "Must specify initial_pool_size and use std::optional instead of thrust::optional.")]] // - explicit pool_memory_resource(Upstream& upstream_mr, - Optional initial_pool_size, - Optional maximum_pool_size = thrust::nullopt) - : pool_memory_resource( - upstream_mr, initial_pool_size.value_or(0), maximum_pool_size.value_or(std::nullopt)) - { - } - - /** - * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using - * `upstream_mr`. - * - * @deprecated Use the constructor that takes an explicit initial pool size instead. - * - * @throws rmm::logic_error if `upstream_mr == nullptr` - * @throws rmm::logic_error if `initial_pool_size` is neither the default nor aligned to a - * multiple of pool_memory_resource::allocation_alignment bytes. - * @throws rmm::logic_error if `maximum_pool_size` is neither the default nor aligned to a - * multiple of pool_memory_resource::allocation_alignment bytes. - * - * @param upstream_mr The memory_resource from which to allocate blocks for the pool. - * @param initial_pool_size Minimum size, in bytes, of the initial pool. Defaults to zero. - * @param maximum_pool_size Maximum size, in bytes, that the pool can grow to. Defaults to all - * of the available memory from the upstream resource. - */ - template , int> = 0> - [[deprecated("Must specify initial_pool_size")]] // - explicit pool_memory_resource(Upstream2& upstream_mr, - std::optional initial_pool_size = std::nullopt, - std::optional maximum_pool_size = std::nullopt) - : pool_memory_resource(upstream_mr, initial_pool_size.value_or(0), maximum_pool_size) - { - } - - /** - * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using - * `upstream_mr`. - * - * @throws rmm::logic_error if `upstream_mr == nullptr` - * @throws rmm::logic_error if `initial_pool_size` is not aligned to a multiple of - * pool_memory_resource::allocation_alignment bytes. - * @throws rmm::logic_error if `maximum_pool_size` is neither the default nor aligned to a - * multiple of pool_memory_resource::allocation_alignment bytes. - * - * @param upstream_mr The memory_resource from which to allocate blocks for the pool. - * @param initial_pool_size Minimum size, in bytes, of the initial pool. - * @param maximum_pool_size Maximum size, in bytes, that the pool can grow to. Defaults to all - * of the available from the upstream resource. - */ - template , - thrust::optional>, - int> = 0> - [[deprecated("Use std::optional instead of thrust::optional.")]] // - explicit pool_memory_resource(Upstream* upstream_mr, - std::size_t initial_pool_size, - Optional maximum_pool_size) - : pool_memory_resource(upstream_mr, initial_pool_size, maximum_pool_size.value_or(std::nullopt)) - { - } - /** * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using * `upstream_mr`. @@ -283,35 +142,6 @@ class pool_memory_resource final initialize_pool(initial_pool_size, maximum_pool_size); } - /** - * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using - * `upstream_mr`. - * - * @throws rmm::logic_error if `upstream_mr == nullptr` - * @throws rmm::logic_error if `initial_pool_size` is not aligned to a multiple of - * pool_memory_resource::allocation_alignment bytes. - * @throws rmm::logic_error if `maximum_pool_size` is neither the default nor aligned to a - * multiple of pool_memory_resource::allocation_alignment bytes. - * - * @param upstream_mr The memory_resource from which to allocate blocks for the pool. - * @param initial_pool_size Minimum size, in bytes, of the initial pool. - * @param maximum_pool_size Maximum size, in bytes, that the pool can grow to. Defaults to all - * of the available memory from the upstream resource. - */ - template , - thrust::optional>, - int> = 0> - [[deprecated("Use std::optional instead of thrust::optional.")]] // - explicit pool_memory_resource(Upstream& upstream_mr, - std::size_t initial_pool_size, - Optional maximum_pool_size) - : pool_memory_resource(cuda::std::addressof(upstream_mr), - initial_pool_size, - maximum_pool_size.value_or(std::nullopt)) - { - } - /** * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using * `upstream_mr`. diff --git a/include/rmm/thrust_rmm_allocator.h b/include/rmm/thrust_rmm_allocator.h deleted file mode 100644 index ad71e107a..000000000 --- a/include/rmm/thrust_rmm_allocator.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2018-2021, 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. - */ - -#pragma once - -#include -#include -#include -#include - -#include - -namespace rmm { - -using par_t = decltype(thrust::cuda::par(*(new rmm::mr::thrust_allocator()))); -using deleter_t = std::function; -using exec_policy_t = std::unique_ptr; - -/** - * @brief Returns a unique_ptr to a Thrust CUDA execution policy that uses RMM - * for temporary memory allocation. - * - * @param stream The stream that the allocator will use - * - * @return A Thrust execution policy that will use RMM for temporary memory - * allocation. - */ -[[deprecated("Use new exec_policy in rmm/exec_policy.hpp")]] inline exec_policy_t exec_policy( - cudaStream_t stream = nullptr) -{ - // NOLINTNEXTLINE(cppcoreguidelines-owning-memory) - auto* alloc = new rmm::mr::thrust_allocator(cuda_stream_view{stream}); - auto deleter = [alloc](par_t* pointer) { - delete alloc; // NOLINT(cppcoreguidelines-owning-memory) - delete pointer; // NOLINT(cppcoreguidelines-owning-memory) - }; - - exec_policy_t policy{new par_t(*alloc), deleter}; - return policy; -} - -} // namespace rmm diff --git a/python/rmm/docs/conf.py b/python/rmm/docs/conf.py index 0140c84b2..6ed770151 100644 --- a/python/rmm/docs/conf.py +++ b/python/rmm/docs/conf.py @@ -89,6 +89,18 @@ # This patterns also effect to html_static_path and html_extra_path exclude_patterns = [] +# List of warnings to suppress +suppress_warnings = [] + +# if the file deprecated.xml does not exist in the doxygen xml output, +# breathe will fail to build the docs, so we conditionally add +# "deprecated.rst" to the exclude_patterns list +if not os.path.exists( + os.path.join(breathe_projects["librmm"], "deprecated.xml") +): + exclude_patterns.append("librmm_docs/deprecated.rst") + suppress_warnings.append("toc.excluded") + # The name of the Pygments (syntax highlighting) style to use. pygments_style = "sphinx" From bdb7a592fa2fa306209906417f964059b2cb5934 Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Tue, 30 Apr 2024 09:18:43 -0500 Subject: [PATCH 392/675] Remove unneeded `update-version.sh` update (#1520) This shouldn't update `build_docs.sh` as this file already reads the version from an updated file. Authors: - Jake Awe (https://github.com/AyodeAwe) - Bradley Dice (https://github.com/bdice) Approvers: - Bradley Dice (https://github.com/bdice) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1520 --- ci/release/update-version.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 2a6e550df..dcd8e85a2 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -39,7 +39,6 @@ echo "${NEXT_FULL_TAG}" > VERSION for FILE in .github/workflows/*.yaml; do sed_runner "/shared-workflows/ s/@.*/@branch-${NEXT_SHORT_TAG}/g" "${FILE}" done -sed_runner "s/RAPIDS_VERSION_NUMBER=\".*/RAPIDS_VERSION_NUMBER=\"${NEXT_SHORT_TAG}\"/g" ci/build_docs.sh # .devcontainer files find .devcontainer/ -type f -name devcontainer.json -print0 | while IFS= read -r -d '' filename; do From 26fa9ecbbdb44de1ef80235e2c750abfe6de0c4f Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Tue, 30 Apr 2024 22:31:52 +0100 Subject: [PATCH 393/675] Fix Python install instruction (#1547) In #1526 we moved the location of the python package, so should also update the install instructions. - Closes #1546 Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Mark Harris (https://github.com/harrism) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1547 --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f378cfe50..c6cd44c47 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,8 @@ $ make test - Build, install, and test the `rmm` python package, in the `python` folder: ```bash -$ python -m pip install -e ./python +# In the root rmm directory +$ python -m pip install -e ./python/rmm $ pytest -v ``` From c74dda239b34da1a55dfbcb069f4f5ad098e2c99 Mon Sep 17 00:00:00 2001 From: Paul Taylor <178183+trxcllnt@users.noreply.github.com> Date: Tue, 30 Apr 2024 15:05:48 -0700 Subject: [PATCH 394/675] Fix `cuda11.8` nvcc dependency (#1542) `cuda-nvcc` is the CUDA 12 package name but was being included in the CUDA 11 dependencies, making the conda solve impossible. This PR uses the same nvcc matrix as defined in the build dependencies list. Authors: - Paul Taylor (https://github.com/trxcllnt) Approvers: - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1542 --- .../all_cuda-118_arch-x86_64.yaml | 1 - dependencies.yaml | 20 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index c4bbcccd2..5806b8bd9 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -9,7 +9,6 @@ dependencies: - clang-tools==16.0.6 - clang==16.0.6 - cmake>=3.26.4 -- cuda-nvcc - cuda-python>=11.7.1,<12.0a0 - cuda-version=11.8 - cudatoolkit diff --git a/dependencies.yaml b/dependencies.yaml index 10d0eab2d..232f9bddd 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -249,7 +249,21 @@ dependencies: packages: - pytest - pytest-cov + # Needed for numba in tests + specific: - output_types: conda - packages: - # Needed for numba in tests - - cuda-nvcc + matrices: + - matrix: + arch: x86_64 + cuda: "11.8" + packages: + - nvcc_linux-64=11.8 + - matrix: + arch: aarch64 + cuda: "11.8" + packages: + - nvcc_linux-aarch64=11.8 + - matrix: + cuda: "12.*" + packages: + - cuda-nvcc From 01ccf97d8ec197a1c56ad1447a05d23aa492da05 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 30 Apr 2024 15:35:55 -0700 Subject: [PATCH 395/675] Only use functions in the limited API (#1545) This PR removes usage of the only method in rmm's Cython that is not part of the Python limited API. Contributes to https://github.com/rapidsai/build-planning/issues/42 Authors: - Vyas Ramasubramani (https://github.com/vyasr) - https://github.com/jakirkham Approvers: - https://github.com/jakirkham URL: https://github.com/rapidsai/rmm/pull/1545 --- python/rmm/rmm/_lib/device_buffer.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/rmm/rmm/_lib/device_buffer.pyx b/python/rmm/rmm/_lib/device_buffer.pyx index 3ce10c5f6..bbeaa614e 100644 --- a/python/rmm/rmm/_lib/device_buffer.pyx +++ b/python/rmm/rmm/_lib/device_buffer.pyx @@ -14,7 +14,7 @@ import numpy as np cimport cython -from cpython.bytes cimport PyBytes_AS_STRING, PyBytes_FromStringAndSize +from cpython.bytes cimport PyBytes_FromStringAndSize from libc.stdint cimport uintptr_t from libcpp.memory cimport unique_ptr from libcpp.utility cimport move @@ -314,7 +314,7 @@ cdef class DeviceBuffer: cdef size_t s = dbp.size() cdef bytes b = PyBytes_FromStringAndSize(NULL, s) - cdef unsigned char* p = PyBytes_AS_STRING(b) + cdef unsigned char* p = b cdef unsigned char[::1] mv = (p)[:s] self.copy_to_host(mv, stream) From 9d0a29a4e2d76b2ec0437282373df690572c1dfc Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 1 May 2024 17:47:56 -0500 Subject: [PATCH 396/675] Remove header existence tests. (#1550) This PR removes header existence tests from the librmm conda recipe to reduce friction when code is moved. Closes https://github.com/rapidsai/rmm/issues/1549. These changes are similar to https://github.com/rapidsai/cudf/pull/14072. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) - Lawrence Mitchell (https://github.com/wence-) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1550 --- conda/recipes/librmm/meta.yaml | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 0d3bd0add..403f7c8c1 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -81,37 +81,7 @@ outputs: - spdlog {{ spdlog_version }} test: commands: - - test -f $PREFIX/include/rmm/logger.hpp - - test -f $PREFIX/include/rmm/cuda_stream.hpp - - test -f $PREFIX/include/rmm/cuda_stream_view.hpp - - test -f $PREFIX/include/rmm/cuda_stream_pool.hpp - - test -f $PREFIX/include/rmm/device_uvector.hpp - - test -f $PREFIX/include/rmm/device_scalar.hpp - - test -f $PREFIX/include/rmm/device_buffer.hpp - - test -f $PREFIX/include/rmm/detail/aligned.hpp - - test -f $PREFIX/include/rmm/detail/error.hpp - - test -f $PREFIX/include/rmm/detail/exec_check_disable.hpp - - test -f $PREFIX/include/rmm/mr/device/detail/arena.hpp - - test -f $PREFIX/include/rmm/mr/device/detail/free_list.hpp - - test -f $PREFIX/include/rmm/mr/device/detail/coalescing_free_list.hpp - - test -f $PREFIX/include/rmm/mr/device/detail/fixed_size_free_list.hpp - - test -f $PREFIX/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/arena_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/binning_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/cuda_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/device_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/fixed_size_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/limiting_resource_adaptor.hpp - - test -f $PREFIX/include/rmm/mr/device/logging_resource_adaptor.hpp - - test -f $PREFIX/include/rmm/mr/device/managed_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/owning_wrapper.hpp - - test -f $PREFIX/include/rmm/mr/device/per_device_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/pool_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/device/thread_safe_resource_adaptor.hpp - - test -f $PREFIX/include/rmm/mr/device/thrust_allocator_adaptor.hpp - - test -f $PREFIX/include/rmm/mr/host/host_memory_resource.hpp - - test -f $PREFIX/include/rmm/mr/host/new_delete_resource.hpp - - test -f $PREFIX/include/rmm/mr/host/pinned_memory_resource.hpp + - test -d "${PREFIX}/include/rmm" about: home: https://rapids.ai/ license: Apache-2.0 From 363e4c627e316c6de48d1a12003fee8ae408a5bc Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Thu, 2 May 2024 06:48:30 -1000 Subject: [PATCH 397/675] Enable warnings as errors for Python tests (#1551) As part of https://github.com/rapidsai/build-planning/issues/26, warnings in Python tests will cause that test to fail. Authors: - Matthew Roeschke (https://github.com/mroeschke) - Lawrence Mitchell (https://github.com/wence-) Approvers: - Lawrence Mitchell (https://github.com/wence-) URL: https://github.com/rapidsai/rmm/pull/1551 --- python/rmm/.coveragerc | 1 + python/rmm/pyproject.toml | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/python/rmm/.coveragerc b/python/rmm/.coveragerc index 6b49c4df6..00997a39b 100644 --- a/python/rmm/.coveragerc +++ b/python/rmm/.coveragerc @@ -2,3 +2,4 @@ [run] include = rmm/* omit = rmm/tests/* +disable_warnings=include-ignored diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index ea8639feb..9ad6d6bbf 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -123,3 +123,8 @@ wheel.packages = ["rmm"] provider = "scikit_build_core.metadata.regex" input = "rmm/VERSION" regex = "(?P.*)" + +[tool.pytest.ini_options] +filterwarnings = [ + "error", +] From beab71aa5bd980e383e42b816aec321361fad4f4 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 3 May 2024 11:56:31 -0700 Subject: [PATCH 398/675] Build C++ wheel (#1529) This PR changes wheel building in RMM to create a separate C++ wheel that is then found from the Python wheel. The C++ wheel is now a hard dependency of the Python wheel. This allows Python packaging to more closely mirror the structure of our conda packaging, and the way we would normally wish to package these in any other manager. It also allows us to reduce package sizes by allowing better sharing of artifacts between different Python packages that rely on the same C++ components from other packages. Contributes to rapidsai/build-planning#33 Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Ray Douglass (https://github.com/raydouglass) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1529 --- .github/workflows/pr.yaml | 17 ++++-- CMakeLists.txt | 2 +- build.sh | 8 +-- ci/build_wheel_cpp.sh | 32 +++++++++++ ci/{build_wheel.sh => build_wheel_python.sh} | 12 +++- ci/test_wheel.sh | 5 +- dependencies.yaml | 20 +++++++ python/librmm/CMakeLists.txt | 38 +++++++++++++ python/librmm/LICENSE | 1 + python/librmm/README.md | 1 + python/librmm/librmm/VERSION | 1 + python/librmm/librmm/__init__.py | 15 +++++ python/librmm/librmm/_version.py | 20 +++++++ python/librmm/pyproject.toml | 60 ++++++++++++++++++++ python/rmm/CMakeLists.txt | 18 +----- python/rmm/pyproject.toml | 1 + 16 files changed, 218 insertions(+), 33 deletions(-) create mode 100755 ci/build_wheel_cpp.sh rename ci/{build_wheel.sh => build_wheel_python.sh} (74%) create mode 100644 python/librmm/CMakeLists.txt create mode 120000 python/librmm/LICENSE create mode 120000 python/librmm/README.md create mode 120000 python/librmm/librmm/VERSION create mode 100644 python/librmm/librmm/__init__.py create mode 100644 python/librmm/librmm/_version.py create mode 100644 python/librmm/pyproject.toml diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 2abbfd078..96e4503b7 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -18,7 +18,8 @@ jobs: - conda-python-build - conda-python-tests - docs-build - - wheel-build + - wheel-build-cpp + - wheel-build-python - wheel-tests - devcontainer secrets: inherit @@ -62,15 +63,23 @@ jobs: arch: "amd64" container_image: "rapidsai/ci-conda:latest" run_script: "ci/build_docs.sh" - wheel-build: + wheel-build-cpp: needs: checks secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.06 with: + matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request - script: ci/build_wheel.sh + script: ci/build_wheel_cpp.sh + wheel-build-python: + needs: wheel-build-cpp + secrets: inherit + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.06 + with: + build_type: pull-request + script: ci/build_wheel_python.sh wheel-tests: - needs: wheel-build + needs: wheel-build-python secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.06 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index fd0ab3422..62a192b7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,7 +50,7 @@ set_property(CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WA # build type for cmake-gui message(STATUS "RMM: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'") -# cudart can be statically linked or dynamically linked the python ecosystem wants dynamic linking +# cudart can be linked statically or dynamically option(CUDA_STATIC_RUNTIME "Statically link the CUDA runtime" OFF) # ################################################################################################## diff --git a/build.sh b/build.sh index fce8e0586..a52a9f594 100755 --- a/build.sh +++ b/build.sh @@ -141,12 +141,6 @@ if hasArg --ptds; then PER_THREAD_DEFAULT_STREAM=ON fi -# Append `-DFIND_RMM_CPP=ON` to CMAKE_ARGS unless a user specified the option. -SKBUILD_EXTRA_CMAKE_ARGS="${EXTRA_CMAKE_ARGS}" -if [[ "${EXTRA_CMAKE_ARGS}" != *"DFIND_RMM_CPP"* ]]; then - SKBUILD_EXTRA_CMAKE_ARGS="${SKBUILD_EXTRA_CMAKE_ARGS} -DFIND_RMM_CPP=ON" -fi - # If clean given, run it prior to any other steps if hasArg clean; then # If the dirs to clean are mounted dirs in a container, the @@ -176,5 +170,5 @@ fi # Build and install the rmm Python package if (( NUMARGS == 0 )) || hasArg rmm; then echo "building and installing rmm..." - SKBUILD_CMAKE_ARGS="${SKBUILD_EXTRA_CMAKE_ARGS}" python -m pip install --no-build-isolation --no-deps ${REPODIR}/python/rmm + SKBUILD_CMAKE_ARGS="${EXTRA_CMAKE_ARGS}" python -m pip install --no-build-isolation --no-deps ${REPODIR}/python/rmm fi diff --git a/ci/build_wheel_cpp.sh b/ci/build_wheel_cpp.sh new file mode 100755 index 000000000..e61f6641c --- /dev/null +++ b/ci/build_wheel_cpp.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# Copyright (c) 2024, NVIDIA CORPORATION. + +set -euo pipefail + +package_name="librmm" +package_dir="python/librmm" + +source rapids-configure-sccache +source rapids-date-string + +version=$(rapids-generate-version) +commit=$(git rev-parse HEAD) + +RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" + +# This is the version of the suffix with a preceding hyphen. It's used +# everywhere except in the final wheel name. +PACKAGE_CUDA_SUFFIX="-${RAPIDS_PY_CUDA_SUFFIX}" + +pyproject_file="${package_dir}/pyproject.toml" + +sed -i "s/name = \"${package_name}\"/name = \"${package_name}${PACKAGE_CUDA_SUFFIX}\"/g" ${pyproject_file} +echo "${version}" > VERSION +sed -i "/^__git_commit__/ s/= .*/= \"${commit}\"/g" "${package_dir}/${package_name}/_version.py" + +cd "${package_dir}" + +python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check +python -m pip install wheel +python -m wheel tags --platform any dist/* --remove +RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 cpp dist diff --git a/ci/build_wheel.sh b/ci/build_wheel_python.sh similarity index 74% rename from ci/build_wheel.sh rename to ci/build_wheel_python.sh index b76e882b3..54234ed20 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel_python.sh @@ -24,15 +24,23 @@ sed -i "s/name = \"${package_name}\"/name = \"${package_name}${PACKAGE_CUDA_SUFF echo "${version}" > VERSION sed -i "/^__git_commit__/ s/= .*/= \"${commit}\"/g" "${package_dir}/${package_name}/_version.py" +alpha_spec='' +if ! rapids-is-release-build; then + alpha_spec=',>=0.0.0a0' +fi + +sed -r -i "s/librmm==(.*)\"/librmm${PACKAGE_CUDA_SUFFIX}==\1${alpha_spec}\"/g" ${pyproject_file} if [[ $PACKAGE_CUDA_SUFFIX == "-cu12" ]]; then sed -i "s/cuda-python[<=>\.,0-9a]*/cuda-python>=12.0,<13.0a0/g" ${pyproject_file} fi cd "${package_dir}" -python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check +CPP_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp /tmp/librmm_dist) + +python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check --find-links "${CPP_WHEELHOUSE}" mkdir -p final_dist python -m auditwheel repair -w final_dist dist/* -RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 final_dist +RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 python final_dist diff --git a/ci/test_wheel.sh b/ci/test_wheel.sh index 3faf15ba2..6f14a0d45 100755 --- a/ci/test_wheel.sh +++ b/ci/test_wheel.sh @@ -4,9 +4,10 @@ set -eou pipefail RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" -RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 ./dist +WHEELHOUSE="${PWD}/dist/" +RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 python "${WHEELHOUSE}" # echo to expand wildcard before adding `[extra]` requires for pip -python -m pip install $(echo ./dist/rmm*.whl)[test] +python -m pip install "rmm-${RAPIDS_PY_CUDA_SUFFIX}[test]>=0.0.0a0" --find-links "${WHEELHOUSE}" python -m pytest ./python/rmm/rmm/tests diff --git a/dependencies.yaml b/dependencies.yaml index 232f9bddd..eb2c4e4f2 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -38,6 +38,13 @@ files: - cuda_version - docs - py_version + py_cpp_build: + output: pyproject + pyproject_dir: python/librmm + extras: + table: build-system + includes: + - build py_build: output: pyproject pyproject_dir: python/rmm @@ -125,6 +132,19 @@ dependencies: - matrix: # All CUDA 11 versions packages: - &cuda_python11 cuda-python>=11.7.1,<12.0a0 + - output_types: [requirements, pyproject] + matrices: + - matrix: + cuda: "12.*" + packages: + - librmm-cu12==24.6.* + - matrix: + cuda: "11.*" + packages: + - librmm-cu11==24.6.* + - matrix: + packages: + - librmm==24.6.* checks: common: - output_types: [conda, requirements] diff --git a/python/librmm/CMakeLists.txt b/python/librmm/CMakeLists.txt new file mode 100644 index 000000000..0217eb6fa --- /dev/null +++ b/python/librmm/CMakeLists.txt @@ -0,0 +1,38 @@ +# ============================================================================= +# Copyright (c) 2022, 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. +# ============================================================================= + +cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) + +include(../../rapids_config.cmake) + +project( + librmm-python + VERSION "${RAPIDS_VERSION}" + LANGUAGES CXX) + +# Check if rmm is already available. If so, it is the user's responsibility to ensure that the CMake +# package is also available at build time of the Python rmm package. +find_package(rmm "${RAPIDS_VERSION}") + +if(rmm_FOUND) + return() +endif() + +unset(rmm_FOUND) + +set(BUILD_TESTS OFF) +set(BUILD_BENCHMARKS OFF) +set(CUDA_STATIC_RUNTIME ON) + +add_subdirectory(../.. rmm-cpp) diff --git a/python/librmm/LICENSE b/python/librmm/LICENSE new file mode 120000 index 000000000..30cff7403 --- /dev/null +++ b/python/librmm/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/python/librmm/README.md b/python/librmm/README.md new file mode 120000 index 000000000..fe8400541 --- /dev/null +++ b/python/librmm/README.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/python/librmm/librmm/VERSION b/python/librmm/librmm/VERSION new file mode 120000 index 000000000..d62dc733e --- /dev/null +++ b/python/librmm/librmm/VERSION @@ -0,0 +1 @@ +../../../VERSION \ No newline at end of file diff --git a/python/librmm/librmm/__init__.py b/python/librmm/librmm/__init__.py new file mode 100644 index 000000000..b914ecdc3 --- /dev/null +++ b/python/librmm/librmm/__init__.py @@ -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. + +from librmm._version import __git_commit__, __version__ diff --git a/python/librmm/librmm/_version.py b/python/librmm/librmm/_version.py new file mode 100644 index 000000000..ea50101b2 --- /dev/null +++ b/python/librmm/librmm/_version.py @@ -0,0 +1,20 @@ +# 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. + +import importlib.resources + +__version__ = ( + importlib.resources.files("librmm").joinpath("VERSION").read_text().strip() +) +__git_commit__ = "" diff --git a/python/librmm/pyproject.toml b/python/librmm/pyproject.toml new file mode 100644 index 000000000..4b997be9a --- /dev/null +++ b/python/librmm/pyproject.toml @@ -0,0 +1,60 @@ +# 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. + +[build-system] +build-backend = "scikit_build_core.build" +requires = [ + "cmake>=3.26.4", + "ninja", + "scikit-build-core[pyproject]>=0.7.0", +] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. + +[project] +name = "librmm" +dynamic = ["version"] +description = "rmm - RAPIDS Memory Manager" +readme = { file = "README.md", content-type = "text/markdown" } +authors = [ + { name = "NVIDIA Corporation" }, +] +license = { text = "Apache 2.0" } +classifiers = [ + "Intended Audience :: Developers", + "Topic :: Database", + "Topic :: Scientific/Engineering", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: C++", + "Environment :: GPU :: NVIDIA CUDA", +] + +[project.urls] +Homepage = "https://github.com/rapidsai/rmm" + +[project.entry-points."cmake.prefix"] +librmm = "librmm" + +[tool.scikit-build] +build-dir = "build/{wheel_tag}" +cmake.build-type = "Release" +cmake.minimum-version = "3.26.4" +ninja.make-fallback = true +sdist.reproducible = true +wheel.packages = ["librmm"] +wheel.install-dir = "librmm" +wheel.py-api = "py3" + +[tool.scikit-build.metadata.version] +provider = "scikit_build_core.metadata.regex" +input = "librmm/VERSION" +regex = "(?P.*)" diff --git a/python/rmm/CMakeLists.txt b/python/rmm/CMakeLists.txt index 22b5ea282..0a472d42f 100644 --- a/python/rmm/CMakeLists.txt +++ b/python/rmm/CMakeLists.txt @@ -21,23 +21,7 @@ project( VERSION "${RAPIDS_VERSION}" LANGUAGES CXX) -option(FIND_RMM_CPP "Search for existing RMM C++ installations before defaulting to local files" - OFF) - -# If the user requested it we attempt to find RMM. -if(FIND_RMM_CPP) - find_package(rmm "${RAPIDS_VERSION}") -else() - set(rmm_FOUND OFF) -endif() - -if(NOT rmm_FOUND) - set(BUILD_TESTS OFF) - set(BUILD_BENCHMARKS OFF) - set(CUDA_STATIC_RUNTIME ON) - - add_subdirectory(../../ rmm-cpp EXCLUDE_FROM_ALL) -endif() +find_package(rmm "${RAPIDS_VERSION}" REQUIRED) include(rapids-cython-core) rapids_cython_init() diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 9ad6d6bbf..c799f101a 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -18,6 +18,7 @@ requires = [ "cmake>=3.26.4", "cuda-python>=11.7.1,<12.0a0", "cython>=3.0.0", + "librmm==24.6.*", "ninja", "scikit-build-core[pyproject]>=0.7.0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. From fdef5f9663514f6bd625a468a25ec8096fbfea7d Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 3 May 2024 14:50:55 -0700 Subject: [PATCH 399/675] Add publish jobs for C++ wheels (#1554) #1529 added new C++ wheels, but I forgot to update build.yaml there. Depends on https://github.com/rapidsai/shared-workflows/pull/209. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1554 --- .github/workflows/build.yaml | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f22d60673..895cac94d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -66,17 +66,39 @@ jobs: arch: "amd64" container_image: "rapidsai/ci-conda:latest" run_script: "ci/build_docs.sh" - wheel-build: + wheel-build-cpp: secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.06 with: + matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} sha: ${{ inputs.sha }} date: ${{ inputs.date }} - script: ci/build_wheel.sh - wheel-publish: - needs: wheel-build + script: ci/build_wheel_cpp.sh + wheel-build-python: + needs: wheel-build-cpp + secrets: inherit + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.06 + with: + build_type: ${{ inputs.build_type || 'branch' }} + branch: ${{ inputs.branch }} + sha: ${{ inputs.sha }} + date: ${{ inputs.date }} + script: ci/build_wheel_python.sh + wheel-publish-cpp: + needs: wheel-build-cpp + secrets: inherit + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.06 + with: + build_type: ${{ inputs.build_type || 'branch' }} + branch: ${{ inputs.branch }} + sha: ${{ inputs.sha }} + date: ${{ inputs.date }} + package-name: rmm + package-type: cpp + wheel-publish-python: + needs: wheel-build-python secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.06 with: @@ -85,3 +107,4 @@ jobs: sha: ${{ inputs.sha }} date: ${{ inputs.date }} package-name: rmm + package-type: python From c7fa7b1a315e77a058eebffecdad473ca3d4519a Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 6 May 2024 08:52:21 -0500 Subject: [PATCH 400/675] add RAPIDS copyright pre-commit hook (#1553) Contributes to https://github.com/rapidsai/build-planning/issues/30. Proposes adding the RAPIDS `verify-copyright` pre-commit hook, which automatically updates copyright dates for modified files. This also fixes one date in a file from #1529. Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Bradley Dice (https://github.com/bdice) - Kyle Edwards (https://github.com/KyleFromNVIDIA) URL: https://github.com/rapidsai/rmm/pull/1553 --- .pre-commit-config.yaml | 4 ++++ python/librmm/CMakeLists.txt | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c266be0bd..d21fcebf8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -81,6 +81,10 @@ repos: hooks: - id: ruff files: python/.*$ + - repo: https://github.com/rapidsai/pre-commit-hooks + rev: v0.0.3 + hooks: + - id: verify-copyright default_language_version: python: python3 diff --git a/python/librmm/CMakeLists.txt b/python/librmm/CMakeLists.txt index 0217eb6fa..a6035ac83 100644 --- a/python/librmm/CMakeLists.txt +++ b/python/librmm/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2022, 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 @@ -21,7 +21,7 @@ project( VERSION "${RAPIDS_VERSION}" LANGUAGES CXX) -# Check if rmm is already available. If so, it is the user's responsibility to ensure that the CMake +# Check if rmm is already available. If so, it's the user's responsibility to ensure that the CMake # package is also available at build time of the Python rmm package. find_package(rmm "${RAPIDS_VERSION}") From e13b253fdfa19ccdf563be5fbf4ffa1cdc6b87a0 Mon Sep 17 00:00:00 2001 From: Philip Hyunsu Cho Date: Mon, 6 May 2024 10:39:52 -0700 Subject: [PATCH 401/675] Migrate to `{{ stdlib("c") }}` (#1543) The `sysroot*` syntax is getting phased out (conda-forge/conda-forge.github.io#2102). The recommendation is to move to `{{ stdlib("c") }}`. Ref https://github.com/rapidsai/build-planning/issues/39 Authors: - Philip Hyunsu Cho (https://github.com/hcho3) - https://github.com/jakirkham Approvers: - Bradley Dice (https://github.com/bdice) - https://github.com/jakirkham - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1543 --- conda/recipes/librmm/conda_build_config.yaml | 4 +++- conda/recipes/librmm/meta.yaml | 2 +- conda/recipes/rmm/conda_build_config.yaml | 4 +++- conda/recipes/rmm/meta.yaml | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index e44698952..1740bfe2f 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -19,5 +19,7 @@ fmt_version: spdlog_version: - ">=1.12.0,<1.13" -sysroot_version: +c_stdlib: + - sysroot +c_stdlib_version: - "2.17" diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 403f7c8c1..88468305b 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -23,7 +23,7 @@ requirements: - {{ compiler('cuda') }} {% endif %} - cuda-version ={{ cuda_version }} - - sysroot_{{ target_platform }} {{ sysroot_version }} + - {{ stdlib("c") }} host: - cuda-version ={{ cuda_version }} # We require spdlog and fmt (which was devendored from spdlog diff --git a/conda/recipes/rmm/conda_build_config.yaml b/conda/recipes/rmm/conda_build_config.yaml index e28b98da7..e21871634 100644 --- a/conda/recipes/rmm/conda_build_config.yaml +++ b/conda/recipes/rmm/conda_build_config.yaml @@ -10,7 +10,9 @@ cuda_compiler: cuda11_compiler: - nvcc -sysroot_version: +c_stdlib: + - sysroot +c_stdlib_version: - "2.17" cmake_version: diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 764c3f75b..560bedd7e 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -51,7 +51,7 @@ requirements: - {{ compiler('cuda') }} {% endif %} - cuda-version ={{ cuda_version }} - - sysroot_{{ target_platform }} {{ sysroot_version }} + - {{ stdlib("c") }} host: - cuda-version ={{ cuda_version }} {% if cuda_major == "11" %} From 4f01c559ff61f2512ae14bae0d86f4a11a1bef93 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Wed, 8 May 2024 15:48:34 +1000 Subject: [PATCH 402/675] Refactor polymorphic allocator to use device_async_resource_ref (#1555) Fixes #1540. Fixes #1453 by removing unused `polymorphic_allocator::resource()`. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Michael Schellenberger Costa (https://github.com/miscco) - Rong Ou (https://github.com/rongou) URL: https://github.com/rapidsai/rmm/pull/1555 --- .clang-format | 1 + .gitignore | 1 + .../rmm/mr/device/polymorphic_allocator.hpp | 90 ++++++++++++++----- .../mr/device/polymorphic_allocator_tests.cpp | 13 +-- 4 files changed, 75 insertions(+), 30 deletions(-) diff --git a/.clang-format b/.clang-format index 35ebdbfae..951a549d0 100644 --- a/.clang-format +++ b/.clang-format @@ -46,6 +46,7 @@ BraceWrapping: SplitEmptyFunction: false SplitEmptyRecord: false SplitEmptyNamespace: false +BreakAfterAttributes: Leave BreakAfterJavaFieldAnnotations: false BreakBeforeBinaryOperators: None BreakBeforeBraces: WebKit diff --git a/.gitignore b/.gitignore index f4993502b..2d0b150e1 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ dist/ rmm.egg-info/ python/build python/*/build +python/rmm/docs/_build python/rmm/**/_lib/**/*.cpp !python/rmm/_lib/_torch_allocator.cpp python/rmm/**/_lib/**/*.h diff --git a/include/rmm/mr/device/polymorphic_allocator.hpp b/include/rmm/mr/device/polymorphic_allocator.hpp index e2fb4b0cf..0b63b4691 100644 --- a/include/rmm/mr/device/polymorphic_allocator.hpp +++ b/include/rmm/mr/device/polymorphic_allocator.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -17,7 +17,6 @@ #pragma once #include -#include #include #include @@ -26,7 +25,11 @@ #include namespace rmm::mr { - +/** + * @addtogroup device_memory_resources + * @{ + * @file + */ /** * @brief A stream ordered Allocator using a `rmm::mr::device_memory_resource` to satisfy * (de)allocations. @@ -55,21 +58,21 @@ class polymorphic_allocator { /** * @brief Construct a `polymorphic_allocator` using the provided memory resource. * - * This constructor provides an implicit conversion from `memory_resource*`. + * This constructor provides an implicit conversion from `device_async_resource_ref`. * - * @param mr The `device_memory_resource` to use as the underlying resource. + * @param mr The upstream memory resource to use for allocation. */ - polymorphic_allocator(device_memory_resource* mr) : mr_{mr} {} + polymorphic_allocator(device_async_resource_ref mr) : mr_{mr} {} /** - * @brief Construct a `polymorphic_allocator` using `other.resource()` as the underlying memory - * resource. + * @brief Construct a `polymorphic_allocator` using the underlying memory resource of `other`. * - * @param other The `polymorphic_resource` whose `resource()` will be used as the underlying + * @param other The `polymorphic_allocator` whose memory resource will be used as the underlying * resource of the new `polymorphic_allocator`. */ template - polymorphic_allocator(polymorphic_allocator const& other) noexcept : mr_{other.resource()} + polymorphic_allocator(polymorphic_allocator const& other) noexcept + : mr_{other.get_upstream_resource()} { } @@ -82,14 +85,15 @@ class polymorphic_allocator { */ value_type* allocate(std::size_t num, cuda_stream_view stream) { - return static_cast(resource()->allocate(num * sizeof(T), stream)); + return static_cast( + get_upstream_resource().allocate_async(num * sizeof(T), stream)); } /** * @brief Deallocates storage pointed to by `ptr`. * - * `ptr` must have been allocated from a `rmm::mr::device_memory_resource` `r` that compares equal - * to `*resource()` using `r.allocate(n * sizeof(T))`. + * `ptr` must have been allocated from a memory resource `r` that compares equal + * to `get_upstream_resource()` using `r.allocate(n * sizeof(T))`. * * @param ptr Pointer to memory to deallocate * @param num Number of objects originally allocated @@ -97,7 +101,7 @@ class polymorphic_allocator { */ void deallocate(value_type* ptr, std::size_t num, cuda_stream_view stream) { - resource()->deallocate(ptr, num * sizeof(T), stream); + get_upstream_resource().deallocate_async(ptr, num * sizeof(T), stream); } /** @@ -108,24 +112,40 @@ class polymorphic_allocator { return mr_; } - /** - * @brief Returns pointer to the underlying `rmm::mr::device_memory_resource`. - * - * @return Pointer to the underlying resource. - */ - [[nodiscard]] device_memory_resource* resource() const noexcept { return mr_; } - private: - device_memory_resource* mr_{ + rmm::device_async_resource_ref mr_{ get_current_device_resource()}; ///< Underlying resource used for (de)allocation }; +/** + * @brief Compare two `polymorphic_allocator`s for equality. + * + * Two `polymorphic_allocator`s are equal if their underlying memory resources compare equal. + * + * @tparam T Type of the first allocator + * @tparam U Type of the second allocator + * @param lhs The first allocator to compare + * @param rhs The second allocator to compare + * @return true if the two allocators are equal, false otherwise + */ template bool operator==(polymorphic_allocator const& lhs, polymorphic_allocator const& rhs) { - return lhs.resource()->is_equal(*rhs.resource()); + return lhs.get_upstream_resource() == rhs.get_upstream_resource(); } +/** + * @brief Compare two `polymorphic_allocator`s for inequality. + * + * Two `polymorphic_allocator`s are not equal if their underlying memory resources compare not + * equal. + * + * @tparam T Type of the first allocator + * @tparam U Type of the second allocator + * @param lhs The first allocator to compare + * @param rhs The second allocator to compare + * @return true if the two allocators are not equal, false otherwise + */ template bool operator!=(polymorphic_allocator const& lhs, polymorphic_allocator const& rhs) { @@ -237,12 +257,34 @@ class stream_allocator_adaptor { cuda_stream_view stream_; ///< Stream on which (de)allocations are performed }; +/** + * @brief Compare two `stream_allocator_adaptor`s for equality. + * + * Two `stream_allocator_adaptor`s are equal if their underlying allocators compare equal. + * + * @tparam A Type of the first allocator + * @tparam O Type of the second allocator + * @param lhs The first allocator to compare + * @param rhs The second allocator to compare + * @return true if the two allocators are equal, false otherwise + */ template bool operator==(stream_allocator_adaptor const& lhs, stream_allocator_adaptor const& rhs) { return lhs.underlying_allocator() == rhs.underlying_allocator(); } +/** + * @brief Compare two `stream_allocator_adaptor`s for inequality. + * + * Two `stream_allocator_adaptor`s are not equal if their underlying allocators compare not equal. + * + * @tparam A Type of the first allocator + * @tparam O Type of the second allocator + * @param lhs The first allocator to compare + * @param rhs The second allocator to compare + * @return true if the two allocators are not equal, false otherwise + */ template bool operator!=(stream_allocator_adaptor const& lhs, stream_allocator_adaptor const& rhs) { @@ -264,5 +306,5 @@ auto make_stream_allocator_adaptor(Allocator const& allocator, cuda_stream_view { return stream_allocator_adaptor{allocator, stream}; } - +/** @} */ // end of group } // namespace rmm::mr diff --git a/tests/mr/device/polymorphic_allocator_tests.cpp b/tests/mr/device/polymorphic_allocator_tests.cpp index 3b73d4a49..d433e010c 100644 --- a/tests/mr/device/polymorphic_allocator_tests.cpp +++ b/tests/mr/device/polymorphic_allocator_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -33,14 +33,15 @@ struct allocator_test : public ::testing::Test { TEST_F(allocator_test, default_resource) { rmm::mr::polymorphic_allocator allocator{}; - EXPECT_EQ(allocator.resource(), rmm::mr::get_current_device_resource()); + EXPECT_EQ(allocator.get_upstream_resource(), + rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}); } TEST_F(allocator_test, custom_resource) { rmm::mr::cuda_memory_resource mr; rmm::mr::polymorphic_allocator allocator{&mr}; - EXPECT_EQ(allocator.resource(), &mr); + EXPECT_EQ(allocator.get_upstream_resource(), rmm::device_async_resource_ref{mr}); } void test_conversion(rmm::mr::polymorphic_allocator /*unused*/) {} @@ -48,7 +49,7 @@ void test_conversion(rmm::mr::polymorphic_allocator /*unused*/) {} TEST_F(allocator_test, implicit_conversion) { rmm::mr::cuda_memory_resource mr; - test_conversion(&mr); + test_conversion(rmm::device_async_resource_ref{mr}); } TEST_F(allocator_test, self_equality) @@ -84,7 +85,7 @@ TEST_F(allocator_test, copy_ctor_same_type) rmm::mr::polymorphic_allocator alloc0; rmm::mr::polymorphic_allocator alloc1{alloc0}; EXPECT_EQ(alloc0, alloc1); - EXPECT_EQ(alloc0.resource(), alloc1.resource()); + EXPECT_EQ(alloc0.get_upstream_resource(), alloc1.get_upstream_resource()); } TEST_F(allocator_test, copy_ctor_different_type) @@ -92,7 +93,7 @@ TEST_F(allocator_test, copy_ctor_different_type) rmm::mr::polymorphic_allocator alloc0; rmm::mr::polymorphic_allocator alloc1{alloc0}; EXPECT_EQ(alloc0, alloc1); - EXPECT_EQ(alloc0.resource(), alloc1.resource()); + EXPECT_EQ(alloc0.get_upstream_resource(), alloc1.get_upstream_resource()); } TEST_F(allocator_test, rebind) From f11c8ca44ec4ab282157e7a1d7be5a3abafe8c57 Mon Sep 17 00:00:00 2001 From: Paul Taylor <178183+trxcllnt@users.noreply.github.com> Date: Wed, 8 May 2024 19:37:12 -0700 Subject: [PATCH 403/675] add --rm and --name to devcontainer run args (#1539) * Remove the devcontainer when the VSCode window closes * Adds a descriptive name to the running container: ```shell $ docker ps -a CONTAINER ID IMAGE ... NAMES 0dbb364fe544 vsc-rmm-... ... rapids-rmm-24.06-cuda12.2-conda $ docker rm -f rapids-rmm-24.06-cuda12.2-conda ``` Authors: - Paul Taylor (https://github.com/trxcllnt) Approvers: - Mark Harris (https://github.com/harrism) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1539 --- .devcontainer/cuda11.8-conda/devcontainer.json | 5 +++++ .devcontainer/cuda11.8-pip/devcontainer.json | 5 +++++ .devcontainer/cuda12.2-conda/devcontainer.json | 5 +++++ .devcontainer/cuda12.2-pip/devcontainer.json | 5 +++++ ci/release/update-version.sh | 2 ++ scripts/run-cmake-format.sh | 2 ++ 6 files changed, 24 insertions(+) diff --git a/.devcontainer/cuda11.8-conda/devcontainer.json b/.devcontainer/cuda11.8-conda/devcontainer.json index 260e93e10..b4b7f3f02 100644 --- a/.devcontainer/cuda11.8-conda/devcontainer.json +++ b/.devcontainer/cuda11.8-conda/devcontainer.json @@ -8,6 +8,11 @@ "BASE": "rapidsai/devcontainers:24.06-cpp-cuda11.8-mambaforge-ubuntu22.04" } }, + "runArgs": [ + "--rm", + "--name", + "${localEnv:USER}-rapids-${localWorkspaceFolderBasename}-24.06-cuda11.8-conda" + ], "hostRequirements": {"gpu": "optional"}, "features": { "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.6": {} diff --git a/.devcontainer/cuda11.8-pip/devcontainer.json b/.devcontainer/cuda11.8-pip/devcontainer.json index 667519658..bcdaaf53d 100644 --- a/.devcontainer/cuda11.8-pip/devcontainer.json +++ b/.devcontainer/cuda11.8-pip/devcontainer.json @@ -8,6 +8,11 @@ "BASE": "rapidsai/devcontainers:24.06-cpp-cuda11.8-ubuntu22.04" } }, + "runArgs": [ + "--rm", + "--name", + "${localEnv:USER}-rapids-${localWorkspaceFolderBasename}-24.06-cuda11.8-pip" + ], "hostRequirements": {"gpu": "optional"}, "features": { "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.6": {} diff --git a/.devcontainer/cuda12.2-conda/devcontainer.json b/.devcontainer/cuda12.2-conda/devcontainer.json index 8ca9ac220..cf5679cf7 100644 --- a/.devcontainer/cuda12.2-conda/devcontainer.json +++ b/.devcontainer/cuda12.2-conda/devcontainer.json @@ -8,6 +8,11 @@ "BASE": "rapidsai/devcontainers:24.06-cpp-mambaforge-ubuntu22.04" } }, + "runArgs": [ + "--rm", + "--name", + "${localEnv:USER}-rapids-${localWorkspaceFolderBasename}-24.06-cuda12.2-conda" + ], "hostRequirements": {"gpu": "optional"}, "features": { "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.6": {} diff --git a/.devcontainer/cuda12.2-pip/devcontainer.json b/.devcontainer/cuda12.2-pip/devcontainer.json index 0309a478a..2e2cb99e1 100644 --- a/.devcontainer/cuda12.2-pip/devcontainer.json +++ b/.devcontainer/cuda12.2-pip/devcontainer.json @@ -8,6 +8,11 @@ "BASE": "rapidsai/devcontainers:24.06-cpp-cuda12.2-ubuntu22.04" } }, + "runArgs": [ + "--rm", + "--name", + "${localEnv:USER}-rapids-${localWorkspaceFolderBasename}-24.06-cuda12.2-pip" + ], "hostRequirements": {"gpu": "optional"}, "features": { "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.6": {} diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index dcd8e85a2..174630e54 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -1,4 +1,5 @@ #!/bin/bash +# Copyright (c) 2024, NVIDIA CORPORATION. ######################## # RMM Version Updater # ######################## @@ -44,4 +45,5 @@ done find .devcontainer/ -type f -name devcontainer.json -print0 | while IFS= read -r -d '' filename; do sed_runner "s@rapidsai/devcontainers:[0-9.]*@rapidsai/devcontainers:${NEXT_SHORT_TAG}@g" "${filename}" sed_runner "s@rapidsai/devcontainers/features/rapids-build-utils:[0-9.]*@rapidsai/devcontainers/features/rapids-build-utils:${NEXT_SHORT_TAG_PEP440}@" "${filename}" + sed_runner "s@rapids-\${localWorkspaceFolderBasename}-[0-9.]*@rapids-\${localWorkspaceFolderBasename}-${NEXT_SHORT_TAG}@g" "${filename}" done diff --git a/scripts/run-cmake-format.sh b/scripts/run-cmake-format.sh index a7d9984b3..df7f22782 100755 --- a/scripts/run-cmake-format.sh +++ b/scripts/run-cmake-format.sh @@ -1,4 +1,5 @@ #!/bin/bash +# Copyright (c) 2024, NVIDIA CORPORATION. # This script is a wrapper for cmakelang that may be used with pre-commit. The # wrapping is necessary because RAPIDS libraries split configuration for @@ -43,6 +44,7 @@ fi DEFAULT_FORMAT_FILE_LOCATIONS=( "${RMM_BUILD_DIR}/_deps/rapids-cmake-src/cmake-format-rapids-cmake.json" + "${RMM_BUILD_DIR:-build}/latest/_deps/rapids-cmake-src/cmake-format-rapids-cmake.json" ) if [ -z ${RAPIDS_CMAKE_FORMAT_FILE:+PLACEHOLDER} ]; then From aa1658820f57c7e169c5805416cb33b79e1e9b1c Mon Sep 17 00:00:00 2001 From: Ray Douglass <3107146+raydouglass@users.noreply.github.com> Date: Fri, 10 May 2024 12:30:08 -0400 Subject: [PATCH 404/675] Overhaul ops-codeowners (#1561) --- .github/CODEOWNERS | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index c9a4cba83..334cae320 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -10,8 +10,14 @@ python/ @rapidsai/rmm-python-codeowners **/CMakeLists.txt @rapidsai/rmm-cmake-codeowners **/cmake/ @rapidsai/rmm-cmake-codeowners -#build/ops code owners -.github/ @rapidsai/ops-codeowners -ci/ @rapidsai/ops-codeowners -conda/ @rapidsai/ops-codeowners -dependencies.yaml @rapidsai/ops-codeowners +#CI code owners +/.github/ @rapidsai/ci-codeowners +/ci/ @rapidsai/ci-codeowners +/.pre-commit-config.yaml @rapidsai/ci-codeowners + +#packaging code owners +/.devcontainers/ @rapidsai/packaging-codeowners +/conda/ @rapidsai/packaging-codeowners +/dependencies.yaml @rapidsai/packaging-codeowners +/build.sh @rapidsai/packaging-codeowners +pyproject.toml @rapidsai/packaging-codeowners From 32cd537a55b81726940bb698013a0d684e338c86 Mon Sep 17 00:00:00 2001 From: Aaron Siddhartha Mondal Date: Tue, 14 May 2024 11:49:39 +0200 Subject: [PATCH 405/675] Don't ignore GCC-specific warning under Clang (#1557) Clang doesn't know `-Wnon-template-friend`. Authors: - Aaron Siddhartha Mondal (https://github.com/aaronmondal) Approvers: - Mark Harris (https://github.com/harrism) - Michael Schellenberger Costa (https://github.com/miscco) URL: https://github.com/rapidsai/rmm/pull/1557 --- include/rmm/mr/device/pool_memory_resource.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 5c0b9a29f..a3a972904 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -75,18 +75,19 @@ struct maybe_remove_property>> { -#ifdef __GNUC__ // GCC warns about compatibility issues with pre ISO C++ code +#if defined(__GNUC__) && !defined(__clang__) // GCC warns about compatibility + // issues with pre ISO C++ code #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wnon-template-friend" -#endif // __GNUC__ +#endif // __GNUC__ and not __clang__ /** * @brief Explicit removal of the friend function so we do not pretend to provide device * accessible memory */ friend void get_property(const PoolResource&, Property) = delete; -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop -#endif // __GNUC__ +#endif // __GNUC__ and not __clang__ }; } // namespace detail From 8ee39ad591fb4f76be625f9c0cd2963172e62e32 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Thu, 16 May 2024 08:49:42 +0100 Subject: [PATCH 406/675] Allow specifying mr in DeviceBuffer construction, and document ownership requirements in Python/C++ interfacing (#1552) On the C++ side, device_buffers store raw pointers for the memory resource that was used in their allocation. Consequently, it is unsafe to take ownership of a device_buffer in Python unless we controlled the provenance of the memory resource that was used in its allocation. The only way to do that is to pass the memory resource from Python into C++ and then use it when constructing the DeviceBuffer. Add discussion of this with some examples and a section on pitfalls if only relying on get_current_device_resource and set_current_device_resource. To allow Python users of `DeviceBuffer` objects to follow best practices, introduce explicit (defaulting to the current device resource) `mr` arguments in both `c_from_unique_ptr` and the `DeviceBuffer` constructor. - Closes #1492 Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Mark Harris (https://github.com/harrism) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1552 --- README.md | 93 ++++++++++++++++++++++++++- python/rmm/rmm/_lib/device_buffer.pxd | 5 +- python/rmm/rmm/_lib/device_buffer.pyx | 16 +++-- python/rmm/rmm/tests/test_rmm.py | 29 ++++++++- 4 files changed, 134 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c6cd44c47..4032f161b 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ Python requirements: * `cuda-python` * `cython` -For more details, see [pyproject.toml](python/pyproject.toml) +For more details, see [pyproject.toml](python/rmm/pyproject.toml) ### Script to build RMM from source @@ -855,3 +855,94 @@ Out[6]: 'total_bytes': 16, 'total_count': 1} ``` + +## Taking ownership of C++ objects from Python. + +When interacting with a C++ library that uses RMM from Python, one +must be careful when taking ownership of `rmm::device_buffer` objects +on the Python side. The `rmm::device_buffer` does not contain an +owning reference to the memory resource used for its allocation (only +a `device_async_resource_ref`), and the allocating user is expected to +keep this memory resource alive for at least the lifetime of the +buffer. When taking ownership of such a buffer in Python, we have no +way (in the general case) of ensuring that the memory resource will +outlive the buffer we are now holding. + +To avoid any issues, we need two things: + +1. The C++ library we are interfacing with should accept a memory + resource that is used for allocations that are returned to the + user. +2. When calling into the library from python, we should provide a + memory resource whose lifetime we control. This memory resource + should then be provided when we take ownership of any allocated + `rmm::device_buffer`s. + +For example, suppose we have a C++ function that allocates +`device_buffer`s, which has a utility overload that defaults the +memory resource to the current device resource: + +```c++ +std::unique_ptr allocate( + std::size_t size, + rmm::mr::device_async_resource_ref mr = get_current_device_resource()) +{ + return std::make_unique(size, rmm::cuda_stream_default, mr); +} +``` + +The Python `DeviceBuffer` class has a convenience Cython function, +`c_from_unique_ptr` to construct a `DeviceBuffer` from a +`unique_ptr`, taking ownership of it. To do this +safely, we must ensure that the allocation that was done on the C++ +side uses a memory resource we control. So: + +```cython +# Bad, doesn't control lifetime +buffer_bad = DeviceBuffer.c_from_unique_ptr(allocate(10)) + +# Good, allocation happens with a memory resource we control +# mr is a DeviceMemoryResource +buffer_good = DeviceBuffer.c_from_unique_ptr( + allocate(10, mr.get_mr()), + mr=mr, +) +``` + +Note two differences between the bad and good cases: + +1. In the good case we pass the memory resource to the allocation + function. +2. In the good case, we pass _the same_ memory resource to the + `DeviceBuffer` constructor so that its lifetime is tied to the + lifetime of the buffer. + +### Potential pitfalls of relying on `get_current_device_resource` + +Functions in both the C++ and Python APIs that perform allocation +typically default the memory resource argument to the value of +`get_current_device_resource`. This is to simplify the interface for +callers. When using a C++ library from Python, this defaulting is +safe, _as long as_ it is only the Python process that ever calls +`set_current_device_resource`. + +This is because the current device resource on the C++ side has a +lifetime which is expected to be managed by the user. The resources +set by `rmm::mr::set_current_device_resource` are stored in a static +`std::map` whose keys are device ids and values are raw pointers to +the memory resources. Consequently, +`rmm::mr::get_current_device_resource` returns an object with no +lifetime provenance. This is, for the reasons discussed above, not +usable from Python. To handle this on the Python side, the +Python-level `set_current_device_resource` sets the C++ resource _and_ +stores the Python object in a static global dictionary. The Python +`get_current_device_resource` then _does not use_ +`rmm::mr::get_current_device_resource` and instead looks up the +current device resource in this global dictionary. + +Hence, if the C++ library we are interfacing with calls +`rmm::mr::set_current_device_resource`, the C++ and Python sides of +the program can disagree on what `get_current_device_resource` +returns. The only safe thing to do if using the simplified interfaces +is therefore to ensure that `set_current_device_resource` is only ever +called on the Python side. diff --git a/python/rmm/rmm/_lib/device_buffer.pxd b/python/rmm/rmm/_lib/device_buffer.pxd index b48df21e7..2ff1a7da9 100644 --- a/python/rmm/rmm/_lib/device_buffer.pxd +++ b/python/rmm/rmm/_lib/device_buffer.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2020, NVIDIA CORPORATION. +# Copyright (c) 2019-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. @@ -65,7 +65,8 @@ cdef class DeviceBuffer: @staticmethod cdef DeviceBuffer c_from_unique_ptr( unique_ptr[device_buffer] ptr, - Stream stream=* + Stream stream=*, + DeviceMemoryResource mr=*, ) @staticmethod diff --git a/python/rmm/rmm/_lib/device_buffer.pyx b/python/rmm/rmm/_lib/device_buffer.pyx index bbeaa614e..9d2298d8b 100644 --- a/python/rmm/rmm/_lib/device_buffer.pyx +++ b/python/rmm/rmm/_lib/device_buffer.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2020, NVIDIA CORPORATION. +# Copyright (c) 2019-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. @@ -33,6 +33,7 @@ from cuda.ccudart cimport ( ) from rmm._lib.memory_resource cimport ( + DeviceMemoryResource, device_memory_resource, get_current_device_resource, ) @@ -48,7 +49,8 @@ cdef class DeviceBuffer: def __cinit__(self, *, uintptr_t ptr=0, size_t size=0, - Stream stream=DEFAULT_STREAM): + Stream stream=DEFAULT_STREAM, + DeviceMemoryResource mr=None): """Construct a ``DeviceBuffer`` with optional size and data pointer Parameters @@ -65,6 +67,9 @@ cdef class DeviceBuffer: scope while the DeviceBuffer is in use. Destroying the underlying stream while the DeviceBuffer is in use will result in undefined behavior. + mr : optional + DeviceMemoryResource for the allocation, if not provided + defaults to the current device resource. Note ---- @@ -80,7 +85,7 @@ cdef class DeviceBuffer: cdef const void* c_ptr cdef device_memory_resource * mr_ptr # Save a reference to the MR and stream used for allocation - self.mr = get_current_device_resource() + self.mr = get_current_device_resource() if mr is None else mr self.stream = stream mr_ptr = self.mr.get_mr() @@ -162,13 +167,14 @@ cdef class DeviceBuffer: @staticmethod cdef DeviceBuffer c_from_unique_ptr( unique_ptr[device_buffer] ptr, - Stream stream=DEFAULT_STREAM + Stream stream=DEFAULT_STREAM, + DeviceMemoryResource mr=None, ): cdef DeviceBuffer buf = DeviceBuffer.__new__(DeviceBuffer) if stream.c_is_default(): stream.c_synchronize() buf.c_obj = move(ptr) - buf.mr = get_current_device_resource() + buf.mr = get_current_device_resource() if mr is None else mr buf.stream = stream return buf diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index 25ff9a7a6..c37fe0298 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2022, NVIDIA CORPORATION. +# Copyright (c) 2020-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. @@ -13,6 +13,7 @@ # limitations under the License. import copy +import functools import gc import os import pickle @@ -498,6 +499,32 @@ def test_mr_devicebuffer_lifetime(): del a +def test_device_buffer_with_mr(): + allocations = [] + base = rmm.mr.CudaMemoryResource() + rmm.mr.set_current_device_resource(base) + + def alloc_cb(size, stream, *, base): + allocations.append(size) + return base.allocate(size, stream) + + def dealloc_cb(ptr, size, stream, *, base): + return base.deallocate(ptr, size, stream) + + cb_mr = rmm.mr.CallbackMemoryResource( + functools.partial(alloc_cb, base=base), + functools.partial(dealloc_cb, base=base), + ) + rmm.DeviceBuffer(size=10) + assert len(allocations) == 0 + buf = rmm.DeviceBuffer(size=256, mr=cb_mr) + assert len(allocations) == 1 + assert allocations[0] == 256 + del cb_mr + gc.collect() + del buf + + def test_mr_upstream_lifetime(): # Simple test to ensure upstream MRs are deallocated before downstream MR cuda_mr = rmm.mr.CudaMemoryResource() From cab7e06cc40eaf9dc98f5563a8cc399fbc876388 Mon Sep 17 00:00:00 2001 From: Lilo Huang Date: Thu, 16 May 2024 21:37:53 +0800 Subject: [PATCH 407/675] Adding support for cupy.cuda.stream.ExternalStream (#1559) Cupy offers the `cupy.cuda.stream.ExternalStream` for utilizing external CUDA streams. Moreover, `cupy.cuda.get_current_stream()` will return an instance of `cupy.cuda.stream.ExternalStream` instead of `cupy.cuda.stream.Stream`, particularly when the current cuPy stream has been changed. Therefore, we must verify both types of instances to avoid errors. See details in the https://docs.cupy.dev/en/stable/user_guide/interoperability.html#cuda-stream-pointers Authors: - Lilo Huang (https://github.com/lilohuang) - Mark Harris (https://github.com/harrism) Approvers: - Mark Harris (https://github.com/harrism) - Leo Fang (https://github.com/leofang) URL: https://github.com/rapidsai/rmm/pull/1559 --- python/rmm/rmm/_cuda/stream.pyx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/rmm/rmm/_cuda/stream.pyx b/python/rmm/rmm/_cuda/stream.pyx index 4795cbb9f..4d5ff5232 100644 --- a/python/rmm/rmm/_cuda/stream.pyx +++ b/python/rmm/rmm/_cuda/stream.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-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. @@ -100,7 +100,8 @@ cdef class Stream: def _init_from_cupy_stream(self, obj): try: import cupy - if isinstance(obj, cupy.cuda.stream.Stream): + if isinstance(obj, (cupy.cuda.stream.Stream, + cupy.cuda.stream.ExternalStream)): self._cuda_stream = (obj.ptr) self._owner = obj return From 91d529f4a2dd7bffed779350d928e89ab23ed85a Mon Sep 17 00:00:00 2001 From: James Lamb Date: Thu, 16 May 2024 14:34:18 -0500 Subject: [PATCH 408/675] update copyright dates (#1564) Updates some copyright dates. These were updated in 2024, but their copyright dates were not automatically modified because #1553 hadn't been merged yet. On each file, I made a trivial change to convince the `verify-copyright` pre-commit hook that the files have changed. Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1564 --- CMakeLists.txt | 4 ++-- build.sh | 4 ++-- ci/build_wheel_python.sh | 4 ++-- ci/test_wheel.sh | 4 ++-- conda/recipes/librmm/meta.yaml | 4 ++-- conda/recipes/rmm/meta.yaml | 4 ++-- python/rmm/CMakeLists.txt | 3 ++- python/rmm/docs/conf.py | 2 ++ python/rmm/pyproject.toml | 3 ++- 9 files changed, 18 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 62a192b7d..1999073bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2018-2023, NVIDIA CORPORATION. +# Copyright (c) 2018-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 @@ -47,7 +47,7 @@ set_property(CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WA "CRITICAL" "OFF") # Set logging level. Must go before including gtests and benchmarks. Set the possible values of -# build type for cmake-gui +# build type for cmake-gui. message(STATUS "RMM: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'") # cudart can be linked statically or dynamically diff --git a/build.sh b/build.sh index a52a9f594..70da14b9b 100755 --- a/build.sh +++ b/build.sh @@ -1,12 +1,12 @@ #!/bin/bash -# Copyright (c) 2019, NVIDIA CORPORATION. +# Copyright (c) 2019-2024, NVIDIA CORPORATION. # rmm build script # This script is used to build the component(s) in this repo from # source, and can be called with various options to customize the -# build as needed (see the help output for details) +# build as needed (see the help output for details). # Abort script on first error set -e diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index 54234ed20..debe9b0fe 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, NVIDIA CORPORATION. set -euo pipefail @@ -14,7 +14,7 @@ commit=$(git rev-parse HEAD) RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" -# This is the version of the suffix with a preceding hyphen. It's used +# This is the version of the suffix with a preceding hyphen. It is used # everywhere except in the final wheel name. PACKAGE_CUDA_SUFFIX="-${RAPIDS_PY_CUDA_SUFFIX}" diff --git a/ci/test_wheel.sh b/ci/test_wheel.sh index 6f14a0d45..50cb203c3 100755 --- a/ci/test_wheel.sh +++ b/ci/test_wheel.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, NVIDIA CORPORATION. set -eou pipefail @@ -7,7 +7,7 @@ RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" WHEELHOUSE="${PWD}/dist/" RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 python "${WHEELHOUSE}" -# echo to expand wildcard before adding `[extra]` requires for pip +# echo to expand wildcard before adding '[extra]' requires for pip python -m pip install "rmm-${RAPIDS_PY_CUDA_SUFFIX}[test]>=0.0.0a0" --find-links "${WHEELHOUSE}" python -m pytest ./python/rmm/rmm/tests diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 88468305b..53e16ebdc 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2018-2023, NVIDIA CORPORATION. +# Copyright (c) 2018-2024, NVIDIA CORPORATION. {% set version = environ['RAPIDS_PACKAGE_VERSION'].lstrip('v') %} {% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} @@ -26,7 +26,7 @@ requirements: - {{ stdlib("c") }} host: - cuda-version ={{ cuda_version }} - # We require spdlog and fmt (which was devendored from spdlog + # We require spdlog and fmt (which was de-vendored from spdlog # conda-forge packages in 1.11.0) so that the spdlog headers are not # pulled by CPM and installed as a part of the rmm packages. However, # building against librmm still requires these headers. They are also diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 560bedd7e..fa8a82475 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -1,6 +1,6 @@ -# Copyright (c) 2019-2023, NVIDIA CORPORATION. +# Copyright (c) 2019-2024, NVIDIA CORPORATION. -{% set version = environ['RAPIDS_PACKAGE_VERSION'].lstrip('v') %} +{% set version = environ['RAPIDS_PACKAGE_VERSION'].strip().lstrip('v') %} {% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} {% set cuda_major = cuda_version.split('.')[0] %} {% set py_version = environ['CONDA_PY'] %} diff --git a/python/rmm/CMakeLists.txt b/python/rmm/CMakeLists.txt index 0a472d42f..6c2515102 100644 --- a/python/rmm/CMakeLists.txt +++ b/python/rmm/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-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 @@ -26,6 +26,7 @@ find_package(rmm "${RAPIDS_VERSION}" REQUIRED) include(rapids-cython-core) rapids_cython_init() +# pass through logging level to spdlog add_compile_definitions("SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") add_subdirectory(rmm/_cuda) diff --git a/python/rmm/docs/conf.py b/python/rmm/docs/conf.py index 6ed770151..dd8267e28 100644 --- a/python/rmm/docs/conf.py +++ b/python/rmm/docs/conf.py @@ -1,3 +1,5 @@ +# Copyright (c) 2020-2024, NVIDIA CORPORATION. + # Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index c799f101a..eb0d23380 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022, NVIDIA CORPORATION. +# Copyright (c) 2021-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. @@ -126,6 +126,7 @@ input = "rmm/VERSION" regex = "(?P.*)" [tool.pytest.ini_options] +# treat warnings as errors filterwarnings = [ "error", ] From 46e153c18d17b07526d6ff2e04859fcbbd706879 Mon Sep 17 00:00:00 2001 From: Ray Douglass <3107146+raydouglass@users.noreply.github.com> Date: Mon, 20 May 2024 16:43:47 -0400 Subject: [PATCH 409/675] Make sure rmm wheel dependency on librmm is updated [skip ci] (#1565) --- ci/release/update-version.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 174630e54..dfb0c17b0 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -47,3 +47,15 @@ find .devcontainer/ -type f -name devcontainer.json -print0 | while IFS= read -r sed_runner "s@rapidsai/devcontainers/features/rapids-build-utils:[0-9.]*@rapidsai/devcontainers/features/rapids-build-utils:${NEXT_SHORT_TAG_PEP440}@" "${filename}" sed_runner "s@rapids-\${localWorkspaceFolderBasename}-[0-9.]*@rapids-\${localWorkspaceFolderBasename}-${NEXT_SHORT_TAG}@g" "${filename}" done + +DEPENDENCIES=( + librmm +) +for DEP in "${DEPENDENCIES[@]}"; do + for FILE in dependencies.yaml conda/environments/*.yaml; do + sed_runner "/-.* ${DEP}\(-cu[[:digit:]]\{2\}\)\{0,1\}==/ s/==.*/==${NEXT_SHORT_TAG_PEP440}.*/g" "${FILE}" + done + for FILE in python/*/pyproject.toml; do + sed_runner "/\"${DEP}==/ s/==.*\"/==${NEXT_SHORT_TAG_PEP440}.*\"/g" "${FILE}" + done +done From bd5135e3407e43cbf155b4b08f70d120ecd33a83 Mon Sep 17 00:00:00 2001 From: Jake Awe Date: Mon, 20 May 2024 20:50:45 +0000 Subject: [PATCH 410/675] DOC v24.08 Updates [skip ci] --- .../cuda11.8-conda/devcontainer.json | 6 ++--- .devcontainer/cuda11.8-pip/devcontainer.json | 6 ++--- .../cuda12.2-conda/devcontainer.json | 6 ++--- .devcontainer/cuda12.2-pip/devcontainer.json | 6 ++--- .github/workflows/build.yaml | 16 +++++++------- .github/workflows/pr.yaml | 22 +++++++++---------- .github/workflows/test.yaml | 6 ++--- VERSION | 2 +- dependencies.yaml | 6 ++--- python/rmm/pyproject.toml | 2 +- 10 files changed, 39 insertions(+), 39 deletions(-) diff --git a/.devcontainer/cuda11.8-conda/devcontainer.json b/.devcontainer/cuda11.8-conda/devcontainer.json index b4b7f3f02..3d23dba87 100644 --- a/.devcontainer/cuda11.8-conda/devcontainer.json +++ b/.devcontainer/cuda11.8-conda/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:24.06-cpp-cuda11.8-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.08-cpp-cuda11.8-mambaforge-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER}-rapids-${localWorkspaceFolderBasename}-24.06-cuda11.8-conda" + "${localEnv:USER}-rapids-${localWorkspaceFolderBasename}-24.08-cuda11.8-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.6": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.8": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda11.8-pip/devcontainer.json b/.devcontainer/cuda11.8-pip/devcontainer.json index bcdaaf53d..e7a916842 100644 --- a/.devcontainer/cuda11.8-pip/devcontainer.json +++ b/.devcontainer/cuda11.8-pip/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:24.06-cpp-cuda11.8-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.08-cpp-cuda11.8-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER}-rapids-${localWorkspaceFolderBasename}-24.06-cuda11.8-pip" + "${localEnv:USER}-rapids-${localWorkspaceFolderBasename}-24.08-cuda11.8-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.6": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.8": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.2-conda/devcontainer.json b/.devcontainer/cuda12.2-conda/devcontainer.json index cf5679cf7..31b594a7f 100644 --- a/.devcontainer/cuda12.2-conda/devcontainer.json +++ b/.devcontainer/cuda12.2-conda/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "12.2", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:24.06-cpp-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.08-cpp-mambaforge-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER}-rapids-${localWorkspaceFolderBasename}-24.06-cuda12.2-conda" + "${localEnv:USER}-rapids-${localWorkspaceFolderBasename}-24.08-cuda12.2-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.6": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.8": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.2-pip/devcontainer.json b/.devcontainer/cuda12.2-pip/devcontainer.json index 2e2cb99e1..65fedac9c 100644 --- a/.devcontainer/cuda12.2-pip/devcontainer.json +++ b/.devcontainer/cuda12.2-pip/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "12.2", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:24.06-cpp-cuda12.2-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.08-cpp-cuda12.2-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER}-rapids-${localWorkspaceFolderBasename}-24.06-cuda12.2-pip" + "${localEnv:USER}-rapids-${localWorkspaceFolderBasename}-24.08-cuda12.2-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.6": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.8": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 895cac94d..5ada2cedd 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build-cpp: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -79,7 +79,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -89,7 +89,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -100,7 +100,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 96e4503b7..68562b467 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -23,40 +23,40 @@ jobs: - wheel-tests - devcontainer secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.08 checks: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.08 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.08 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.08 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.08 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.08 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.08 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -66,7 +66,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -74,20 +74,20 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 with: build_type: pull-request script: ci/build_wheel_python.sh wheel-tests: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.08 with: build_type: pull-request script: ci/test_wheel.sh devcontainer: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.08 with: arch: '["amd64"]' cuda: '["12.2"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 747f9f544..42cdcb282 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.08 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.08 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.08 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/VERSION b/VERSION index 0bff6981a..ec8489fda 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -24.06.00 +24.08.00 diff --git a/dependencies.yaml b/dependencies.yaml index eb2c4e4f2..82d1c83e0 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -137,14 +137,14 @@ dependencies: - matrix: cuda: "12.*" packages: - - librmm-cu12==24.6.* + - librmm-cu12==24.8.* - matrix: cuda: "11.*" packages: - - librmm-cu11==24.6.* + - librmm-cu11==24.8.* - matrix: packages: - - librmm==24.6.* + - librmm==24.8.* checks: common: - output_types: [conda, requirements] diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index eb0d23380..d3a1ac635 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -18,7 +18,7 @@ requires = [ "cmake>=3.26.4", "cuda-python>=11.7.1,<12.0a0", "cython>=3.0.0", - "librmm==24.6.*", + "librmm==24.8.*", "ninja", "scikit-build-core[pyproject]>=0.7.0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. From 4e9482f5a7473dd8b960f76c9c399576c9662ae3 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Thu, 23 May 2024 10:00:38 +1000 Subject: [PATCH 411/675] Add NVTX support and RMM_FUNC_RANGE() macro (#1558) Let's get RMM allocate/deallocates showing up in profiler timelines. Closes #495 Authors: - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1558 --- CMakeLists.txt | 9 +++ cmake/thirdparty/get_nvtx.cmake | 23 +++++++ include/rmm/detail/nvtx/ranges.hpp | 61 +++++++++++++++++++ .../rmm/mr/device/device_memory_resource.hpp | 9 +++ include/rmm/mr/host/host_memory_resource.hpp | 6 +- .../rmm/mr/pinned_host_memory_resource.hpp | 13 ++++ 6 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 cmake/thirdparty/get_nvtx.cmake create mode 100644 include/rmm/detail/nvtx/ranges.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 1999073bc..ddfed3df5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,7 @@ rapids_cmake_build_type(Release) # ################################################################################################## # * build options ---------------------------------------------------------------------------------- +option(USE_NVTX "Build with NVTX support" ON) option(BUILD_TESTS "Configure CMake to build tests" ON) option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" OFF) set(RMM_LOGGING_LEVEL @@ -46,6 +47,7 @@ set(RMM_LOGGING_LEVEL set_property(CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF") +message(VERBOSE "RMM: Build with NVTX support: ${USE_NVTX}") # Set logging level. Must go before including gtests and benchmarks. Set the possible values of # build type for cmake-gui. message(STATUS "RMM: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'") @@ -71,6 +73,7 @@ rapids_cpm_init() include(cmake/thirdparty/get_fmt.cmake) include(cmake/thirdparty/get_spdlog.cmake) include(cmake/thirdparty/get_cccl.cmake) +include(cmake/thirdparty/get_nvtx.cmake) # ################################################################################################## # * library targets -------------------------------------------------------------------------------- @@ -93,9 +96,15 @@ target_link_libraries(rmm INTERFACE CCCL::CCCL) target_link_libraries(rmm INTERFACE fmt::fmt-header-only) target_link_libraries(rmm INTERFACE spdlog::spdlog_header_only) target_link_libraries(rmm INTERFACE dl) +target_link_libraries(rmm INTERFACE nvtx3-cpp) target_compile_features(rmm INTERFACE cxx_std_17 $) target_compile_definitions(rmm INTERFACE LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE) +# Disable NVTX if necessary +if(NOT USE_NVTX) + target_compile_definitions(rmm INTERFACE NVTX_DISABLE) +endif() + # ################################################################################################## # * tests and benchmarks --------------------------------------------------------------------------- diff --git a/cmake/thirdparty/get_nvtx.cmake b/cmake/thirdparty/get_nvtx.cmake new file mode 100644 index 000000000..90487dd22 --- /dev/null +++ b/cmake/thirdparty/get_nvtx.cmake @@ -0,0 +1,23 @@ +# ============================================================================= +# 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. +# ============================================================================= + +# Use CPM to find or clone NVTX3 +function(find_and_configure_nvtx3) + + include(${rapids-cmake-dir}/cpm/nvtx3.cmake) + rapids_cpm_nvtx3(BUILD_EXPORT_SET rmm-exports INSTALL_EXPORT_SET rmm-exports) + +endfunction() + +find_and_configure_nvtx3() diff --git a/include/rmm/detail/nvtx/ranges.hpp b/include/rmm/detail/nvtx/ranges.hpp new file mode 100644 index 000000000..1791a8c3b --- /dev/null +++ b/include/rmm/detail/nvtx/ranges.hpp @@ -0,0 +1,61 @@ +/* + * 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. + */ + +#pragma once + +#include + +namespace rmm { +/** + * @brief Tag type for librmm's NVTX domain. + */ +struct librmm_domain { + static constexpr char const* name{"librmm"}; ///< Name of the librmm domain +}; + +/** + * @brief Alias for an NVTX range in the librmm domain. + * + * Customizes an NVTX range with the given input. + * + * Example: + * ``` + * void some_function(){ + * rmm::scoped_range rng{"custom_name"}; // Customizes range name + * ... + * } + * ``` + */ +using scoped_range = ::nvtx3::scoped_range_in; + +} // namespace rmm + +/** + * @brief Convenience macro for generating an NVTX range in the `librmm` domain + * from the lifetime of a function. + * + * Uses the name of the immediately enclosing function returned by `__func__` to + * name the range. + * + * Example: + * ``` + * void some_function(){ + * RMM_FUNC_RANGE(); + * ... + * } + * ``` + */ +#define RMM_FUNC_RANGE() NVTX3_FUNC_RANGE_IN(rmm::librmm_domain) diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index 5d7a60e2c..783dff2ed 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -17,6 +17,7 @@ #include #include +#include #include @@ -117,6 +118,7 @@ class device_memory_resource { */ void* allocate(std::size_t bytes, cuda_stream_view stream = cuda_stream_view{}) { + RMM_FUNC_RANGE(); return do_allocate(bytes, stream); } @@ -138,6 +140,7 @@ class device_memory_resource { */ void deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream = cuda_stream_view{}) { + RMM_FUNC_RANGE(); do_deallocate(ptr, bytes, stream); } @@ -173,6 +176,7 @@ class device_memory_resource { */ void* allocate(std::size_t bytes, std::size_t alignment) { + RMM_FUNC_RANGE(); return do_allocate(rmm::align_up(bytes, alignment), cuda_stream_view{}); } @@ -191,6 +195,7 @@ class device_memory_resource { */ void deallocate(void* ptr, std::size_t bytes, std::size_t alignment) { + RMM_FUNC_RANGE(); do_deallocate(ptr, rmm::align_up(bytes, alignment), cuda_stream_view{}); } @@ -209,6 +214,7 @@ class device_memory_resource { */ void* allocate_async(std::size_t bytes, std::size_t alignment, cuda_stream_view stream) { + RMM_FUNC_RANGE(); return do_allocate(rmm::align_up(bytes, alignment), stream); } @@ -226,6 +232,7 @@ class device_memory_resource { */ void* allocate_async(std::size_t bytes, cuda_stream_view stream) { + RMM_FUNC_RANGE(); return do_allocate(bytes, stream); } @@ -248,6 +255,7 @@ class device_memory_resource { std::size_t alignment, cuda_stream_view stream) { + RMM_FUNC_RANGE(); do_deallocate(ptr, rmm::align_up(bytes, alignment), stream); } @@ -266,6 +274,7 @@ class device_memory_resource { */ void deallocate_async(void* ptr, std::size_t bytes, cuda_stream_view stream) { + RMM_FUNC_RANGE(); do_deallocate(ptr, bytes, stream); } diff --git a/include/rmm/mr/host/host_memory_resource.hpp b/include/rmm/mr/host/host_memory_resource.hpp index ce870287c..d8bb311c8 100644 --- a/include/rmm/mr/host/host_memory_resource.hpp +++ b/include/rmm/mr/host/host_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -15,6 +15,8 @@ */ #pragma once +#include + #include #include @@ -76,6 +78,7 @@ class host_memory_resource { */ void* allocate(std::size_t bytes, std::size_t alignment = alignof(std::max_align_t)) { + RMM_FUNC_RANGE(); return do_allocate(bytes, alignment); } @@ -94,6 +97,7 @@ class host_memory_resource { */ void deallocate(void* ptr, std::size_t bytes, std::size_t alignment = alignof(std::max_align_t)) { + RMM_FUNC_RANGE(); do_deallocate(ptr, bytes, alignment); } diff --git a/include/rmm/mr/pinned_host_memory_resource.hpp b/include/rmm/mr/pinned_host_memory_resource.hpp index ee409dbac..6bca05376 100644 --- a/include/rmm/mr/pinned_host_memory_resource.hpp +++ b/include/rmm/mr/pinned_host_memory_resource.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -63,6 +64,8 @@ class pinned_host_memory_resource { static void* allocate(std::size_t bytes, [[maybe_unused]] std::size_t alignment = rmm::RMM_DEFAULT_HOST_ALIGNMENT) { + RMM_FUNC_RANGE(); + // don't allocate anything if the user requested zero bytes if (0 == bytes) { return nullptr; } @@ -84,6 +87,8 @@ class pinned_host_memory_resource { std::size_t bytes, std::size_t alignment = rmm::RMM_DEFAULT_HOST_ALIGNMENT) noexcept { + RMM_FUNC_RANGE(); + rmm::detail::aligned_host_deallocate( ptr, bytes, alignment, [](void* ptr) { RMM_ASSERT_CUDA_SUCCESS(cudaFreeHost(ptr)); }); } @@ -104,6 +109,8 @@ class pinned_host_memory_resource { */ static void* allocate_async(std::size_t bytes, [[maybe_unused]] cuda::stream_ref stream) { + RMM_FUNC_RANGE(); + return allocate(bytes); } @@ -126,6 +133,8 @@ class pinned_host_memory_resource { std::size_t alignment, [[maybe_unused]] cuda::stream_ref stream) { + RMM_FUNC_RANGE(); + return allocate(bytes, alignment); } @@ -142,6 +151,8 @@ class pinned_host_memory_resource { std::size_t bytes, [[maybe_unused]] cuda::stream_ref stream) noexcept { + RMM_FUNC_RANGE(); + return deallocate(ptr, bytes); } @@ -161,6 +172,8 @@ class pinned_host_memory_resource { std::size_t alignment, [[maybe_unused]] cuda::stream_ref stream) noexcept { + RMM_FUNC_RANGE(); + return deallocate(ptr, bytes, alignment); } // NOLINTEND(bugprone-easily-swappable-parameters) From dc1e17a03ed2dbc9329ccecc27922e414250f45a Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 23 May 2024 14:27:08 -0400 Subject: [PATCH 412/675] rmm needs to link to nvtx3::nvtx3-cpp to support installed nvtx3 (#1569) If nvtx3 is already installed on the system via rapids-cmake rmm fails to link since it uses the non-namespaced target names. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Paul Taylor (https://github.com/trxcllnt) URL: https://github.com/rapidsai/rmm/pull/1569 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddfed3df5..fa3358ca0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,7 @@ target_link_libraries(rmm INTERFACE CCCL::CCCL) target_link_libraries(rmm INTERFACE fmt::fmt-header-only) target_link_libraries(rmm INTERFACE spdlog::spdlog_header_only) target_link_libraries(rmm INTERFACE dl) -target_link_libraries(rmm INTERFACE nvtx3-cpp) +target_link_libraries(rmm INTERFACE nvtx3::nvtx3-cpp) target_compile_features(rmm INTERFACE cxx_std_17 $) target_compile_definitions(rmm INTERFACE LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE) From 15c04666e20712f30882a903bfad79e208d8e852 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 24 May 2024 16:55:50 -0500 Subject: [PATCH 413/675] Use rapids-build-backend. (#1502) This PR uses `rapids-build-backend` to simplify wheel builds and reduce the complexity of various CI/build scripts. See also: - https://github.com/rapidsai/rapids-build-backend - https://github.com/rapidsai/build-planning/issues/31 - https://github.com/rapidsai/cudf/pull/15245 - #1529 Authors: - Bradley Dice (https://github.com/bdice) - James Lamb (https://github.com/jameslamb) Approvers: - Kyle Edwards (https://github.com/KyleFromNVIDIA) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1502 --- .pre-commit-config.yaml | 2 +- build.sh | 6 ++- ci/build_python.sh | 13 ++----- ci/build_wheel_cpp.sh | 14 +------ ci/build_wheel_python.sh | 26 +------------ .../all_cuda-118_arch-x86_64.yaml | 4 +- .../all_cuda-122_arch-x86_64.yaml | 4 +- conda/recipes/rmm/meta.yaml | 1 + dependencies.yaml | 38 +++++++++++++++---- python/librmm/librmm/_version.py | 7 +++- python/librmm/pyproject.toml | 14 +++++-- python/rmm/pyproject.toml | 20 +++++++--- python/rmm/rmm/_version.py | 19 ++++++++-- python/rmm/rmm/tests/test_version.py | 24 ++++++++++++ 14 files changed, 121 insertions(+), 71 deletions(-) create mode 100644 python/rmm/rmm/tests/test_version.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d21fcebf8..4155cdc19 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - repo: https://github.com/rapidsai/dependency-file-generator - rev: v1.8.0 + rev: v1.13.11 hooks: - id: rapids-dependency-file-generator args: ["--clean"] diff --git a/build.sh b/build.sh index 70da14b9b..afd26e9e6 100755 --- a/build.sh +++ b/build.sh @@ -170,5 +170,9 @@ fi # Build and install the rmm Python package if (( NUMARGS == 0 )) || hasArg rmm; then echo "building and installing rmm..." - SKBUILD_CMAKE_ARGS="${EXTRA_CMAKE_ARGS}" python -m pip install --no-build-isolation --no-deps ${REPODIR}/python/rmm + SKBUILD_CMAKE_ARGS="${EXTRA_CMAKE_ARGS}" python -m pip install \ + --no-build-isolation \ + --no-deps \ + --config-settings rapidsai.disable-cuda=true \ + ${REPODIR}/python/rmm fi diff --git a/ci/build_python.sh b/ci/build_python.sh index 394b3a453..fcd2c55e7 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2020-2023, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. set -euo pipefail @@ -13,20 +13,13 @@ export CMAKE_GENERATOR=Ninja rapids-print-env -package_name="rmm" -package_dir="python/rmm" - -version=$(rapids-generate-version) -commit=$(git rev-parse HEAD) - -echo "${version}" > VERSION -sed -i "/^__git_commit__/ s/= .*/= \"${commit}\"/g" "${package_dir}/${package_name}/_version.py" +rapids-generate-version > ./VERSION rapids-logger "Begin py build" CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) # This calls mambabuild when boa is installed (as is the case in the CI images) -RAPIDS_PACKAGE_VERSION=${version} rapids-conda-retry mambabuild -c "${CPP_CHANNEL}" conda/recipes/rmm +RAPIDS_PACKAGE_VERSION=$(head -1 ./VERSION) rapids-conda-retry mambabuild -c "${CPP_CHANNEL}" conda/recipes/rmm rapids-upload-conda-to-s3 python diff --git a/ci/build_wheel_cpp.sh b/ci/build_wheel_cpp.sh index e61f6641c..2c5cc0560 100755 --- a/ci/build_wheel_cpp.sh +++ b/ci/build_wheel_cpp.sh @@ -3,27 +3,15 @@ set -euo pipefail -package_name="librmm" package_dir="python/librmm" source rapids-configure-sccache source rapids-date-string -version=$(rapids-generate-version) -commit=$(git rev-parse HEAD) +rapids-generate-version > ./VERSION RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" -# This is the version of the suffix with a preceding hyphen. It's used -# everywhere except in the final wheel name. -PACKAGE_CUDA_SUFFIX="-${RAPIDS_PY_CUDA_SUFFIX}" - -pyproject_file="${package_dir}/pyproject.toml" - -sed -i "s/name = \"${package_name}\"/name = \"${package_name}${PACKAGE_CUDA_SUFFIX}\"/g" ${pyproject_file} -echo "${version}" > VERSION -sed -i "/^__git_commit__/ s/= .*/= \"${commit}\"/g" "${package_dir}/${package_name}/_version.py" - cd "${package_dir}" python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index debe9b0fe..92a0c8df2 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -9,33 +9,11 @@ package_dir="python/rmm" source rapids-configure-sccache source rapids-date-string -version=$(rapids-generate-version) -commit=$(git rev-parse HEAD) - -RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" - -# This is the version of the suffix with a preceding hyphen. It is used -# everywhere except in the final wheel name. -PACKAGE_CUDA_SUFFIX="-${RAPIDS_PY_CUDA_SUFFIX}" - -pyproject_file="${package_dir}/pyproject.toml" - -sed -i "s/name = \"${package_name}\"/name = \"${package_name}${PACKAGE_CUDA_SUFFIX}\"/g" ${pyproject_file} -echo "${version}" > VERSION -sed -i "/^__git_commit__/ s/= .*/= \"${commit}\"/g" "${package_dir}/${package_name}/_version.py" - -alpha_spec='' -if ! rapids-is-release-build; then - alpha_spec=',>=0.0.0a0' -fi - -sed -r -i "s/librmm==(.*)\"/librmm${PACKAGE_CUDA_SUFFIX}==\1${alpha_spec}\"/g" ${pyproject_file} -if [[ $PACKAGE_CUDA_SUFFIX == "-cu12" ]]; then - sed -i "s/cuda-python[<=>\.,0-9a]*/cuda-python>=12.0,<13.0a0/g" ${pyproject_file} -fi +rapids-generate-version > ./VERSION cd "${package_dir}" +RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" CPP_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp /tmp/librmm_dist) python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check --find-links "${CPP_WHEELHOUSE}" diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 5806b8bd9..cb2d68d21 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -2,6 +2,7 @@ # To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. channels: - rapidsai +- rapidsai-nightly - conda-forge dependencies: - breathe>=4.35.0 @@ -32,7 +33,8 @@ dependencies: - pytest - pytest-cov - python>=3.9,<3.12 -- scikit-build-core>=0.7.0 +- rapids-build-backend >=0.3.0,<0.4.0.dev0 +- scikit-build-core >=0.7.0 - spdlog>=1.12.0,<1.13 - sphinx - sphinx-copybutton diff --git a/conda/environments/all_cuda-122_arch-x86_64.yaml b/conda/environments/all_cuda-122_arch-x86_64.yaml index 63876715a..d5fe64a52 100644 --- a/conda/environments/all_cuda-122_arch-x86_64.yaml +++ b/conda/environments/all_cuda-122_arch-x86_64.yaml @@ -2,6 +2,7 @@ # To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. channels: - rapidsai +- rapidsai-nightly - conda-forge dependencies: - breathe>=4.35.0 @@ -31,7 +32,8 @@ dependencies: - pytest - pytest-cov - python>=3.9,<3.12 -- scikit-build-core>=0.7.0 +- rapids-build-backend >=0.3.0,<0.4.0.dev0 +- scikit-build-core >=0.7.0 - spdlog>=1.12.0,<1.13 - sphinx - sphinx-copybutton diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index fa8a82475..044defdd9 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -62,6 +62,7 @@ requirements: - cuda-python >=12.0,<13.0a0 {% endif %} - cython >=3.0.0 + - rapids-build-backend >=0.3.0,<0.4.0.dev0 - librmm ={{ version }} - python - scikit-build-core >=0.7.0 diff --git a/dependencies.yaml b/dependencies.yaml index 82d1c83e0..d112b3ba6 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -14,6 +14,7 @@ files: - develop - docs - py_version + - rapids_build_skbuild - run - test_python test_python: @@ -43,6 +44,14 @@ files: pyproject_dir: python/librmm extras: table: build-system + includes: + - rapids_build_skbuild + py_cpp_rapids_build: + output: pyproject + pyproject_dir: python/librmm + extras: + table: tool.rapids-build-backend + key: requires includes: - build py_build: @@ -50,6 +59,14 @@ files: pyproject_dir: python/rmm extras: table: build-system + includes: + - rapids_build_skbuild + py_rapids_build: + output: pyproject + pyproject_dir: python/rmm + extras: + table: tool.rapids-build-backend + key: requires includes: - build - cython_build @@ -70,8 +87,19 @@ files: - test_python channels: - rapidsai + - rapidsai-nightly - conda-forge dependencies: + rapids_build_skbuild: + common: + - output_types: conda + packages: + - rapids-build-backend >=0.3.0,<0.4.0.dev0 + - scikit-build-core >=0.7.0 + - output_types: [requirements, pyproject] + packages: + - rapids-build-backend>=0.3.0,<0.4.0.dev0 + - scikit-build-core[pyproject]>=0.7.0 build: common: - output_types: [conda, requirements, pyproject] @@ -83,11 +111,7 @@ dependencies: - c-compiler - cxx-compiler - fmt>=10.1.1,<11 - - scikit-build-core>=0.7.0 - spdlog>=1.12.0,<1.13 - - output_types: [requirements, pyproject] - packages: - - scikit-build-core[pyproject]>=0.7.0 specific: - output_types: conda matrices: @@ -137,14 +161,14 @@ dependencies: - matrix: cuda: "12.*" packages: - - librmm-cu12==24.8.* + - librmm-cu12==24.8.*,>=0.0.0a0 - matrix: cuda: "11.*" packages: - - librmm-cu11==24.8.* + - librmm-cu11==24.8.*,>=0.0.0a0 - matrix: packages: - - librmm==24.8.* + - librmm==24.8.*,>=0.0.0a0 checks: common: - output_types: [conda, requirements] diff --git a/python/librmm/librmm/_version.py b/python/librmm/librmm/_version.py index ea50101b2..d4be04086 100644 --- a/python/librmm/librmm/_version.py +++ b/python/librmm/librmm/_version.py @@ -15,6 +15,11 @@ import importlib.resources __version__ = ( - importlib.resources.files("librmm").joinpath("VERSION").read_text().strip() + importlib.resources.files(__package__) + .joinpath("VERSION") + .read_text() + .strip() ) __git_commit__ = "" + +__all__ = ["__git_commit__", "__version__"] diff --git a/python/librmm/pyproject.toml b/python/librmm/pyproject.toml index 4b997be9a..04d544c33 100644 --- a/python/librmm/pyproject.toml +++ b/python/librmm/pyproject.toml @@ -13,10 +13,9 @@ # limitations under the License. [build-system] -build-backend = "scikit_build_core.build" +build-backend = "rapids_build_backend.build" requires = [ - "cmake>=3.26.4", - "ninja", + "rapids-build-backend>=0.3.0,<0.4.0.dev0", "scikit-build-core[pyproject]>=0.7.0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. @@ -44,6 +43,15 @@ Homepage = "https://github.com/rapidsai/rmm" [project.entry-points."cmake.prefix"] librmm = "librmm" +[tool.rapids-build-backend] +build-backend = "scikit_build_core.build" +commit-file = "librmm/GIT_COMMIT" +dependencies-file = "../../dependencies.yaml" +requires = [ + "cmake>=3.26.4", + "ninja", +] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. + [tool.scikit-build] build-dir = "build/{wheel_tag}" cmake.build-type = "Release" diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index d3a1ac635..a728d132c 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -13,13 +13,9 @@ # limitations under the License. [build-system] -build-backend = "scikit_build_core.build" +build-backend = "rapids_build_backend.build" requires = [ - "cmake>=3.26.4", - "cuda-python>=11.7.1,<12.0a0", - "cython>=3.0.0", - "librmm==24.8.*", - "ninja", + "rapids-build-backend>=0.3.0,<0.4.0.dev0", "scikit-build-core[pyproject]>=0.7.0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. @@ -125,6 +121,18 @@ provider = "scikit_build_core.metadata.regex" input = "rmm/VERSION" regex = "(?P.*)" +[tool.rapids-build-backend] +build-backend = "scikit_build_core.build" +commit-file = "rmm/GIT_COMMIT" +dependencies-file = "../../dependencies.yaml" +requires = [ + "cmake>=3.26.4", + "cuda-python>=11.7.1,<12.0a0", + "cython>=3.0.0", + "librmm==24.8.*,>=0.0.0a0", + "ninja", +] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. + [tool.pytest.ini_options] # treat warnings as errors filterwarnings = [ diff --git a/python/rmm/rmm/_version.py b/python/rmm/rmm/_version.py index 053e51ecd..7dd732b49 100644 --- a/python/rmm/rmm/_version.py +++ b/python/rmm/rmm/_version.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. +# 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. @@ -15,6 +15,19 @@ import importlib.resources __version__ = ( - importlib.resources.files("rmm").joinpath("VERSION").read_text().strip() + importlib.resources.files(__package__) + .joinpath("VERSION") + .read_text() + .strip() ) -__git_commit__ = "" +try: + __git_commit__ = ( + importlib.resources.files(__package__) + .joinpath("GIT_COMMIT") + .read_text() + .strip() + ) +except FileNotFoundError: + __git_commit__ = "" + +__all__ = ["__git_commit__", "__version__"] diff --git a/python/rmm/rmm/tests/test_version.py b/python/rmm/rmm/tests/test_version.py new file mode 100644 index 000000000..f74642829 --- /dev/null +++ b/python/rmm/rmm/tests/test_version.py @@ -0,0 +1,24 @@ +# 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. + +import rmm + + +def test_version_constants_are_populated(): + # __git_commit__ will only be non-empty in a built distribution + assert isinstance(rmm.__git_commit__, str) + + # __version__ should always be non-empty + assert isinstance(rmm.__version__, str) + assert len(rmm.__version__) > 0 From 805bcf1f6926c154d5ff00b0ed0e9c63f7437cc5 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Thu, 30 May 2024 08:18:13 -0500 Subject: [PATCH 414/675] ensure update-version.sh preserves alpha specs (#1572) Contributes to https://github.com/rapidsai/build-planning/issues/31 Follow-up to #1502 * ensures that `update-version.sh` does not remove alpha specs like `,>=0.0.0a0` in `pyproject.toml` and conda environment files * consolidates `rapids-build-backend` versions in `dependencies.yaml` - *since I was pushing a new commit here anyway, figured I'd take the opportunity to include that simplification recommended in https://github.com/rapidsai/cudf/pull/15245#discussion_r1617724287* Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Kyle Edwards (https://github.com/KyleFromNVIDIA) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1572 --- ci/release/update-version.sh | 4 ++-- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-122_arch-x86_64.yaml | 2 +- dependencies.yaml | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index dfb0c17b0..fb779048c 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -53,9 +53,9 @@ DEPENDENCIES=( ) for DEP in "${DEPENDENCIES[@]}"; do for FILE in dependencies.yaml conda/environments/*.yaml; do - sed_runner "/-.* ${DEP}\(-cu[[:digit:]]\{2\}\)\{0,1\}==/ s/==.*/==${NEXT_SHORT_TAG_PEP440}.*/g" "${FILE}" + sed_runner "/-.* ${DEP}\(-cu[[:digit:]]\{2\}\)\{0,1\}==/ s/==.*/==${NEXT_SHORT_TAG_PEP440}.*,>=0.0.0a0/g" "${FILE}" done for FILE in python/*/pyproject.toml; do - sed_runner "/\"${DEP}==/ s/==.*\"/==${NEXT_SHORT_TAG_PEP440}.*\"/g" "${FILE}" + sed_runner "/\"${DEP}==/ s/==.*\"/==${NEXT_SHORT_TAG_PEP440}.*,>=0.0.0a0\"/g" "${FILE}" done done diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index cb2d68d21..7c79d41b7 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -33,7 +33,7 @@ dependencies: - pytest - pytest-cov - python>=3.9,<3.12 -- rapids-build-backend >=0.3.0,<0.4.0.dev0 +- rapids-build-backend>=0.3.0,<0.4.0.dev0 - scikit-build-core >=0.7.0 - spdlog>=1.12.0,<1.13 - sphinx diff --git a/conda/environments/all_cuda-122_arch-x86_64.yaml b/conda/environments/all_cuda-122_arch-x86_64.yaml index d5fe64a52..efce3b84c 100644 --- a/conda/environments/all_cuda-122_arch-x86_64.yaml +++ b/conda/environments/all_cuda-122_arch-x86_64.yaml @@ -32,7 +32,7 @@ dependencies: - pytest - pytest-cov - python>=3.9,<3.12 -- rapids-build-backend >=0.3.0,<0.4.0.dev0 +- rapids-build-backend>=0.3.0,<0.4.0.dev0 - scikit-build-core >=0.7.0 - spdlog>=1.12.0,<1.13 - sphinx diff --git a/dependencies.yaml b/dependencies.yaml index d112b3ba6..eba0d609b 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -92,13 +92,14 @@ channels: dependencies: rapids_build_skbuild: common: + - output_types: [conda, requirements, pyproject] + packages: + - rapids-build-backend>=0.3.0,<0.4.0.dev0 - output_types: conda packages: - - rapids-build-backend >=0.3.0,<0.4.0.dev0 - scikit-build-core >=0.7.0 - output_types: [requirements, pyproject] packages: - - rapids-build-backend>=0.3.0,<0.4.0.dev0 - scikit-build-core[pyproject]>=0.7.0 build: common: From 8597c22a93b0950517c6c80b94f41f8e3313dd80 Mon Sep 17 00:00:00 2001 From: GALI PREM SAGAR Date: Tue, 4 Jun 2024 12:08:48 -0500 Subject: [PATCH 415/675] Add `available_device_memory` to fetch free amount of memory on a GPU (#1567) This PR adds `get_free_device_memory` that returns free GPU memory necessary for https://github.com/rapidsai/cudf/pull/15628 Authors: - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) - Lawrence Mitchell (https://github.com/wence-) URL: https://github.com/rapidsai/rmm/pull/1567 --- python/rmm/rmm/_lib/memory_resource.pxd | 7 ++++++- python/rmm/rmm/_lib/memory_resource.pyx | 22 ++++++++++++++++++---- python/rmm/rmm/mr.py | 4 +++- python/rmm/rmm/tests/test_rmm.py | 13 +++++++++++++ 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/python/rmm/rmm/_lib/memory_resource.pxd b/python/rmm/rmm/_lib/memory_resource.pxd index f9c2e91de..15ddc84f6 100644 --- a/python/rmm/rmm/_lib/memory_resource.pxd +++ b/python/rmm/rmm/_lib/memory_resource.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2022, NVIDIA CORPORATION. +# Copyright (c) 2020-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. @@ -14,6 +14,7 @@ from libc.stdint cimport int8_t from libcpp.memory cimport shared_ptr +from libcpp.pair cimport pair from libcpp.string cimport string from libcpp.vector cimport vector @@ -32,6 +33,10 @@ cdef extern from "rmm/mr/device/device_memory_resource.hpp" \ cuda_stream_view stream ) except + +cdef extern from "rmm/cuda_device.hpp" namespace "rmm" nogil: + size_t percent_of_free_device_memory(int percent) except + + pair[size_t, size_t] available_device_memory() except + + cdef class DeviceMemoryResource: cdef shared_ptr[device_memory_resource] c_obj cdef device_memory_resource* get_mr(self) noexcept nogil diff --git a/python/rmm/rmm/_lib/memory_resource.pyx b/python/rmm/rmm/_lib/memory_resource.pyx index 100d18b56..992203c27 100644 --- a/python/rmm/rmm/_lib/memory_resource.pyx +++ b/python/rmm/rmm/_lib/memory_resource.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2022, NVIDIA CORPORATION. +# Copyright (c) 2020-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. @@ -32,9 +32,16 @@ from libcpp.string cimport string from cuda.cudart import cudaError_t from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice + from rmm._cuda.stream cimport Stream + from rmm._cuda.stream import DEFAULT_STREAM + from rmm._lib.cuda_stream_view cimport cuda_stream_view +from rmm._lib.memory_resource cimport ( + available_device_memory as c_available_device_memory, + percent_of_free_device_memory as c_percent_of_free_device_memory, +) from rmm._lib.per_device_resource cimport ( cuda_device_id, set_per_device_resource as cpp_set_per_device_resource, @@ -109,8 +116,6 @@ cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ win32 win32_kmt -cdef extern from "rmm/cuda_device.hpp" namespace "rmm" nogil: - size_t percent_of_free_device_memory(int percent) except + cdef extern from "rmm/mr/device/pool_memory_resource.hpp" \ namespace "rmm::mr" nogil: @@ -368,7 +373,7 @@ cdef class PoolMemoryResource(UpstreamResourceAdaptor): cdef size_t c_initial_pool_size cdef optional[size_t] c_maximum_pool_size c_initial_pool_size = ( - percent_of_free_device_memory(50) if + c_percent_of_free_device_memory(50) if initial_pool_size is None else initial_pool_size ) @@ -1188,3 +1193,12 @@ def get_log_filenames(): else None for i, each_mr in _per_device_mrs.items() } + + +def available_device_memory(): + """ + Returns a tuple of free and total device memory memory. + """ + cdef pair[size_t, size_t] res + res = c_available_device_memory() + return (res.first, res.second) diff --git a/python/rmm/rmm/mr.py b/python/rmm/rmm/mr.py index 4f6b801f5..b6ae4e6cd 100644 --- a/python/rmm/rmm/mr.py +++ b/python/rmm/rmm/mr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-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. @@ -28,6 +28,7 @@ UpstreamResourceAdaptor, _flush_logs, _initialize, + available_device_memory, disable_logging, enable_logging, get_current_device_resource, @@ -57,6 +58,7 @@ "UpstreamResourceAdaptor", "_flush_logs", "_initialize", + "available_device_memory", "set_per_device_resource", "enable_logging", "disable_logging", diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index c37fe0298..62adcd4a5 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -1002,3 +1002,16 @@ def test_invalid_logging_level(level): rmm.set_flush_level(level) with pytest.raises(TypeError): rmm.should_log(level) + + +def test_available_device_memory(): + from rmm.mr import available_device_memory + + initial_memory = available_device_memory() + device_buffer = rmm.DeviceBuffer.to_device( # noqa: F841 + np.zeros(10000, dtype="u1") + ) + final_memory = available_device_memory() + assert initial_memory[1] == final_memory[1] + assert initial_memory[0] > 0 + assert final_memory[0] > 0 From f47ce3f0d46848cd9d5844d499bf150dd14d823a Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Wed, 5 Jun 2024 10:13:32 -0400 Subject: [PATCH 416/675] Update Changelog [skip ci] --- CHANGELOG.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f78aa7692..70f788615 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,55 @@ +# rmm 24.06.00 (5 Jun 2024) + +## 🚨 Breaking Changes + +- Refactor polymorphic allocator to use device_async_resource_ref ([#1555](https://github.com/rapidsai/rmm/pull/1555)) [@harrism](https://github.com/harrism) +- Remove deprecated functionality ([#1537](https://github.com/rapidsai/rmm/pull/1537)) [@harrism](https://github.com/harrism) +- Remove deprecated cuda_async_memory_resource constructor that takes thrust::optional parameters ([#1535](https://github.com/rapidsai/rmm/pull/1535)) [@harrism](https://github.com/harrism) +- Remove deprecated supports_streams and get_mem_info methods. ([#1519](https://github.com/rapidsai/rmm/pull/1519)) [@harrism](https://github.com/harrism) + +## 🐛 Bug Fixes + +- rmm needs to link to nvtx3::nvtx3-cpp to support installed nvtx3 ([#1569](https://github.com/rapidsai/rmm/pull/1569)) [@robertmaynard](https://github.com/robertmaynard) +- Make sure rmm wheel dependency on librmm is updated [skip ci] ([#1565](https://github.com/rapidsai/rmm/pull/1565)) [@raydouglass](https://github.com/raydouglass) +- Don't ignore GCC-specific warning under Clang ([#1557](https://github.com/rapidsai/rmm/pull/1557)) [@aaronmondal](https://github.com/aaronmondal) +- Add publish jobs for C++ wheels ([#1554](https://github.com/rapidsai/rmm/pull/1554)) [@vyasr](https://github.com/vyasr) +- Explicitly use the current device resource in DeviceBuffer ([#1514](https://github.com/rapidsai/rmm/pull/1514)) [@wence-](https://github.com/wence-) + +## 📖 Documentation + +- Allow specifying mr in DeviceBuffer construction, and document ownership requirements in Python/C++ interfacing ([#1552](https://github.com/rapidsai/rmm/pull/1552)) [@wence-](https://github.com/wence-) +- Fix Python install instruction ([#1547](https://github.com/rapidsai/rmm/pull/1547)) [@wence-](https://github.com/wence-) +- Update multi-gpu discussion for device_buffer and device_vector dtors ([#1524](https://github.com/rapidsai/rmm/pull/1524)) [@wence-](https://github.com/wence-) +- Fix ordering / heading levels in README.md and python example in guide.md ([#1513](https://github.com/rapidsai/rmm/pull/1513)) [@harrism](https://github.com/harrism) + +## 🚀 New Features + +- Add NVTX support and RMM_FUNC_RANGE() macro ([#1558](https://github.com/rapidsai/rmm/pull/1558)) [@harrism](https://github.com/harrism) +- Always use a static gtest ([#1532](https://github.com/rapidsai/rmm/pull/1532)) [@robertmaynard](https://github.com/robertmaynard) +- Build C++ wheel ([#1529](https://github.com/rapidsai/rmm/pull/1529)) [@vyasr](https://github.com/vyasr) +- Remove deprecated supports_streams and get_mem_info methods. ([#1519](https://github.com/rapidsai/rmm/pull/1519)) [@harrism](https://github.com/harrism) + +## 🛠️ Improvements + +- update copyright dates ([#1564](https://github.com/rapidsai/rmm/pull/1564)) [@jameslamb](https://github.com/jameslamb) +- Overhaul ops-codeowners ([#1561](https://github.com/rapidsai/rmm/pull/1561)) [@raydouglass](https://github.com/raydouglass) +- Adding support for cupy.cuda.stream.ExternalStream ([#1559](https://github.com/rapidsai/rmm/pull/1559)) [@lilohuang](https://github.com/lilohuang) +- Refactor polymorphic allocator to use device_async_resource_ref ([#1555](https://github.com/rapidsai/rmm/pull/1555)) [@harrism](https://github.com/harrism) +- add RAPIDS copyright pre-commit hook ([#1553](https://github.com/rapidsai/rmm/pull/1553)) [@jameslamb](https://github.com/jameslamb) +- Enable warnings as errors for Python tests ([#1551](https://github.com/rapidsai/rmm/pull/1551)) [@mroeschke](https://github.com/mroeschke) +- Remove header existence tests. ([#1550](https://github.com/rapidsai/rmm/pull/1550)) [@bdice](https://github.com/bdice) +- Only use functions in the limited API ([#1545](https://github.com/rapidsai/rmm/pull/1545)) [@vyasr](https://github.com/vyasr) +- Migrate to `{{ stdlib("c") }}` ([#1543](https://github.com/rapidsai/rmm/pull/1543)) [@hcho3](https://github.com/hcho3) +- Fix `cuda11.8` nvcc dependency ([#1542](https://github.com/rapidsai/rmm/pull/1542)) [@trxcllnt](https://github.com/trxcllnt) +- add --rm and --name to devcontainer run args ([#1539](https://github.com/rapidsai/rmm/pull/1539)) [@trxcllnt](https://github.com/trxcllnt) +- Remove deprecated functionality ([#1537](https://github.com/rapidsai/rmm/pull/1537)) [@harrism](https://github.com/harrism) +- Remove deprecated cuda_async_memory_resource constructor that takes thrust::optional parameters ([#1535](https://github.com/rapidsai/rmm/pull/1535)) [@harrism](https://github.com/harrism) +- Make thrust_allocator deallocate safe in multi-device setting ([#1533](https://github.com/rapidsai/rmm/pull/1533)) [@wence-](https://github.com/wence-) +- Move rmm Python package to subdirectory ([#1526](https://github.com/rapidsai/rmm/pull/1526)) [@vyasr](https://github.com/vyasr) +- Remove a file not being used ([#1521](https://github.com/rapidsai/rmm/pull/1521)) [@galipremsagar](https://github.com/galipremsagar) +- Remove unneeded `update-version.sh` update ([#1520](https://github.com/rapidsai/rmm/pull/1520)) [@AyodeAwe](https://github.com/AyodeAwe) +- Enable all tests for `arm` arch ([#1510](https://github.com/rapidsai/rmm/pull/1510)) [@galipremsagar](https://github.com/galipremsagar) + # RMM 24.04.00 (10 Apr 2024) ## 🚨 Breaking Changes From 6902af9e17f3e9c41d23bd3b5855b2f4f51c83d6 Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Thu, 6 Jun 2024 09:57:51 +0200 Subject: [PATCH 417/675] Add a stack to the statistics resource (#1563) In order to enable more fine-grained statistics, this PR adds a _stack_ to `statistics_resource_adaptor` Closes https://github.com/rapidsai/rmm/issues/1332 Authors: - Mads R. B. Kristensen (https://github.com/madsbk) Approvers: - Mark Harris (https://github.com/harrism) - Lawrence Mitchell (https://github.com/wence-) URL: https://github.com/rapidsai/rmm/pull/1563 --- .../mr/device/statistics_resource_adaptor.hpp | 91 ++++- .../mr/device/tracking_resource_adaptor.hpp | 7 +- python/rmm/docs/guide.md | 101 +++++ python/rmm/docs/python_api.rst | 9 + python/rmm/rmm/_lib/memory_resource.pyx | 84 ++++- python/rmm/rmm/statistics.py | 350 ++++++++++++++++++ python/rmm/rmm/tests/conftest.py | 21 +- python/rmm/rmm/tests/test_rmm.py | 62 ---- python/rmm/rmm/tests/test_rmm_pytorch.py | 26 +- python/rmm/rmm/tests/test_statistics.py | 336 +++++++++++++++++ tests/mr/device/statistics_mr_tests.cpp | 44 ++- 11 files changed, 1020 insertions(+), 111 deletions(-) create mode 100644 python/rmm/rmm/statistics.py create mode 100644 python/rmm/rmm/tests/test_statistics.py diff --git a/include/rmm/mr/device/statistics_resource_adaptor.hpp b/include/rmm/mr/device/statistics_resource_adaptor.hpp index d072d5886..c8906afd2 100644 --- a/include/rmm/mr/device/statistics_resource_adaptor.hpp +++ b/include/rmm/mr/device/statistics_resource_adaptor.hpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace rmm::mr { /** @@ -36,8 +37,16 @@ namespace rmm::mr { * resource in order to satisfy allocation requests, but any existing * allocations will be untracked. Tracking statistics stores the current, peak * and total memory allocations for both the number of bytes and number of calls - * to the memory resource. `statistics_resource_adaptor` is intended as a debug - * adaptor and shouldn't be used in performance-sensitive code. + * to the memory resource. + * + * This resource supports nested statistics, which makes it possible to track statistics + * of a code block. Use `.push_counters()` to start tracking statistics on a code block + * and use `.pop_counters()` to stop the tracking. The nested statistics are cascading + * such that the statistics tracked by a code block include the statistics tracked in + * all its tracked sub code blocks. + * + * `statistics_resource_adaptor` is intended as a debug adaptor and shouldn't be + * used in performance-sensitive code. * * @tparam Upstream Type of the upstream resource used for * allocation/deallocation. @@ -45,11 +54,10 @@ namespace rmm::mr { template class statistics_resource_adaptor final : public device_memory_resource { public: - // can be a std::shared_mutex once C++17 is adopted using read_lock_t = - std::shared_lock; ///< Type of lock used to synchronize read access + std::shared_lock; ///< Type of lock used to synchronize read access using write_lock_t = - std::unique_lock; ///< Type of lock used to synchronize write access + std::unique_lock; ///< Type of lock used to synchronize write access /** * @brief Utility struct for counting the current, peak, and total value of a number */ @@ -83,6 +91,24 @@ class statistics_resource_adaptor final : public device_memory_resource { value -= val; return *this; } + + /** + * @brief Add `val` to the current value and update the peak value if necessary + * + * When updating the peak value, we assume that `val` is tracking a code block inside the + * code block tracked by `this`. Because nested statistics are cascading, we have to convert + * `val.peak` to the peak it would have been if it was part of the statistics tracked by `this`. + * We do this by adding the current value that was active when `val` started tracking such that + * we get `std::max(value + val.peak, peak)`. + * + * @param val Value to add + */ + void add_counters_from_tracked_sub_block(const counter& val) + { + peak = std::max(value + val.peak, peak); + value += val.value; + total += val.total; + } }; /** @@ -96,6 +122,8 @@ class statistics_resource_adaptor final : public device_memory_resource { statistics_resource_adaptor(Upstream* upstream) : upstream_{upstream} { RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); + // Initially, we push a single counter pair on the stack + push_counters(); } statistics_resource_adaptor() = delete; @@ -131,7 +159,7 @@ class statistics_resource_adaptor final : public device_memory_resource { { read_lock_t lock(mtx_); - return bytes_; + return counter_stack_.top().first; } /** @@ -145,7 +173,40 @@ class statistics_resource_adaptor final : public device_memory_resource { { read_lock_t lock(mtx_); - return allocations_; + return counter_stack_.top().second; + } + + /** + * @brief Push a pair of zero counters on the stack, which becomes the new + * counters returned by `get_bytes_counter()` and `get_allocations_counter()` + * + * @return top pair of counters from the stack _before_ + * the push + */ + std::pair push_counters() + { + write_lock_t lock(mtx_); + auto ret = counter_stack_.top(); + counter_stack_.push(std::make_pair(counter{}, counter{})); + return ret; + } + + /** + * @brief Pop a pair of counters from the stack + * + * @return top pair of counters from the stack _before_ + * the pop + */ + std::pair pop_counters() + { + write_lock_t lock(mtx_); + if (counter_stack_.size() < 2) { throw std::out_of_range("cannot pop the last counter pair"); } + auto ret = counter_stack_.top(); + counter_stack_.pop(); + // Update the new top pair of counters + counter_stack_.top().first.add_counters_from_tracked_sub_block(ret.first); + counter_stack_.top().second.add_counters_from_tracked_sub_block(ret.second); + return ret; } private: @@ -171,8 +232,8 @@ class statistics_resource_adaptor final : public device_memory_resource { write_lock_t lock(mtx_); // Increment the allocation_count_ while we have the lock - bytes_ += bytes; - allocations_ += 1; + counter_stack_.top().first += bytes; + counter_stack_.top().second += 1; } return ptr; @@ -193,8 +254,8 @@ class statistics_resource_adaptor final : public device_memory_resource { write_lock_t lock(mtx_); // Decrement the current allocated counts. - bytes_ -= bytes; - allocations_ -= 1; + counter_stack_.top().first -= bytes; + counter_stack_.top().second -= 1; } } @@ -213,10 +274,10 @@ class statistics_resource_adaptor final : public device_memory_resource { return get_upstream_resource() == cast->get_upstream_resource(); } - counter bytes_; // peak, current and total allocated bytes - counter allocations_; // peak, current and total allocation count - std::shared_timed_mutex mutable mtx_; // mutex for thread safe access to allocations_ - Upstream* upstream_; // the upstream resource used for satisfying allocation requests + // Stack of counter pairs + std::stack> counter_stack_; + std::shared_mutex mutable mtx_; // mutex for thread safe access to allocations_ + Upstream* upstream_; // the upstream resource used for satisfying allocation requests }; /** diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index c49674849..d01d08b9c 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -53,11 +53,10 @@ namespace rmm::mr { template class tracking_resource_adaptor final : public device_memory_resource { public: - // can be a std::shared_mutex once C++17 is adopted using read_lock_t = - std::shared_lock; ///< Type of lock used to synchronize read access + std::shared_lock; ///< Type of lock used to synchronize read access using write_lock_t = - std::unique_lock; ///< Type of lock used to synchronize write access + std::unique_lock; ///< Type of lock used to synchronize write access /** * @brief Information stored about an allocation. Includes the size * and a stack trace if the `tracking_resource_adaptor` was initialized @@ -271,7 +270,7 @@ class tracking_resource_adaptor final : public device_memory_resource { bool capture_stacks_; // whether or not to capture call stacks std::map allocations_; // map of active allocations std::atomic allocated_bytes_; // number of bytes currently allocated - std::shared_timed_mutex mutable mtx_; // mutex for thread safe access to allocations_ + std::shared_mutex mutable mtx_; // mutex for thread safe access to allocations_ Upstream* upstream_; // the upstream resource used for satisfying allocation requests }; diff --git a/python/rmm/docs/guide.md b/python/rmm/docs/guide.md index 968be8586..bfba0800b 100644 --- a/python/rmm/docs/guide.md +++ b/python/rmm/docs/guide.md @@ -187,3 +187,104 @@ allocator. >>> torch.cuda.memory.change_current_allocator(rmm_torch_allocator) ``` + +## Memory statistics and profiling + +RMM can profile memory usage and track memory statistics by using either of the following: + - Use the context manager `rmm.statistics.statistics()` to enable statistics tracking for a specific code block. + - Call `rmm.statistics.enable_statistics()` to enable statistics tracking globally. + +Common to both usages is that they modify the currently active RMM memory resource. The current device resource is wrapped with a `StatisticsResourceAdaptor` which must remain the topmost resource throughout the statistics tracking: +```python +>>> import rmm +>>> import rmm.statistics + +>>> # We start with the default cuda memory resource +>>> rmm.mr.get_current_device_resource() + + +>>> # When using statistics, we get a StatisticsResourceAdaptor with the context +>>> with rmm.statistics.statistics(): +... rmm.mr.get_current_device_resource() + + +>>> # We can also enable statistics globally +>>> rmm.statistics.enable_statistics() +>>> print(rmm.mr.get_current_device_resource()) + +``` + +With statistics enabled, you can query statistics of the current and peak bytes and number of allocations performed by the current RMM memory resource: +```python +>>> buf = rmm.DeviceBuffer(size=10) +>>> rmm.statistics.get_statistics() +Statistics(current_bytes=16, current_count=1, peak_bytes=16, peak_count=1, total_bytes=16, total_count=1) +``` + +### Memory Profiler +To profile a specific block of code, first enable memory statistics by calling `rmm.statistics.enable_statistics()`. To profile a function, use `profiler` as a function decorator: +```python +>>> @rmm.statistics.profiler() +... def f(size): +... rmm.DeviceBuffer(size=size) +>>> f(1000) + +>>> # By default, the profiler write to rmm.statistics.default_profiler_records +>>> print(rmm.statistics.default_profiler_records.report()) +Memory Profiling +================ + +Legends: + ncalls - number of times the function or code block was called + memory_peak - peak memory allocated in function or code block (in bytes) + memory_total - total memory allocated in function or code block (in bytes) + +Ordered by: memory_peak + +ncalls memory_peak memory_total filename:lineno(function) + 1 1,008 1,008 :1(f) +``` + +To profile a code block, use `profiler` as a context manager: +```python +>>> with rmm.statistics.profiler(name="my code block"): +... rmm.DeviceBuffer(size=20) +>>> print(rmm.statistics.default_profiler_records.report()) +Memory Profiling +================ + +Legends: + ncalls - number of times the function or code block was called + memory_peak - peak memory allocated in function or code block (in bytes) + memory_total - total memory allocated in function or code block (in bytes) + +Ordered by: memory_peak + +ncalls memory_peak memory_total filename:lineno(function) + 1 1,008 1,008 :1(f) + 1 32 32 my code block +``` + +The `profiler` supports nesting: +```python +>>> with rmm.statistics.profiler(name="outer"): +... buf1 = rmm.DeviceBuffer(size=10) +... with rmm.statistics.profiler(name="inner"): +... buf2 = rmm.DeviceBuffer(size=10) +>>> print(rmm.statistics.default_profiler_records.report()) +Memory Profiling +================ + +Legends: + ncalls - number of times the function or code block was called + memory_peak - peak memory allocated in function or code block (in bytes) + memory_total - total memory allocated in function or code block (in bytes) + +Ordered by: memory_peak + +ncalls memory_peak memory_total filename:lineno(function) + 1 1,008 1,008 :1(f) + 1 32 32 my code block + 1 32 32 outer + 1 16 16 inner +``` diff --git a/python/rmm/docs/python_api.rst b/python/rmm/docs/python_api.rst index b229d8214..a62304d21 100644 --- a/python/rmm/docs/python_api.rst +++ b/python/rmm/docs/python_api.rst @@ -37,3 +37,12 @@ Memory Allocators :members: :undoc-members: :show-inheritance: + +Memory Statistics +----------------- + +.. automodule:: rmm.statistics + :members: + :inherited-members: + :undoc-members: + :show-inheritance: diff --git a/python/rmm/rmm/_lib/memory_resource.pyx b/python/rmm/rmm/_lib/memory_resource.pyx index 992203c27..e181bff4c 100644 --- a/python/rmm/rmm/_lib/memory_resource.pyx +++ b/python/rmm/rmm/_lib/memory_resource.pyx @@ -32,9 +32,7 @@ from libcpp.string cimport string from cuda.cudart import cudaError_t from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice - from rmm._cuda.stream cimport Stream - from rmm._cuda.stream import DEFAULT_STREAM from rmm._lib.cuda_stream_view cimport cuda_stream_view @@ -46,6 +44,7 @@ from rmm._lib.per_device_resource cimport ( cuda_device_id, set_per_device_resource as cpp_set_per_device_resource, ) +from rmm.statistics import Statistics # Transparent handle of a C++ exception ctypedef pair[int, string] CppExcept @@ -182,8 +181,7 @@ cdef extern from "rmm/mr/device/logging_resource_adaptor.hpp" \ cdef extern from "rmm/mr/device/statistics_resource_adaptor.hpp" \ namespace "rmm::mr" nogil: - cdef cppclass statistics_resource_adaptor[Upstream]( - device_memory_resource): + cdef cppclass statistics_resource_adaptor[Upstream](device_memory_resource): struct counter: counter() @@ -191,11 +189,12 @@ cdef extern from "rmm/mr/device/statistics_resource_adaptor.hpp" \ int64_t peak int64_t total - statistics_resource_adaptor( - Upstream* upstream_mr) except + + statistics_resource_adaptor(Upstream* upstream_mr) except + counter get_bytes_counter() except + counter get_allocations_counter() except + + pair[counter, counter] pop_counters() except + + pair[counter, counter] push_counters() except + cdef extern from "rmm/mr/device/tracking_resource_adaptor.hpp" \ namespace "rmm::mr" nogil: @@ -798,6 +797,9 @@ cdef class StatisticsResourceAdaptor(UpstreamResourceAdaptor): allocations/deallocations performed by an upstream memory resource. Includes the ability to query these statistics at any time. + A stack of counters is maintained. Use :meth:`push_counters` and + :meth:`pop_counters` to track statistics at different nesting levels. + Parameters ---------- upstream : DeviceMemoryResource @@ -806,7 +808,7 @@ cdef class StatisticsResourceAdaptor(UpstreamResourceAdaptor): pass @property - def allocation_counts(self) -> dict: + def allocation_counts(self) -> Statistics: """ Gets the current, peak, and total allocated bytes and number of allocations. @@ -817,20 +819,62 @@ cdef class StatisticsResourceAdaptor(UpstreamResourceAdaptor): Returns: dict: Dictionary containing allocation counts and bytes. """ + cdef statistics_resource_adaptor[device_memory_resource]* mr = \ + self.c_obj.get() + + counts = deref(mr).get_allocations_counter() + byte_counts = deref(mr).get_bytes_counter() + return Statistics( + current_bytes=byte_counts.value, + current_count=counts.value, + peak_bytes=byte_counts.peak, + peak_count=counts.peak, + total_bytes=byte_counts.total, + total_count=counts.total, + ) + + def pop_counters(self) -> Statistics: + """ + Pop a counter pair (bytes and allocations) from the stack - counts = (( - self.c_obj.get()))[0].get_allocations_counter() - byte_counts = (( - self.c_obj.get()))[0].get_bytes_counter() - - return { - "current_bytes": byte_counts.value, - "current_count": counts.value, - "peak_bytes": byte_counts.peak, - "peak_count": counts.peak, - "total_bytes": byte_counts.total, - "total_count": counts.total, - } + Returns + ------- + The popped statistics + """ + cdef statistics_resource_adaptor[device_memory_resource]* mr = \ + self.c_obj.get() + + bytes_and_allocs = deref(mr).pop_counters() + return Statistics( + current_bytes=bytes_and_allocs.first.value, + current_count=bytes_and_allocs.second.value, + peak_bytes=bytes_and_allocs.first.peak, + peak_count=bytes_and_allocs.second.peak, + total_bytes=bytes_and_allocs.first.total, + total_count=bytes_and_allocs.second.total, + ) + + def push_counters(self) -> Statistics: + """ + Push a new counter pair (bytes and allocations) on the stack + + Returns + ------- + The statistics _before_ the push + """ + + cdef statistics_resource_adaptor[device_memory_resource]* mr = \ + self.c_obj.get() + + bytes_and_allocs = deref(mr).push_counters() + return Statistics( + current_bytes=bytes_and_allocs.first.value, + current_count=bytes_and_allocs.second.value, + peak_bytes=bytes_and_allocs.first.peak, + peak_count=bytes_and_allocs.second.peak, + total_bytes=bytes_and_allocs.first.total, + total_count=bytes_and_allocs.second.total, + ) cdef class TrackingResourceAdaptor(UpstreamResourceAdaptor): diff --git a/python/rmm/rmm/statistics.py b/python/rmm/rmm/statistics.py new file mode 100644 index 000000000..279e45dc6 --- /dev/null +++ b/python/rmm/rmm/statistics.py @@ -0,0 +1,350 @@ +# 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. + +import inspect +import threading +from collections import defaultdict +from contextlib import contextmanager +from dataclasses import dataclass +from functools import wraps +from typing import Dict, Literal, Optional + +import rmm.mr + + +@dataclass +class Statistics: + """Statistics returned by ``{get,push,pop}_statistics()``. + + Attributes + ---------- + current_bytes + Current number of bytes allocated + current_count + Current number of allocations allocated + peak_bytes + Peak number of bytes allocated + peak_count + Peak number of allocations allocated + total_bytes + Total number of bytes allocated + total_count + Total number of allocations allocated + """ + + current_bytes: int + current_count: int + peak_bytes: int + peak_count: int + total_bytes: int + total_count: int + + +def enable_statistics() -> None: + """Enable allocation statistics. + + This function is idempotent. If statistics have been enabled for the + current RMM resource stack, this is a no-op. + + Warnings + -------- + This modifies the current RMM memory resource. StatisticsResourceAdaptor + is pushed onto the current RMM memory resource stack and must remain the + topmost resource throughout the statistics gathering. + """ + + mr = rmm.mr.get_current_device_resource() + if not isinstance(mr, rmm.mr.StatisticsResourceAdaptor): + rmm.mr.set_current_device_resource( + rmm.mr.StatisticsResourceAdaptor(mr) + ) + + +def get_statistics() -> Optional[Statistics]: + """Get the current allocation statistics. + + Return + ------ + If enabled, returns the current tracked statistics. + If disabled, returns None. + """ + mr = rmm.mr.get_current_device_resource() + if isinstance(mr, rmm.mr.StatisticsResourceAdaptor): + return mr.allocation_counts + return None + + +def push_statistics() -> Optional[Statistics]: + """Push new counters on the current allocation statistics stack. + + This returns the current tracked statistics and pushes a new set + of zero counters on the stack of statistics. + + If statistics are disabled (the current memory resource is not an + instance of StatisticsResourceAdaptor), this function is a no-op. + + Return + ------ + If enabled, returns the current tracked statistics _before_ the pop. + If disabled, returns None. + """ + mr = rmm.mr.get_current_device_resource() + if isinstance(mr, rmm.mr.StatisticsResourceAdaptor): + return mr.push_counters() + return None + + +def pop_statistics() -> Optional[Statistics]: + """Pop the counters of the current allocation statistics stack. + + This returns the counters of current tracked statistics and pops + them from the stack. + + If statistics are disabled (the current memory resource is not an + instance of StatisticsResourceAdaptor), this function is a no-op. + + Return + ------ + If enabled, returns the popped counters. + If disabled, returns None. + """ + mr = rmm.mr.get_current_device_resource() + if isinstance(mr, rmm.mr.StatisticsResourceAdaptor): + return mr.pop_counters() + return None + + +@contextmanager +def statistics(): + """Context to enable allocation statistics. + + If statistics have been enabled already (the current memory resource is an + instance of StatisticsResourceAdaptor), new counters are pushed on the + current allocation statistics stack when entering the context and popped + again when exiting using `push_statistics()` and `push_statistics()`. + + If statistics have not been enabled, a new StatisticsResourceAdaptor is set + as the current RMM memory resource when entering the context and removed + again when exiting. + + Raises + ------ + ValueError + If the current RMM memory source was changed while in the context. + """ + + prior_non_stats_mr = None + if push_statistics() is None: + # Save the current non-statistics memory resource for later cleanup + prior_non_stats_mr = rmm.mr.get_current_device_resource() + enable_statistics() + + try: + current_mr = rmm.mr.get_current_device_resource() + yield + finally: + if current_mr is not rmm.mr.get_current_device_resource(): + raise ValueError( + "RMM memory source stack was changed " + "while in the statistics context" + ) + if prior_non_stats_mr is None: + pop_statistics() + else: + rmm.mr.set_current_device_resource(prior_non_stats_mr) + + +class ProfilerRecords: + """Records of the memory statistics recorded by a profiler.""" + + @dataclass + class MemoryRecord: + """Memory statistics of a single code block. + + Attributes + ---------- + num_calls + Number of times this code block was invoked. + memory_total + Total number of bytes allocated. + memory_peak + Peak number of bytes allocated. + """ + + num_calls: int = 0 + memory_total: int = 0 + memory_peak: int = 0 + + def add(self, memory_total: int, memory_peak: int): + self.num_calls += 1 + self.memory_total += memory_total + self.memory_peak = max(self.memory_peak, memory_peak) + + def __init__(self) -> None: + self._lock = threading.Lock() + self._records: Dict[str, ProfilerRecords.MemoryRecord] = defaultdict( + ProfilerRecords.MemoryRecord + ) + + def add(self, name: str, data: Statistics) -> None: + """Add memory statistics to the record named `name`. + + This method is thread-safe. + + Parameters + ---------- + name + Name of the record. + data + Memory statistics of `name`. + """ + with self._lock: + self._records[name].add( + memory_total=data.total_bytes, memory_peak=data.peak_bytes + ) + + @property + def records(self) -> Dict[str, MemoryRecord]: + """Dictionary mapping record names to their memory statistics.""" + return dict(self._records) + + def report( + self, + ordered_by: Literal[ + "num_calls", "memory_peak", "memory_total" + ] = "memory_peak", + ) -> str: + """Pretty format the recorded memory statistics. + + Parameters + ---------- + ordered_by + Sort the statistics by this attribute. + + Return + ------ + The pretty formatted string of the memory statistics + """ + + # Sort by `ordered_by` + records = sorted( + ((name, data) for name, data in self.records.items()), + key=lambda x: getattr(x[1], ordered_by), + reverse=True, + ) + ret = "Memory Profiling\n" + ret += "================\n\n" + if len(records) == 0: + return ret + "No data, maybe profiling wasn't enabled?" + ret += ( + "Legends:\n" + " ncalls - number of times the function or code block " + "was called\n" + " memory_peak - peak memory allocated in function or code " + "block (in bytes)\n" + " memory_total - total memory allocated in function or code " + "block (in bytes)\n" + ) + ret += f"\nOrdered by: {ordered_by}\n" + ret += "\nncalls memory_peak memory_total " + ret += "filename:lineno(function)\n" + for name, data in records: + ret += f"{data.num_calls:6,d} {data.memory_peak:15,d} " + ret += f"{data.memory_total:15,d} {name}\n" + return ret[:-1] # Remove the final newline + + def __repr__(self) -> str: + return f"{self.__class__.__name__}({self.records})" + + def __str__(self) -> str: + return self.report() + + +def _get_descriptive_name_of_object(obj: object) -> str: + """Get descriptive name of object. + + Parameters + ---------- + obj + Object in question + + Return + ------ + A string including filename, line number, and object name. + """ + + obj = inspect.unwrap(obj) + _, linenumber = inspect.getsourcelines(obj) + filepath = inspect.getfile(obj) + return f"{filepath}:{linenumber}({obj.__qualname__})" + + +default_profiler_records = ProfilerRecords() + + +def profiler( + *, + records: ProfilerRecords = default_profiler_records, + name: str = "", +): + """Decorator and context to profile function or code block. + + If statistics are enabled (the current memory resource is an + instance of StatisticsResourceAdaptor), this decorator records the + memory statistics of the decorated function or code block. + + If statistics are disabled, this decorator/context is a no-op. + + Parameters + ---------- + records + The profiler records that the memory statistics are written to. If + not set, a default profiler records are used. + name + The name of the memory profile, mandatory when the profiler + is used as a context manager. If used as a decorator, an empty name + is allowed. In this case, the name is the filename, line number, and + function name. + """ + + class ProfilerContext: + def __call__(self, func: callable) -> callable: + _name = name or _get_descriptive_name_of_object(func) + + @wraps(func) + def wrapper(*args, **kwargs): + push_statistics() + try: + return func(*args, **kwargs) + finally: + if (stats := pop_statistics()) is not None: + records.add(name=_name, data=stats) + + return wrapper + + def __enter__(self): + if not name: + raise ValueError( + "When profiler is used as a context manager, " + "a name must be provided" + ) + push_statistics() + return self + + def __exit__(self, *exc): + if (stats := pop_statistics()) is not None: + records.add(name=name, data=stats) + return False + + return ProfilerContext() diff --git a/python/rmm/rmm/tests/conftest.py b/python/rmm/rmm/tests/conftest.py index 5fad81c79..b6debd9a2 100644 --- a/python/rmm/rmm/tests/conftest.py +++ b/python/rmm/rmm/tests/conftest.py @@ -1,6 +1,21 @@ +# 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. + import pytest import rmm +import rmm.statistics @pytest.fixture(scope="function", autouse=True) @@ -16,6 +31,6 @@ def rmm_auto_reinitialize(): @pytest.fixture def stats_mr(): - mr = rmm.mr.StatisticsResourceAdaptor(rmm.mr.CudaMemoryResource()) - rmm.mr.set_current_device_resource(mr) - return mr + """Fixture that makes a StatisticsResourceAdaptor available to the test""" + with rmm.statistics.statistics(): + yield rmm.mr.get_current_device_resource() diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index 62adcd4a5..53edd96d2 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -649,68 +649,6 @@ def test_limiting_resource_adaptor(mr): rmm.DeviceBuffer(size=1) -def test_statistics_resource_adaptor(stats_mr): - - buffers = [rmm.DeviceBuffer(size=1000) for _ in range(10)] - - for i in range(9, 0, -2): - del buffers[i] - - assert stats_mr.allocation_counts == { - "current_bytes": 5040, - "current_count": 5, - "peak_bytes": 10080, - "peak_count": 10, - "total_bytes": 10080, - "total_count": 10, - } - - # Push a new Tracking adaptor - mr2 = rmm.mr.StatisticsResourceAdaptor(stats_mr) - rmm.mr.set_current_device_resource(mr2) - - for _ in range(2): - buffers.append(rmm.DeviceBuffer(size=1000)) - - assert mr2.allocation_counts == { - "current_bytes": 2016, - "current_count": 2, - "peak_bytes": 2016, - "peak_count": 2, - "total_bytes": 2016, - "total_count": 2, - } - assert stats_mr.allocation_counts == { - "current_bytes": 7056, - "current_count": 7, - "peak_bytes": 10080, - "peak_count": 10, - "total_bytes": 12096, - "total_count": 12, - } - - del buffers - gc.collect() - - assert mr2.allocation_counts == { - "current_bytes": 0, - "current_count": 0, - "peak_bytes": 2016, - "peak_count": 2, - "total_bytes": 2016, - "total_count": 2, - } - assert stats_mr.allocation_counts == { - "current_bytes": 0, - "current_count": 0, - "peak_bytes": 10080, - "peak_count": 10, - "total_bytes": 12096, - "total_count": 12, - } - gc.collect() - - def test_tracking_resource_adaptor(): cuda_mr = rmm.mr.CudaMemoryResource() diff --git a/python/rmm/rmm/tests/test_rmm_pytorch.py b/python/rmm/rmm/tests/test_rmm_pytorch.py index 065507b61..2c9a4af23 100644 --- a/python/rmm/rmm/tests/test_rmm_pytorch.py +++ b/python/rmm/rmm/tests/test_rmm_pytorch.py @@ -1,3 +1,17 @@ +# 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. + import gc import pytest @@ -17,21 +31,21 @@ def torch_allocator(): def test_rmm_torch_allocator(torch_allocator, stats_mr): - assert stats_mr.allocation_counts["current_bytes"] == 0 + assert stats_mr.allocation_counts.current_bytes == 0 x = torch.tensor([1, 2]).cuda() - assert stats_mr.allocation_counts["current_bytes"] > 0 + assert stats_mr.allocation_counts.current_bytes > 0 del x gc.collect() - assert stats_mr.allocation_counts["current_bytes"] == 0 + assert stats_mr.allocation_counts.current_bytes == 0 def test_rmm_torch_allocator_using_stream(torch_allocator, stats_mr): - assert stats_mr.allocation_counts["current_bytes"] == 0 + assert stats_mr.allocation_counts.current_bytes == 0 s = torch.cuda.Stream() with torch.cuda.stream(s): x = torch.tensor([1, 2]).cuda() torch.cuda.current_stream().wait_stream(s) - assert stats_mr.allocation_counts["current_bytes"] > 0 + assert stats_mr.allocation_counts.current_bytes > 0 del x gc.collect() - assert stats_mr.allocation_counts["current_bytes"] == 0 + assert stats_mr.allocation_counts.current_bytes == 0 diff --git a/python/rmm/rmm/tests/test_statistics.py b/python/rmm/rmm/tests/test_statistics.py new file mode 100644 index 000000000..7ba09a92f --- /dev/null +++ b/python/rmm/rmm/tests/test_statistics.py @@ -0,0 +1,336 @@ +# 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. + +import pytest + +import rmm.mr +from rmm.statistics import ( + ProfilerRecords, + _get_descriptive_name_of_object, + default_profiler_records, + get_statistics, + pop_statistics, + profiler, + push_statistics, + statistics, +) + + +def test_context(): + mr0 = rmm.mr.get_current_device_resource() + assert get_statistics() is None + with statistics(): + mr1 = rmm.mr.get_current_device_resource() + assert isinstance( + rmm.mr.get_current_device_resource(), + rmm.mr.StatisticsResourceAdaptor, + ) + b1 = rmm.DeviceBuffer(size=20) + stats = get_statistics() + assert stats.current_bytes == 32 + assert stats.current_count == 1 + assert stats.peak_bytes == 32 + assert stats.peak_count == 1 + assert stats.total_bytes == 32 + assert stats.total_count == 1 + + with statistics(): + mr2 = rmm.mr.get_current_device_resource() + assert mr1 is mr2 + b2 = rmm.DeviceBuffer(size=10) + stats = get_statistics() + assert stats.current_bytes == 16 + assert stats.current_count == 1 + assert stats.peak_bytes == 16 + assert stats.peak_count == 1 + assert stats.total_bytes == 16 + assert stats.total_count == 1 + + stats = get_statistics() + assert stats.current_bytes == 48 + assert stats.current_count == 2 + assert stats.peak_bytes == 48 + assert stats.peak_count == 2 + assert stats.total_bytes == 48 + assert stats.total_count == 2 + + del b1 + del b2 + assert rmm.mr.get_current_device_resource() is mr0 + + +def test_multiple_mr(stats_mr): + buffers = [rmm.DeviceBuffer(size=1000) for _ in range(10)] + + for i in range(9, 0, -2): + del buffers[i] + + stats = stats_mr.allocation_counts + assert stats.current_bytes == 5040 + assert stats.current_count == 5 + assert stats.peak_bytes == 10080 + assert stats.peak_count == 10 + assert stats.total_bytes == 10080 + assert stats.total_count == 10 + + # Push a new Tracking adaptor + mr2 = rmm.mr.StatisticsResourceAdaptor(stats_mr) + rmm.mr.set_current_device_resource(mr2) + try: + for _ in range(2): + buffers.append(rmm.DeviceBuffer(size=1000)) + + stats = mr2.allocation_counts + assert stats.current_bytes == 2016 + assert stats.current_count == 2 + assert stats.peak_bytes == 2016 + assert stats.peak_count == 2 + assert stats.total_bytes == 2016 + assert stats.total_count == 2 + + stats = stats_mr.allocation_counts + assert stats.current_bytes == 7056 + assert stats.current_count == 7 + assert stats.peak_bytes == 10080 + assert stats.peak_count == 10 + assert stats.total_bytes == 12096 + assert stats.total_count == 12 + + del buffers + stats = mr2.allocation_counts + assert stats.current_bytes == 0 + assert stats.current_count == 0 + assert stats.peak_bytes == 2016 + assert stats.peak_count == 2 + assert stats.total_bytes == 2016 + assert stats.total_count == 2 + + stats = stats_mr.allocation_counts + assert stats.current_bytes == 0 + assert stats.current_count == 0 + assert stats.peak_bytes == 10080 + assert stats.peak_count == 10 + assert stats.total_bytes == 12096 + assert stats.total_count == 12 + + finally: + rmm.mr.set_current_device_resource(stats_mr) + + +def test_counter_stack(stats_mr): + buffers = [rmm.DeviceBuffer(size=10) for _ in range(10)] + + # push returns the stats from the top before the push + stats = stats_mr.push_counters() # stats from stack level 0 + assert stats.current_bytes == 160 + assert stats.current_count == 10 + assert stats.peak_bytes == 160 + assert stats.peak_count == 10 + assert stats.total_bytes == 160 + assert stats.total_count == 10 + + b1 = rmm.DeviceBuffer(size=10) + + stats = stats_mr.push_counters() # stats from stack level 1 + assert stats.current_bytes == 16 + assert stats.current_count == 1 + assert stats.peak_bytes == 16 + assert stats.peak_count == 1 + assert stats.total_bytes == 16 + assert stats.total_count == 1 + + del b1 + + # pop returns the popped stats + # Note, the bytes and counts can be negative + stats = stats_mr.pop_counters() # stats from stack level 2 + assert stats.current_bytes == -16 + assert stats.current_count == -1 + assert stats.peak_bytes == 0 + assert stats.peak_count == 0 + assert stats.total_bytes == 0 + assert stats.total_count == 0 + + b1 = rmm.DeviceBuffer(size=10) + + stats = stats_mr.push_counters() # stats from stack level 1 + assert stats.current_bytes == 16 + assert stats.current_count == 1 + assert stats.peak_bytes == 16 + assert stats.peak_count == 1 + assert stats.total_bytes == 32 + assert stats.total_count == 2 + + b2 = rmm.DeviceBuffer(size=10) + + stats = stats_mr.pop_counters() # stats from stack level 2 + assert stats.current_bytes == 16 + assert stats.current_count == 1 + assert stats.peak_bytes == 16 + assert stats.peak_count == 1 + assert stats.total_bytes == 16 + assert stats.total_count == 1 + + stats = stats_mr.pop_counters() # stats from stack level 1 + assert stats.current_bytes == 32 + assert stats.current_count == 2 + assert stats.peak_bytes == 32 + assert stats.peak_count == 2 + assert stats.total_bytes == 48 + assert stats.total_count == 3 + + del b1 + del b2 + + stats = stats_mr.allocation_counts # stats from stack level 0 + assert stats.current_bytes == 160 + assert stats.current_count == 10 + assert stats.peak_bytes == 192 + assert stats.peak_count == 12 + assert stats.total_bytes == 208 + assert stats.total_count == 13 + + del buffers + with pytest.raises(IndexError, match="cannot pop the last counter pair"): + stats_mr.pop_counters() + + +def test_current_statistics(stats_mr): + b1 = rmm.DeviceBuffer(size=10) + stats = get_statistics() + assert stats.current_bytes == 16 + assert stats.current_count == 1 + assert stats.peak_bytes == 16 + assert stats.peak_count == 1 + assert stats.total_bytes == 16 + assert stats.total_count == 1 + + b2 = rmm.DeviceBuffer(size=20) + stats = push_statistics() + assert stats.current_bytes == 48 + assert stats.current_count == 2 + assert stats.peak_bytes == 48 + assert stats.peak_count == 2 + assert stats.total_bytes == 48 + assert stats.total_count == 2 + + del b1 + stats = pop_statistics() + assert stats.current_bytes == -16 + assert stats.current_count == -1 + assert stats.peak_bytes == 0 + assert stats.peak_count == 0 + assert stats.total_bytes == 0 + assert stats.total_count == 0 + + del b2 + stats = get_statistics() + assert stats.current_bytes == 0 + assert stats.current_count == 0 + assert stats.peak_bytes == 48 + assert stats.peak_count == 2 + assert stats.total_bytes == 48 + assert stats.total_count == 2 + + +def test_statistics_disabled(): + assert get_statistics() is None + assert push_statistics() is None + assert get_statistics() is None + + +def test_profiler(stats_mr): + profiler_records = ProfilerRecords() + assert len(profiler_records.records) == 0 + assert "No data" in profiler_records.report() + + @profiler(records=profiler_records) + def f1(): + b1 = rmm.DeviceBuffer(size=10) + b2 = rmm.DeviceBuffer(size=10) + del b1 + return b2 + + b1 = f1() + b2 = f1() + + @profiler(records=profiler_records) + def f2(): + b1 = rmm.DeviceBuffer(size=10) + + @profiler(records=profiler_records, name="g2") + def g2(b1): + b2 = rmm.DeviceBuffer(size=10) + del b1 + return b2 + + return g2(b1) + + f2() + f2() + del b1 + del b2 + f2() + + @profiler(records=profiler_records) + def f3(): + return [rmm.DeviceBuffer(size=100) for _ in range(100)] + + f3() + + records = profiler_records.records + assert records[ + _get_descriptive_name_of_object(f1) + ] == ProfilerRecords.MemoryRecord( + num_calls=2, memory_total=64, memory_peak=32 + ) + assert records[ + _get_descriptive_name_of_object(f2) + ] == ProfilerRecords.MemoryRecord( + num_calls=3, memory_total=96, memory_peak=32 + ) + assert records["g2"] == ProfilerRecords.MemoryRecord( + num_calls=3, memory_total=48, memory_peak=16 + ) + assert records[ + _get_descriptive_name_of_object(f3) + ] == ProfilerRecords.MemoryRecord( + num_calls=1, memory_total=11200, memory_peak=11200 + ) + + @profiler() # use the default profiler records + def f4(): + return [rmm.DeviceBuffer(size=10) for _ in range(10)] + + f4() + + with profiler(name="b1 and b2"): # use the profiler as a context manager + b1 = rmm.DeviceBuffer(size=100) + b2 = rmm.DeviceBuffer(size=100) + with profiler(name="del b1 and b2"): + del b1 + del b2 + + records = default_profiler_records.records + assert records[ + _get_descriptive_name_of_object(f4) + ] == ProfilerRecords.MemoryRecord( + num_calls=1, memory_total=160, memory_peak=160 + ) + assert records["b1 and b2"] == ProfilerRecords.MemoryRecord( + num_calls=1, memory_total=224, memory_peak=224 + ) + assert records["del b1 and b2"] == ProfilerRecords.MemoryRecord( + num_calls=1, memory_total=0, memory_peak=0 + ) diff --git a/tests/mr/device/statistics_mr_tests.cpp b/tests/mr/device/statistics_mr_tests.cpp index 8fd12f49b..6c5700f0b 100644 --- a/tests/mr/device/statistics_mr_tests.cpp +++ b/tests/mr/device/statistics_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -234,5 +234,47 @@ TEST(StatisticsTest, NegativeInnerTracking) EXPECT_EQ(inner_mr.get_allocations_counter().total, 5); } +TEST(StatisticsTest, Nested) +{ + statistics_adaptor mr{rmm::mr::get_current_device_resource()}; + void* a0 = mr.allocate(ten_MiB); + EXPECT_EQ(mr.get_bytes_counter().value, ten_MiB); + EXPECT_EQ(mr.get_allocations_counter().value, 1); + { + auto [bytes, allocs] = mr.push_counters(); + EXPECT_EQ(bytes.value, ten_MiB); + EXPECT_EQ(allocs.value, 1); + } + EXPECT_EQ(mr.get_bytes_counter().value, 0); + EXPECT_EQ(mr.get_allocations_counter().value, 0); + void* a1 = mr.allocate(ten_MiB); + mr.push_counters(); + EXPECT_EQ(mr.get_bytes_counter().value, 0); + EXPECT_EQ(mr.get_allocations_counter().value, 0); + void* a2 = mr.allocate(ten_MiB); + mr.deallocate(a2, ten_MiB); + EXPECT_EQ(mr.get_bytes_counter().value, 0); + EXPECT_EQ(mr.get_bytes_counter().peak, ten_MiB); + EXPECT_EQ(mr.get_allocations_counter().value, 0); + EXPECT_EQ(mr.get_allocations_counter().peak, 1); + { + auto [bytes, allocs] = mr.pop_counters(); + EXPECT_EQ(bytes.value, 0); + EXPECT_EQ(bytes.peak, ten_MiB); + EXPECT_EQ(allocs.value, 0); + EXPECT_EQ(allocs.peak, 1); + } + mr.deallocate(a0, ten_MiB); + { + auto [bytes, allocs] = mr.pop_counters(); + EXPECT_EQ(bytes.value, 0); + EXPECT_EQ(bytes.peak, ten_MiB * 2); + EXPECT_EQ(allocs.value, 0); + EXPECT_EQ(allocs.peak, 2); + } + mr.deallocate(a1, ten_MiB); + EXPECT_THROW(mr.pop_counters(), std::out_of_range); +} + } // namespace } // namespace rmm::test From 49fcfeb771098c38b4fb83e969b2ae63f5dc66ab Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 6 Jun 2024 19:04:42 -0700 Subject: [PATCH 418/675] Remove text builds of documentation (#1575) This PR removes text builds of the documentation, which we do not currently use for anything. Contributes to https://github.com/rapidsai/build-planning/issues/71. Authors: - Vyas Ramasubramani (https://github.com/vyasr) - Bradley Dice (https://github.com/bdice) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1575 --- ci/build_docs.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 5519a3c35..dc8a2b613 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2020-2023, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. set -euo pipefail @@ -38,10 +38,8 @@ popd rapids-logger "Build Python docs" pushd python/rmm/docs make dirhtml -make text -mkdir -p "${RAPIDS_DOCS_DIR}/rmm/"{html,txt} +mkdir -p "${RAPIDS_DOCS_DIR}/rmm/html" mv _build/dirhtml/* "${RAPIDS_DOCS_DIR}/rmm/html" -mv _build/text/* "${RAPIDS_DOCS_DIR}/rmm/txt" popd rapids-upload-docs From dcca09818f1c5b5b1936f684b0ff9cca5683e63f Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 10 Jun 2024 11:33:35 -0500 Subject: [PATCH 419/675] Allow anonymous user in devcontainer name (#1576) Recently devcontainer names were updated to include the current user's name. However, in GitHub Codespaces, the username is not defined. As a result, the container name starts with a dash. This is not allowed by GitHub Codespaces, so it fails to launch. This PR adds a default value of `anon` to the devcontainer username. See https://github.com/rapidsai/cudf/pull/15784 for more information. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Paul Taylor (https://github.com/trxcllnt) - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1576 --- .devcontainer/cuda11.8-conda/devcontainer.json | 2 +- .devcontainer/cuda11.8-pip/devcontainer.json | 2 +- .devcontainer/cuda12.2-conda/devcontainer.json | 2 +- .devcontainer/cuda12.2-pip/devcontainer.json | 2 +- .github/CODEOWNERS | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.devcontainer/cuda11.8-conda/devcontainer.json b/.devcontainer/cuda11.8-conda/devcontainer.json index 3d23dba87..d87e036d1 100644 --- a/.devcontainer/cuda11.8-conda/devcontainer.json +++ b/.devcontainer/cuda11.8-conda/devcontainer.json @@ -11,7 +11,7 @@ "runArgs": [ "--rm", "--name", - "${localEnv:USER}-rapids-${localWorkspaceFolderBasename}-24.08-cuda11.8-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.08-cuda11.8-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { diff --git a/.devcontainer/cuda11.8-pip/devcontainer.json b/.devcontainer/cuda11.8-pip/devcontainer.json index e7a916842..918c3e98e 100644 --- a/.devcontainer/cuda11.8-pip/devcontainer.json +++ b/.devcontainer/cuda11.8-pip/devcontainer.json @@ -11,7 +11,7 @@ "runArgs": [ "--rm", "--name", - "${localEnv:USER}-rapids-${localWorkspaceFolderBasename}-24.08-cuda11.8-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.08-cuda11.8-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { diff --git a/.devcontainer/cuda12.2-conda/devcontainer.json b/.devcontainer/cuda12.2-conda/devcontainer.json index 31b594a7f..6e694f86f 100644 --- a/.devcontainer/cuda12.2-conda/devcontainer.json +++ b/.devcontainer/cuda12.2-conda/devcontainer.json @@ -11,7 +11,7 @@ "runArgs": [ "--rm", "--name", - "${localEnv:USER}-rapids-${localWorkspaceFolderBasename}-24.08-cuda12.2-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.08-cuda12.2-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { diff --git a/.devcontainer/cuda12.2-pip/devcontainer.json b/.devcontainer/cuda12.2-pip/devcontainer.json index 65fedac9c..5b5bc4f6a 100644 --- a/.devcontainer/cuda12.2-pip/devcontainer.json +++ b/.devcontainer/cuda12.2-pip/devcontainer.json @@ -11,7 +11,7 @@ "runArgs": [ "--rm", "--name", - "${localEnv:USER}-rapids-${localWorkspaceFolderBasename}-24.08-cuda12.2-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.08-cuda12.2-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 334cae320..0de47da43 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -16,7 +16,7 @@ python/ @rapidsai/rmm-python-codeowners /.pre-commit-config.yaml @rapidsai/ci-codeowners #packaging code owners -/.devcontainers/ @rapidsai/packaging-codeowners +/.devcontainer/ @rapidsai/packaging-codeowners /conda/ @rapidsai/packaging-codeowners /dependencies.yaml @rapidsai/packaging-codeowners /build.sh @rapidsai/packaging-codeowners From 9c5b1ed4b0baefd45a61432d4aadbe461dd465ce Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 12 Jun 2024 08:22:28 -0500 Subject: [PATCH 420/675] Avoid `--find-links`. (#1583) Avoid `pip --find-links` which can fail to install and fall back to older wheels. See https://github.com/rapidsai/build-planning/issues/69 for more information. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1583 --- ci/test_wheel.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/test_wheel.sh b/ci/test_wheel.sh index 50cb203c3..8ba03f3a2 100755 --- a/ci/test_wheel.sh +++ b/ci/test_wheel.sh @@ -8,6 +8,6 @@ WHEELHOUSE="${PWD}/dist/" RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 python "${WHEELHOUSE}" # echo to expand wildcard before adding '[extra]' requires for pip -python -m pip install "rmm-${RAPIDS_PY_CUDA_SUFFIX}[test]>=0.0.0a0" --find-links "${WHEELHOUSE}" +python -m pip install -v "$(echo "${WHEELHOUSE}"/rmm_${RAPIDS_PY_CUDA_SUFFIX}*.whl)[test]" python -m pytest ./python/rmm/rmm/tests From e28e0c7cb48c80bc00cb9b65e650616a6148de29 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 12 Jun 2024 09:34:21 -0500 Subject: [PATCH 421/675] resolve dependency-file-generator warning, remove unnecessary rapids-build-backend configuration (#1582) Contributes to https://github.com/rapidsai/build-planning/issues/31 Contributes to https://github.com/rapidsai/dependency-file-generator/issues/89 #1502 was one of the first `rapids-build-backend` PRs merged across RAPIDS. Since it was merged, we've made some small adjustments to the approach for `rapids-build-backend`. This catches `rmm` up with those changes: * consolidates version-handling in `ci/build_cpp.sh` * removes `commit-file` configuration in `pyproject.toml` - *as of https://github.com/rapidsai/rapids-build-backend/pull/30, this is no longer necessary if the project's top-level directory is `{project_name}.replace("-", "_")* - *and anyway, it was changed from `commit-file` to `commit-files` in that PR, so `commit-file` was being silently ignored here* * uses `--file-key` instead of `--file_key` in `rapids-dependency-file-generator` calls Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Kyle Edwards (https://github.com/KyleFromNVIDIA) URL: https://github.com/rapidsai/rmm/pull/1582 --- ci/build_cpp.sh | 6 ++---- ci/build_docs.sh | 2 +- ci/check_style.sh | 4 ++-- ci/test_cpp.sh | 2 +- ci/test_python.sh | 2 +- python/librmm/pyproject.toml | 1 - python/rmm/pyproject.toml | 1 - 7 files changed, 7 insertions(+), 11 deletions(-) diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 7329d4a34..a601ecaae 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2020-2023, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. set -euo pipefail @@ -13,11 +13,9 @@ export CMAKE_GENERATOR=Ninja rapids-print-env -version=$(rapids-generate-version) - rapids-logger "Begin cpp build" # This calls mambabuild when boa is installed (as is the case in the CI images) -RAPIDS_PACKAGE_VERSION=${version} rapids-conda-retry mambabuild conda/recipes/librmm +RAPIDS_PACKAGE_VERSION=$(rapids-generate-version) rapids-conda-retry mambabuild conda/recipes/librmm rapids-upload-conda-to-s3 cpp diff --git a/ci/build_docs.sh b/ci/build_docs.sh index dc8a2b613..307f48e44 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -8,7 +8,7 @@ rapids-logger "Create test conda environment" rapids-dependency-file-generator \ --output conda \ - --file_key docs \ + --file-key docs \ --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee env.yaml rapids-mamba-retry env create --yes -f env.yaml -n docs diff --git a/ci/check_style.sh b/ci/check_style.sh index b8478f312..9d9151417 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2020-2023, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. set -euo pipefail @@ -8,7 +8,7 @@ rapids-logger "Create checks conda environment" rapids-dependency-file-generator \ --output conda \ - --file_key checks \ + --file-key checks \ --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee env.yaml rapids-mamba-retry env create --yes -f env.yaml -n checks diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index e3ff28d9f..9ad1c9536 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -11,7 +11,7 @@ cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../ rapids-logger "Generate C++ testing dependencies" rapids-dependency-file-generator \ --output conda \ - --file_key test_cpp \ + --file-key test_cpp \ --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch)" | tee env.yaml rapids-mamba-retry env create --yes -f env.yaml -n test diff --git a/ci/test_python.sh b/ci/test_python.sh index b4e2791db..3239beaf1 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -11,7 +11,7 @@ rapids-logger "Create test conda environment" rapids-dependency-file-generator \ --output conda \ - --file_key test_python \ + --file-key test_python \ --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee env.yaml rapids-mamba-retry env create --yes -f env.yaml -n test diff --git a/python/librmm/pyproject.toml b/python/librmm/pyproject.toml index 04d544c33..14a591293 100644 --- a/python/librmm/pyproject.toml +++ b/python/librmm/pyproject.toml @@ -45,7 +45,6 @@ librmm = "librmm" [tool.rapids-build-backend] build-backend = "scikit_build_core.build" -commit-file = "librmm/GIT_COMMIT" dependencies-file = "../../dependencies.yaml" requires = [ "cmake>=3.26.4", diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index a728d132c..7de3a3b42 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -123,7 +123,6 @@ regex = "(?P.*)" [tool.rapids-build-backend] build-backend = "scikit_build_core.build" -commit-file = "rmm/GIT_COMMIT" dependencies-file = "../../dependencies.yaml" requires = [ "cmake>=3.26.4", From ac2496454be822422b22b14ae73a695827a9da45 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 12 Jun 2024 11:13:45 -0400 Subject: [PATCH 422/675] Fix test_python matrix (#1579) This fixes the matrix for `test_python` to allow for CUDA 11.4. Fixes a testing regression from https://github.com/rapidsai/rmm/pull/1542. Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) Approvers: - Bradley Dice (https://github.com/bdice) - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1579 --- dependencies.yaml | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/dependencies.yaml b/dependencies.yaml index eba0d609b..ee443184c 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -294,21 +294,15 @@ dependencies: packages: - pytest - pytest-cov - # Needed for numba in tests specific: - output_types: conda matrices: - - matrix: - arch: x86_64 - cuda: "11.8" - packages: - - nvcc_linux-64=11.8 - - matrix: - arch: aarch64 - cuda: "11.8" - packages: - - nvcc_linux-aarch64=11.8 + # Needed for numba in tests on CUDA 12+ since Conda CI environments + # do not have a CUDA compiler preinstalled. Wheel tests are run on + # images that supply a CUDA compiler. - matrix: cuda: "12.*" packages: - cuda-nvcc + - matrix: + packages: From a7093941c84481cc24d558b4aca63a387b7ebedb Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Thu, 13 Jun 2024 08:35:32 +1000 Subject: [PATCH 423/675] Add rmm::prefetch() and DeviceBuffer.prefetch() (#1573) This adds two `rmm::prefetch()` functions in C++. 1. `rmm::prefetch(void *ptr, size_t bytes, device, stream)` 2. `rmm::prefetch(cuda::std::span data, device, stream)` Item 2 enables prefetching the containers that RMM provides (`device_uvector`, `device_scalar`) that support conversion to `cuda::std::span`. In order to enable that, `device_scalar::size()` is added. Note that `device_buffer`s must be prefetched using item 1 because you can't create a `span`. In Python, this adds `DeviceBuffer.prefetch()` because that's really the only RMM Python data type to prefetch. There is *one* Cython use of `device_uvector` in cuDF `join` that we might need to add prefetch support for later. `prefetch` is a no-op on non-managed memory. Rather than querying the type of memory, it just catches `cudaErrorInvalidValue` from `cudaMemPrefetchAsync`. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Rong Ou (https://github.com/rongou) - Jake Hemstad (https://github.com/jrhemstad) - Michael Schellenberger Costa (https://github.com/miscco) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1573 --- include/rmm/cuda_device.hpp | 8 ++ include/rmm/device_scalar.hpp | 6 ++ include/rmm/prefetch.hpp | 77 ++++++++++++++++++ python/rmm/docs/conf.py | 1 + python/rmm/docs/guide.md | 53 ++++++++++--- python/rmm/rmm/_lib/device_buffer.pxd | 15 ++++ python/rmm/rmm/_lib/device_buffer.pyx | 25 ++++++ python/rmm/rmm/tests/test_rmm.py | 27 +++++++ tests/CMakeLists.txt | 11 ++- tests/prefetch_tests.cpp | 110 ++++++++++++++++++++++++++ 10 files changed, 320 insertions(+), 13 deletions(-) create mode 100644 include/rmm/prefetch.hpp create mode 100644 tests/prefetch_tests.cpp diff --git a/include/rmm/cuda_device.hpp b/include/rmm/cuda_device.hpp index 56520518a..32a6b763d 100644 --- a/include/rmm/cuda_device.hpp +++ b/include/rmm/cuda_device.hpp @@ -22,6 +22,9 @@ namespace rmm { +struct cuda_device_id; +inline cuda_device_id get_current_cuda_device(); + /** * @addtogroup cuda_device_management * @{ @@ -34,6 +37,11 @@ namespace rmm { struct cuda_device_id { using value_type = int; ///< Integer type used for device identifier + /** + * @brief Construct a `cuda_device_id` from the current device + */ + cuda_device_id() noexcept : id_{get_current_cuda_device().value()} {} + /** * @brief Construct a `cuda_device_id` from the specified integer value. * diff --git a/include/rmm/device_scalar.hpp b/include/rmm/device_scalar.hpp index 762ba1612..47eed78b2 100644 --- a/include/rmm/device_scalar.hpp +++ b/include/rmm/device_scalar.hpp @@ -43,6 +43,7 @@ class device_scalar { static_assert(std::is_trivially_copyable::value, "Scalar type must be trivially copyable"); using value_type = typename device_uvector::value_type; ///< T, the type of the scalar element + using size_type = typename device_uvector::size_type; ///< The type used for the size using reference = typename device_uvector::reference; ///< value_type& using const_reference = typename device_uvector::const_reference; ///< const value_type& using pointer = @@ -254,6 +255,11 @@ class device_scalar { return static_cast(_storage.data()); } + /** + * @briefreturn{The size of the scalar: always 1} + */ + [[nodiscard]] constexpr size_type size() const noexcept { return 1; } + /** * @briefreturn{Stream associated with the device memory allocation} */ diff --git a/include/rmm/prefetch.hpp b/include/rmm/prefetch.hpp new file mode 100644 index 000000000..205a4d241 --- /dev/null +++ b/include/rmm/prefetch.hpp @@ -0,0 +1,77 @@ +/* + * 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. + */ + +#pragma once + +#include +#include +#include + +#include + +namespace rmm { + +/** + * @addtogroup utilities + * @{ + * @file + */ + +/** + * @brief Prefetch memory to the specified device on the specified stream. + * + * This function is a no-op if the pointer is not to CUDA managed memory. + * + * @throw rmm::cuda_error if the prefetch fails. + * + * @param ptr The pointer to the memory to prefetch + * @param size The number of bytes to prefetch + * @param device The device to prefetch to + * @param stream The stream to use for the prefetch + */ +void prefetch(void const* ptr, + std::size_t size, + rmm::cuda_device_id device, + rmm::cuda_stream_view stream) +{ + auto result = cudaMemPrefetchAsync(ptr, size, device.value(), stream.value()); + // InvalidValue error is raised when non-managed memory is passed to cudaMemPrefetchAsync + // We should treat this as a no-op + if (result != cudaErrorInvalidValue && result != cudaSuccess) { RMM_CUDA_TRY(result); } +} + +/** + * @brief Prefetch a span of memory to the specified device on the specified stream. + * + * This function is a no-op if the buffer is not backed by CUDA managed memory. + * + * @throw rmm::cuda_error if the prefetch fails. + * + * @param data The span to prefetch + * @param device The device to prefetch to + * @param stream The stream to use for the prefetch + */ +template +void prefetch(cuda::std::span data, + rmm::cuda_device_id device, + rmm::cuda_stream_view stream) +{ + prefetch(data.data(), data.size_bytes(), device, stream); +} + +/** @} */ // end of group + +} // namespace rmm diff --git a/python/rmm/docs/conf.py b/python/rmm/docs/conf.py index dd8267e28..d48dc2b42 100644 --- a/python/rmm/docs/conf.py +++ b/python/rmm/docs/conf.py @@ -209,6 +209,7 @@ intersphinx_mapping = { "python": ("https://docs.python.org/3", None), "numba": ("https://numba.readthedocs.io/en/stable", None), + "cuda-python": ("https://nvidia.github.io/cuda-python/", None), } # Config numpydoc diff --git a/python/rmm/docs/guide.md b/python/rmm/docs/guide.md index bfba0800b..911073b5d 100644 --- a/python/rmm/docs/guide.md +++ b/python/rmm/docs/guide.md @@ -27,10 +27,10 @@ There are two ways to use RMM in Python code: RMM provides a `MemoryResource` abstraction to control _how_ device memory is allocated in both the above uses. -### DeviceBuffers +### `DeviceBuffer` Objects -A DeviceBuffer represents an **untyped, uninitialized device memory -allocation**. DeviceBuffers can be created by providing the +A `DeviceBuffer` represents an **untyped, uninitialized device memory +allocation**. `DeviceBuffer`s can be created by providing the size of the allocation in bytes: ```python @@ -48,7 +48,7 @@ can be accessed via the `.size` and `.ptr` attributes respectively: 140202544726016 ``` -DeviceBuffers can also be created by copying data from host memory: +`DeviceBuffer`s can also be created by copying data from host memory: ```python >>> import rmm @@ -59,15 +59,50 @@ DeviceBuffers can also be created by copying data from host memory: 24 ``` -Conversely, the data underlying a DeviceBuffer can be copied to the -host: +Conversely, the data underlying a `DeviceBuffer` can be copied to the host: ```python >>> np.frombuffer(buf.tobytes()) array([1., 2., 3.]) ``` -### MemoryResource objects +#### Prefetching a `DeviceBuffer` + +[CUDA Unified Memory]( + https://developer.nvidia.com/blog/unified-memory-cuda-beginners/ +), also known as managed memory, can be allocated using an +`rmm.mr.ManagedMemoryResource` explicitly, or by calling `rmm.reinitialize` +with `managed_memory=True`. + +A `DeviceBuffer` backed by managed memory or other +migratable memory (such as +[HMM/ATS](https://developer.nvidia.com/blog/simplifying-gpu-application-development-with-heterogeneous-memory-management/) +memory) may be prefetched to a specified device, for example to reduce or eliminate page faults. + +```python +>>> import rmm +>>> rmm.reinitialize(managed_memory=True) +>>> buf = rmm.DeviceBuffer(size=100) +>>> buf.prefetch() +``` + +The above example prefetches the `DeviceBuffer` memory to the current CUDA device +on the stream that the `DeviceBuffer` last used (e.g. at construction). The +destination device ID and stream are optional parameters. + +```python +>>> import rmm +>>> rmm.reinitialize(managed_memory=True) +>>> from rmm._cuda.stream import Stream +>>> stream = Stream() +>>> buf = rmm.DeviceBuffer(size=100, stream=stream) +>>> buf.prefetch(device=3, stream=stream) # prefetch to device on stream. +``` + +`DeviceBuffer.prefetch()` is a no-op if the `DeviceBuffer` is not backed +by migratable memory. + +### `MemoryResource` objects `MemoryResource` objects are used to configure how device memory allocations are made by RMM. @@ -122,13 +157,13 @@ Similarly, to use a pool of managed memory: >>> rmm.mr.set_current_device_resource(pool) ``` -Other MemoryResources include: +Other `MemoryResource`s include: * `FixedSizeMemoryResource` for allocating fixed blocks of memory * `BinningMemoryResource` for allocating blocks within specified "bin" sizes from different memory resources -MemoryResources are highly configurable and can be composed together in different ways. +`MemoryResource`s are highly configurable and can be composed together in different ways. See `help(rmm.mr)` for more information. ## Using RMM with third-party libraries diff --git a/python/rmm/rmm/_lib/device_buffer.pxd b/python/rmm/rmm/_lib/device_buffer.pxd index 2ff1a7da9..0da9ace0c 100644 --- a/python/rmm/rmm/_lib/device_buffer.pxd +++ b/python/rmm/rmm/_lib/device_buffer.pxd @@ -23,6 +23,21 @@ from rmm._lib.memory_resource cimport ( ) +cdef extern from "rmm/mr/device/per_device_resource.hpp" namespace "rmm" nogil: + cdef cppclass cuda_device_id: + ctypedef int value_type + cuda_device_id() + cuda_device_id(value_type id) + value_type value() + + cdef cuda_device_id get_current_cuda_device() + +cdef extern from "rmm/prefetch.hpp" namespace "rmm" nogil: + cdef void prefetch(const void* ptr, + size_t bytes, + cuda_device_id device, + cuda_stream_view stream) except + + cdef extern from "rmm/device_buffer.hpp" namespace "rmm" nogil: cdef cppclass device_buffer: device_buffer() diff --git a/python/rmm/rmm/_lib/device_buffer.pyx b/python/rmm/rmm/_lib/device_buffer.pyx index 9d2298d8b..b539881e7 100644 --- a/python/rmm/rmm/_lib/device_buffer.pyx +++ b/python/rmm/rmm/_lib/device_buffer.pyx @@ -138,6 +138,31 @@ cdef class DeviceBuffer: } return intf + def prefetch(self, device=None, stream=None): + """Prefetch buffer data to the specified device on the specified stream. + + Assumes the storage for this DeviceBuffer is CUDA managed memory + (unified memory). If it is not, this function is a no-op. + + Parameters + ---------- + device : optional + The CUDA device to which to prefetch the memory for this buffer. + Defaults to the current CUDA device. To prefetch to the CPU, pass + `~cuda.cudart.cudaCpuDeviceId` as the device. + stream : optional + CUDA stream to use for prefetching. Defaults to self.stream + """ + cdef cuda_device_id dev = (get_current_cuda_device() + if device is None + else cuda_device_id(device)) + cdef Stream strm = self.stream if stream is None else stream + with nogil: + prefetch(self.c_obj.get()[0].data(), + self.c_obj.get()[0].size(), + dev, + strm.view()) + def copy(self): """Returns a copy of DeviceBuffer. diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index 53edd96d2..05ffcf832 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -20,6 +20,7 @@ import warnings from itertools import product +import cuda.cudart as cudart import numpy as np import pytest from numba import cuda @@ -284,6 +285,32 @@ def test_rmm_device_buffer_pickle_roundtrip(hb): assert hb3 == hb +def assert_prefetched(buffer, device_id): + err, dev = cudart.cudaMemRangeGetAttribute( + 4, + cudart.cudaMemRangeAttribute.cudaMemRangeAttributeLastPrefetchLocation, + buffer.ptr, + buffer.size, + ) + assert err == cudart.cudaError_t.cudaSuccess + assert dev == device_id + + +@pytest.mark.parametrize( + "managed, pool", list(product([False, True], [False, True])) +) +def test_rmm_device_buffer_prefetch(pool, managed): + rmm.reinitialize(pool_allocator=pool, managed_memory=managed) + db = rmm.DeviceBuffer.to_device(np.zeros(256, dtype="u1")) + if managed: + assert_prefetched(db, cudart.cudaInvalidDeviceId) + db.prefetch() # just test that it doesn't throw + if managed: + err, device = cudart.cudaGetDevice() + assert err == cudart.cudaError_t.cudaSuccess + assert_prefetched(db, device) + + @pytest.mark.parametrize("stream", [cuda.default_stream(), cuda.stream()]) def test_rmm_pool_numba_stream(stream): rmm.reinitialize(pool_allocator=True) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1a14ed1fb..31410566a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2018-2023, NVIDIA CORPORATION. +# Copyright (c) 2018-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 @@ -174,12 +174,15 @@ ConfigureTest(DEVICE_BUFFER_TEST device_buffer_tests.cu) # device scalar tests ConfigureTest(DEVICE_SCALAR_TEST device_scalar_tests.cpp) -# logger tests -ConfigureTest(LOGGER_TEST logger_tests.cpp) - # uvector tests ConfigureTest(DEVICE_UVECTOR_TEST device_uvector_tests.cpp GPUS 1 PERCENT 60) +# prefetch tests +ConfigureTest(PREFETCH_TEST prefetch_tests.cpp) + +# logger tests +ConfigureTest(LOGGER_TEST logger_tests.cpp) + # arena MR tests ConfigureTest(ARENA_MR_TEST mr/device/arena_mr_tests.cpp GPUS 1 PERCENT 60) diff --git a/tests/prefetch_tests.cpp b/tests/prefetch_tests.cpp new file mode 100644 index 000000000..8873dd47f --- /dev/null +++ b/tests/prefetch_tests.cpp @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2019-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. + */ + +#include "driver_types.h" +#include "rmm/cuda_device.hpp" + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +template +struct PrefetchTest : public ::testing::Test { + rmm::cuda_stream stream{}; + std::size_t size{}; + MemoryResourceType mr{}; + + PrefetchTest() + { + std::default_random_engine generator; + + auto constexpr range_min{1000}; + auto constexpr range_max{100000}; + std::uniform_int_distribution distribution(range_min, range_max); + size = distribution(generator); + } + + // Test that the memory range was last prefetched to the specified device + void expect_prefetched(void const* ptr, std::size_t size, rmm::cuda_device_id device) + { + if constexpr (std::is_same_v) { + int prefetch_location{0}; + RMM_CUDA_TRY( + cudaMemRangeGetAttribute(&prefetch_location, + 4, + cudaMemRangeAttribute::cudaMemRangeAttributeLastPrefetchLocation, + ptr, + size)); + EXPECT_EQ(prefetch_location, device.value()); + } + } +}; + +using resources = ::testing::Types; + +TYPED_TEST_CASE(PrefetchTest, resources); + +// The following tests simply test compilation and that there are no exceptions thrown +// due to prefetching non-managed memory. + +TYPED_TEST(PrefetchTest, PointerAndSize) +{ + rmm::device_buffer buff(this->size, this->stream, &this->mr); + // verify not prefetched before prefetching + this->expect_prefetched(buff.data(), buff.size(), rmm::cuda_device_id(cudaInvalidDeviceId)); + rmm::prefetch(buff.data(), buff.size(), rmm::get_current_cuda_device(), this->stream); + // verify data range has been prefetched + this->expect_prefetched(buff.data(), buff.size(), rmm::get_current_cuda_device()); +} + +TYPED_TEST(PrefetchTest, DeviceUVector) +{ + { + rmm::device_uvector uvec(this->size, this->stream, &this->mr); + rmm::prefetch(uvec, rmm::get_current_cuda_device(), this->stream); + this->expect_prefetched(uvec.data(), uvec.size() * sizeof(int), rmm::get_current_cuda_device()); + } + + // test iterator range of part of the vector (implicitly constructs a span) + { + rmm::device_uvector uvec(this->size, this->stream, &this->mr); + rmm::prefetch({uvec.begin(), std::next(uvec.begin(), this->size / 2)}, // span + rmm::get_current_cuda_device(), + this->stream); + this->expect_prefetched( + uvec.data(), this->size / 2 * sizeof(int), rmm::get_current_cuda_device()); + } +} + +TYPED_TEST(PrefetchTest, DeviceScalar) +{ + rmm::device_scalar scalar(this->stream, &this->mr); + // TODO once we update to a version of CCCL with https://github.com/NVIDIA/cccl/pull/1836, + // remove this explicit conversion to span + rmm::prefetch(cuda::std::span{scalar.data(), scalar.size()}, + rmm::get_current_cuda_device(), + this->stream); + this->expect_prefetched(scalar.data(), sizeof(int), rmm::get_current_cuda_device()); +} From f2d079768215357953ab87227139167cd2beb95c Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Thu, 13 Jun 2024 20:13:17 +1000 Subject: [PATCH 424/675] Remove THRUST_WRAPPED_NAMESPACE and tests (#1578) Fixes #1577. Removes the no-longer-necessary duplications of tests for `THRUST_WRAPPED_NAMESPACE` Wrapping the Thrust namespace is no longer required as of CCCL 2.3 (but is still available if needed). RMM is adopting CCCL 2.5 in release 24.08. Eliminating these tests improves build time and reduces testing time by 50%. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Bradley Dice (https://github.com/bdice) - Michael Schellenberger Costa (https://github.com/miscco) URL: https://github.com/rapidsai/rmm/pull/1578 --- tests/CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 31410566a..b9285df3c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -104,11 +104,6 @@ function(ConfigureTest TEST_NAME) ConfigureTestInternal("${PTDS_TEST_NAME}" ${_RMM_TEST_UNPARSED_ARGUMENTS}) target_compile_definitions("${PTDS_TEST_NAME}" PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM) - # Test with custom thrust namespace - string(REGEX REPLACE "_TEST$" "_NAMESPACE_TEST" NS_TEST_NAME "${TEST_NAME}") - ConfigureTestInternal("${NS_TEST_NAME}" ${_RMM_TEST_UNPARSED_ARGUMENTS}) - target_compile_definitions("${NS_TEST_NAME}" PUBLIC THRUST_WRAPPED_NAMESPACE=rmm_thrust) - foreach(name ${TEST_NAME} ${PTDS_TEST_NAME} ${NS_TEST_NAME}) rapids_test_add( NAME ${name} From 1ab4920e50a07a97ec717db514ad9a3dccc9939a Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 24 Jun 2024 12:41:48 -0500 Subject: [PATCH 425/675] Avoid --find-links in wheel jobs (#1586) Contributes to https://github.com/rapidsai/build-planning/issues/69. Proposes a stricter pattern for passing a `librmm` wheel from the `wheel-build-cpp` job that produced it into the `wheel-build-python` job wanting to use it (as a build dependency of `rmm`). This change improves the likelihood that issues with the `librmm` wheels will be caught in CI. Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1586 --- ci/build_wheel_python.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index 92a0c8df2..22711fd04 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -16,7 +16,14 @@ cd "${package_dir}" RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" CPP_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp /tmp/librmm_dist) -python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check --find-links "${CPP_WHEELHOUSE}" +# ensure 'rmm' wheel builds always use the 'librmm' just built in the same CI run +# +# using env variable PIP_CONSTRAINT is necessary to ensure the constraints +# are used when created the isolated build environment +echo "librmm-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo ${CPP_WHEELHOUSE}/librmm_${RAPIDS_PY_CUDA_SUFFIX}*.whl)" > ./build-constraints.txt + +PIP_CONSTRAINT="${PWD}/build-constraints.txt" \ + python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check mkdir -p final_dist python -m auditwheel repair -w final_dist dist/* From cc53275be319487d568f8d89bc14629efef67c87 Mon Sep 17 00:00:00 2001 From: pauleonix Date: Wed, 26 Jun 2024 15:53:47 +0200 Subject: [PATCH 426/675] Update Thrust CMake Guide link in README.md (#1593) The README still linked to the archived Thrust repo instead of the new CCCL repo for the Thrust CMake Guide. Replace link. - Closes #1592 Authors: - https://github.com/pauleonix Approvers: - Lawrence Mitchell (https://github.com/wence-) URL: https://github.com/rapidsai/rmm/pull/1593 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4032f161b..3f6cceb49 100644 --- a/README.md +++ b/README.md @@ -169,7 +169,7 @@ automatically pulls in `Thrust` by means of a dependency on the `rmm::Thrust` target. By default it uses the standard configuration of Thrust. If you want to customize it, you can set the variables `THRUST_HOST_SYSTEM` and `THRUST_DEVICE_SYSTEM`; see -[Thrust's CMake documentation](https://github.com/NVIDIA/thrust/blob/main/thrust/cmake/README.md). +[Thrust's CMake documentation](https://github.com/NVIDIA/cccl/blob/main/thrust/thrust/cmake/README.md). # Using RMM in C++ From 0f608ecfb16a5b82d5c7f2cfa59f5085b041c7d9 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Thu, 27 Jun 2024 16:19:11 +1000 Subject: [PATCH 427/675] Avoid accessing statistics_resource_adaptor stack top if it is empty (#1588) Fixes #1587 Note: the only time UB could occur was in the constructor, because the ctor pushes a pair onto the stack and `pop_counters()` does not allow the last pair to be popped. Therefore, we only need to check for empty in `push_counters()`. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Mads R. B. Kristensen (https://github.com/madsbk) - Lawrence Mitchell (https://github.com/wence-) - Rong Ou (https://github.com/rongou) URL: https://github.com/rapidsai/rmm/pull/1588 --- include/rmm/mr/device/statistics_resource_adaptor.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/rmm/mr/device/statistics_resource_adaptor.hpp b/include/rmm/mr/device/statistics_resource_adaptor.hpp index c8906afd2..3ee2315f2 100644 --- a/include/rmm/mr/device/statistics_resource_adaptor.hpp +++ b/include/rmm/mr/device/statistics_resource_adaptor.hpp @@ -122,8 +122,6 @@ class statistics_resource_adaptor final : public device_memory_resource { statistics_resource_adaptor(Upstream* upstream) : upstream_{upstream} { RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); - // Initially, we push a single counter pair on the stack - push_counters(); } statistics_resource_adaptor() = delete; @@ -187,7 +185,7 @@ class statistics_resource_adaptor final : public device_memory_resource { { write_lock_t lock(mtx_); auto ret = counter_stack_.top(); - counter_stack_.push(std::make_pair(counter{}, counter{})); + counter_stack_.push({counter{}, counter{}}); return ret; } @@ -196,6 +194,7 @@ class statistics_resource_adaptor final : public device_memory_resource { * * @return top pair of counters from the stack _before_ * the pop + * @throws std::out_of_range if the counter stack has fewer than two entries. */ std::pair pop_counters() { @@ -275,7 +274,8 @@ class statistics_resource_adaptor final : public device_memory_resource { } // Stack of counter pairs - std::stack> counter_stack_; + // Invariant: the stack always contains at least one entry + std::stack> counter_stack_{{std::make_pair(counter{}, counter{})}}; std::shared_mutex mutable mtx_; // mutex for thread safe access to allocations_ Upstream* upstream_; // the upstream resource used for satisfying allocation requests }; From a727a033629c27a17d34bfc2f4c3deaff71fb1db Mon Sep 17 00:00:00 2001 From: Rong Ou Date: Mon, 1 Jul 2024 13:50:23 -0700 Subject: [PATCH 428/675] Add system memory resource (#1581) Adds a new device memory resource that uses system allocated memory. Works around some existing issues when GPU memory is oversubscribed. closes #1580 Authors: - Rong Ou (https://github.com/rongou) Approvers: - Kyle Edwards (https://github.com/KyleFromNVIDIA) - Lawrence Mitchell (https://github.com/wence-) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1581 --- .../device/sam_headroom_resource_adaptor.hpp | 156 ++++++++++++++++++ .../rmm/mr/device/system_memory_resource.hpp | 156 ++++++++++++++++++ tests/CMakeLists.txt | 3 + tests/mr/device/mr_ref_test.hpp | 10 ++ tests/mr/device/mr_ref_tests.cpp | 4 +- tests/mr/device/system_mr_tests.cu | 136 +++++++++++++++ tests/mr/device/test_utils.hpp | 5 +- 7 files changed, 468 insertions(+), 2 deletions(-) create mode 100644 include/rmm/mr/device/sam_headroom_resource_adaptor.hpp create mode 100644 include/rmm/mr/device/system_memory_resource.hpp create mode 100644 tests/mr/device/system_mr_tests.cu diff --git a/include/rmm/mr/device/sam_headroom_resource_adaptor.hpp b/include/rmm/mr/device/sam_headroom_resource_adaptor.hpp new file mode 100644 index 000000000..fc913f290 --- /dev/null +++ b/include/rmm/mr/device/sam_headroom_resource_adaptor.hpp @@ -0,0 +1,156 @@ +/* + * 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. + */ +#pragma once + +#include +#include +#include +#include +#include + +namespace rmm::mr { +/** + * @addtogroup device_resource_adaptors + * @{ + * @file + */ +/** + * @brief Resource that adapts system memory resource to allocate memory with a headroom. + * + * System allocated memory (SAM) can be migrated to the GPU, but is never migrated back the host. If + * GPU memory is over-subscribed, this can cause other CUDA calls to fail with out-of-memory errors. + * To work around this problem, when using a system memory resource, we reserve some GPU memory as + * headroom for other CUDA calls, and only conditionally set its preferred location to the GPU if + * the allocation would not eat into the headroom. + * + * Since doing this check on every allocation can be expensive, the caller may choose to use other + * allocators (e.g. `binning_memory_resource`) for small allocations, and use this allocator for + * large allocations only. + * + * @tparam Upstream Type of the upstream resource used for allocation/deallocation. Must be + * `system_memory_resource`. + */ +template +class sam_headroom_resource_adaptor final : public device_memory_resource { + public: + /** + * @brief Construct a headroom adaptor using `upstream` to satisfy allocation requests. + * + * @param upstream The resource used for allocating/deallocating device memory. Must be + * `system_memory_resource`. + * @param headroom Size of the reserved GPU memory as headroom + */ + explicit sam_headroom_resource_adaptor(Upstream* upstream, std::size_t headroom) + : upstream_{upstream}, headroom_{headroom} + { + static_assert(std::is_same_v, + "Upstream must be rmm::mr::system_memory_resource"); + } + + sam_headroom_resource_adaptor() = delete; + ~sam_headroom_resource_adaptor() override = default; + sam_headroom_resource_adaptor(sam_headroom_resource_adaptor const&) = delete; + sam_headroom_resource_adaptor(sam_headroom_resource_adaptor&&) = delete; + sam_headroom_resource_adaptor& operator=(sam_headroom_resource_adaptor const&) = delete; + sam_headroom_resource_adaptor& operator=(sam_headroom_resource_adaptor&&) = delete; + + /** + * @briefreturn{rmm::device_async_resource_ref to the upstream resource} + */ + [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + { + return upstream_; + } + + /** + * @briefreturn{Upstream* to the upstream memory resource} + */ + [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } + + private: + /** + * @brief Allocates memory of size at least \p bytes. + * + * The returned pointer will have at minimum 256 byte alignment. + * + * The stream argument is ignored. + * + * @param bytes The size of the allocation + * @param stream This argument is ignored + * @return void* Pointer to the newly allocated memory + */ + void* do_allocate(std::size_t bytes, [[maybe_unused]] cuda_stream_view stream) override + { + void* pointer = + get_upstream_resource().allocate_async(bytes, rmm::CUDA_ALLOCATION_ALIGNMENT, stream); + + auto const free = rmm::available_device_memory().first; + auto const allocatable = free > headroom_ ? free - headroom_ : 0UL; + auto const gpu_portion = + rmm::align_down(std::min(allocatable, bytes), rmm::CUDA_ALLOCATION_ALIGNMENT); + auto const cpu_portion = bytes - gpu_portion; + if (gpu_portion != 0) { + RMM_CUDA_TRY(cudaMemAdvise(pointer, + gpu_portion, + cudaMemAdviseSetPreferredLocation, + rmm::get_current_cuda_device().value())); + } + if (cpu_portion != 0) { + RMM_CUDA_TRY(cudaMemAdvise(static_cast(pointer) + gpu_portion, + cpu_portion, + cudaMemAdviseSetPreferredLocation, + cudaCpuDeviceId)); + } + + return pointer; + } + + /** + * @brief Deallocate memory pointed to by \p p. + * + * The stream argument is ignored. + * + * @param ptr Pointer to be deallocated + * @param bytes This argument is ignored + * @param stream This argument is ignored + */ + void do_deallocate(void* ptr, + [[maybe_unused]] std::size_t bytes, + [[maybe_unused]] cuda_stream_view stream) override + { + get_upstream_resource().deallocate_async(ptr, rmm::CUDA_ALLOCATION_ALIGNMENT, stream); + } + + /** + * @brief Compare this resource to another. + * + * @param other The other resource to compare to + * @return true If the two resources are equivalent + * @return false If the two resources are not equal + */ + [[nodiscard]] bool do_is_equal(device_memory_resource const& other) const noexcept override + { + if (this == &other) { return true; } + auto cast = dynamic_cast(&other); + if (cast == nullptr) { return false; } + return get_upstream_resource() == cast->get_upstream_resource() && headroom_ == cast->headroom_; + } + + Upstream* upstream_; ///< The upstream resource used for satisfying allocation requests + std::size_t headroom_; ///< Size of GPU memory reserved as headroom +}; +/** @} */ // end of group +} // namespace rmm::mr diff --git a/include/rmm/mr/device/system_memory_resource.hpp b/include/rmm/mr/device/system_memory_resource.hpp new file mode 100644 index 000000000..39d8504a9 --- /dev/null +++ b/include/rmm/mr/device/system_memory_resource.hpp @@ -0,0 +1,156 @@ +/* + * 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. + */ +#pragma once + +#include +#include +#include +#include + +namespace rmm::mr { + +namespace detail { +/** + * @brief Check if system allocated memory (SAM) is supported on the specified device. + * + * @param device_id The device to check + * @return true if SAM is supported on the device, false otherwise + */ +static bool is_system_memory_supported(cuda_device_id device_id) +{ + int pageableMemoryAccess; + RMM_CUDA_TRY(cudaDeviceGetAttribute( + &pageableMemoryAccess, cudaDevAttrPageableMemoryAccess, device_id.value())); + return pageableMemoryAccess == 1; +} +} // namespace detail + +/** + * @addtogroup device_memory_resources + * @{ + * @file + */ +/** + * @brief `device_memory_resource` derived class that uses malloc/free for allocation/deallocation. + * + * There are two flavors of hardware/software environments that support accessing system allocated + * memory (SAM) from the GPU: HMM and ATS. + * + * Heterogeneous Memory Management (HMM) is a software-based solution for PCIe-connected GPUs on + * x86 systems. Requirements: + * - NVIDIA CUDA 12.2 with the open-source r535_00 driver or newer. + * - A sufficiently recent Linux kernel: 6.1.24+, 6.2.11+, or 6.3+. + * - A GPU with one of the following supported architectures: NVIDIA Turing, NVIDIA Ampere, + * NVIDIA Ada Lovelace, NVIDIA Hopper, or newer. + * - A 64-bit x86 CPU. + * + * For more information, see + * https://developer.nvidia.com/blog/simplifying-gpu-application-development-with-heterogeneous-memory-management/. + * + * Address Translation Services (ATS) is a hardware/software solution for the Grace Hopper + * Superchip that uses the NVLink Chip-2-Chip (C2C) interconnect to provide coherent memory. For + * more information, see + * https://developer.nvidia.com/blog/nvidia-grace-hopper-superchip-architecture-in-depth/. + */ +class system_memory_resource final : public device_memory_resource { + public: + system_memory_resource() + { + RMM_EXPECTS(rmm::mr::detail::is_system_memory_supported(rmm::get_current_cuda_device()), + "System memory allocator is not supported with this hardware/software version."); + } + ~system_memory_resource() override = default; + system_memory_resource(system_memory_resource const&) = default; ///< @default_copy_constructor + system_memory_resource(system_memory_resource&&) = default; ///< @default_copy_constructor + system_memory_resource& operator=(system_memory_resource const&) = + default; ///< @default_copy_assignment{system_memory_resource} + system_memory_resource& operator=(system_memory_resource&&) = + default; ///< @default_move_assignment{system_memory_resource} + + private: + /** + * @brief Allocates memory of size at least \p bytes. + * + * The returned pointer will have at minimum 256 byte alignment. + * + * The stream argument is ignored. + * + * @param bytes The size of the allocation + * @param stream This argument is ignored + * @return void* Pointer to the newly allocated memory + */ + void* do_allocate(std::size_t bytes, [[maybe_unused]] cuda_stream_view stream) override + { + try { + return rmm::detail::aligned_host_allocate( + bytes, CUDA_ALLOCATION_ALIGNMENT, [](std::size_t size) { return ::operator new(size); }); + } catch (std::bad_alloc const& e) { + RMM_FAIL("Failed to allocate memory: " + std::string{e.what()}, rmm::out_of_memory); + } + } + + /** + * @brief Deallocate memory pointed to by \p p. + * + * The stream argument is ignored. + * + * @param ptr Pointer to be deallocated + * @param bytes The size in bytes of the allocation. This must be equal to the value of `bytes` + * that was passed to the `allocate` call that returned `ptr`. + * @param stream This argument is ignored + */ + void do_deallocate(void* ptr, + [[maybe_unused]] std::size_t bytes, + [[maybe_unused]] cuda_stream_view stream) override + { + rmm::detail::aligned_host_deallocate( + ptr, bytes, CUDA_ALLOCATION_ALIGNMENT, [](void* ptr) { ::operator delete(ptr); }); + } + + /** + * @brief Compare this resource to another. + * + * Two system_memory_resources always compare equal, because they can each deallocate memory + * allocated by the other. + * + * @param other The other resource to compare to + * @return true If the two resources are equivalent + * @return false If the two resources are not equal + */ + [[nodiscard]] bool do_is_equal(device_memory_resource const& other) const noexcept override + { + return dynamic_cast(&other) != nullptr; + } + /** + * @brief Enables the `cuda::mr::device_accessible` property + * + * This property declares that a `system_memory_resource` provides device-accessible memory + */ + friend void get_property(system_memory_resource const&, cuda::mr::device_accessible) noexcept {} + + /** + * @brief Enables the `cuda::mr::host_accessible` property + * + * This property declares that a `system_memory_resource` provides host-accessible memory + */ + friend void get_property(system_memory_resource const&, cuda::mr::host_accessible) noexcept {} +}; + +// static property checks +static_assert(cuda::mr::async_resource_with); +static_assert(cuda::mr::async_resource_with); +/** @} */ // end of group +} // namespace rmm::mr diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b9285df3c..de0dc363b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -187,6 +187,9 @@ ConfigureTest(BINNING_MR_TEST mr/device/binning_mr_tests.cpp) # callback memory resource tests ConfigureTest(CALLBACK_MR_TEST mr/device/callback_mr_tests.cpp) +# system memory resource tests +ConfigureTest(SYSTEM_MR_TEST mr/device/system_mr_tests.cu) + # container multidevice tests ConfigureTest(CONTAINER_MULTIDEVICE_TEST container_multidevice_tests.cu) diff --git a/tests/mr/device/mr_ref_test.hpp b/tests/mr/device/mr_ref_test.hpp index a8a6226f1..50f35911b 100644 --- a/tests/mr/device/mr_ref_test.hpp +++ b/tests/mr/device/mr_ref_test.hpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -381,6 +382,15 @@ inline auto make_cuda_async() inline auto make_managed() { return std::make_shared(); } +inline auto make_system() +{ + if (rmm::mr::detail::is_system_memory_supported(rmm::get_current_cuda_device())) { + return std::make_shared(); + } else { + return std::shared_ptr{nullptr}; + } +} + inline auto make_pool() { return rmm::mr::make_owning_wrapper( diff --git a/tests/mr/device/mr_ref_tests.cpp b/tests/mr/device/mr_ref_tests.cpp index c7c37d4cc..f4d4c7a99 100644 --- a/tests/mr/device/mr_ref_tests.cpp +++ b/tests/mr/device/mr_ref_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, NVIDIA CORPORATION. + * 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. @@ -32,6 +32,7 @@ INSTANTIATE_TEST_SUITE_P(ResourceTests, mr_factory{"CUDA_Async", &make_cuda_async}, #endif mr_factory{"Managed", &make_managed}, + mr_factory{"System", &make_system}, mr_factory{"Pool", &make_pool}, mr_factory{"HostPinnedPool", &make_host_pinned_pool}, mr_factory{"Arena", &make_arena}, @@ -47,6 +48,7 @@ INSTANTIATE_TEST_SUITE_P(ResourceAllocationTests, mr_factory{"CUDA_Async", &make_cuda_async}, #endif mr_factory{"Managed", &make_managed}, + mr_factory{"System", &make_system}, mr_factory{"Pool", &make_pool}, mr_factory{"HostPinnedPool", &make_host_pinned_pool}, mr_factory{"Arena", &make_arena}, diff --git a/tests/mr/device/system_mr_tests.cu b/tests/mr/device/system_mr_tests.cu new file mode 100644 index 000000000..079afeb14 --- /dev/null +++ b/tests/mr/device/system_mr_tests.cu @@ -0,0 +1,136 @@ +/* + * 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. + */ + +#include "../../byte_literals.hpp" + +#include +#include +#include +#include + +#include + +namespace rmm::test { +namespace { + +std::size_t constexpr size_mb{1_MiB}; +std::size_t constexpr size_gb{1_GiB}; + +void touch_on_cpu(void* ptr, std::size_t size) +{ + auto* data = static_cast(ptr); + for (std::size_t i = 0; i < size; ++i) { + data[i] = static_cast(i); + } +} + +__global__ void touch_memory_kernel(char* data, std::size_t size) +{ + auto const tid = blockIdx.x * blockDim.x + threadIdx.x; + if (tid < size) { data[tid] = static_cast(tid); } +} + +void touch_on_gpu(void* ptr, std::size_t size) +{ + dim3 blockSize(256); + dim3 gridSize((size + blockSize.x - 1) / blockSize.x); + touch_memory_kernel<<>>(static_cast(ptr), size); + cudaDeviceSynchronize(); +} + +using system_mr = rmm::mr::system_memory_resource; +static_assert(cuda::mr::resource_with); +static_assert(cuda::mr::async_resource_with); +using headroom_adaptor = rmm::mr::sam_headroom_resource_adaptor; +static_assert(cuda::mr::resource_with); +static_assert(cuda::mr::async_resource_with); + +class SystemMRTest : public ::testing::Test { + protected: + void SetUp() override + { + if (!rmm::mr::detail::is_system_memory_supported(rmm::get_current_cuda_device())) { + GTEST_SKIP() << "Skipping tests since system memory allocator not supported with this " + "hardware/software version"; + } + } +}; + +TEST(SystemMRSimpleTest, ThrowIfNotSupported) +{ + auto construct_mr = []() { system_mr mr; }; + if (rmm::mr::detail::is_system_memory_supported(rmm::get_current_cuda_device())) { + EXPECT_NO_THROW(construct_mr()); + } else { + EXPECT_THROW(construct_mr(), rmm::logic_error); + } +} + +TEST(SAMHeadroomAdaptorTest, ThrowIfNotSupported) +{ + auto construct_mr = []() { + system_mr mr; + headroom_adaptor adaptor{&mr, 0}; + }; + if (rmm::mr::detail::is_system_memory_supported(rmm::get_current_cuda_device())) { + EXPECT_NO_THROW(construct_mr()); + } else { + EXPECT_THROW(construct_mr(), rmm::logic_error); + } +} + +TEST_F(SystemMRTest, FirstTouchOnCPU) +{ + auto const free = rmm::available_device_memory().first; + system_mr mr; + void* ptr = mr.allocate(size_mb); + touch_on_cpu(ptr, size_mb); + auto const free2 = rmm::available_device_memory().first; + EXPECT_EQ(free, free2); + mr.deallocate(ptr, size_mb); +} + +TEST_F(SystemMRTest, FirstTouchOnGPU) +{ + auto const free = rmm::available_device_memory().first; + system_mr mr; + void* ptr = mr.allocate(size_mb); + touch_on_gpu(ptr, size_mb); + auto const free2 = rmm::available_device_memory().first; + EXPECT_LT(free2, free); + mr.deallocate(ptr, size_mb); +} + +TEST_F(SystemMRTest, AdaptorReserveAllFreeMemory) +{ + auto const free = rmm::available_device_memory().first; + system_mr mr; + // All the free GPU memory is set as headroom, so allocation is only on the CPU. + headroom_adaptor adaptor{&mr, free + size_gb}; + void* ptr = adaptor.allocate(size_mb); + touch_on_cpu(ptr, size_mb); + adaptor.deallocate(ptr, size_mb); +} + +TEST_F(SystemMRTest, AdaptorDifferentParametersUnequal) +{ + system_mr mr; + headroom_adaptor adaptor1{&mr, size_mb}; + headroom_adaptor adaptor2{&mr, size_gb}; + EXPECT_FALSE(adaptor1.is_equal(adaptor2)); +} +} // namespace +} // namespace rmm::test diff --git a/tests/mr/device/test_utils.hpp b/tests/mr/device/test_utils.hpp index 932a72a7e..2b9513793 100644 --- a/tests/mr/device/test_utils.hpp +++ b/tests/mr/device/test_utils.hpp @@ -17,6 +17,7 @@ #pragma once #include +#include #include @@ -31,7 +32,9 @@ inline bool is_device_accessible_memory(void* ptr) cudaPointerAttributes attributes{}; if (cudaSuccess != cudaPointerGetAttributes(&attributes, ptr)) { return false; } return (attributes.type == cudaMemoryTypeDevice) or (attributes.type == cudaMemoryTypeManaged) or - ((attributes.type == cudaMemoryTypeHost) and (attributes.devicePointer != nullptr)); + ((attributes.type == cudaMemoryTypeHost) and (attributes.devicePointer != nullptr)) or + ((attributes.type == cudaMemoryTypeUnregistered) and + (rmm::mr::detail::is_system_memory_supported(rmm::get_current_cuda_device()))); } inline bool is_host_memory(void* ptr) From d71f9e1eda044842273f48fbf8887ba880322257 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Tue, 2 Jul 2024 11:04:14 +1000 Subject: [PATCH 429/675] Refactor mr_ref_tests to not depend on MR base classes (#1589) Fixes #1444 Refactors mr_ref_tests.hpp and the .cpp files that include it to use a hierarchy of factory classes in which the base class contains a `resource_ref` and the derived classes are templated on the actual resource type and own the MR under test to maintain its lifetime. This way the tests can still be value parameterized (by name) and the test machinery can be type erased. In the future, if CCCL adds an `any_resource` type-erased owning resource container, we can use that to simplify this machinery. Note that until #1598 merges, this PR necessarily disables (comments out) tests of `set_current_device_resource()`. This is because the test only has a resource_ref, so it can't `set_current_device_resource(ref).` #1598 adds `set_current_device_resource_ref()` which reenables this testing. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1589 --- .../mr/device/mr_ref_multithreaded_tests.cpp | 25 ++-- tests/mr/device/mr_ref_test.hpp | 124 ++++++++++++------ tests/mr/device/mr_ref_tests.cpp | 43 +++--- tests/mr/device/thrust_allocator_tests.cu | 19 +-- tests/mr/host/mr_ref_tests.cpp | 1 - 5 files changed, 131 insertions(+), 81 deletions(-) diff --git a/tests/mr/device/mr_ref_multithreaded_tests.cpp b/tests/mr/device/mr_ref_multithreaded_tests.cpp index d0d11ccbe..3ba32445f 100644 --- a/tests/mr/device/mr_ref_multithreaded_tests.cpp +++ b/tests/mr/device/mr_ref_multithreaded_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, NVIDIA CORPORATION. + * 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. @@ -37,15 +37,15 @@ struct mr_ref_test_mt : public mr_ref_test {}; INSTANTIATE_TEST_CASE_P(MultiThreadResourceTests, mr_ref_test_mt, - ::testing::Values(mr_factory{"CUDA", &make_cuda}, + ::testing::Values("CUDA", #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT - mr_factory{"CUDA_Async", &make_cuda_async}, + "CUDA_Async", #endif - mr_factory{"Managed", &make_managed}, - mr_factory{"Pool", &make_pool}, - mr_factory{"Arena", &make_arena}, - mr_factory{"Binning", &make_binning}), - [](auto const& info) { return info.param.name; }); + "Managed", + "Pool", + "Arena", + "Binning"), + [](auto const& info) { return info.param; }); template void spawn_n(std::size_t num_threads, Task task, Arguments&&... args) @@ -86,7 +86,8 @@ TEST(DefaultTest, GetCurrentDeviceResource_mt) }); } -TEST_P(mr_ref_test_mt, SetCurrentDeviceResource_mt) +// Disable until we support resource_ref with set_current_device_resource +/*TEST_P(mr_ref_test_mt, SetCurrentDeviceResource_mt) { // single thread changes default resource, then multiple threads use it @@ -101,9 +102,9 @@ TEST_P(mr_ref_test_mt, SetCurrentDeviceResource_mt) // setting default resource w/ nullptr should reset to initial rmm::mr::set_current_device_resource(nullptr); EXPECT_TRUE(old->is_equal(*rmm::mr::get_current_device_resource())); -} +}*/ -TEST_P(mr_ref_test_mt, SetCurrentDeviceResourcePerThread_mt) +/*TEST_P(mr_ref_test_mt, SetCurrentDeviceResourcePerThread_mt) { int num_devices{}; RMM_CUDA_TRY(cudaGetDeviceCount(&num_devices)); @@ -135,7 +136,7 @@ TEST_P(mr_ref_test_mt, SetCurrentDeviceResourcePerThread_mt) for (auto& thread : threads) { thread.join(); } -} +}*/ TEST_P(mr_ref_test_mt, Allocate) { spawn(test_various_allocations, this->ref); } diff --git a/tests/mr/device/mr_ref_test.hpp b/tests/mr/device/mr_ref_test.hpp index 50f35911b..df0045d2b 100644 --- a/tests/mr/device/mr_ref_test.hpp +++ b/tests/mr/device/mr_ref_test.hpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -42,12 +41,11 @@ #include #include -#include -#include #include +#include #include -using resource_ref = cuda::mr::resource_ref; +using resource_ref = rmm::device_async_resource_ref; namespace rmm::test { @@ -333,40 +331,6 @@ inline void test_mixed_random_async_allocation_free(rmm::device_async_resource_r EXPECT_EQ(allocations.size(), active_allocations); } -using MRFactoryFunc = std::function()>; - -/// Encapsulates a `device_memory_resource` factory function and associated name -struct mr_factory { - mr_factory(std::string name, MRFactoryFunc factory) - : name{std::move(name)}, factory{std::move(factory)} - { - } - - std::string name; ///< Name to associate with tests that use this factory - MRFactoryFunc factory; ///< Factory function that returns shared_ptr to `device_memory_resource` - ///< instance to use in test -}; - -/// Test fixture class value-parameterized on different `mr_factory`s -struct mr_ref_test : public ::testing::TestWithParam { - void SetUp() override - { - auto factory = GetParam().factory; - mr = factory(); - if (mr == nullptr) { - GTEST_SKIP() << "Skipping tests since the memory resource is not supported with this CUDA " - << "driver/runtime version"; - } - ref = rmm::device_async_resource_ref{*mr}; - } - - std::shared_ptr mr; ///< Pointer to resource to use in tests - rmm::device_async_resource_ref ref{*mr}; - rmm::cuda_stream stream{}; -}; - -struct mr_ref_allocation_test : public mr_ref_test {}; - /// MR factory functions inline auto make_cuda() { return std::make_shared(); } @@ -426,4 +390,88 @@ inline auto make_binning() return mr; } +struct mr_factory_base { + std::string name{}; ///< Name to associate with tests that use this factory + resource_ref mr{rmm::mr::get_current_device_resource()}; + bool skip_test{false}; +}; + +/// Encapsulates a memory resource factory function and associated name +template +struct mr_factory : mr_factory_base { + mr_factory(std::string_view name, MRFactoryFunc factory) + : mr_factory_base{std::string{name}}, owned_mr{std::move(factory())} + { + if (owned_mr == nullptr) { skip_test = true; } + + mr = *owned_mr; + } + + // Owned resource to use in tests, type determined by the type of factory function + std::invoke_result_t owned_mr; +}; + +using cuda_mr = rmm::mr::cuda_memory_resource; +using pinned_mr = rmm::mr::pinned_host_memory_resource; +using cuda_async_mr = rmm::mr::cuda_async_memory_resource; +using managed_mr = rmm::mr::managed_memory_resource; +using system_mr = rmm::mr::system_memory_resource; +using pool_mr = rmm::mr::pool_memory_resource; +using pinned_pool_mr = rmm::mr::pool_memory_resource; +using arena_mr = rmm::mr::arena_memory_resource; +using fixed_mr = rmm::mr::fixed_size_memory_resource; +using binning_mr = rmm::mr::binning_memory_resource; + +inline std::shared_ptr mr_factory_dispatch(std::string name) +{ + if (name == "CUDA") { + return std::make_shared>("CUDA", make_cuda); + } else if (name == "Host_Pinned") { + return std::make_shared>("Host_Pinned", + make_host_pinned); + } else if (name == "CUDA_Async") { + return std::make_shared>("CUDA_Async", + make_cuda_async); + } else if (name == "Managed") { + return std::make_shared>("Managed", + make_managed); + } else if (name == "System") { + return std::make_shared>("System", make_system); + } else if (name == "Pool") { + return std::make_shared>("Pool", make_pool); + } else if (name == "Host_Pinned_Pool") { + return std::make_shared>( + "Host_Pinned_Pool", make_host_pinned_pool); + } else if (name == "Arena") { + return std::make_shared>("Arena", make_arena); + } else if (name == "Binning") { + return std::make_shared>("Binning", + make_binning); + } else if (name == "Fixed_Size") { + return std::make_shared>("Fixed_Size", + make_fixed_size); + } else { + return std::make_shared>("Error", make_cuda); + } +} + +/// Test fixture class value-parameterized on different `mr_factory`s +struct mr_ref_test : public ::testing::TestWithParam { + void SetUp() override + { + factory_obj = mr_factory_dispatch(GetParam()); + if (factory_obj->skip_test) { + GTEST_SKIP() << "Skipping tests since the memory resource is not supported with this CUDA " + << "driver/runtime version"; + } + ref = factory_obj->mr; + } + + std::shared_ptr factory_obj{}; + resource_ref ref{rmm::mr::get_current_device_resource()}; + rmm::cuda_stream stream{}; +}; + +struct mr_ref_allocation_test : public mr_ref_test {}; + } // namespace rmm::test diff --git a/tests/mr/device/mr_ref_tests.cpp b/tests/mr/device/mr_ref_tests.cpp index f4d4c7a99..d94817bef 100644 --- a/tests/mr/device/mr_ref_tests.cpp +++ b/tests/mr/device/mr_ref_tests.cpp @@ -27,33 +27,33 @@ namespace { INSTANTIATE_TEST_SUITE_P(ResourceTests, mr_ref_test, - ::testing::Values(mr_factory{"CUDA", &make_cuda}, + ::testing::Values("CUDA", #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT - mr_factory{"CUDA_Async", &make_cuda_async}, + "CUDA_Async", #endif - mr_factory{"Managed", &make_managed}, - mr_factory{"System", &make_system}, - mr_factory{"Pool", &make_pool}, - mr_factory{"HostPinnedPool", &make_host_pinned_pool}, - mr_factory{"Arena", &make_arena}, - mr_factory{"Binning", &make_binning}, - mr_factory{"Fixed_Size", &make_fixed_size}), - [](auto const& info) { return info.param.name; }); + "Managed", + "System", + "Pool", + "HostPinnedPool", + "Arena", + "Binning", + "Fixed_Size"), + [](auto const& info) { return info.param; }); // Leave out fixed-size MR here because it can't handle the dynamic allocation sizes INSTANTIATE_TEST_SUITE_P(ResourceAllocationTests, mr_ref_allocation_test, - ::testing::Values(mr_factory{"CUDA", &make_cuda}, + ::testing::Values("CUDA", #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT - mr_factory{"CUDA_Async", &make_cuda_async}, + "CUDA_Async", #endif - mr_factory{"Managed", &make_managed}, - mr_factory{"System", &make_system}, - mr_factory{"Pool", &make_pool}, - mr_factory{"HostPinnedPool", &make_host_pinned_pool}, - mr_factory{"Arena", &make_arena}, - mr_factory{"Binning", &make_binning}), - [](auto const& info) { return info.param.name; }); + "Managed", + "System" + "Pool", + "HostPinnedPool", + "Arena", + "Binning"), + [](auto const& info) { return info.param; }); TEST(DefaultTest, CurrentDeviceResourceIsCUDA) { @@ -70,7 +70,8 @@ TEST(DefaultTest, GetCurrentDeviceResource) EXPECT_TRUE(mr->is_equal(rmm::mr::cuda_memory_resource{})); } -TEST_P(mr_ref_test, SetCurrentDeviceResource) +// Disable until we support resource_ref with set_current_device_resource +/*TEST_P(mr_ref_test, SetCurrentDeviceResource) { rmm::mr::device_memory_resource* old{}; old = rmm::mr::set_current_device_resource(this->mr.get()); @@ -87,7 +88,7 @@ TEST_P(mr_ref_test, SetCurrentDeviceResource) // setting to `nullptr` should reset to initial cuda resource rmm::mr::set_current_device_resource(nullptr); EXPECT_TRUE(rmm::mr::get_current_device_resource()->is_equal(rmm::mr::cuda_memory_resource{})); -} +}*/ TEST_P(mr_ref_test, SelfEquality) { EXPECT_TRUE(this->ref == this->ref); } diff --git a/tests/mr/device/thrust_allocator_tests.cu b/tests/mr/device/thrust_allocator_tests.cu index e855d1036..91ae396ed 100644 --- a/tests/mr/device/thrust_allocator_tests.cu +++ b/tests/mr/device/thrust_allocator_tests.cu @@ -36,7 +36,8 @@ namespace { struct allocator_test : public mr_ref_test {}; -TEST_P(allocator_test, first) +// Disable until we support resource_ref with set_current_device_resource +/*TEST_P(allocator_test, first) { rmm::mr::set_current_device_resource(this->mr.get()); auto const num_ints{100}; @@ -51,7 +52,7 @@ TEST_P(allocator_test, defaults) EXPECT_EQ(allocator.stream(), rmm::cuda_stream_default); EXPECT_EQ(allocator.get_upstream_resource(), rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}); -} +}*/ TEST_P(allocator_test, multi_device) { @@ -70,15 +71,15 @@ TEST_P(allocator_test, multi_device) INSTANTIATE_TEST_CASE_P(ThrustAllocatorTests, allocator_test, - ::testing::Values(mr_factory{"CUDA", &make_cuda}, + ::testing::Values("CUDA", #ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT - mr_factory{"CUDA_Async", &make_cuda_async}, + "CUDA_Async", #endif - mr_factory{"Managed", &make_managed}, - mr_factory{"Pool", &make_pool}, - mr_factory{"Arena", &make_arena}, - mr_factory{"Binning", &make_binning}), - [](auto const& info) { return info.param.name; }); + "Managed", + "Pool", + "Arena", + "Binning"), + [](auto const& info) { return info.param; }); } // namespace } // namespace rmm::test diff --git a/tests/mr/host/mr_ref_tests.cpp b/tests/mr/host/mr_ref_tests.cpp index 3755a8a29..8445ab1f5 100644 --- a/tests/mr/host/mr_ref_tests.cpp +++ b/tests/mr/host/mr_ref_tests.cpp @@ -17,7 +17,6 @@ #include "../../byte_literals.hpp" #include -#include #include #include #include From 53830f74d1697b83617005d8093de41f8e6aa3bb Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 2 Jul 2024 13:11:52 -0400 Subject: [PATCH 430/675] Use verify-alpha-spec hook (#1601) Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1601 --- .pre-commit-config.yaml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4155cdc19..835337790 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,11 +5,6 @@ repos: hooks: - id: trailing-whitespace - id: end-of-file-fixer - - repo: https://github.com/rapidsai/dependency-file-generator - rev: v1.13.11 - hooks: - - id: rapids-dependency-file-generator - args: ["--clean"] - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: @@ -82,9 +77,15 @@ repos: - id: ruff files: python/.*$ - repo: https://github.com/rapidsai/pre-commit-hooks - rev: v0.0.3 + rev: v0.2.0 hooks: - id: verify-copyright + - id: verify-alpha-spec + - repo: https://github.com/rapidsai/dependency-file-generator + rev: v1.13.11 + hooks: + - id: rapids-dependency-file-generator + args: ["--clean"] default_language_version: python: python3 From b8b67f8ceb52b50bf1c16d4f3305b7885de5c3ea Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 5 Jul 2024 17:00:30 -0500 Subject: [PATCH 431/675] skip CMake 3.30.0 (#1603) Contributes to https://github.com/rapidsai/build-planning/issues/80 Adds constraints to avoid pulling in CMake 3.30.0, for the reasons described in that issue. Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1603 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-122_arch-x86_64.yaml | 2 +- conda/recipes/librmm/conda_build_config.yaml | 2 +- conda/recipes/rmm/conda_build_config.yaml | 2 +- dependencies.yaml | 2 +- python/librmm/pyproject.toml | 2 +- python/rmm/pyproject.toml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 7c79d41b7..f6f179f77 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -9,7 +9,7 @@ dependencies: - c-compiler - clang-tools==16.0.6 - clang==16.0.6 -- cmake>=3.26.4 +- cmake>=3.26.4,!=3.30.0 - cuda-python>=11.7.1,<12.0a0 - cuda-version=11.8 - cudatoolkit diff --git a/conda/environments/all_cuda-122_arch-x86_64.yaml b/conda/environments/all_cuda-122_arch-x86_64.yaml index efce3b84c..42cb364dc 100644 --- a/conda/environments/all_cuda-122_arch-x86_64.yaml +++ b/conda/environments/all_cuda-122_arch-x86_64.yaml @@ -9,7 +9,7 @@ dependencies: - c-compiler - clang-tools==16.0.6 - clang==16.0.6 -- cmake>=3.26.4 +- cmake>=3.26.4,!=3.30.0 - cuda-nvcc - cuda-python>=12.0,<13.0a0 - cuda-version=12.2 diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index 1740bfe2f..6afd32c32 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -11,7 +11,7 @@ cuda11_compiler: - nvcc cmake_version: - - ">=3.26.4" + - ">=3.26.4,!=3.30.0" fmt_version: - ">=10.1.1,<11" diff --git a/conda/recipes/rmm/conda_build_config.yaml b/conda/recipes/rmm/conda_build_config.yaml index e21871634..68947bade 100644 --- a/conda/recipes/rmm/conda_build_config.yaml +++ b/conda/recipes/rmm/conda_build_config.yaml @@ -16,4 +16,4 @@ c_stdlib_version: - "2.17" cmake_version: - - ">=3.26.4" + - ">=3.26.4,!=3.30.0" diff --git a/dependencies.yaml b/dependencies.yaml index ee443184c..834d2ba6e 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -105,7 +105,7 @@ dependencies: common: - output_types: [conda, requirements, pyproject] packages: - - &cmake_ver cmake>=3.26.4 + - &cmake_ver cmake>=3.26.4,!=3.30.0 - ninja - output_types: conda packages: diff --git a/python/librmm/pyproject.toml b/python/librmm/pyproject.toml index 14a591293..1b4042217 100644 --- a/python/librmm/pyproject.toml +++ b/python/librmm/pyproject.toml @@ -47,7 +47,7 @@ librmm = "librmm" build-backend = "scikit_build_core.build" dependencies-file = "../../dependencies.yaml" requires = [ - "cmake>=3.26.4", + "cmake>=3.26.4,!=3.30.0", "ninja", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 7de3a3b42..9cbabda61 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -125,7 +125,7 @@ regex = "(?P.*)" build-backend = "scikit_build_core.build" dependencies-file = "../../dependencies.yaml" requires = [ - "cmake>=3.26.4", + "cmake>=3.26.4,!=3.30.0", "cuda-python>=11.7.1,<12.0a0", "cython>=3.0.0", "librmm==24.8.*,>=0.0.0a0", From 429960808c3bccea2e7e1da177439546481bb684 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 15 Jul 2024 14:31:07 -0600 Subject: [PATCH 432/675] Revert "Remove HTML builds of librmm (#1415)" (#1604) This reverts commit 77b55003b5ae598b7c26553ff39c5dde369c73d8. See: https://github.com/rapidsai/docs/pull/517#pullrequestreview-2105119364 We need to have librmm docs published in order to enable cross-linking of librmm from libcudf docs. From discussion with @raydouglass, we don't need to link to them publicly on docs.rapids.ai, as they are already included in the rmm docs (both C++ and Python). The librmm docs will just be used to cross-reference from libcudf docs. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Ray Douglass (https://github.com/raydouglass) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1604 --- ci/build_docs.sh | 2 ++ doxygen/Doxyfile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 307f48e44..970417c1d 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -33,6 +33,8 @@ export RAPIDS_DOCS_DIR="$(mktemp -d)" rapids-logger "Build CPP docs" pushd doxygen doxygen Doxyfile +mkdir -p "${RAPIDS_DOCS_DIR}/librmm/html" +mv html/* "${RAPIDS_DOCS_DIR}/librmm/html" popd rapids-logger "Build Python docs" diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index a5c183236..434e92e05 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -1135,7 +1135,7 @@ IGNORE_PREFIX = # If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output # The default value is: YES. -GENERATE_HTML = NO +GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of From 2cafc81e34882cd05bf076c7a03a39a7f4ee1d58 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 16 Jul 2024 11:54:24 -0400 Subject: [PATCH 433/675] Build and test with CUDA 12.5.1 (#1607) This PR updates the latest CUDA build/test version 12.2.2 to 12.5.1. Contributes to https://github.com/rapidsai/build-planning/issues/73 Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) - https://github.com/jakirkham Approvers: - https://github.com/jakirkham - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1607 --- .../cuda12.2-conda/devcontainer.json | 8 +++---- .devcontainer/cuda12.2-pip/devcontainer.json | 10 ++++---- .github/workflows/build.yaml | 16 ++++++------- .github/workflows/pr.yaml | 24 +++++++++---------- .github/workflows/test.yaml | 6 ++--- ..._64.yaml => all_cuda-125_arch-x86_64.yaml} | 4 ++-- dependencies.yaml | 6 ++++- 7 files changed, 39 insertions(+), 35 deletions(-) rename conda/environments/{all_cuda-122_arch-x86_64.yaml => all_cuda-125_arch-x86_64.yaml} (94%) diff --git a/.devcontainer/cuda12.2-conda/devcontainer.json b/.devcontainer/cuda12.2-conda/devcontainer.json index 6e694f86f..ed0d28f20 100644 --- a/.devcontainer/cuda12.2-conda/devcontainer.json +++ b/.devcontainer/cuda12.2-conda/devcontainer.json @@ -3,7 +3,7 @@ "context": "${localWorkspaceFolder}/.devcontainer", "dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile", "args": { - "CUDA": "12.2", + "CUDA": "12.5", "PYTHON_PACKAGE_MANAGER": "conda", "BASE": "rapidsai/devcontainers:24.08-cpp-mambaforge-ubuntu22.04" } @@ -11,7 +11,7 @@ "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.08-cuda12.2-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.08-cuda12.5-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { @@ -20,7 +20,7 @@ "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" ], - "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config,conda/pkgs,conda/${localWorkspaceFolderBasename}-cuda12.2-envs}"], + "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config,conda/pkgs,conda/${localWorkspaceFolderBasename}-cuda12.5-envs}"], "postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"], "workspaceFolder": "/home/coder", "workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent", @@ -29,7 +29,7 @@ "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.conda/pkgs,target=/home/coder/.conda/pkgs,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.conda/${localWorkspaceFolderBasename}-cuda12.2-envs,target=/home/coder/.conda/envs,type=bind,consistency=consistent" + "source=${localWorkspaceFolder}/../.conda/${localWorkspaceFolderBasename}-cuda12.5-envs,target=/home/coder/.conda/envs,type=bind,consistency=consistent" ], "customizations": { "vscode": { diff --git a/.devcontainer/cuda12.2-pip/devcontainer.json b/.devcontainer/cuda12.2-pip/devcontainer.json index 5b5bc4f6a..9648fe1fd 100644 --- a/.devcontainer/cuda12.2-pip/devcontainer.json +++ b/.devcontainer/cuda12.2-pip/devcontainer.json @@ -3,15 +3,15 @@ "context": "${localWorkspaceFolder}/.devcontainer", "dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile", "args": { - "CUDA": "12.2", + "CUDA": "12.5", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:24.08-cpp-cuda12.2-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.08-cpp-cuda12.5-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.08-cuda12.2-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.08-cuda12.5-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { @@ -20,7 +20,7 @@ "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" ], - "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config/pip,local/share/${localWorkspaceFolderBasename}-cuda12.2-venvs}"], + "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config/pip,local/share/${localWorkspaceFolderBasename}-cuda12.5-venvs}"], "postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"], "workspaceFolder": "/home/coder", "workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent", @@ -28,7 +28,7 @@ "source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.local/share/${localWorkspaceFolderBasename}-cuda12.2-venvs,target=/home/coder/.local/share/venvs,type=bind,consistency=consistent" + "source=${localWorkspaceFolder}/../.local/share/${localWorkspaceFolderBasename}-cuda12.5-venvs,target=/home/coder/.local/share/venvs,type=bind,consistency=consistent" ], "customizations": { "vscode": { diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5ada2cedd..409e32bb6 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@cuda-12.5.1 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@cuda-12.5.1 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@cuda-12.5.1 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@cuda-12.5.1 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build-cpp: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.5.1 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -79,7 +79,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.5.1 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -89,7 +89,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@cuda-12.5.1 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -100,7 +100,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@cuda-12.5.1 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 68562b467..c5ae9bce2 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -23,40 +23,40 @@ jobs: - wheel-tests - devcontainer secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@cuda-12.5.1 checks: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@cuda-12.5.1 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@cuda-12.5.1 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-12.5.1 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@cuda-12.5.1 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@cuda-12.5.1 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@cuda-12.5.1 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -66,7 +66,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.5.1 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -74,23 +74,23 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.5.1 with: build_type: pull-request script: ci/build_wheel_python.sh wheel-tests: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@cuda-12.5.1 with: build_type: pull-request script: ci/test_wheel.sh devcontainer: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@cuda-12.5.1 with: arch: '["amd64"]' - cuda: '["12.2"]' + cuda: '["12.5"]' build_command: | sccache -z; build-all -DBUILD_BENCHMARKS=ON --verbose; diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 42cdcb282..145afb1ac 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-12.5.1 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@cuda-12.5.1 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@cuda-12.5.1 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/conda/environments/all_cuda-122_arch-x86_64.yaml b/conda/environments/all_cuda-125_arch-x86_64.yaml similarity index 94% rename from conda/environments/all_cuda-122_arch-x86_64.yaml rename to conda/environments/all_cuda-125_arch-x86_64.yaml index 42cb364dc..feadd4835 100644 --- a/conda/environments/all_cuda-122_arch-x86_64.yaml +++ b/conda/environments/all_cuda-125_arch-x86_64.yaml @@ -12,7 +12,7 @@ dependencies: - cmake>=3.26.4,!=3.30.0 - cuda-nvcc - cuda-python>=12.0,<13.0a0 -- cuda-version=12.2 +- cuda-version=12.5 - cxx-compiler - cython>=3.0.0 - doxygen=1.9.1 @@ -40,4 +40,4 @@ dependencies: - sphinx-markdown-tables - sphinx_rtd_theme - sysroot_linux-64==2.17 -name: all_cuda-122_arch-x86_64 +name: all_cuda-125_arch-x86_64 diff --git a/dependencies.yaml b/dependencies.yaml index 834d2ba6e..82847c89c 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -3,7 +3,7 @@ files: all: output: conda matrix: - cuda: ["11.8", "12.2"] + cuda: ["11.8", "12.5"] arch: [x86_64] includes: - build @@ -213,6 +213,10 @@ dependencies: cuda: "12.2" packages: - cuda-version=12.2 + - matrix: + cuda: "12.5" + packages: + - cuda-version=12.5 cuda: specific: - output_types: conda From f91ca6f22195868e6493e38975f5c07029bd1977 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 16 Jul 2024 11:44:25 -0700 Subject: [PATCH 434/675] add rapids-build-backend to docs (#1614) Fixes #1609 Follow-up to #1502 Adds `rapids-build-backend` to the documentation on how to build `rmm` from source. Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Kyle Edwards (https://github.com/KyleFromNVIDIA) - Jiaming Yuan (https://github.com/trivialfis) URL: https://github.com/rapidsai/rmm/pull/1614 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3f6cceb49..34545c27e 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ GPU Support: may work on earlier architectures. Python requirements: +* `rapids-build-backend` (available from PyPI or the `rapidsai` conda channel) * `scikit-build-core` * `cuda-python` * `cython` From 65deae534c56890b159b56be31889f4eb9403406 Mon Sep 17 00:00:00 2001 From: jakirkham Date: Wed, 17 Jul 2024 09:53:36 -0700 Subject: [PATCH 435/675] Rename `.devcontainer`s for CUDA 12.5 (#1615) Follow up to PR: https://github.com/rapidsai/rmm/pull/1607 Partially addresses issue: https://github.com/rapidsai/build-planning/issues/73 Renames the `.devcontainer`s for CUDA 12.5 Authors: - https://github.com/jakirkham Approvers: - James Lamb (https://github.com/jameslamb) - Paul Taylor (https://github.com/trxcllnt) URL: https://github.com/rapidsai/rmm/pull/1615 --- .../{cuda12.2-conda => cuda12.5-conda}/devcontainer.json | 0 .devcontainer/{cuda12.2-pip => cuda12.5-pip}/devcontainer.json | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .devcontainer/{cuda12.2-conda => cuda12.5-conda}/devcontainer.json (100%) rename .devcontainer/{cuda12.2-pip => cuda12.5-pip}/devcontainer.json (100%) diff --git a/.devcontainer/cuda12.2-conda/devcontainer.json b/.devcontainer/cuda12.5-conda/devcontainer.json similarity index 100% rename from .devcontainer/cuda12.2-conda/devcontainer.json rename to .devcontainer/cuda12.5-conda/devcontainer.json diff --git a/.devcontainer/cuda12.2-pip/devcontainer.json b/.devcontainer/cuda12.5-pip/devcontainer.json similarity index 100% rename from .devcontainer/cuda12.2-pip/devcontainer.json rename to .devcontainer/cuda12.5-pip/devcontainer.json From 47e4882411071ef56a7111743537e8eb5508c473 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Fri, 19 Jul 2024 12:14:20 -0400 Subject: [PATCH 436/675] Use workflow branch 24.08 again (#1617) After updating everything to CUDA 12.5.1, use `shared-workflows@branch-24.08` again. Contributes to https://github.com/rapidsai/build-planning/issues/73 Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1617 --- .github/workflows/build.yaml | 16 ++++++++-------- .github/workflows/pr.yaml | 22 +++++++++++----------- .github/workflows/test.yaml | 6 +++--- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 409e32bb6..5ada2cedd 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build-cpp: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -79,7 +79,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -89,7 +89,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -100,7 +100,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index c5ae9bce2..4969af7e0 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -23,40 +23,40 @@ jobs: - wheel-tests - devcontainer secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.08 checks: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.08 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.08 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.08 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.08 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.08 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.08 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -66,7 +66,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -74,20 +74,20 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 with: build_type: pull-request script: ci/build_wheel_python.sh wheel-tests: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.08 with: build_type: pull-request script: ci/test_wheel.sh devcontainer: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.08 with: arch: '["amd64"]' cuda: '["12.5"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 145afb1ac..42cdcb282 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.08 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.08 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@cuda-12.5.1 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.08 with: build_type: nightly branch: ${{ inputs.branch }} From b4631c57647572c9d6d42e955b1a04dcb0cc9e00 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Fri, 19 Jul 2024 14:50:40 -0400 Subject: [PATCH 437/675] DOC v24.10 Updates [skip ci] --- .../cuda11.8-conda/devcontainer.json | 6 ++--- .devcontainer/cuda11.8-pip/devcontainer.json | 6 ++--- .../cuda12.5-conda/devcontainer.json | 6 ++--- .devcontainer/cuda12.5-pip/devcontainer.json | 6 ++--- .github/workflows/build.yaml | 16 +++++++------- .github/workflows/pr.yaml | 22 +++++++++---------- .github/workflows/test.yaml | 6 ++--- VERSION | 2 +- dependencies.yaml | 6 ++--- python/rmm/pyproject.toml | 2 +- 10 files changed, 39 insertions(+), 39 deletions(-) diff --git a/.devcontainer/cuda11.8-conda/devcontainer.json b/.devcontainer/cuda11.8-conda/devcontainer.json index d87e036d1..3bfef6706 100644 --- a/.devcontainer/cuda11.8-conda/devcontainer.json +++ b/.devcontainer/cuda11.8-conda/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:24.08-cpp-cuda11.8-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.10-cpp-cuda11.8-mambaforge-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.08-cuda11.8-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.10-cuda11.8-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.8": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.10": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda11.8-pip/devcontainer.json b/.devcontainer/cuda11.8-pip/devcontainer.json index 918c3e98e..5bfc30823 100644 --- a/.devcontainer/cuda11.8-pip/devcontainer.json +++ b/.devcontainer/cuda11.8-pip/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:24.08-cpp-cuda11.8-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.10-cpp-cuda11.8-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.08-cuda11.8-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.10-cuda11.8-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.8": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.10": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.5-conda/devcontainer.json b/.devcontainer/cuda12.5-conda/devcontainer.json index ed0d28f20..925557b22 100644 --- a/.devcontainer/cuda12.5-conda/devcontainer.json +++ b/.devcontainer/cuda12.5-conda/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "12.5", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:24.08-cpp-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.10-cpp-mambaforge-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.08-cuda12.5-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.10-cuda12.5-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.8": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.10": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.5-pip/devcontainer.json b/.devcontainer/cuda12.5-pip/devcontainer.json index 9648fe1fd..2f9e1c493 100644 --- a/.devcontainer/cuda12.5-pip/devcontainer.json +++ b/.devcontainer/cuda12.5-pip/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "12.5", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:24.08-cpp-cuda12.5-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.10-cpp-cuda12.5-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.08-cuda12.5-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.10-cuda12.5-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.8": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.10": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5ada2cedd..9b7efecde 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build-cpp: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -79,7 +79,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -89,7 +89,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -100,7 +100,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 4969af7e0..1160b93e9 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -23,40 +23,40 @@ jobs: - wheel-tests - devcontainer secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.10 checks: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.10 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.10 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.10 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.10 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.10 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.10 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -66,7 +66,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -74,20 +74,20 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10 with: build_type: pull-request script: ci/build_wheel_python.sh wheel-tests: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.10 with: build_type: pull-request script: ci/test_wheel.sh devcontainer: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.10 with: arch: '["amd64"]' cuda: '["12.5"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 42cdcb282..13838d888 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.10 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.10 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.08 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.10 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/VERSION b/VERSION index ec8489fda..7c7ba0443 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -24.08.00 +24.10.00 diff --git a/dependencies.yaml b/dependencies.yaml index 82847c89c..8356b89cc 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -162,14 +162,14 @@ dependencies: - matrix: cuda: "12.*" packages: - - librmm-cu12==24.8.*,>=0.0.0a0 + - librmm-cu12==24.10.*,>=0.0.0a0 - matrix: cuda: "11.*" packages: - - librmm-cu11==24.8.*,>=0.0.0a0 + - librmm-cu11==24.10.*,>=0.0.0a0 - matrix: packages: - - librmm==24.8.*,>=0.0.0a0 + - librmm==24.10.*,>=0.0.0a0 checks: common: - output_types: [conda, requirements] diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 9cbabda61..badd09316 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -128,7 +128,7 @@ requires = [ "cmake>=3.26.4,!=3.30.0", "cuda-python>=11.7.1,<12.0a0", "cython>=3.0.0", - "librmm==24.8.*,>=0.0.0a0", + "librmm==24.10.*,>=0.0.0a0", "ninja", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. From 33598c7e6b97dce2264f632e28a8f216998cfe4a Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 19 Jul 2024 13:31:50 -0600 Subject: [PATCH 438/675] Prefetch resource adaptor (#1608) This implements a `PrefetchResourceAdaptor`, following the proposal from https://github.com/rapidsai/cudf/issues/16251. > Implement a new PrefetchMemoryResource that performs a prefetch when data is allocated. This is important because injecting prefetches in cuIO is more challenging than in the rest of libcudf, so prefetching on allocate is a short-term fix that ensures buffers are prefetched before being written to in cuIO. Authors: - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Rong Ou (https://github.com/rongou) - Lawrence Mitchell (https://github.com/wence-) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1608 --- .../mr/device/prefetch_resource_adaptor.hpp | 143 ++++++++++++++++++ python/rmm/rmm/_lib/memory_resource.pxd | 3 + python/rmm/rmm/_lib/memory_resource.pyx | 31 ++++ python/rmm/rmm/mr.py | 2 + python/rmm/rmm/tests/test_rmm.py | 24 +++ tests/CMakeLists.txt | 3 + .../prefetch_resource_adaptor_tests.cpp | 101 +++++++++++++ tests/prefetch_tests.cpp | 7 +- 8 files changed, 313 insertions(+), 1 deletion(-) create mode 100644 include/rmm/mr/device/prefetch_resource_adaptor.hpp create mode 100644 tests/mr/device/prefetch_resource_adaptor_tests.cpp diff --git a/include/rmm/mr/device/prefetch_resource_adaptor.hpp b/include/rmm/mr/device/prefetch_resource_adaptor.hpp new file mode 100644 index 000000000..da0ca8c86 --- /dev/null +++ b/include/rmm/mr/device/prefetch_resource_adaptor.hpp @@ -0,0 +1,143 @@ +/* + * 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. + */ +#pragma once + +#include +#include +#include + +#include +#include +#include +#include + +namespace rmm::mr { +/** + * @addtogroup device_resource_adaptors + * @{ + * @file + */ +/** + * @brief Resource that prefetches all memory allocations. + * + * @tparam Upstream Type of the upstream resource used for + * allocation/deallocation. + */ +template +class prefetch_resource_adaptor final : public device_memory_resource { + public: + /** + * @brief Construct a new prefetch resource adaptor using `upstream` to satisfy + * allocation requests. + * + * @throws rmm::logic_error if `upstream == nullptr` + * + * @param upstream The resource used for allocating/deallocating device memory + */ + prefetch_resource_adaptor(Upstream* upstream) : upstream_{upstream} + { + RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); + } + + prefetch_resource_adaptor() = delete; + ~prefetch_resource_adaptor() override = default; + prefetch_resource_adaptor(prefetch_resource_adaptor const&) = delete; + prefetch_resource_adaptor& operator=(prefetch_resource_adaptor const&) = delete; + prefetch_resource_adaptor(prefetch_resource_adaptor&&) noexcept = + default; ///< @default_move_constructor + prefetch_resource_adaptor& operator=(prefetch_resource_adaptor&&) noexcept = + default; ///< @default_move_assignment{prefetch_resource_adaptor} + + /** + * @briefreturn{rmm::device_async_resource_ref to the upstream resource} + */ + [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + { + return upstream_; + } + + /** + * @briefreturn{Upstream* to the upstream memory resource} + */ + [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } + + private: + /** + * @brief Allocates memory of size at least `bytes` using the upstream + * resource as long as it fits inside the allocation limit. + * + * @note The allocation is always prefetched to the current device. + * + * @throws rmm::bad_alloc if the requested allocation could not be fulfilled + * by the upstream resource. + * + * @param bytes The size, in bytes, of the allocation + * @param stream Stream on which to perform the allocation + * @return void* Pointer to the newly allocated memory + */ + void* do_allocate(std::size_t bytes, cuda_stream_view stream) override + { + void* ptr = upstream_->allocate(bytes, stream); + rmm::prefetch(ptr, bytes, rmm::get_current_cuda_device(), stream); + return ptr; + } + + /** + * @brief Free allocation of size `bytes` pointed to by `ptr` + * + * @param ptr Pointer to be deallocated + * @param bytes Size of the allocation + * @param stream Stream on which to perform the deallocation + */ + void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override + { + upstream_->deallocate(ptr, bytes, stream); + } + + /** + * @brief Compare the upstream resource to another. + * + * @param other The other resource to compare to + * @return true If the two resources are equivalent + * @return false If the two resources are not equal + */ + bool do_is_equal(device_memory_resource const& other) const noexcept override + { + if (this == &other) { return true; } + auto cast = dynamic_cast const*>(&other); + if (cast == nullptr) { return upstream_->is_equal(other); } + return get_upstream_resource() == cast->get_upstream_resource(); + } + + Upstream* upstream_; // the upstream resource used for satisfying allocation requests +}; + +/** + * @brief Convenience factory to return a `prefetch_resource_adaptor` around the + * upstream resource `upstream`. + * + * @tparam Upstream Type of the upstream `device_memory_resource`. + * @param upstream Pointer to the upstream resource + * @return The new prefetch resource adaptor + */ +template +prefetch_resource_adaptor make_prefetch_adaptor(Upstream* upstream) +{ + return prefetch_resource_adaptor{upstream}; +} + +/** @} */ // end of group +} // namespace rmm::mr diff --git a/python/rmm/rmm/_lib/memory_resource.pxd b/python/rmm/rmm/_lib/memory_resource.pxd index 15ddc84f6..8be2ba158 100644 --- a/python/rmm/rmm/_lib/memory_resource.pxd +++ b/python/rmm/rmm/_lib/memory_resource.pxd @@ -91,4 +91,7 @@ cdef class TrackingResourceAdaptor(UpstreamResourceAdaptor): cdef class FailureCallbackResourceAdaptor(UpstreamResourceAdaptor): cdef object _callback +cdef class PrefetchResourceAdaptor(UpstreamResourceAdaptor): + pass + cpdef DeviceMemoryResource get_current_device_resource() diff --git a/python/rmm/rmm/_lib/memory_resource.pyx b/python/rmm/rmm/_lib/memory_resource.pyx index e181bff4c..bf927c336 100644 --- a/python/rmm/rmm/_lib/memory_resource.pyx +++ b/python/rmm/rmm/_lib/memory_resource.pyx @@ -219,6 +219,11 @@ cdef extern from "rmm/mr/device/failure_callback_resource_adaptor.hpp" \ void* callback_arg ) except + +cdef extern from "rmm/mr/device/prefetch_resource_adaptor.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass prefetch_resource_adaptor[Upstream](device_memory_resource): + prefetch_resource_adaptor(Upstream* upstream_mr) except + + cdef class DeviceMemoryResource: @@ -987,6 +992,32 @@ cdef class FailureCallbackResourceAdaptor(UpstreamResourceAdaptor): """ pass +cdef class PrefetchResourceAdaptor(UpstreamResourceAdaptor): + + def __cinit__( + self, + DeviceMemoryResource upstream_mr + ): + self.c_obj.reset( + new prefetch_resource_adaptor[device_memory_resource]( + upstream_mr.get_mr() + ) + ) + + def __init__( + self, + DeviceMemoryResource upstream_mr + ): + """ + Memory resource that prefetches all allocations. + + Parameters + ---------- + upstream : DeviceMemoryResource + The upstream memory resource. + """ + pass + # Global per-device memory resources; dict of int:DeviceMemoryResource cdef _per_device_mrs = defaultdict(CudaMemoryResource) diff --git a/python/rmm/rmm/mr.py b/python/rmm/rmm/mr.py index b6ae4e6cd..4ca6805c8 100644 --- a/python/rmm/rmm/mr.py +++ b/python/rmm/rmm/mr.py @@ -23,6 +23,7 @@ LoggingResourceAdaptor, ManagedMemoryResource, PoolMemoryResource, + PrefetchResourceAdaptor, StatisticsResourceAdaptor, TrackingResourceAdaptor, UpstreamResourceAdaptor, @@ -52,6 +53,7 @@ "LoggingResourceAdaptor", "ManagedMemoryResource", "PoolMemoryResource", + "PrefetchResourceAdaptor", "StatisticsResourceAdaptor", "TrackingResourceAdaptor", "FailureCallbackResourceAdaptor", diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index 05ffcf832..ff8ed9aad 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -733,6 +733,30 @@ def callback(nbytes: int) -> bool: assert retried[0] +@pytest.mark.parametrize("managed", [True, False]) +def test_prefetch_resource_adaptor(managed): + if managed: + upstream_mr = rmm.mr.ManagedMemoryResource() + else: + upstream_mr = rmm.mr.CudaMemoryResource() + mr = rmm.mr.PrefetchResourceAdaptor(upstream_mr) + rmm.mr.set_current_device_resource(mr) + + # This allocation should be prefetched + db = rmm.DeviceBuffer.to_device(np.zeros(256, dtype="u1")) + + err, device = cudart.cudaGetDevice() + assert err == cudart.cudaError_t.cudaSuccess + + if managed: + assert_prefetched(db, device) + db.prefetch() # just test that it doesn't throw + if managed: + err, device = cudart.cudaGetDevice() + assert err == cudart.cudaError_t.cudaSuccess + assert_prefetched(db, device) + + def test_failure_callback_resource_adaptor_error(): def callback(nbytes: int) -> bool: raise RuntimeError("MyError") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index de0dc363b..75b15a90b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -148,6 +148,9 @@ ConfigureTest(TRACKING_TEST mr/device/tracking_mr_tests.cpp GPUS 1 PERCENT 100) # out-of-memory callback adaptor tests ConfigureTest(FAILURE_CALLBACK_TEST mr/device/failure_callback_mr_tests.cpp) +# prefetch adaptor tests +ConfigureTest(PREFETCH_ADAPTOR_TEST mr/device/prefetch_resource_adaptor_tests.cpp) + # aligned adaptor tests ConfigureTest(ALIGNED_TEST mr/device/aligned_mr_tests.cpp) diff --git a/tests/mr/device/prefetch_resource_adaptor_tests.cpp b/tests/mr/device/prefetch_resource_adaptor_tests.cpp new file mode 100644 index 000000000..9d15c07f2 --- /dev/null +++ b/tests/mr/device/prefetch_resource_adaptor_tests.cpp @@ -0,0 +1,101 @@ +/* + * 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. + */ + +#include "../../byte_literals.hpp" + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +using prefetch_adaptor = rmm::mr::prefetch_resource_adaptor; + +template +struct PrefetchAdaptorTest : public ::testing::Test { + rmm::cuda_stream stream{}; + std::size_t size{}; + MemoryResourceType mr{}; + + PrefetchAdaptorTest() + { + std::default_random_engine generator; + + auto constexpr range_min{1000}; + auto constexpr range_max{100000}; + std::uniform_int_distribution distribution(range_min, range_max); + size = distribution(generator); + } + + // Test that the memory range was last prefetched to the specified device + void expect_prefetched(void const* ptr, std::size_t size, rmm::cuda_device_id device) + { + if constexpr (std::is_same_v) { + int prefetch_location{0}; + // See the CUDA documentation for cudaMemRangeGetAttribute + // https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g8048f6ea5ad77917444567656c140c5a + // specifically for when cudaMemRangeAttribute::cudaMemRangeAttributeLastPrefetchLocation is + // used. + constexpr size_t prefetch_data_size = 4; + RMM_CUDA_TRY( + cudaMemRangeGetAttribute(&prefetch_location, + prefetch_data_size, + cudaMemRangeAttribute::cudaMemRangeAttributeLastPrefetchLocation, + ptr, + size)); + EXPECT_EQ(prefetch_location, device.value()); + } + } +}; + +using resources = ::testing::Types; + +TYPED_TEST_CASE(PrefetchAdaptorTest, resources); + +// The following tests simply test compilation and that there are no exceptions thrown +// due to prefetching non-managed memory. + +TYPED_TEST(PrefetchAdaptorTest, PointerAndSize) +{ + auto* orig_device_resource = &this->mr; + prefetch_adaptor prefetch_mr{orig_device_resource}; + rmm::device_buffer buff(this->size, this->stream, &prefetch_mr); + // verify data range has been prefetched + this->expect_prefetched(buff.data(), buff.size(), rmm::get_current_cuda_device()); + // verify that prefetching does not error + rmm::prefetch(buff.data(), buff.size(), rmm::get_current_cuda_device(), this->stream); + // reverify data range has been prefetched + this->expect_prefetched(buff.data(), buff.size(), rmm::get_current_cuda_device()); +} + +TYPED_TEST(PrefetchAdaptorTest, NotPrefetchedWithoutAdaptor) +{ + // verify not prefetched without adaptor + rmm::device_buffer buff(this->size, this->stream, &this->mr); + this->expect_prefetched(buff.data(), buff.size(), rmm::cuda_device_id(cudaInvalidDeviceId)); +} + +TEST(PrefetchAdaptorTestNullUpstream, ThrowOnNullUpstream) +{ + auto construct_nullptr = []() { prefetch_adaptor mr{nullptr}; }; + EXPECT_THROW(construct_nullptr(), rmm::logic_error); +} diff --git a/tests/prefetch_tests.cpp b/tests/prefetch_tests.cpp index 8873dd47f..6c7bb2dd3 100644 --- a/tests/prefetch_tests.cpp +++ b/tests/prefetch_tests.cpp @@ -49,11 +49,16 @@ struct PrefetchTest : public ::testing::Test { // Test that the memory range was last prefetched to the specified device void expect_prefetched(void const* ptr, std::size_t size, rmm::cuda_device_id device) { + // See the CUDA documentation for cudaMemRangeGetAttribute + // https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g8048f6ea5ad77917444567656c140c5a + // specifically for when cudaMemRangeAttribute::cudaMemRangeAttributeLastPrefetchLocation is + // used. + constexpr size_t prefetch_data_size = 4; if constexpr (std::is_same_v) { int prefetch_location{0}; RMM_CUDA_TRY( cudaMemRangeGetAttribute(&prefetch_location, - 4, + prefetch_data_size, cudaMemRangeAttribute::cudaMemRangeAttributeLastPrefetchLocation, ptr, size)); From 5f786ba3de2652432fab8fa03ade4d9922471262 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Fri, 19 Jul 2024 17:17:46 -0500 Subject: [PATCH 439/675] Add RMM_USE_NVTX cmake option to provide localized control of NVTX for RMM (#1602) Adds a new RMM_USE_NVTX cmake option that defaults to the prior USE_NVTX setting if not set. If RMM_USE_NVTX is OFF, it stubs out the RMM_FUNC_RANGE macro which is used for RMM's NVTX ranges, effectively disabling NVTX within RMM yet leaving it enabled for the rest of the project using RMM. Closes #1595 Authors: - Jason Lowe (https://github.com/jlowe) Approvers: - Robert Maynard (https://github.com/robertmaynard) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1602 --- CMakeLists.txt | 10 +++++----- include/rmm/detail/nvtx/ranges.hpp | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa3358ca0..93130907f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ rapids_cmake_build_type(Release) # ################################################################################################## # * build options ---------------------------------------------------------------------------------- -option(USE_NVTX "Build with NVTX support" ON) +option(RMM_NVTX "Build RMM with NVTX support" OFF) option(BUILD_TESTS "Configure CMake to build tests" ON) option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" OFF) set(RMM_LOGGING_LEVEL @@ -47,7 +47,7 @@ set(RMM_LOGGING_LEVEL set_property(CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF") -message(VERBOSE "RMM: Build with NVTX support: ${USE_NVTX}") +message(VERBOSE "RMM: Build with NVTX support: ${RMM_NVTX}") # Set logging level. Must go before including gtests and benchmarks. Set the possible values of # build type for cmake-gui. message(STATUS "RMM: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'") @@ -100,9 +100,9 @@ target_link_libraries(rmm INTERFACE nvtx3::nvtx3-cpp) target_compile_features(rmm INTERFACE cxx_std_17 $) target_compile_definitions(rmm INTERFACE LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE) -# Disable NVTX if necessary -if(NOT USE_NVTX) - target_compile_definitions(rmm INTERFACE NVTX_DISABLE) +# Enable NVTX if necessary +if(RMM_NVTX) + target_compile_definitions(rmm INTERFACE RMM_NVTX) endif() # ################################################################################################## diff --git a/include/rmm/detail/nvtx/ranges.hpp b/include/rmm/detail/nvtx/ranges.hpp index 1791a8c3b..fc5e0e077 100644 --- a/include/rmm/detail/nvtx/ranges.hpp +++ b/include/rmm/detail/nvtx/ranges.hpp @@ -58,4 +58,8 @@ using scoped_range = ::nvtx3::scoped_range_in; * } * ``` */ +#if defined(RMM_NVTX) #define RMM_FUNC_RANGE() NVTX3_FUNC_RANGE_IN(rmm::librmm_domain) +#else +#define RMM_FUNC_RANGE() +#endif From 0e7d519d6667064a0e8ac42fc0e8b5b80f7c644c Mon Sep 17 00:00:00 2001 From: pauleonix Date: Tue, 23 Jul 2024 01:31:11 +0200 Subject: [PATCH 440/675] Add documentation for CPM usage (#1600) - Add section in README.md that describes issue with CPM's single argument syntax. - Update link to CPM.cmake repo (old link redirected to this new one). - Add optional INTERFACE argument to CMake snippets for completeness. closes #1594 Authors: - https://github.com/pauleonix - Mark Harris (https://github.com/harrism) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1600 --- README.md | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 34545c27e..e1d78458f 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ Done! You are ready to develop for the RMM OSS project. ### Caching third-party dependencies -RMM uses [CPM.cmake](https://github.com/TheLartians/CPM.cmake) to +RMM uses [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) to handle third-party dependencies like spdlog, Thrust, GoogleTest, GoogleBenchmark. In general you won't have to worry about it. If CMake finds an appropriate version on your system, it uses it (you can @@ -157,7 +157,7 @@ integrate RMM into your own CMake project. In your `CMakeLists.txt`, just add ```cmake find_package(rmm [VERSION]) # ... -target_link_libraries( (PRIVATE|PUBLIC) rmm::rmm) +target_link_libraries( (PRIVATE|PUBLIC|INTERFACE) rmm::rmm) ``` Since RMM is a header-only library, this does not actually link RMM, @@ -172,6 +172,27 @@ Thrust. If you want to customize it, you can set the variables `THRUST_HOST_SYSTEM` and `THRUST_DEVICE_SYSTEM`; see [Thrust's CMake documentation](https://github.com/NVIDIA/cccl/blob/main/thrust/thrust/cmake/README.md). +### Using CPM to manage RMM + +RMM uses [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) to manage +its dependencies, including [CCCL](https://github.com/nvidia/cccl), and you can +use CPM for your project's dependency on RMM. + +There is an issue with using CPM's *single-argument compact syntax* for +RMM/CCCL as it transitively marks targets as `SYSTEM` dependencies. +This causes the CCCL headers pulled in through CPM to be of lower priority +to the preprocessor than the (potentially outdated) CCCL headers provided +by the CUDA SDK. To avoid this issue, use CPM's *multi-argument syntax* +instead: + +```cmake +CPMAddPackage(NAME rmm [VERSION] + GITHUB_REPOSITORY rapidsai/rmm + SYSTEM Off) +# ... +target_link_libraries( (PRIVATE|PUBLIC|INTERFACE) rmm::rmm) +``` + # Using RMM in C++ The first goal of RMM is to provide a common interface for device and host memory allocation. From 094675dc3728a6ff21387edeae2f50d7261341d8 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:49:59 +1000 Subject: [PATCH 441/675] Instruct to create associated issue in PR template. (#1624) We use issues for tracking work and new features in RMM. This adds instruction to the PR template to suggest contributors should create an associated issue if it doesn't already exist. Fixes #1623 Authors: - Mark Harris (https://github.com/harrism) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1624 --- .github/PULL_REQUEST_TEMPLATE.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index a16c8da96..d1bbe38bb 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,8 @@ ## Description + + + + From e8df17d5f383ada7e493dda54c31a494a87fb7d3 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 24 Jul 2024 17:24:45 -0500 Subject: [PATCH 442/675] split up CUDA-suffixed dependencies in dependencies.yaml (#1627) Contributes to https://github.com/rapidsai/build-planning/issues/31 In short, RAPIDS DLFW builds want to produce wheels with unsuffixed dependencies, e.g. `cudf` depending on `rmm`, not `rmm-cu12`. This PR is part of a series across all of RAPIDS to try to support that type of build by setting up CUDA-suffixed and CUDA-unsuffixed dependency lists in `dependencies.yaml`. For more details, see: * https://github.com/rapidsai/build-planning/issues/31#issuecomment-2245815818 * https://github.com/rapidsai/cudf/pull/16183 ## Notes for Reviewers ### Why target 24.08? This is targeting 24.08 because: 1. it should be very low-risk 2. getting these changes into 24.08 prevents the need to carry around patches for every library in DLFW builds using RAPIDS 24.08 Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1627 --- dependencies.yaml | 4 +++- python/librmm/pyproject.toml | 1 + python/rmm/pyproject.toml | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dependencies.yaml b/dependencies.yaml index 82847c89c..974192967 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -161,13 +161,15 @@ dependencies: matrices: - matrix: cuda: "12.*" + cuda_suffixed: "true" packages: - librmm-cu12==24.8.*,>=0.0.0a0 - matrix: cuda: "11.*" + cuda_suffixed: "true" packages: - librmm-cu11==24.8.*,>=0.0.0a0 - - matrix: + - matrix: null packages: - librmm==24.8.*,>=0.0.0a0 checks: diff --git a/python/librmm/pyproject.toml b/python/librmm/pyproject.toml index 1b4042217..6bfae3000 100644 --- a/python/librmm/pyproject.toml +++ b/python/librmm/pyproject.toml @@ -46,6 +46,7 @@ librmm = "librmm" [tool.rapids-build-backend] build-backend = "scikit_build_core.build" dependencies-file = "../../dependencies.yaml" +matrix-entry = "cuda_suffixed=true" requires = [ "cmake>=3.26.4,!=3.30.0", "ninja", diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 9cbabda61..acc3b6c85 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -124,6 +124,7 @@ regex = "(?P.*)" [tool.rapids-build-backend] build-backend = "scikit_build_core.build" dependencies-file = "../../dependencies.yaml" +matrix-entry = "cuda_suffixed=true" requires = [ "cmake>=3.26.4,!=3.30.0", "cuda-python>=11.7.1,<12.0a0", From 8c20e14110f1c4079a0922ca90c96597ae20350b Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 24 Jul 2024 19:44:44 -0500 Subject: [PATCH 443/675] Remove prefetch factory. (#1625) PR #1608 added a prefetch resource adaptor. However, per issue #1616, we want to remove the adaptor factories like `make_prefetch_adaptor` in favor of constructors with CTAD. I am removing the prefetch adaptor factory because it has not yet been released, and thus can be deleted without deprecation. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Rong Ou (https://github.com/rongou) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1625 --- .../rmm/mr/device/prefetch_resource_adaptor.hpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/include/rmm/mr/device/prefetch_resource_adaptor.hpp b/include/rmm/mr/device/prefetch_resource_adaptor.hpp index da0ca8c86..48a64a5b9 100644 --- a/include/rmm/mr/device/prefetch_resource_adaptor.hpp +++ b/include/rmm/mr/device/prefetch_resource_adaptor.hpp @@ -125,19 +125,5 @@ class prefetch_resource_adaptor final : public device_memory_resource { Upstream* upstream_; // the upstream resource used for satisfying allocation requests }; -/** - * @brief Convenience factory to return a `prefetch_resource_adaptor` around the - * upstream resource `upstream`. - * - * @tparam Upstream Type of the upstream `device_memory_resource`. - * @param upstream Pointer to the upstream resource - * @return The new prefetch resource adaptor - */ -template -prefetch_resource_adaptor make_prefetch_adaptor(Upstream* upstream) -{ - return prefetch_resource_adaptor{upstream}; -} - /** @} */ // end of group } // namespace rmm::mr From 67a78d6370ed34a0ffcb3aa9c77299e2a7ea1ee5 Mon Sep 17 00:00:00 2001 From: Rong Ou Date: Wed, 24 Jul 2024 18:37:21 -0700 Subject: [PATCH 444/675] Add python wrapper for system memory resource (#1605) Follow up on #1581 to add access to the system memory resource in python. Fixes #1622 Authors: - Rong Ou (https://github.com/rongou) Approvers: - Mark Harris (https://github.com/harrism) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1605 --- ...r.hpp => sam_headroom_memory_resource.hpp} | 61 ++++++------------- python/rmm/rmm/_lib/memory_resource.pxd | 6 ++ python/rmm/rmm/_lib/memory_resource.pyx | 47 ++++++++++++++ python/rmm/rmm/mr.py | 4 ++ python/rmm/rmm/tests/test_rmm.py | 58 +++++++++++++++++- tests/mr/device/system_mr_tests.cu | 39 ++++-------- 6 files changed, 144 insertions(+), 71 deletions(-) rename include/rmm/mr/device/{sam_headroom_resource_adaptor.hpp => sam_headroom_memory_resource.hpp} (62%) diff --git a/include/rmm/mr/device/sam_headroom_resource_adaptor.hpp b/include/rmm/mr/device/sam_headroom_memory_resource.hpp similarity index 62% rename from include/rmm/mr/device/sam_headroom_resource_adaptor.hpp rename to include/rmm/mr/device/sam_headroom_memory_resource.hpp index fc913f290..cdf14181f 100644 --- a/include/rmm/mr/device/sam_headroom_resource_adaptor.hpp +++ b/include/rmm/mr/device/sam_headroom_memory_resource.hpp @@ -23,12 +23,12 @@ namespace rmm::mr { /** - * @addtogroup device_resource_adaptors + * @addtogroup device_memory_resources * @{ * @file */ /** - * @brief Resource that adapts system memory resource to allocate memory with a headroom. + * @brief Resource that uses system memory resource to allocate memory with a headroom. * * System allocated memory (SAM) can be migrated to the GPU, but is never migrated back the host. If * GPU memory is over-subscribed, this can cause other CUDA calls to fail with out-of-memory errors. @@ -39,46 +39,22 @@ namespace rmm::mr { * Since doing this check on every allocation can be expensive, the caller may choose to use other * allocators (e.g. `binning_memory_resource`) for small allocations, and use this allocator for * large allocations only. - * - * @tparam Upstream Type of the upstream resource used for allocation/deallocation. Must be - * `system_memory_resource`. */ -template -class sam_headroom_resource_adaptor final : public device_memory_resource { +class sam_headroom_memory_resource final : public device_memory_resource { public: /** - * @brief Construct a headroom adaptor using `upstream` to satisfy allocation requests. + * @brief Construct a headroom memory resource. * - * @param upstream The resource used for allocating/deallocating device memory. Must be - * `system_memory_resource`. * @param headroom Size of the reserved GPU memory as headroom */ - explicit sam_headroom_resource_adaptor(Upstream* upstream, std::size_t headroom) - : upstream_{upstream}, headroom_{headroom} - { - static_assert(std::is_same_v, - "Upstream must be rmm::mr::system_memory_resource"); - } + explicit sam_headroom_memory_resource(std::size_t headroom) : system_mr_{}, headroom_{headroom} {} - sam_headroom_resource_adaptor() = delete; - ~sam_headroom_resource_adaptor() override = default; - sam_headroom_resource_adaptor(sam_headroom_resource_adaptor const&) = delete; - sam_headroom_resource_adaptor(sam_headroom_resource_adaptor&&) = delete; - sam_headroom_resource_adaptor& operator=(sam_headroom_resource_adaptor const&) = delete; - sam_headroom_resource_adaptor& operator=(sam_headroom_resource_adaptor&&) = delete; - - /** - * @briefreturn{rmm::device_async_resource_ref to the upstream resource} - */ - [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept - { - return upstream_; - } - - /** - * @briefreturn{Upstream* to the upstream memory resource} - */ - [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } + sam_headroom_memory_resource() = delete; + ~sam_headroom_memory_resource() override = default; + sam_headroom_memory_resource(sam_headroom_memory_resource const&) = delete; + sam_headroom_memory_resource(sam_headroom_memory_resource&&) = delete; + sam_headroom_memory_resource& operator=(sam_headroom_memory_resource const&) = delete; + sam_headroom_memory_resource& operator=(sam_headroom_memory_resource&&) = delete; private: /** @@ -94,8 +70,7 @@ class sam_headroom_resource_adaptor final : public device_memory_resource { */ void* do_allocate(std::size_t bytes, [[maybe_unused]] cuda_stream_view stream) override { - void* pointer = - get_upstream_resource().allocate_async(bytes, rmm::CUDA_ALLOCATION_ALIGNMENT, stream); + void* pointer = system_mr_.allocate_async(bytes, rmm::CUDA_ALLOCATION_ALIGNMENT, stream); auto const free = rmm::available_device_memory().first; auto const allocatable = free > headroom_ ? free - headroom_ : 0UL; @@ -131,7 +106,7 @@ class sam_headroom_resource_adaptor final : public device_memory_resource { [[maybe_unused]] std::size_t bytes, [[maybe_unused]] cuda_stream_view stream) override { - get_upstream_resource().deallocate_async(ptr, rmm::CUDA_ALLOCATION_ALIGNMENT, stream); + system_mr_.deallocate_async(ptr, rmm::CUDA_ALLOCATION_ALIGNMENT, stream); } /** @@ -144,13 +119,15 @@ class sam_headroom_resource_adaptor final : public device_memory_resource { [[nodiscard]] bool do_is_equal(device_memory_resource const& other) const noexcept override { if (this == &other) { return true; } - auto cast = dynamic_cast(&other); + auto cast = dynamic_cast(&other); if (cast == nullptr) { return false; } - return get_upstream_resource() == cast->get_upstream_resource() && headroom_ == cast->headroom_; + return headroom_ == cast->headroom_; } - Upstream* upstream_; ///< The upstream resource used for satisfying allocation requests - std::size_t headroom_; ///< Size of GPU memory reserved as headroom + ///< The system memory resource used for satisfying allocation requests + system_memory_resource system_mr_; + ///< Size of GPU memory reserved as headroom + std::size_t headroom_; }; /** @} */ // end of group } // namespace rmm::mr diff --git a/python/rmm/rmm/_lib/memory_resource.pxd b/python/rmm/rmm/_lib/memory_resource.pxd index 8be2ba158..000a3fe1e 100644 --- a/python/rmm/rmm/_lib/memory_resource.pxd +++ b/python/rmm/rmm/_lib/memory_resource.pxd @@ -52,6 +52,12 @@ cdef class CudaMemoryResource(DeviceMemoryResource): cdef class ManagedMemoryResource(DeviceMemoryResource): pass +cdef class SystemMemoryResource(DeviceMemoryResource): + pass + +cdef class SamHeadroomMemoryResource(DeviceMemoryResource): + pass + cdef class CudaAsyncMemoryResource(DeviceMemoryResource): pass diff --git a/python/rmm/rmm/_lib/memory_resource.pyx b/python/rmm/rmm/_lib/memory_resource.pyx index bf927c336..5030c5d2d 100644 --- a/python/rmm/rmm/_lib/memory_resource.pyx +++ b/python/rmm/rmm/_lib/memory_resource.pyx @@ -94,6 +94,16 @@ cdef extern from "rmm/mr/device/managed_memory_resource.hpp" \ cdef cppclass managed_memory_resource(device_memory_resource): managed_memory_resource() except + +cdef extern from "rmm/mr/device/system_memory_resource.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass system_memory_resource(device_memory_resource): + system_memory_resource() except + + +cdef extern from "rmm/mr/device/sam_headroom_memory_resource.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass sam_headroom_memory_resource(device_memory_resource): + sam_headroom_memory_resource(size_t headroom) except + + cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ namespace "rmm::mr" nogil: @@ -366,6 +376,43 @@ cdef class ManagedMemoryResource(DeviceMemoryResource): pass +cdef class SystemMemoryResource(DeviceMemoryResource): + def __cinit__(self): + self.c_obj.reset( + new system_memory_resource() + ) + + def __init__(self): + """ + Memory resource that uses ``malloc``/``free`` for + allocation/deallocation. + """ + pass + + +cdef class SamHeadroomMemoryResource(DeviceMemoryResource): + def __cinit__( + self, + size_t headroom + ): + self.c_obj.reset(new sam_headroom_memory_resource(headroom)) + + def __init__( + self, + size_t headroom + ): + """ + Memory resource that uses ``malloc``/``free`` for + allocation/deallocation. + + Parameters + ---------- + headroom : size_t + Size of the reserved GPU memory as headroom + """ + pass + + cdef class PoolMemoryResource(UpstreamResourceAdaptor): def __cinit__( diff --git a/python/rmm/rmm/mr.py b/python/rmm/rmm/mr.py index 4ca6805c8..6eb94da0f 100644 --- a/python/rmm/rmm/mr.py +++ b/python/rmm/rmm/mr.py @@ -24,7 +24,9 @@ ManagedMemoryResource, PoolMemoryResource, PrefetchResourceAdaptor, + SamHeadroomMemoryResource, StatisticsResourceAdaptor, + SystemMemoryResource, TrackingResourceAdaptor, UpstreamResourceAdaptor, _flush_logs, @@ -54,7 +56,9 @@ "ManagedMemoryResource", "PoolMemoryResource", "PrefetchResourceAdaptor", + "SamHeadroomMemoryResource", "StatisticsResourceAdaptor", + "SystemMemoryResource", "TrackingResourceAdaptor", "FailureCallbackResourceAdaptor", "UpstreamResourceAdaptor", diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index ff8ed9aad..c4fd90c45 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -38,6 +38,11 @@ _runtime_version >= 11020 ) +_SYSTEM_MEMORY_SUPPORTED = rmm._cuda.gpu.getDeviceAttribute( + cudart.cudaDeviceAttr.cudaDevAttrPageableMemoryAccess, + rmm._cuda.gpu.getDevice(), +) + def array_tester(dtype, nelem, alloc): # data @@ -91,6 +96,39 @@ def test_rmm_modes(dtype, nelem, alloc, managed, pool): array_tester(dtype, nelem, alloc) +@pytest.mark.skipif( + not _SYSTEM_MEMORY_SUPPORTED, + reason="System memory not supported", +) +@pytest.mark.parametrize("dtype", _dtypes) +@pytest.mark.parametrize("nelem", _nelems) +@pytest.mark.parametrize("alloc", _allocs) +@pytest.mark.parametrize( + "system, pool, headroom", + list(product([False, True], [False, True], [False, True])), +) +def test_rmm_modes_system_memory(dtype, nelem, alloc, system, pool, headroom): + assert rmm.is_initialized() + array_tester(dtype, nelem, alloc) + + if system: + if headroom: + base_mr = rmm.mr.SamHeadroomMemoryResource(headroom=1 << 20) + else: + base_mr = rmm.mr.SystemMemoryResource() + else: + base_mr = rmm.mr.CudaMemoryResource() + if pool: + mr = rmm.mr.PoolMemoryResource(base_mr) + else: + mr = base_mr + rmm.mr.set_current_device_resource(mr) + + assert rmm.is_initialized() + + array_tester(dtype, nelem, alloc) + + @pytest.mark.parametrize("dtype", _dtypes) @pytest.mark.parametrize("nelem", _nelems) @pytest.mark.parametrize("alloc", _allocs) @@ -410,7 +448,15 @@ def test_pool_memory_resource(dtype, nelem, alloc): [ lambda: rmm.mr.CudaMemoryResource(), lambda: rmm.mr.ManagedMemoryResource(), - ], + ] + + ( + [ + lambda: rmm.mr.SystemMemoryResource(), + lambda: rmm.mr.SamHeadroomMemoryResource(headroom=1 << 20), + ] + if _SYSTEM_MEMORY_SUPPORTED + else [] + ), ) def test_fixed_size_memory_resource(dtype, nelem, alloc, upstream): mr = rmm.mr.FixedSizeMemoryResource( @@ -432,7 +478,15 @@ def test_fixed_size_memory_resource(dtype, nelem, alloc, upstream): lambda: rmm.mr.PoolMemoryResource( rmm.mr.CudaMemoryResource(), 1 << 20 ), - ], + ] + + ( + [ + lambda: rmm.mr.SystemMemoryResource(), + lambda: rmm.mr.SamHeadroomMemoryResource(headroom=1 << 20), + ] + if _SYSTEM_MEMORY_SUPPORTED + else [] + ), ) def test_binning_memory_resource(dtype, nelem, alloc, upstream_mr): upstream = upstream_mr() diff --git a/tests/mr/device/system_mr_tests.cu b/tests/mr/device/system_mr_tests.cu index 079afeb14..00084c4e2 100644 --- a/tests/mr/device/system_mr_tests.cu +++ b/tests/mr/device/system_mr_tests.cu @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include @@ -54,9 +54,9 @@ void touch_on_gpu(void* ptr, std::size_t size) using system_mr = rmm::mr::system_memory_resource; static_assert(cuda::mr::resource_with); static_assert(cuda::mr::async_resource_with); -using headroom_adaptor = rmm::mr::sam_headroom_resource_adaptor; -static_assert(cuda::mr::resource_with); -static_assert(cuda::mr::async_resource_with); +using headroom_mr = rmm::mr::sam_headroom_memory_resource; +static_assert(cuda::mr::resource_with); +static_assert(cuda::mr::async_resource_with); class SystemMRTest : public ::testing::Test { protected: @@ -79,19 +79,6 @@ TEST(SystemMRSimpleTest, ThrowIfNotSupported) } } -TEST(SAMHeadroomAdaptorTest, ThrowIfNotSupported) -{ - auto construct_mr = []() { - system_mr mr; - headroom_adaptor adaptor{&mr, 0}; - }; - if (rmm::mr::detail::is_system_memory_supported(rmm::get_current_cuda_device())) { - EXPECT_NO_THROW(construct_mr()); - } else { - EXPECT_THROW(construct_mr(), rmm::logic_error); - } -} - TEST_F(SystemMRTest, FirstTouchOnCPU) { auto const free = rmm::available_device_memory().first; @@ -114,23 +101,21 @@ TEST_F(SystemMRTest, FirstTouchOnGPU) mr.deallocate(ptr, size_mb); } -TEST_F(SystemMRTest, AdaptorReserveAllFreeMemory) +TEST_F(SystemMRTest, HeadroomMRReserveAllFreeMemory) { auto const free = rmm::available_device_memory().first; - system_mr mr; // All the free GPU memory is set as headroom, so allocation is only on the CPU. - headroom_adaptor adaptor{&mr, free + size_gb}; - void* ptr = adaptor.allocate(size_mb); + headroom_mr mr{free + size_gb}; + void* ptr = mr.allocate(size_mb); touch_on_cpu(ptr, size_mb); - adaptor.deallocate(ptr, size_mb); + mr.deallocate(ptr, size_mb); } -TEST_F(SystemMRTest, AdaptorDifferentParametersUnequal) +TEST_F(SystemMRTest, HeadroomMRDifferentParametersUnequal) { - system_mr mr; - headroom_adaptor adaptor1{&mr, size_mb}; - headroom_adaptor adaptor2{&mr, size_gb}; - EXPECT_FALSE(adaptor1.is_equal(adaptor2)); + headroom_mr mr1{size_mb}; + headroom_mr mr2{size_gb}; + EXPECT_FALSE(mr1.is_equal(mr2)); } } // namespace } // namespace rmm::test From 514ba80fc9810f9ca38ffac350dc69414f4e05f6 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 31 Jul 2024 13:41:42 -0400 Subject: [PATCH 445/675] Install headers into `${CMAKE_INSTALL_INCLUDEDIR}` (#1633) Instead of installing into a hard-coded `include` directory, install to `${CMAKE_INSTALL_INCLUDEDIR}`, which defaults to `include`. Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) Approvers: - Robert Maynard (https://github.com/robertmaynard) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1633 --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93130907f..39d5dccde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,12 +142,14 @@ endif() # ################################################################################################## # * install targets -------------------------------------------------------------------------------- +include(GNUInstallDirs) include(CPack) # install export targets install(TARGETS rmm EXPORT rmm-exports) -install(DIRECTORY include/rmm/ DESTINATION include/rmm) -install(FILES ${RMM_BINARY_DIR}/include/rmm/version_config.hpp DESTINATION include/rmm) +install(DIRECTORY include/rmm/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rmm) +install(FILES ${RMM_BINARY_DIR}/include/rmm/version_config.hpp + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rmm) set(doc_string [=[ From 816713e1fdc235ff449ca732bfd622d3fd7a8c1e Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 5 Aug 2024 09:51:34 -0500 Subject: [PATCH 446/675] Fix docs cross reference in DeviceBuffer.prefetch (#1636) Closes #1635. Authors: - Bradley Dice (https://github.com/bdice) - https://github.com/jakirkham Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1636 --- python/rmm/rmm/_lib/device_buffer.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/rmm/rmm/_lib/device_buffer.pyx b/python/rmm/rmm/_lib/device_buffer.pyx index b539881e7..94a4dc771 100644 --- a/python/rmm/rmm/_lib/device_buffer.pyx +++ b/python/rmm/rmm/_lib/device_buffer.pyx @@ -149,7 +149,7 @@ cdef class DeviceBuffer: device : optional The CUDA device to which to prefetch the memory for this buffer. Defaults to the current CUDA device. To prefetch to the CPU, pass - `~cuda.cudart.cudaCpuDeviceId` as the device. + :py:attr:`~cuda.cudart.cudaCpuDeviceId` as the device. stream : optional CUDA stream to use for prefetching. Defaults to self.stream """ From 9d788cc0ece2676dc8a81079ecd1fcbf8804c72f Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Wed, 7 Aug 2024 10:43:11 -0400 Subject: [PATCH 447/675] Update Changelog [skip ci] --- CHANGELOG.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70f788615..986cf7052 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,51 @@ +# rmm 24.08.00 (7 Aug 2024) + +## 🚨 Breaking Changes + +- Add a stack to the statistics resource ([#1563](https://github.com/rapidsai/rmm/pull/1563)) [@madsbk](https://github.com/madsbk) + +## 🐛 Bug Fixes + +- Rename `.devcontainer`s for CUDA 12.5 ([#1615](https://github.com/rapidsai/rmm/pull/1615)) [@jakirkham](https://github.com/jakirkham) +- Avoid accessing statistics_resource_adaptor stack top if it is empty ([#1588](https://github.com/rapidsai/rmm/pull/1588)) [@harrism](https://github.com/harrism) +- Avoid `--find-links`. ([#1583](https://github.com/rapidsai/rmm/pull/1583)) [@bdice](https://github.com/bdice) +- Fix test_python matrix ([#1579](https://github.com/rapidsai/rmm/pull/1579)) [@KyleFromNVIDIA](https://github.com/KyleFromNVIDIA) +- Allow anonymous user in devcontainer name ([#1576](https://github.com/rapidsai/rmm/pull/1576)) [@bdice](https://github.com/bdice) + +## 📖 Documentation + +- Instruct to create associated issue in PR template. ([#1624](https://github.com/rapidsai/rmm/pull/1624)) [@harrism](https://github.com/harrism) +- add rapids-build-backend to docs ([#1614](https://github.com/rapidsai/rmm/pull/1614)) [@jameslamb](https://github.com/jameslamb) +- Revert "Remove HTML builds of librmm ([#1415)" (#1604](https://github.com/rapidsai/rmm/pull/1415)" (#1604)) [@bdice](https://github.com/bdice) +- Add documentation for CPM usage ([#1600](https://github.com/rapidsai/rmm/pull/1600)) [@pauleonix](https://github.com/pauleonix) +- Update Thrust CMake Guide link in README.md ([#1593](https://github.com/rapidsai/rmm/pull/1593)) [@pauleonix](https://github.com/pauleonix) + +## 🚀 New Features + +- Prefetch resource adaptor ([#1608](https://github.com/rapidsai/rmm/pull/1608)) [@bdice](https://github.com/bdice) +- Add python wrapper for system memory resource ([#1605](https://github.com/rapidsai/rmm/pull/1605)) [@rongou](https://github.com/rongou) +- Refactor mr_ref_tests to not depend on MR base classes ([#1589](https://github.com/rapidsai/rmm/pull/1589)) [@harrism](https://github.com/harrism) +- Add system memory resource ([#1581](https://github.com/rapidsai/rmm/pull/1581)) [@rongou](https://github.com/rongou) +- Add rmm::prefetch() and DeviceBuffer.prefetch() ([#1573](https://github.com/rapidsai/rmm/pull/1573)) [@harrism](https://github.com/harrism) + +## 🛠️ Improvements + +- split up CUDA-suffixed dependencies in dependencies.yaml ([#1627](https://github.com/rapidsai/rmm/pull/1627)) [@jameslamb](https://github.com/jameslamb) +- Remove prefetch factory. ([#1625](https://github.com/rapidsai/rmm/pull/1625)) [@bdice](https://github.com/bdice) +- Use workflow branch 24.08 again ([#1617](https://github.com/rapidsai/rmm/pull/1617)) [@KyleFromNVIDIA](https://github.com/KyleFromNVIDIA) +- Build and test with CUDA 12.5.1 ([#1607](https://github.com/rapidsai/rmm/pull/1607)) [@KyleFromNVIDIA](https://github.com/KyleFromNVIDIA) +- skip CMake 3.30.0 ([#1603](https://github.com/rapidsai/rmm/pull/1603)) [@jameslamb](https://github.com/jameslamb) +- Add RMM_USE_NVTX cmake option to provide localized control of NVTX for RMM ([#1602](https://github.com/rapidsai/rmm/pull/1602)) [@jlowe](https://github.com/jlowe) +- Use verify-alpha-spec hook ([#1601](https://github.com/rapidsai/rmm/pull/1601)) [@KyleFromNVIDIA](https://github.com/KyleFromNVIDIA) +- Avoid --find-links in wheel jobs ([#1586](https://github.com/rapidsai/rmm/pull/1586)) [@jameslamb](https://github.com/jameslamb) +- resolve dependency-file-generator warning, remove unnecessary rapids-build-backend configuration ([#1582](https://github.com/rapidsai/rmm/pull/1582)) [@jameslamb](https://github.com/jameslamb) +- Remove THRUST_WRAPPED_NAMESPACE and tests ([#1578](https://github.com/rapidsai/rmm/pull/1578)) [@harrism](https://github.com/harrism) +- Remove text builds of documentation ([#1575](https://github.com/rapidsai/rmm/pull/1575)) [@vyasr](https://github.com/vyasr) +- ensure update-version.sh preserves alpha specs ([#1572](https://github.com/rapidsai/rmm/pull/1572)) [@jameslamb](https://github.com/jameslamb) +- Add `available_device_memory` to fetch free amount of memory on a GPU ([#1567](https://github.com/rapidsai/rmm/pull/1567)) [@galipremsagar](https://github.com/galipremsagar) +- Add a stack to the statistics resource ([#1563](https://github.com/rapidsai/rmm/pull/1563)) [@madsbk](https://github.com/madsbk) +- Use rapids-build-backend. ([#1502](https://github.com/rapidsai/rmm/pull/1502)) [@bdice](https://github.com/bdice) + # rmm 24.06.00 (5 Jun 2024) ## 🚨 Breaking Changes From 203c9048ec2d67f0d963fefa90fe19497d0de564 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 7 Aug 2024 17:39:33 -0500 Subject: [PATCH 448/675] Deprecate adaptor factories. (#1626) This PR deprecates adaptor factory functions, per issue #1616. After some deprecation cycle, these functions can be removed in a later release. Authors: - Bradley Dice (https://github.com/bdice) - Mark Harris (https://github.com/harrism) Approvers: - Mark Harris (https://github.com/harrism) - Paul Mattione (https://github.com/pmattione-nvidia) URL: https://github.com/rapidsai/rmm/pull/1626 --- README.md | 2 +- .../mr/device/limiting_resource_adaptor.hpp | 3 +++ .../mr/device/logging_resource_adaptor.hpp | 9 ++++++++ .../rmm/mr/device/polymorphic_allocator.hpp | 6 ++++- .../mr/device/statistics_resource_adaptor.hpp | 4 ++++ .../mr/device/tracking_resource_adaptor.hpp | 3 +++ tests/logger_tests.cpp | 14 ++++++------ .../device/stream_allocator_adaptor_tests.cpp | 22 +++++++++---------- 8 files changed, 43 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index e1d78458f..2117f40ee 100644 --- a/README.md +++ b/README.md @@ -478,7 +478,7 @@ rmm::cuda_stream stream; rmm::mr::polymorphic_allocator stream_alloc; // Constructs an adaptor that forwards all (de)allocations to `stream_alloc` on `stream`. -auto adapted = rmm::mr::make_stream_allocator_adaptor(stream_alloc, stream); +auto adapted = rmm::mr::stream_allocator_adaptor(stream_alloc, stream); // Allocates 100 bytes using `stream_alloc` on `stream` auto p = adapted.allocate(100); diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index aa2361d1f..76a5a31c1 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -189,6 +189,9 @@ class limiting_resource_adaptor final : public device_memory_resource { * @return The new limiting resource adaptor */ template +[[deprecated( + "make_limiting_adaptor is deprecated in RMM 24.10. Use the limiting_resource_adaptor constructor " + "instead.")]] limiting_resource_adaptor make_limiting_adaptor(Upstream* upstream, std::size_t allocation_limit) { diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 61d00cafc..493d6e89e 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -284,6 +284,9 @@ class logging_resource_adaptor final : public device_memory_resource { // make_logging_adaptor needs access to private get_default_filename template // NOLINTNEXTLINE(readability-redundant-declaration) + [[deprecated( + "make_logging_adaptor is deprecated in RMM 24.10. Use the logging_resource_adaptor constructor " + "instead.")]] friend logging_resource_adaptor make_logging_adaptor(T* upstream, std::string const& filename, bool auto_flush); @@ -307,6 +310,9 @@ class logging_resource_adaptor final : public device_memory_resource { * @return The new logging resource adaptor */ template +[[deprecated( + "make_logging_adaptor is deprecated in RMM 24.10. Use the logging_resource_adaptor constructor " + "instead.")]] logging_resource_adaptor make_logging_adaptor( Upstream* upstream, std::string const& filename = logging_resource_adaptor::get_default_filename(), @@ -327,6 +333,9 @@ logging_resource_adaptor make_logging_adaptor( * @return The new logging resource adaptor */ template +[[deprecated( + "make_logging_adaptor is deprecated in RMM 24.10. Use the logging_resource_adaptor constructor " + "instead.")]] logging_resource_adaptor make_logging_adaptor(Upstream* upstream, std::ostream& stream, bool auto_flush = false) diff --git a/include/rmm/mr/device/polymorphic_allocator.hpp b/include/rmm/mr/device/polymorphic_allocator.hpp index 0b63b4691..863ba6f62 100644 --- a/include/rmm/mr/device/polymorphic_allocator.hpp +++ b/include/rmm/mr/device/polymorphic_allocator.hpp @@ -166,7 +166,7 @@ bool operator!=(polymorphic_allocator const& lhs, polymorphic_allocator co * my_stream_ordered_allocator a{...}; * cuda_stream_view s = // create stream; * - * auto adapted = make_stream_allocator_adaptor(a, s); + * auto adapted = stream_allocator_adaptor(a, s); * * // Allocates storage for `n` int's on stream `s` * int * p = std::allocator_traits::allocate(adapted, n); @@ -302,6 +302,10 @@ bool operator!=(stream_allocator_adaptor const& lhs, stream_allocator_adaptor * @return A `stream_allocator_adaptor` wrapping `allocator` and `s` */ template +[[deprecated( + "make_stream_allocator_adaptor is deprecated in RMM 24.10. Use the stream_allocator_adaptor " + "constructor " + "instead.")]] auto make_stream_allocator_adaptor(Allocator const& allocator, cuda_stream_view stream) { return stream_allocator_adaptor{allocator, stream}; diff --git a/include/rmm/mr/device/statistics_resource_adaptor.hpp b/include/rmm/mr/device/statistics_resource_adaptor.hpp index 3ee2315f2..cbf1b87d2 100644 --- a/include/rmm/mr/device/statistics_resource_adaptor.hpp +++ b/include/rmm/mr/device/statistics_resource_adaptor.hpp @@ -289,6 +289,10 @@ class statistics_resource_adaptor final : public device_memory_resource { * @return The new statistics resource adaptor */ template +[[deprecated( + "make_statistics_adaptor is deprecated in RMM 24.10. Use the statistics_resource_adaptor " + "constructor " + "instead.")]] statistics_resource_adaptor make_statistics_adaptor(Upstream* upstream) { return statistics_resource_adaptor{upstream}; diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index d01d08b9c..0d3046973 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -283,6 +283,9 @@ class tracking_resource_adaptor final : public device_memory_resource { * @return The new tracking resource adaptor */ template +[[deprecated( + "make_tracking_adaptor is deprecated in RMM 24.10. Use the tracking_resource_adaptor constructor " + "instead.")]] tracking_resource_adaptor make_tracking_adaptor(Upstream* upstream) { return tracking_resource_adaptor{upstream}; diff --git a/tests/logger_tests.cpp b/tests/logger_tests.cpp index 5e3b2f899..643281d91 100644 --- a/tests/logger_tests.cpp +++ b/tests/logger_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -186,7 +186,7 @@ TEST(Adaptor, Factory) std::string filename{temp_dir.generate_path("test.txt")}; rmm::mr::cuda_memory_resource upstream; - auto log_mr = rmm::mr::make_logging_adaptor(&upstream, filename); + auto log_mr = rmm::mr::logging_resource_adaptor(&upstream, filename); auto const size0{99}; auto const size1{42}; @@ -219,14 +219,14 @@ TEST(Adaptor, EnvironmentPath) unsetenv("RMM_LOG_FILE"); // expect logging adaptor to fail if RMM_LOG_FILE is unset - EXPECT_THROW(rmm::mr::make_logging_adaptor(&upstream), rmm::logic_error); + EXPECT_THROW(rmm::mr::logging_resource_adaptor{&upstream}, rmm::logic_error); std::string filename{temp_dir.generate_path("test.txt")}; setenv("RMM_LOG_FILE", filename.c_str(), 1); // use log file location specified in environment variable RMM_LOG_FILE - auto log_mr = rmm::mr::make_logging_adaptor(&upstream); + auto log_mr = rmm::mr::logging_resource_adaptor(&upstream); auto const size{100}; @@ -252,7 +252,7 @@ TEST(Adaptor, AllocateFailure) std::string filename{temp_dir.generate_path("failure.txt")}; rmm::mr::cuda_memory_resource upstream; - auto log_mr = rmm::mr::make_logging_adaptor(&upstream, filename); + auto log_mr = rmm::mr::logging_resource_adaptor(&upstream, filename); auto const size0{99}; auto const size1{1_TiB}; @@ -281,7 +281,7 @@ TEST(Adaptor, STDOUT) rmm::mr::cuda_memory_resource upstream; - auto log_mr = rmm::mr::make_logging_adaptor(&upstream, std::cout); + auto log_mr = rmm::mr::logging_resource_adaptor(&upstream, std::cout); auto const size{100}; @@ -299,7 +299,7 @@ TEST(Adaptor, STDERR) rmm::mr::cuda_memory_resource upstream; - auto log_mr = rmm::mr::make_logging_adaptor(&upstream, std::cerr); + auto log_mr = rmm::mr::logging_resource_adaptor(&upstream, std::cerr); auto const size{100}; diff --git a/tests/mr/device/stream_allocator_adaptor_tests.cpp b/tests/mr/device/stream_allocator_adaptor_tests.cpp index 669fca5f5..72a014bfa 100644 --- a/tests/mr/device/stream_allocator_adaptor_tests.cpp +++ b/tests/mr/device/stream_allocator_adaptor_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -34,7 +34,7 @@ struct allocator_test : public ::testing::Test { TEST_F(allocator_test, factory) { using Adaptor = rmm::mr::stream_allocator_adaptor; - auto adapted = rmm::mr::make_stream_allocator_adaptor(allocator, stream); + auto adapted = rmm::mr::stream_allocator_adaptor(allocator, stream); static_assert((std::is_same::value)); EXPECT_EQ(adapted.underlying_allocator(), allocator); EXPECT_EQ(adapted.stream(), stream); @@ -42,7 +42,7 @@ TEST_F(allocator_test, factory) TEST_F(allocator_test, self_equality) { - auto adapted = rmm::mr::make_stream_allocator_adaptor(allocator, stream); + auto adapted = rmm::mr::stream_allocator_adaptor(allocator, stream); EXPECT_EQ(adapted, adapted); EXPECT_FALSE(adapted != adapted); } @@ -50,10 +50,10 @@ TEST_F(allocator_test, self_equality) TEST_F(allocator_test, equal_allocators) { rmm::mr::polymorphic_allocator alloc0; - auto adapted0 = rmm::mr::make_stream_allocator_adaptor(alloc0, stream); + auto adapted0 = rmm::mr::stream_allocator_adaptor(alloc0, stream); rmm::mr::polymorphic_allocator alloc1; - auto adapted1 = rmm::mr::make_stream_allocator_adaptor(alloc1, stream); + auto adapted1 = rmm::mr::stream_allocator_adaptor(alloc1, stream); EXPECT_EQ(adapted0, adapted1); EXPECT_FALSE(adapted0 != adapted1); @@ -63,11 +63,11 @@ TEST_F(allocator_test, unequal_resources) { rmm::mr::cuda_memory_resource mr0; rmm::mr::polymorphic_allocator alloc0{&mr0}; - auto adapted0 = rmm::mr::make_stream_allocator_adaptor(alloc0, stream); + auto adapted0 = rmm::mr::stream_allocator_adaptor(alloc0, stream); rmm::mr::managed_memory_resource mr1; rmm::mr::polymorphic_allocator alloc1{&mr1}; - auto adapted1 = rmm::mr::make_stream_allocator_adaptor(alloc1, stream); + auto adapted1 = rmm::mr::stream_allocator_adaptor(alloc1, stream); EXPECT_NE(adapted0, adapted1); } @@ -75,7 +75,7 @@ TEST_F(allocator_test, unequal_resources) TEST_F(allocator_test, copy_ctor_same_type) { rmm::mr::polymorphic_allocator alloc0; - auto adapted0 = rmm::mr::make_stream_allocator_adaptor(alloc0, stream); + auto adapted0 = rmm::mr::stream_allocator_adaptor(alloc0, stream); using Adaptor = rmm::mr::stream_allocator_adaptor; Adaptor adapted1{adapted0}; @@ -86,7 +86,7 @@ TEST_F(allocator_test, copy_ctor_same_type) TEST_F(allocator_test, copy_ctor_different_type) { rmm::mr::polymorphic_allocator alloc0; - auto adapted0 = rmm::mr::make_stream_allocator_adaptor(alloc0, stream); + auto adapted0 = rmm::mr::stream_allocator_adaptor(alloc0, stream); using Adaptor = rmm::mr::stream_allocator_adaptor>; Adaptor adapted1{adapted0}; @@ -96,7 +96,7 @@ TEST_F(allocator_test, copy_ctor_different_type) TEST_F(allocator_test, rebind) { - auto adapted = rmm::mr::make_stream_allocator_adaptor(allocator, stream); + auto adapted = rmm::mr::stream_allocator_adaptor(allocator, stream); using Rebound = std::allocator_traits::rebind_alloc; static_assert((std::is_same::value_type, double>::value)); static_assert( @@ -108,7 +108,7 @@ TEST_F(allocator_test, rebind) TEST_F(allocator_test, allocate_deallocate) { - auto adapted = rmm::mr::make_stream_allocator_adaptor(allocator, stream); + auto adapted = rmm::mr::stream_allocator_adaptor(allocator, stream); auto const size{1000}; auto* ptr = adapted.allocate(size); EXPECT_NE(ptr, nullptr); From 83369792c854a9d91c04f23d730f0d57ce6803dd Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 7 Aug 2024 20:49:09 -0400 Subject: [PATCH 449/675] Use `tool.scikit-build.cmake.version` (#1637) `cmake.minimum-version` has been deprecated since `scikit-build-core` 0.8, and is now causing conflicts in 0.10 due to its attempts to auto-detect `cmake.version` from `CMakeLists.txt`. Bump the minimum `scikit-build-core` to 0.10 and use the suggested `cmake.version`. Contributes to https://github.com/rapidsai/build-planning/issues/58 Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) - James Lamb (https://github.com/jameslamb) - https://github.com/jakirkham Approvers: - Bradley Dice (https://github.com/bdice) - https://github.com/jakirkham URL: https://github.com/rapidsai/rmm/pull/1637 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-125_arch-x86_64.yaml | 2 +- conda/recipes/rmm/meta.yaml | 2 +- dependencies.yaml | 4 ++-- python/librmm/pyproject.toml | 5 +++-- python/rmm/pyproject.toml | 5 +++-- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index f6f179f77..365fe36c3 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -34,7 +34,7 @@ dependencies: - pytest-cov - python>=3.9,<3.12 - rapids-build-backend>=0.3.0,<0.4.0.dev0 -- scikit-build-core >=0.7.0 +- scikit-build-core >=0.10.0 - spdlog>=1.12.0,<1.13 - sphinx - sphinx-copybutton diff --git a/conda/environments/all_cuda-125_arch-x86_64.yaml b/conda/environments/all_cuda-125_arch-x86_64.yaml index feadd4835..c67269fe4 100644 --- a/conda/environments/all_cuda-125_arch-x86_64.yaml +++ b/conda/environments/all_cuda-125_arch-x86_64.yaml @@ -33,7 +33,7 @@ dependencies: - pytest-cov - python>=3.9,<3.12 - rapids-build-backend>=0.3.0,<0.4.0.dev0 -- scikit-build-core >=0.7.0 +- scikit-build-core >=0.10.0 - spdlog>=1.12.0,<1.13 - sphinx - sphinx-copybutton diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 044defdd9..ff61012cb 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -65,7 +65,7 @@ requirements: - rapids-build-backend >=0.3.0,<0.4.0.dev0 - librmm ={{ version }} - python - - scikit-build-core >=0.7.0 + - scikit-build-core >=0.10.0 run: {% if cuda_major == "11" %} - cudatoolkit diff --git a/dependencies.yaml b/dependencies.yaml index 640b0e8b9..3bc8214dc 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -97,10 +97,10 @@ dependencies: - rapids-build-backend>=0.3.0,<0.4.0.dev0 - output_types: conda packages: - - scikit-build-core >=0.7.0 + - scikit-build-core >=0.10.0 - output_types: [requirements, pyproject] packages: - - scikit-build-core[pyproject]>=0.7.0 + - scikit-build-core[pyproject]>=0.10.0 build: common: - output_types: [conda, requirements, pyproject] diff --git a/python/librmm/pyproject.toml b/python/librmm/pyproject.toml index 6bfae3000..0f0b4e397 100644 --- a/python/librmm/pyproject.toml +++ b/python/librmm/pyproject.toml @@ -16,7 +16,7 @@ build-backend = "rapids_build_backend.build" requires = [ "rapids-build-backend>=0.3.0,<0.4.0.dev0", - "scikit-build-core[pyproject]>=0.7.0", + "scikit-build-core[pyproject]>=0.10.0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. [project] @@ -55,7 +55,8 @@ requires = [ [tool.scikit-build] build-dir = "build/{wheel_tag}" cmake.build-type = "Release" -cmake.minimum-version = "3.26.4" +cmake.version = "CMakeLists.txt" +minimum-version = "build-system.requires" ninja.make-fallback = true sdist.reproducible = true wheel.packages = ["librmm"] diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 90fbfd924..172862d58 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -16,7 +16,7 @@ build-backend = "rapids_build_backend.build" requires = [ "rapids-build-backend>=0.3.0,<0.4.0.dev0", - "scikit-build-core[pyproject]>=0.7.0", + "scikit-build-core[pyproject]>=0.10.0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. [project] @@ -110,7 +110,8 @@ skip = [ [tool.scikit-build] build-dir = "build/{wheel_tag}" cmake.build-type = "Release" -cmake.minimum-version = "3.26.4" +cmake.version = "CMakeLists.txt" +minimum-version = "build-system.requires" ninja.make-fallback = true sdist.exclude = ["*tests*"] sdist.reproducible = true From 4b2e442ce28baf561eb7fa6e2c6f28a684c2cdb9 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 8 Aug 2024 10:22:00 -0500 Subject: [PATCH 450/675] Improve update-version.sh (#1640) A few small tweaks to `update-version.sh` for alignment across RAPIDS. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1640 --- ci/release/update-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index fb779048c..acec1c658 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -18,7 +18,7 @@ CURRENT_MINOR=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[2]}') CURRENT_PATCH=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[3]}') CURRENT_SHORT_TAG=${CURRENT_MAJOR}.${CURRENT_MINOR} -#Get . for next version +# Get . for next version NEXT_MAJOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[1]}') NEXT_MINOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[2]}') NEXT_SHORT_TAG=${NEXT_MAJOR}.${NEXT_MINOR} From 975c911ad59219e98b8aed1e9959120a2c877d06 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Thu, 8 Aug 2024 11:50:16 -0400 Subject: [PATCH 451/675] Update pre-commit hooks (#1643) This PR updates pre-commit hooks to the latest versions that are supported without causing style check errors. Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1643 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 835337790..a3b3e56e2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -77,7 +77,7 @@ repos: - id: ruff files: python/.*$ - repo: https://github.com/rapidsai/pre-commit-hooks - rev: v0.2.0 + rev: v0.3.1 hooks: - id: verify-copyright - id: verify-alpha-spec From 43d01db12b4655658360d4f89ac636cf637d2f48 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 14 Aug 2024 22:05:32 -0500 Subject: [PATCH 452/675] Hide visibility of non-public symbols (#1644) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1645 Contributes to https://github.com/rapidsai/build-planning/issues/33 Similar to https://github.com/rapidsai/cudf/pull/15982 Proposes more tightly controlling the visibility of symbols in the shared libraries produces for the `rmm` Python library, via the following: * compiling with `-fvisibility=hidden` by default * marking intended-to-be-public parts of `rmm` *(everything in the `rmm::` namespace)* with `__attribute__((visibility("default")))` ## Benefits of this change Reduces the risk of symbol conflicts when `rmm` is used alongside other libraries. For example, see this case in `cudf` where the `spdlog::` symbols in `rmm` are conflicting with the `spdlog::` symbols in `nvcomp`: https://github.com/rapidsai/cudf/pull/15483#discussion_r1670892743 Reduces library size by a bit (around 0.3 MB uncompressed), by reducing the size of symbol tables in DSOs. ## Notes for Reviewers This is at the very edge of my C++ knowledge, apologies in advance if I've missed something obvious 😬 # Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Bradley Dice (https://github.com/bdice) - Kyle Edwards (https://github.com/KyleFromNVIDIA) - Mark Harris (https://github.com/harrism) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1644 --- ci/build_wheel_python.sh | 6 ++- ci/check_symbols.sh | 82 +++++++++++++++++++++++++++++ python/rmm/rmm/_cuda/CMakeLists.txt | 9 +++- python/rmm/rmm/_lib/CMakeLists.txt | 9 +++- 4 files changed, 103 insertions(+), 3 deletions(-) create mode 100755 ci/check_symbols.sh diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index 22711fd04..555974b50 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -11,7 +11,7 @@ source rapids-date-string rapids-generate-version > ./VERSION -cd "${package_dir}" +pushd "${package_dir}" RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" CPP_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp /tmp/librmm_dist) @@ -29,3 +29,7 @@ mkdir -p final_dist python -m auditwheel repair -w final_dist dist/* RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 python final_dist + +# switch back to the root of the repo and check symbol visibility +popd +ci/check_symbols.sh "$(echo ${package_dir}/final_dist/rmm_*.whl)" diff --git a/ci/check_symbols.sh b/ci/check_symbols.sh new file mode 100755 index 000000000..1d73a082b --- /dev/null +++ b/ci/check_symbols.sh @@ -0,0 +1,82 @@ +#!/bin/bash +# Copyright (c) 2024, NVIDIA CORPORATION. + +set -eEuo pipefail + +echo "checking for symbol visibility issues" + +WHEEL_FILE=${1} + +raise-symbols-found-error() { + local pattern="${1}" + +err_msg="ERROR: Found some exported symbols matching the pattern '${pattern}'. + +These should be marked with 'hidden' visibility. +See https://cmake.org/cmake/help/latest/prop_tgt/LANG_VISIBILITY_PRESET.html and https://gcc.gnu.org/wiki/Visibility for details. +" + + echo "" + echo "${err_msg}" + exit 1 +} + +WHEEL_EXPORT_DIR="$(mktemp -d)" + +unzip \ + -d "${WHEEL_EXPORT_DIR}" \ + "${WHEEL_FILE}" + +dso_files=$( + find \ + "${WHEEL_EXPORT_DIR}" \ + -type f \ + \( -name '*.so' -o -name '*.so.*' \) +) + +for dso_file in ${dso_files}; do + echo "" + echo "checking exported symbols in '${dso_file}'" + symbol_file="./syms.txt" + readelf --symbols --wide "${dso_file}" \ + | c++filt \ + > "${symbol_file}" + + echo "symbol counts by type" + echo " * GLOBAL: $(grep --count -E ' GLOBAL ' < ${symbol_file})" + echo " * WEAK: $(grep --count -E ' WEAK ' < ${symbol_file})" + echo " * LOCAL: $(grep --count -E ' LOCAL ' < ${symbol_file})" + + # Explanation for '-v' uses here: + # + # * 'format_error' symbols are intentionally exported, that type of error + # can be thrown across library boundaries. See "Problems with C++ exceptions" + # at https://gcc.gnu.org/wiki/Visibility. + echo "checking for 'fmt::' symbols..." + if grep -E 'fmt\:\:' < "${symbol_file}" \ + | grep -v 'format_error' + then + raise-symbols-found-error 'fmt::' + fi + + # Explanation for '-v' uses here: + # + # * trivially-destructible objects sometimes get an entry in the symbol table + # for a specialization of `std::_Destroy_aux()` called to destroy them. + # There is one for `spdlog::details::log_msg_buffer like that: + # + # 'std::_Destroy_aux::__destroy' + # + # That should be safe to export. + # + echo "checking for 'spdlog::' symbols..." + if grep -E 'spdlog\:\:' < "${symbol_file}" \ + | grep -v 'std\:\:_Destroy_aux' + then + raise-symbols-found-error 'spdlog::' + fi + echo "No symbol visibility issues found" +done + +echo "" +echo "No symbol visibility issues found in any DSOs" diff --git a/python/rmm/rmm/_cuda/CMakeLists.txt b/python/rmm/rmm/_cuda/CMakeLists.txt index 1f17b0d2c..7fd27d110 100644 --- a/python/rmm/rmm/_cuda/CMakeLists.txt +++ b/python/rmm/rmm/_cuda/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-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 @@ -17,3 +17,10 @@ set(linked_libraries rmm::rmm) rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}" CXX) + +# mark all symbols in these Cython targets "hidden" by default, so they won't collide with symbols +# loaded from other DSOs +foreach(_cython_target IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${_cython_target} PROPERTIES C_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden) +endforeach() diff --git a/python/rmm/rmm/_lib/CMakeLists.txt b/python/rmm/rmm/_lib/CMakeLists.txt index 980217f0c..1e629a402 100644 --- a/python/rmm/rmm/_lib/CMakeLists.txt +++ b/python/rmm/rmm/_lib/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-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 @@ -19,6 +19,13 @@ set(linked_libraries rmm::rmm) rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}" CXX) +# mark all symbols in these Cython targets "hidden" by default, so they won't collide with symbols +# loaded from other DSOs +foreach(_cython_target IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${_cython_target} PROPERTIES C_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden) +endforeach() + add_library(_torch_allocator SHARED _torch_allocator.cpp) # Want the output to be called _torch_allocator.so set_target_properties(_torch_allocator PROPERTIES PREFIX "" SUFFIX ".so") From 66320edf53336bf7a97c542fe7d45a60eb7811b5 Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Wed, 21 Aug 2024 01:45:26 +0200 Subject: [PATCH 453/675] Remove NumPy <2 pin (#1650) This PR removes the NumPy<2 pin which is expected to work for RAPIDS projects once CuPy 13.3.0 is released (CuPy 13.2.0 had some issues preventing the use with NumPy 2). Authors: - Sebastian Berg (https://github.com/seberg) Approvers: - https://github.com/jakirkham URL: https://github.com/rapidsai/rmm/pull/1650 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-125_arch-x86_64.yaml | 2 +- conda/recipes/rmm/meta.yaml | 2 +- dependencies.yaml | 2 +- python/rmm/pyproject.toml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 365fe36c3..d5c1c8c55 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -26,7 +26,7 @@ dependencies: - nbsphinx - ninja - numba>=0.57 -- numpy>=1.23,<2.0a0 +- numpy>=1.23,<3.0a0 - numpydoc - nvcc_linux-64=11.8 - pre-commit diff --git a/conda/environments/all_cuda-125_arch-x86_64.yaml b/conda/environments/all_cuda-125_arch-x86_64.yaml index c67269fe4..98aa1dfdb 100644 --- a/conda/environments/all_cuda-125_arch-x86_64.yaml +++ b/conda/environments/all_cuda-125_arch-x86_64.yaml @@ -26,7 +26,7 @@ dependencies: - nbsphinx - ninja - numba>=0.57 -- numpy>=1.23,<2.0a0 +- numpy>=1.23,<3.0a0 - numpydoc - pre-commit - pytest diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index ff61012cb..fcc7424fa 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -74,7 +74,7 @@ requirements: {% endif %} - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - numba >=0.57 - - numpy >=1.23,<2.0a0 + - numpy >=1.23,<3.0a0 test: imports: diff --git a/dependencies.yaml b/dependencies.yaml index 3bc8214dc..f2bf12c15 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -278,7 +278,7 @@ dependencies: - output_types: [conda, requirements, pyproject] packages: - numba>=0.57 - - numpy>=1.23,<2.0a0 + - numpy>=1.23,<3.0a0 specific: - output_types: [conda, requirements, pyproject] matrices: diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 172862d58..a213a597b 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -32,7 +32,7 @@ requires-python = ">=3.9" dependencies = [ "cuda-python>=11.7.1,<12.0a0", "numba>=0.57", - "numpy>=1.23,<2.0a0", + "numpy>=1.23,<3.0a0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. classifiers = [ "Intended Audience :: Developers", From ed2e8acac0ebe761172215aaa54c9f3f87b21540 Mon Sep 17 00:00:00 2001 From: Rong Ou Date: Thu, 22 Aug 2024 03:25:15 -0700 Subject: [PATCH 454/675] Fix `build.sh clean` to delete python build directory (#1658) Fixes #1657 Authors: - Rong Ou (https://github.com/rongou) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1658 --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index afd26e9e6..4d61aceee 100755 --- a/build.sh +++ b/build.sh @@ -36,7 +36,7 @@ HELP="$0 [clean] [librmm] [rmm] [-v] [-g] [-n] [-s] [--ptds] [--cmake-args=\" Date: Thu, 22 Aug 2024 08:28:22 -0500 Subject: [PATCH 455/675] Drop Python 3.9 support (#1659) Contributes to https://github.com/rapidsai/build-planning/issues/88 Finishes the work of dropping Python 3.9 support. This project stopped building / testing against Python 3.9 as of https://github.com/rapidsai/shared-workflows/pull/235. This PR updates configuration and docs to reflect that. ## Notes for Reviewers ### How I tested this Checked that there were no remaining uses like this: ```shell git grep -E '3\.9' git grep '39' git grep 'py39' ``` And similar for variations on Python 3.8 (to catch things that were missed the last time this was done). Authors: - James Lamb (https://github.com/jameslamb) Approvers: - https://github.com/jakirkham URL: https://github.com/rapidsai/rmm/pull/1659 --- README.md | 2 +- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-125_arch-x86_64.yaml | 2 +- dependencies.yaml | 6 +----- python/rmm/pyproject.toml | 5 ++--- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 2117f40ee..897be2da0 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ conda install -c rapidsai -c conda-forge -c nvidia rmm cuda-version=12.0 We also provide [nightly Conda packages](https://anaconda.org/rapidsai-nightly) built from the HEAD of our latest development branch. -Note: RMM is supported only on Linux, and only tested with Python versions 3.9, 3.10, and 3.11. +Note: RMM is supported only on Linux, and only tested with Python versions 3.10 and 3.11. Note: The RMM package from Conda requires building with GCC 9 or later. Otherwise, your application may fail to build. diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index d5c1c8c55..eb56557de 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -32,7 +32,7 @@ dependencies: - pre-commit - pytest - pytest-cov -- python>=3.9,<3.12 +- python>=3.10,<3.12 - rapids-build-backend>=0.3.0,<0.4.0.dev0 - scikit-build-core >=0.10.0 - spdlog>=1.12.0,<1.13 diff --git a/conda/environments/all_cuda-125_arch-x86_64.yaml b/conda/environments/all_cuda-125_arch-x86_64.yaml index 98aa1dfdb..6e286d01e 100644 --- a/conda/environments/all_cuda-125_arch-x86_64.yaml +++ b/conda/environments/all_cuda-125_arch-x86_64.yaml @@ -31,7 +31,7 @@ dependencies: - pre-commit - pytest - pytest-cov -- python>=3.9,<3.12 +- python>=3.10,<3.12 - rapids-build-backend>=0.3.0,<0.4.0.dev0 - scikit-build-core >=0.10.0 - spdlog>=1.12.0,<1.13 diff --git a/dependencies.yaml b/dependencies.yaml index f2bf12c15..ef2de69ed 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -258,10 +258,6 @@ dependencies: specific: - output_types: conda matrices: - - matrix: - py: "3.9" - packages: - - python=3.9 - matrix: py: "3.10" packages: @@ -272,7 +268,7 @@ dependencies: - python=3.11 - matrix: packages: - - python>=3.9,<3.12 + - python>=3.10,<3.12 run: common: - output_types: [conda, requirements, pyproject] diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index a213a597b..2ecccbee0 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -28,7 +28,7 @@ authors = [ { name = "NVIDIA Corporation" }, ] license = { text = "Apache 2.0" } -requires-python = ">=3.9" +requires-python = ">=3.10" dependencies = [ "cuda-python>=11.7.1,<12.0a0", "numba>=0.57", @@ -40,7 +40,6 @@ classifiers = [ "Topic :: Scientific/Engineering", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", ] @@ -56,7 +55,7 @@ Homepage = "https://github.com/rapidsai/rmm" [tool.black] line-length = 79 -target-version = ["py39"] +target-version = ["py310"] include = '\.py?$' exclude = ''' /( From 1555d6ca70a180952eebf535c17360e211480162 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 22 Aug 2024 13:03:05 -0400 Subject: [PATCH 456/675] Explicitly mark RMM headers with `RMM_EXPORT` (#1654) Fixes https://github.com/rapidsai/rmm/issues/1652 Authors: - Robert Maynard (https://github.com/robertmaynard) - James Lamb (https://github.com/jameslamb) - Lawrence Mitchell (https://github.com/wence-) Approvers: - James Lamb (https://github.com/jameslamb) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1654 --- doxygen/Doxyfile | 8 ++++---- include/rmm/aligned.hpp | 6 ++++-- include/rmm/cuda_device.hpp | 5 +++-- include/rmm/cuda_stream.hpp | 7 ++++--- include/rmm/cuda_stream_pool.hpp | 7 ++++--- include/rmm/cuda_stream_view.hpp | 7 ++++--- include/rmm/detail/aligned.hpp | 7 +++++-- include/rmm/detail/dynamic_load_runtime.hpp | 9 ++++++--- include/rmm/detail/export.hpp | 7 ++++--- include/rmm/detail/stack_trace.hpp | 9 ++++++--- include/rmm/device_buffer.hpp | 7 ++++--- include/rmm/device_scalar.hpp | 5 +++-- include/rmm/device_uvector.hpp | 7 ++++--- include/rmm/device_vector.hpp | 7 ++++--- include/rmm/error.hpp | 6 ++++-- include/rmm/exec_policy.hpp | 5 +++-- include/rmm/logger.hpp | 8 +++++--- include/rmm/mr/device/aligned_resource_adaptor.hpp | 7 +++++-- include/rmm/mr/device/arena_memory_resource.hpp | 7 +++++-- include/rmm/mr/device/binning_memory_resource.hpp | 7 +++++-- include/rmm/mr/device/callback_memory_resource.hpp | 7 +++++-- include/rmm/mr/device/cuda_async_memory_resource.hpp | 7 +++++-- .../rmm/mr/device/cuda_async_view_memory_resource.hpp | 7 +++++-- include/rmm/mr/device/cuda_memory_resource.hpp | 7 +++++-- include/rmm/mr/device/detail/arena.hpp | 7 +++++-- include/rmm/mr/device/detail/coalescing_free_list.hpp | 9 ++++++--- include/rmm/mr/device/detail/fixed_size_free_list.hpp | 9 ++++++--- include/rmm/mr/device/detail/free_list.hpp | 10 +++++++--- .../device/detail/stream_ordered_memory_resource.hpp | 7 +++++-- include/rmm/mr/device/device_memory_resource.hpp | 7 +++++-- .../mr/device/failure_callback_resource_adaptor.hpp | 7 +++++-- include/rmm/mr/device/fixed_size_memory_resource.hpp | 7 +++++-- include/rmm/mr/device/limiting_resource_adaptor.hpp | 7 +++++-- include/rmm/mr/device/logging_resource_adaptor.hpp | 7 +++++-- include/rmm/mr/device/managed_memory_resource.hpp | 7 +++++-- include/rmm/mr/device/owning_wrapper.hpp | 7 +++++-- include/rmm/mr/device/per_device_resource.hpp | 6 ++++-- include/rmm/mr/device/polymorphic_allocator.hpp | 7 +++++-- include/rmm/mr/device/pool_memory_resource.hpp | 7 +++++-- include/rmm/mr/device/prefetch_resource_adaptor.hpp | 7 +++++-- include/rmm/mr/device/sam_headroom_memory_resource.hpp | 7 +++++-- include/rmm/mr/device/statistics_resource_adaptor.hpp | 7 +++++-- include/rmm/mr/device/system_memory_resource.hpp | 7 +++++-- include/rmm/mr/device/thread_safe_resource_adaptor.hpp | 7 +++++-- include/rmm/mr/device/thrust_allocator_adaptor.hpp | 9 ++++++--- include/rmm/mr/device/tracking_resource_adaptor.hpp | 7 +++++-- include/rmm/mr/host/host_memory_resource.hpp | 7 +++++-- include/rmm/mr/host/new_delete_resource.hpp | 7 +++++-- include/rmm/mr/host/pinned_memory_resource.hpp | 7 +++++-- include/rmm/mr/is_resource_adaptor.hpp | 8 ++++++-- include/rmm/mr/pinned_host_memory_resource.hpp | 7 +++++-- include/rmm/prefetch.hpp | 5 +++-- include/rmm/resource_ref.hpp | 6 ++++-- 53 files changed, 253 insertions(+), 122 deletions(-) diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 434e92e05..7e13fa95b 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -2136,7 +2136,7 @@ ENABLE_PREPROCESSING = YES # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -MACRO_EXPANSION = NO +MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then # the macro expansion is limited to the macros specified with the PREDEFINED and @@ -2144,7 +2144,7 @@ MACRO_EXPANSION = NO # The default value is: NO. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_ONLY_PREDEF = NO +EXPAND_ONLY_PREDEF = YES # If the SEARCH_INCLUDES tag is set to YES, the include files in the # INCLUDE_PATH will be searched if a #include is found. @@ -2176,7 +2176,7 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = +PREDEFINED = RMM_NAMESPACE=rmm RMM_EXPORT # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The @@ -2185,7 +2185,7 @@ PREDEFINED = # definition found in the source code. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = RMM_NAMESPACE # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will # remove all references to function-like macros that are alone on a line, have diff --git a/include/rmm/aligned.hpp b/include/rmm/aligned.hpp index 6e9970ab8..cf032fc94 100644 --- a/include/rmm/aligned.hpp +++ b/include/rmm/aligned.hpp @@ -16,11 +16,13 @@ #pragma once +#include + #include #include #include -namespace rmm { +namespace RMM_NAMESPACE { /** * @addtogroup utilities @@ -123,4 +125,4 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; /** @} */ // end of group -} // namespace rmm +} // namespace RMM_NAMESPACE diff --git a/include/rmm/cuda_device.hpp b/include/rmm/cuda_device.hpp index 32a6b763d..124404679 100644 --- a/include/rmm/cuda_device.hpp +++ b/include/rmm/cuda_device.hpp @@ -17,10 +17,11 @@ #include #include +#include #include -namespace rmm { +namespace RMM_NAMESPACE { struct cuda_device_id; inline cuda_device_id get_current_cuda_device(); @@ -175,4 +176,4 @@ struct cuda_set_device_raii { }; /** @} */ // end of group -} // namespace rmm +} // namespace RMM_NAMESPACE diff --git a/include/rmm/cuda_stream.hpp b/include/rmm/cuda_stream.hpp index 197095c39..df1dde86b 100644 --- a/include/rmm/cuda_stream.hpp +++ b/include/rmm/cuda_stream.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -25,7 +26,7 @@ #include #include -namespace rmm { +namespace RMM_NAMESPACE { /** * @addtogroup cuda_streams * @{ @@ -139,4 +140,4 @@ class cuda_stream { }; /** @} */ // end of group -} // namespace rmm +} // namespace RMM_NAMESPACE diff --git a/include/rmm/cuda_stream_pool.hpp b/include/rmm/cuda_stream_pool.hpp index 9eb341057..0d84d8798 100644 --- a/include/rmm/cuda_stream_pool.hpp +++ b/include/rmm/cuda_stream_pool.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -19,12 +19,13 @@ #include #include #include +#include #include #include #include -namespace rmm { +namespace RMM_NAMESPACE { /** * @addtogroup cuda_streams * @{ @@ -102,4 +103,4 @@ class cuda_stream_pool { }; /** @} */ // end of group -} // namespace rmm +} // namespace RMM_NAMESPACE diff --git a/include/rmm/cuda_stream_view.hpp b/include/rmm/cuda_stream_view.hpp index a34897df6..2aaa17a59 100644 --- a/include/rmm/cuda_stream_view.hpp +++ b/include/rmm/cuda_stream_view.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -17,6 +17,7 @@ #pragma once #include +#include #include #include @@ -25,7 +26,7 @@ #include #include -namespace rmm { +namespace RMM_NAMESPACE { /** * @addtogroup cuda_streams * @{ @@ -201,4 +202,4 @@ inline std::ostream& operator<<(std::ostream& os, cuda_stream_view stream) } /** @} */ // end of group -} // namespace rmm +} // namespace RMM_NAMESPACE diff --git a/include/rmm/detail/aligned.hpp b/include/rmm/detail/aligned.hpp index 1206a1983..6d4f5244f 100644 --- a/include/rmm/detail/aligned.hpp +++ b/include/rmm/detail/aligned.hpp @@ -17,6 +17,7 @@ #pragma once #include +#include #include #include @@ -24,7 +25,8 @@ #include #include -namespace rmm::detail { +namespace RMM_NAMESPACE { +namespace detail { /** * @brief Allocates sufficient host-accessible memory to satisfy the requested size `bytes` with @@ -112,4 +114,5 @@ void aligned_host_deallocate(void* ptr, dealloc(original); } -} // namespace rmm::detail +} // namespace detail +} // namespace RMM_NAMESPACE diff --git a/include/rmm/detail/dynamic_load_runtime.hpp b/include/rmm/detail/dynamic_load_runtime.hpp index 43626144a..214228752 100644 --- a/include/rmm/detail/dynamic_load_runtime.hpp +++ b/include/rmm/detail/dynamic_load_runtime.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -16,6 +16,7 @@ #pragma once #include +#include #include @@ -24,7 +25,8 @@ #include #include -namespace rmm::detail { +namespace RMM_NAMESPACE { +namespace detail { /** * @brief `dynamic_load_runtime` loads the cuda runtime library at runtime @@ -185,4 +187,5 @@ struct async_alloc { #endif #undef RMM_CUDART_API_WRAPPER -} // namespace rmm::detail +} // namespace detail +} // namespace RMM_NAMESPACE diff --git a/include/rmm/detail/export.hpp b/include/rmm/detail/export.hpp index 087303a03..90fa8d173 100644 --- a/include/rmm/detail/export.hpp +++ b/include/rmm/detail/export.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-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. @@ -18,8 +18,9 @@ // Macros used for defining symbol visibility, only GLIBC is supported #if (defined(__GNUC__) && !defined(__MINGW32__) && !defined(__MINGW64__)) -#define RMM_EXPORT __attribute__((visibility("default"))) -#define RMM_HIDDEN __attribute__((visibility("hidden"))) +#define RMM_EXPORT __attribute__((visibility("default"))) +#define RMM_HIDDEN __attribute__((visibility("hidden"))) +#define RMM_NAMESPACE RMM_EXPORT rmm #else #define RMM_EXPORT #define RMM_HIDDEN diff --git a/include/rmm/detail/stack_trace.hpp b/include/rmm/detail/stack_trace.hpp index f658fe7ad..7b3d40bd2 100644 --- a/include/rmm/detail/stack_trace.hpp +++ b/include/rmm/detail/stack_trace.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -17,6 +17,7 @@ #pragma once #include +#include // execinfo is a linux-only library, so stack traces will only be available on // linux systems. @@ -36,7 +37,8 @@ #include #endif -namespace rmm::detail { +namespace RMM_NAMESPACE { +namespace detail { /** * @brief stack_trace is a class that will capture a stack on instantiation for output later. @@ -102,4 +104,5 @@ class stack_trace { #endif // RMM_ENABLE_STACK_TRACES }; -} // namespace rmm::detail +} // namespace detail +} // namespace RMM_NAMESPACE diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index 4663b5733..e6664e0f6 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -29,7 +30,7 @@ #include #include -namespace rmm { +namespace RMM_NAMESPACE { /** * @addtogroup data_containers * @{ @@ -479,4 +480,4 @@ class device_buffer { }; /** @} */ // end of group -} // namespace rmm +} // namespace RMM_NAMESPACE diff --git a/include/rmm/device_scalar.hpp b/include/rmm/device_scalar.hpp index 47eed78b2..95388eca9 100644 --- a/include/rmm/device_scalar.hpp +++ b/include/rmm/device_scalar.hpp @@ -17,13 +17,14 @@ #pragma once #include +#include #include #include #include #include -namespace rmm { +namespace RMM_NAMESPACE { /** * @addtogroup data_containers * @{ @@ -277,4 +278,4 @@ class device_scalar { }; /** @} */ // end of group -} // namespace rmm +} // namespace RMM_NAMESPACE diff --git a/include/rmm/device_uvector.hpp b/include/rmm/device_uvector.hpp index ff6a7d837..e1610a73a 100644 --- a/include/rmm/device_uvector.hpp +++ b/include/rmm/device_uvector.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -28,7 +29,7 @@ #include #include -namespace rmm { +namespace RMM_NAMESPACE { /** * @addtogroup data_containers * @{ @@ -565,4 +566,4 @@ class device_uvector { }; /** @} */ // end of group -} // namespace rmm +} // namespace RMM_NAMESPACE diff --git a/include/rmm/device_vector.hpp b/include/rmm/device_vector.hpp index 64fd8b993..9dad109a0 100644 --- a/include/rmm/device_vector.hpp +++ b/include/rmm/device_vector.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -16,12 +16,13 @@ #pragma once +#include #include #include #include -namespace rmm { +namespace RMM_NAMESPACE { /** * @addtogroup thrust_integrations * @{ @@ -35,4 +36,4 @@ template using device_vector = thrust::device_vector>; /** @} */ // end of group -} // namespace rmm +} // namespace RMM_NAMESPACE diff --git a/include/rmm/error.hpp b/include/rmm/error.hpp index 18ba9303e..75bf1fbe4 100644 --- a/include/rmm/error.hpp +++ b/include/rmm/error.hpp @@ -16,10 +16,12 @@ #pragma once +#include + #include #include -namespace rmm { +namespace RMM_NAMESPACE { /** * @brief Exception thrown when logical precondition is violated. @@ -109,4 +111,4 @@ class out_of_range : public std::out_of_range { using std::out_of_range::out_of_range; }; -} // namespace rmm +} // namespace RMM_NAMESPACE diff --git a/include/rmm/exec_policy.hpp b/include/rmm/exec_policy.hpp index a343afb8b..1c9a07abd 100644 --- a/include/rmm/exec_policy.hpp +++ b/include/rmm/exec_policy.hpp @@ -22,6 +22,7 @@ #pragma once #include +#include #include #include #include @@ -29,7 +30,7 @@ #include #include -namespace rmm { +namespace RMM_NAMESPACE { /** * @addtogroup thrust_integrations * @{ @@ -97,4 +98,4 @@ using exec_policy_nosync = #endif /** @} */ // end of group -} // namespace rmm +} // namespace RMM_NAMESPACE diff --git a/include/rmm/logger.hpp b/include/rmm/logger.hpp index 6213221ab..e60501d2b 100644 --- a/include/rmm/logger.hpp +++ b/include/rmm/logger.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2023, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -16,6 +16,8 @@ #pragma once +#include + #include #include #include @@ -25,7 +27,7 @@ #include #include -namespace rmm { +namespace RMM_NAMESPACE { namespace detail { @@ -125,7 +127,7 @@ inline spdlog::logger& logger() //! @endcond -} // namespace rmm +} // namespace RMM_NAMESPACE // Doxygen doesn't like this because we're overloading something from fmt //! @cond Doxygen_Suppress diff --git a/include/rmm/mr/device/aligned_resource_adaptor.hpp b/include/rmm/mr/device/aligned_resource_adaptor.hpp index a91056dfa..85eddb427 100644 --- a/include/rmm/mr/device/aligned_resource_adaptor.hpp +++ b/include/rmm/mr/device/aligned_resource_adaptor.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -26,7 +27,8 @@ #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_resource_adaptors * @{ @@ -194,4 +196,5 @@ class aligned_resource_adaptor final : public device_memory_resource { }; /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index b274e0c18..388182e6a 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -31,7 +32,8 @@ #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_memory_resources * @{ @@ -342,4 +344,5 @@ class arena_memory_resource final : public device_memory_resource { }; /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/binning_memory_resource.hpp b/include/rmm/mr/device/binning_memory_resource.hpp index 2649a17b8..773035231 100644 --- a/include/rmm/mr/device/binning_memory_resource.hpp +++ b/include/rmm/mr/device/binning_memory_resource.hpp @@ -16,6 +16,7 @@ #pragma once #include +#include #include #include #include @@ -28,7 +29,8 @@ #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_memory_resources * @{ @@ -194,4 +196,5 @@ class binning_memory_resource final : public device_memory_resource { }; /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/callback_memory_resource.hpp b/include/rmm/mr/device/callback_memory_resource.hpp index 1483925de..c569f7dd6 100644 --- a/include/rmm/mr/device/callback_memory_resource.hpp +++ b/include/rmm/mr/device/callback_memory_resource.hpp @@ -15,13 +15,15 @@ */ #pragma once +#include #include #include #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_memory_resources * @{ @@ -145,4 +147,5 @@ class callback_memory_resource final : public device_memory_resource { }; /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index a51e6b886..52fd2fe4e 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -36,7 +37,8 @@ #endif #endif -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_memory_resources * @{ @@ -220,4 +222,5 @@ class cuda_async_memory_resource final : public device_memory_resource { }; /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index 9ca695b9d..3e1900e72 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -31,7 +32,8 @@ #define RMM_CUDA_MALLOC_ASYNC_SUPPORT #endif -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_memory_resources * @{ @@ -155,4 +157,5 @@ class cuda_async_view_memory_resource final : public device_memory_resource { }; /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/cuda_memory_resource.hpp b/include/rmm/mr/device/cuda_memory_resource.hpp index 16100b06a..4e88ac81e 100644 --- a/include/rmm/mr/device/cuda_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_memory_resource.hpp @@ -17,11 +17,13 @@ #include #include +#include #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_memory_resources * @{ @@ -94,4 +96,5 @@ class cuda_memory_resource final : public device_memory_resource { } }; /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/detail/arena.hpp b/include/rmm/mr/device/detail/arena.hpp index c7965ca34..3d24cfebf 100644 --- a/include/rmm/mr/device/detail/arena.hpp +++ b/include/rmm/mr/device/detail/arena.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -37,7 +38,8 @@ #include #include -namespace rmm::mr::detail::arena { +namespace RMM_NAMESPACE { +namespace mr::detail::arena { /** * @brief Align up to nearest size class. @@ -998,4 +1000,5 @@ class arena_cleaner { std::weak_ptr> arena_; }; -} // namespace rmm::mr::detail::arena +} // namespace mr::detail::arena +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/detail/coalescing_free_list.hpp b/include/rmm/mr/device/detail/coalescing_free_list.hpp index dbc706117..8d5cbf9ed 100644 --- a/include/rmm/mr/device/detail/coalescing_free_list.hpp +++ b/include/rmm/mr/device/detail/coalescing_free_list.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2023, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -17,6 +17,7 @@ #pragma once #include +#include #include #include @@ -28,7 +29,8 @@ #include #include -namespace rmm::mr::detail { +namespace RMM_NAMESPACE { +namespace mr::detail { /** * @brief A simple block structure specifying the size and location of a block @@ -267,4 +269,5 @@ struct coalescing_free_list : free_list { #endif }; // coalescing_free_list -} // namespace rmm::mr::detail +} // namespace mr::detail +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/detail/fixed_size_free_list.hpp b/include/rmm/mr/device/detail/fixed_size_free_list.hpp index ad26904c2..deb0e1646 100644 --- a/include/rmm/mr/device/detail/fixed_size_free_list.hpp +++ b/include/rmm/mr/device/detail/fixed_size_free_list.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -16,12 +16,14 @@ #pragma once +#include #include #include #include -namespace rmm::mr::detail { +namespace RMM_NAMESPACE { +namespace mr::detail { struct fixed_size_free_list : free_list { fixed_size_free_list() = default; @@ -75,4 +77,5 @@ struct fixed_size_free_list : free_list { } }; -} // namespace rmm::mr::detail +} // namespace mr::detail +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/detail/free_list.hpp b/include/rmm/mr/device/detail/free_list.hpp index d4d42c122..07b1dbcae 100644 --- a/include/rmm/mr/device/detail/free_list.hpp +++ b/include/rmm/mr/device/detail/free_list.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -16,11 +16,14 @@ #pragma once +#include + #include #include #include -namespace rmm::mr::detail { +namespace RMM_NAMESPACE { +namespace mr::detail { struct block_base { void* ptr{}; ///< Raw memory pointer @@ -179,4 +182,5 @@ class free_list { list_type blocks; // The internal container of blocks }; -} // namespace rmm::mr::detail +} // namespace mr::detail +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index c7c8d9178..9cf674d6e 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -30,7 +31,8 @@ #include #include -namespace rmm::mr::detail { +namespace RMM_NAMESPACE { +namespace mr::detail { /** * @brief A CRTP helper function @@ -490,4 +492,5 @@ class stream_ordered_memory_resource : public crtp, public device_ rmm::cuda_device_id device_id_{rmm::get_current_cuda_device()}; }; // namespace detail -} // namespace rmm::mr::detail +} // namespace mr::detail +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index 783dff2ed..aae9aeaf2 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -24,7 +25,8 @@ #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_memory_resources * @{ @@ -358,4 +360,5 @@ class device_memory_resource { }; static_assert(cuda::mr::async_resource_with); /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp index 53bc572c2..eeebaac3b 100644 --- a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp +++ b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp @@ -16,6 +16,7 @@ #pragma once #include +#include #include #include @@ -23,7 +24,8 @@ #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_resource_adaptors * @{ @@ -193,4 +195,5 @@ class failure_callback_resource_adaptor final : public device_memory_resource { }; /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index da9476b1e..84cb3b0c6 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,8 @@ #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_memory_resources * @{ @@ -262,4 +264,5 @@ class fixed_size_memory_resource }; /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index 76a5a31c1..c3ef72e09 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -17,12 +17,14 @@ #include #include +#include #include #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_resource_adaptors * @{ @@ -199,4 +201,5 @@ limiting_resource_adaptor make_limiting_adaptor(Upstream* upstream, } /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 493d6e89e..6f6cd816a 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -31,7 +32,8 @@ #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_resource_adaptors * @{ @@ -344,4 +346,5 @@ logging_resource_adaptor make_logging_adaptor(Upstream* upstream, } /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/managed_memory_resource.hpp b/include/rmm/mr/device/managed_memory_resource.hpp index ea43315de..6fc0cdd4c 100644 --- a/include/rmm/mr/device/managed_memory_resource.hpp +++ b/include/rmm/mr/device/managed_memory_resource.hpp @@ -17,11 +17,13 @@ #include #include +#include #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_memory_resources * @{ @@ -99,4 +101,5 @@ class managed_memory_resource final : public device_memory_resource { }; /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/owning_wrapper.hpp b/include/rmm/mr/device/owning_wrapper.hpp index f8c10e76d..0fa28d59e 100644 --- a/include/rmm/mr/device/owning_wrapper.hpp +++ b/include/rmm/mr/device/owning_wrapper.hpp @@ -15,6 +15,7 @@ */ #pragma once +#include #include #include @@ -22,7 +23,8 @@ #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { namespace detail { /** * @brief Converts a tuple into a parameter pack. @@ -270,4 +272,5 @@ auto make_owning_wrapper(std::shared_ptr upstream, Args&&... args) } /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/per_device_resource.hpp b/include/rmm/mr/device/per_device_resource.hpp index a56a784a1..1319f9e94 100644 --- a/include/rmm/mr/device/per_device_resource.hpp +++ b/include/rmm/mr/device/per_device_resource.hpp @@ -81,7 +81,8 @@ * @endcode */ -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup memory_resources * @{ @@ -248,4 +249,5 @@ inline device_memory_resource* set_current_device_resource(device_memory_resourc return set_per_device_resource(rmm::get_current_cuda_device(), new_mr); } /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/polymorphic_allocator.hpp b/include/rmm/mr/device/polymorphic_allocator.hpp index 863ba6f62..6fb068410 100644 --- a/include/rmm/mr/device/polymorphic_allocator.hpp +++ b/include/rmm/mr/device/polymorphic_allocator.hpp @@ -17,6 +17,7 @@ #pragma once #include +#include #include #include @@ -24,7 +25,8 @@ #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_memory_resources * @{ @@ -311,4 +313,5 @@ auto make_stream_allocator_adaptor(Allocator const& allocator, cuda_stream_view return stream_allocator_adaptor{allocator, stream}; } /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index a3a972904..d22b53404 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -46,7 +47,8 @@ #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_memory_resources * @{ @@ -477,4 +479,5 @@ class pool_memory_resource final }; // namespace mr /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/prefetch_resource_adaptor.hpp b/include/rmm/mr/device/prefetch_resource_adaptor.hpp index 48a64a5b9..59ce8e036 100644 --- a/include/rmm/mr/device/prefetch_resource_adaptor.hpp +++ b/include/rmm/mr/device/prefetch_resource_adaptor.hpp @@ -15,6 +15,7 @@ */ #pragma once +#include #include #include #include @@ -24,7 +25,8 @@ #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_resource_adaptors * @{ @@ -126,4 +128,5 @@ class prefetch_resource_adaptor final : public device_memory_resource { }; /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/sam_headroom_memory_resource.hpp b/include/rmm/mr/device/sam_headroom_memory_resource.hpp index cdf14181f..db5d8034f 100644 --- a/include/rmm/mr/device/sam_headroom_memory_resource.hpp +++ b/include/rmm/mr/device/sam_headroom_memory_resource.hpp @@ -17,11 +17,13 @@ #include #include +#include #include #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_memory_resources * @{ @@ -130,4 +132,5 @@ class sam_headroom_memory_resource final : public device_memory_resource { std::size_t headroom_; }; /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/statistics_resource_adaptor.hpp b/include/rmm/mr/device/statistics_resource_adaptor.hpp index cbf1b87d2..bf78c669a 100644 --- a/include/rmm/mr/device/statistics_resource_adaptor.hpp +++ b/include/rmm/mr/device/statistics_resource_adaptor.hpp @@ -15,6 +15,7 @@ */ #pragma once +#include #include #include @@ -23,7 +24,8 @@ #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_resource_adaptors * @{ @@ -299,4 +301,5 @@ statistics_resource_adaptor make_statistics_adaptor(Upstream* upstream } /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/system_memory_resource.hpp b/include/rmm/mr/device/system_memory_resource.hpp index 39d8504a9..a32685e86 100644 --- a/include/rmm/mr/device/system_memory_resource.hpp +++ b/include/rmm/mr/device/system_memory_resource.hpp @@ -18,9 +18,11 @@ #include #include #include +#include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { namespace detail { /** @@ -153,4 +155,5 @@ class system_memory_resource final : public device_memory_resource { static_assert(cuda::mr::async_resource_with); static_assert(cuda::mr::async_resource_with); /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp index 64a6f8ad5..9979d1e08 100644 --- a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp +++ b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp @@ -17,13 +17,15 @@ #include #include +#include #include #include #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_resource_adaptors * @{ @@ -129,4 +131,5 @@ class thread_safe_resource_adaptor final : public device_memory_resource { }; /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/thrust_allocator_adaptor.hpp b/include/rmm/mr/device/thrust_allocator_adaptor.hpp index 3bfd65996..2055a0633 100644 --- a/include/rmm/mr/device/thrust_allocator_adaptor.hpp +++ b/include/rmm/mr/device/thrust_allocator_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -17,6 +17,7 @@ #pragma once #include +#include #include #include #include @@ -26,7 +27,8 @@ #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_resource_adaptors * @{ @@ -152,4 +154,5 @@ class thrust_allocator : public thrust::device_malloc_allocator { cuda_device_id _device{get_current_cuda_device()}; }; /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index 0d3046973..3d3188b23 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -16,6 +16,7 @@ #pragma once #include +#include #include #include #include @@ -29,7 +30,8 @@ #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup device_resource_adaptors * @{ @@ -292,4 +294,5 @@ tracking_resource_adaptor make_tracking_adaptor(Upstream* upstream) } /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/host/host_memory_resource.hpp b/include/rmm/mr/host/host_memory_resource.hpp index d8bb311c8..71c63cfb3 100644 --- a/include/rmm/mr/host/host_memory_resource.hpp +++ b/include/rmm/mr/host/host_memory_resource.hpp @@ -15,6 +15,7 @@ */ #pragma once +#include #include #include @@ -22,7 +23,8 @@ #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup host_memory_resources * @{ @@ -202,4 +204,5 @@ class host_memory_resource { static_assert(cuda::mr::resource_with); /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/host/new_delete_resource.hpp b/include/rmm/mr/host/new_delete_resource.hpp index a48f61447..c7ad4a758 100644 --- a/include/rmm/mr/host/new_delete_resource.hpp +++ b/include/rmm/mr/host/new_delete_resource.hpp @@ -17,12 +17,14 @@ #include #include +#include #include #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup host_memory_resources * @{ @@ -91,4 +93,5 @@ class new_delete_resource final : public host_memory_resource { }; /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/host/pinned_memory_resource.hpp b/include/rmm/mr/host/pinned_memory_resource.hpp index 75af35343..6d9e419b0 100644 --- a/include/rmm/mr/host/pinned_memory_resource.hpp +++ b/include/rmm/mr/host/pinned_memory_resource.hpp @@ -19,12 +19,14 @@ #include #include #include +#include #include #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup host_memory_resources * @{ @@ -153,4 +155,5 @@ static_assert(cuda::mr::async_resource_with); /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/is_resource_adaptor.hpp b/include/rmm/mr/is_resource_adaptor.hpp index 96989c14f..64f0e61d2 100644 --- a/include/rmm/mr/is_resource_adaptor.hpp +++ b/include/rmm/mr/is_resource_adaptor.hpp @@ -15,10 +15,13 @@ */ #pragma once +#include + #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup memory_resources @@ -40,4 +43,5 @@ inline constexpr bool is_resource_adaptor< cuda::mr::resource; /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/pinned_host_memory_resource.hpp b/include/rmm/mr/pinned_host_memory_resource.hpp index 6bca05376..0b23d9112 100644 --- a/include/rmm/mr/pinned_host_memory_resource.hpp +++ b/include/rmm/mr/pinned_host_memory_resource.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -27,7 +28,8 @@ #include #include -namespace rmm::mr { +namespace RMM_NAMESPACE { +namespace mr { /** * @addtogroup memory_resources @@ -213,4 +215,5 @@ static_assert(cuda::mr::async_resource_with); /** @} */ // end of group -} // namespace rmm::mr +} // namespace mr +} // namespace RMM_NAMESPACE diff --git a/include/rmm/prefetch.hpp b/include/rmm/prefetch.hpp index 205a4d241..5d778be4f 100644 --- a/include/rmm/prefetch.hpp +++ b/include/rmm/prefetch.hpp @@ -18,11 +18,12 @@ #include #include +#include #include #include -namespace rmm { +namespace RMM_NAMESPACE { /** * @addtogroup utilities @@ -74,4 +75,4 @@ void prefetch(cuda::std::span data, /** @} */ // end of group -} // namespace rmm +} // namespace RMM_NAMESPACE diff --git a/include/rmm/resource_ref.hpp b/include/rmm/resource_ref.hpp index e71613fe9..08942a040 100644 --- a/include/rmm/resource_ref.hpp +++ b/include/rmm/resource_ref.hpp @@ -15,9 +15,11 @@ */ #pragma once +#include + #include -namespace rmm { +namespace RMM_NAMESPACE { /** * @addtogroup memory_resources @@ -64,4 +66,4 @@ using host_device_async_resource_ref = cuda::mr::async_resource_ref; /** @} */ // end of group -} // namespace rmm +} // namespace RMM_NAMESPACE From 8adedd09f9c0d106e5aaed6c35ff63557b6df077 Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Thu, 22 Aug 2024 22:55:30 +0200 Subject: [PATCH 457/675] Allow testing of earliest/latest dependencies (#1613) Mostly identical to gh-1606, which allows the testing of oldest/latest dependencies. What oldest/latest dependencies means exactly has to be set by each project in their `dependencies.yaml` file for the test env. See https://github.com/rapidsai/shared-workflows/pull/228 for the workflow changes. This is part of preparing for 2.0 (which should just work, but in the end no need to include it in the same PR). *Modifications from draft PR:* - I renamed it to `oldest`, as suggested by Matthew. - Noticed that the name is different between wheel and conda workflows, so modified both to include all matrix information. (Draft, since the shared workflow should be pushed in first to revert the branch renaming probably. Need to test that the wheel workflow is correct.) Authors: - Sebastian Berg (https://github.com/seberg) - Bradley Dice (https://github.com/bdice) Approvers: - James Lamb (https://github.com/jameslamb) - https://github.com/jakirkham URL: https://github.com/rapidsai/rmm/pull/1613 --- ci/test_python.sh | 2 +- ci/test_wheel.sh | 15 ++++++++++++++- dependencies.yaml | 10 ++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ci/test_python.sh b/ci/test_python.sh index 3239beaf1..386d0b063 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -12,7 +12,7 @@ rapids-logger "Create test conda environment" rapids-dependency-file-generator \ --output conda \ --file-key test_python \ - --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee env.yaml + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION};dependencies=${RAPIDS_DEPENDENCIES}" | tee env.yaml rapids-mamba-retry env create --yes -f env.yaml -n test set +u diff --git a/ci/test_wheel.sh b/ci/test_wheel.sh index 8ba03f3a2..d06c4eed0 100755 --- a/ci/test_wheel.sh +++ b/ci/test_wheel.sh @@ -7,7 +7,20 @@ RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" WHEELHOUSE="${PWD}/dist/" RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 python "${WHEELHOUSE}" +# Constraint to minimum dependency versions if job is set up as "oldest" +echo "" > ./constraints.txt +if [[ $RAPIDS_DEPENDENCIES == "oldest" ]]; then + rapids-dependency-file-generator \ + --output requirements \ + --file-key test_python \ + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION};dependencies=${RAPIDS_DEPENDENCIES}" \ + | tee ./constraints.txt +fi + # echo to expand wildcard before adding '[extra]' requires for pip -python -m pip install -v "$(echo "${WHEELHOUSE}"/rmm_${RAPIDS_PY_CUDA_SUFFIX}*.whl)[test]" +python -m pip install \ + -v \ + --constraint ./constraints.txt \ + "$(echo "${WHEELHOUSE}"/rmm_${RAPIDS_PY_CUDA_SUFFIX}*.whl)[test]" python -m pytest ./python/rmm/rmm/tests diff --git a/dependencies.yaml b/dependencies.yaml index ef2de69ed..0196a6ee0 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -308,3 +308,13 @@ dependencies: - cuda-nvcc - matrix: packages: + - output_types: [conda, requirements] + # Define additional constraints for testing with oldest dependencies. + matrices: + - matrix: + dependencies: "oldest" + packages: + - numba==0.57.* + - numpy==1.23.* + - matrix: + packages: From 0a8ae04206be81a3c2b7e7f5aecf2c453eaf8372 Mon Sep 17 00:00:00 2001 From: Rong Ou Date: Mon, 26 Aug 2024 13:10:28 -0700 Subject: [PATCH 458/675] Stream synchronize before deallocating SAM (#1655) While investigating cuml benchmarks, I found an issue with the current `system_memory_resource` that causes segfault. Roughly it's in code like this: ```cuda void foo(...) { rmm::device_uvector tmp(bufferSize, stream); // launch cuda kernels making use of tmp } ``` When the function returns, the `device_uvector` would go out of scope and get deleted, while the cuda kernel might still be in flight. With `cudaFree`, the CUDA runtime would perform implicit synchronization to make sure the kernel finishes before actually freeing the memory, but with SAM we don't have that guarantee, thus causing use-after-free errors. This is a rather simple fix. In the future we may want to use CUDA events to make this less blocking. Authors: - Rong Ou (https://github.com/rongou) Approvers: - Mark Harris (https://github.com/harrism) - Lawrence Mitchell (https://github.com/wence-) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1655 --- include/rmm/mr/device/system_memory_resource.hpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/rmm/mr/device/system_memory_resource.hpp b/include/rmm/mr/device/system_memory_resource.hpp index a32685e86..6ac74192d 100644 --- a/include/rmm/mr/device/system_memory_resource.hpp +++ b/include/rmm/mr/device/system_memory_resource.hpp @@ -107,17 +107,23 @@ class system_memory_resource final : public device_memory_resource { /** * @brief Deallocate memory pointed to by \p p. * - * The stream argument is ignored. + * This function synchronizes the stream before deallocating the memory. * * @param ptr Pointer to be deallocated * @param bytes The size in bytes of the allocation. This must be equal to the value of `bytes` * that was passed to the `allocate` call that returned `ptr`. - * @param stream This argument is ignored + * @param stream The stream in which to order this deallocation */ void do_deallocate(void* ptr, [[maybe_unused]] std::size_t bytes, - [[maybe_unused]] cuda_stream_view stream) override + cuda_stream_view stream) override { + // With `cudaFree`, the CUDA runtime keeps track of dependent operations and does implicit + // synchronization. However, with SAM, since `free` is immediate, we need to wait for in-flight + // CUDA operations to finish before freeing the memory, to avoid potential use-after-free errors + // or race conditions. + stream.synchronize(); + rmm::detail::aligned_host_deallocate( ptr, bytes, CUDA_ALLOCATION_ALIGNMENT, [](void* ptr) { ::operator delete(ptr); }); } From ebc0d2f737a2b03cf52b6aa68616f8cd77ce33e7 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 27 Aug 2024 13:12:29 -0400 Subject: [PATCH 459/675] Update rapidsai/pre-commit-hooks (#1663) This PR updates rapidsai/pre-commit-hooks to the version 0.4.0. Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1663 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a3b3e56e2..f114abec4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -77,7 +77,7 @@ repos: - id: ruff files: python/.*$ - repo: https://github.com/rapidsai/pre-commit-hooks - rev: v0.3.1 + rev: v0.4.0 hooks: - id: verify-copyright - id: verify-alpha-spec From a42d36ddd740a6d17372ef00c59de17c7ed28977 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:51:27 +1000 Subject: [PATCH 460/675] Add resource_ref versions of get/set_current_device_resource (#1598) Fixes #1597 Adds new` get_per_device_resource_ref()`, `set_per_device_resource_ref()` and `current_device` versions of these, intended to replace `get_per_device_resource()`. The new functions deal in `device_async_resource_ref`, while the old functions deal in `device_memory_resource` pointers. Tests are updated to use the new functions. Note that I have also added `reset_per_device_resource_ref()` and `reset_current_device_resource_ref()` which are necessary because previously we implemented the resetting behavior by passing `nullptr` to `set_current_device_resource()`, which doesn't work with `resource_ref` because it can't refer to `nullptr` (no such thing as a null reference). Updates tests to cover the new functionality, and re-enables tests of `set_current_device_resource_ref()` which were disabled in #1589. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Bradley Dice (https://github.com/bdice) - Rong Ou (https://github.com/rongou) - Lawrence Mitchell (https://github.com/wence-) URL: https://github.com/rapidsai/rmm/pull/1598 --- include/rmm/mr/device/per_device_resource.hpp | 218 +++++++++++++++++- .../mr/device/mr_ref_multithreaded_tests.cpp | 86 ++++--- tests/mr/device/mr_ref_test.hpp | 13 +- tests/mr/device/mr_ref_tests.cpp | 36 ++- 4 files changed, 296 insertions(+), 57 deletions(-) diff --git a/include/rmm/mr/device/per_device_resource.hpp b/include/rmm/mr/device/per_device_resource.hpp index 1319f9e94..b8291c237 100644 --- a/include/rmm/mr/device/per_device_resource.hpp +++ b/include/rmm/mr/device/per_device_resource.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -52,9 +53,18 @@ * `get_per_device_resource(id)` will return a pointer to a `cuda_memory_resource`. * * To fetch and modify the resource for the current CUDA device, `get_current_device_resource()` and - * `set_current_device_resource()` will automatically use the current CUDA device id from + * `set_current_device_resource()` automatically use the current CUDA device id from * `cudaGetDevice()`. * + * RMM is in transition to use `cuda::mr::async_resource_ref` in place of raw pointers to + * `device_memory_resource`. The `set_per_device_resource_ref`, `get_per_device_resource_ref`, + * `get_current_device_resource_ref`, `set_current_device_resource_ref`, and + * `reset_current_device_resource_ref` functions provide the same functionality as their + * `device_memory_resource` counterparts, but with `device_async_resource_ref` objects. The raw + * pointer versions and the `resource_ref` versions maintain distinc state and are not + * interchangeable. The raw pointer versions are expected to be deprecated and removed in a future + * release. + * * Creating a device_memory_resource for each device requires care to set the current device * before creating each resource, and to maintain the lifetime of the resources as long as they * are set as per-device resources. Here is an example loop that creates `unique_ptr`s to @@ -97,7 +107,7 @@ namespace detail { * * @return Pointer to the static cuda_memory_resource used as the initial, default resource */ -inline device_memory_resource* initial_resource() +RMM_EXPORT inline device_memory_resource* initial_resource() { static cuda_memory_resource mr{}; return &mr; @@ -106,7 +116,7 @@ inline device_memory_resource* initial_resource() /** * @briefreturn{Reference to the lock} */ -inline std::mutex& map_lock() +RMM_EXPORT inline std::mutex& map_lock() { static std::mutex map_lock; return map_lock; @@ -122,6 +132,25 @@ RMM_EXPORT inline auto& get_map() return device_id_to_resource; } +/** + * @briefreturn{Reference to the lock} + */ +RMM_EXPORT inline std::mutex& ref_map_lock() +{ + static std::mutex ref_map_lock; + return ref_map_lock; +} + +// This symbol must have default visibility, see: https://github.com/rapidsai/rmm/issues/826 +/** + * @briefreturn{Reference to the map from device id -> resource_ref} + */ +RMM_EXPORT inline auto& get_ref_map() +{ + static std::map device_id_to_resource_ref; + return device_id_to_resource_ref; +} + } // namespace detail /** @@ -130,20 +159,21 @@ RMM_EXPORT inline auto& get_map() * Returns a pointer to the `device_memory_resource` for the specified device. The initial * resource is a `cuda_memory_resource`. * - * `id.value()` must be in the range `[0, cudaGetDeviceCount())`, otherwise behavior is undefined. + * `device_id.value()` must be in the range `[0, cudaGetDeviceCount())`, otherwise behavior is + * undefined. * * This function is thread-safe with respect to concurrent calls to `set_per_device_resource`, * `get_per_device_resource`, `get_current_device_resource`, and `set_current_device_resource`. * Concurrent calls to any of these functions will result in a valid state, but the order of * execution is undefined. * - * @note The returned `device_memory_resource` should only be used when CUDA device `id` is the - * current device (e.g. set using `cudaSetDevice()`). The behavior of a device_memory_resource is - * undefined if used while the active CUDA device is a different device from the one that was active - * when the device_memory_resource was created. + * @note The returned `device_memory_resource` should only be used when CUDA device `device_id` is + * the current device (e.g. set using `cudaSetDevice()`). The behavior of a + * `device_memory_resource` is undefined if used while the active CUDA device is a different device + * from the one that was active when the `device_memory_resource` was created. * * @param device_id The id of the target device - * @return Pointer to the current `device_memory_resource` for device `id` + * @return Pointer to the current `device_memory_resource` for device `device_id` */ inline device_memory_resource* get_per_device_resource(cuda_device_id device_id) { @@ -248,6 +278,176 @@ inline device_memory_resource* set_current_device_resource(device_memory_resourc { return set_per_device_resource(rmm::get_current_cuda_device(), new_mr); } + +/** + * @brief Get the `device_async_resource_ref` for the specified device. + * + * Returns a `device_async_resource_ref` for the specified device. The initial resource_ref + * references a `cuda_memory_resource`. + * + * `device_id.value()` must be in the range `[0, cudaGetDeviceCount())`, otherwise behavior is + * undefined. + * + * This function is thread-safe with respect to concurrent calls to `set_per_device_resource_ref`, + * `get_per_device_resource_ref`, `get_current_device_resource_ref`, + * `set_current_device_resource_ref` and `reset_current_device_resource_ref`. Concurrent calls to + * any of these functions will result in a valid state, but the order of execution is undefined. + * + * @note The returned `device_async_resource_ref` should only be used when CUDA device `device_id` + * is the current device (e.g. set using `cudaSetDevice()`). The behavior of a + * `device_async_resource_ref` is undefined if used while the active CUDA device is a different + * device from the one that was active when the memory resource was created. + * + * @param device_id The id of the target device + * @return The current `device_async_resource_ref` for device `device_id` + */ +inline device_async_resource_ref get_per_device_resource_ref(cuda_device_id device_id) +{ + std::lock_guard lock{detail::ref_map_lock()}; + auto& map = detail::get_ref_map(); + // If a resource was never set for `id`, set to the initial resource + auto const found = map.find(device_id.value()); + if (found == map.end()) { + auto item = map.insert({device_id.value(), detail::initial_resource()}); + return item.first->second; + } + return found->second; +} + +/** + * @brief Set the `device_async_resource_ref` for the specified device to `new_resource_ref` + * + * `device_id.value()` must be in the range `[0, cudaGetDeviceCount())`, otherwise behavior is + * undefined. + * + * The object referenced by `new_resource_ref` must outlive the last use of the resource, otherwise + * behavior is undefined. It is the caller's responsibility to maintain the lifetime of the resource + * object. + * + * This function is thread-safe with respect to concurrent calls to `set_per_device_resource_ref`, + * `get_per_device_resource_ref`, `get_current_device_resource_ref`, + * `set_current_device_resource_ref` and `reset_current_device_resource_ref. Concurrent calls to any + * of these functions will result in a valid state, but the order of execution is undefined. + * + * @note The resource passed in `new_resource_ref` must have been created when device `device_id` + * was the current CUDA device (e.g. set using `cudaSetDevice()`). The behavior of a + * `device_async_resource_ref` is undefined if used while the active CUDA device is a different + * device from the one that was active when the memory resource was created. + * + * @param device_id The id of the target device + * @param new_resource_ref new `device_async_resource_ref` to use as new resource for `device_id` + * @return The previous `device_async_resource_ref` for `device_id` + */ +inline device_async_resource_ref set_per_device_resource_ref( + cuda_device_id device_id, device_async_resource_ref new_resource_ref) +{ + std::lock_guard lock{detail::ref_map_lock()}; + auto& map = detail::get_ref_map(); + auto const old_itr = map.find(device_id.value()); + // If a resource didn't previously exist for `device_id`, return pointer to initial_resource + // Note: because resource_ref is not default-constructible, we can't use std::map::operator[] + if (old_itr == map.end()) { + map.insert({device_id.value(), new_resource_ref}); + return device_async_resource_ref{detail::initial_resource()}; + } + + auto old_resource_ref = old_itr->second; + old_itr->second = new_resource_ref; // update map directly via iterator + return old_resource_ref; +} + +/** + * @brief Get the `device_async_resource_ref` for the current device. + * + * Returns the `device_async_resource_ref` set for the current device. The initial resource_ref + * references a `cuda_memory_resource`. + * + * The "current device" is the device returned by `cudaGetDevice`. + * + * This function is thread-safe with respect to concurrent calls to `set_per_device_resource_ref`, + * `get_per_device_resource_ref`, `get_current_device_resource_ref`, + * `set_current_device_resource_ref` and `reset_current_device_resource_ref. Concurrent calls to any + * of these functions will result in a valid state, but the order of execution is undefined. + + * + * @note The returned `device_async_resource_ref` should only be used with the current CUDA device. + * Changing the current device (e.g. using `cudaSetDevice()`) and then using the returned + * `resource_ref` can result in undefined behavior. The behavior of a `device_async_resource_ref` is + * undefined if used while the active CUDA device is a different device from the one that was active + * when the memory resource was created. + * + * @return `device_async_resource_ref` active for the current device + */ +inline device_async_resource_ref get_current_device_resource_ref() +{ + return get_per_device_resource_ref(rmm::get_current_cuda_device()); +} + +/** + * @brief Set the `device_async_resource_ref` for the current device. + * + * The "current device" is the device returned by `cudaGetDevice`. + * + * The object referenced by `new_resource_ref` must outlive the last use of the resource, otherwise + * behavior is undefined. It is the caller's responsibility to maintain the lifetime of the resource + * object. + * + * This function is thread-safe with respect to concurrent calls to `set_per_device_resource_ref`, + * `get_per_device_resource_ref`, `get_current_device_resource_ref`, + * `set_current_device_resource_ref` and `reset_current_device_resource_ref. Concurrent calls to any + * of these functions will result in a valid state, but the order of execution is undefined. + * + * @note The resource passed in `new_resource` must have been created for the current CUDA device. + * The behavior of a `device_async_resource_ref` is undefined if used while the active CUDA device + * is a different device from the one that was active when the memory resource was created. + * + * @param new_resource_ref New `device_async_resource_ref` to use for the current device + * @return Previous `device_async_resource_ref` for the current device + */ +inline device_async_resource_ref set_current_device_resource_ref( + device_async_resource_ref new_resource_ref) +{ + return set_per_device_resource_ref(rmm::get_current_cuda_device(), new_resource_ref); +} + +/** + * @brief Reset the `device_async_resource_ref` for the specified device to the initial resource. + * + * Resets to a reference to the initial `cuda_memory_resource`. + * + * `device_id.value()` must be in the range `[0, cudaGetDeviceCount())`, otherwise behavior is + * undefined. + * + * This function is thread-safe with respect to concurrent calls to `set_per_device_resource_ref`, + * `get_per_device_resource_ref`, `get_current_device_resource_ref`, + * `set_current_device_resource_ref` and `reset_current_device_resource_ref. Concurrent calls to any + * of these functions will result in a valid state, but the order of execution is undefined. + * + * @param device_id The id of the target device + * @return Previous `device_async_resource_ref` for `device_id` + */ +inline device_async_resource_ref reset_per_device_resource_ref(cuda_device_id device_id) +{ + return set_per_device_resource_ref(device_id, detail::initial_resource()); +} + +/** + * @brief Reset the `device_async_resource_ref` for the current device to the initial resource. + * + * Resets to a reference to the initial `cuda_memory_resource`. The "current device" is the device + * returned by `cudaGetDevice`. + * + * This function is thread-safe with respect to concurrent calls to `set_per_device_resource_ref`, + * `get_per_device_resource_ref`, `get_current_device_resource_ref`, + * `set_current_device_resource_ref` and `reset_current_device_resource_ref. Concurrent calls to any + * of these functions will result in a valid state, but the order of execution is undefined. + * + * @return Previous `device_async_resource_ref` for `device_id` + */ +inline device_async_resource_ref reset_current_device_resource_ref() +{ + return reset_per_device_resource_ref(rmm::get_current_cuda_device()); +} /** @} */ // end of group } // namespace mr } // namespace RMM_NAMESPACE diff --git a/tests/mr/device/mr_ref_multithreaded_tests.cpp b/tests/mr/device/mr_ref_multithreaded_tests.cpp index 3ba32445f..7d749efd1 100644 --- a/tests/mr/device/mr_ref_multithreaded_tests.cpp +++ b/tests/mr/device/mr_ref_multithreaded_tests.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -69,6 +70,8 @@ void spawn(Task task, Arguments&&... args) TEST(DefaultTest, UseCurrentDeviceResource_mt) { spawn(test_get_current_device_resource); } +TEST(DefaultTest, UseCurrentDeviceResourceRef_mt) { spawn(test_get_current_device_resource_ref); } + TEST(DefaultTest, CurrentDeviceResourceIsCUDA_mt) { spawn([]() { @@ -77,6 +80,14 @@ TEST(DefaultTest, CurrentDeviceResourceIsCUDA_mt) }); } +TEST(DefaultTest, CurrentDeviceResourceRefIsCUDA_mt) +{ + spawn([]() { + EXPECT_EQ(rmm::mr::get_current_device_resource_ref(), + rmm::device_async_resource_ref{rmm::mr::detail::initial_resource()}); + }); +} + TEST(DefaultTest, GetCurrentDeviceResource_mt) { spawn([]() { @@ -86,57 +97,64 @@ TEST(DefaultTest, GetCurrentDeviceResource_mt) }); } -// Disable until we support resource_ref with set_current_device_resource -/*TEST_P(mr_ref_test_mt, SetCurrentDeviceResource_mt) +TEST(DefaultTest, GetCurrentDeviceResourceRef_mt) { - // single thread changes default resource, then multiple threads use it + spawn([]() { + auto mr = rmm::mr::get_current_device_resource_ref(); + EXPECT_EQ(mr, rmm::device_async_resource_ref{rmm::mr::detail::initial_resource()}); + }); +} - rmm::mr::device_memory_resource* old = rmm::mr::set_current_device_resource(this->mr.get()); - EXPECT_NE(nullptr, old); +TEST_P(mr_ref_test_mt, SetCurrentDeviceResourceRef_mt) +{ + // single thread changes default resource, then multiple threads use it + auto old = rmm::mr::set_current_device_resource_ref(this->ref); - spawn([mr = this->mr.get()]() { - EXPECT_EQ(mr, rmm::mr::get_current_device_resource()); - test_get_current_device_resource(); // test allocating with the new default resource + spawn([mr = this->ref]() { + EXPECT_EQ(mr, rmm::mr::get_current_device_resource_ref()); + test_get_current_device_resource_ref(); // test allocating with the new default resource }); - // setting default resource w/ nullptr should reset to initial - rmm::mr::set_current_device_resource(nullptr); - EXPECT_TRUE(old->is_equal(*rmm::mr::get_current_device_resource())); -}*/ + // resetting default resource should reset to initial + rmm::mr::reset_current_device_resource_ref(); + EXPECT_EQ(old, rmm::mr::get_current_device_resource_ref()); +} -/*TEST_P(mr_ref_test_mt, SetCurrentDeviceResourcePerThread_mt) +TEST_P(mr_ref_test_mt, SetCurrentDeviceResourceRefPerThread_mt) { int num_devices{}; RMM_CUDA_TRY(cudaGetDeviceCount(&num_devices)); std::vector threads; threads.reserve(num_devices); + + auto mr = this->ref; + for (int i = 0; i < num_devices; ++i) { - threads.emplace_back(std::thread{[mr = this->mr.get()](auto dev_id) { - RMM_CUDA_TRY(cudaSetDevice(dev_id)); - rmm::mr::device_memory_resource* old = - rmm::mr::set_current_device_resource(mr); - EXPECT_NE(nullptr, old); - // initial resource for this device should be CUDA mr - EXPECT_TRUE(old->is_equal(rmm::mr::cuda_memory_resource{})); - // get_current_device_resource should equal the resource we - // just set - EXPECT_EQ(mr, rmm::mr::get_current_device_resource()); - // Setting current dev resource to nullptr should reset to - // cuda MR and return the MR we previously set - old = rmm::mr::set_current_device_resource(nullptr); - EXPECT_NE(nullptr, old); - EXPECT_EQ(old, mr); - EXPECT_TRUE(rmm::mr::get_current_device_resource()->is_equal( - rmm::mr::cuda_memory_resource{})); - }, - i}); + threads.emplace_back( + [mr](auto dev_id) { + RMM_CUDA_TRY(cudaSetDevice(dev_id)); + auto cuda_ref = rmm::mr::get_current_device_resource_ref(); + auto old = rmm::mr::set_current_device_resource_ref(mr); + + // initial resource for this device should be CUDA mr + EXPECT_EQ(old, cuda_ref); + // get_current_device_resource_ref should equal the resource we + // just set + EXPECT_EQ(mr, rmm::mr::get_current_device_resource_ref()); + // Resetting current dev resource ref should make it + // cuda MR and return the MR we previously set + old = rmm::mr::reset_current_device_resource_ref(); + EXPECT_EQ(old, mr); + EXPECT_EQ(cuda_ref, rmm::mr::get_current_device_resource_ref()); + }, + i); } for (auto& thread : threads) { thread.join(); } -}*/ +} TEST_P(mr_ref_test_mt, Allocate) { spawn(test_various_allocations, this->ref); } @@ -247,7 +265,7 @@ void test_allocate_async_free_different_threads(rmm::device_async_resource_ref r std::mutex mtx; std::condition_variable allocations_ready; std::list allocations; - cudaEvent_t event; + cudaEvent_t event{}; RMM_CUDA_TRY(cudaEventCreate(&event)); diff --git a/tests/mr/device/mr_ref_test.hpp b/tests/mr/device/mr_ref_test.hpp index df0045d2b..6e63b3838 100644 --- a/tests/mr/device/mr_ref_test.hpp +++ b/tests/mr/device/mr_ref_test.hpp @@ -73,6 +73,15 @@ inline void test_get_current_device_resource() rmm::mr::get_current_device_resource()->deallocate(ptr, 1_MiB); } +inline void test_get_current_device_resource_ref() +{ + void* ptr = rmm::mr::get_current_device_resource_ref().allocate(1_MiB); + EXPECT_NE(nullptr, ptr); + EXPECT_TRUE(is_properly_aligned(ptr)); + EXPECT_TRUE(is_device_accessible_memory(ptr)); + rmm::mr::get_current_device_resource_ref().deallocate(ptr, 1_MiB); +} + inline void test_allocate(resource_ref ref, std::size_t bytes) { try { @@ -392,7 +401,7 @@ inline auto make_binning() struct mr_factory_base { std::string name{}; ///< Name to associate with tests that use this factory - resource_ref mr{rmm::mr::get_current_device_resource()}; + resource_ref mr{rmm::mr::get_current_device_resource_ref()}; bool skip_test{false}; }; @@ -468,7 +477,7 @@ struct mr_ref_test : public ::testing::TestWithParam { } std::shared_ptr factory_obj{}; - resource_ref ref{rmm::mr::get_current_device_resource()}; + resource_ref ref{rmm::mr::get_current_device_resource_ref()}; rmm::cuda_stream stream{}; }; diff --git a/tests/mr/device/mr_ref_tests.cpp b/tests/mr/device/mr_ref_tests.cpp index d94817bef..55e91d765 100644 --- a/tests/mr/device/mr_ref_tests.cpp +++ b/tests/mr/device/mr_ref_tests.cpp @@ -16,7 +16,9 @@ #include "mr_ref_test.hpp" +#include #include +#include #include @@ -63,6 +65,8 @@ TEST(DefaultTest, CurrentDeviceResourceIsCUDA) TEST(DefaultTest, UseCurrentDeviceResource) { test_get_current_device_resource(); } +TEST(DefaultTest, UseCurrentDeviceResourceRef) { test_get_current_device_resource_ref(); } + TEST(DefaultTest, GetCurrentDeviceResource) { auto* mr = rmm::mr::get_current_device_resource(); @@ -70,25 +74,33 @@ TEST(DefaultTest, GetCurrentDeviceResource) EXPECT_TRUE(mr->is_equal(rmm::mr::cuda_memory_resource{})); } -// Disable until we support resource_ref with set_current_device_resource -/*TEST_P(mr_ref_test, SetCurrentDeviceResource) +TEST(DefaultTest, GetCurrentDeviceResourceRef) +{ + auto mr = rmm::mr::get_current_device_resource_ref(); + EXPECT_EQ(mr, rmm::device_async_resource_ref{rmm::mr::detail::initial_resource()}); +} + +TEST_P(mr_ref_test, SetCurrentDeviceResourceRef) { - rmm::mr::device_memory_resource* old{}; - old = rmm::mr::set_current_device_resource(this->mr.get()); - EXPECT_NE(nullptr, old); + rmm::mr::cuda_memory_resource cuda_mr{}; + auto cuda_ref = rmm::device_async_resource_ref{cuda_mr}; + + rmm::mr::set_current_device_resource_ref(cuda_ref); + auto old = rmm::mr::set_current_device_resource_ref(this->ref); // old mr should equal a cuda mr - EXPECT_TRUE(old->is_equal(rmm::mr::cuda_memory_resource{})); + EXPECT_EQ(old, cuda_ref); // current dev resource should equal this resource - EXPECT_TRUE(this->mr->is_equal(*rmm::mr::get_current_device_resource())); + EXPECT_EQ(this->ref, rmm::mr::get_current_device_resource_ref()); - test_get_current_device_resource(); + test_get_current_device_resource_ref(); - // setting to `nullptr` should reset to initial cuda resource - rmm::mr::set_current_device_resource(nullptr); - EXPECT_TRUE(rmm::mr::get_current_device_resource()->is_equal(rmm::mr::cuda_memory_resource{})); -}*/ + // Resetting should reset to initial cuda resource + rmm::mr::reset_current_device_resource_ref(); + EXPECT_EQ(rmm::device_async_resource_ref{rmm::mr::detail::initial_resource()}, + rmm::mr::get_current_device_resource_ref()); +} TEST_P(mr_ref_test, SelfEquality) { EXPECT_TRUE(this->ref == this->ref); } From 93d291fa3e15a23b3dfed25809a179347ac3a241 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 4 Sep 2024 18:20:12 -0500 Subject: [PATCH 461/675] Add support for Python 3.12 (#1666) Contributes to https://github.com/rapidsai/build-planning/issues/40 This PR adds support for Python 3.12. ## Notes for Reviewers This is part of ongoing work to add Python 3.12 support across RAPIDS. It temporarily introduces a build/test matrix including Python 3.12, from https://github.com/rapidsai/shared-workflows/pull/213. A follow-up PR will revert back to pointing at the `branch-24.10` branch of `shared-workflows` once all RAPIDS repos have added Python 3.12 support. ### This will fail until all dependencies have been updates to Python 3.12 CI here is expected to fail until all of this project's upstream dependencies support Python 3.12. This can be merged whenever all CI jobs are passing. Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1666 --- .github/workflows/build.yaml | 16 +++++++------- .github/workflows/pr.yaml | 22 +++++++++---------- .github/workflows/test.yaml | 6 ++--- README.md | 2 +- .../all_cuda-118_arch-x86_64.yaml | 2 +- .../all_cuda-125_arch-x86_64.yaml | 2 +- dependencies.yaml | 6 ++++- python/rmm/pyproject.toml | 1 + 8 files changed, 31 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9b7efecde..7f54701d9 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@python-3.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@python-3.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@python-3.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@python-3.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build-cpp: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@python-3.12 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -79,7 +79,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@python-3.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -89,7 +89,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@python-3.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -100,7 +100,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@python-3.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 1160b93e9..7d9fbb086 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -23,40 +23,40 @@ jobs: - wheel-tests - devcontainer secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@python-3.12 checks: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@python-3.12 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@python-3.12 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@python-3.12 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@python-3.12 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@python-3.12 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@python-3.12 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -66,7 +66,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@python-3.12 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -74,20 +74,20 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@python-3.12 with: build_type: pull-request script: ci/build_wheel_python.sh wheel-tests: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@python-3.12 with: build_type: pull-request script: ci/test_wheel.sh devcontainer: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@python-3.12 with: arch: '["amd64"]' cuda: '["12.5"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 13838d888..eec04005d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@python-3.12 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@python-3.12 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@python-3.12 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/README.md b/README.md index 897be2da0..e90398c2b 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ conda install -c rapidsai -c conda-forge -c nvidia rmm cuda-version=12.0 We also provide [nightly Conda packages](https://anaconda.org/rapidsai-nightly) built from the HEAD of our latest development branch. -Note: RMM is supported only on Linux, and only tested with Python versions 3.10 and 3.11. +Note: RMM is supported only on Linux, and only tested with Python versions 3.10, 3.11, and 3.12. Note: The RMM package from Conda requires building with GCC 9 or later. Otherwise, your application may fail to build. diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index eb56557de..33b54b3f9 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -32,7 +32,7 @@ dependencies: - pre-commit - pytest - pytest-cov -- python>=3.10,<3.12 +- python>=3.10,<3.13 - rapids-build-backend>=0.3.0,<0.4.0.dev0 - scikit-build-core >=0.10.0 - spdlog>=1.12.0,<1.13 diff --git a/conda/environments/all_cuda-125_arch-x86_64.yaml b/conda/environments/all_cuda-125_arch-x86_64.yaml index 6e286d01e..5946a9786 100644 --- a/conda/environments/all_cuda-125_arch-x86_64.yaml +++ b/conda/environments/all_cuda-125_arch-x86_64.yaml @@ -31,7 +31,7 @@ dependencies: - pre-commit - pytest - pytest-cov -- python>=3.10,<3.12 +- python>=3.10,<3.13 - rapids-build-backend>=0.3.0,<0.4.0.dev0 - scikit-build-core >=0.10.0 - spdlog>=1.12.0,<1.13 diff --git a/dependencies.yaml b/dependencies.yaml index 0196a6ee0..eff3560e7 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -267,8 +267,12 @@ dependencies: packages: - python=3.11 - matrix: + py: "3.12" packages: - - python>=3.10,<3.12 + - python=3.12 + - matrix: + packages: + - python>=3.10,<3.13 run: common: - output_types: [conda, requirements, pyproject] diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 2ecccbee0..7577ad961 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -42,6 +42,7 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] [project.optional-dependencies] From 9864b51b2ae83d4bf7f2c934aacebf9cd66ecec2 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Fri, 6 Sep 2024 14:54:33 +0100 Subject: [PATCH 462/675] Inline functions that return static references must have default visibility (#1653) In #833, we gave `rmm::mr::detail::get_map` default visibility. However, there are a number of other functions that return static references that should also have this visibility so that the static reference is unique across multiple DSOs. - Closes #1651 Authors: - Lawrence Mitchell (https://github.com/wence-) - Mark Harris (https://github.com/harrism) Approvers: - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1653 --- doxygen/Doxyfile | 8 ++++++-- include/rmm/detail/export.hpp | 1 + include/rmm/logger.hpp | 2 +- include/rmm/mr/device/per_device_resource.hpp | 10 +++++++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 7e13fa95b..dbd4194ab 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -2176,7 +2176,11 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = RMM_NAMESPACE=rmm RMM_EXPORT +# These need to be kept in sync with set in rmm/detail/export.hpp +# Since we are excluding detail files in EXCLUDE_PATTERNS there +# appears to be no way of getting doxygen to still parse that file and +# make the definitions available via the preprocessor :( +PREDEFINED = RMM_EXPORT RMM_HIDDEN RMM_NAMESPACE=rmm # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The @@ -2185,7 +2189,7 @@ PREDEFINED = RMM_NAMESPACE=rmm RMM_EXPORT # definition found in the source code. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -EXPAND_AS_DEFINED = RMM_NAMESPACE +EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will # remove all references to function-like macros that are alone on a line, have diff --git a/include/rmm/detail/export.hpp b/include/rmm/detail/export.hpp index 90fa8d173..9587a6009 100644 --- a/include/rmm/detail/export.hpp +++ b/include/rmm/detail/export.hpp @@ -24,4 +24,5 @@ #else #define RMM_EXPORT #define RMM_HIDDEN +#define RMM_NAMESPACE rmm #endif diff --git a/include/rmm/logger.hpp b/include/rmm/logger.hpp index e60501d2b..326385f16 100644 --- a/include/rmm/logger.hpp +++ b/include/rmm/logger.hpp @@ -107,7 +107,7 @@ struct bytes { * * @return spdlog::logger& The logger. */ -inline spdlog::logger& logger() +RMM_EXPORT inline spdlog::logger& logger() { static detail::logger_wrapper wrapped{}; return wrapped.logger_; diff --git a/include/rmm/mr/device/per_device_resource.hpp b/include/rmm/mr/device/per_device_resource.hpp index b8291c237..ff6321e25 100644 --- a/include/rmm/mr/device/per_device_resource.hpp +++ b/include/rmm/mr/device/per_device_resource.hpp @@ -100,6 +100,15 @@ namespace mr { namespace detail { +// These symbols must have default visibility so that when they are +// referenced in multiple different DSOs the linker correctly +// determines that there is only a single unique reference to the +// function symbols (and hence they return unique static references +// across different DSOs). See also +// https://github.com/rapidsai/rmm/issues/826 +// Although currently the entire RMM namespace is RMM_EXPORT, we +// explicitly mark these functions as exported in case the namespace +// export changes. /** * @brief Returns a pointer to the initial resource. * @@ -122,7 +131,6 @@ RMM_EXPORT inline std::mutex& map_lock() return map_lock; } -// This symbol must have default visibility, see: https://github.com/rapidsai/rmm/issues/826 /** * @briefreturn{Reference to the map from device id -> resource} */ From 8bc51c30d924d43513732c5ec97ec5e8a8e1e9fd Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Fri, 6 Sep 2024 17:05:26 -0400 Subject: [PATCH 463/675] Remove the friend declaration with an attribute (#1669) The `logging_resource_adaptor` has a friend declaration (which is not a definition) preceded by an attribute, whereas C++ standard requires that such [declaration must be a definition](https://eel.is/c++draft/dcl.attr.grammar#5). gcc 11.4.0 used in the dev container does not correctly identify this, but gcc 12.1 and newer are able to, and will report a compile error (converted from a warning) when building RMM: ``` an attribute that appertains to a friend declaration that is not a definition is ignored ``` This simple PR removes the friend declaration from the `logging_resource_adaptor` class. This is valid since in recent releases of RMM the friended function no longer accesses any private (or protected) data or methods of `logging_resource_adaptor`. closes #1668 Authors: - Tianyu Liu (https://github.com/kingcrimsontianyu) Approvers: - Rong Ou (https://github.com/rongou) - Bradley Dice (https://github.com/bdice) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1669 --- include/rmm/mr/device/logging_resource_adaptor.hpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 6f6cd816a..1b4d80f14 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -283,16 +283,6 @@ class logging_resource_adaptor final : public device_memory_resource { return get_upstream_resource() == cast->get_upstream_resource(); } - // make_logging_adaptor needs access to private get_default_filename - template - // NOLINTNEXTLINE(readability-redundant-declaration) - [[deprecated( - "make_logging_adaptor is deprecated in RMM 24.10. Use the logging_resource_adaptor constructor " - "instead.")]] - friend logging_resource_adaptor make_logging_adaptor(T* upstream, - std::string const& filename, - bool auto_flush); - std::shared_ptr logger_; ///< spdlog logger object Upstream* upstream_; ///< The upstream resource used for satisfying From 1e5fa03592c7ebb619bdcaa8d5fdc569e0397845 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Mon, 9 Sep 2024 14:26:20 +0100 Subject: [PATCH 464/675] Attempt to address oom failures in test suite (#1672) Audit the existing MR tests and serialize those that make large allocations (specifically, a pool with 90% of the available device memory). This also allows us to remove serialization from some of the tests which don't make large allocations. - Closes #1671 Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Bradley Dice (https://github.com/bdice) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1672 --- tests/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 75b15a90b..5a4f88166 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -125,7 +125,7 @@ ConfigureTest(DEVICE_MR_REF_TEST mr/device/mr_ref_tests.cpp ConfigureTest(ADAPTOR_TEST mr/device/adaptor_tests.cpp) # pool mr tests -ConfigureTest(POOL_MR_TEST mr/device/pool_mr_tests.cpp GPUS 1 PERCENT 60) +ConfigureTest(POOL_MR_TEST mr/device/pool_mr_tests.cpp GPUS 1 PERCENT 100) # cuda_async mr tests ConfigureTest(CUDA_ASYNC_MR_TEST mr/device/cuda_async_mr_tests.cpp GPUS 1 PERCENT 60) @@ -140,10 +140,10 @@ ConfigureTest(POLYMORPHIC_ALLOCATOR_TEST mr/device/polymorphic_allocator_tests.c ConfigureTest(STREAM_ADAPTOR_TEST mr/device/stream_allocator_adaptor_tests.cpp) # statistics adaptor tests -ConfigureTest(STATISTICS_TEST mr/device/statistics_mr_tests.cpp GPUS 1 PERCENT 100) +ConfigureTest(STATISTICS_TEST mr/device/statistics_mr_tests.cpp) # tracking adaptor tests -ConfigureTest(TRACKING_TEST mr/device/tracking_mr_tests.cpp GPUS 1 PERCENT 100) +ConfigureTest(TRACKING_TEST mr/device/tracking_mr_tests.cpp) # out-of-memory callback adaptor tests ConfigureTest(FAILURE_CALLBACK_TEST mr/device/failure_callback_mr_tests.cpp) @@ -182,7 +182,7 @@ ConfigureTest(PREFETCH_TEST prefetch_tests.cpp) ConfigureTest(LOGGER_TEST logger_tests.cpp) # arena MR tests -ConfigureTest(ARENA_MR_TEST mr/device/arena_mr_tests.cpp GPUS 1 PERCENT 60) +ConfigureTest(ARENA_MR_TEST mr/device/arena_mr_tests.cpp GPUS 1 PERCENT 100) # binning MR tests ConfigureTest(BINNING_MR_TEST mr/device/binning_mr_tests.cpp) From 687ed5c4b8b76d240aa76f801f5e3d9974b6893e Mon Sep 17 00:00:00 2001 From: Matthew Murray <41342305+Matt711@users.noreply.github.com> Date: Mon, 9 Sep 2024 18:47:39 -0400 Subject: [PATCH 465/675] [FEA] Allow setting `*_pool_size` with human-readable string (#1670) Closes #173 Authors: - Matthew Murray (https://github.com/Matt711) - Lawrence Mitchell (https://github.com/wence-) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1670 --- README.md | 4 +- python/rmm/docs/guide.md | 8 +-- python/rmm/rmm/_lib/CMakeLists.txt | 3 +- python/rmm/rmm/_lib/helper.pxd | 16 +++++ python/rmm/rmm/_lib/helper.pyx | 78 +++++++++++++++++++++++++ python/rmm/rmm/_lib/memory_resource.pyx | 24 +++++--- python/rmm/rmm/rmm.py | 8 ++- python/rmm/rmm/tests/test_rmm.py | 24 +++++++- 8 files changed, 143 insertions(+), 22 deletions(-) create mode 100644 python/rmm/rmm/_lib/helper.pxd create mode 100644 python/rmm/rmm/_lib/helper.pyx diff --git a/README.md b/README.md index e90398c2b..1250d094b 100644 --- a/README.md +++ b/README.md @@ -771,8 +771,8 @@ of 1 GiB and a maximum size of 4 GiB. The pool uses >>> import rmm >>> pool = rmm.mr.PoolMemoryResource( ... rmm.mr.CudaMemoryResource(), -... initial_pool_size=2**30, -... maximum_pool_size=2**32 +... initial_pool_size="1GiB", # equivalent to initial_pool_size=2**30 +... maximum_pool_size="4GiB" ... ) >>> rmm.mr.set_current_device_resource(pool) ``` diff --git a/python/rmm/docs/guide.md b/python/rmm/docs/guide.md index 911073b5d..22c0dc023 100644 --- a/python/rmm/docs/guide.md +++ b/python/rmm/docs/guide.md @@ -139,8 +139,8 @@ of 1 GiB and a maximum size of 4 GiB. The pool uses >>> import rmm >>> pool = rmm.mr.PoolMemoryResource( ... rmm.mr.CudaMemoryResource(), -... initial_pool_size=2**30, -... maximum_pool_size=2**32 +... initial_pool_size="1GiB", # equivalent to initial_pool_size=2**30 +... maximum_pool_size="4GiB" ... ) >>> rmm.mr.set_current_device_resource(pool) ``` @@ -151,8 +151,8 @@ Similarly, to use a pool of managed memory: >>> import rmm >>> pool = rmm.mr.PoolMemoryResource( ... rmm.mr.ManagedMemoryResource(), -... initial_pool_size=2**30, -... maximum_pool_size=2**32 +... initial_pool_size="1GiB", +... maximum_pool_size="4GiB" ... ) >>> rmm.mr.set_current_device_resource(pool) ``` diff --git a/python/rmm/rmm/_lib/CMakeLists.txt b/python/rmm/rmm/_lib/CMakeLists.txt index 1e629a402..7cdfed971 100644 --- a/python/rmm/rmm/_lib/CMakeLists.txt +++ b/python/rmm/rmm/_lib/CMakeLists.txt @@ -12,7 +12,8 @@ # the License. # ============================================================================= -set(cython_sources device_buffer.pyx lib.pyx logger.pyx memory_resource.pyx cuda_stream.pyx) +set(cython_sources device_buffer.pyx lib.pyx logger.pyx memory_resource.pyx cuda_stream.pyx + helper.pyx) set(linked_libraries rmm::rmm) # Build all of the Cython targets diff --git a/python/rmm/rmm/_lib/helper.pxd b/python/rmm/rmm/_lib/helper.pxd new file mode 100644 index 000000000..8ca151c00 --- /dev/null +++ b/python/rmm/rmm/_lib/helper.pxd @@ -0,0 +1,16 @@ +# 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. + + +cdef object parse_bytes(object s) except * diff --git a/python/rmm/rmm/_lib/helper.pyx b/python/rmm/rmm/_lib/helper.pyx new file mode 100644 index 000000000..d442ee341 --- /dev/null +++ b/python/rmm/rmm/_lib/helper.pyx @@ -0,0 +1,78 @@ +# 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. + +"""Helper functions for rmm""" + +import re + + +cdef dict BYTE_SIZES = { + 'b': 1, + '': 1, + 'kb': 1000, + 'mb': 1000**2, + 'gb': 1000**3, + 'tb': 1000**4, + 'pb': 1000**5, + 'kib': 1024, + 'mib': 1024**2, + 'gib': 1024**3, + 'tib': 1024**4, + 'pib': 1024**5, +} + + +pattern = re.compile(r"^([0-9]+(?:\.[0-9]*)?)[\t ]*((?i:(?:[kmgtp]i?)?b))?$") + +cdef object parse_bytes(object s): + """Parse a string or integer into a number of bytes. + + Parameters + ---------- + s : int | str + Size in bytes. If an integer is provided, it is returned as-is. + A string is parsed as a floating point number with an (optional, + case-insensitive) byte-specifier, both SI prefixes (kb, mb, ..., pb) + and binary prefixes (kib, mib, ..., pib) are supported. + + Returns + ------- + Requested size in bytes as an integer. + + Raises + ------ + ValueError + If it is not possible to parse the input as a byte specification. + """ + cdef str suffix + cdef double n + cdef int multiplier + + if isinstance(s, int): + return s + + match = pattern.match(s) + + if match is None: + raise ValueError(f"Could not parse {s} as a byte specification") + + n = float(match.group(1)) + + suffix = match.group(2) + if suffix is None: + suffix = "" + + multiplier = BYTE_SIZES[suffix.lower()] + + return int(n*multiplier) diff --git a/python/rmm/rmm/_lib/memory_resource.pyx b/python/rmm/rmm/_lib/memory_resource.pyx index 5030c5d2d..231253e3f 100644 --- a/python/rmm/rmm/_lib/memory_resource.pyx +++ b/python/rmm/rmm/_lib/memory_resource.pyx @@ -32,10 +32,13 @@ from libcpp.string cimport string from cuda.cudart import cudaError_t from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice + from rmm._cuda.stream cimport Stream + from rmm._cuda.stream import DEFAULT_STREAM from rmm._lib.cuda_stream_view cimport cuda_stream_view +from rmm._lib.helper cimport parse_bytes from rmm._lib.memory_resource cimport ( available_device_memory as c_available_device_memory, percent_of_free_device_memory as c_percent_of_free_device_memory, @@ -44,6 +47,7 @@ from rmm._lib.per_device_resource cimport ( cuda_device_id, set_per_device_resource as cpp_set_per_device_resource, ) + from rmm.statistics import Statistics # Transparent handle of a C++ exception @@ -314,9 +318,9 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): Parameters ---------- - initial_pool_size : int, optional + initial_pool_size : int | str, optional Initial pool size in bytes. By default, half the available memory - on the device is used. + on the device is used. A string argument is parsed using `parse_bytes`. release_threshold: int, optional Release threshold in bytes. If the pool size grows beyond this value, unused memory held by the pool will be released at the @@ -334,7 +338,7 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): cdef optional[size_t] c_initial_pool_size = ( optional[size_t]() if initial_pool_size is None - else optional[size_t]( initial_pool_size) + else optional[size_t]( parse_bytes(initial_pool_size)) ) cdef optional[size_t] c_release_threshold = ( @@ -426,12 +430,12 @@ cdef class PoolMemoryResource(UpstreamResourceAdaptor): c_initial_pool_size = ( c_percent_of_free_device_memory(50) if initial_pool_size is None - else initial_pool_size + else parse_bytes(initial_pool_size) ) c_maximum_pool_size = ( optional[size_t]() if maximum_pool_size is None - else optional[size_t]( maximum_pool_size) + else optional[size_t]( parse_bytes(maximum_pool_size)) ) self.c_obj.reset( new pool_memory_resource[device_memory_resource]( @@ -456,10 +460,10 @@ cdef class PoolMemoryResource(UpstreamResourceAdaptor): upstream_mr : DeviceMemoryResource The DeviceMemoryResource from which to allocate blocks for the pool. - initial_pool_size : int, optional + initial_pool_size : int | str, optional Initial pool size in bytes. By default, half the available memory on the device is used. - maximum_pool_size : int, optional + maximum_pool_size : int | str, optional Maximum size in bytes, that the pool can grow to. """ pass @@ -1091,8 +1095,10 @@ cpdef void _initialize( typ = PoolMemoryResource args = (upstream(),) kwargs = dict( - initial_pool_size=initial_pool_size, - maximum_pool_size=maximum_pool_size + initial_pool_size=None if initial_pool_size is None + else parse_bytes(initial_pool_size), + maximum_pool_size=None if maximum_pool_size is None + else parse_bytes(maximum_pool_size) ) else: typ = upstream diff --git a/python/rmm/rmm/rmm.py b/python/rmm/rmm/rmm.py index e5290905c..bac04b477 100644 --- a/python/rmm/rmm/rmm.py +++ b/python/rmm/rmm/rmm.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019, NVIDIA CORPORATION. +# Copyright (c) 2019-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. @@ -45,14 +45,16 @@ def reinitialize( performance. managed_memory : bool, default False If True, use managed memory for device memory allocation - initial_pool_size : int, default None + initial_pool_size : int | str, default None When `pool_allocator` is True, this indicates the initial pool size in bytes. By default, 1/2 of the total GPU memory is used. When `pool_allocator` is False, this argument is ignored if provided. - maximum_pool_size : int, default None + A string argument is parsed using `parse_bytes`. + maximum_pool_size : int | str, default None When `pool_allocator` is True, this indicates the maximum pool size in bytes. By default, the total available memory on the GPU is used. When `pool_allocator` is False, this argument is ignored if provided. + A string argument is parsed using `parse_bytes`. devices : int or List[int], default 0 GPU device IDs to register. By default registers only GPU 0. logging : bool, default False diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index c4fd90c45..c88d21b38 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -432,8 +432,8 @@ def test_rmm_pool_cupy_allocator_stream_lifetime(): def test_pool_memory_resource(dtype, nelem, alloc): mr = rmm.mr.PoolMemoryResource( rmm.mr.CudaMemoryResource(), - initial_pool_size=1 << 22, - maximum_pool_size=1 << 23, + initial_pool_size="4MiB", + maximum_pool_size="8MiB", ) rmm.mr.set_current_device_resource(mr) assert rmm.mr.get_current_device_resource_type() is type(mr) @@ -507,7 +507,7 @@ def test_binning_memory_resource(dtype, nelem, alloc, upstream_mr): def test_reinitialize_max_pool_size(): rmm.reinitialize( - pool_allocator=True, initial_pool_size=0, maximum_pool_size=1 << 23 + pool_allocator=True, initial_pool_size=0, maximum_pool_size="8MiB" ) rmm.DeviceBuffer().resize((1 << 23) - 1) @@ -530,6 +530,24 @@ def test_reinitialize_initial_pool_size_gt_max(): assert "Initial pool size exceeds the maximum pool size" in str(e.value) +def test_reinitialize_with_valid_str_arg_pool_size(): + rmm.reinitialize( + pool_allocator=True, + initial_pool_size="2kib", + maximum_pool_size="8kib", + ) + + +def test_reinitialize_with_invalid_str_arg_pool_size(): + with pytest.raises(ValueError) as e: + rmm.reinitialize( + pool_allocator=True, + initial_pool_size="2k", # 2kb valid, not 2k + maximum_pool_size="8k", + ) + assert "Could not parse" in str(e.value) + + @pytest.mark.parametrize("dtype", _dtypes) @pytest.mark.parametrize("nelem", _nelems) @pytest.mark.parametrize("alloc", _allocs) From 6729deff42fcb771555186af3027e662a34985ea Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Tue, 10 Sep 2024 09:39:41 +1000 Subject: [PATCH 466/675] Update RMM adaptors, containers and tests to use get/set_current_device_resource_ref() (#1661) Closes #1660. This adds a constructor to each MR adaptor to take a resource_ref rather than an `Upstream*`. It also updates RMM to use `get_current_device_resource_ref()` everywhere: in containers, in tests, in adaptors, Thrust allocator, polymorphic allocator, execution_policy, etc. Importantly, this PR also modifies `set_current_device_resource()` to basically call `set_current_device_resource_ref()`. This is necessary, because while RMM C++ uses `get_current_device_resource_ref()` everywhere, the Python API still uses the raw pointer API `set_current_device_resource()`. So we need the latter to update the state for the former. This is a temporary bootstrap to help with the refactoring. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Michael Schellenberger Costa (https://github.com/miscco) - Lawrence Mitchell (https://github.com/wence-) - Rong Ou (https://github.com/rongou) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1661 --- .../device_uvector/device_uvector_bench.cu | 18 ++-- .../multi_stream_allocations_bench.cu | 4 +- include/rmm/device_buffer.hpp | 14 +-- include/rmm/device_scalar.hpp | 6 +- include/rmm/device_uvector.hpp | 6 +- include/rmm/exec_policy.hpp | 4 +- .../mr/device/aligned_resource_adaptor.hpp | 51 ++++++---- .../rmm/mr/device/arena_memory_resource.hpp | 30 +++++- .../rmm/mr/device/binning_memory_resource.hpp | 82 ++++++++++------ .../mr/device/callback_memory_resource.hpp | 13 +-- include/rmm/mr/device/detail/arena.hpp | 33 +++---- .../failure_callback_resource_adaptor.hpp | 39 +++++--- .../mr/device/fixed_size_memory_resource.hpp | 50 +++++++--- .../mr/device/limiting_resource_adaptor.hpp | 53 +++++++---- .../mr/device/logging_resource_adaptor.hpp | 93 +++++++++++++++---- include/rmm/mr/device/per_device_resource.hpp | 46 ++++++--- .../rmm/mr/device/polymorphic_allocator.hpp | 4 +- .../rmm/mr/device/pool_memory_resource.hpp | 43 ++++++--- .../mr/device/prefetch_resource_adaptor.hpp | 26 +++--- .../mr/device/statistics_resource_adaptor.hpp | 32 ++++--- .../device/thread_safe_resource_adaptor.hpp | 28 +++--- .../mr/device/thrust_allocator_adaptor.hpp | 2 +- .../mr/device/tracking_resource_adaptor.hpp | 33 ++++--- include/rmm/resource_ref.hpp | 16 ++++ python/rmm/rmm/_lib/_torch_allocator.cpp | 14 ++- tests/CMakeLists.txt | 1 + tests/container_multidevice_tests.cu | 24 ++--- tests/cuda_stream_tests.cpp | 4 +- tests/device_buffer_tests.cu | 14 +-- tests/device_check_resource_adaptor.hpp | 16 ++-- tests/device_scalar_tests.cpp | 4 +- tests/device_uvector_tests.cpp | 2 +- tests/mock_resource.hpp | 5 + tests/mr/device/adaptor_tests.cpp | 3 +- tests/mr/device/aligned_mr_tests.cpp | 6 +- tests/mr/device/arena_mr_tests.cpp | 50 +++++----- tests/mr/device/callback_mr_tests.cpp | 39 ++++---- tests/mr/device/failure_callback_mr_tests.cpp | 3 +- tests/mr/device/limiting_mr_tests.cpp | 16 ++-- tests/mr/device/pool_mr_tests.cpp | 40 +++----- tests/mr/device/statistics_mr_tests.cpp | 20 ++-- tests/mr/device/thrust_allocator_tests.cu | 10 +- tests/mr/device/tracking_mr_tests.cpp | 26 +++--- tests/mr/host/mr_ref_tests.cpp | 3 + 44 files changed, 639 insertions(+), 387 deletions(-) diff --git a/benchmarks/device_uvector/device_uvector_bench.cu b/benchmarks/device_uvector/device_uvector_bench.cu index 36c9183f9..0eddb1d92 100644 --- a/benchmarks/device_uvector/device_uvector_bench.cu +++ b/benchmarks/device_uvector/device_uvector_bench.cu @@ -40,7 +40,7 @@ void BM_UvectorSizeConstruction(benchmark::State& state) rmm::mr::cuda_memory_resource cuda_mr{}; rmm::mr::pool_memory_resource mr{ &cuda_mr, rmm::percent_of_free_device_memory(50)}; - rmm::mr::set_current_device_resource(&mr); + rmm::mr::set_current_device_resource_ref(mr); for (auto _ : state) { // NOLINT(clang-analyzer-deadcode.DeadStores) rmm::device_uvector vec(state.range(0), rmm::cuda_stream_view{}); @@ -49,7 +49,7 @@ void BM_UvectorSizeConstruction(benchmark::State& state) state.SetItemsProcessed(static_cast(state.iterations())); - rmm::mr::set_current_device_resource(nullptr); + rmm::mr::reset_current_device_resource_ref(); } BENCHMARK(BM_UvectorSizeConstruction) @@ -62,7 +62,7 @@ void BM_ThrustVectorSizeConstruction(benchmark::State& state) rmm::mr::cuda_memory_resource cuda_mr{}; rmm::mr::pool_memory_resource mr{ &cuda_mr, rmm::percent_of_free_device_memory(50)}; - rmm::mr::set_current_device_resource(&mr); + rmm::mr::set_current_device_resource_ref(mr); for (auto _ : state) { // NOLINT(clang-analyzer-deadcode.DeadStores) rmm::device_vector vec(state.range(0)); @@ -71,7 +71,7 @@ void BM_ThrustVectorSizeConstruction(benchmark::State& state) state.SetItemsProcessed(static_cast(state.iterations())); - rmm::mr::set_current_device_resource(nullptr); + rmm::mr::reset_current_device_resource_ref(); } BENCHMARK(BM_ThrustVectorSizeConstruction) @@ -140,7 +140,7 @@ template void BM_VectorWorkflow(benchmark::State& state) { rmm::mr::cuda_async_memory_resource cuda_async_mr{}; - rmm::mr::set_current_device_resource(&cuda_async_mr); + rmm::mr::set_current_device_resource_ref(cuda_async_mr); rmm::cuda_stream input_stream; std::vector streams(4); @@ -158,7 +158,7 @@ void BM_VectorWorkflow(benchmark::State& state) auto const bytes = num_elements * sizeof(std::int32_t) * num_accesses; state.SetBytesProcessed(static_cast(state.iterations() * bytes)); - rmm::mr::set_current_device_resource(nullptr); + rmm::mr::reset_current_device_resource_ref(); } BENCHMARK_TEMPLATE(BM_VectorWorkflow, thrust_vector) // NOLINT @@ -167,9 +167,9 @@ BENCHMARK_TEMPLATE(BM_VectorWorkflow, thrust_vector) // NOLINT ->Unit(benchmark::kMicrosecond) ->UseManualTime(); -// The only difference here is that `rmm::device_vector` uses `rmm::current_device_resource()` -// for allocation while `thrust::device_vector` uses cudaMalloc/cudaFree. In the benchmarks we use -// `cuda_async_memory_resource`, which is faster. +// The only difference here is that `rmm::device_vector` uses +// `rmm::get_current_device_resource_ref()` for allocation while `thrust::device_vector` uses +// cudaMalloc/cudaFree. In the benchmarks we use `cuda_async_memory_resource`, which is faster. BENCHMARK_TEMPLATE(BM_VectorWorkflow, rmm_vector) // NOLINT ->RangeMultiplier(10) // NOLINT ->Range(100'000, 100'000'000) // NOLINT diff --git a/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu b/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu index b73ef54f8..86e761c80 100644 --- a/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu +++ b/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu @@ -75,7 +75,7 @@ static void BM_MultiStreamAllocations(benchmark::State& state, MRFactoryFunc con { auto mr = factory(); - rmm::mr::set_current_device_resource(mr.get()); + rmm::mr::set_current_device_resource_ref(mr.get()); auto num_streams = state.range(0); auto num_kernels = state.range(1); @@ -92,7 +92,7 @@ static void BM_MultiStreamAllocations(benchmark::State& state, MRFactoryFunc con state.SetItemsProcessed(static_cast(state.iterations() * num_kernels)); - rmm::mr::set_current_device_resource(nullptr); + rmm::mr::reset_current_device_resource_ref(); } inline auto make_cuda() { return std::make_shared(); } diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index e6664e0f6..3ddd37415 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -41,7 +41,7 @@ namespace RMM_NAMESPACE { * * This class allocates untyped and *uninitialized* device memory using a * `device_async_resource_ref`. If not explicitly specified, the memory resource - * returned from `get_current_device_resource()` is used. + * returned from `get_current_device_resource_ref()` is used. * * @note Unlike `std::vector` or `thrust::device_vector`, the device memory * allocated by a `device_buffer` is uninitialized. Therefore, it is undefined @@ -95,7 +95,7 @@ class device_buffer { // `__host__ __device__` specifiers to the defaulted constructor when it is called within the // context of both host and device functions. Specifically, the `cudf::type_dispatcher` is a host- // device function. This causes warnings/errors because this ctor invokes host-only functions. - device_buffer() : _mr{rmm::mr::get_current_device_resource()} {} + device_buffer() : _mr{rmm::mr::get_current_device_resource_ref()} {} /** * @brief Constructs a new device buffer of `size` uninitialized bytes @@ -109,7 +109,7 @@ class device_buffer { */ explicit device_buffer(std::size_t size, cuda_stream_view stream, - device_async_resource_ref mr = mr::get_current_device_resource()) + device_async_resource_ref mr = mr::get_current_device_resource_ref()) : _stream{stream}, _mr{mr} { cuda_set_device_raii dev{_device}; @@ -138,7 +138,7 @@ class device_buffer { device_buffer(void const* source_data, std::size_t size, cuda_stream_view stream, - device_async_resource_ref mr = mr::get_current_device_resource()) + device_async_resource_ref mr = mr::get_current_device_resource_ref()) : _stream{stream}, _mr{mr} { cuda_set_device_raii dev{_device}; @@ -169,7 +169,7 @@ class device_buffer { */ device_buffer(device_buffer const& other, cuda_stream_view stream, - device_async_resource_ref mr = mr::get_current_device_resource()) + device_async_resource_ref mr = mr::get_current_device_resource_ref()) : device_buffer{other.data(), other.size(), stream, mr} { } @@ -419,8 +419,8 @@ class device_buffer { cuda_stream_view _stream{}; ///< Stream to use for device memory deallocation rmm::device_async_resource_ref _mr{ - rmm::mr::get_current_device_resource()}; ///< The memory resource used to - ///< allocate/deallocate device memory + rmm::mr::get_current_device_resource_ref()}; ///< The memory resource used to + ///< allocate/deallocate device memory cuda_device_id _device{get_current_cuda_device()}; /** diff --git a/include/rmm/device_scalar.hpp b/include/rmm/device_scalar.hpp index 95388eca9..62b004e2f 100644 --- a/include/rmm/device_scalar.hpp +++ b/include/rmm/device_scalar.hpp @@ -95,7 +95,7 @@ class device_scalar { * @param mr Optional, resource with which to allocate. */ explicit device_scalar(cuda_stream_view stream, - device_async_resource_ref mr = mr::get_current_device_resource()) + device_async_resource_ref mr = mr::get_current_device_resource_ref()) : _storage{1, stream, mr} { } @@ -118,7 +118,7 @@ class device_scalar { */ explicit device_scalar(value_type const& initial_value, cuda_stream_view stream, - device_async_resource_ref mr = mr::get_current_device_resource()) + device_async_resource_ref mr = mr::get_current_device_resource_ref()) : _storage{1, stream, mr} { set_value_async(initial_value, stream); @@ -138,7 +138,7 @@ class device_scalar { */ device_scalar(device_scalar const& other, cuda_stream_view stream, - device_async_resource_ref mr = mr::get_current_device_resource()) + device_async_resource_ref mr = mr::get_current_device_resource_ref()) : _storage{other._storage, stream, mr} { } diff --git a/include/rmm/device_uvector.hpp b/include/rmm/device_uvector.hpp index e1610a73a..13f566150 100644 --- a/include/rmm/device_uvector.hpp +++ b/include/rmm/device_uvector.hpp @@ -48,7 +48,7 @@ namespace RMM_NAMESPACE { * * Example: * @code{.cpp} - * rmm::mr::device_memory_resource * mr = new my_custom_resource(); + * auto mr = new my_custom_resource(); * rmm::cuda_stream_view s{}; * * // Allocates *uninitialized* device memory on stream `s` sufficient for 100 ints using the @@ -126,7 +126,7 @@ class device_uvector { */ explicit device_uvector(std::size_t size, cuda_stream_view stream, - device_async_resource_ref mr = mr::get_current_device_resource()) + device_async_resource_ref mr = mr::get_current_device_resource_ref()) : _storage{elements_to_bytes(size), stream, mr} { } @@ -142,7 +142,7 @@ class device_uvector { */ explicit device_uvector(device_uvector const& other, cuda_stream_view stream, - device_async_resource_ref mr = mr::get_current_device_resource()) + device_async_resource_ref mr = mr::get_current_device_resource_ref()) : _storage{other._storage, stream, mr} { } diff --git a/include/rmm/exec_policy.hpp b/include/rmm/exec_policy.hpp index 1c9a07abd..019a8245a 100644 --- a/include/rmm/exec_policy.hpp +++ b/include/rmm/exec_policy.hpp @@ -57,7 +57,7 @@ class exec_policy : public thrust_exec_policy_t { * @param mr The resource to use for allocating temporary memory */ explicit exec_policy(cuda_stream_view stream = cuda_stream_default, - device_async_resource_ref mr = mr::get_current_device_resource()) + device_async_resource_ref mr = mr::get_current_device_resource_ref()) : thrust_exec_policy_t( thrust::cuda::par(mr::thrust_allocator(stream, mr)).on(stream.value())) { @@ -81,7 +81,7 @@ using thrust_exec_policy_nosync_t = class exec_policy_nosync : public thrust_exec_policy_nosync_t { public: explicit exec_policy_nosync(cuda_stream_view stream = cuda_stream_default, - device_async_resource_ref mr = mr::get_current_device_resource()) + device_async_resource_ref mr = mr::get_current_device_resource_ref()) : thrust_exec_policy_nosync_t( thrust::cuda::par_nosync(mr::thrust_allocator(stream, mr)).on(stream.value())) { diff --git a/include/rmm/mr/device/aligned_resource_adaptor.hpp b/include/rmm/mr/device/aligned_resource_adaptor.hpp index 85eddb427..4df2c4d2d 100644 --- a/include/rmm/mr/device/aligned_resource_adaptor.hpp +++ b/include/rmm/mr/device/aligned_resource_adaptor.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -59,7 +60,6 @@ class aligned_resource_adaptor final : public device_memory_resource { /** * @brief Construct an aligned resource adaptor using `upstream` to satisfy allocation requests. * - * @throws rmm::logic_error if `upstream == nullptr` * @throws rmm::logic_error if `allocation_alignment` is not a power of 2 * * @param upstream The resource used for allocating/deallocating device memory. @@ -67,12 +67,33 @@ class aligned_resource_adaptor final : public device_memory_resource { * @param alignment_threshold Only allocations with a size larger than or equal to this threshold * are aligned. */ - explicit aligned_resource_adaptor(Upstream* upstream, + explicit aligned_resource_adaptor(device_async_resource_ref upstream, std::size_t alignment = rmm::CUDA_ALLOCATION_ALIGNMENT, std::size_t alignment_threshold = default_alignment_threshold) : upstream_{upstream}, alignment_{alignment}, alignment_threshold_{alignment_threshold} { - RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); + RMM_EXPECTS(rmm::is_supported_alignment(alignment), + "Allocation alignment is not a power of 2."); + } + + /** + * @brief Construct an aligned resource adaptor using `upstream` to satisfy allocation requests. + * + * @throws rmm::logic_error if `upstream == nullptr` + * @throws rmm::logic_error if `alignment` is not a power of 2 + * + * @param upstream The resource used for allocating/deallocating device memory. + * @param alignment The size used for allocation alignment. + * @param alignment_threshold Only allocations with a size larger than or equal to this threshold + * are aligned. + */ + explicit aligned_resource_adaptor(Upstream* upstream, + std::size_t alignment = rmm::CUDA_ALLOCATION_ALIGNMENT, + std::size_t alignment_threshold = default_alignment_threshold) + : upstream_{to_device_async_resource_ref_checked(upstream)}, + alignment_{alignment}, + alignment_threshold_{alignment_threshold} + { RMM_EXPECTS(rmm::is_supported_alignment(alignment), "Allocation alignment is not a power of 2."); } @@ -92,11 +113,6 @@ class aligned_resource_adaptor final : public device_memory_resource { return upstream_; } - /** - * @briefreturn{Upstream* to the upstream memory resource} - */ - [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } - /** * @brief The default alignment used by the adaptor. */ @@ -106,8 +122,8 @@ class aligned_resource_adaptor final : public device_memory_resource { using lock_guard = std::lock_guard; /** - * @brief Allocates memory of size at least `bytes` using the upstream resource with the specified - * alignment. + * @brief Allocates memory of size at least `bytes` using the upstream resource with the + * specified alignment. * * @throws rmm::bad_alloc if the requested allocation could not be fulfilled * by the upstream resource. @@ -119,10 +135,10 @@ class aligned_resource_adaptor final : public device_memory_resource { void* do_allocate(std::size_t bytes, cuda_stream_view stream) override { if (alignment_ == rmm::CUDA_ALLOCATION_ALIGNMENT || bytes < alignment_threshold_) { - return upstream_->allocate(bytes, stream); + return get_upstream_resource().allocate_async(bytes, 1, stream); } auto const size = upstream_allocation_size(bytes); - void* pointer = upstream_->allocate(size, stream); + void* pointer = get_upstream_resource().allocate_async(size, 1, stream); // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) auto const address = reinterpret_cast(pointer); auto const aligned_address = rmm::align_up(address, alignment_); @@ -145,7 +161,7 @@ class aligned_resource_adaptor final : public device_memory_resource { void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override { if (alignment_ == rmm::CUDA_ALLOCATION_ALIGNMENT || bytes < alignment_threshold_) { - upstream_->deallocate(ptr, bytes, stream); + get_upstream_resource().deallocate_async(ptr, bytes, 1, stream); } else { { lock_guard lock(mtx_); @@ -155,7 +171,7 @@ class aligned_resource_adaptor final : public device_memory_resource { pointers_.erase(iter); } } - upstream_->deallocate(ptr, upstream_allocation_size(bytes), stream); + get_upstream_resource().deallocate_async(ptr, upstream_allocation_size(bytes), 1, stream); } } @@ -176,8 +192,8 @@ class aligned_resource_adaptor final : public device_memory_resource { } /** - * @brief Calculate the allocation size needed from upstream to account for alignments of both the - * size and the base pointer. + * @brief Calculate the allocation size needed from upstream to account for alignments of both + * the size and the base pointer. * * @param bytes The requested allocation size. * @return Allocation size needed from upstream to align both the size and the base pointer. @@ -188,7 +204,8 @@ class aligned_resource_adaptor final : public device_memory_resource { return aligned_size + alignment_ - rmm::CUDA_ALLOCATION_ALIGNMENT; } - Upstream* upstream_; ///< The upstream resource used for satisfying allocation requests + /// The upstream resource used for satisfying allocation requests + device_async_resource_ref upstream_; std::unordered_map pointers_; ///< Map of aligned pointers to upstream pointers. std::size_t alignment_; ///< The size used for allocation alignment std::size_t alignment_threshold_; ///< The size above which allocations should be aligned diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index 388182e6a..417b7d2b4 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -82,6 +83,26 @@ namespace mr { template class arena_memory_resource final : public device_memory_resource { public: + /** + * @brief Construct an `arena_memory_resource`. + * + * @param upstream_mr The memory resource from which to allocate blocks for the global arena. + * @param arena_size Size in bytes of the global arena. Defaults to half of the available + * memory on the current device. + * @param dump_log_on_failure If true, dump memory log when running out of memory. + */ + explicit arena_memory_resource(device_async_resource_ref upstream_mr, + std::optional arena_size = std::nullopt, + bool dump_log_on_failure = false) + : global_arena_{upstream_mr, arena_size}, dump_log_on_failure_{dump_log_on_failure} + { + if (dump_log_on_failure_) { + logger_ = spdlog::basic_logger_mt("arena_memory_dump", "rmm_arena_memory_dump.log"); + // Set the level to `debug` for more detailed output. + logger_->set_level(spdlog::level::info); + } + } + /** * @brief Construct an `arena_memory_resource`. * @@ -95,7 +116,8 @@ class arena_memory_resource final : public device_memory_resource { explicit arena_memory_resource(Upstream* upstream_mr, std::optional arena_size = std::nullopt, bool dump_log_on_failure = false) - : global_arena_{upstream_mr, arena_size}, dump_log_on_failure_{dump_log_on_failure} + : global_arena_{to_device_async_resource_ref_checked(upstream_mr), arena_size}, + dump_log_on_failure_{dump_log_on_failure} { if (dump_log_on_failure_) { logger_ = spdlog::basic_logger_mt("arena_memory_dump", "rmm_arena_memory_dump.log"); @@ -113,8 +135,8 @@ class arena_memory_resource final : public device_memory_resource { arena_memory_resource& operator=(arena_memory_resource&&) noexcept = delete; private: - using global_arena = rmm::mr::detail::arena::global_arena; - using arena = rmm::mr::detail::arena::arena; + using global_arena = rmm::mr::detail::arena::global_arena; + using arena = rmm::mr::detail::arena::arena; /** * @brief Allocates memory of size at least `bytes`. @@ -274,7 +296,7 @@ class arena_memory_resource final : public device_memory_resource { std::unique_lock lock(map_mtx_); auto thread_arena = std::make_shared(global_arena_); thread_arenas_.emplace(thread_id, thread_arena); - thread_local detail::arena::arena_cleaner cleaner{thread_arena}; + thread_local detail::arena::arena_cleaner cleaner{thread_arena}; return *thread_arena; } } diff --git a/include/rmm/mr/device/binning_memory_resource.hpp b/include/rmm/mr/device/binning_memory_resource.hpp index 773035231..a5ef64665 100644 --- a/include/rmm/mr/device/binning_memory_resource.hpp +++ b/include/rmm/mr/device/binning_memory_resource.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include namespace RMM_NAMESPACE { @@ -52,16 +53,48 @@ class binning_memory_resource final : public device_memory_resource { * Initially has no bins, so simply uses the upstream_resource until bin resources are added * with `add_bin`. * - * @throws rmm::logic_error if size_base is not a power of two. + * @param upstream_resource The upstream memory resource used to allocate bin pools. + */ + explicit binning_memory_resource(device_async_resource_ref upstream_resource) + : upstream_mr_{upstream_resource} + { + } + + /** + * @brief Construct a new binning memory resource object. + * + * Initially has no bins, so simply uses the upstream_resource until bin resources are added + * with `add_bin`. + * + * @throws rmm::logic_error if upstream_resource is nullptr * * @param upstream_resource The upstream memory resource used to allocate bin pools. */ explicit binning_memory_resource(Upstream* upstream_resource) - : upstream_mr_{[upstream_resource]() { - RMM_EXPECTS(nullptr != upstream_resource, "Unexpected null upstream pointer."); - return upstream_resource; - }()} + : upstream_mr_{to_device_async_resource_ref_checked(upstream_resource)} + { + } + + /** + * @brief Construct a new binning memory resource object with a range of initial bins. + * + * Constructs a new binning memory resource and adds bins backed by `fixed_size_memory_resource` + * in the range [2^min_size_exponent, 2^max_size_exponent]. For example if `min_size_exponent==18` + * and `max_size_exponent==22`, creates bins of sizes 256KiB, 512KiB, 1024KiB, 2048KiB and + * 4096KiB. + * + * @param upstream_resource The upstream memory resource used to allocate bin pools. + * @param min_size_exponent The minimum base-2 exponent bin size. + * @param max_size_exponent The maximum base-2 exponent bin size. + */ + binning_memory_resource(device_async_resource_ref upstream_resource, + int8_t min_size_exponent, // NOLINT(bugprone-easily-swappable-parameters) + int8_t max_size_exponent) + : upstream_mr_{upstream_resource} { + for (auto i = min_size_exponent; i <= max_size_exponent; i++) { + add_bin(1 << i); + } } /** @@ -72,6 +105,8 @@ class binning_memory_resource final : public device_memory_resource { * and `max_size_exponent==22`, creates bins of sizes 256KiB, 512KiB, 1024KiB, 2048KiB and * 4096KiB. * + * @throws rmm::logic_error if upstream_resource is nullptr + * * @param upstream_resource The upstream memory resource used to allocate bin pools. * @param min_size_exponent The minimum base-2 exponent bin size. * @param max_size_exponent The maximum base-2 exponent bin size. @@ -79,10 +114,7 @@ class binning_memory_resource final : public device_memory_resource { binning_memory_resource(Upstream* upstream_resource, int8_t min_size_exponent, // NOLINT(bugprone-easily-swappable-parameters) int8_t max_size_exponent) - : upstream_mr_{[upstream_resource]() { - RMM_EXPECTS(nullptr != upstream_resource, "Unexpected null upstream pointer."); - return upstream_resource; - }()} + : upstream_mr_{to_device_async_resource_ref_checked(upstream_resource)} { for (auto i = min_size_exponent; i <= max_size_exponent; i++) { add_bin(1 << i); @@ -102,23 +134,17 @@ class binning_memory_resource final : public device_memory_resource { binning_memory_resource& operator=(binning_memory_resource&&) = delete; /** - * @briefreturn{rmm::device_async_resource_ref to the upstream resource} + * @briefreturn{device_async_resource_ref to the upstream resource} */ - [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + [[nodiscard]] device_async_resource_ref get_upstream_resource() const noexcept { return upstream_mr_; } - /** - * @briefreturn{Upstream* to the upstream memory resource} - */ - [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_mr_; } - /** * @brief Add a bin allocator to this resource * - * Adds `bin_resource` if it is not null; otherwise constructs and adds a - * fixed_size_memory_resource. + * Adds `bin_resource` if provided; otherwise constructs and adds a fixed_size_memory_resource. * * This bin will be used for any allocation smaller than `allocation_size` that is larger than * the next smaller bin's allocation size. @@ -130,14 +156,14 @@ class binning_memory_resource final : public device_memory_resource { * @param allocation_size The maximum size that this bin allocates * @param bin_resource The memory resource for the bin */ - void add_bin(std::size_t allocation_size, device_memory_resource* bin_resource = nullptr) + void add_bin(std::size_t allocation_size, + std::optional bin_resource = std::nullopt) { - allocation_size = rmm::align_up(allocation_size, rmm::CUDA_ALLOCATION_ALIGNMENT); + allocation_size = align_up(allocation_size, CUDA_ALLOCATION_ALIGNMENT); - if (nullptr != bin_resource) { - resource_bins_.insert({allocation_size, bin_resource}); + if (bin_resource.has_value()) { + resource_bins_.insert({allocation_size, bin_resource.value()}); } else if (resource_bins_.count(allocation_size) == 0) { // do nothing if bin already exists - owned_bin_resources_.push_back( std::make_unique>(upstream_mr_, allocation_size)); resource_bins_.insert({allocation_size, owned_bin_resources_.back().get()}); @@ -153,11 +179,10 @@ class binning_memory_resource final : public device_memory_resource { * @param bytes Requested allocation size in bytes * @return Get the resource reference for the requested size. */ - rmm::device_async_resource_ref get_resource_ref(std::size_t bytes) + device_async_resource_ref get_resource_ref(std::size_t bytes) { auto iter = resource_bins_.lower_bound(bytes); - return (iter != resource_bins_.cend()) ? rmm::device_async_resource_ref{iter->second} - : get_upstream_resource(); + return (iter != resource_bins_.cend()) ? iter->second : get_upstream_resource(); } /** @@ -188,11 +213,12 @@ class binning_memory_resource final : public device_memory_resource { get_resource_ref(bytes).deallocate_async(ptr, bytes, stream); } - Upstream* upstream_mr_; // The upstream memory_resource from which to allocate blocks. + device_async_resource_ref + upstream_mr_; // The upstream memory_resource from which to allocate blocks. std::vector>> owned_bin_resources_; - std::map resource_bins_; + std::map resource_bins_; }; /** @} */ // end of group diff --git a/include/rmm/mr/device/callback_memory_resource.hpp b/include/rmm/mr/device/callback_memory_resource.hpp index c569f7dd6..fa2d8056d 100644 --- a/include/rmm/mr/device/callback_memory_resource.hpp +++ b/include/rmm/mr/device/callback_memory_resource.hpp @@ -86,12 +86,13 @@ class callback_memory_resource final : public device_memory_resource { * It is the caller's responsibility to maintain the lifetime of the pointed-to data * for the duration of the lifetime of the `callback_memory_resource`. */ - callback_memory_resource(allocate_callback_t allocate_callback, - deallocate_callback_t deallocate_callback, - void* allocate_callback_arg = nullptr, - void* deallocate_callback_arg = nullptr) noexcept - : allocate_callback_(allocate_callback), - deallocate_callback_(deallocate_callback), + callback_memory_resource( + allocate_callback_t allocate_callback, + deallocate_callback_t deallocate_callback, + void* allocate_callback_arg = nullptr, // NOLINT(bugprone-easily-swappable-parameters) + void* deallocate_callback_arg = nullptr) noexcept + : allocate_callback_(std::move(allocate_callback)), + deallocate_callback_(std::move(deallocate_callback)), allocate_callback_arg_(allocate_callback_arg), deallocate_callback_arg_(deallocate_callback_arg) { diff --git a/include/rmm/mr/device/detail/arena.hpp b/include/rmm/mr/device/detail/arena.hpp index 3d24cfebf..6f8303c83 100644 --- a/include/rmm/mr/device/detail/arena.hpp +++ b/include/rmm/mr/device/detail/arena.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -494,22 +495,18 @@ inline auto max_free_size(std::set const& superblocks) * @tparam Upstream Memory resource to use for allocating the arena. Implements * rmm::mr::device_memory_resource interface. */ -template class global_arena final { public: /** * @brief Construct a global arena. * - * @throws rmm::logic_error if `upstream_mr == nullptr`. - * * @param upstream_mr The memory resource from which to allocate blocks for the pool * @param arena_size Size in bytes of the global arena. Defaults to half of the available memory * on the current device. */ - global_arena(Upstream* upstream_mr, std::optional arena_size) + global_arena(device_async_resource_ref upstream_mr, std::optional arena_size) : upstream_mr_{upstream_mr} { - RMM_EXPECTS(nullptr != upstream_mr_, "Unexpected null upstream pointer."); auto const size = rmm::align_down(arena_size.value_or(default_size()), rmm::CUDA_ALLOCATION_ALIGNMENT); RMM_EXPECTS(size >= superblock::minimum_size, @@ -530,7 +527,7 @@ class global_arena final { ~global_arena() { std::lock_guard lock(mtx_); - upstream_mr_->deallocate(upstream_block_.pointer(), upstream_block_.size()); + upstream_mr_.deallocate(upstream_block_.pointer(), upstream_block_.size()); } /** @@ -539,7 +536,7 @@ class global_arena final { * @param size The size in bytes of the allocation. * @return bool True if the allocation should be handled by the global arena. */ - bool handles(std::size_t size) const { return size > superblock::minimum_size; } + static bool handles(std::size_t size) { return size > superblock::minimum_size; } /** * @brief Acquire a superblock that can fit a block of the given size. @@ -610,7 +607,7 @@ class global_arena final { * @param stream Stream on which to perform deallocation. * @return bool true if the allocation is found, false otherwise. */ - bool deallocate(void* ptr, std::size_t size, cuda_stream_view stream) + bool deallocate_async(void* ptr, std::size_t size, cuda_stream_view stream) { RMM_LOGGING_ASSERT(handles(size)); stream.synchronize_no_throw(); @@ -692,7 +689,7 @@ class global_arena final { * @brief Default size of the global arena if unspecified. * @return the default global arena size. */ - constexpr std::size_t default_size() const + static std::size_t default_size() { auto const [free, total] = rmm::available_device_memory(); return free / 2; @@ -705,7 +702,7 @@ class global_arena final { */ void initialize(std::size_t size) { - upstream_block_ = {upstream_mr_->allocate(size), size}; + upstream_block_ = {upstream_mr_.allocate(size), size}; superblocks_.emplace(upstream_block_.pointer(), size); } @@ -777,7 +774,7 @@ class global_arena final { } /// The upstream resource to allocate memory from. - Upstream* upstream_mr_; + device_async_resource_ref upstream_mr_; /// Block allocated from upstream so that it can be quickly freed. block upstream_block_; /// Address-ordered set of superblocks. @@ -795,7 +792,6 @@ class global_arena final { * @tparam Upstream Memory resource to use for allocating the global arena. Implements * rmm::mr::device_memory_resource interface. */ -template class arena { public: /** @@ -803,7 +799,7 @@ class arena { * * @param global_arena The global arena from which to allocate superblocks. */ - explicit arena(global_arena& global_arena) : global_arena_{global_arena} {} + explicit arena(global_arena& global_arena) : global_arena_{global_arena} {} // Disable copy (and move) semantics. arena(arena const&) = delete; @@ -837,7 +833,9 @@ class arena { */ bool deallocate(void* ptr, std::size_t size, cuda_stream_view stream) { - if (global_arena_.handles(size) && global_arena_.deallocate(ptr, size, stream)) { return true; } + if (global_arena::handles(size) && global_arena_.deallocate_async(ptr, size, stream)) { + return true; + } return deallocate(ptr, size); } @@ -961,7 +959,7 @@ class arena { } /// The global arena to allocate superblocks from. - global_arena& global_arena_; + global_arena& global_arena_; /// Acquired superblocks. std::set superblocks_; /// Mutex for exclusive lock. @@ -976,10 +974,9 @@ class arena { * @tparam Upstream Memory resource to use for allocating the global arena. Implements * rmm::mr::device_memory_resource interface. */ -template class arena_cleaner { public: - explicit arena_cleaner(std::shared_ptr> const& arena) : arena_(arena) {} + explicit arena_cleaner(std::shared_ptr const& arena) : arena_(arena) {} // Disable copy (and move) semantics. arena_cleaner(arena_cleaner const&) = delete; @@ -997,7 +994,7 @@ class arena_cleaner { private: /// A non-owning pointer to the arena that may need cleaning. - std::weak_ptr> arena_; + std::weak_ptr arena_; }; } // namespace mr::detail::arena diff --git a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp index eeebaac3b..fdb385748 100644 --- a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp +++ b/include/rmm/mr/device/failure_callback_resource_adaptor.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -81,9 +82,9 @@ using failure_callback_t = std::function; * { * bool retried{false}; * failure_callback_adaptor mr{ - * rmm::mr::get_current_device_resource(), failure_handler, &retried + * rmm::mr::get_current_device_resource_ref(), failure_handler, &retried * }; - * rmm::mr::set_current_device_resource(&mr); + * rmm::mr::set_current_device_resource_ref(mr); * } * @endcode * @@ -95,6 +96,21 @@ class failure_callback_resource_adaptor final : public device_memory_resource { public: using exception_type = ExceptionType; ///< The type of exception this object catches/throws + /** + * @brief Construct a new `failure_callback_resource_adaptor` using `upstream` to satisfy + * allocation requests. + * + * @param upstream The resource used for allocating/deallocating device memory + * @param callback Callback function @see failure_callback_t + * @param callback_arg Extra argument passed to `callback` + */ + failure_callback_resource_adaptor(device_async_resource_ref upstream, + failure_callback_t callback, + void* callback_arg) + : upstream_{upstream}, callback_{std::move(callback)}, callback_arg_{callback_arg} + { + } + /** * @brief Construct a new `failure_callback_resource_adaptor` using `upstream` to satisfy * allocation requests. @@ -108,9 +124,10 @@ class failure_callback_resource_adaptor final : public device_memory_resource { failure_callback_resource_adaptor(Upstream* upstream, failure_callback_t callback, void* callback_arg) - : upstream_{upstream}, callback_{std::move(callback)}, callback_arg_{callback_arg} + : upstream_{to_device_async_resource_ref_checked(upstream)}, + callback_{std::move(callback)}, + callback_arg_{callback_arg} { - RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); } failure_callback_resource_adaptor() = delete; @@ -130,11 +147,6 @@ class failure_callback_resource_adaptor final : public device_memory_resource { return upstream_; } - /** - * @briefreturn{Upstream* to the upstream memory resource} - */ - [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } - private: /** * @brief Allocates memory of size at least `bytes` using the upstream @@ -153,7 +165,7 @@ class failure_callback_resource_adaptor final : public device_memory_resource { while (true) { try { - ret = upstream_->allocate(bytes, stream); + ret = get_upstream_resource().allocate_async(bytes, stream); break; } catch (exception_type const& e) { if (!callback_(bytes, callback_arg_)) { throw; } @@ -171,7 +183,7 @@ class failure_callback_resource_adaptor final : public device_memory_resource { */ void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override { - upstream_->deallocate(ptr, bytes, stream); + get_upstream_resource().deallocate_async(ptr, bytes, stream); } /** @@ -185,11 +197,12 @@ class failure_callback_resource_adaptor final : public device_memory_resource { { if (this == &other) { return true; } auto cast = dynamic_cast const*>(&other); - if (cast == nullptr) { return upstream_->is_equal(other); } + if (cast == nullptr) { return false; } return get_upstream_resource() == cast->get_upstream_resource(); } - Upstream* upstream_; // the upstream resource used for satisfying allocation requests + // the upstream resource used for satisfying allocation requests + device_async_resource_ref upstream_; failure_callback_t callback_; void* callback_arg_; }; diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index 84cb3b0c6..249af77dd 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -65,7 +65,31 @@ class fixed_size_memory_resource /** * @brief Construct a new `fixed_size_memory_resource` that allocates memory from - * `upstream_resource`. + * `upstream_mr`. + * + * When the pool of blocks is all allocated, grows the pool by allocating + * `blocks_to_preallocate` more blocks from `upstream_mr`. + * + * @param upstream_mr The device_async_resource_ref from which to allocate blocks for the pool. + * @param block_size The size of blocks to allocate. + * @param blocks_to_preallocate The number of blocks to allocate to initialize the pool. + */ + explicit fixed_size_memory_resource( + device_async_resource_ref upstream_mr, + // NOLINTNEXTLINE bugprone-easily-swappable-parameters + std::size_t block_size = default_block_size, + std::size_t blocks_to_preallocate = default_blocks_to_preallocate) + : upstream_mr_{upstream_mr}, + block_size_{align_up(block_size, CUDA_ALLOCATION_ALIGNMENT)}, + upstream_chunk_size_{block_size_ * blocks_to_preallocate} + { + // allocate initial blocks and insert into free list + this->insert_blocks(std::move(blocks_from_upstream(cuda_stream_legacy)), cuda_stream_legacy); + } + + /** + * @brief Construct a new `fixed_size_memory_resource` that allocates memory from + * `upstream_mr`. * * When the pool of blocks is all allocated, grows the pool by allocating * `blocks_to_preallocate` more blocks from `upstream_mr`. @@ -76,11 +100,12 @@ class fixed_size_memory_resource */ explicit fixed_size_memory_resource( Upstream* upstream_mr, + // NOLINTNEXTLINE bugprone-easily-swappable-parameters std::size_t block_size = default_block_size, std::size_t blocks_to_preallocate = default_blocks_to_preallocate) - : upstream_mr_{upstream_mr}, - block_size_{rmm::align_up(block_size, rmm::CUDA_ALLOCATION_ALIGNMENT)}, - upstream_chunk_size_{block_size * blocks_to_preallocate} + : upstream_mr_{to_device_async_resource_ref_checked(upstream_mr)}, + block_size_{align_up(block_size, CUDA_ALLOCATION_ALIGNMENT)}, + upstream_chunk_size_{block_size_ * blocks_to_preallocate} { // allocate initial blocks and insert into free list this->insert_blocks(std::move(blocks_from_upstream(cuda_stream_legacy)), cuda_stream_legacy); @@ -99,18 +124,13 @@ class fixed_size_memory_resource fixed_size_memory_resource& operator=(fixed_size_memory_resource&&) = delete; /** - * @briefreturn{rmm::device_async_resource_ref to the upstream resource} + * @briefreturn{device_async_resource_ref to the upstream resource} */ - [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + [[nodiscard]] device_async_resource_ref get_upstream_resource() const noexcept { return upstream_mr_; } - /** - * @briefreturn{Upstream* to the upstream memory resource} - */ - [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_mr_; } - /** * @brief Get the size of blocks allocated by this memory resource. * @@ -200,7 +220,7 @@ class fixed_size_memory_resource { // Deallocating a fixed-size block just inserts it in the free list, which is // handled by the parent class - RMM_LOGGING_ASSERT(rmm::align_up(size, rmm::CUDA_ALLOCATION_ALIGNMENT) <= block_size_); + RMM_LOGGING_ASSERT(align_up(size, CUDA_ALLOCATION_ALIGNMENT) <= block_size_); return block_type{ptr}; } @@ -254,10 +274,10 @@ class fixed_size_memory_resource } private: - Upstream* upstream_mr_; // The resource from which to allocate new blocks + device_async_resource_ref upstream_mr_; // The resource from which to allocate new blocks - std::size_t const block_size_; // size of blocks this MR allocates - std::size_t const upstream_chunk_size_; // size of chunks allocated from heap MR + std::size_t block_size_; // size of blocks this MR allocates + std::size_t upstream_chunk_size_; // size of chunks allocated from heap MR // blocks allocated from heap: so they can be easily freed std::vector upstream_blocks_; diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index c3ef72e09..d19fa3a0a 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -45,6 +46,24 @@ namespace mr { template class limiting_resource_adaptor final : public device_memory_resource { public: + /** + * @brief Construct a new limiting resource adaptor using `upstream` to satisfy + * allocation requests and limiting the total allocation amount possible. + * + * @param upstream The resource used for allocating/deallocating device memory + * @param allocation_limit Maximum memory allowed for this allocator + * @param alignment Alignment in bytes for the start of each allocated buffer + */ + limiting_resource_adaptor(device_async_resource_ref upstream, + std::size_t allocation_limit, + std::size_t alignment = CUDA_ALLOCATION_ALIGNMENT) + : upstream_{upstream}, + allocation_limit_{allocation_limit}, + allocated_bytes_(0), + alignment_(alignment) + { + } + /** * @brief Construct a new limiting resource adaptor using `upstream` to satisfy * allocation requests and limiting the total allocation amount possible. @@ -57,13 +76,12 @@ class limiting_resource_adaptor final : public device_memory_resource { */ limiting_resource_adaptor(Upstream* upstream, std::size_t allocation_limit, - std::size_t alignment = rmm::CUDA_ALLOCATION_ALIGNMENT) - : allocation_limit_{allocation_limit}, + std::size_t alignment = CUDA_ALLOCATION_ALIGNMENT) + : upstream_{to_device_async_resource_ref_checked(upstream)}, + allocation_limit_{allocation_limit}, allocated_bytes_(0), - alignment_(alignment), - upstream_{upstream} + alignment_(alignment) { - RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); } limiting_resource_adaptor() = delete; @@ -76,18 +94,13 @@ class limiting_resource_adaptor final : public device_memory_resource { default; ///< @default_move_assignment{limiting_resource_adaptor} /** - * @briefreturn{rmm::device_async_resource_ref to the upstream resource} + * @briefreturn{device_async_resource_ref to the upstream resource} */ - [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + [[nodiscard]] device_async_resource_ref get_upstream_resource() const noexcept { return upstream_; } - /** - * @briefreturn{Upstream* to the upstream memory resource} - */ - [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } - /** * @brief Query the number of bytes that have been allocated. Note that * this can not be used to know how large of an allocation is possible due @@ -124,11 +137,11 @@ class limiting_resource_adaptor final : public device_memory_resource { */ void* do_allocate(std::size_t bytes, cuda_stream_view stream) override { - auto const proposed_size = rmm::align_up(bytes, alignment_); + auto const proposed_size = align_up(bytes, alignment_); auto const old = allocated_bytes_.fetch_add(proposed_size); if (old + proposed_size <= allocation_limit_) { try { - return upstream_->allocate(bytes, stream); + return get_upstream_resource().allocate_async(bytes, stream); } catch (...) { allocated_bytes_ -= proposed_size; throw; @@ -148,8 +161,8 @@ class limiting_resource_adaptor final : public device_memory_resource { */ void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override { - std::size_t allocated_size = rmm::align_up(bytes, alignment_); - upstream_->deallocate(ptr, bytes, stream); + std::size_t allocated_size = align_up(bytes, alignment_); + get_upstream_resource().deallocate_async(ptr, bytes, stream); allocated_bytes_ -= allocated_size; } @@ -164,10 +177,13 @@ class limiting_resource_adaptor final : public device_memory_resource { { if (this == &other) { return true; } auto const* cast = dynamic_cast const*>(&other); - if (cast == nullptr) { return upstream_->is_equal(other); } + if (cast == nullptr) { return false; } return get_upstream_resource() == cast->get_upstream_resource(); } + // The upstream resource used for satisfying allocation requests + device_async_resource_ref upstream_; + // maximum bytes this allocator is allowed to allocate. std::size_t allocation_limit_; @@ -176,9 +192,6 @@ class limiting_resource_adaptor final : public device_memory_resource { // todo: should be some way to ask the upstream... std::size_t alignment_; - - Upstream* upstream_; ///< The upstream resource used for satisfying - ///< allocation requests }; /** diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 1b4d80f14..595ab2e4e 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -77,10 +77,8 @@ class logging_resource_adaptor final : public device_memory_resource { logging_resource_adaptor(Upstream* upstream, std::string const& filename = get_default_filename(), bool auto_flush = false) - : logger_{make_logger(filename)}, upstream_{upstream} + : logger_{make_logger(filename)}, upstream_{to_device_async_resource_ref_checked(upstream)} { - RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); - init_logger(auto_flush); } @@ -99,10 +97,8 @@ class logging_resource_adaptor final : public device_memory_resource { * performance. */ logging_resource_adaptor(Upstream* upstream, std::ostream& stream, bool auto_flush = false) - : logger_{make_logger(stream)}, upstream_{upstream} + : logger_{make_logger(stream)}, upstream_{to_device_async_resource_ref_checked(upstream)} { - RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); - init_logger(auto_flush); } @@ -123,10 +119,76 @@ class logging_resource_adaptor final : public device_memory_resource { logging_resource_adaptor(Upstream* upstream, spdlog::sinks_init_list sinks, bool auto_flush = false) - : logger_{make_logger(sinks)}, upstream_{upstream} + : logger_{make_logger(sinks)}, upstream_{to_device_async_resource_ref_checked(upstream)} + { + init_logger(auto_flush); + } + + /** + * @brief Construct a new logging resource adaptor using `upstream` to satisfy + * allocation requests and logging information about each allocation/free to + * the file specified by `filename`. + * + * The logfile will be written using CSV formatting. + * + * Clears the contents of `filename` if it already exists. + * + * Creating multiple `logging_resource_adaptor`s with the same `filename` will + * result in undefined behavior. + * + * @throws spdlog::spdlog_ex if opening `filename` failed + * + * @param upstream The resource_ref used for allocating/deallocating device memory. + * @param filename Name of file to write log info. If not specified, retrieves + * the file name from the environment variable "RMM_LOG_FILE". + * @param auto_flush If true, flushes the log for every (de)allocation. Warning, this will degrade + * performance. + */ + logging_resource_adaptor(device_async_resource_ref upstream, + std::string const& filename = get_default_filename(), + bool auto_flush = false) + : logger_{make_logger(filename)}, upstream_{upstream} + { + init_logger(auto_flush); + } + + /** + * @brief Construct a new logging resource adaptor using `upstream` to satisfy + * allocation requests and logging information about each allocation/free to + * the ostream specified by `stream`. + * + * The logfile will be written using CSV formatting. + * + * @param upstream The resource_ref used for allocating/deallocating device memory. + * @param stream The ostream to write log info. + * @param auto_flush If true, flushes the log for every (de)allocation. Warning, this will degrade + * performance. + */ + logging_resource_adaptor(device_async_resource_ref upstream, + std::ostream& stream, + bool auto_flush = false) + : logger_{make_logger(stream)}, upstream_{upstream} { - RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); + init_logger(auto_flush); + } + /** + * @brief Construct a new logging resource adaptor using `upstream` to satisfy + * allocation requests and logging information about each allocation/free to + * the ostream specified by `stream`. + * + * The logfile will be written using CSV formatting. + * + * @param upstream The resource_ref used for allocating/deallocating device memory. + * @param sinks A list of logging sinks to which log output will be written. + * @param auto_flush If true, flushes the log for every (de)allocation. Warning, this will degrade + * performance. + */ + logging_resource_adaptor(device_async_resource_ref upstream, + spdlog::sinks_init_list sinks, + bool auto_flush = false) + : logger_{make_logger(sinks)}, upstream_{upstream} + { init_logger(auto_flush); } @@ -147,11 +209,6 @@ class logging_resource_adaptor final : public device_memory_resource { return upstream_; } - /** - * @briefreturn{Upstream* to the upstream memory resource} - */ - [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } - /** * @brief Flush logger contents. */ @@ -239,7 +296,7 @@ class logging_resource_adaptor final : public device_memory_resource { void* do_allocate(std::size_t bytes, cuda_stream_view stream) override { try { - auto const ptr = upstream_->allocate(bytes, stream); + auto const ptr = get_upstream_resource().allocate_async(bytes, stream); logger_->info("allocate,{},{},{}", ptr, bytes, fmt::ptr(stream.value())); return ptr; } catch (...) { @@ -265,7 +322,7 @@ class logging_resource_adaptor final : public device_memory_resource { void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override { logger_->info("free,{},{},{}", ptr, bytes, fmt::ptr(stream.value())); - upstream_->deallocate(ptr, bytes, stream); + get_upstream_resource().deallocate_async(ptr, bytes, stream); } /** @@ -279,14 +336,14 @@ class logging_resource_adaptor final : public device_memory_resource { { if (this == &other) { return true; } auto const* cast = dynamic_cast const*>(&other); - if (cast == nullptr) { return upstream_->is_equal(other); } + if (cast == nullptr) { return false; } return get_upstream_resource() == cast->get_upstream_resource(); } std::shared_ptr logger_; ///< spdlog logger object - Upstream* upstream_; ///< The upstream resource used for satisfying - ///< allocation requests + device_async_resource_ref upstream_; ///< The upstream resource used for satisfying + ///< allocation requests }; /** diff --git a/include/rmm/mr/device/per_device_resource.hpp b/include/rmm/mr/device/per_device_resource.hpp index ff6321e25..855d4c0bf 100644 --- a/include/rmm/mr/device/per_device_resource.hpp +++ b/include/rmm/mr/device/per_device_resource.hpp @@ -193,6 +193,31 @@ inline device_memory_resource* get_per_device_resource(cuda_device_id device_id) : found->second; } +namespace detail { + +// The non-thread-safe implementation of `set_per_device_resource_ref`. This exists because +// we need to call this function from two places: the thread-safe version of +// `set_per_device_resource_ref` and the thread-safe version of `set_per_device_resource`, +// both of which take the lock, so we need an implementation that doesn't take the lock. +/// @private +inline device_async_resource_ref set_per_device_resource_ref_unsafe( + cuda_device_id device_id, device_async_resource_ref new_resource_ref) +{ + auto& map = detail::get_ref_map(); + auto const old_itr = map.find(device_id.value()); + // If a resource didn't previously exist for `device_id`, return pointer to initial_resource + // Note: because resource_ref is not default-constructible, we can't use std::map::operator[] + if (old_itr == map.end()) { + map.insert({device_id.value(), new_resource_ref}); + return device_async_resource_ref{detail::initial_resource()}; + } + + auto old_resource_ref = old_itr->second; + old_itr->second = new_resource_ref; // update map directly via iterator + return old_resource_ref; +} +} // namespace detail + /** * @brief Set the `device_memory_resource` for the specified device. * @@ -224,6 +249,14 @@ inline device_memory_resource* set_per_device_resource(cuda_device_id device_id, device_memory_resource* new_mr) { std::lock_guard lock{detail::map_lock()}; + + // Note: even though set_per_device_resource() and set_per_device_resource_ref() are not + // interchangeable, we call the latter from the former to maintain resource_ref + // state consistent with the resource pointer state. This is necessary because the + // Python API still uses the raw pointer API. Once the Python API is updated to use + // resource_ref, this call can be removed. + detail::set_per_device_resource_ref_unsafe(device_id, new_mr); + auto& map = detail::get_map(); auto const old_itr = map.find(device_id.value()); // If a resource didn't previously exist for `id`, return pointer to initial_resource @@ -350,18 +383,7 @@ inline device_async_resource_ref set_per_device_resource_ref( cuda_device_id device_id, device_async_resource_ref new_resource_ref) { std::lock_guard lock{detail::ref_map_lock()}; - auto& map = detail::get_ref_map(); - auto const old_itr = map.find(device_id.value()); - // If a resource didn't previously exist for `device_id`, return pointer to initial_resource - // Note: because resource_ref is not default-constructible, we can't use std::map::operator[] - if (old_itr == map.end()) { - map.insert({device_id.value(), new_resource_ref}); - return device_async_resource_ref{detail::initial_resource()}; - } - - auto old_resource_ref = old_itr->second; - old_itr->second = new_resource_ref; // update map directly via iterator - return old_resource_ref; + return detail::set_per_device_resource_ref_unsafe(device_id, new_resource_ref); } /** diff --git a/include/rmm/mr/device/polymorphic_allocator.hpp b/include/rmm/mr/device/polymorphic_allocator.hpp index 6fb068410..442632d4f 100644 --- a/include/rmm/mr/device/polymorphic_allocator.hpp +++ b/include/rmm/mr/device/polymorphic_allocator.hpp @@ -52,7 +52,7 @@ class polymorphic_allocator { using value_type = T; ///< T, the value type of objects allocated by this allocator /** * @brief Construct a `polymorphic_allocator` using the return value of - * `rmm::mr::get_current_device_resource()` as the underlying memory resource. + * `rmm::mr::get_current_device_resource_ref()` as the underlying memory resource. * */ polymorphic_allocator() = default; @@ -116,7 +116,7 @@ class polymorphic_allocator { private: rmm::device_async_resource_ref mr_{ - get_current_device_resource()}; ///< Underlying resource used for (de)allocation + get_current_device_resource_ref()}; ///< Underlying resource used for (de)allocation }; /** diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index d22b53404..f63de21ff 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -114,6 +115,33 @@ class pool_memory_resource final friend class detail::stream_ordered_memory_resource, detail::coalescing_free_list>; + /** + * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using + * `upstream_mr`. + * + * @throws rmm::logic_error if `initial_pool_size` is not aligned to a multiple of + * pool_memory_resource::allocation_alignment bytes. + * @throws rmm::logic_error if `maximum_pool_size` is neither the default nor aligned to a + * multiple of pool_memory_resource::allocation_alignment bytes. + * + * @param upstream_mr The memory_resource from which to allocate blocks for the pool. + * @param initial_pool_size Minimum size, in bytes, of the initial pool. + * @param maximum_pool_size Maximum size, in bytes, that the pool can grow to. Defaults to all + * of the available from the upstream resource. + */ + explicit pool_memory_resource(device_async_resource_ref upstream_mr, + std::size_t initial_pool_size, + std::optional maximum_pool_size = std::nullopt) + : upstream_mr_{upstream_mr} + { + RMM_EXPECTS(rmm::is_aligned(initial_pool_size, rmm::CUDA_ALLOCATION_ALIGNMENT), + "Error, Initial pool size required to be a multiple of 256 bytes"); + RMM_EXPECTS(rmm::is_aligned(maximum_pool_size.value_or(0), rmm::CUDA_ALLOCATION_ALIGNMENT), + "Error, Maximum pool size required to be a multiple of 256 bytes"); + + initialize_pool(initial_pool_size, maximum_pool_size); + } + /** * @brief Construct a `pool_memory_resource` and allocate the initial device memory pool using * `upstream_mr`. @@ -132,10 +160,7 @@ class pool_memory_resource final explicit pool_memory_resource(Upstream* upstream_mr, std::size_t initial_pool_size, std::optional maximum_pool_size = std::nullopt) - : upstream_mr_{[upstream_mr]() { - RMM_EXPECTS(nullptr != upstream_mr, "Unexpected null upstream pointer."); - return upstream_mr; - }()} + : upstream_mr_{to_device_async_resource_ref_checked(upstream_mr)} { RMM_EXPECTS(rmm::is_aligned(initial_pool_size, rmm::CUDA_ALLOCATION_ALIGNMENT), "Error, Initial pool size required to be a multiple of 256 bytes"); @@ -184,16 +209,11 @@ class pool_memory_resource final /** * @briefreturn{rmm::device_async_resource_ref to the upstream resource} */ - [[nodiscard]] rmm::device_async_resource_ref get_upstream_resource() const noexcept + [[nodiscard]] device_async_resource_ref get_upstream_resource() const noexcept { return upstream_mr_; } - /** - * @briefreturn{Upstream* to the upstream memory resource} - */ - [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_mr_; } - /** * @brief Computes the size of the current pool * @@ -466,7 +486,8 @@ class pool_memory_resource final } private: - Upstream* upstream_mr_; // The "heap" to allocate the pool from + // The "heap" to allocate the pool from + device_async_resource_ref upstream_mr_; std::size_t current_pool_size_{}; std::optional maximum_pool_size_{}; diff --git a/include/rmm/mr/device/prefetch_resource_adaptor.hpp b/include/rmm/mr/device/prefetch_resource_adaptor.hpp index 59ce8e036..d3a4c676a 100644 --- a/include/rmm/mr/device/prefetch_resource_adaptor.hpp +++ b/include/rmm/mr/device/prefetch_resource_adaptor.hpp @@ -41,6 +41,14 @@ namespace mr { template class prefetch_resource_adaptor final : public device_memory_resource { public: + /** + * @brief Construct a new prefetch resource adaptor using `upstream` to satisfy + * allocation requests. + * + * @param upstream The resource_ref used for allocating/deallocating device memory + */ + prefetch_resource_adaptor(device_async_resource_ref upstream) : upstream_{upstream} {} + /** * @brief Construct a new prefetch resource adaptor using `upstream` to satisfy * allocation requests. @@ -49,9 +57,9 @@ class prefetch_resource_adaptor final : public device_memory_resource { * * @param upstream The resource used for allocating/deallocating device memory */ - prefetch_resource_adaptor(Upstream* upstream) : upstream_{upstream} + prefetch_resource_adaptor(Upstream* upstream) + : upstream_{to_device_async_resource_ref_checked(upstream)} { - RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); } prefetch_resource_adaptor() = delete; @@ -71,11 +79,6 @@ class prefetch_resource_adaptor final : public device_memory_resource { return upstream_; } - /** - * @briefreturn{Upstream* to the upstream memory resource} - */ - [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } - private: /** * @brief Allocates memory of size at least `bytes` using the upstream @@ -92,7 +95,7 @@ class prefetch_resource_adaptor final : public device_memory_resource { */ void* do_allocate(std::size_t bytes, cuda_stream_view stream) override { - void* ptr = upstream_->allocate(bytes, stream); + void* ptr = get_upstream_resource().allocate_async(bytes, stream); rmm::prefetch(ptr, bytes, rmm::get_current_cuda_device(), stream); return ptr; } @@ -106,7 +109,7 @@ class prefetch_resource_adaptor final : public device_memory_resource { */ void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override { - upstream_->deallocate(ptr, bytes, stream); + get_upstream_resource().deallocate_async(ptr, bytes, stream); } /** @@ -120,11 +123,12 @@ class prefetch_resource_adaptor final : public device_memory_resource { { if (this == &other) { return true; } auto cast = dynamic_cast const*>(&other); - if (cast == nullptr) { return upstream_->is_equal(other); } + if (cast == nullptr) { return false; } return get_upstream_resource() == cast->get_upstream_resource(); } - Upstream* upstream_; // the upstream resource used for satisfying allocation requests + // the upstream resource used for satisfying allocation requests + device_async_resource_ref upstream_; }; /** @} */ // end of group diff --git a/include/rmm/mr/device/statistics_resource_adaptor.hpp b/include/rmm/mr/device/statistics_resource_adaptor.hpp index bf78c669a..025c51aa7 100644 --- a/include/rmm/mr/device/statistics_resource_adaptor.hpp +++ b/include/rmm/mr/device/statistics_resource_adaptor.hpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -113,17 +114,25 @@ class statistics_resource_adaptor final : public device_memory_resource { } }; + /** + * @brief Construct a new statistics resource adaptor using `upstream` to satisfy + * allocation requests. + * + * @param upstream The resource_ref used for allocating/deallocating device memory. + */ + statistics_resource_adaptor(device_async_resource_ref upstream) : upstream_{upstream} {} + /** * @brief Construct a new statistics resource adaptor using `upstream` to satisfy * allocation requests. * * @throws rmm::logic_error if `upstream == nullptr` * - * @param upstream The resource used for allocating/deallocating device memory + * @param upstream The resource used for allocating/deallocating device memory. */ - statistics_resource_adaptor(Upstream* upstream) : upstream_{upstream} + statistics_resource_adaptor(Upstream* upstream) + : upstream_{to_device_async_resource_ref_checked(upstream)} { - RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); } statistics_resource_adaptor() = delete; @@ -143,11 +152,6 @@ class statistics_resource_adaptor final : public device_memory_resource { return upstream_; } - /** - * @briefreturn{Upstream* to the upstream memory resource} - */ - [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } - /** * @brief Returns a `counter` struct for this adaptor containing the current, * peak, and total number of allocated bytes for this @@ -226,7 +230,7 @@ class statistics_resource_adaptor final : public device_memory_resource { */ void* do_allocate(std::size_t bytes, cuda_stream_view stream) override { - void* ptr = upstream_->allocate(bytes, stream); + void* ptr = get_upstream_resource().allocate_async(bytes, stream); // increment the stats { @@ -249,7 +253,7 @@ class statistics_resource_adaptor final : public device_memory_resource { */ void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override { - upstream_->deallocate(ptr, bytes, stream); + get_upstream_resource().deallocate_async(ptr, bytes, stream); { write_lock_t lock(mtx_); @@ -271,7 +275,7 @@ class statistics_resource_adaptor final : public device_memory_resource { { if (this == &other) { return true; } auto cast = dynamic_cast const*>(&other); - if (cast == nullptr) { return upstream_->is_equal(other); } + if (cast == nullptr) { return false; } return get_upstream_resource() == cast->get_upstream_resource(); } @@ -279,14 +283,14 @@ class statistics_resource_adaptor final : public device_memory_resource { // Invariant: the stack always contains at least one entry std::stack> counter_stack_{{std::make_pair(counter{}, counter{})}}; std::shared_mutex mutable mtx_; // mutex for thread safe access to allocations_ - Upstream* upstream_; // the upstream resource used for satisfying allocation requests + // the upstream resource used for satisfying allocation requests + device_async_resource_ref upstream_; }; /** * @brief Convenience factory to return a `statistics_resource_adaptor` around the * upstream resource `upstream`. * - * @tparam Upstream Type of the upstream `device_memory_resource`. * @param upstream Pointer to the upstream resource * @return The new statistics resource adaptor */ @@ -297,7 +301,7 @@ template "instead.")]] statistics_resource_adaptor make_statistics_adaptor(Upstream* upstream) { - return statistics_resource_adaptor{upstream}; + return statistics_resource_adaptor{upstream}; } /** @} */ // end of group diff --git a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp index 9979d1e08..6881aa19e 100644 --- a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp +++ b/include/rmm/mr/device/thread_safe_resource_adaptor.hpp @@ -45,6 +45,16 @@ class thread_safe_resource_adaptor final : public device_memory_resource { public: using lock_t = std::lock_guard; ///< Type of lock used to synchronize access + /** + * @brief Construct a new thread safe resource adaptor using `upstream` to satisfy + * allocation requests. + * + * All allocations and frees are protected by a mutex lock + * + * @param upstream The resource used for allocating/deallocating device memory. + */ + thread_safe_resource_adaptor(device_async_resource_ref upstream) : upstream_{upstream} {} + /** * @brief Construct a new thread safe resource adaptor using `upstream` to satisfy * allocation requests. @@ -55,9 +65,9 @@ class thread_safe_resource_adaptor final : public device_memory_resource { * * @param upstream The resource used for allocating/deallocating device memory. */ - thread_safe_resource_adaptor(Upstream* upstream) : upstream_{upstream} + thread_safe_resource_adaptor(Upstream* upstream) + : upstream_{to_device_async_resource_ref_checked(upstream)} { - RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); } thread_safe_resource_adaptor() = delete; @@ -75,11 +85,6 @@ class thread_safe_resource_adaptor final : public device_memory_resource { return upstream_; } - /** - * @briefreturn{Upstream* to the upstream memory resource} - */ - [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } - private: /** * @brief Allocates memory of size at least `bytes` using the upstream @@ -95,7 +100,7 @@ class thread_safe_resource_adaptor final : public device_memory_resource { void* do_allocate(std::size_t bytes, cuda_stream_view stream) override { lock_t lock(mtx); - return upstream_->allocate(bytes, stream); + return get_upstream_resource().allocate_async(bytes, stream); } /** @@ -108,7 +113,7 @@ class thread_safe_resource_adaptor final : public device_memory_resource { void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override { lock_t lock(mtx); - upstream_->deallocate(ptr, bytes, stream); + get_upstream_resource().deallocate_async(ptr, bytes, stream); } /** @@ -122,12 +127,13 @@ class thread_safe_resource_adaptor final : public device_memory_resource { { if (this == &other) { return true; } auto cast = dynamic_cast const*>(&other); - if (cast == nullptr) { return upstream_->is_equal(other); } + if (cast == nullptr) { return false; } return get_upstream_resource() == cast->get_upstream_resource(); } std::mutex mutable mtx; // mutex for thread safe access to upstream - Upstream* upstream_; ///< The upstream resource used for satisfying allocation requests + device_async_resource_ref + upstream_; ///< The upstream resource used for satisfying allocation requests }; /** @} */ // end of group diff --git a/include/rmm/mr/device/thrust_allocator_adaptor.hpp b/include/rmm/mr/device/thrust_allocator_adaptor.hpp index 2055a0633..b7b990c3d 100644 --- a/include/rmm/mr/device/thrust_allocator_adaptor.hpp +++ b/include/rmm/mr/device/thrust_allocator_adaptor.hpp @@ -150,7 +150,7 @@ class thrust_allocator : public thrust::device_malloc_allocator { private: cuda_stream_view _stream{}; - rmm::device_async_resource_ref _mr{rmm::mr::get_current_device_resource()}; + rmm::device_async_resource_ref _mr{rmm::mr::get_current_device_resource_ref()}; cuda_device_id _device{get_current_cuda_device()}; }; /** @} */ // end of group diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index 3d3188b23..6a5916e5c 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -83,6 +84,18 @@ class tracking_resource_adaptor final : public device_memory_resource { allocation_size{size} {}; }; + /** + * @brief Construct a new tracking resource adaptor using `upstream` to satisfy + * allocation requests. + * + * @param upstream The resource used for allocating/deallocating device memory + * @param capture_stacks If true, capture stacks for allocation calls + */ + tracking_resource_adaptor(device_async_resource_ref upstream, bool capture_stacks = false) + : capture_stacks_{capture_stacks}, allocated_bytes_{0}, upstream_{upstream} + { + } + /** * @brief Construct a new tracking resource adaptor using `upstream` to satisfy * allocation requests. @@ -93,9 +106,10 @@ class tracking_resource_adaptor final : public device_memory_resource { * @param capture_stacks If true, capture stacks for allocation calls */ tracking_resource_adaptor(Upstream* upstream, bool capture_stacks = false) - : capture_stacks_{capture_stacks}, allocated_bytes_{0}, upstream_{upstream} + : capture_stacks_{capture_stacks}, + allocated_bytes_{0}, + upstream_{to_device_async_resource_ref_checked(upstream)} { - RMM_EXPECTS(nullptr != upstream, "Unexpected null upstream resource pointer."); } tracking_resource_adaptor() = delete; @@ -115,11 +129,6 @@ class tracking_resource_adaptor final : public device_memory_resource { return upstream_; } - /** - * @briefreturn{Upstream* to the upstream memory resource} - */ - [[nodiscard]] Upstream* get_upstream() const noexcept { return upstream_; } - /** * @brief Get the outstanding allocations map * @@ -199,8 +208,7 @@ class tracking_resource_adaptor final : public device_memory_resource { */ void* do_allocate(std::size_t bytes, cuda_stream_view stream) override { - void* ptr = upstream_->allocate(bytes, stream); - + void* ptr = get_upstream_resource().allocate_async(bytes, stream); // track it. { write_lock_t lock(mtx_); @@ -220,7 +228,7 @@ class tracking_resource_adaptor final : public device_memory_resource { */ void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override { - upstream_->deallocate(ptr, bytes, stream); + get_upstream_resource().deallocate_async(ptr, bytes, stream); { write_lock_t lock(mtx_); @@ -265,7 +273,7 @@ class tracking_resource_adaptor final : public device_memory_resource { { if (this == &other) { return true; } auto cast = dynamic_cast const*>(&other); - if (cast == nullptr) { return upstream_->is_equal(other); } + if (cast == nullptr) { return false; } return get_upstream_resource() == cast->get_upstream_resource(); } @@ -273,7 +281,8 @@ class tracking_resource_adaptor final : public device_memory_resource { std::map allocations_; // map of active allocations std::atomic allocated_bytes_; // number of bytes currently allocated std::shared_mutex mutable mtx_; // mutex for thread safe access to allocations_ - Upstream* upstream_; // the upstream resource used for satisfying allocation requests + device_async_resource_ref upstream_; // the upstream resource used for satisfying + // allocation requests }; /** diff --git a/include/rmm/resource_ref.hpp b/include/rmm/resource_ref.hpp index 08942a040..56049522f 100644 --- a/include/rmm/resource_ref.hpp +++ b/include/rmm/resource_ref.hpp @@ -65,5 +65,21 @@ using host_device_resource_ref = using host_device_async_resource_ref = cuda::mr::async_resource_ref; +/** + * @brief Convert pointer to memory resource into `device_async_resource_ref`, checking for + * `nullptr` + * + * @tparam Resource The type of the memory resource. + * @param res A pointer to the memory resource. + * @return A `device_async_resource_ref` to the memory resource. + * @throws std::logic_error if the memory resource pointer is null. + */ +template +device_async_resource_ref to_device_async_resource_ref_checked(Resource* res) +{ + RMM_EXPECTS(res, "Unexpected null resource pointer."); + return device_async_resource_ref{*res}; +} + /** @} */ // end of group } // namespace RMM_NAMESPACE diff --git a/python/rmm/rmm/_lib/_torch_allocator.cpp b/python/rmm/rmm/_lib/_torch_allocator.cpp index dc92e4639..bfe94c2d0 100644 --- a/python/rmm/rmm/_lib/_torch_allocator.cpp +++ b/python/rmm/rmm/_lib/_torch_allocator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, NVIDIA CORPORATION. + * 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. @@ -39,8 +39,9 @@ extern "C" void* allocate(std::size_t size, int device, void* stream) { rmm::cuda_device_id const device_id{device}; rmm::cuda_set_device_raii with_device{device_id}; - auto mr = rmm::mr::get_per_device_resource(device_id); - return mr->allocate(size, rmm::cuda_stream_view{static_cast(stream)}); + auto mr = rmm::mr::get_per_device_resource_ref(device_id); + return mr.allocate_async( + size, rmm::CUDA_ALLOCATION_ALIGNMENT, rmm::cuda_stream_view{static_cast(stream)}); } /** @@ -55,6 +56,9 @@ extern "C" void deallocate(void* ptr, std::size_t size, int device, void* stream { rmm::cuda_device_id const device_id{device}; rmm::cuda_set_device_raii with_device{device_id}; - auto mr = rmm::mr::get_per_device_resource(device_id); - mr->deallocate(ptr, size, rmm::cuda_stream_view{static_cast(stream)}); + auto mr = rmm::mr::get_per_device_resource_ref(device_id); + mr.deallocate_async(ptr, + size, + rmm::CUDA_ALLOCATION_ALIGNMENT, + rmm::cuda_stream_view{static_cast(stream)}); } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5a4f88166..ea1af58cd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -40,6 +40,7 @@ function(ConfigureTestInternal TEST_NAME) PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") target_compile_options(${TEST_NAME} PUBLIC $<$:-Wall -Werror -Wno-error=deprecated-declarations>) + target_compile_options(${TEST_NAME} PUBLIC "$<$:-O0>") if(DISABLE_DEPRECATION_WARNING) target_compile_options( diff --git a/tests/container_multidevice_tests.cu b/tests/container_multidevice_tests.cu index e58ba53a2..55432feb0 100644 --- a/tests/container_multidevice_tests.cu +++ b/tests/container_multidevice_tests.cu @@ -42,9 +42,9 @@ TYPED_TEST(ContainerMultiDeviceTest, CreateDestroyDifferentActiveDevice) // only run on multidevice systems if (num_devices >= 2) { rmm::cuda_set_device_raii dev{rmm::cuda_device_id{0}}; - auto* orig_mr = rmm::mr::get_current_device_resource(); + auto orig_mr = rmm::mr::get_current_device_resource_ref(); auto check_mr = device_check_resource_adaptor{orig_mr}; - rmm::mr::set_current_device_resource(&check_mr); + rmm::mr::set_current_device_resource_ref(check_mr); { if constexpr (std::is_same_v>) { @@ -57,7 +57,7 @@ TYPED_TEST(ContainerMultiDeviceTest, CreateDestroyDifferentActiveDevice) } RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(0)); - rmm::mr::set_current_device_resource(orig_mr); + rmm::mr::set_current_device_resource_ref(orig_mr); } } @@ -69,9 +69,9 @@ TYPED_TEST(ContainerMultiDeviceTest, CreateMoveDestroyDifferentActiveDevice) // only run on multidevice systems if (num_devices >= 2) { rmm::cuda_set_device_raii dev{rmm::cuda_device_id{0}}; - auto* orig_mr = rmm::mr::get_current_device_resource(); + auto orig_mr = rmm::mr::get_current_device_resource_ref(); auto check_mr = device_check_resource_adaptor{orig_mr}; - rmm::mr::set_current_device_resource(&check_mr); + rmm::mr::set_current_device_resource_ref(check_mr); { auto buf_1 = []() { @@ -97,7 +97,7 @@ TYPED_TEST(ContainerMultiDeviceTest, CreateMoveDestroyDifferentActiveDevice) } RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(0)); - rmm::mr::set_current_device_resource(orig_mr); + rmm::mr::set_current_device_resource_ref(orig_mr); } } @@ -109,9 +109,9 @@ TYPED_TEST(ContainerMultiDeviceTest, ResizeDifferentActiveDevice) // only run on multidevice systems if (num_devices >= 2) { rmm::cuda_set_device_raii dev{rmm::cuda_device_id{0}}; - auto* orig_mr = rmm::mr::get_current_device_resource(); + auto orig_mr = rmm::mr::get_current_device_resource_ref(); auto check_mr = device_check_resource_adaptor{orig_mr}; - rmm::mr::set_current_device_resource(&check_mr); + rmm::mr::set_current_device_resource_ref(check_mr); if constexpr (not std::is_same_v>) { auto buf = TypeParam(128, rmm::cuda_stream_view{}); @@ -120,7 +120,7 @@ TYPED_TEST(ContainerMultiDeviceTest, ResizeDifferentActiveDevice) } RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(0)); - rmm::mr::set_current_device_resource(orig_mr); + rmm::mr::set_current_device_resource_ref(orig_mr); } } @@ -132,9 +132,9 @@ TYPED_TEST(ContainerMultiDeviceTest, ShrinkDifferentActiveDevice) // only run on multidevice systems if (num_devices >= 2) { rmm::cuda_set_device_raii dev{rmm::cuda_device_id{0}}; - auto* orig_mr = rmm::mr::get_current_device_resource(); + auto orig_mr = rmm::mr::get_current_device_resource_ref(); auto check_mr = device_check_resource_adaptor{orig_mr}; - rmm::mr::set_current_device_resource(&check_mr); + rmm::mr::set_current_device_resource_ref(check_mr); if constexpr (not std::is_same_v>) { auto buf = TypeParam(128, rmm::cuda_stream_view{}); @@ -144,6 +144,6 @@ TYPED_TEST(ContainerMultiDeviceTest, ShrinkDifferentActiveDevice) } RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(0)); - rmm::mr::set_current_device_resource(orig_mr); + rmm::mr::set_current_device_resource_ref(orig_mr); } } diff --git a/tests/cuda_stream_tests.cpp b/tests/cuda_stream_tests.cpp index 1cc068434..ec7e6c3e9 100644 --- a/tests/cuda_stream_tests.cpp +++ b/tests/cuda_stream_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -96,6 +96,6 @@ TEST_F(CudaStreamDeathTest, TestSyncNoThrow) // should assert here or in `~cuda_stream()` stream_a.synchronize_no_throw(); }; - EXPECT_DEATH(test(), "Assertion"); + EXPECT_DEATH(test(), ""); } #endif diff --git a/tests/device_buffer_tests.cu b/tests/device_buffer_tests.cu index c095eecf8..5e48504d6 100644 --- a/tests/device_buffer_tests.cu +++ b/tests/device_buffer_tests.cu @@ -75,7 +75,7 @@ TYPED_TEST(DeviceBufferTest, DefaultMemoryResource) EXPECT_EQ(this->size, buff.size()); EXPECT_EQ(this->size, buff.ssize()); EXPECT_EQ(this->size, buff.capacity()); - EXPECT_EQ(rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}, + EXPECT_EQ(rmm::device_async_resource_ref{rmm::mr::get_current_device_resource_ref()}, buff.memory_resource()); EXPECT_EQ(rmm::cuda_stream_view{}, buff.stream()); } @@ -87,7 +87,7 @@ TYPED_TEST(DeviceBufferTest, DefaultMemoryResourceStream) EXPECT_NE(nullptr, buff.data()); EXPECT_EQ(this->size, buff.size()); EXPECT_EQ(this->size, buff.capacity()); - EXPECT_EQ(rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}, + EXPECT_EQ(rmm::device_async_resource_ref{rmm::mr::get_current_device_resource_ref()}, buff.memory_resource()); EXPECT_EQ(this->stream, buff.stream()); } @@ -121,7 +121,7 @@ TYPED_TEST(DeviceBufferTest, CopyFromRawDevicePointer) EXPECT_NE(nullptr, buff.data()); EXPECT_EQ(this->size, buff.size()); EXPECT_EQ(this->size, buff.capacity()); - EXPECT_EQ(rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}, + EXPECT_EQ(rmm::device_async_resource_ref{rmm::mr::get_current_device_resource_ref()}, buff.memory_resource()); EXPECT_EQ(rmm::cuda_stream_view{}, buff.stream()); @@ -138,7 +138,7 @@ TYPED_TEST(DeviceBufferTest, CopyFromRawHostPointer) EXPECT_NE(nullptr, buff.data()); EXPECT_EQ(this->size, buff.size()); EXPECT_EQ(this->size, buff.capacity()); - EXPECT_EQ(rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}, + EXPECT_EQ(rmm::device_async_resource_ref{rmm::mr::get_current_device_resource_ref()}, buff.memory_resource()); EXPECT_EQ(rmm::cuda_stream_view{}, buff.stream()); buff.stream().synchronize(); @@ -152,7 +152,7 @@ TYPED_TEST(DeviceBufferTest, CopyFromNullptr) EXPECT_EQ(nullptr, buff.data()); EXPECT_EQ(0, buff.size()); EXPECT_EQ(0, buff.capacity()); - EXPECT_EQ(rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}, + EXPECT_EQ(rmm::device_async_resource_ref{rmm::mr::get_current_device_resource_ref()}, buff.memory_resource()); EXPECT_EQ(rmm::cuda_stream_view{}, buff.stream()); } @@ -180,7 +180,7 @@ TYPED_TEST(DeviceBufferTest, CopyConstructor) EXPECT_EQ(buff.size(), buff_copy.size()); EXPECT_EQ(buff.capacity(), buff_copy.capacity()); EXPECT_EQ(buff_copy.memory_resource(), - rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}); + rmm::device_async_resource_ref{rmm::mr::get_current_device_resource_ref()}); EXPECT_EQ(buff_copy.stream(), rmm::cuda_stream_view{}); EXPECT_TRUE(thrust::equal(rmm::exec_policy(rmm::cuda_stream_default), @@ -223,7 +223,7 @@ TYPED_TEST(DeviceBufferTest, CopyCapacityLargerThanSize) // The capacity of the copy should be equal to the `size()` of the original EXPECT_EQ(new_size, buff_copy.capacity()); EXPECT_EQ(buff_copy.memory_resource(), - rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}); + rmm::device_async_resource_ref{rmm::mr::get_current_device_resource_ref()}); EXPECT_EQ(buff_copy.stream(), rmm::cuda_stream_view{}); EXPECT_TRUE(thrust::equal(rmm::exec_policy(rmm::cuda_stream_default), diff --git a/tests/device_check_resource_adaptor.hpp b/tests/device_check_resource_adaptor.hpp index fcb578fdf..6780f56d7 100644 --- a/tests/device_check_resource_adaptor.hpp +++ b/tests/device_check_resource_adaptor.hpp @@ -17,13 +17,14 @@ #include #include #include +#include #include #include class device_check_resource_adaptor final : public rmm::mr::device_memory_resource { public: - device_check_resource_adaptor(rmm::mr::device_memory_resource* upstream) + device_check_resource_adaptor(rmm::device_async_resource_ref upstream) : device_id{rmm::get_current_cuda_device()}, upstream_(upstream) { } @@ -36,11 +37,6 @@ class device_check_resource_adaptor final : public rmm::mr::device_memory_resour return upstream_; } - /** - * @briefreturn{device_memory_resource* to the upstream memory resource} - */ - [[nodiscard]] device_memory_resource* get_upstream() const noexcept { return upstream_; } - private: [[nodiscard]] bool check_device_id() const { return device_id == rmm::get_current_cuda_device(); } @@ -48,7 +44,7 @@ class device_check_resource_adaptor final : public rmm::mr::device_memory_resour { bool const is_correct_device = check_device_id(); EXPECT_TRUE(is_correct_device); - if (is_correct_device) { return upstream_->allocate(bytes, stream); } + if (is_correct_device) { return get_upstream_resource().allocate_async(bytes, stream); } return nullptr; } @@ -56,7 +52,7 @@ class device_check_resource_adaptor final : public rmm::mr::device_memory_resour { bool const is_correct_device = check_device_id(); EXPECT_TRUE(is_correct_device); - if (is_correct_device) { upstream_->deallocate(ptr, bytes, stream); } + if (is_correct_device) { get_upstream_resource().deallocate_async(ptr, bytes, stream); } } [[nodiscard]] bool do_is_equal( @@ -64,10 +60,10 @@ class device_check_resource_adaptor final : public rmm::mr::device_memory_resour { if (this == &other) { return true; } auto const* cast = dynamic_cast(&other); - if (cast == nullptr) { return upstream_->is_equal(other); } + if (cast == nullptr) { return false; } return get_upstream_resource() == cast->get_upstream_resource(); } rmm::cuda_device_id device_id; - rmm::mr::device_memory_resource* upstream_{}; + rmm::device_async_resource_ref upstream_; }; diff --git a/tests/device_scalar_tests.cpp b/tests/device_scalar_tests.cpp index 6f80a5de1..323894a6a 100644 --- a/tests/device_scalar_tests.cpp +++ b/tests/device_scalar_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -38,7 +38,7 @@ struct DeviceScalarTest : public ::testing::Test { std::default_random_engine generator{}; T value{}; rmm::cuda_stream stream{}; - rmm::device_async_resource_ref mr{rmm::mr::get_current_device_resource()}; + rmm::device_async_resource_ref mr{rmm::mr::get_current_device_resource_ref()}; DeviceScalarTest() : value{random_value()} {} diff --git a/tests/device_uvector_tests.cpp b/tests/device_uvector_tests.cpp index 1c93ef138..90955c24c 100644 --- a/tests/device_uvector_tests.cpp +++ b/tests/device_uvector_tests.cpp @@ -39,7 +39,7 @@ TYPED_TEST(TypedUVectorTest, MemoryResource) { rmm::device_uvector vec(128, this->stream()); EXPECT_EQ(vec.memory_resource(), - rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}); + rmm::device_async_resource_ref{rmm::mr::get_current_device_resource_ref()}); } TYPED_TEST(TypedUVectorTest, ZeroSizeConstructor) diff --git a/tests/mock_resource.hpp b/tests/mock_resource.hpp index e06148d3a..555cf0d74 100644 --- a/tests/mock_resource.hpp +++ b/tests/mock_resource.hpp @@ -25,7 +25,12 @@ class mock_resource : public rmm::mr::device_memory_resource { public: MOCK_METHOD(void*, do_allocate, (std::size_t, cuda_stream_view), (override)); MOCK_METHOD(void, do_deallocate, (void*, std::size_t, cuda_stream_view), (override)); + bool operator==(mock_resource const&) const noexcept { return true; } + bool operator!=(mock_resource const&) const { return false; } + friend void get_property(mock_resource const&, cuda::mr::device_accessible) noexcept {} using size_pair = std::pair; }; +static_assert(cuda::mr::async_resource_with); + } // namespace rmm::test diff --git a/tests/mr/device/adaptor_tests.cpp b/tests/mr/device/adaptor_tests.cpp index a757a78b0..286daa841 100644 --- a/tests/mr/device/adaptor_tests.cpp +++ b/tests/mr/device/adaptor_tests.cpp @@ -129,8 +129,7 @@ TYPED_TEST(AdaptorTest, Equality) } { - rmm::mr::device_memory_resource* device_mr = &this->cuda; - auto other_mr = aligned_resource_adaptor{device_mr}; + auto other_mr = aligned_resource_adaptor{&this->cuda}; EXPECT_FALSE(this->mr->is_equal(other_mr)); } } diff --git a/tests/mr/device/aligned_mr_tests.cpp b/tests/mr/device/aligned_mr_tests.cpp index b9ecbc8ca..9b90bf751 100644 --- a/tests/mr/device/aligned_mr_tests.cpp +++ b/tests/mr/device/aligned_mr_tests.cpp @@ -59,13 +59,13 @@ TEST(AlignedTest, ThrowOnInvalidAllocationAlignment) TEST(AlignedTest, SupportsGetMemInfo) { mock_resource mock; - aligned_mock mr{&mock}; + aligned_mock mr{mock}; } TEST(AlignedTest, DefaultAllocationAlignmentPassthrough) { mock_resource mock; - aligned_mock mr{&mock}; + aligned_mock mr{mock}; cuda_stream_view stream; void* const pointer = int_to_address(123); @@ -204,7 +204,7 @@ TEST(AlignedTest, AlignRealPointer) { auto const alignment{4096}; auto const threshold{65536}; - aligned_real mr{rmm::mr::get_current_device_resource(), alignment, threshold}; + aligned_real mr{rmm::mr::get_current_device_resource_ref(), alignment, threshold}; void* alloc = mr.allocate(threshold); EXPECT_TRUE(rmm::is_pointer_aligned(alloc, alignment)); mr.deallocate(alloc, threshold); diff --git a/tests/mr/device/arena_mr_tests.cpp b/tests/mr/device/arena_mr_tests.cpp index 1eb38888e..bdc0f2438 100644 --- a/tests/mr/device/arena_mr_tests.cpp +++ b/tests/mr/device/arena_mr_tests.cpp @@ -23,6 +23,9 @@ #include #include #include +#include + +#include #include #include @@ -37,15 +40,22 @@ namespace { class mock_memory_resource { public: - MOCK_METHOD(void*, allocate, (std::size_t)); - MOCK_METHOD(void, deallocate, (void*, std::size_t)); + MOCK_METHOD(void*, allocate, (std::size_t, std::size_t)); + MOCK_METHOD(void, deallocate, (void*, std::size_t, std::size_t)); + MOCK_METHOD(void*, allocate_async, (std::size_t, std::size_t, cuda::stream_ref)); + MOCK_METHOD(void, deallocate_async, (void*, std::size_t, std::size_t, cuda::stream_ref)); + bool operator==(mock_memory_resource const&) const noexcept { return true; } + bool operator!=(mock_memory_resource const&) const { return false; } + friend void get_property(mock_memory_resource const&, cuda::mr::device_accessible) noexcept {} }; +static_assert(cuda::mr::async_resource_with); + using rmm::mr::detail::arena::block; using rmm::mr::detail::arena::byte_span; using rmm::mr::detail::arena::superblock; -using global_arena = rmm::mr::detail::arena::global_arena; -using arena = rmm::mr::detail::arena::arena; +using global_arena = rmm::mr::detail::arena::global_arena; +using arena = rmm::mr::detail::arena::arena; using arena_mr = rmm::mr::arena_memory_resource; using ::testing::Return; @@ -59,9 +69,10 @@ auto const fake_address4 = reinterpret_cast(superblock::minimum_size * 2) struct ArenaTest : public ::testing::Test { void SetUp() override { - EXPECT_CALL(mock_mr, allocate(arena_size)).WillOnce(Return(fake_address3)); - EXPECT_CALL(mock_mr, deallocate(fake_address3, arena_size)); - global = std::make_unique(&mock_mr, arena_size); + EXPECT_CALL(mock_mr, allocate(arena_size, ::testing::_)).WillOnce(Return(fake_address3)); + EXPECT_CALL(mock_mr, deallocate(fake_address3, arena_size, ::testing::_)); + + global = std::make_unique(mock_mr, arena_size); per_thread = std::make_unique(*global); } @@ -293,13 +304,6 @@ TEST_F(ArenaTest, SuperblockMaxFreeSizeWhenFull) // NOLINT /** * Test global_arena. */ - -TEST_F(ArenaTest, GlobalArenaNullUpstream) // NOLINT -{ - auto construct_nullptr = []() { global_arena global{nullptr, std::nullopt}; }; - EXPECT_THROW(construct_nullptr(), rmm::logic_error); // NOLINT(cppcoreguidelines-avoid-goto) -} - TEST_F(ArenaTest, GlobalArenaAcquire) // NOLINT { auto const sblk = global->acquire(256); @@ -378,7 +382,7 @@ TEST_F(ArenaTest, GlobalArenaDeallocate) // NOLINT { auto* ptr = global->allocate(superblock::minimum_size * 2); EXPECT_EQ(ptr, fake_address3); - global->deallocate(ptr, superblock::minimum_size * 2, {}); + global->deallocate_async(ptr, superblock::minimum_size * 2, {}); ptr = global->allocate(superblock::minimum_size * 2); EXPECT_EQ(ptr, fake_address3); } @@ -387,8 +391,8 @@ TEST_F(ArenaTest, GlobalArenaDeallocateAlignUp) // NOLINT { auto* ptr = global->allocate(superblock::minimum_size + 256); auto* ptr2 = global->allocate(superblock::minimum_size + 512); - global->deallocate(ptr, superblock::minimum_size + 256, {}); - global->deallocate(ptr2, superblock::minimum_size + 512, {}); + global->deallocate_async(ptr, superblock::minimum_size + 256, {}); + global->deallocate_async(ptr2, superblock::minimum_size + 512, {}); EXPECT_EQ(global->allocate(arena_size), fake_address3); } @@ -479,7 +483,7 @@ TEST_F(ArenaTest, ThrowOnNullUpstream) // NOLINT TEST_F(ArenaTest, SizeSmallerThanSuperblockSize) // NOLINT { - auto construct_small = []() { arena_mr mr{rmm::mr::get_current_device_resource(), 256}; }; + auto construct_small = []() { arena_mr mr{rmm::mr::get_current_device_resource_ref(), 256}; }; // NOLINTNEXTLINE(cppcoreguidelines-avoid-goto) EXPECT_THROW(construct_small(), rmm::logic_error); } @@ -490,14 +494,14 @@ TEST_F(ArenaTest, AllocateNinetyPercent) // NOLINT auto const free = rmm::available_device_memory().first; auto const ninety_percent = rmm::align_up( static_cast(static_cast(free) * 0.9), rmm::CUDA_ALLOCATION_ALIGNMENT); - arena_mr mr(rmm::mr::get_current_device_resource(), ninety_percent); + arena_mr mr(rmm::mr::get_current_device_resource_ref(), ninety_percent); }()); } TEST_F(ArenaTest, SmallMediumLarge) // NOLINT { EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) - arena_mr mr(rmm::mr::get_current_device_resource()); + arena_mr mr(rmm::mr::get_current_device_resource_ref()); auto* small = mr.allocate(256); auto* medium = mr.allocate(64_MiB); auto const free = rmm::available_device_memory().first; @@ -512,7 +516,7 @@ TEST_F(ArenaTest, Defragment) // NOLINT { EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) auto const arena_size = superblock::minimum_size * 4; - arena_mr mr(rmm::mr::get_current_device_resource(), arena_size); + arena_mr mr(rmm::mr::get_current_device_resource_ref(), arena_size); std::vector threads; std::size_t num_threads{4}; threads.reserve(num_threads); @@ -539,7 +543,7 @@ TEST_F(ArenaTest, PerThreadToStreamDealloc) // NOLINT // arena that then moved to global arena during a defragmentation // and then moved to a stream arena. auto const arena_size = superblock::minimum_size * 2; - arena_mr mr(rmm::mr::get_current_device_resource(), arena_size); + arena_mr mr(rmm::mr::get_current_device_resource_ref(), arena_size); // Create an allocation from a per thread arena void* thread_ptr = mr.allocate(256, rmm::cuda_stream_per_thread); // Create an allocation in a stream arena to force global arena @@ -565,7 +569,7 @@ TEST_F(ArenaTest, PerThreadToStreamDealloc) // NOLINT TEST_F(ArenaTest, DumpLogOnFailure) // NOLINT { - arena_mr mr{rmm::mr::get_current_device_resource(), 1_MiB, true}; + arena_mr mr{rmm::mr::get_current_device_resource_ref(), 1_MiB, true}; { // make the log interesting std::vector threads; diff --git a/tests/mr/device/callback_mr_tests.cpp b/tests/mr/device/callback_mr_tests.cpp index 34a2cc8cc..a56efa60c 100644 --- a/tests/mr/device/callback_mr_tests.cpp +++ b/tests/mr/device/callback_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -36,47 +36,50 @@ using ::testing::_; TEST(CallbackTest, TestCallbacksAreInvoked) { - auto base_mr = mock_resource(); + auto base_mr = mock_resource(); + auto base_ref = device_async_resource_ref{base_mr}; EXPECT_CALL(base_mr, do_allocate(10_MiB, cuda_stream_view{})).Times(1); EXPECT_CALL(base_mr, do_deallocate(_, 10_MiB, cuda_stream_view{})).Times(1); auto allocate_callback = [](std::size_t size, cuda_stream_view stream, void* arg) { - auto base_mr = static_cast(arg); - return base_mr->allocate(size, stream); + auto base_mr = *static_cast(arg); + return base_mr.allocate_async(size, stream); }; auto deallocate_callback = [](void* ptr, std::size_t size, cuda_stream_view stream, void* arg) { - auto base_mr = static_cast(arg); - base_mr->deallocate(ptr, size, stream); + auto base_mr = *static_cast(arg); + base_mr.deallocate_async(ptr, size, stream); }; auto mr = - rmm::mr::callback_memory_resource(allocate_callback, deallocate_callback, &base_mr, &base_mr); - auto ptr = mr.allocate(10_MiB); - mr.deallocate(ptr, 10_MiB); + rmm::mr::callback_memory_resource(allocate_callback, deallocate_callback, &base_ref, &base_ref); + auto const size = std::size_t{10_MiB}; + auto* ptr = mr.allocate(size); + mr.deallocate(ptr, size); } TEST(CallbackTest, LoggingTest) { testing::internal::CaptureStdout(); - auto base_mr = rmm::mr::get_current_device_resource(); + auto base_mr = rmm::mr::get_current_device_resource_ref(); auto allocate_callback = [](std::size_t size, cuda_stream_view stream, void* arg) { std::cout << "Allocating " << size << " bytes" << std::endl; - auto base_mr = static_cast(arg); - return base_mr->allocate(size, stream); + auto base_mr = *static_cast(arg); + return base_mr.allocate_async(size, stream); }; auto deallocate_callback = [](void* ptr, std::size_t size, cuda_stream_view stream, void* arg) { std::cout << "Deallocating " << size << " bytes" << std::endl; - auto base_mr = static_cast(arg); - base_mr->deallocate(ptr, size, stream); + auto base_mr = *static_cast(arg); + base_mr.deallocate_async(ptr, size, stream); }; auto mr = - rmm::mr::callback_memory_resource(allocate_callback, deallocate_callback, base_mr, base_mr); - auto ptr = mr.allocate(10_MiB); - mr.deallocate(ptr, 10_MiB); + rmm::mr::callback_memory_resource(allocate_callback, deallocate_callback, &base_mr, &base_mr); + auto const size = std::size_t{10_MiB}; + auto* ptr = mr.allocate(size); + mr.deallocate(ptr, size); std::string output = testing::internal::GetCapturedStdout(); - std::string expect = fmt::format("Allocating {} bytes\nDeallocating {} bytes\n", 10_MiB, 10_MiB); + std::string expect = fmt::format("Allocating {} bytes\nDeallocating {} bytes\n", size, size); ASSERT_EQ(expect, output); } diff --git a/tests/mr/device/failure_callback_mr_tests.cpp b/tests/mr/device/failure_callback_mr_tests.cpp index 683aee86e..4b3d084d5 100644 --- a/tests/mr/device/failure_callback_mr_tests.cpp +++ b/tests/mr/device/failure_callback_mr_tests.cpp @@ -47,7 +47,8 @@ bool failure_handler(std::size_t /*bytes*/, void* arg) TEST(FailureCallbackTest, RetryAllocationOnce) { bool retried{false}; - failure_callback_adaptor<> mr{rmm::mr::get_current_device_resource(), failure_handler, &retried}; + failure_callback_adaptor<> mr{ + rmm::mr::get_current_device_resource_ref(), failure_handler, &retried}; EXPECT_EQ(retried, false); EXPECT_THROW(mr.allocate(512_GiB), std::bad_alloc); EXPECT_EQ(retried, true); diff --git a/tests/mr/device/limiting_mr_tests.cpp b/tests/mr/device/limiting_mr_tests.cpp index 777ce9428..e6cc97029 100644 --- a/tests/mr/device/limiting_mr_tests.cpp +++ b/tests/mr/device/limiting_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. + * Copyright (c) 2019-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. @@ -25,19 +25,19 @@ namespace rmm::test { namespace { -using Limiting_adaptor = rmm::mr::limiting_resource_adaptor; +using limiting_adaptor = rmm::mr::limiting_resource_adaptor; TEST(LimitingTest, ThrowOnNullUpstream) { auto const max_size{5_MiB}; - auto construct_nullptr = []() { Limiting_adaptor mr{nullptr, max_size}; }; + auto construct_nullptr = []() { limiting_adaptor mr{nullptr, max_size}; }; EXPECT_THROW(construct_nullptr(), rmm::logic_error); } TEST(LimitingTest, TooBig) { auto const max_size{5_MiB}; - Limiting_adaptor mr{rmm::mr::get_current_device_resource(), max_size}; + limiting_adaptor mr{rmm::mr::get_current_device_resource_ref(), max_size}; EXPECT_THROW(mr.allocate(max_size + 1), rmm::out_of_memory); } @@ -45,15 +45,15 @@ TEST(LimitingTest, UpstreamFailure) { auto const max_size_1{2_MiB}; auto const max_size_2{5_MiB}; - Limiting_adaptor mr1{rmm::mr::get_current_device_resource(), max_size_1}; - Limiting_adaptor mr2{&mr1, max_size_2}; + limiting_adaptor mr1{rmm::mr::get_current_device_resource_ref(), max_size_1}; + limiting_adaptor mr2{&mr1, max_size_2}; EXPECT_THROW(mr2.allocate(4_MiB), rmm::out_of_memory); } TEST(LimitingTest, UnderLimitDueToFrees) { auto const max_size{10_MiB}; - Limiting_adaptor mr{rmm::mr::get_current_device_resource(), max_size}; + limiting_adaptor mr{rmm::mr::get_current_device_resource_ref(), max_size}; auto const size1{4_MiB}; auto* ptr1 = mr.allocate(size1); auto allocated_bytes = size1; @@ -81,7 +81,7 @@ TEST(LimitingTest, UnderLimitDueToFrees) TEST(LimitingTest, OverLimit) { auto const max_size{10_MiB}; - Limiting_adaptor mr{rmm::mr::get_current_device_resource(), max_size}; + limiting_adaptor mr{rmm::mr::get_current_device_resource_ref(), max_size}; auto const size1{4_MiB}; auto* ptr1 = mr.allocate(size1); auto allocated_bytes = size1; diff --git a/tests/mr/device/pool_mr_tests.cpp b/tests/mr/device/pool_mr_tests.cpp index c63a61844..9db63eb1b 100644 --- a/tests/mr/device/pool_mr_tests.cpp +++ b/tests/mr/device/pool_mr_tests.cpp @@ -49,19 +49,7 @@ TEST(PoolTest, ThrowMaxLessThanInitial) auto max_less_than_initial = []() { const auto initial{1024}; const auto maximum{256}; - pool_mr mr{rmm::mr::get_current_device_resource(), initial, maximum}; - }; - EXPECT_THROW(max_less_than_initial(), rmm::logic_error); -} - -TEST(PoolTest, ReferenceThrowMaxLessThanInitial) -{ - // Make sure first argument is enough larger than the second that alignment rounding doesn't - // make them equal - auto max_less_than_initial = []() { - const auto initial{1024}; - const auto maximum{256}; - pool_mr mr{*rmm::mr::get_current_device_resource(), initial, maximum}; + pool_mr mr{rmm::mr::get_current_device_resource_ref(), initial, maximum}; }; EXPECT_THROW(max_less_than_initial(), rmm::logic_error); } @@ -72,7 +60,7 @@ TEST(PoolTest, AllocateNinetyPercent) auto const [free, total] = rmm::available_device_memory(); (void)total; auto const ninety_percent_pool = rmm::percent_of_free_device_memory(90); - pool_mr mr{rmm::mr::get_current_device_resource(), ninety_percent_pool}; + pool_mr mr{rmm::mr::get_current_device_resource_ref(), ninety_percent_pool}; }; EXPECT_NO_THROW(allocate_ninety()); } @@ -81,7 +69,7 @@ TEST(PoolTest, TwoLargeBuffers) { auto two_large = []() { [[maybe_unused]] auto const [free, total] = rmm::available_device_memory(); - pool_mr mr{rmm::mr::get_current_device_resource(), rmm::percent_of_free_device_memory(50)}; + pool_mr mr{rmm::mr::get_current_device_resource_ref(), rmm::percent_of_free_device_memory(50)}; auto* ptr1 = mr.allocate(free / 4); auto* ptr2 = mr.allocate(free / 4); mr.deallocate(ptr1, free / 4); @@ -116,7 +104,7 @@ TEST(PoolTest, ForceGrowth) TEST(PoolTest, DeletedStream) { - pool_mr mr{rmm::mr::get_current_device_resource(), 0}; + pool_mr mr{rmm::mr::get_current_device_resource_ref(), 0}; cudaStream_t stream{}; // we don't use rmm::cuda_stream here to make destruction more explicit const int size = 10000; EXPECT_EQ(cudaSuccess, cudaStreamCreate(&stream)); @@ -129,7 +117,7 @@ TEST(PoolTest, DeletedStream) TEST(PoolTest, InitialAndMaxPoolSizeEqual) { EXPECT_NO_THROW([]() { - pool_mr mr(rmm::mr::get_current_device_resource(), 1000192, 1000192); + pool_mr mr(rmm::mr::get_current_device_resource_ref(), 1000192, 1000192); mr.allocate(1000); }()); } @@ -138,14 +126,14 @@ TEST(PoolTest, NonAlignedPoolSize) { EXPECT_THROW( []() { - pool_mr mr(rmm::mr::get_current_device_resource(), 1000031, 1000192); + pool_mr mr(rmm::mr::get_current_device_resource_ref(), 1000031, 1000192); mr.allocate(1000); }(), rmm::logic_error); EXPECT_THROW( []() { - pool_mr mr(rmm::mr::get_current_device_resource(), 1000192, 1000200); + pool_mr mr(rmm::mr::get_current_device_resource_ref(), 1000192, 1000200); mr.allocate(1000); }(), rmm::logic_error); @@ -203,18 +191,18 @@ namespace test_properties { class fake_async_resource { public: // To model `async_resource` - void* allocate(std::size_t, std::size_t) { return nullptr; } - void deallocate(void* ptr, std::size_t, std::size_t) {} - void* allocate_async(std::size_t, std::size_t, cuda::stream_ref) { return nullptr; } - void deallocate_async(void* ptr, std::size_t, std::size_t, cuda::stream_ref) {} + static void* allocate(std::size_t, std::size_t) { return nullptr; } + static void deallocate(void* ptr, std::size_t, std::size_t) {} + static void* allocate_async(std::size_t, std::size_t, cuda::stream_ref) { return nullptr; } + static void deallocate_async(void* ptr, std::size_t, std::size_t, cuda::stream_ref) {} bool operator==(const fake_async_resource& other) const { return true; } bool operator!=(const fake_async_resource& other) const { return false; } private: - void* do_allocate(std::size_t bytes, cuda_stream_view) { return nullptr; } - void do_deallocate(void* ptr, std::size_t, cuda_stream_view) {} - [[nodiscard]] bool do_is_equal(fake_async_resource const& other) const noexcept { return true; } + static void* do_allocate(std::size_t bytes, cuda_stream_view) { return nullptr; } + static void do_deallocate(void* ptr, std::size_t, cuda_stream_view) {} + [[nodiscard]] static bool do_is_equal(fake_async_resource const& other) noexcept { return true; } }; static_assert(!cuda::has_property); static_assert(!cuda::has_property, diff --git a/tests/mr/device/statistics_mr_tests.cpp b/tests/mr/device/statistics_mr_tests.cpp index 6c5700f0b..f796a4c00 100644 --- a/tests/mr/device/statistics_mr_tests.cpp +++ b/tests/mr/device/statistics_mr_tests.cpp @@ -40,7 +40,7 @@ TEST(StatisticsTest, ThrowOnNullUpstream) TEST(StatisticsTest, Empty) { - statistics_adaptor mr{rmm::mr::get_current_device_resource()}; + statistics_adaptor mr{rmm::mr::get_current_device_resource_ref()}; EXPECT_EQ(mr.get_bytes_counter().peak, 0); EXPECT_EQ(mr.get_bytes_counter().total, 0); @@ -53,7 +53,7 @@ TEST(StatisticsTest, Empty) TEST(StatisticsTest, AllFreed) { - statistics_adaptor mr{rmm::mr::get_current_device_resource()}; + statistics_adaptor mr{rmm::mr::get_current_device_resource_ref()}; std::vector allocations; allocations.reserve(num_allocations); @@ -71,7 +71,7 @@ TEST(StatisticsTest, AllFreed) TEST(StatisticsTest, PeakAllocations) { - statistics_adaptor mr{rmm::mr::get_current_device_resource()}; + statistics_adaptor mr{rmm::mr::get_current_device_resource_ref()}; std::vector allocations; for (std::size_t i = 0; i < num_allocations; ++i) { @@ -127,9 +127,9 @@ TEST(StatisticsTest, PeakAllocations) TEST(StatisticsTest, MultiTracking) { - auto* orig_device_resource = rmm::mr::get_current_device_resource(); + auto orig_device_resource = rmm::mr::get_current_device_resource_ref(); statistics_adaptor mr{orig_device_resource}; - rmm::mr::set_current_device_resource(&mr); + rmm::mr::set_current_device_resource_ref(mr); std::vector> allocations; for (std::size_t i = 0; i < num_allocations; ++i) { @@ -139,8 +139,8 @@ TEST(StatisticsTest, MultiTracking) EXPECT_EQ(mr.get_allocations_counter().value, 10); - statistics_adaptor inner_mr{rmm::mr::get_current_device_resource()}; - rmm::mr::set_current_device_resource(&inner_mr); + statistics_adaptor inner_mr{rmm::mr::get_current_device_resource_ref()}; + rmm::mr::set_current_device_resource_ref(inner_mr); for (std::size_t i = 0; i < num_more_allocations; ++i) { allocations.emplace_back( @@ -172,7 +172,7 @@ TEST(StatisticsTest, MultiTracking) EXPECT_EQ(inner_mr.get_allocations_counter().peak, 5); // Reset the current device resource - rmm::mr::set_current_device_resource(orig_device_resource); + rmm::mr::set_current_device_resource_ref(orig_device_resource); } TEST(StatisticsTest, NegativeInnerTracking) @@ -180,7 +180,7 @@ TEST(StatisticsTest, NegativeInnerTracking) // This tests the unlikely scenario where pointers are deallocated on an inner // wrapped memory resource. This can happen if the MR is not saved with the // memory pointer - statistics_adaptor mr{rmm::mr::get_current_device_resource()}; + statistics_adaptor mr{rmm::mr::get_current_device_resource_ref()}; std::vector allocations; for (std::size_t i = 0; i < num_allocations; ++i) { allocations.push_back(mr.allocate(ten_MiB)); @@ -236,7 +236,7 @@ TEST(StatisticsTest, NegativeInnerTracking) TEST(StatisticsTest, Nested) { - statistics_adaptor mr{rmm::mr::get_current_device_resource()}; + statistics_adaptor mr{rmm::mr::get_current_device_resource_ref()}; void* a0 = mr.allocate(ten_MiB); EXPECT_EQ(mr.get_bytes_counter().value, ten_MiB); EXPECT_EQ(mr.get_allocations_counter().value, 1); diff --git a/tests/mr/device/thrust_allocator_tests.cu b/tests/mr/device/thrust_allocator_tests.cu index 91ae396ed..84f599957 100644 --- a/tests/mr/device/thrust_allocator_tests.cu +++ b/tests/mr/device/thrust_allocator_tests.cu @@ -37,9 +37,9 @@ namespace { struct allocator_test : public mr_ref_test {}; // Disable until we support resource_ref with set_current_device_resource -/*TEST_P(allocator_test, first) +TEST_P(allocator_test, first) { - rmm::mr::set_current_device_resource(this->mr.get()); + rmm::mr::set_current_device_resource_ref(this->ref); auto const num_ints{100}; rmm::device_vector ints(num_ints, 1); EXPECT_EQ(num_ints, thrust::reduce(ints.begin(), ints.end())); @@ -47,12 +47,12 @@ struct allocator_test : public mr_ref_test {}; TEST_P(allocator_test, defaults) { - rmm::mr::set_current_device_resource(this->mr.get()); + rmm::mr::set_current_device_resource_ref(this->ref); rmm::mr::thrust_allocator allocator(rmm::cuda_stream_default); EXPECT_EQ(allocator.stream(), rmm::cuda_stream_default); EXPECT_EQ(allocator.get_upstream_resource(), - rmm::device_async_resource_ref{rmm::mr::get_current_device_resource()}); -}*/ + rmm::device_async_resource_ref{rmm::mr::get_current_device_resource_ref()}); +} TEST_P(allocator_test, multi_device) { diff --git a/tests/mr/device/tracking_mr_tests.cpp b/tests/mr/device/tracking_mr_tests.cpp index 7c2532c60..acd540ae6 100644 --- a/tests/mr/device/tracking_mr_tests.cpp +++ b/tests/mr/device/tracking_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -42,14 +42,14 @@ TEST(TrackingTest, ThrowOnNullUpstream) TEST(TrackingTest, Empty) { - tracking_adaptor mr{rmm::mr::get_current_device_resource()}; + tracking_adaptor mr{rmm::mr::get_current_device_resource_ref()}; EXPECT_EQ(mr.get_outstanding_allocations().size(), 0); EXPECT_EQ(mr.get_allocated_bytes(), 0); } TEST(TrackingTest, AllFreed) { - tracking_adaptor mr{rmm::mr::get_current_device_resource()}; + tracking_adaptor mr{rmm::mr::get_current_device_resource_ref()}; std::vector allocations; allocations.reserve(num_allocations); for (int i = 0; i < num_allocations; ++i) { @@ -64,7 +64,7 @@ TEST(TrackingTest, AllFreed) TEST(TrackingTest, AllocationsLeftWithStacks) { - tracking_adaptor mr{rmm::mr::get_current_device_resource(), true}; + tracking_adaptor mr{rmm::mr::get_current_device_resource_ref(), true}; std::vector allocations; allocations.reserve(num_allocations); for (int i = 0; i < num_allocations; ++i) { @@ -82,7 +82,7 @@ TEST(TrackingTest, AllocationsLeftWithStacks) TEST(TrackingTest, AllocationsLeftWithoutStacks) { - tracking_adaptor mr{rmm::mr::get_current_device_resource()}; + tracking_adaptor mr{rmm::mr::get_current_device_resource_ref()}; std::vector allocations; allocations.reserve(num_allocations); for (int i = 0; i < num_allocations; ++i) { @@ -101,9 +101,9 @@ TEST(TrackingTest, AllocationsLeftWithoutStacks) TEST(TrackingTest, MultiTracking) { - auto* orig_device_resource = rmm::mr::get_current_device_resource(); + auto orig_device_resource = rmm::mr::get_current_device_resource_ref(); tracking_adaptor mr{orig_device_resource, true}; - rmm::mr::set_current_device_resource(&mr); + rmm::mr::set_current_device_resource_ref(mr); std::vector> allocations; for (std::size_t i = 0; i < num_allocations; ++i) { @@ -113,8 +113,8 @@ TEST(TrackingTest, MultiTracking) EXPECT_EQ(mr.get_outstanding_allocations().size(), num_allocations); - tracking_adaptor inner_mr{rmm::mr::get_current_device_resource()}; - rmm::mr::set_current_device_resource(&inner_mr); + tracking_adaptor inner_mr{rmm::mr::get_current_device_resource_ref()}; + rmm::mr::set_current_device_resource_ref(inner_mr); for (std::size_t i = 0; i < num_more_allocations; ++i) { allocations.emplace_back( @@ -141,7 +141,7 @@ TEST(TrackingTest, MultiTracking) EXPECT_EQ(inner_mr.get_allocated_bytes(), 0); // Reset the current device resource - rmm::mr::set_current_device_resource(orig_device_resource); + rmm::mr::set_current_device_resource_ref(orig_device_resource); } TEST(TrackingTest, NegativeInnerTracking) @@ -149,7 +149,7 @@ TEST(TrackingTest, NegativeInnerTracking) // This tests the unlikely scenario where pointers are deallocated on an inner // wrapped memory resource. This can happen if the MR is not saved with the // memory pointer - tracking_adaptor mr{rmm::mr::get_current_device_resource()}; + tracking_adaptor mr{rmm::mr::get_current_device_resource_ref()}; std::vector allocations; for (std::size_t i = 0; i < num_allocations; ++i) { allocations.push_back(mr.allocate(ten_MiB)); @@ -181,7 +181,7 @@ TEST(TrackingTest, NegativeInnerTracking) TEST(TrackingTest, DeallocWrongBytes) { - tracking_adaptor mr{rmm::mr::get_current_device_resource()}; + tracking_adaptor mr{rmm::mr::get_current_device_resource_ref()}; std::vector allocations; for (std::size_t i = 0; i < num_allocations; ++i) { allocations.push_back(mr.allocate(ten_MiB)); @@ -207,7 +207,7 @@ TEST(TrackingTest, LogOutstandingAllocations) rmm::logger().sinks().push_back(oss_sink); auto old_level = rmm::logger().level(); - tracking_adaptor mr{rmm::mr::get_current_device_resource()}; + tracking_adaptor mr{rmm::mr::get_current_device_resource_ref()}; std::vector allocations; for (std::size_t i = 0; i < num_allocations; ++i) { allocations.push_back(mr.allocate(ten_MiB)); diff --git a/tests/mr/host/mr_ref_tests.cpp b/tests/mr/host/mr_ref_tests.cpp index 8445ab1f5..071739575 100644 --- a/tests/mr/host/mr_ref_tests.cpp +++ b/tests/mr/host/mr_ref_tests.cpp @@ -233,14 +233,17 @@ TYPED_TEST(MRRefTest, UnsupportedAlignmentTest) for (std::size_t num_trials = 0; num_trials < NUM_TRIALS; ++num_trials) { for (std::size_t alignment = MinTestedAlignment; alignment <= MaxTestedAlignment; alignment *= TestedAlignmentMultiplier) { +#ifdef NDEBUG auto allocation_size = size_distribution(generator); void* ptr{nullptr}; // An unsupported alignment (like an odd number) should result in an // alignment of `alignof(std::max_align_t)` auto const bad_alignment = alignment + 1; + EXPECT_NO_THROW(ptr = this->ref.allocate(allocation_size, bad_alignment)); EXPECT_TRUE(is_aligned(ptr, alignof(std::max_align_t))); EXPECT_NO_THROW(this->ref.deallocate(ptr, allocation_size, bad_alignment)); +#endif } } } From 800dc8749aa889c6b51046739449ef5322217ddf Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Tue, 10 Sep 2024 10:55:14 +0200 Subject: [PATCH 467/675] Add missing include to `resource_ref.hpp` (#1677) This has been found breaking CCCL CI when building cuDF Authors: - Michael Schellenberger Costa (https://github.com/miscco) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1677 --- include/rmm/resource_ref.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/rmm/resource_ref.hpp b/include/rmm/resource_ref.hpp index 56049522f..285726478 100644 --- a/include/rmm/resource_ref.hpp +++ b/include/rmm/resource_ref.hpp @@ -15,6 +15,7 @@ */ #pragma once +#include #include #include From 68a51d3a12e9d13793dd79f053e63145e7107ee1 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 18 Sep 2024 01:00:58 -0500 Subject: [PATCH 468/675] Recommend `miniforge` for conda install. (#1681) Recommending `miniforge` for conda install in installation docs. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1681 --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1250d094b..0a25cd348 100644 --- a/README.md +++ b/README.md @@ -33,19 +33,20 @@ For a walkthrough about the design of the RAPIDS Memory Manager, read [Fast, Fle ### Conda -RMM can be installed with Conda ([miniconda](https://conda.io/miniconda.html), or the full -[Anaconda distribution](https://www.anaconda.com/download)) from the `rapidsai` channel: +RMM can be installed with conda. You can get a minimal conda installation with [miniforge](https://github.com/conda-forge/miniforge). + +Install RMM with: ```bash conda install -c rapidsai -c conda-forge -c nvidia rmm cuda-version=12.0 ``` -We also provide [nightly Conda packages](https://anaconda.org/rapidsai-nightly) built from the HEAD +We also provide [nightly conda packages](https://anaconda.org/rapidsai-nightly) built from the HEAD of our latest development branch. Note: RMM is supported only on Linux, and only tested with Python versions 3.10, 3.11, and 3.12. -Note: The RMM package from Conda requires building with GCC 9 or later. Otherwise, your application may fail to build. +Note: The RMM package from conda requires building with GCC 9 or later. Otherwise, your application may fail to build. See the [Get RAPIDS version picker](https://rapids.ai/start.html) for more OS and version info. From 58039d3c8ff63ecfbfde8b3a103bc14d33be7bae Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 18 Sep 2024 14:43:51 -0500 Subject: [PATCH 469/675] Use CI workflow branch 'branch-24.10' again [skip ci] (#1683) --- .github/workflows/build.yaml | 16 ++++++++-------- .github/workflows/pr.yaml | 22 +++++++++++----------- .github/workflows/test.yaml | 6 +++--- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 7f54701d9..9b7efecde 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build-cpp: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -79,7 +79,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -89,7 +89,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -100,7 +100,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.10 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 7d9fbb086..1160b93e9 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -23,40 +23,40 @@ jobs: - wheel-tests - devcontainer secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.10 checks: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.10 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.10 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.10 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.10 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.10 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.10 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -66,7 +66,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -74,20 +74,20 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10 with: build_type: pull-request script: ci/build_wheel_python.sh wheel-tests: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.10 with: build_type: pull-request script: ci/test_wheel.sh devcontainer: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.10 with: arch: '["amd64"]' cuda: '["12.5"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index eec04005d..13838d888 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.10 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.10 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@python-3.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.10 with: build_type: nightly branch: ${{ inputs.branch }} From f4ec4631a66de1bfa199120321abe95782cf32c6 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Thu, 19 Sep 2024 11:43:47 -0400 Subject: [PATCH 470/675] DOC v24.12 Updates [skip ci] --- .../cuda11.8-conda/devcontainer.json | 6 ++--- .devcontainer/cuda11.8-pip/devcontainer.json | 6 ++--- .../cuda12.5-conda/devcontainer.json | 6 ++--- .devcontainer/cuda12.5-pip/devcontainer.json | 6 ++--- .github/workflows/build.yaml | 16 +++++++------- .github/workflows/pr.yaml | 22 +++++++++---------- .github/workflows/test.yaml | 6 ++--- VERSION | 2 +- dependencies.yaml | 6 ++--- python/rmm/pyproject.toml | 2 +- 10 files changed, 39 insertions(+), 39 deletions(-) diff --git a/.devcontainer/cuda11.8-conda/devcontainer.json b/.devcontainer/cuda11.8-conda/devcontainer.json index 3bfef6706..549ffa67b 100644 --- a/.devcontainer/cuda11.8-conda/devcontainer.json +++ b/.devcontainer/cuda11.8-conda/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:24.10-cpp-cuda11.8-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.12-cpp-cuda11.8-mambaforge-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.10-cuda11.8-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.12-cuda11.8-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.10": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.12": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda11.8-pip/devcontainer.json b/.devcontainer/cuda11.8-pip/devcontainer.json index 5bfc30823..d6dd7b6ce 100644 --- a/.devcontainer/cuda11.8-pip/devcontainer.json +++ b/.devcontainer/cuda11.8-pip/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:24.10-cpp-cuda11.8-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.12-cpp-cuda11.8-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.10-cuda11.8-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.12-cuda11.8-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.10": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.12": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.5-conda/devcontainer.json b/.devcontainer/cuda12.5-conda/devcontainer.json index 925557b22..17e8d5cd0 100644 --- a/.devcontainer/cuda12.5-conda/devcontainer.json +++ b/.devcontainer/cuda12.5-conda/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "12.5", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:24.10-cpp-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.12-cpp-mambaforge-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.10-cuda12.5-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.12-cuda12.5-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.10": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.12": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.5-pip/devcontainer.json b/.devcontainer/cuda12.5-pip/devcontainer.json index 2f9e1c493..54964d880 100644 --- a/.devcontainer/cuda12.5-pip/devcontainer.json +++ b/.devcontainer/cuda12.5-pip/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "12.5", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:24.10-cpp-cuda12.5-ubuntu22.04" + "BASE": "rapidsai/devcontainers:24.12-cpp-cuda12.5-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.10-cuda12.5-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.12-cuda12.5-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.10": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.12": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9b7efecde..6fa11225e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build-cpp: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.12 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -79,7 +79,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -89,7 +89,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -100,7 +100,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.12 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 1160b93e9..afc9f7487 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -23,40 +23,40 @@ jobs: - wheel-tests - devcontainer secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.12 checks: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.12 with: enable_check_generated_files: false conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.12 with: build_type: pull-request conda-cpp-tests: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.12 with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.12 with: build_type: pull-request conda-python-tests: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.12 with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.12 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -66,7 +66,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.12 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -74,20 +74,20 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.12 with: build_type: pull-request script: ci/build_wheel_python.sh wheel-tests: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.12 with: build_type: pull-request script: ci/test_wheel.sh devcontainer: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.12 with: arch: '["amd64"]' cuda: '["12.5"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 13838d888..34a0f746d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.12 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.12 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.10 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.12 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/VERSION b/VERSION index 7c7ba0443..af28c42b5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -24.10.00 +24.12.00 diff --git a/dependencies.yaml b/dependencies.yaml index eff3560e7..5b5cded62 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -163,15 +163,15 @@ dependencies: cuda: "12.*" cuda_suffixed: "true" packages: - - librmm-cu12==24.10.*,>=0.0.0a0 + - librmm-cu12==24.12.*,>=0.0.0a0 - matrix: cuda: "11.*" cuda_suffixed: "true" packages: - - librmm-cu11==24.10.*,>=0.0.0a0 + - librmm-cu11==24.12.*,>=0.0.0a0 - matrix: null packages: - - librmm==24.10.*,>=0.0.0a0 + - librmm==24.12.*,>=0.0.0a0 checks: common: - output_types: [conda, requirements] diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 7577ad961..b148cdba7 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -130,7 +130,7 @@ requires = [ "cmake>=3.26.4,!=3.30.0", "cuda-python>=11.7.1,<12.0a0", "cython>=3.0.0", - "librmm==24.10.*,>=0.0.0a0", + "librmm==24.12.*,>=0.0.0a0", "ninja", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. From 99e237ef6a42321a6bbd28b7aab9e4cc4105e6a3 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 23 Sep 2024 15:11:29 -0500 Subject: [PATCH 471/675] Update fmt (to 11.0.2) and spdlog (to 1.14.1). (#1678) * Update fmt (to 11.0.2) and spdlog (to 1.14.1). * simplify get_spdlog * copyright * Apply suggestions from code review Co-authored-by: Bradley Dice * Apply suggestions from code review * test with changes from https://github.com/rapidsai/rapids-cmake/pull/689/commits/d7671a30f99bc2b239653b5c1089ff51bcc37dc4 * Update cmake/thirdparty/get_spdlog.cmake * move rapids-cmake overrides [skip ci] * try reverting get_spdlog export changes [skip ci] * more fiddling with export sets [skip ci] * more exporting [skip ci] * more export set fiddling [skip ci] * more [skip ci] * exports [skip ci] * run a build * restore tests * branch references * remove testing-only changes [skip ci] --------- Co-authored-by: Bradley Dice --- cmake/thirdparty/get_spdlog.cmake | 18 +++++------------- .../environments/all_cuda-118_arch-x86_64.yaml | 4 ++-- .../environments/all_cuda-125_arch-x86_64.yaml | 4 ++-- conda/recipes/librmm/conda_build_config.yaml | 4 ++-- dependencies.yaml | 4 ++-- 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/cmake/thirdparty/get_spdlog.cmake b/cmake/thirdparty/get_spdlog.cmake index 296370469..7f80b3726 100644 --- a/cmake/thirdparty/get_spdlog.cmake +++ b/cmake/thirdparty/get_spdlog.cmake @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2021-2023, NVIDIA CORPORATION. +# Copyright (c) 2021-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 @@ -16,19 +16,11 @@ function(find_and_configure_spdlog) include(${rapids-cmake-dir}/cpm/spdlog.cmake) - rapids_cpm_spdlog(FMT_OPTION "EXTERNAL_FMT_HO" INSTALL_EXPORT_SET rmm-exports) - rapids_export_package(BUILD spdlog rmm-exports) + rapids_cpm_spdlog( + FMT_OPTION "EXTERNAL_FMT_HO" + INSTALL_EXPORT_SET rmm-exports + BUILD_EXPORT_SET rmm-exports) - if(spdlog_ADDED) - rapids_export( - BUILD spdlog - EXPORT_SET spdlog - GLOBAL_TARGETS spdlog spdlog_header_only - NAMESPACE spdlog::) - include("${rapids-cmake-dir}/export/find_package_root.cmake") - rapids_export_find_package_root(BUILD spdlog [=[${CMAKE_CURRENT_LIST_DIR}]=] - EXPORT_SET rmm-exports) - endif() endfunction() find_and_configure_spdlog() diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 33b54b3f9..bf64d4d55 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -16,7 +16,7 @@ dependencies: - cxx-compiler - cython>=3.0.0 - doxygen=1.9.1 -- fmt>=10.1.1,<11 +- fmt>=11.0.2,<12 - gcc_linux-64=11.* - gcovr>=5.0 - graphviz @@ -35,7 +35,7 @@ dependencies: - python>=3.10,<3.13 - rapids-build-backend>=0.3.0,<0.4.0.dev0 - scikit-build-core >=0.10.0 -- spdlog>=1.12.0,<1.13 +- spdlog>=1.14.1,<1.15 - sphinx - sphinx-copybutton - sphinx-markdown-tables diff --git a/conda/environments/all_cuda-125_arch-x86_64.yaml b/conda/environments/all_cuda-125_arch-x86_64.yaml index 5946a9786..112c635a8 100644 --- a/conda/environments/all_cuda-125_arch-x86_64.yaml +++ b/conda/environments/all_cuda-125_arch-x86_64.yaml @@ -16,7 +16,7 @@ dependencies: - cxx-compiler - cython>=3.0.0 - doxygen=1.9.1 -- fmt>=10.1.1,<11 +- fmt>=11.0.2,<12 - gcc_linux-64=11.* - gcovr>=5.0 - graphviz @@ -34,7 +34,7 @@ dependencies: - python>=3.10,<3.13 - rapids-build-backend>=0.3.0,<0.4.0.dev0 - scikit-build-core >=0.10.0 -- spdlog>=1.12.0,<1.13 +- spdlog>=1.14.1,<1.15 - sphinx - sphinx-copybutton - sphinx-markdown-tables diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index 6afd32c32..b4791745f 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -14,10 +14,10 @@ cmake_version: - ">=3.26.4,!=3.30.0" fmt_version: - - ">=10.1.1,<11" + - ">=11.0.2,<12" spdlog_version: - - ">=1.12.0,<1.13" + - ">=1.14.1,<1.15" c_stdlib: - sysroot diff --git a/dependencies.yaml b/dependencies.yaml index eff3560e7..483c21e61 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -111,8 +111,8 @@ dependencies: packages: - c-compiler - cxx-compiler - - fmt>=10.1.1,<11 - - spdlog>=1.12.0,<1.13 + - fmt>=11.0.2,<12 + - spdlog>=1.14.1,<1.15 specific: - output_types: conda matrices: From ab6e2961d7b8f833f688775e941c4e2ed2bd4d8a Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Tue, 24 Sep 2024 14:09:28 -0500 Subject: [PATCH 472/675] update update-version.sh to use packaging lib (#1685) --- ci/release/update-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index acec1c658..ddd093bea 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -24,7 +24,7 @@ NEXT_MINOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[2]}') NEXT_SHORT_TAG=${NEXT_MAJOR}.${NEXT_MINOR} # Need to distutils-normalize the original version -NEXT_SHORT_TAG_PEP440=$(python -c "from setuptools.extern import packaging; print(packaging.version.Version('${NEXT_SHORT_TAG}'))") +NEXT_SHORT_TAG_PEP440=$(python -c "from packaging.version import Version; print(Version('${NEXT_SHORT_TAG}'))") echo "Preparing release $CURRENT_TAG => $NEXT_FULL_TAG" From b51447393c523cc929608d84850c70a3eae08af3 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 27 Sep 2024 11:56:06 -0500 Subject: [PATCH 473/675] exclude 'gcovr' from list of development pip packages (#1688) This project currently lists `gcovr` (https://pypi.org/project/gcovr/) as a pip dependency for development. I strongly suspect that that was unintentional... it doesn't look like it has any reliance on getting that package via `pip` (just conda, in the C++ test jobs and for local C++ development). This proposes removing `gcovr` from the list of pip dependencies, so it won't get installed in the DLFW images or other places where `rapids-make-pip-env` from https://github.com/rapidsai/devcontainers is called. Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1688 --- dependencies.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dependencies.yaml b/dependencies.yaml index b9a1e1b36..9f1ed9c40 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -232,13 +232,11 @@ dependencies: packages: develop: common: - - output_types: [conda, requirements] - packages: - - gcovr>=5.0 - output_types: conda packages: - clang==16.0.6 - clang-tools==16.0.6 + - gcovr>=5.0 docs: common: - output_types: conda From 9e410c0591f38aa6c0a17c4e2c2edc4f6bfed058 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Mon, 30 Sep 2024 18:28:44 +0100 Subject: [PATCH 474/675] Use `rmm::percent_of_free_device_memory` in arena test (#1689) Rather than hand-coding a fraction of the device memory use the utility routine. - Closes #1674 Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Rong Ou (https://github.com/rongou) URL: https://github.com/rapidsai/rmm/pull/1689 --- tests/mr/device/arena_mr_tests.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/mr/device/arena_mr_tests.cpp b/tests/mr/device/arena_mr_tests.cpp index bdc0f2438..95cc9c9c1 100644 --- a/tests/mr/device/arena_mr_tests.cpp +++ b/tests/mr/device/arena_mr_tests.cpp @@ -491,9 +491,7 @@ TEST_F(ArenaTest, SizeSmallerThanSuperblockSize) // NOLINT TEST_F(ArenaTest, AllocateNinetyPercent) // NOLINT { EXPECT_NO_THROW([]() { // NOLINT(cppcoreguidelines-avoid-goto) - auto const free = rmm::available_device_memory().first; - auto const ninety_percent = rmm::align_up( - static_cast(static_cast(free) * 0.9), rmm::CUDA_ALLOCATION_ALIGNMENT); + auto const ninety_percent = rmm::percent_of_free_device_memory(90); arena_mr mr(rmm::mr::get_current_device_resource_ref(), ninety_percent); }()); } From 6489bb7df63a3784b4a94067e3a8fa8917523ab7 Mon Sep 17 00:00:00 2001 From: Matthew Murray <41342305+Matt711@users.noreply.github.com> Date: Wed, 2 Oct 2024 23:14:10 -0400 Subject: [PATCH 475/675] [Improvement] Reorganize Cython to separate C++ bindings and make Cython classes public (#1676) Closes #1280 Authors: - Matthew Murray (https://github.com/Matt711) - Lawrence Mitchell (https://github.com/wence-) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1676 --- .gitignore | 11 +- python/rmm/CMakeLists.txt | 3 +- python/rmm/docs/guide.md | 6 +- python/rmm/rmm/__init__.py | 20 +- python/rmm/rmm/_cuda/stream.pxd | 4 +- python/rmm/rmm/_cuda/stream.pyx | 4 +- python/rmm/rmm/_lib/__init__.py | 4 +- python/rmm/rmm/_lib/cuda_stream.pxd | 27 +- python/rmm/rmm/_lib/cuda_stream_pool.pxd | 14 +- python/rmm/rmm/_lib/cuda_stream_view.pxd | 26 +- python/rmm/rmm/_lib/device_buffer.pxd | 115 +-------- python/rmm/rmm/_lib/device_uvector.pxd | 28 +-- python/rmm/rmm/_lib/helper.pxd | 3 +- python/rmm/rmm/_lib/logger.pxd | 24 ++ python/rmm/rmm/_lib/memory_resource.pxd | 138 ++++------- python/rmm/rmm/_lib/per_device_resource.pxd | 42 ++-- python/rmm/rmm/allocators/cupy.py | 6 +- python/rmm/rmm/allocators/numba.py | 6 +- python/rmm/rmm/allocators/torch.py | 8 +- .../rmm/rmm/{_lib => librmm}/CMakeLists.txt | 3 +- .../{_lib/__init__.pxd => librmm/__init__.py} | 0 python/rmm/rmm/librmm/_logger.pxd | 66 +++++ .../rmm/{_lib/lib.pxd => librmm/_logger.pyx} | 9 +- .../rmm/{_lib => librmm}/_torch_allocator.cpp | 0 python/rmm/rmm/librmm/cuda_stream.pxd | 28 +++ python/rmm/rmm/librmm/cuda_stream_pool.pxd | 23 ++ python/rmm/rmm/librmm/cuda_stream_view.pxd | 32 +++ python/rmm/rmm/librmm/device_buffer.pxd | 58 +++++ python/rmm/rmm/librmm/device_uvector.pxd | 39 +++ python/rmm/rmm/librmm/memory_resource.pxd | 230 ++++++++++++++++++ python/rmm/rmm/librmm/per_device_resource.pxd | 36 +++ python/rmm/rmm/mr.py | 2 +- python/rmm/rmm/pylibrmm/CMakeLists.txt | 27 ++ python/rmm/rmm/pylibrmm/__init__.py | 15 ++ python/rmm/rmm/pylibrmm/cuda_stream.pxd | 27 ++ .../rmm/{_lib => pylibrmm}/cuda_stream.pyx | 4 +- python/rmm/rmm/pylibrmm/device_buffer.pxd | 71 ++++++ .../rmm/{_lib => pylibrmm}/device_buffer.pyx | 19 +- .../rmm/{_lib/lib.pyx => pylibrmm/helper.pxd} | 5 +- python/rmm/rmm/{_lib => pylibrmm}/helper.pyx | 0 python/rmm/rmm/{_lib => pylibrmm}/logger.pyx | 57 +---- python/rmm/rmm/pylibrmm/memory_resource.pxd | 83 +++++++ .../{_lib => pylibrmm}/memory_resource.pyx | 228 +++-------------- .../rmm/{_lib => pylibrmm}/tests/__init__.py | 0 .../tests/test_device_buffer.pyx | 7 +- python/rmm/rmm/tests/test_cython.py | 4 +- python/rmm/rmm/tests/test_rmm.py | 2 +- 47 files changed, 965 insertions(+), 599 deletions(-) create mode 100644 python/rmm/rmm/_lib/logger.pxd rename python/rmm/rmm/{_lib => librmm}/CMakeLists.txt (93%) rename python/rmm/rmm/{_lib/__init__.pxd => librmm/__init__.py} (100%) create mode 100644 python/rmm/rmm/librmm/_logger.pxd rename python/rmm/rmm/{_lib/lib.pxd => librmm/_logger.pyx} (70%) rename python/rmm/rmm/{_lib => librmm}/_torch_allocator.cpp (100%) create mode 100644 python/rmm/rmm/librmm/cuda_stream.pxd create mode 100644 python/rmm/rmm/librmm/cuda_stream_pool.pxd create mode 100644 python/rmm/rmm/librmm/cuda_stream_view.pxd create mode 100644 python/rmm/rmm/librmm/device_buffer.pxd create mode 100644 python/rmm/rmm/librmm/device_uvector.pxd create mode 100644 python/rmm/rmm/librmm/memory_resource.pxd create mode 100644 python/rmm/rmm/librmm/per_device_resource.pxd create mode 100644 python/rmm/rmm/pylibrmm/CMakeLists.txt create mode 100644 python/rmm/rmm/pylibrmm/__init__.py create mode 100644 python/rmm/rmm/pylibrmm/cuda_stream.pxd rename python/rmm/rmm/{_lib => pylibrmm}/cuda_stream.pyx (91%) create mode 100644 python/rmm/rmm/pylibrmm/device_buffer.pxd rename python/rmm/rmm/{_lib => pylibrmm}/device_buffer.pyx (96%) rename python/rmm/rmm/{_lib/lib.pyx => pylibrmm/helper.pxd} (86%) rename python/rmm/rmm/{_lib => pylibrmm}/helper.pyx (100%) rename python/rmm/rmm/{_lib => pylibrmm}/logger.pyx (77%) create mode 100644 python/rmm/rmm/pylibrmm/memory_resource.pxd rename python/rmm/rmm/{_lib => pylibrmm}/memory_resource.pyx (82%) rename python/rmm/rmm/{_lib => pylibrmm}/tests/__init__.py (100%) rename python/rmm/rmm/{_lib => pylibrmm}/tests/test_device_buffer.pyx (83%) diff --git a/.gitignore b/.gitignore index 2d0b150e1..36aafe643 100644 --- a/.gitignore +++ b/.gitignore @@ -22,10 +22,13 @@ rmm.egg-info/ python/build python/*/build python/rmm/docs/_build -python/rmm/**/_lib/**/*.cpp -!python/rmm/_lib/_torch_allocator.cpp -python/rmm/**/_lib/**/*.h -python/rmm/**/_lib/.nfs* +python/rmm/**/librmmm/**/*.cpp +!python/rmm/librmmm/_torch_allocator.cpp +python/rmm/**/librmm/**/*.h +python/rmm/**/librmm/.nfs* +python/rmm/**/pylibrmmm/**/*.cpp +python/rmm/**/pylibrmmm/**/*.h +python/rmm/**/pylibrmmm/.nfs* python/rmm/_cuda/*.cpp python/rmm/tests/*.cpp python/rmm/*.ipynb diff --git a/python/rmm/CMakeLists.txt b/python/rmm/CMakeLists.txt index 6c2515102..ac8495e14 100644 --- a/python/rmm/CMakeLists.txt +++ b/python/rmm/CMakeLists.txt @@ -30,4 +30,5 @@ rapids_cython_init() add_compile_definitions("SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") add_subdirectory(rmm/_cuda) -add_subdirectory(rmm/_lib) +add_subdirectory(rmm/librmm) +add_subdirectory(rmm/pylibrmm) diff --git a/python/rmm/docs/guide.md b/python/rmm/docs/guide.md index 22c0dc023..c7e940497 100644 --- a/python/rmm/docs/guide.md +++ b/python/rmm/docs/guide.md @@ -236,17 +236,17 @@ Common to both usages is that they modify the currently active RMM memory resour >>> # We start with the default cuda memory resource >>> rmm.mr.get_current_device_resource() - + >>> # When using statistics, we get a StatisticsResourceAdaptor with the context >>> with rmm.statistics.statistics(): ... rmm.mr.get_current_device_resource() - + >>> # We can also enable statistics globally >>> rmm.statistics.enable_statistics() >>> print(rmm.mr.get_current_device_resource()) - + ``` With statistics enabled, you can query statistics of the current and peak bytes and number of allocations performed by the current RMM memory resource: diff --git a/python/rmm/rmm/__init__.py b/python/rmm/rmm/__init__.py index 1e3b5c8b1..b23ad68f9 100644 --- a/python/rmm/rmm/__init__.py +++ b/python/rmm/rmm/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018-2021, NVIDIA CORPORATION. +# Copyright (c) 2018-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. @@ -13,8 +13,10 @@ # limitations under the License. from rmm import mr -from rmm._lib.device_buffer import DeviceBuffer -from rmm._lib.logger import ( +from rmm._version import __git_commit__, __version__ +from rmm.mr import disable_logging, enable_logging, get_log_filenames +from rmm.pylibrmm.device_buffer import DeviceBuffer +from rmm.pylibrmm.logger import ( flush_logger, get_flush_level, get_logging_level, @@ -23,8 +25,6 @@ set_logging_level, should_log, ) -from rmm._version import __git_commit__, __version__ -from rmm.mr import disable_logging, enable_logging, get_log_filenames from rmm.rmm import ( RMMError, is_initialized, @@ -52,3 +52,13 @@ "should_log", "unregister_reinitialize_hook", ] + + +def __getattr__(name): + if name == "_lib": + import importlib + + module = importlib.import_module("rmm.pylibrmm") + return module + else: + raise AttributeError(f"Module '{__name__}' has no attribute '{name}'") diff --git a/python/rmm/rmm/_cuda/stream.pxd b/python/rmm/rmm/_cuda/stream.pxd index 3c3d3aa6f..e91e2ce58 100644 --- a/python/rmm/rmm/_cuda/stream.pxd +++ b/python/rmm/rmm/_cuda/stream.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-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. @@ -16,7 +16,7 @@ from cuda.ccudart cimport cudaStream_t from libc.stdint cimport uintptr_t from libcpp cimport bool -from rmm._lib.cuda_stream_view cimport cuda_stream_view +from rmm.librmm.cuda_stream_view cimport cuda_stream_view cdef class Stream: diff --git a/python/rmm/rmm/_cuda/stream.pyx b/python/rmm/rmm/_cuda/stream.pyx index 4d5ff5232..37dcbd610 100644 --- a/python/rmm/rmm/_cuda/stream.pyx +++ b/python/rmm/rmm/_cuda/stream.pyx @@ -16,13 +16,13 @@ from cuda.ccudart cimport cudaStream_t from libc.stdint cimport uintptr_t from libcpp cimport bool -from rmm._lib.cuda_stream cimport CudaStream -from rmm._lib.cuda_stream_view cimport ( +from rmm.librmm.cuda_stream_view cimport ( cuda_stream_default, cuda_stream_legacy, cuda_stream_per_thread, cuda_stream_view, ) +from rmm.pylibrmm.cuda_stream cimport CudaStream cdef class Stream: diff --git a/python/rmm/rmm/_lib/__init__.py b/python/rmm/rmm/_lib/__init__.py index 0b8672ef6..7cfddab60 100644 --- a/python/rmm/rmm/_lib/__init__.py +++ b/python/rmm/rmm/_lib/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2021, NVIDIA CORPORATION. +# Copyright (c) 2018-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. @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .device_buffer import DeviceBuffer +from rmm.pylibrmm import * diff --git a/python/rmm/rmm/_lib/cuda_stream.pxd b/python/rmm/rmm/_lib/cuda_stream.pxd index e224cf9af..afc365fbb 100644 --- a/python/rmm/rmm/_lib/cuda_stream.pxd +++ b/python/rmm/rmm/_lib/cuda_stream.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2020, 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. @@ -12,26 +12,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -cimport cython -from cuda.ccudart cimport cudaStream_t -from libcpp cimport bool -from libcpp.memory cimport unique_ptr - -from rmm._lib.cuda_stream_view cimport cuda_stream_view - - -cdef extern from "rmm/cuda_stream.hpp" namespace "rmm" nogil: - cdef cppclass cuda_stream: - cuda_stream() except + - bool is_valid() except + - cudaStream_t value() except + - cuda_stream_view view() except + - void synchronize() except + - void synchronize_no_throw() - - -@cython.final -cdef class CudaStream: - cdef unique_ptr[cuda_stream] c_obj - cdef cudaStream_t value(self) except * nogil - cdef bool is_valid(self) except * nogil +from rmm.librmm.cuda_stream cimport cuda_stream +from rmm.pylibrmm.cuda_stream cimport CudaStream diff --git a/python/rmm/rmm/_lib/cuda_stream_pool.pxd b/python/rmm/rmm/_lib/cuda_stream_pool.pxd index 0286a9377..4da59cc68 100644 --- a/python/rmm/rmm/_lib/cuda_stream_pool.pxd +++ b/python/rmm/rmm/_lib/cuda_stream_pool.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-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. @@ -12,14 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -cimport cython - -from rmm._lib.cuda_stream_view cimport cuda_stream_view - - -cdef extern from "rmm/cuda_stream_pool.hpp" namespace "rmm" nogil: - cdef cppclass cuda_stream_pool: - cuda_stream_pool(size_t pool_size) - cuda_stream_view get_stream() - cuda_stream_view get_stream(size_t stream_id) except + - size_t get_pool_size() +from rmm.librmm.cuda_stream_pool cimport cuda_stream_pool diff --git a/python/rmm/rmm/_lib/cuda_stream_view.pxd b/python/rmm/rmm/_lib/cuda_stream_view.pxd index bf0d33c24..c336b0fe8 100644 --- a/python/rmm/rmm/_lib/cuda_stream_view.pxd +++ b/python/rmm/rmm/_lib/cuda_stream_view.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-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. @@ -12,21 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cuda.ccudart cimport cudaStream_t -from libcpp cimport bool - - -cdef extern from "rmm/cuda_stream_view.hpp" namespace "rmm" nogil: - cdef cppclass cuda_stream_view: - cuda_stream_view() - cuda_stream_view(cudaStream_t) - cudaStream_t value() - bool is_default() - bool is_per_thread_default() - void synchronize() except + - - cdef bool operator==(cuda_stream_view const, cuda_stream_view const) - - const cuda_stream_view cuda_stream_default - const cuda_stream_view cuda_stream_legacy - const cuda_stream_view cuda_stream_per_thread +from rmm.librmm.cuda_stream_view cimport ( + cuda_stream_default, + cuda_stream_legacy, + cuda_stream_per_thread, + cuda_stream_view, +) diff --git a/python/rmm/rmm/_lib/device_buffer.pxd b/python/rmm/rmm/_lib/device_buffer.pxd index 0da9ace0c..22833b1b8 100644 --- a/python/rmm/rmm/_lib/device_buffer.pxd +++ b/python/rmm/rmm/_lib/device_buffer.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2019-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. @@ -12,105 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from libc.stdint cimport uintptr_t -from libcpp.memory cimport unique_ptr - -from rmm._cuda.stream cimport Stream -from rmm._lib.cuda_stream_view cimport cuda_stream_view -from rmm._lib.memory_resource cimport ( - DeviceMemoryResource, - device_memory_resource, +from rmm.librmm.device_buffer cimport ( + cuda_device_id, + device_buffer, + get_current_cuda_device, + prefetch, +) +from rmm.pylibrmm.device_buffer cimport ( + DeviceBuffer, + copy_device_to_ptr, + copy_host_to_ptr, + copy_ptr_to_host, + to_device, ) - - -cdef extern from "rmm/mr/device/per_device_resource.hpp" namespace "rmm" nogil: - cdef cppclass cuda_device_id: - ctypedef int value_type - cuda_device_id() - cuda_device_id(value_type id) - value_type value() - - cdef cuda_device_id get_current_cuda_device() - -cdef extern from "rmm/prefetch.hpp" namespace "rmm" nogil: - cdef void prefetch(const void* ptr, - size_t bytes, - cuda_device_id device, - cuda_stream_view stream) except + - -cdef extern from "rmm/device_buffer.hpp" namespace "rmm" nogil: - cdef cppclass device_buffer: - device_buffer() - device_buffer( - size_t size, - cuda_stream_view stream, - device_memory_resource * - ) except + - device_buffer( - const void* source_data, - size_t size, - cuda_stream_view stream, - device_memory_resource * - ) except + - device_buffer( - const device_buffer buf, - cuda_stream_view stream, - device_memory_resource * - ) except + - void reserve(size_t new_capacity, cuda_stream_view stream) except + - void resize(size_t new_size, cuda_stream_view stream) except + - void shrink_to_fit(cuda_stream_view stream) except + - void* data() - size_t size() - size_t capacity() - - -cdef class DeviceBuffer: - cdef unique_ptr[device_buffer] c_obj - - # Holds a reference to the DeviceMemoryResource used for allocation. - # Ensures the MR does not get destroyed before this DeviceBuffer. `mr` is - # needed for deallocation - cdef DeviceMemoryResource mr - - # Holds a reference to the stream used by the underlying `device_buffer`. - # Ensures the stream does not get destroyed before this DeviceBuffer - cdef Stream stream - - @staticmethod - cdef DeviceBuffer c_from_unique_ptr( - unique_ptr[device_buffer] ptr, - Stream stream=*, - DeviceMemoryResource mr=*, - ) - - @staticmethod - cdef DeviceBuffer c_to_device(const unsigned char[::1] b, - Stream stream=*) except * - cpdef copy_to_host(self, ary=*, Stream stream=*) - cpdef copy_from_host(self, ary, Stream stream=*) - cpdef copy_from_device(self, cuda_ary, Stream stream=*) - cpdef bytes tobytes(self, Stream stream=*) - - cdef size_t c_size(self) except * - cpdef void reserve(self, size_t new_capacity, Stream stream=*) except * - cpdef void resize(self, size_t new_size, Stream stream=*) except * - cpdef size_t capacity(self) except * - cdef void* c_data(self) except * - - cdef device_buffer c_release(self) except * - -cpdef DeviceBuffer to_device(const unsigned char[::1] b, - Stream stream=*) -cpdef void copy_ptr_to_host(uintptr_t db, - unsigned char[::1] hb, - Stream stream=*) except * - -cpdef void copy_host_to_ptr(const unsigned char[::1] hb, - uintptr_t db, - Stream stream=*) except * - -cpdef void copy_device_to_ptr(uintptr_t d_src, - uintptr_t d_dst, - size_t count, - Stream stream=*) except * diff --git a/python/rmm/rmm/_lib/device_uvector.pxd b/python/rmm/rmm/_lib/device_uvector.pxd index 29e122bbf..230b0afb3 100644 --- a/python/rmm/rmm/_lib/device_uvector.pxd +++ b/python/rmm/rmm/_lib/device_uvector.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-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. @@ -12,28 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -from rmm._lib.cuda_stream_view cimport cuda_stream_view -from rmm._lib.device_buffer cimport device_buffer -from rmm._lib.memory_resource cimport device_memory_resource - - -cdef extern from "rmm/device_buffer.hpp" namespace "rmm" nogil: - cdef cppclass device_uvector[T]: - device_uvector(size_t size, cuda_stream_view stream) except + - T* element_ptr(size_t index) - void set_element(size_t element_index, const T& v, cuda_stream_view s) - void set_element_async( - size_t element_index, - const T& v, - cuda_stream_view s - ) except + - T front_element(cuda_stream_view s) except + - T back_element(cuda_stream_view s) except + - void reserve(size_t new_capacity, cuda_stream_view stream) except + - void resize(size_t new_size, cuda_stream_view stream) except + - void shrink_to_fit(cuda_stream_view stream) except + - device_buffer release() - size_t capacity() - T* data() - size_t size() - device_memory_resource* memory_resource() +from rmm.librmm.device_uvector cimport device_uvector diff --git a/python/rmm/rmm/_lib/helper.pxd b/python/rmm/rmm/_lib/helper.pxd index 8ca151c00..4a5159435 100644 --- a/python/rmm/rmm/_lib/helper.pxd +++ b/python/rmm/rmm/_lib/helper.pxd @@ -12,5 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. - -cdef object parse_bytes(object s) except * +from rmm.pylibrmm.helper cimport parse_bytes diff --git a/python/rmm/rmm/_lib/logger.pxd b/python/rmm/rmm/_lib/logger.pxd new file mode 100644 index 000000000..bef05c903 --- /dev/null +++ b/python/rmm/rmm/_lib/logger.pxd @@ -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. + +from rmm.librmm._logger cimport logger, logging_level, spdlog_logger +from rmm.pylibrmm.logger cimport ( + _validate_level_type, + flush_logger, + get_flush_level, + get_logging_level, + set_flush_level, + set_logging_level, + should_log, +) diff --git a/python/rmm/rmm/_lib/memory_resource.pxd b/python/rmm/rmm/_lib/memory_resource.pxd index 000a3fe1e..983063914 100644 --- a/python/rmm/rmm/_lib/memory_resource.pxd +++ b/python/rmm/rmm/_lib/memory_resource.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2020-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. @@ -12,92 +12,50 @@ # See the License for the specific language governing permissions and # limitations under the License. -from libc.stdint cimport int8_t -from libcpp.memory cimport shared_ptr -from libcpp.pair cimport pair -from libcpp.string cimport string -from libcpp.vector cimport vector - -from rmm._lib.cuda_stream_view cimport cuda_stream_view - - -cdef extern from "rmm/mr/device/device_memory_resource.hpp" \ - namespace "rmm::mr" nogil: - cdef cppclass device_memory_resource: - void* allocate(size_t bytes) except + - void* allocate(size_t bytes, cuda_stream_view stream) except + - void deallocate(void* ptr, size_t bytes) except + - void deallocate( - void* ptr, - size_t bytes, - cuda_stream_view stream - ) except + - -cdef extern from "rmm/cuda_device.hpp" namespace "rmm" nogil: - size_t percent_of_free_device_memory(int percent) except + - pair[size_t, size_t] available_device_memory() except + - -cdef class DeviceMemoryResource: - cdef shared_ptr[device_memory_resource] c_obj - cdef device_memory_resource* get_mr(self) noexcept nogil - -cdef class UpstreamResourceAdaptor(DeviceMemoryResource): - cdef readonly DeviceMemoryResource upstream_mr - - cpdef DeviceMemoryResource get_upstream(self) - -cdef class CudaMemoryResource(DeviceMemoryResource): - pass - -cdef class ManagedMemoryResource(DeviceMemoryResource): - pass - -cdef class SystemMemoryResource(DeviceMemoryResource): - pass - -cdef class SamHeadroomMemoryResource(DeviceMemoryResource): - pass - -cdef class CudaAsyncMemoryResource(DeviceMemoryResource): - pass - -cdef class PoolMemoryResource(UpstreamResourceAdaptor): - pass - -cdef class FixedSizeMemoryResource(UpstreamResourceAdaptor): - pass - -cdef class BinningMemoryResource(UpstreamResourceAdaptor): - - cdef readonly list _bin_mrs - - cpdef add_bin( - self, - size_t allocation_size, - DeviceMemoryResource bin_resource=*) - -cdef class CallbackMemoryResource(DeviceMemoryResource): - cdef object _allocate_func - cdef object _deallocate_func - -cdef class LimitingResourceAdaptor(UpstreamResourceAdaptor): - pass - -cdef class LoggingResourceAdaptor(UpstreamResourceAdaptor): - cdef object _log_file_name - cpdef get_file_name(self) - cpdef flush(self) - -cdef class StatisticsResourceAdaptor(UpstreamResourceAdaptor): - pass - -cdef class TrackingResourceAdaptor(UpstreamResourceAdaptor): - pass - -cdef class FailureCallbackResourceAdaptor(UpstreamResourceAdaptor): - cdef object _callback - -cdef class PrefetchResourceAdaptor(UpstreamResourceAdaptor): - pass - -cpdef DeviceMemoryResource get_current_device_resource() +from rmm.librmm.memory_resource cimport ( + CppExcept, + allocate_callback_t, + allocation_handle_type, + available_device_memory, + binning_memory_resource, + callback_memory_resource, + cuda_async_memory_resource, + cuda_memory_resource, + deallocate_callback_t, + device_memory_resource, + failure_callback_resource_adaptor, + failure_callback_t, + fixed_size_memory_resource, + limiting_resource_adaptor, + logging_resource_adaptor, + managed_memory_resource, + percent_of_free_device_memory, + pool_memory_resource, + prefetch_resource_adaptor, + sam_headroom_memory_resource, + statistics_resource_adaptor, + system_memory_resource, + throw_cpp_except, + tracking_resource_adaptor, + translate_python_except_to_cpp, +) +from rmm.pylibrmm.memory_resource cimport ( + BinningMemoryResource, + CallbackMemoryResource, + CudaAsyncMemoryResource, + CudaMemoryResource, + DeviceMemoryResource, + FailureCallbackResourceAdaptor, + FixedSizeMemoryResource, + LimitingResourceAdaptor, + LoggingResourceAdaptor, + ManagedMemoryResource, + PoolMemoryResource, + PrefetchResourceAdaptor, + SamHeadroomMemoryResource, + StatisticsResourceAdaptor, + SystemMemoryResource, + TrackingResourceAdaptor, + UpstreamResourceAdaptor, + get_current_device_resource, +) diff --git a/python/rmm/rmm/_lib/per_device_resource.pxd b/python/rmm/rmm/_lib/per_device_resource.pxd index c33217622..29487f503 100644 --- a/python/rmm/rmm/_lib/per_device_resource.pxd +++ b/python/rmm/rmm/_lib/per_device_resource.pxd @@ -1,23 +1,21 @@ -from rmm._lib.memory_resource cimport device_memory_resource +# Copyright (c) 2019-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. - -cdef extern from "rmm/mr/device/per_device_resource.hpp" namespace "rmm" nogil: - cdef cppclass cuda_device_id: - ctypedef int value_type - - cuda_device_id(value_type id) - - value_type value() - -cdef extern from "rmm/mr/device/per_device_resource.hpp" \ - namespace "rmm::mr" nogil: - cdef device_memory_resource* set_current_device_resource( - device_memory_resource* new_mr - ) - cdef device_memory_resource* get_current_device_resource() - cdef device_memory_resource* set_per_device_resource( - cuda_device_id id, device_memory_resource* new_mr - ) - cdef device_memory_resource* get_per_device_resource ( - cuda_device_id id - ) +from rmm.librmm.per_device_resource cimport ( + cuda_device_id, + get_current_device_resource, + get_per_device_resource, + set_current_device_resource, + set_per_device_resource, +) diff --git a/python/rmm/rmm/allocators/cupy.py b/python/rmm/rmm/allocators/cupy.py index 89947c46b..780ff2abf 100644 --- a/python/rmm/rmm/allocators/cupy.py +++ b/python/rmm/rmm/allocators/cupy.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. +# 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. @@ -11,7 +11,7 @@ # 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. -from rmm import _lib as librmm +from rmm import pylibrmm from rmm._cuda.stream import Stream try: @@ -34,7 +34,7 @@ def rmm_cupy_allocator(nbytes): raise ModuleNotFoundError("No module named 'cupy'") stream = Stream(obj=cupy.cuda.get_current_stream()) - buf = librmm.device_buffer.DeviceBuffer(size=nbytes, stream=stream) + buf = pylibrmm.device_buffer.DeviceBuffer(size=nbytes, stream=stream) dev_id = -1 if buf.ptr else cupy.cuda.device.get_device_id() mem = cupy.cuda.UnownedMemory( ptr=buf.ptr, size=buf.size, owner=buf, device_id=dev_id diff --git a/python/rmm/rmm/allocators/numba.py b/python/rmm/rmm/allocators/numba.py index 5e87b87b6..fd9bacb5a 100644 --- a/python/rmm/rmm/allocators/numba.py +++ b/python/rmm/rmm/allocators/numba.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. +# 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. @@ -19,7 +19,7 @@ from numba import config, cuda from numba.cuda import HostOnlyCUDAMemoryManager, IpcHandle, MemoryPointer -from rmm import _lib as librmm +from rmm import pylibrmm def _make_emm_plugin_finalizer(handle, allocations): @@ -70,7 +70,7 @@ def memalloc(self, size): """ Allocate an on-device array from the RMM pool. """ - buf = librmm.DeviceBuffer(size=size) + buf = pylibrmm.DeviceBuffer(size=size) ctx = self.context if config.CUDA_USE_NVIDIA_BINDING: diff --git a/python/rmm/rmm/allocators/torch.py b/python/rmm/rmm/allocators/torch.py index 753da66da..eee0e9df9 100644 --- a/python/rmm/rmm/allocators/torch.py +++ b/python/rmm/rmm/allocators/torch.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. +# 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. @@ -28,10 +28,10 @@ # allocator .so relative to the current file because the current file # is pure Python and will therefore be in the source directory. # Instead, we search relative to an arbitrary file in the compiled - # package. We use the _lib.lib module because it is small. - from rmm._lib import lib + # package. We use the librmm._logger module because it is small. + from rmm.librmm import _logger - sofile = pathlib.Path(lib.__file__).parent / "_torch_allocator.so" + sofile = pathlib.Path(_logger.__file__).parent / "_torch_allocator.so" rmm_torch_allocator = CUDAPluggableAllocator( str(sofile.absolute()), alloc_fn_name="allocate", diff --git a/python/rmm/rmm/_lib/CMakeLists.txt b/python/rmm/rmm/librmm/CMakeLists.txt similarity index 93% rename from python/rmm/rmm/_lib/CMakeLists.txt rename to python/rmm/rmm/librmm/CMakeLists.txt index 7cdfed971..5da2a1a01 100644 --- a/python/rmm/rmm/_lib/CMakeLists.txt +++ b/python/rmm/rmm/librmm/CMakeLists.txt @@ -12,8 +12,7 @@ # the License. # ============================================================================= -set(cython_sources device_buffer.pyx lib.pyx logger.pyx memory_resource.pyx cuda_stream.pyx - helper.pyx) +set(cython_sources _logger.pyx) set(linked_libraries rmm::rmm) # Build all of the Cython targets diff --git a/python/rmm/rmm/_lib/__init__.pxd b/python/rmm/rmm/librmm/__init__.py similarity index 100% rename from python/rmm/rmm/_lib/__init__.pxd rename to python/rmm/rmm/librmm/__init__.py diff --git a/python/rmm/rmm/librmm/_logger.pxd b/python/rmm/rmm/librmm/_logger.pxd new file mode 100644 index 000000000..241a748c3 --- /dev/null +++ b/python/rmm/rmm/librmm/_logger.pxd @@ -0,0 +1,66 @@ +# 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. + +from libcpp cimport bool + + +cdef extern from "spdlog/common.h" namespace "spdlog::level" nogil: + cpdef enum logging_level "spdlog::level::level_enum": + """ + The debug logging level for RMM. + + Debug logging prints messages to a log file. See + `Debug Logging `_ + for more information. + + Valid levels, in decreasing order of verbosity, are TRACE, DEBUG, + INFO, WARN, ERR, CRITICAL, and OFF. Default is INFO. + + Examples + -------- + >>> import rmm + >>> rmm.logging_level.DEBUG + + >>> rmm.logging_level.DEBUG.value + 1 + >>> rmm.logging_level.DEBUG.name + 'DEBUG' + + See Also + -------- + set_logging_level : Set the debug logging level + get_logging_level : Get the current debug logging level + """ + TRACE "spdlog::level::trace" + DEBUG "spdlog::level::debug" + INFO "spdlog::level::info" + WARN "spdlog::level::warn" + ERR "spdlog::level::err" + CRITICAL "spdlog::level::critical" + OFF "spdlog::level::off" + + +cdef extern from "spdlog/spdlog.h" namespace "spdlog" nogil: + cdef cppclass spdlog_logger "spdlog::logger": + spdlog_logger() except + + void set_level(logging_level level) + logging_level level() + void flush() except + + void flush_on(logging_level level) + logging_level flush_level() + bool should_log(logging_level msg_level) + + +cdef extern from "rmm/logger.hpp" namespace "rmm" nogil: + cdef spdlog_logger& logger() except + diff --git a/python/rmm/rmm/_lib/lib.pxd b/python/rmm/rmm/librmm/_logger.pyx similarity index 70% rename from python/rmm/rmm/_lib/lib.pxd rename to python/rmm/rmm/librmm/_logger.pyx index e35b672e4..4392cb106 100644 --- a/python/rmm/rmm/_lib/lib.pxd +++ b/python/rmm/rmm/librmm/_logger.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2020, NVIDIA CORPORATION. +# 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. @@ -12,9 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -from libc.stdint cimport uintptr_t -from libcpp cimport bool -from libcpp.utility cimport pair -from libcpp.vector cimport vector - -ctypedef pair[const char*, unsigned int] caller_pair +from rmm.librmm._logger cimport logging_level # no-cython-lint diff --git a/python/rmm/rmm/_lib/_torch_allocator.cpp b/python/rmm/rmm/librmm/_torch_allocator.cpp similarity index 100% rename from python/rmm/rmm/_lib/_torch_allocator.cpp rename to python/rmm/rmm/librmm/_torch_allocator.cpp diff --git a/python/rmm/rmm/librmm/cuda_stream.pxd b/python/rmm/rmm/librmm/cuda_stream.pxd new file mode 100644 index 000000000..3f2ac3361 --- /dev/null +++ b/python/rmm/rmm/librmm/cuda_stream.pxd @@ -0,0 +1,28 @@ +# Copyright (c) 2020-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. + +from cuda.ccudart cimport cudaStream_t +from libcpp cimport bool + +from rmm.librmm.cuda_stream_view cimport cuda_stream_view + + +cdef extern from "rmm/cuda_stream.hpp" namespace "rmm" nogil: + cdef cppclass cuda_stream: + cuda_stream() except + + bool is_valid() except + + cudaStream_t value() except + + cuda_stream_view view() except + + void synchronize() except + + void synchronize_no_throw() diff --git a/python/rmm/rmm/librmm/cuda_stream_pool.pxd b/python/rmm/rmm/librmm/cuda_stream_pool.pxd new file mode 100644 index 000000000..4f2cbb36d --- /dev/null +++ b/python/rmm/rmm/librmm/cuda_stream_pool.pxd @@ -0,0 +1,23 @@ +# Copyright (c) 2021-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. + +from rmm.librmm.cuda_stream_view cimport cuda_stream_view + + +cdef extern from "rmm/cuda_stream_pool.hpp" namespace "rmm" nogil: + cdef cppclass cuda_stream_pool: + cuda_stream_pool(size_t pool_size) + cuda_stream_view get_stream() + cuda_stream_view get_stream(size_t stream_id) except + + size_t get_pool_size() diff --git a/python/rmm/rmm/librmm/cuda_stream_view.pxd b/python/rmm/rmm/librmm/cuda_stream_view.pxd new file mode 100644 index 000000000..bf0d33c24 --- /dev/null +++ b/python/rmm/rmm/librmm/cuda_stream_view.pxd @@ -0,0 +1,32 @@ +# Copyright (c) 2020, 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. + +from cuda.ccudart cimport cudaStream_t +from libcpp cimport bool + + +cdef extern from "rmm/cuda_stream_view.hpp" namespace "rmm" nogil: + cdef cppclass cuda_stream_view: + cuda_stream_view() + cuda_stream_view(cudaStream_t) + cudaStream_t value() + bool is_default() + bool is_per_thread_default() + void synchronize() except + + + cdef bool operator==(cuda_stream_view const, cuda_stream_view const) + + const cuda_stream_view cuda_stream_default + const cuda_stream_view cuda_stream_legacy + const cuda_stream_view cuda_stream_per_thread diff --git a/python/rmm/rmm/librmm/device_buffer.pxd b/python/rmm/rmm/librmm/device_buffer.pxd new file mode 100644 index 000000000..1c503ac9a --- /dev/null +++ b/python/rmm/rmm/librmm/device_buffer.pxd @@ -0,0 +1,58 @@ +# Copyright (c) 2019-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. + +from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from rmm.librmm.memory_resource cimport device_memory_resource + + +cdef extern from "rmm/mr/device/per_device_resource.hpp" namespace "rmm" nogil: + cdef cppclass cuda_device_id: + ctypedef int value_type + cuda_device_id() + cuda_device_id(value_type id) + value_type value() + + cdef cuda_device_id get_current_cuda_device() + +cdef extern from "rmm/prefetch.hpp" namespace "rmm" nogil: + cdef void prefetch(const void* ptr, + size_t bytes, + cuda_device_id device, + cuda_stream_view stream) except + + +cdef extern from "rmm/device_buffer.hpp" namespace "rmm" nogil: + cdef cppclass device_buffer: + device_buffer() + device_buffer( + size_t size, + cuda_stream_view stream, + device_memory_resource * + ) except + + device_buffer( + const void* source_data, + size_t size, + cuda_stream_view stream, + device_memory_resource * + ) except + + device_buffer( + const device_buffer buf, + cuda_stream_view stream, + device_memory_resource * + ) except + + void reserve(size_t new_capacity, cuda_stream_view stream) except + + void resize(size_t new_size, cuda_stream_view stream) except + + void shrink_to_fit(cuda_stream_view stream) except + + void* data() + size_t size() + size_t capacity() diff --git a/python/rmm/rmm/librmm/device_uvector.pxd b/python/rmm/rmm/librmm/device_uvector.pxd new file mode 100644 index 000000000..f560a9e38 --- /dev/null +++ b/python/rmm/rmm/librmm/device_uvector.pxd @@ -0,0 +1,39 @@ +# Copyright (c) 2021-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. + +from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from rmm.librmm.device_buffer cimport device_buffer +from rmm.librmm.memory_resource cimport device_memory_resource + + +cdef extern from "rmm/device_buffer.hpp" namespace "rmm" nogil: + cdef cppclass device_uvector[T]: + device_uvector(size_t size, cuda_stream_view stream) except + + T* element_ptr(size_t index) + void set_element(size_t element_index, const T& v, cuda_stream_view s) + void set_element_async( + size_t element_index, + const T& v, + cuda_stream_view s + ) except + + T front_element(cuda_stream_view s) except + + T back_element(cuda_stream_view s) except + + void reserve(size_t new_capacity, cuda_stream_view stream) except + + void resize(size_t new_size, cuda_stream_view stream) except + + void shrink_to_fit(cuda_stream_view stream) except + + device_buffer release() + size_t capacity() + T* data() + size_t size() + device_memory_resource* memory_resource() diff --git a/python/rmm/rmm/librmm/memory_resource.pxd b/python/rmm/rmm/librmm/memory_resource.pxd new file mode 100644 index 000000000..9ddaf04b9 --- /dev/null +++ b/python/rmm/rmm/librmm/memory_resource.pxd @@ -0,0 +1,230 @@ +# Copyright (c) 2020-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. + +# This import is needed for Cython typing in translate_python_except_to_cpp +# See https://github.com/cython/cython/issues/5589 +from builtins import BaseException + +from libc.stddef cimport size_t +from libc.stdint cimport int8_t, int64_t +from libcpp cimport bool +from libcpp.optional cimport optional +from libcpp.pair cimport pair +from libcpp.string cimport string + +from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from rmm.librmm.memory_resource cimport device_memory_resource + + +cdef extern from "rmm/mr/device/device_memory_resource.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass device_memory_resource: + void* allocate(size_t bytes) except + + void* allocate(size_t bytes, cuda_stream_view stream) except + + void deallocate(void* ptr, size_t bytes) except + + void deallocate( + void* ptr, + size_t bytes, + cuda_stream_view stream + ) except + + +cdef extern from "rmm/cuda_device.hpp" namespace "rmm" nogil: + size_t percent_of_free_device_memory(int percent) except + + pair[size_t, size_t] available_device_memory() except + + +# Transparent handle of a C++ exception +ctypedef pair[int, string] CppExcept + +cdef inline CppExcept translate_python_except_to_cpp(err: BaseException) noexcept: + """Translate a Python exception into a C++ exception handle + + The returned exception handle can then be thrown by `throw_cpp_except()`, + which MUST be done without holding the GIL. + + This is useful when C++ calls a Python function and needs to catch or + propagate exceptions. + """ + if isinstance(err, MemoryError): + return CppExcept(0, str.encode(str(err))) + return CppExcept(-1, str.encode(str(err))) + +# Implementation of `throw_cpp_except()`, which throws a given `CppExcept`. +# This function MUST be called without the GIL otherwise the thrown C++ +# exception are translated back into a Python exception. +cdef extern from *: + """ + #include + #include + + void throw_cpp_except(std::pair res) { + switch(res.first) { + case 0: + throw rmm::out_of_memory(res.second); + default: + throw std::runtime_error(res.second); + } + } + """ + void throw_cpp_except(CppExcept) nogil + + +cdef extern from "rmm/mr/device/cuda_memory_resource.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass cuda_memory_resource(device_memory_resource): + cuda_memory_resource() except + + +cdef extern from "rmm/mr/device/managed_memory_resource.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass managed_memory_resource(device_memory_resource): + managed_memory_resource() except + + +cdef extern from "rmm/mr/device/system_memory_resource.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass system_memory_resource(device_memory_resource): + system_memory_resource() except + + +cdef extern from "rmm/mr/device/sam_headroom_memory_resource.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass sam_headroom_memory_resource(device_memory_resource): + sam_headroom_memory_resource(size_t headroom) except + + +cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ + namespace "rmm::mr" nogil: + + cdef cppclass cuda_async_memory_resource(device_memory_resource): + cuda_async_memory_resource( + optional[size_t] initial_pool_size, + optional[size_t] release_threshold, + optional[allocation_handle_type] export_handle_type) except + + +# TODO: when we adopt Cython 3.0 use enum class +cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ + namespace \ + "rmm::mr::cuda_async_memory_resource::allocation_handle_type" \ + nogil: + enum allocation_handle_type \ + "rmm::mr::cuda_async_memory_resource::allocation_handle_type": + none + posix_file_descriptor + win32 + win32_kmt + + +cdef extern from "rmm/mr/device/pool_memory_resource.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass pool_memory_resource[Upstream](device_memory_resource): + pool_memory_resource( + Upstream* upstream_mr, + size_t initial_pool_size, + optional[size_t] maximum_pool_size) except + + size_t pool_size() + +cdef extern from "rmm/mr/device/fixed_size_memory_resource.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass fixed_size_memory_resource[Upstream](device_memory_resource): + fixed_size_memory_resource( + Upstream* upstream_mr, + size_t block_size, + size_t block_to_preallocate) except + + +cdef extern from "rmm/mr/device/callback_memory_resource.hpp" \ + namespace "rmm::mr" nogil: + ctypedef void* (*allocate_callback_t)(size_t, cuda_stream_view, void*) + ctypedef void (*deallocate_callback_t)(void*, size_t, cuda_stream_view, void*) + + cdef cppclass callback_memory_resource(device_memory_resource): + callback_memory_resource( + allocate_callback_t allocate_callback, + deallocate_callback_t deallocate_callback, + void* allocate_callback_arg, + void* deallocate_callback_arg + ) except + + +cdef extern from "rmm/mr/device/binning_memory_resource.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass binning_memory_resource[Upstream](device_memory_resource): + binning_memory_resource(Upstream* upstream_mr) except + + binning_memory_resource( + Upstream* upstream_mr, + int8_t min_size_exponent, + int8_t max_size_exponent) except + + + void add_bin(size_t allocation_size) except + + void add_bin( + size_t allocation_size, + device_memory_resource* bin_resource) except + + +cdef extern from "rmm/mr/device/limiting_resource_adaptor.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass limiting_resource_adaptor[Upstream](device_memory_resource): + limiting_resource_adaptor( + Upstream* upstream_mr, + size_t allocation_limit) except + + + size_t get_allocated_bytes() except + + size_t get_allocation_limit() except + + +cdef extern from "rmm/mr/device/logging_resource_adaptor.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass logging_resource_adaptor[Upstream](device_memory_resource): + logging_resource_adaptor( + Upstream* upstream_mr, + string filename) except + + + void flush() except + + +cdef extern from "rmm/mr/device/statistics_resource_adaptor.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass statistics_resource_adaptor[Upstream](device_memory_resource): + struct counter: + counter() + + int64_t value + int64_t peak + int64_t total + + statistics_resource_adaptor(Upstream* upstream_mr) except + + + counter get_bytes_counter() except + + counter get_allocations_counter() except + + pair[counter, counter] pop_counters() except + + pair[counter, counter] push_counters() except + + +cdef extern from "rmm/mr/device/tracking_resource_adaptor.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass tracking_resource_adaptor[Upstream](device_memory_resource): + tracking_resource_adaptor( + Upstream* upstream_mr, + bool capture_stacks) except + + + size_t get_allocated_bytes() except + + string get_outstanding_allocations_str() except + + void log_outstanding_allocations() except + + +cdef extern from "rmm/mr/device/failure_callback_resource_adaptor.hpp" \ + namespace "rmm::mr" nogil: + ctypedef bool (*failure_callback_t)(size_t, void*) + cdef cppclass failure_callback_resource_adaptor[Upstream]( + device_memory_resource + ): + failure_callback_resource_adaptor( + Upstream* upstream_mr, + failure_callback_t callback, + void* callback_arg + ) except + + +cdef extern from "rmm/mr/device/prefetch_resource_adaptor.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass prefetch_resource_adaptor[Upstream](device_memory_resource): + prefetch_resource_adaptor(Upstream* upstream_mr) except + diff --git a/python/rmm/rmm/librmm/per_device_resource.pxd b/python/rmm/rmm/librmm/per_device_resource.pxd new file mode 100644 index 000000000..63ee29056 --- /dev/null +++ b/python/rmm/rmm/librmm/per_device_resource.pxd @@ -0,0 +1,36 @@ +# Copyright (c) 2019-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. +from rmm.librmm.memory_resource cimport device_memory_resource + + +cdef extern from "rmm/mr/device/per_device_resource.hpp" namespace "rmm" nogil: + cdef cppclass cuda_device_id: + ctypedef int value_type + + cuda_device_id(value_type id) + + value_type value() + +cdef extern from "rmm/mr/device/per_device_resource.hpp" \ + namespace "rmm::mr" nogil: + cdef device_memory_resource* set_current_device_resource( + device_memory_resource* new_mr + ) + cdef device_memory_resource* get_current_device_resource() + cdef device_memory_resource* set_per_device_resource( + cuda_device_id id, device_memory_resource* new_mr + ) + cdef device_memory_resource* get_per_device_resource ( + cuda_device_id id + ) diff --git a/python/rmm/rmm/mr.py b/python/rmm/rmm/mr.py index 6eb94da0f..3f0c3fce3 100644 --- a/python/rmm/rmm/mr.py +++ b/python/rmm/rmm/mr.py @@ -11,7 +11,7 @@ # 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. -from rmm._lib.memory_resource import ( +from rmm.pylibrmm.memory_resource import ( BinningMemoryResource, CallbackMemoryResource, CudaAsyncMemoryResource, diff --git a/python/rmm/rmm/pylibrmm/CMakeLists.txt b/python/rmm/rmm/pylibrmm/CMakeLists.txt new file mode 100644 index 000000000..0e88f01bb --- /dev/null +++ b/python/rmm/rmm/pylibrmm/CMakeLists.txt @@ -0,0 +1,27 @@ +# ============================================================================= +# Copyright (c) 2022-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(cython_sources device_buffer.pyx logger.pyx memory_resource.pyx cuda_stream.pyx helper.pyx) +set(linked_libraries rmm::rmm) + +# Build all of the Cython targets +rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}" + CXX) + +# mark all symbols in these Cython targets "hidden" by default, so they won't collide with symbols +# loaded from other DSOs +foreach(_cython_target IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${_cython_target} PROPERTIES C_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden) +endforeach() diff --git a/python/rmm/rmm/pylibrmm/__init__.py b/python/rmm/rmm/pylibrmm/__init__.py new file mode 100644 index 000000000..0b8672ef6 --- /dev/null +++ b/python/rmm/rmm/pylibrmm/__init__.py @@ -0,0 +1,15 @@ +# Copyright (c) 2019-2021, 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. + +from .device_buffer import DeviceBuffer diff --git a/python/rmm/rmm/pylibrmm/cuda_stream.pxd b/python/rmm/rmm/pylibrmm/cuda_stream.pxd new file mode 100644 index 000000000..dd38387c2 --- /dev/null +++ b/python/rmm/rmm/pylibrmm/cuda_stream.pxd @@ -0,0 +1,27 @@ +# Copyright (c) 2019-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. + +cimport cython +from cuda.ccudart cimport cudaStream_t +from libcpp cimport bool +from libcpp.memory cimport unique_ptr + +from rmm.librmm.cuda_stream cimport cuda_stream + + +@cython.final +cdef class CudaStream: + cdef unique_ptr[cuda_stream] c_obj + cdef cudaStream_t value(self) except * nogil + cdef bool is_valid(self) except * nogil diff --git a/python/rmm/rmm/_lib/cuda_stream.pyx b/python/rmm/rmm/pylibrmm/cuda_stream.pyx similarity index 91% rename from python/rmm/rmm/_lib/cuda_stream.pyx rename to python/rmm/rmm/pylibrmm/cuda_stream.pyx index 0861f0663..d6aa4edc7 100644 --- a/python/rmm/rmm/_lib/cuda_stream.pyx +++ b/python/rmm/rmm/pylibrmm/cuda_stream.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-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. @@ -16,6 +16,8 @@ cimport cython from cuda.ccudart cimport cudaStream_t from libcpp cimport bool +from rmm.librmm.cuda_stream cimport cuda_stream + @cython.final cdef class CudaStream: diff --git a/python/rmm/rmm/pylibrmm/device_buffer.pxd b/python/rmm/rmm/pylibrmm/device_buffer.pxd new file mode 100644 index 000000000..a0d287423 --- /dev/null +++ b/python/rmm/rmm/pylibrmm/device_buffer.pxd @@ -0,0 +1,71 @@ +# Copyright (c) 2019-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. + +from libc.stdint cimport uintptr_t +from libcpp.memory cimport unique_ptr + +from rmm._cuda.stream cimport Stream +from rmm.librmm.device_buffer cimport device_buffer +from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource + + +cdef class DeviceBuffer: + cdef unique_ptr[device_buffer] c_obj + + # Holds a reference to the DeviceMemoryResource used for allocation. + # Ensures the MR does not get destroyed before this DeviceBuffer. `mr` is + # needed for deallocation + cdef DeviceMemoryResource mr + + # Holds a reference to the stream used by the underlying `device_buffer`. + # Ensures the stream does not get destroyed before this DeviceBuffer + cdef Stream stream + + @staticmethod + cdef DeviceBuffer c_from_unique_ptr( + unique_ptr[device_buffer] ptr, + Stream stream=*, + DeviceMemoryResource mr=*, + ) + + @staticmethod + cdef DeviceBuffer c_to_device(const unsigned char[::1] b, + Stream stream=*) except * + cpdef copy_to_host(self, ary=*, Stream stream=*) + cpdef copy_from_host(self, ary, Stream stream=*) + cpdef copy_from_device(self, cuda_ary, Stream stream=*) + cpdef bytes tobytes(self, Stream stream=*) + + cdef size_t c_size(self) except * + cpdef void reserve(self, size_t new_capacity, Stream stream=*) except * + cpdef void resize(self, size_t new_size, Stream stream=*) except * + cpdef size_t capacity(self) except * + cdef void* c_data(self) except * + + cdef device_buffer c_release(self) except * + +cpdef DeviceBuffer to_device(const unsigned char[::1] b, + Stream stream=*) +cpdef void copy_ptr_to_host(uintptr_t db, + unsigned char[::1] hb, + Stream stream=*) except * + +cpdef void copy_host_to_ptr(const unsigned char[::1] hb, + uintptr_t db, + Stream stream=*) except * + +cpdef void copy_device_to_ptr(uintptr_t d_src, + uintptr_t d_dst, + size_t count, + Stream stream=*) except * diff --git a/python/rmm/rmm/_lib/device_buffer.pyx b/python/rmm/rmm/pylibrmm/device_buffer.pyx similarity index 96% rename from python/rmm/rmm/_lib/device_buffer.pyx rename to python/rmm/rmm/pylibrmm/device_buffer.pyx index 94a4dc771..76fbceef8 100644 --- a/python/rmm/rmm/_lib/device_buffer.pyx +++ b/python/rmm/rmm/pylibrmm/device_buffer.pyx @@ -32,9 +32,16 @@ from cuda.ccudart cimport ( cudaStream_t, ) -from rmm._lib.memory_resource cimport ( +from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from rmm.librmm.device_buffer cimport ( + cuda_device_id, + device_buffer, + get_current_cuda_device, + prefetch, +) +from rmm.librmm.memory_resource cimport device_memory_resource +from rmm.pylibrmm.memory_resource cimport ( DeviceMemoryResource, - device_memory_resource, get_current_device_resource, ) @@ -394,7 +401,7 @@ cpdef DeviceBuffer to_device(const unsigned char[::1] b, Examples -------- >>> import rmm - >>> db = rmm._lib.device_buffer.to_device(b"abc") + >>> db = rmm.pylibrmm.device_buffer.to_device(b"abc") >>> print(bytes(db)) b'abc' """ @@ -460,7 +467,7 @@ cpdef void copy_ptr_to_host(uintptr_t db, >>> import rmm >>> db = rmm.DeviceBuffer.to_device(b"abc") >>> hb = bytearray(db.nbytes) - >>> rmm._lib.device_buffer.copy_ptr_to_host(db.ptr, hb) + >>> rmm.pylibrmm.device_buffer.copy_ptr_to_host(db.ptr, hb) >>> print(hb) bytearray(b'abc') """ @@ -502,7 +509,7 @@ cpdef void copy_host_to_ptr(const unsigned char[::1] hb, >>> import rmm >>> db = rmm.DeviceBuffer(size=10) >>> hb = b"abc" - >>> rmm._lib.device_buffer.copy_host_to_ptr(hb, db.ptr) + >>> rmm.pylibrmm.device_buffer.copy_host_to_ptr(hb, db.ptr) >>> hb = db.copy_to_host() >>> print(hb) array([97, 98, 99, 0, 0, 0, 0, 0, 0, 0], dtype=uint8) @@ -541,7 +548,7 @@ cpdef void copy_device_to_ptr(uintptr_t d_src, >>> import rmm >>> db = rmm.DeviceBuffer(size=5) >>> db2 = rmm.DeviceBuffer.to_device(b"abc") - >>> rmm._lib.device_buffer.copy_device_to_ptr(db2.ptr, db.ptr, db2.size) + >>> rmm.pylibrmm.device_buffer.copy_device_to_ptr(db2.ptr, db.ptr, db2.size) >>> hb = db.copy_to_host() >>> hb array([97, 98, 99, 0, 0], dtype=uint8) diff --git a/python/rmm/rmm/_lib/lib.pyx b/python/rmm/rmm/pylibrmm/helper.pxd similarity index 86% rename from python/rmm/rmm/_lib/lib.pyx rename to python/rmm/rmm/pylibrmm/helper.pxd index 46753baa3..8ca151c00 100644 --- a/python/rmm/rmm/_lib/lib.pyx +++ b/python/rmm/rmm/pylibrmm/helper.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2020, 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. @@ -11,3 +11,6 @@ # 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. + + +cdef object parse_bytes(object s) except * diff --git a/python/rmm/rmm/_lib/helper.pyx b/python/rmm/rmm/pylibrmm/helper.pyx similarity index 100% rename from python/rmm/rmm/_lib/helper.pyx rename to python/rmm/rmm/pylibrmm/helper.pyx diff --git a/python/rmm/rmm/_lib/logger.pyx b/python/rmm/rmm/pylibrmm/logger.pyx similarity index 77% rename from python/rmm/rmm/_lib/logger.pyx rename to python/rmm/rmm/pylibrmm/logger.pyx index 029bbdd79..119e1c92f 100644 --- a/python/rmm/rmm/_lib/logger.pyx +++ b/python/rmm/rmm/pylibrmm/logger.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. +# 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. @@ -14,58 +14,9 @@ import warnings -from libcpp cimport bool - - -cdef extern from "spdlog/common.h" namespace "spdlog::level" nogil: - cpdef enum logging_level "spdlog::level::level_enum": - """ - The debug logging level for RMM. - - Debug logging prints messages to a log file. See - `Debug Logging `_ - for more information. - - Valid levels, in decreasing order of verbosity, are TRACE, DEBUG, - INFO, WARN, ERR, CRITICAL, and OFF. Default is INFO. - - Examples - -------- - >>> import rmm - >>> rmm.logging_level.DEBUG - - >>> rmm.logging_level.DEBUG.value - 1 - >>> rmm.logging_level.DEBUG.name - 'DEBUG' - - See Also - -------- - set_logging_level : Set the debug logging level - get_logging_level : Get the current debug logging level - """ - TRACE "spdlog::level::trace" - DEBUG "spdlog::level::debug" - INFO "spdlog::level::info" - WARN "spdlog::level::warn" - ERR "spdlog::level::err" - CRITICAL "spdlog::level::critical" - OFF "spdlog::level::off" - - -cdef extern from "spdlog/spdlog.h" namespace "spdlog" nogil: - cdef cppclass spdlog_logger "spdlog::logger": - spdlog_logger() except + - void set_level(logging_level level) - logging_level level() - void flush() except + - void flush_on(logging_level level) - logging_level flush_level() - bool should_log(logging_level msg_level) - - -cdef extern from "rmm/logger.hpp" namespace "rmm" nogil: - cdef spdlog_logger& logger() except + +from rmm.librmm._logger cimport logger + +from rmm.librmm._logger import logging_level def _validate_level_type(level): diff --git a/python/rmm/rmm/pylibrmm/memory_resource.pxd b/python/rmm/rmm/pylibrmm/memory_resource.pxd new file mode 100644 index 000000000..985d5d31b --- /dev/null +++ b/python/rmm/rmm/pylibrmm/memory_resource.pxd @@ -0,0 +1,83 @@ +# Copyright (c) 2020-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. + +from libcpp.memory cimport shared_ptr + +from rmm.librmm.memory_resource cimport device_memory_resource + + +cdef class DeviceMemoryResource: + cdef shared_ptr[device_memory_resource] c_obj + cdef device_memory_resource* get_mr(self) noexcept nogil + +cdef class UpstreamResourceAdaptor(DeviceMemoryResource): + cdef readonly DeviceMemoryResource upstream_mr + + cpdef DeviceMemoryResource get_upstream(self) + +cdef class CudaMemoryResource(DeviceMemoryResource): + pass + +cdef class ManagedMemoryResource(DeviceMemoryResource): + pass + +cdef class SystemMemoryResource(DeviceMemoryResource): + pass + +cdef class SamHeadroomMemoryResource(DeviceMemoryResource): + pass + +cdef class CudaAsyncMemoryResource(DeviceMemoryResource): + pass + +cdef class PoolMemoryResource(UpstreamResourceAdaptor): + pass + +cdef class FixedSizeMemoryResource(UpstreamResourceAdaptor): + pass + +cdef class BinningMemoryResource(UpstreamResourceAdaptor): + + cdef readonly list _bin_mrs + + cpdef add_bin( + self, + size_t allocation_size, + DeviceMemoryResource bin_resource=*) + +cdef class CallbackMemoryResource(DeviceMemoryResource): + cdef object _allocate_func + cdef object _deallocate_func + +cdef class LimitingResourceAdaptor(UpstreamResourceAdaptor): + pass + +cdef class LoggingResourceAdaptor(UpstreamResourceAdaptor): + cdef object _log_file_name + cpdef get_file_name(self) + cpdef flush(self) + +cdef class StatisticsResourceAdaptor(UpstreamResourceAdaptor): + pass + +cdef class TrackingResourceAdaptor(UpstreamResourceAdaptor): + pass + +cdef class FailureCallbackResourceAdaptor(UpstreamResourceAdaptor): + cdef object _callback + +cdef class PrefetchResourceAdaptor(UpstreamResourceAdaptor): + pass + +cpdef DeviceMemoryResource get_current_device_resource() diff --git a/python/rmm/rmm/_lib/memory_resource.pyx b/python/rmm/rmm/pylibrmm/memory_resource.pyx similarity index 82% rename from python/rmm/rmm/_lib/memory_resource.pyx rename to python/rmm/rmm/pylibrmm/memory_resource.pyx index 231253e3f..021125567 100644 --- a/python/rmm/rmm/_lib/memory_resource.pyx +++ b/python/rmm/rmm/pylibrmm/memory_resource.pyx @@ -22,12 +22,11 @@ from collections import defaultdict cimport cython from cython.operator cimport dereference as deref from libc.stddef cimport size_t -from libc.stdint cimport int8_t, int64_t, uintptr_t +from libc.stdint cimport int8_t, uintptr_t from libcpp cimport bool from libcpp.memory cimport make_unique, unique_ptr from libcpp.optional cimport optional from libcpp.pair cimport pair -from libcpp.string cimport string from cuda.cudart import cudaError_t @@ -37,206 +36,43 @@ from rmm._cuda.stream cimport Stream from rmm._cuda.stream import DEFAULT_STREAM -from rmm._lib.cuda_stream_view cimport cuda_stream_view -from rmm._lib.helper cimport parse_bytes -from rmm._lib.memory_resource cimport ( - available_device_memory as c_available_device_memory, - percent_of_free_device_memory as c_percent_of_free_device_memory, -) -from rmm._lib.per_device_resource cimport ( +from rmm.librmm.cuda_stream_view cimport cuda_stream_view +from rmm.librmm.per_device_resource cimport ( cuda_device_id, set_per_device_resource as cpp_set_per_device_resource, ) +from rmm.pylibrmm.helper cimport parse_bytes from rmm.statistics import Statistics -# Transparent handle of a C++ exception -ctypedef pair[int, string] CppExcept - -cdef CppExcept translate_python_except_to_cpp(err: BaseException) noexcept: - """Translate a Python exception into a C++ exception handle - - The returned exception handle can then be thrown by `throw_cpp_except()`, - which MUST be done without holding the GIL. - - This is useful when C++ calls a Python function and needs to catch or - propagate exceptions. - """ - if isinstance(err, MemoryError): - return CppExcept(0, str.encode(str(err))) - return CppExcept(-1, str.encode(str(err))) - -# Implementation of `throw_cpp_except()`, which throws a given `CppExcept`. -# This function MUST be called without the GIL otherwise the thrown C++ -# exception are translated back into a Python exception. -cdef extern from *: - """ - #include - #include - - void throw_cpp_except(std::pair res) { - switch(res.first) { - case 0: - throw rmm::out_of_memory(res.second); - default: - throw std::runtime_error(res.second); - } - } - """ - void throw_cpp_except(CppExcept) nogil - - -# NOTE: Keep extern declarations in .pyx file as much as possible to avoid -# leaking dependencies when importing RMM Cython .pxd files -cdef extern from "rmm/mr/device/cuda_memory_resource.hpp" \ - namespace "rmm::mr" nogil: - cdef cppclass cuda_memory_resource(device_memory_resource): - cuda_memory_resource() except + - -cdef extern from "rmm/mr/device/managed_memory_resource.hpp" \ - namespace "rmm::mr" nogil: - cdef cppclass managed_memory_resource(device_memory_resource): - managed_memory_resource() except + - -cdef extern from "rmm/mr/device/system_memory_resource.hpp" \ - namespace "rmm::mr" nogil: - cdef cppclass system_memory_resource(device_memory_resource): - system_memory_resource() except + - -cdef extern from "rmm/mr/device/sam_headroom_memory_resource.hpp" \ - namespace "rmm::mr" nogil: - cdef cppclass sam_headroom_memory_resource(device_memory_resource): - sam_headroom_memory_resource(size_t headroom) except + - -cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ - namespace "rmm::mr" nogil: - - cdef cppclass cuda_async_memory_resource(device_memory_resource): - cuda_async_memory_resource( - optional[size_t] initial_pool_size, - optional[size_t] release_threshold, - optional[allocation_handle_type] export_handle_type) except + - -# TODO: when we adopt Cython 3.0 use enum class -cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ - namespace \ - "rmm::mr::cuda_async_memory_resource::allocation_handle_type" \ - nogil: - enum allocation_handle_type \ - "rmm::mr::cuda_async_memory_resource::allocation_handle_type": - none - posix_file_descriptor - win32 - win32_kmt - - -cdef extern from "rmm/mr/device/pool_memory_resource.hpp" \ - namespace "rmm::mr" nogil: - cdef cppclass pool_memory_resource[Upstream](device_memory_resource): - pool_memory_resource( - Upstream* upstream_mr, - size_t initial_pool_size, - optional[size_t] maximum_pool_size) except + - size_t pool_size() - -cdef extern from "rmm/mr/device/fixed_size_memory_resource.hpp" \ - namespace "rmm::mr" nogil: - cdef cppclass fixed_size_memory_resource[Upstream](device_memory_resource): - fixed_size_memory_resource( - Upstream* upstream_mr, - size_t block_size, - size_t block_to_preallocate) except + - -cdef extern from "rmm/mr/device/callback_memory_resource.hpp" \ - namespace "rmm::mr" nogil: - ctypedef void* (*allocate_callback_t)(size_t, cuda_stream_view, void*) - ctypedef void (*deallocate_callback_t)(void*, size_t, cuda_stream_view, void*) - - cdef cppclass callback_memory_resource(device_memory_resource): - callback_memory_resource( - allocate_callback_t allocate_callback, - deallocate_callback_t deallocate_callback, - void* allocate_callback_arg, - void* deallocate_callback_arg - ) except + - -cdef extern from "rmm/mr/device/binning_memory_resource.hpp" \ - namespace "rmm::mr" nogil: - cdef cppclass binning_memory_resource[Upstream](device_memory_resource): - binning_memory_resource(Upstream* upstream_mr) except + - binning_memory_resource( - Upstream* upstream_mr, - int8_t min_size_exponent, - int8_t max_size_exponent) except + - - void add_bin(size_t allocation_size) except + - void add_bin( - size_t allocation_size, - device_memory_resource* bin_resource) except + - -cdef extern from "rmm/mr/device/limiting_resource_adaptor.hpp" \ - namespace "rmm::mr" nogil: - cdef cppclass limiting_resource_adaptor[Upstream](device_memory_resource): - limiting_resource_adaptor( - Upstream* upstream_mr, - size_t allocation_limit) except + - - size_t get_allocated_bytes() except + - size_t get_allocation_limit() except + - -cdef extern from "rmm/mr/device/logging_resource_adaptor.hpp" \ - namespace "rmm::mr" nogil: - cdef cppclass logging_resource_adaptor[Upstream](device_memory_resource): - logging_resource_adaptor( - Upstream* upstream_mr, - string filename) except + - - void flush() except + - -cdef extern from "rmm/mr/device/statistics_resource_adaptor.hpp" \ - namespace "rmm::mr" nogil: - cdef cppclass statistics_resource_adaptor[Upstream](device_memory_resource): - struct counter: - counter() - - int64_t value - int64_t peak - int64_t total - - statistics_resource_adaptor(Upstream* upstream_mr) except + - - counter get_bytes_counter() except + - counter get_allocations_counter() except + - pair[counter, counter] pop_counters() except + - pair[counter, counter] push_counters() except + - -cdef extern from "rmm/mr/device/tracking_resource_adaptor.hpp" \ - namespace "rmm::mr" nogil: - cdef cppclass tracking_resource_adaptor[Upstream](device_memory_resource): - tracking_resource_adaptor( - Upstream* upstream_mr, - bool capture_stacks) except + - - size_t get_allocated_bytes() except + - string get_outstanding_allocations_str() except + - void log_outstanding_allocations() except + - -cdef extern from "rmm/mr/device/failure_callback_resource_adaptor.hpp" \ - namespace "rmm::mr" nogil: - ctypedef bool (*failure_callback_t)(size_t, void*) - cdef cppclass failure_callback_resource_adaptor[Upstream]( - device_memory_resource - ): - failure_callback_resource_adaptor( - Upstream* upstream_mr, - failure_callback_t callback, - void* callback_arg - ) except + - -cdef extern from "rmm/mr/device/prefetch_resource_adaptor.hpp" \ - namespace "rmm::mr" nogil: - cdef cppclass prefetch_resource_adaptor[Upstream](device_memory_resource): - prefetch_resource_adaptor(Upstream* upstream_mr) except + +from rmm.librmm.memory_resource cimport ( + CppExcept, + allocate_callback_t, + allocation_handle_type, + available_device_memory as c_available_device_memory, + binning_memory_resource, + callback_memory_resource, + cuda_async_memory_resource, + cuda_memory_resource, + deallocate_callback_t, + device_memory_resource, + failure_callback_resource_adaptor, + failure_callback_t, + fixed_size_memory_resource, + limiting_resource_adaptor, + logging_resource_adaptor, + managed_memory_resource, + percent_of_free_device_memory as c_percent_of_free_device_memory, + pool_memory_resource, + posix_file_descriptor, + prefetch_resource_adaptor, + sam_headroom_memory_resource, + statistics_resource_adaptor, + system_memory_resource, + throw_cpp_except, + tracking_resource_adaptor, + translate_python_except_to_cpp, +) cdef class DeviceMemoryResource: diff --git a/python/rmm/rmm/_lib/tests/__init__.py b/python/rmm/rmm/pylibrmm/tests/__init__.py similarity index 100% rename from python/rmm/rmm/_lib/tests/__init__.py rename to python/rmm/rmm/pylibrmm/tests/__init__.py diff --git a/python/rmm/rmm/_lib/tests/test_device_buffer.pyx b/python/rmm/rmm/pylibrmm/tests/test_device_buffer.pyx similarity index 83% rename from python/rmm/rmm/_lib/tests/test_device_buffer.pyx rename to python/rmm/rmm/pylibrmm/tests/test_device_buffer.pyx index 733383827..ec2ff4def 100644 --- a/python/rmm/rmm/_lib/tests/test_device_buffer.pyx +++ b/python/rmm/rmm/pylibrmm/tests/test_device_buffer.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-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. @@ -16,8 +16,9 @@ import numpy as np from libcpp.memory cimport make_unique -from rmm._lib.cuda_stream_view cimport cuda_stream_default -from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer +from rmm.librmm.cuda_stream_view cimport cuda_stream_default +from rmm.librmm.device_buffer cimport device_buffer +from rmm.pylibrmm.device_buffer cimport DeviceBuffer def test_release(): diff --git a/python/rmm/rmm/tests/test_cython.py b/python/rmm/rmm/tests/test_cython.py index 82eba2451..5df933435 100644 --- a/python/rmm/rmm/tests/test_cython.py +++ b/python/rmm/rmm/tests/test_cython.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-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. @@ -29,7 +29,7 @@ def wrapped(*args, **kwargs): return wrapped -cython_test_modules = ["rmm._lib.tests.test_device_buffer"] +cython_test_modules = ["rmm.pylibrmm.tests.test_device_buffer"] for mod in cython_test_modules: diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index c88d21b38..c03b9e501 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -354,7 +354,7 @@ def test_rmm_pool_numba_stream(stream): rmm.reinitialize(pool_allocator=True) stream = rmm._cuda.stream.Stream(stream) - a = rmm._lib.device_buffer.DeviceBuffer(size=3, stream=stream) + a = rmm.pylibrmm.device_buffer.DeviceBuffer(size=3, stream=stream) assert a.size == 3 assert a.ptr != 0 From 815003232d90a45fe6867214e73284649c639066 Mon Sep 17 00:00:00 2001 From: Matthew Murray <41342305+Matt711@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:10:01 -0400 Subject: [PATCH 476/675] Fix `rmm ._lib` imports (#1693) This PR fixes a bug in #1676. It makes sure that rmm imports work correctly using both `from rmm._lib...` and `import rmm._lib...` syntax. I'm adding DO NOT MERGE until I do some more testing. Authors: - Matthew Murray (https://github.com/Matt711) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1693 --- python/rmm/rmm/_lib/cuda_stream.py | 15 +++++++++ python/rmm/rmm/_lib/device_buffer.py | 21 ++++++++++++ python/rmm/rmm/_lib/logger.py | 24 ++++++++++++++ python/rmm/rmm/_lib/memory_resource.py | 44 ++++++++++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 python/rmm/rmm/_lib/cuda_stream.py create mode 100644 python/rmm/rmm/_lib/device_buffer.py create mode 100644 python/rmm/rmm/_lib/logger.py create mode 100644 python/rmm/rmm/_lib/memory_resource.py diff --git a/python/rmm/rmm/_lib/cuda_stream.py b/python/rmm/rmm/_lib/cuda_stream.py new file mode 100644 index 000000000..1eb424e12 --- /dev/null +++ b/python/rmm/rmm/_lib/cuda_stream.py @@ -0,0 +1,15 @@ +# Copyright (c) 2018-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. + +from rmm.pylibrmm.cuda_stream import CudaStream # noqa: F401 diff --git a/python/rmm/rmm/_lib/device_buffer.py b/python/rmm/rmm/_lib/device_buffer.py new file mode 100644 index 000000000..c531bca5f --- /dev/null +++ b/python/rmm/rmm/_lib/device_buffer.py @@ -0,0 +1,21 @@ +# Copyright (c) 2018-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. + +from rmm.pylibrmm.device_buffer import ( # noqa: F401 + DeviceBuffer, + copy_device_to_ptr, + copy_host_to_ptr, + copy_ptr_to_host, + to_device, +) diff --git a/python/rmm/rmm/_lib/logger.py b/python/rmm/rmm/_lib/logger.py new file mode 100644 index 000000000..1e9b519b8 --- /dev/null +++ b/python/rmm/rmm/_lib/logger.py @@ -0,0 +1,24 @@ +# Copyright (c) 2018-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. + +from rmm.librmm._logger import logging_level # noqa: F401 +from rmm.pylibrmm.logger import ( # noqa: F401 + _validate_level_type, + flush_logger, + get_flush_level, + get_logging_level, + set_flush_level, + set_logging_level, + should_log, +) diff --git a/python/rmm/rmm/_lib/memory_resource.py b/python/rmm/rmm/_lib/memory_resource.py new file mode 100644 index 000000000..0d47e8c9b --- /dev/null +++ b/python/rmm/rmm/_lib/memory_resource.py @@ -0,0 +1,44 @@ +# Copyright (c) 2018-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. + +from rmm.pylibrmm.memory_resource import ( # noqa: F401 + BinningMemoryResource, + CallbackMemoryResource, + CudaAsyncMemoryResource, + CudaMemoryResource, + DeviceMemoryResource, + FailureCallbackResourceAdaptor, + FixedSizeMemoryResource, + LimitingResourceAdaptor, + LoggingResourceAdaptor, + ManagedMemoryResource, + PoolMemoryResource, + PrefetchResourceAdaptor, + SamHeadroomMemoryResource, + StatisticsResourceAdaptor, + SystemMemoryResource, + TrackingResourceAdaptor, + UpstreamResourceAdaptor, + _flush_logs, + available_device_memory, + disable_logging, + enable_logging, + get_current_device_resource, + get_current_device_resource_type, + get_log_filenames, + get_per_device_resource_type, + is_initialized, + set_current_device_resource, + set_per_device_resource, +) From c494395e58288cac16321ce90e9b15f3508ae89a Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Fri, 4 Oct 2024 16:18:35 -0400 Subject: [PATCH 477/675] Prune workflows based on changed files (#1695) Contributes to https://github.com/rapidsai/build-planning/issues/94 Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1695 --- .github/workflows/pr.yaml | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index afc9f7487..4dfcaf1ae 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -12,6 +12,7 @@ concurrency: jobs: pr-builder: needs: + - changed-files - checks - conda-cpp-build - conda-cpp-tests @@ -24,6 +25,29 @@ jobs: - devcontainer secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.12 + if: always() + with: + needs: ${{ toJSON(needs) }} + changed-files: + secrets: inherit + uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-24.12 + with: + files_yaml: | + test_cpp: + - '**' + - '!.devcontainer/**' + - '!.pre-commit-config.yaml' + - '!CONTRIBUTING.md' + - '!README.md' + - '!img/**' + - '!python/**' + test_python: + - '**' + - '!.devcontainer/**' + - '!.pre-commit-config.yaml' + - '!CONTRIBUTING.md' + - '!README.md' + - '!img/**' checks: secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.12 @@ -36,9 +60,10 @@ jobs: with: build_type: pull-request conda-cpp-tests: - needs: conda-cpp-build + needs: [conda-cpp-build, changed-files] secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.12 + if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp with: build_type: pull-request conda-python-build: @@ -48,9 +73,10 @@ jobs: with: build_type: pull-request conda-python-tests: - needs: conda-python-build + needs: [conda-python-build, changed-files] secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.12 + if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request docs-build: @@ -79,9 +105,10 @@ jobs: build_type: pull-request script: ci/build_wheel_python.sh wheel-tests: - needs: wheel-build-python + needs: [wheel-build-python, changed-files] secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.12 + if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request script: ci/test_wheel.sh From afe0a3336397b17a96bb703e82f3b6365ee7c41e Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Wed, 9 Oct 2024 09:39:40 -0400 Subject: [PATCH 478/675] Update Changelog [skip ci] --- CHANGELOG.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 986cf7052..1268762b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,50 @@ +# rmm 24.10.00 (9 Oct 2024) + +## 🚨 Breaking Changes + +- Inline functions that return static references must have default visibility ([#1653](https://github.com/rapidsai/rmm/pull/1653)) [@wence-](https://github.com/wence-) +- Hide visibility of non-public symbols ([#1644](https://github.com/rapidsai/rmm/pull/1644)) [@jameslamb](https://github.com/jameslamb) +- Deprecate adaptor factories. ([#1626](https://github.com/rapidsai/rmm/pull/1626)) [@bdice](https://github.com/bdice) + +## 🐛 Bug Fixes + +- Add missing include to `resource_ref.hpp` ([#1677](https://github.com/rapidsai/rmm/pull/1677)) [@miscco](https://github.com/miscco) +- Remove the friend declaration with an attribute ([#1669](https://github.com/rapidsai/rmm/pull/1669)) [@kingcrimsontianyu](https://github.com/kingcrimsontianyu) +- Fix `build.sh clean` to delete python build directory ([#1658](https://github.com/rapidsai/rmm/pull/1658)) [@rongou](https://github.com/rongou) +- Stream synchronize before deallocating SAM ([#1655](https://github.com/rapidsai/rmm/pull/1655)) [@rongou](https://github.com/rongou) +- Explicitly mark RMM headers with `RMM_EXPORT` ([#1654](https://github.com/rapidsai/rmm/pull/1654)) [@robertmaynard](https://github.com/robertmaynard) +- Inline functions that return static references must have default visibility ([#1653](https://github.com/rapidsai/rmm/pull/1653)) [@wence-](https://github.com/wence-) +- Use `tool.scikit-build.cmake.version` ([#1637](https://github.com/rapidsai/rmm/pull/1637)) [@KyleFromNVIDIA](https://github.com/KyleFromNVIDIA) + +## 📖 Documentation + +- Recommend `miniforge` for conda install. ([#1681](https://github.com/rapidsai/rmm/pull/1681)) [@bdice](https://github.com/bdice) +- Fix docs cross reference in DeviceBuffer.prefetch ([#1636](https://github.com/rapidsai/rmm/pull/1636)) [@bdice](https://github.com/bdice) + +## 🚀 New Features + +- [FEA] Allow setting `*_pool_size` with human-readable string ([#1670](https://github.com/rapidsai/rmm/pull/1670)) [@Matt711](https://github.com/Matt711) +- Update RMM adaptors, containers and tests to use get/set_current_device_resource_ref() ([#1661](https://github.com/rapidsai/rmm/pull/1661)) [@harrism](https://github.com/harrism) +- Deprecate adaptor factories. ([#1626](https://github.com/rapidsai/rmm/pull/1626)) [@bdice](https://github.com/bdice) +- Allow testing of earliest/latest dependencies ([#1613](https://github.com/rapidsai/rmm/pull/1613)) [@seberg](https://github.com/seberg) +- Add resource_ref versions of get/set_current_device_resource ([#1598](https://github.com/rapidsai/rmm/pull/1598)) [@harrism](https://github.com/harrism) + +## 🛠️ Improvements + +- Update update-version.sh to use packaging lib ([#1685](https://github.com/rapidsai/rmm/pull/1685)) [@AyodeAwe](https://github.com/AyodeAwe) +- Use CI workflow branch 'branch-24.10' again ([#1683](https://github.com/rapidsai/rmm/pull/1683)) [@jameslamb](https://github.com/jameslamb) +- Update fmt (to 11.0.2) and spdlog (to 1.14.1). ([#1678](https://github.com/rapidsai/rmm/pull/1678)) [@jameslamb](https://github.com/jameslamb) +- Attempt to address oom failures in test suite ([#1672](https://github.com/rapidsai/rmm/pull/1672)) [@wence-](https://github.com/wence-) +- Add support for Python 3.12 ([#1666](https://github.com/rapidsai/rmm/pull/1666)) [@jameslamb](https://github.com/jameslamb) +- Update rapidsai/pre-commit-hooks ([#1663](https://github.com/rapidsai/rmm/pull/1663)) [@KyleFromNVIDIA](https://github.com/KyleFromNVIDIA) +- Drop Python 3.9 support ([#1659](https://github.com/rapidsai/rmm/pull/1659)) [@jameslamb](https://github.com/jameslamb) +- Remove NumPy <2 pin ([#1650](https://github.com/rapidsai/rmm/pull/1650)) [@seberg](https://github.com/seberg) +- Hide visibility of non-public symbols ([#1644](https://github.com/rapidsai/rmm/pull/1644)) [@jameslamb](https://github.com/jameslamb) +- Update pre-commit hooks ([#1643](https://github.com/rapidsai/rmm/pull/1643)) [@KyleFromNVIDIA](https://github.com/KyleFromNVIDIA) +- Improve update-version.sh ([#1640](https://github.com/rapidsai/rmm/pull/1640)) [@bdice](https://github.com/bdice) +- Install headers into `${CMAKE_INSTALL_INCLUDEDIR}` ([#1633](https://github.com/rapidsai/rmm/pull/1633)) [@KyleFromNVIDIA](https://github.com/KyleFromNVIDIA) +- Merge branch-24.08 into branch-24.10 ([#1631](https://github.com/rapidsai/rmm/pull/1631)) [@jameslamb](https://github.com/jameslamb) + # rmm 24.08.00 (7 Aug 2024) ## 🚨 Breaking Changes From 4e519bbf94dd1641dfb69fc171f714c38a7d0894 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Wed, 9 Oct 2024 18:09:39 +0100 Subject: [PATCH 479/675] Update cross-link to cuda-python object (#1699) nvidia/cuda-python#137 reorganised the low-level binding structure which broke our cross-linking, update to the new name to fix. - Closes #1698 Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Matthew Murray (https://github.com/Matt711) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1699 --- python/rmm/rmm/pylibrmm/device_buffer.pyx | 2 +- python/rmm/rmm/statistics.py | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/python/rmm/rmm/pylibrmm/device_buffer.pyx b/python/rmm/rmm/pylibrmm/device_buffer.pyx index 76fbceef8..c2e95e845 100644 --- a/python/rmm/rmm/pylibrmm/device_buffer.pyx +++ b/python/rmm/rmm/pylibrmm/device_buffer.pyx @@ -156,7 +156,7 @@ cdef class DeviceBuffer: device : optional The CUDA device to which to prefetch the memory for this buffer. Defaults to the current CUDA device. To prefetch to the CPU, pass - :py:attr:`~cuda.cudart.cudaCpuDeviceId` as the device. + :py:attr:`~cuda.bindings.runtime.cudaCpuDeviceId` as the device. stream : optional CUDA stream to use for prefetching. Defaults to self.stream """ diff --git a/python/rmm/rmm/statistics.py b/python/rmm/rmm/statistics.py index 279e45dc6..2dabedce6 100644 --- a/python/rmm/rmm/statistics.py +++ b/python/rmm/rmm/statistics.py @@ -74,8 +74,8 @@ def enable_statistics() -> None: def get_statistics() -> Optional[Statistics]: """Get the current allocation statistics. - Return - ------ + Returns + ------- If enabled, returns the current tracked statistics. If disabled, returns None. """ @@ -94,8 +94,8 @@ def push_statistics() -> Optional[Statistics]: If statistics are disabled (the current memory resource is not an instance of StatisticsResourceAdaptor), this function is a no-op. - Return - ------ + Returns + ------- If enabled, returns the current tracked statistics _before_ the pop. If disabled, returns None. """ @@ -114,8 +114,8 @@ def pop_statistics() -> Optional[Statistics]: If statistics are disabled (the current memory resource is not an instance of StatisticsResourceAdaptor), this function is a no-op. - Return - ------ + Returns + ------- If enabled, returns the popped counters. If disabled, returns None. """ @@ -232,8 +232,8 @@ def report( ordered_by Sort the statistics by this attribute. - Return - ------ + Returns + ------- The pretty formatted string of the memory statistics """ @@ -279,8 +279,8 @@ def _get_descriptive_name_of_object(obj: object) -> str: obj Object in question - Return - ------ + Returns + ------- A string including filename, line number, and object name. """ From 69a297d82641fcb61eac92ac6de42658cfa651f6 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Wed, 9 Oct 2024 19:00:50 +0100 Subject: [PATCH 480/675] Add BUILD_SHARED_LIBS option defaulting to ON (#1702) This means that downstream libraries that get their `fmt` dependency from RMM will use `-DFMT_SHARED` in the compile command: this matches what the rapids combined devcontainers do, so we get sccache hits. - Closes #1701 Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Kyle Edwards (https://github.com/KyleFromNVIDIA) URL: https://github.com/rapidsai/rmm/pull/1702 --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 39d5dccde..26fcf1fd0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,9 @@ rapids_cmake_build_type(Release) option(RMM_NVTX "Build RMM with NVTX support" OFF) option(BUILD_TESTS "Configure CMake to build tests" ON) option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" OFF) +# This is mostly so that dependent libraries, such as fmt, are configured in shared mode for +# downstream dependents of RMM that get their common dependencies transitively. +option(BUILD_SHARED_LIBS "Build RMM shared libraries" ON) set(RMM_LOGGING_LEVEL "INFO" CACHE STRING "Choose the logging level.") From f7155183645f640fa5695a0558d9708703f5b2a6 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 9 Oct 2024 13:28:23 -0500 Subject: [PATCH 481/675] make conda installs in CI stricter (#1696) Contributes to https://github.com/rapidsai/build-planning/issues/106 Proposes specifying the RAPIDS version in `conda install` calls in CI that install CI artifacts, to reduce the risk of CI jobs picking up artifacts from other releases. Authors: - James Lamb (https://github.com/jameslamb) - Lawrence Mitchell (https://github.com/wence-) Approvers: - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1696 --- ci/build_docs.sh | 9 +++++---- ci/test_cpp.sh | 5 ++++- ci/test_python.sh | 5 ++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 970417c1d..fadaf0f27 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -6,6 +6,9 @@ set -euo pipefail rapids-logger "Create test conda environment" . /opt/conda/etc/profile.d/conda.sh +RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)" +export RAPIDS_VERSION_NUMBER="$RAPIDS_VERSION_MAJOR_MINOR" + rapids-dependency-file-generator \ --output conda \ --file-key docs \ @@ -23,11 +26,9 @@ PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) rapids-mamba-retry install \ --channel "${CPP_CHANNEL}" \ --channel "${PYTHON_CHANNEL}" \ - rmm librmm + "rmm=${RAPIDS_VERSION_MAJOR_MINOR}" \ + "librmm=${RAPIDS_VERSION_MAJOR_MINOR}" -export RAPIDS_VERSION="$(rapids-version)" -export RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)" -export RAPIDS_VERSION_NUMBER="$RAPIDS_VERSION_MAJOR_MINOR" export RAPIDS_DOCS_DIR="$(mktemp -d)" rapids-logger "Build CPP docs" diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 9ad1c9536..02435f249 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -8,6 +8,8 @@ cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../ . /opt/conda/etc/profile.d/conda.sh +RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)" + rapids-logger "Generate C++ testing dependencies" rapids-dependency-file-generator \ --output conda \ @@ -29,7 +31,8 @@ rapids-print-env rapids-mamba-retry install \ --channel "${CPP_CHANNEL}" \ - librmm librmm-tests + "librmm=${RAPIDS_VERSION_MAJOR_MINOR}" \ + "librmm-tests=${RAPIDS_VERSION_MAJOR_MINOR}" rapids-logger "Check GPU usage" nvidia-smi diff --git a/ci/test_python.sh b/ci/test_python.sh index 386d0b063..7a688107e 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -9,6 +9,8 @@ cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../ rapids-logger "Create test conda environment" . /opt/conda/etc/profile.d/conda.sh +RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)" + rapids-dependency-file-generator \ --output conda \ --file-key test_python \ @@ -28,7 +30,8 @@ PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) rapids-mamba-retry install \ --channel "${CPP_CHANNEL}" \ --channel "${PYTHON_CHANNEL}" \ - rmm librmm + "rmm=${RAPIDS_VERSION_MAJOR_MINOR}" \ + "librmm=${RAPIDS_VERSION_MAJOR_MINOR}" RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"} RAPIDS_COVERAGE_DIR=${RAPIDS_COVERAGE_DIR:-"${PWD}/coverage-results"} From 90a5631e1093ce44c4feceb88fcf557c3dfc043b Mon Sep 17 00:00:00 2001 From: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com> Date: Wed, 9 Oct 2024 15:03:33 -0400 Subject: [PATCH 482/675] Fix typos in .gitignore (#1697) Small fix to some typos that cropped up in the .gitignore with #1676 Authors: - Charles Blackmon-Luca (https://github.com/charlesbluca) - Lawrence Mitchell (https://github.com/wence-) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1697 --- .gitignore | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 36aafe643..df9d920d5 100644 --- a/.gitignore +++ b/.gitignore @@ -22,13 +22,13 @@ rmm.egg-info/ python/build python/*/build python/rmm/docs/_build -python/rmm/**/librmmm/**/*.cpp -!python/rmm/librmmm/_torch_allocator.cpp +python/rmm/**/librmm/**/*.cpp +!python/rmm/librmm/_torch_allocator.cpp python/rmm/**/librmm/**/*.h python/rmm/**/librmm/.nfs* -python/rmm/**/pylibrmmm/**/*.cpp -python/rmm/**/pylibrmmm/**/*.h -python/rmm/**/pylibrmmm/.nfs* +python/rmm/**/pylibrmm/**/*.cpp +python/rmm/**/pylibrmm/**/*.h +python/rmm/**/pylibrmm/.nfs* python/rmm/_cuda/*.cpp python/rmm/tests/*.cpp python/rmm/*.ipynb From 1b70ffdd5ab460ac481f1575c42e8c1fccfda792 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 11 Oct 2024 15:09:11 -0500 Subject: [PATCH 483/675] make conda installs in CI stricter (part 2) (#1703) Follow-up to #1696 Changes relative to that PR: * switches to pinning CI conda installs to the output of `rapids-version` (`{major}.{minor}.{patch}`) instead of `rapids-version-major-minor` (`{major}.{minor}`), to get a bit more protection in the presence of hotfix releases * restores some exporting of variables needed for docs builds In #1696, I'd missed that this project's Doxygen setup is expecting to find `RAPIDS_VERSION_MAJOR_MINOR` defined in the environment. https://github.com/rapidsai/rmm/blob/90a5631e1093ce44c4feceb88fcf557c3dfc043b/ci/build_docs.sh#L36 https://github.com/rapidsai/rmm/blob/90a5631e1093ce44c4feceb88fcf557c3dfc043b/doxygen/Doxyfile#L41 Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Mike Sarahan (https://github.com/msarahan) URL: https://github.com/rapidsai/rmm/pull/1703 --- ci/build_docs.sh | 10 +++++----- ci/test_cpp.sh | 6 +++--- ci/test_python.sh | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ci/build_docs.sh b/ci/build_docs.sh index fadaf0f27..844dae1c6 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -6,8 +6,8 @@ set -euo pipefail rapids-logger "Create test conda environment" . /opt/conda/etc/profile.d/conda.sh -RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)" -export RAPIDS_VERSION_NUMBER="$RAPIDS_VERSION_MAJOR_MINOR" +RAPIDS_VERSION="$(rapids-version)" +export RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)" rapids-dependency-file-generator \ --output conda \ @@ -26,8 +26,8 @@ PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) rapids-mamba-retry install \ --channel "${CPP_CHANNEL}" \ --channel "${PYTHON_CHANNEL}" \ - "rmm=${RAPIDS_VERSION_MAJOR_MINOR}" \ - "librmm=${RAPIDS_VERSION_MAJOR_MINOR}" + "rmm=${RAPIDS_VERSION}" \ + "librmm=${RAPIDS_VERSION}" export RAPIDS_DOCS_DIR="$(mktemp -d)" @@ -45,4 +45,4 @@ mkdir -p "${RAPIDS_DOCS_DIR}/rmm/html" mv _build/dirhtml/* "${RAPIDS_DOCS_DIR}/rmm/html" popd -rapids-upload-docs +RAPIDS_VERSION_NUMBER="${RAPIDS_VERSION_MAJOR_MINOR}" rapids-upload-docs diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 02435f249..975477a6e 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -8,7 +8,7 @@ cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../ . /opt/conda/etc/profile.d/conda.sh -RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)" +RAPIDS_VERSION="$(rapids-version)" rapids-logger "Generate C++ testing dependencies" rapids-dependency-file-generator \ @@ -31,8 +31,8 @@ rapids-print-env rapids-mamba-retry install \ --channel "${CPP_CHANNEL}" \ - "librmm=${RAPIDS_VERSION_MAJOR_MINOR}" \ - "librmm-tests=${RAPIDS_VERSION_MAJOR_MINOR}" + "librmm=${RAPIDS_VERSION}" \ + "librmm-tests=${RAPIDS_VERSION}" rapids-logger "Check GPU usage" nvidia-smi diff --git a/ci/test_python.sh b/ci/test_python.sh index 7a688107e..51d0a48c3 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -9,7 +9,7 @@ cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../ rapids-logger "Create test conda environment" . /opt/conda/etc/profile.d/conda.sh -RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)" +RAPIDS_VERSION="$(rapids-version)" rapids-dependency-file-generator \ --output conda \ @@ -30,8 +30,8 @@ PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) rapids-mamba-retry install \ --channel "${CPP_CHANNEL}" \ --channel "${PYTHON_CHANNEL}" \ - "rmm=${RAPIDS_VERSION_MAJOR_MINOR}" \ - "librmm=${RAPIDS_VERSION_MAJOR_MINOR}" + "rmm=${RAPIDS_VERSION}" \ + "librmm=${RAPIDS_VERSION}" RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"} RAPIDS_COVERAGE_DIR=${RAPIDS_COVERAGE_DIR:-"${PWD}/coverage-results"} From de42f5711386f6b914cef0fc54d3081a936c5740 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 16 Oct 2024 01:22:40 -0700 Subject: [PATCH 484/675] Deprecate support for directly accessing logger (#1690) Contributes to https://github.com/rapidsai/build-planning/issues/104 This PR removes support for accessing rmm's underlying spdlog logger directly. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) - Lawrence Mitchell (https://github.com/wence-) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1690 --- include/rmm/logger.hpp | 25 ++++++++++++++++--------- python/rmm/rmm/librmm/_logger.pxd | 2 +- tests/mr/device/tracking_mr_tests.cpp | 10 +++++----- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/include/rmm/logger.hpp b/include/rmm/logger.hpp index 326385f16..eba3f122b 100644 --- a/include/rmm/logger.hpp +++ b/include/rmm/logger.hpp @@ -96,6 +96,11 @@ struct bytes { } }; +inline spdlog::logger& logger() +{ + static detail::logger_wrapper wrapped{}; + return wrapped.logger_; +} } // namespace detail /** @@ -107,10 +112,12 @@ struct bytes { * * @return spdlog::logger& The logger. */ -RMM_EXPORT inline spdlog::logger& logger() +[[deprecated( + "Support for direct access to spdlog loggers in rmm is planned for " + "removal")]] RMM_EXPORT inline spdlog::logger& +logger() { - static detail::logger_wrapper wrapped{}; - return wrapped.logger_; + return detail::logger(); } //! @cond Doxygen_Suppress @@ -118,12 +125,12 @@ RMM_EXPORT inline spdlog::logger& logger() // The default is INFO, but it should be used sparingly, so that by default a log file is only // output if there is important information, warnings, errors, and critical failures // Log messages that require computation should only be used at level TRACE and DEBUG -#define RMM_LOG_TRACE(...) SPDLOG_LOGGER_TRACE(&rmm::logger(), __VA_ARGS__) -#define RMM_LOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(&rmm::logger(), __VA_ARGS__) -#define RMM_LOG_INFO(...) SPDLOG_LOGGER_INFO(&rmm::logger(), __VA_ARGS__) -#define RMM_LOG_WARN(...) SPDLOG_LOGGER_WARN(&rmm::logger(), __VA_ARGS__) -#define RMM_LOG_ERROR(...) SPDLOG_LOGGER_ERROR(&rmm::logger(), __VA_ARGS__) -#define RMM_LOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(&rmm::logger(), __VA_ARGS__) +#define RMM_LOG_TRACE(...) SPDLOG_LOGGER_TRACE(&rmm::detail::logger(), __VA_ARGS__) +#define RMM_LOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(&rmm::detail::logger(), __VA_ARGS__) +#define RMM_LOG_INFO(...) SPDLOG_LOGGER_INFO(&rmm::detail::logger(), __VA_ARGS__) +#define RMM_LOG_WARN(...) SPDLOG_LOGGER_WARN(&rmm::detail::logger(), __VA_ARGS__) +#define RMM_LOG_ERROR(...) SPDLOG_LOGGER_ERROR(&rmm::detail::logger(), __VA_ARGS__) +#define RMM_LOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(&rmm::detail::logger(), __VA_ARGS__) //! @endcond diff --git a/python/rmm/rmm/librmm/_logger.pxd b/python/rmm/rmm/librmm/_logger.pxd index 241a748c3..fb2126b2f 100644 --- a/python/rmm/rmm/librmm/_logger.pxd +++ b/python/rmm/rmm/librmm/_logger.pxd @@ -62,5 +62,5 @@ cdef extern from "spdlog/spdlog.h" namespace "spdlog" nogil: bool should_log(logging_level msg_level) -cdef extern from "rmm/logger.hpp" namespace "rmm" nogil: +cdef extern from "rmm/logger.hpp" namespace "rmm::detail" nogil: cdef spdlog_logger& logger() except + diff --git a/tests/mr/device/tracking_mr_tests.cpp b/tests/mr/device/tracking_mr_tests.cpp index acd540ae6..3fce55fb8 100644 --- a/tests/mr/device/tracking_mr_tests.cpp +++ b/tests/mr/device/tracking_mr_tests.cpp @@ -204,8 +204,8 @@ TEST(TrackingTest, LogOutstandingAllocations) { std::ostringstream oss; auto oss_sink = std::make_shared(oss); - rmm::logger().sinks().push_back(oss_sink); - auto old_level = rmm::logger().level(); + rmm::detail::logger().sinks().push_back(oss_sink); + auto old_level = rmm::detail::logger().level(); tracking_adaptor mr{rmm::mr::get_current_device_resource_ref()}; std::vector allocations; @@ -213,7 +213,7 @@ TEST(TrackingTest, LogOutstandingAllocations) allocations.push_back(mr.allocate(ten_MiB)); } - rmm::logger().set_level(spdlog::level::debug); + rmm::detail::logger().set_level(spdlog::level::debug); EXPECT_NO_THROW(mr.log_outstanding_allocations()); #if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_DEBUG @@ -224,8 +224,8 @@ TEST(TrackingTest, LogOutstandingAllocations) mr.deallocate(allocation, ten_MiB); } - rmm::logger().set_level(old_level); - rmm::logger().sinks().pop_back(); + rmm::detail::logger().set_level(old_level); + rmm::detail::logger().sinks().pop_back(); } } // namespace From 50e60a868af05cc9f65b9980753d708e7170f3a1 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 16 Oct 2024 16:16:32 -0500 Subject: [PATCH 485/675] Fix docs warning (#1706) Closes https://github.com/rapidsai/rmm/issues/1705. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) URL: https://github.com/rapidsai/rmm/pull/1706 --- python/rmm/docs/conf.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/python/rmm/docs/conf.py b/python/rmm/docs/conf.py index d48dc2b42..0b2c21d5a 100644 --- a/python/rmm/docs/conf.py +++ b/python/rmm/docs/conf.py @@ -12,6 +12,7 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # +import datetime import os import re @@ -22,8 +23,8 @@ # -- Project information ----------------------------------------------------- project = "rmm" -copyright = "2020-2023, NVIDIA" -author = "NVIDIA" +copyright = f"2018-{datetime.datetime.today().year}, NVIDIA Corporation" +author = "NVIDIA Corporation" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -118,19 +119,6 @@ html_theme = "sphinx_rtd_theme" -# on_rtd is whether we are on readthedocs.org -on_rtd = os.environ.get("READTHEDOCS", None) == "True" - -if not on_rtd: - # only import and set the theme if we're building docs locally - # otherwise, readthedocs.org uses their theme by default, - # so no need to specify it - import sphinx_rtd_theme - - html_theme = "sphinx_rtd_theme" - html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] - - # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. From 1024a1250cfde7e93d26dc6d5e063e84c4a39824 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 22 Oct 2024 08:20:02 -0400 Subject: [PATCH 486/675] Update rmm tests to use rapids_cmake_support_conda_env (#1707) Fixes issue brought up in https://github.com/rapidsai/rapids-cmake/issues/634#issuecomment-2345129521 where rmm wasn't using rapids_cmake_support_conda_env Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1707 --- tests/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ea1af58cd..0258c59c5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -19,13 +19,16 @@ option(CODE_COVERAGE "Enable generating code coverage with gcov." OFF) include(rapids-test) rapids_test_init() +# Ensure tests are using the conda env, so they have the correct release/debug compile flags +rapids_cmake_support_conda_env(conda_env) + # This function takes in a test name and test source and handles setting all of the associated # properties and linking to build the test function(ConfigureTestInternal TEST_NAME) add_executable(${TEST_NAME} ${ARGN}) target_include_directories(${TEST_NAME} PRIVATE "$") target_link_libraries(${TEST_NAME} GTest::gmock GTest::gtest GTest::gmock_main GTest::gtest_main - pthread rmm) + pthread rmm $) set_target_properties( ${TEST_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON @@ -40,7 +43,6 @@ function(ConfigureTestInternal TEST_NAME) PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") target_compile_options(${TEST_NAME} PUBLIC $<$:-Wall -Werror -Wno-error=deprecated-declarations>) - target_compile_options(${TEST_NAME} PUBLIC "$<$:-O0>") if(DISABLE_DEPRECATION_WARNING) target_compile_options( From 1ebfe0a4ee5f83a2ad54afcf99716944d20598dd Mon Sep 17 00:00:00 2001 From: Jordan Jacobelli Date: Fri, 25 Oct 2024 19:18:44 +0200 Subject: [PATCH 487/675] devcontainer: replace `VAULT_HOST` with `AWS_ROLE_ARN` (#1708) This PR is replacing the `VAULT_HOST` variable with `AWS_ROLE_ARN`. This is required to use the new token service to get AWS credentials. Authors: - Jordan Jacobelli (https://github.com/jjacobelli) Approvers: - Paul Taylor (https://github.com/trxcllnt) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1708 --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9d35e3f97..5d1d53670 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -26,5 +26,5 @@ ENV PYTHONDONTWRITEBYTECODE="1" ENV SCCACHE_REGION="us-east-2" ENV SCCACHE_BUCKET="rapids-sccache-devs" -ENV VAULT_HOST="https://vault.ops.k8s.rapids.ai" +ENV AWS_ROLE_ARN="arn:aws:iam::279114543810:role/nv-gha-token-sccache-devs" ENV HISTFILE="/home/coder/.cache/._bash_history" From 47dae24b5578894ac0efc3c06930b7a5a069d988 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 29 Oct 2024 13:39:06 -0500 Subject: [PATCH 488/675] print sccache stats in builds (#1712) Contributes to https://github.com/rapidsai/build-planning/issues/111 Proposes some small packaging/CI changes, matching similar changes being made across RAPIDS. * printing `sccache` stats to CI logs * updating to the latest `rapids-dependency-file-generator` (v1.16.0) * reducing verbosity of `pip wheel` in wheel builds Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1712 --- .pre-commit-config.yaml | 2 +- ci/build_cpp.sh | 4 ++++ ci/build_python.sh | 4 ++++ ci/build_wheel_cpp.sh | 7 ++++++- ci/build_wheel_python.sh | 6 +++++- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f114abec4..56c972b4e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -82,7 +82,7 @@ repos: - id: verify-copyright - id: verify-alpha-spec - repo: https://github.com/rapidsai/dependency-file-generator - rev: v1.13.11 + rev: v1.16.0 hooks: - id: rapids-dependency-file-generator args: ["--clean"] diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index a601ecaae..9d14cd072 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -15,7 +15,11 @@ rapids-print-env rapids-logger "Begin cpp build" +sccache --zero-stats + # This calls mambabuild when boa is installed (as is the case in the CI images) RAPIDS_PACKAGE_VERSION=$(rapids-generate-version) rapids-conda-retry mambabuild conda/recipes/librmm +sccache --show-adv-stats + rapids-upload-conda-to-s3 cpp diff --git a/ci/build_python.sh b/ci/build_python.sh index fcd2c55e7..7a9df5fc7 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -19,7 +19,11 @@ rapids-logger "Begin py build" CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) +sccache --zero-stats + # This calls mambabuild when boa is installed (as is the case in the CI images) RAPIDS_PACKAGE_VERSION=$(head -1 ./VERSION) rapids-conda-retry mambabuild -c "${CPP_CHANNEL}" conda/recipes/rmm +sccache --show-adv-stats + rapids-upload-conda-to-s3 python diff --git a/ci/build_wheel_cpp.sh b/ci/build_wheel_cpp.sh index 2c5cc0560..12e099bdb 100755 --- a/ci/build_wheel_cpp.sh +++ b/ci/build_wheel_cpp.sh @@ -14,7 +14,12 @@ RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" cd "${package_dir}" -python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check +sccache --zero-stats + +python -m pip wheel . -w dist -v --no-deps --disable-pip-version-check + +sccache --show-adv-stats + python -m pip install wheel python -m wheel tags --platform any dist/* --remove RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 cpp dist diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index 555974b50..b497b76d3 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -22,8 +22,12 @@ CPP_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-down # are used when created the isolated build environment echo "librmm-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo ${CPP_WHEELHOUSE}/librmm_${RAPIDS_PY_CUDA_SUFFIX}*.whl)" > ./build-constraints.txt +sccache --zero-stats + PIP_CONSTRAINT="${PWD}/build-constraints.txt" \ - python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check + python -m pip wheel . -w dist -v --no-deps --disable-pip-version-check + +sccache --show-adv-stats mkdir -p final_dist python -m auditwheel repair -w final_dist dist/* From 8d49fffdb93b55ce70c72981d2e1d5511692eaa2 Mon Sep 17 00:00:00 2001 From: Matthew Murray <41342305+Matt711@users.noreply.github.com> Date: Thu, 31 Oct 2024 19:44:38 -0400 Subject: [PATCH 489/675] Deprecate `rmm._lib` (#1713) Follows up #1676 to add deprecation warnings to the `rmm._lib` sub package. Authors: - Matthew Murray (https://github.com/Matt711) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1713 --- python/rmm/rmm/__init__.py | 8 ++++++++ python/rmm/rmm/_lib/__init__.py | 8 ++++++++ python/rmm/rmm/tests/test_rmm.py | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/python/rmm/rmm/__init__.py b/python/rmm/rmm/__init__.py index b23ad68f9..832fec095 100644 --- a/python/rmm/rmm/__init__.py +++ b/python/rmm/rmm/__init__.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import warnings + from rmm import mr from rmm._version import __git_commit__, __version__ from rmm.mr import disable_logging, enable_logging, get_log_filenames @@ -58,6 +60,12 @@ def __getattr__(name): if name == "_lib": import importlib + warnings.warn( + "The `rmm._lib` module is deprecated in will be removed in a future release. Use `rmm.pylibrmm` instead.", + FutureWarning, + stacklevel=2, + ) + module = importlib.import_module("rmm.pylibrmm") return module else: diff --git a/python/rmm/rmm/_lib/__init__.py b/python/rmm/rmm/_lib/__init__.py index 7cfddab60..7e01bda77 100644 --- a/python/rmm/rmm/_lib/__init__.py +++ b/python/rmm/rmm/_lib/__init__.py @@ -12,4 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import warnings + from rmm.pylibrmm import * + +warnings.warn( + "The `rmm._lib` module is deprecated in will be removed in a future release. Use `rmm.pylibrmm` instead.", + FutureWarning, + stacklevel=2, +) diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index c03b9e501..9872ba89d 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -1076,3 +1076,9 @@ def test_available_device_memory(): assert initial_memory[1] == final_memory[1] assert initial_memory[0] > 0 assert final_memory[0] > 0 + + +# TODO: Remove test when rmm._lib is removed in 25.02 +def test_deprecate_rmm_lib(): + with pytest.warns(FutureWarning): + rmm._lib.device_buffer.DeviceBuffer(size=100) From 9b76d366d2d971839d4997c437e2d20490d9d65e Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 1 Nov 2024 13:47:08 -0400 Subject: [PATCH 490/675] Correct rmm tests for validity of device pointers (#1714) The `is_host_memory` function has been updated to understand that `cudaMemoryTypeUnregistered` is returned when provided pointers allocated by `malloc` and other host side allocation functions. The `is_device_memory` function has been restricted to report only when device pointer that is usable by the calling cuda context. For that reason the tests now also set the active cuda device for all calling threads. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Rong Ou (https://github.com/rongou) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1714 --- .../mr/device/mr_ref_multithreaded_tests.cpp | 19 +++++++++++++++++-- tests/mr/device/test_utils.hpp | 7 ++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/mr/device/mr_ref_multithreaded_tests.cpp b/tests/mr/device/mr_ref_multithreaded_tests.cpp index 7d749efd1..944ba1807 100644 --- a/tests/mr/device/mr_ref_multithreaded_tests.cpp +++ b/tests/mr/device/mr_ref_multithreaded_tests.cpp @@ -109,8 +109,13 @@ TEST_P(mr_ref_test_mt, SetCurrentDeviceResourceRef_mt) { // single thread changes default resource, then multiple threads use it auto old = rmm::mr::set_current_device_resource_ref(this->ref); + test_get_current_device_resource_ref(); - spawn([mr = this->ref]() { + int device; + RMM_CUDA_TRY(cudaGetDevice(&device)); + + spawn([device, mr = this->ref]() { + RMM_CUDA_TRY(cudaSetDevice(device)); EXPECT_EQ(mr, rmm::mr::get_current_device_resource_ref()); test_get_current_device_resource_ref(); // test allocating with the new default resource }); @@ -156,7 +161,17 @@ TEST_P(mr_ref_test_mt, SetCurrentDeviceResourceRefPerThread_mt) } } -TEST_P(mr_ref_test_mt, Allocate) { spawn(test_various_allocations, this->ref); } +TEST_P(mr_ref_test_mt, Allocate) +{ + int device; + RMM_CUDA_TRY(cudaGetDevice(&device)); + + auto mr = this->ref; + spawn([device, mr]() { + RMM_CUDA_TRY(cudaSetDevice(device)); + test_various_allocations(mr); + }); +} TEST_P(mr_ref_test_mt, AllocateDefaultStream) { diff --git a/tests/mr/device/test_utils.hpp b/tests/mr/device/test_utils.hpp index 2b9513793..5b7ef197b 100644 --- a/tests/mr/device/test_utils.hpp +++ b/tests/mr/device/test_utils.hpp @@ -31,17 +31,14 @@ inline bool is_device_accessible_memory(void* ptr) { cudaPointerAttributes attributes{}; if (cudaSuccess != cudaPointerGetAttributes(&attributes, ptr)) { return false; } - return (attributes.type == cudaMemoryTypeDevice) or (attributes.type == cudaMemoryTypeManaged) or - ((attributes.type == cudaMemoryTypeHost) and (attributes.devicePointer != nullptr)) or - ((attributes.type == cudaMemoryTypeUnregistered) and - (rmm::mr::detail::is_system_memory_supported(rmm::get_current_cuda_device()))); + return attributes.devicePointer != nullptr; } inline bool is_host_memory(void* ptr) { cudaPointerAttributes attributes{}; if (cudaSuccess != cudaPointerGetAttributes(&attributes, ptr)) { return false; } - return attributes.type == cudaMemoryTypeHost; + return attributes.hostPointer != nullptr || attributes.type == cudaMemoryTypeUnregistered; } inline bool is_properly_aligned(void* ptr) From dbae8c08b0bed1d14ff1b5fe1bc5332b0c175cf8 Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Sat, 2 Nov 2024 01:58:15 +0800 Subject: [PATCH 491/675] [fea] Expose the arena mr to the Python interface. (#1711) Close https://github.com/rapidsai/rmm/issues/830 . - Add the arena allocator to the public Python interface. - Small changes to the logger initialization to avoid exposing spdlog in the shared objects. Authors: - Jiaming Yuan (https://github.com/trivialfis) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1711 --- .../rmm/mr/device/arena_memory_resource.hpp | 10 ++++- include/rmm/mr/device/detail/arena.hpp | 2 +- python/rmm/rmm/_lib/memory_resource.pxd | 1 + python/rmm/rmm/_lib/memory_resource.py | 1 + python/rmm/rmm/librmm/memory_resource.pxd | 9 ++++ python/rmm/rmm/mr.py | 2 + python/rmm/rmm/pylibrmm/memory_resource.pxd | 3 ++ python/rmm/rmm/pylibrmm/memory_resource.pyx | 43 +++++++++++++++++++ python/rmm/rmm/tests/test_rmm.py | 22 ++++++++++ 9 files changed, 90 insertions(+), 3 deletions(-) diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index 417b7d2b4..9b380ffb9 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -97,7 +97,10 @@ class arena_memory_resource final : public device_memory_resource { : global_arena_{upstream_mr, arena_size}, dump_log_on_failure_{dump_log_on_failure} { if (dump_log_on_failure_) { - logger_ = spdlog::basic_logger_mt("arena_memory_dump", "rmm_arena_memory_dump.log"); + logger_ = + std::make_shared("arena_memory_dump", + std::make_shared( + "rmm_arena_memory_dump.log", true /*truncate file*/)); // Set the level to `debug` for more detailed output. logger_->set_level(spdlog::level::info); } @@ -120,7 +123,10 @@ class arena_memory_resource final : public device_memory_resource { dump_log_on_failure_{dump_log_on_failure} { if (dump_log_on_failure_) { - logger_ = spdlog::basic_logger_mt("arena_memory_dump", "rmm_arena_memory_dump.log"); + logger_ = + std::make_shared("arena_memory_dump", + std::make_shared( + "rmm_arena_memory_dump.log", true /*truncate file*/)); // Set the level to `debug` for more detailed output. logger_->set_level(spdlog::level::info); } diff --git a/include/rmm/mr/device/detail/arena.hpp b/include/rmm/mr/device/detail/arena.hpp index 6f8303c83..da64ca85b 100644 --- a/include/rmm/mr/device/detail/arena.hpp +++ b/include/rmm/mr/device/detail/arena.hpp @@ -647,7 +647,7 @@ class global_arena final { * * @param logger the spdlog logger to use */ - void dump_memory_log(std::shared_ptr const& logger) const + RMM_HIDDEN void dump_memory_log(std::shared_ptr const& logger) const { std::lock_guard lock(mtx_); diff --git a/python/rmm/rmm/_lib/memory_resource.pxd b/python/rmm/rmm/_lib/memory_resource.pxd index 983063914..0d11001a4 100644 --- a/python/rmm/rmm/_lib/memory_resource.pxd +++ b/python/rmm/rmm/_lib/memory_resource.pxd @@ -40,6 +40,7 @@ from rmm.librmm.memory_resource cimport ( translate_python_except_to_cpp, ) from rmm.pylibrmm.memory_resource cimport ( + ArenaMemoryResource, BinningMemoryResource, CallbackMemoryResource, CudaAsyncMemoryResource, diff --git a/python/rmm/rmm/_lib/memory_resource.py b/python/rmm/rmm/_lib/memory_resource.py index 0d47e8c9b..f3a24f635 100644 --- a/python/rmm/rmm/_lib/memory_resource.py +++ b/python/rmm/rmm/_lib/memory_resource.py @@ -13,6 +13,7 @@ # limitations under the License. from rmm.pylibrmm.memory_resource import ( # noqa: F401 + ArenaMemoryResource, BinningMemoryResource, CallbackMemoryResource, CudaAsyncMemoryResource, diff --git a/python/rmm/rmm/librmm/memory_resource.pxd b/python/rmm/rmm/librmm/memory_resource.pxd index 9ddaf04b9..9e7b70c4f 100644 --- a/python/rmm/rmm/librmm/memory_resource.pxd +++ b/python/rmm/rmm/librmm/memory_resource.pxd @@ -130,6 +130,15 @@ cdef extern from "rmm/mr/device/pool_memory_resource.hpp" \ optional[size_t] maximum_pool_size) except + size_t pool_size() +cdef extern from "rmm/mr/device/arena_memory_resource.hpp" \ + namespace "rmm::mr" nogil: + cdef cppclass arena_memory_resource[Upstream](device_memory_resource): + arena_memory_resource( + Upstream* upstream_mr, + optional[size_t] arena_size, + bool dump_log_on_failure + ) except + + cdef extern from "rmm/mr/device/fixed_size_memory_resource.hpp" \ namespace "rmm::mr" nogil: cdef cppclass fixed_size_memory_resource[Upstream](device_memory_resource): diff --git a/python/rmm/rmm/mr.py b/python/rmm/rmm/mr.py index 3f0c3fce3..82729271f 100644 --- a/python/rmm/rmm/mr.py +++ b/python/rmm/rmm/mr.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. from rmm.pylibrmm.memory_resource import ( + ArenaMemoryResource, BinningMemoryResource, CallbackMemoryResource, CudaAsyncMemoryResource, @@ -45,6 +46,7 @@ ) __all__ = [ + "ArenaMemoryResource", "BinningMemoryResource", "CallbackMemoryResource", "CudaAsyncMemoryResource", diff --git a/python/rmm/rmm/pylibrmm/memory_resource.pxd b/python/rmm/rmm/pylibrmm/memory_resource.pxd index 985d5d31b..d1e5610db 100644 --- a/python/rmm/rmm/pylibrmm/memory_resource.pxd +++ b/python/rmm/rmm/pylibrmm/memory_resource.pxd @@ -26,6 +26,9 @@ cdef class UpstreamResourceAdaptor(DeviceMemoryResource): cpdef DeviceMemoryResource get_upstream(self) +cdef class ArenaMemoryResource(UpstreamResourceAdaptor): + pass + cdef class CudaMemoryResource(DeviceMemoryResource): pass diff --git a/python/rmm/rmm/pylibrmm/memory_resource.pyx b/python/rmm/rmm/pylibrmm/memory_resource.pyx index 021125567..b41890fca 100644 --- a/python/rmm/rmm/pylibrmm/memory_resource.pyx +++ b/python/rmm/rmm/pylibrmm/memory_resource.pyx @@ -49,6 +49,7 @@ from rmm.librmm.memory_resource cimport ( CppExcept, allocate_callback_t, allocation_handle_type, + arena_memory_resource, available_device_memory as c_available_device_memory, binning_memory_resource, callback_memory_resource, @@ -310,6 +311,48 @@ cdef class PoolMemoryResource(UpstreamResourceAdaptor): ) return c_mr.pool_size() +cdef class ArenaMemoryResource(UpstreamResourceAdaptor): + def __cinit__( + self, DeviceMemoryResource upstream_mr, + arena_size=None, + dump_log_on_failure=False + ): + cdef optional[size_t] c_arena_size = ( + optional[size_t]() if + arena_size is None + else optional[size_t]( parse_bytes(arena_size)) + ) + self.c_obj.reset( + new arena_memory_resource[device_memory_resource]( + upstream_mr.get_mr(), + c_arena_size, + dump_log_on_failure, + ) + ) + + def __init__( + self, + DeviceMemoryResource upstream_mr, + object arena_size=None, + bool dump_log_on_failure=False + ): + """ + A suballocator that emphasizes fragmentation avoidance and scalable concurrency + support. + + Parameters + ---------- + upstream_mr : DeviceMemoryResource + The DeviceMemoryResource from which to allocate memory for arenas. + arena_size : int, optional + Size in bytes of the global arena. Defaults to half of the available memory + on the current device. + dump_log_on_failure : bool, optional + Whether to dump the arena on allocation failure. + """ + pass + + cdef class FixedSizeMemoryResource(UpstreamResourceAdaptor): def __cinit__( self, diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index 9872ba89d..b52ea0179 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -505,6 +505,28 @@ def test_binning_memory_resource(dtype, nelem, alloc, upstream_mr): array_tester(dtype, nelem, alloc) +@pytest.mark.parametrize("dtype", _dtypes) +@pytest.mark.parametrize("nelem", _nelems) +@pytest.mark.parametrize("alloc", _allocs) +@pytest.mark.parametrize( + "upstream_mr", + [ + lambda: rmm.mr.CudaMemoryResource(), + lambda: rmm.mr.ManagedMemoryResource(), + lambda: rmm.mr.PoolMemoryResource( + rmm.mr.CudaMemoryResource(), 1 << 20 + ), + ], +) +def test_arena_memory_resource(dtype, nelem, alloc, upstream_mr): + upstream = upstream_mr() + mr = rmm.mr.ArenaMemoryResource(upstream) + + rmm.mr.set_current_device_resource(mr) + assert rmm.mr.get_current_device_resource_type() is type(mr) + array_tester(dtype, nelem, alloc) + + def test_reinitialize_max_pool_size(): rmm.reinitialize( pool_allocator=True, initial_pool_size=0, maximum_pool_size="8MiB" From d4c0635677508900668e50cd6f1afd8fae4e5c98 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 6 Nov 2024 15:28:02 -0500 Subject: [PATCH 492/675] Disallow cuda-python 12.6.1 and 11.8.4 (#1720) Due to a bug in cuda-python we must disallow cuda-python 12.6.1 and 11.8.4. See https://github.com/rapidsai/build-planning/issues/116 for more information. This PR disallows those versions, and other changes following from that: * specifying `python` in both `host:` and `run:` dependencies for the `rmm` conda package * ignoring deprecation warnings raised by newer versions of `cuda-python` Authors: - Bradley Dice (https://github.com/bdice) - James Lamb (https://github.com/jameslamb) - https://github.com/jakirkham Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1720 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-125_arch-x86_64.yaml | 2 +- conda/recipes/rmm/meta.yaml | 8 ++++++-- dependencies.yaml | 4 ++-- python/rmm/pyproject.toml | 5 +++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index bf64d4d55..2501effa5 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -10,7 +10,7 @@ dependencies: - clang-tools==16.0.6 - clang==16.0.6 - cmake>=3.26.4,!=3.30.0 -- cuda-python>=11.7.1,<12.0a0 +- cuda-python>=11.7.1,<12.0a0,!=11.8.4 - cuda-version=11.8 - cudatoolkit - cxx-compiler diff --git a/conda/environments/all_cuda-125_arch-x86_64.yaml b/conda/environments/all_cuda-125_arch-x86_64.yaml index 112c635a8..357ae8a24 100644 --- a/conda/environments/all_cuda-125_arch-x86_64.yaml +++ b/conda/environments/all_cuda-125_arch-x86_64.yaml @@ -11,7 +11,7 @@ dependencies: - clang==16.0.6 - cmake>=3.26.4,!=3.30.0 - cuda-nvcc -- cuda-python>=12.0,<13.0a0 +- cuda-python>=12.0,<13.0a0,!=12.6.1 - cuda-version=12.5 - cxx-compiler - cython>=3.0.0 diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index fcc7424fa..c9b0f8189 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -38,6 +38,7 @@ build: - {{ compiler('cuda') }} - cuda-cudart-dev {% endif %} + - cuda-python requirements: build: @@ -56,10 +57,10 @@ requirements: - cuda-version ={{ cuda_version }} {% if cuda_major == "11" %} - cudatoolkit - - cuda-python >=11.7.1,<12.0a0 + - cuda-python >=11.7.1,<12.0a0,!=11.8.4 {% else %} - cuda-cudart-dev - - cuda-python >=12.0,<13.0a0 + - cuda-python >=12.0,<13.0a0,!=12.6.1 {% endif %} - cython >=3.0.0 - rapids-build-backend >=0.3.0,<0.4.0.dev0 @@ -69,12 +70,15 @@ requirements: run: {% if cuda_major == "11" %} - cudatoolkit + - cuda-python >=11.7.1,<12.0a0,!=11.8.4 {% else %} - cuda-cudart + - cuda-python >=12.0,<13.0a0,!=12.6.1 {% endif %} - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - numba >=0.57 - numpy >=1.23,<3.0a0 + - python test: imports: diff --git a/dependencies.yaml b/dependencies.yaml index 9f1ed9c40..88459c8f5 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -153,10 +153,10 @@ dependencies: - matrix: cuda: "12.*" packages: - - &cuda_python12 cuda-python>=12.0,<13.0a0 + - &cuda_python12 cuda-python>=12.0,<13.0a0,!=12.6.1 - matrix: # All CUDA 11 versions packages: - - &cuda_python11 cuda-python>=11.7.1,<12.0a0 + - &cuda_python11 cuda-python>=11.7.1,<12.0a0,!=11.8.4 - output_types: [requirements, pyproject] matrices: - matrix: diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index b148cdba7..095af6339 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -30,7 +30,7 @@ authors = [ license = { text = "Apache 2.0" } requires-python = ">=3.10" dependencies = [ - "cuda-python>=11.7.1,<12.0a0", + "cuda-python>=11.7.1,<12.0a0,!=11.8.4", "numba>=0.57", "numpy>=1.23,<3.0a0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. @@ -128,7 +128,7 @@ dependencies-file = "../../dependencies.yaml" matrix-entry = "cuda_suffixed=true" requires = [ "cmake>=3.26.4,!=3.30.0", - "cuda-python>=11.7.1,<12.0a0", + "cuda-python>=11.7.1,<12.0a0,!=11.8.4", "cython>=3.0.0", "librmm==24.12.*,>=0.0.0a0", "ninja", @@ -138,4 +138,5 @@ requires = [ # treat warnings as errors filterwarnings = [ "error", + "ignore:.*cuda..* module is deprecated.*:DeprecationWarning" ] From a98c22a76bc0dfbd8fd39d4aa2acef1598bd68ab Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 6 Nov 2024 21:19:25 -0600 Subject: [PATCH 493/675] WIP: put a ceiling on cuda-python (#1723) Follow-up to #1720 Contributes to https://github.com/rapidsai/build-planning/issues/116 That PR used `!=` requirements to skip a particular version of `cuda-python` that `rmm` was incompatible with. A newer version of `cuda-python` (12.6.2 for CUDA 12, 11.8.5 for CUDA 11) was just released, and it also causes some build issues for RAPIDS libraries: https://github.com/rapidsai/cuvs/pull/445#issuecomment-2461146449 To unblock CI across RAPIDS, this proposes **temporarily** switching to ceilings on `rmm`'s `cuda-python` dependency. Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1723 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-125_arch-x86_64.yaml | 2 +- conda/recipes/rmm/meta.yaml | 8 ++++---- dependencies.yaml | 4 ++-- python/rmm/pyproject.toml | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 2501effa5..519c056b5 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -10,7 +10,7 @@ dependencies: - clang-tools==16.0.6 - clang==16.0.6 - cmake>=3.26.4,!=3.30.0 -- cuda-python>=11.7.1,<12.0a0,!=11.8.4 +- cuda-python>=11.7.1,<12.0a0,<=11.8.3 - cuda-version=11.8 - cudatoolkit - cxx-compiler diff --git a/conda/environments/all_cuda-125_arch-x86_64.yaml b/conda/environments/all_cuda-125_arch-x86_64.yaml index 357ae8a24..86e887c21 100644 --- a/conda/environments/all_cuda-125_arch-x86_64.yaml +++ b/conda/environments/all_cuda-125_arch-x86_64.yaml @@ -11,7 +11,7 @@ dependencies: - clang==16.0.6 - cmake>=3.26.4,!=3.30.0 - cuda-nvcc -- cuda-python>=12.0,<13.0a0,!=12.6.1 +- cuda-python>=12.0,<13.0a0,<=12.6.0 - cuda-version=12.5 - cxx-compiler - cython>=3.0.0 diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index c9b0f8189..8f6e13fd7 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -57,10 +57,10 @@ requirements: - cuda-version ={{ cuda_version }} {% if cuda_major == "11" %} - cudatoolkit - - cuda-python >=11.7.1,<12.0a0,!=11.8.4 + - cuda-python >=11.7.1,<12.0a0,<=11.8.3 {% else %} - cuda-cudart-dev - - cuda-python >=12.0,<13.0a0,!=12.6.1 + - cuda-python >=12.0,<13.0a0,<=12.6.0 {% endif %} - cython >=3.0.0 - rapids-build-backend >=0.3.0,<0.4.0.dev0 @@ -70,10 +70,10 @@ requirements: run: {% if cuda_major == "11" %} - cudatoolkit - - cuda-python >=11.7.1,<12.0a0,!=11.8.4 + - cuda-python >=11.7.1,<12.0a0,<=11.8.3 {% else %} - cuda-cudart - - cuda-python >=12.0,<13.0a0,!=12.6.1 + - cuda-python >=12.0,<13.0a0,<=12.6.0 {% endif %} - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - numba >=0.57 diff --git a/dependencies.yaml b/dependencies.yaml index 88459c8f5..3e2c2eb29 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -153,10 +153,10 @@ dependencies: - matrix: cuda: "12.*" packages: - - &cuda_python12 cuda-python>=12.0,<13.0a0,!=12.6.1 + - &cuda_python12 cuda-python>=12.0,<13.0a0,<=12.6.0 - matrix: # All CUDA 11 versions packages: - - &cuda_python11 cuda-python>=11.7.1,<12.0a0,!=11.8.4 + - &cuda_python11 cuda-python>=11.7.1,<12.0a0,<=11.8.3 - output_types: [requirements, pyproject] matrices: - matrix: diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 095af6339..22ed94660 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -30,7 +30,7 @@ authors = [ license = { text = "Apache 2.0" } requires-python = ">=3.10" dependencies = [ - "cuda-python>=11.7.1,<12.0a0,!=11.8.4", + "cuda-python>=11.7.1,<12.0a0,<=11.8.3", "numba>=0.57", "numpy>=1.23,<3.0a0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. @@ -128,7 +128,7 @@ dependencies-file = "../../dependencies.yaml" matrix-entry = "cuda_suffixed=true" requires = [ "cmake>=3.26.4,!=3.30.0", - "cuda-python>=11.7.1,<12.0a0,!=11.8.4", + "cuda-python>=11.7.1,<12.0a0,<=11.8.3", "cython>=3.0.0", "librmm==24.12.*,>=0.0.0a0", "ninja", From 771ccdc3a1aa142f4be03518d868595b0f81a8c3 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Thu, 7 Nov 2024 10:22:42 -0600 Subject: [PATCH 494/675] use rapids-generate-pip-constraints to pin to oldest dependencies in CI (#1716) Follow-up to #1613 Similar to https://github.com/rapidsai/cudf/pull/17131 Proposes using the new `rapids-generate-pip-constraints` tool from `gha-tools` to generate a list of pip constraints pinning to the oldest supported verisons of dependencies here. ## Notes for Reviewers ### How I tested this `wheel-tests`: * oldest-deps: numpy 1.x ([build link](https://github.com/rapidsai/rmm/actions/runs/11620907528/job/32364032641?pr=1716#step:8:106)) * latest-deps: numpy 2.x ([build link](https://github.com/rapidsai/rmm/actions/runs/11620907528/job/32364032835?pr=1716#step:8:104)) And the testing of the general approach in https://github.com/rapidsai/gha-tools/pull/114#issuecomment-2445377824 Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1716 --- ci/test_wheel.sh | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/ci/test_wheel.sh b/ci/test_wheel.sh index d06c4eed0..2f39b197b 100755 --- a/ci/test_wheel.sh +++ b/ci/test_wheel.sh @@ -7,15 +7,8 @@ RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" WHEELHOUSE="${PWD}/dist/" RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 python "${WHEELHOUSE}" -# Constraint to minimum dependency versions if job is set up as "oldest" -echo "" > ./constraints.txt -if [[ $RAPIDS_DEPENDENCIES == "oldest" ]]; then - rapids-dependency-file-generator \ - --output requirements \ - --file-key test_python \ - --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION};dependencies=${RAPIDS_DEPENDENCIES}" \ - | tee ./constraints.txt -fi +# generate constraints (possibly pinning to oldest support versions of dependencies) +rapids-generate-pip-constraints test_python ./constraints.txt # echo to expand wildcard before adding '[extra]' requires for pip python -m pip install \ From 56f3a464053a66f801a39c65cde47dbab46ce513 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 13 Nov 2024 12:40:18 -0600 Subject: [PATCH 495/675] enforce wheel size limits, README formatting in CI (#1726) Contributes to https://github.com/rapidsai/build-planning/issues/110 Proposes adding 2 types of validation on wheels in CI, to ensure we continue to produce wheels that are suitable for PyPI. * checks on wheel size (compressed), - *to be sure they're under PyPI limits* - *and to prompt discussion on PRs that significantly increase wheel sizes* * checks on README formatting - *to ensure they'll render properly as the PyPI project homepages* - *e.g. like how https://github.com/scikit-learn/scikit-learn/blob/main/README.rst becomes https://pypi.org/project/scikit-learn/* Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1726 --- ci/build_wheel_cpp.sh | 3 +++ ci/build_wheel_python.sh | 2 ++ ci/validate_wheel.sh | 18 ++++++++++++++++++ python/librmm/pyproject.toml | 8 ++++++++ python/rmm/docs/conf.py | 5 ++++- python/rmm/pyproject.toml | 8 ++++++++ 6 files changed, 43 insertions(+), 1 deletion(-) create mode 100755 ci/validate_wheel.sh diff --git a/ci/build_wheel_cpp.sh b/ci/build_wheel_cpp.sh index 12e099bdb..1ec979372 100755 --- a/ci/build_wheel_cpp.sh +++ b/ci/build_wheel_cpp.sh @@ -22,4 +22,7 @@ sccache --show-adv-stats python -m pip install wheel python -m wheel tags --platform any dist/* --remove + +../../ci/validate_wheel.sh dist + RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 cpp dist diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index b497b76d3..4e4d3bf61 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -32,6 +32,8 @@ sccache --show-adv-stats mkdir -p final_dist python -m auditwheel repair -w final_dist dist/* +../../ci/validate_wheel.sh final_dist + RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 python final_dist # switch back to the root of the repo and check symbol visibility diff --git a/ci/validate_wheel.sh b/ci/validate_wheel.sh new file mode 100755 index 000000000..60a80fce6 --- /dev/null +++ b/ci/validate_wheel.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Copyright (c) 2024, NVIDIA CORPORATION. + +set -euo pipefail + +wheel_dir_relative_path=$1 + +rapids-logger "validate packages with 'pydistcheck'" + +pydistcheck \ + --inspect \ + "$(echo ${wheel_dir_relative_path}/*.whl)" + +rapids-logger "validate packages with 'twine'" + +twine check \ + --strict \ + "$(echo ${wheel_dir_relative_path}/*.whl)" diff --git a/python/librmm/pyproject.toml b/python/librmm/pyproject.toml index 0f0b4e397..bae2ef36b 100644 --- a/python/librmm/pyproject.toml +++ b/python/librmm/pyproject.toml @@ -67,3 +67,11 @@ wheel.py-api = "py3" provider = "scikit_build_core.metadata.regex" input = "librmm/VERSION" regex = "(?P.*)" + +[tool.pydistcheck] +select = [ + "distro-too-large-compressed", +] + +# PyPI limit is 100 MiB, fail CI before we get too close to that +max_allowed_size_compressed = '75M' diff --git a/python/rmm/docs/conf.py b/python/rmm/docs/conf.py index 0b2c21d5a..2aad3a82c 100644 --- a/python/rmm/docs/conf.py +++ b/python/rmm/docs/conf.py @@ -197,7 +197,10 @@ intersphinx_mapping = { "python": ("https://docs.python.org/3", None), "numba": ("https://numba.readthedocs.io/en/stable", None), - "cuda-python": ("https://nvidia.github.io/cuda-python/", None), + "cuda-python": ( + "https://nvidia.github.io/cuda-python/cuda-bindings/", + None, + ), } # Config numpydoc diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 22ed94660..aaaa15482 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -134,6 +134,14 @@ requires = [ "ninja", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. +[tool.pydistcheck] +select = [ + "distro-too-large-compressed", +] + +# PyPI limit is 100 MiB, fail CI before we get too close to that +max_allowed_size_compressed = '75M' + [tool.pytest.ini_options] # treat warnings as errors filterwarnings = [ From 220003e57532d1276fbecdba9dd82ed04efa1db4 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:37:07 +1100 Subject: [PATCH 496/675] Treat deprecation warnings as errors and fix deprecation warnings in replay benchmark (#1728) Fixes #1727 Contributes to https://github.com/rapidsai/build-planning/issues/26 - Removes `-Wno-error=deprecated-declarations` - Replaces deprecated usage of `rmm::logger()` in reply benchmark with supported `RMM_LOG_INFO` macros. Note the latter duplicates a change in #1724 which allows the two PRs to be merged independently. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Rong Ou (https://github.com/rongou) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1728 --- benchmarks/CMakeLists.txt | 7 +++---- benchmarks/replay/replay.cpp | 6 +++--- tests/CMakeLists.txt | 3 +-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 9dfb2c538..0487a2dfa 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2018-2020, NVIDIA CORPORATION. +# Copyright (c) 2018-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 @@ -42,9 +42,8 @@ function(ConfigureBench BENCH_NAME) target_compile_definitions(${BENCH_NAME} PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM) endif() - target_compile_options( - ${BENCH_NAME} PUBLIC $<$:-Wall -Werror - -Wno-error=deprecated-declarations -Wno-unknown-pragmas>) + target_compile_options(${BENCH_NAME} PUBLIC $<$:-Wall -Werror + -Wno-unknown-pragmas>) if(DISABLE_DEPRECATION_WARNING) target_compile_options( ${BENCH_NAME} PUBLIC $<$:-Xcompiler=-Wno-deprecated-declarations>) diff --git a/benchmarks/replay/replay.cpp b/benchmarks/replay/replay.cpp index 5afed036a..d80841321 100644 --- a/benchmarks/replay/replay.cpp +++ b/benchmarks/replay/replay.cpp @@ -172,7 +172,7 @@ struct replay_benchmark { void SetUp(const ::benchmark::State& state) { if (state.thread_index() == 0) { - rmm::logger().log(spdlog::level::info, "------ Start of Benchmark -----"); + RMM_LOG_INFO("------ Start of Benchmark -----"); mr_ = factory_(simulated_size_); } } @@ -181,7 +181,7 @@ struct replay_benchmark { void TearDown(const ::benchmark::State& state) { if (state.thread_index() == 0) { - rmm::logger().log(spdlog::level::info, "------ End of Benchmark -----"); + RMM_LOG_INFO("------ End of Benchmark -----"); // clean up any leaked allocations std::size_t total_leaked{0}; std::size_t num_leaked{0}; @@ -402,7 +402,7 @@ int main(int argc, char** argv) auto const num_threads = per_thread_events.size(); // Uncomment to enable / change default log level - // rmm::logger().set_level(spdlog::level::trace); + // rmm::detail::logger().set_level(spdlog::level::trace); if (args.count("resource") > 0) { std::string mr_name = args["resource"].as(); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0258c59c5..a482c8cc1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -41,8 +41,7 @@ function(ConfigureTestInternal TEST_NAME) CUDA_STANDARD_REQUIRED ON) target_compile_definitions(${TEST_NAME} PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") - target_compile_options(${TEST_NAME} PUBLIC $<$:-Wall -Werror - -Wno-error=deprecated-declarations>) + target_compile_options(${TEST_NAME} PUBLIC $<$:-Wall -Werror>) if(DISABLE_DEPRECATION_WARNING) target_compile_options( From 52d61c528fa46a1f579ce294757ed7fe6d0b2970 Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:41:18 +1100 Subject: [PATCH 497/675] Remove all explicit usage of fmtlib (#1724) Fixes #1717 Also fixes #1710 in 5330063 I have replaced fmt-style format string placeholders (`"... {} ..."`) with printf-style placeholders by adding a function `rmm::detail::formatted_log()`, which I modified from @vyasr 's #1722. ~The only remaining mention of fmt is in CMakeLists.txt. Do we still need to explicitly fetch fmt?~ Removed. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1724 --- CMakeLists.txt | 6 +- benchmarks/replay/replay.cpp | 1 + benchmarks/utilities/log_parser.hpp | 4 +- cmake/thirdparty/get_fmt.cmake | 22 ---- include/rmm/detail/format.hpp | 101 ++++++++++++++++++ include/rmm/detail/logging_assert.hpp | 4 +- include/rmm/logger.hpp | 55 +++------- .../rmm/mr/device/arena_memory_resource.hpp | 4 +- include/rmm/mr/device/detail/arena.hpp | 41 +++---- .../mr/device/detail/coalescing_free_list.hpp | 9 +- .../detail/stream_ordered_memory_resource.hpp | 29 +++-- .../mr/device/logging_resource_adaptor.hpp | 12 ++- .../rmm/mr/device/pool_memory_resource.hpp | 9 +- .../mr/device/tracking_resource_adaptor.hpp | 16 ++- tests/logger_tests.cpp | 1 - tests/mr/device/arena_mr_tests.cpp | 4 +- tests/mr/device/callback_mr_tests.cpp | 7 +- 17 files changed, 189 insertions(+), 136 deletions(-) delete mode 100644 cmake/thirdparty/get_fmt.cmake create mode 100644 include/rmm/detail/format.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 26fcf1fd0..44d7fbb79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,8 +41,8 @@ rapids_cmake_build_type(Release) option(RMM_NVTX "Build RMM with NVTX support" OFF) option(BUILD_TESTS "Configure CMake to build tests" ON) option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" OFF) -# This is mostly so that dependent libraries, such as fmt, are configured in shared mode for -# downstream dependents of RMM that get their common dependencies transitively. +# This is mostly so that dependent libraries are configured in shared mode for downstream dependents +# of RMM that get their common dependencies transitively. option(BUILD_SHARED_LIBS "Build RMM shared libraries" ON) set(RMM_LOGGING_LEVEL "INFO" @@ -73,7 +73,6 @@ rapids_find_package( # add third party dependencies using CPM rapids_cpm_init() -include(cmake/thirdparty/get_fmt.cmake) include(cmake/thirdparty/get_spdlog.cmake) include(cmake/thirdparty/get_cccl.cmake) include(cmake/thirdparty/get_nvtx.cmake) @@ -96,7 +95,6 @@ else() endif() target_link_libraries(rmm INTERFACE CCCL::CCCL) -target_link_libraries(rmm INTERFACE fmt::fmt-header-only) target_link_libraries(rmm INTERFACE spdlog::spdlog_header_only) target_link_libraries(rmm INTERFACE dl) target_link_libraries(rmm INTERFACE nvtx3::nvtx3-cpp) diff --git a/benchmarks/replay/replay.cpp b/benchmarks/replay/replay.cpp index d80841321..7f45b7691 100644 --- a/benchmarks/replay/replay.cpp +++ b/benchmarks/replay/replay.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include diff --git a/benchmarks/utilities/log_parser.hpp b/benchmarks/utilities/log_parser.hpp index 2283ace93..4dfa5bae4 100644 --- a/benchmarks/utilities/log_parser.hpp +++ b/benchmarks/utilities/log_parser.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -151,7 +151,7 @@ inline std::vector parse_csv(std::string const& filename) auto parse_pointer = [](std::string const& str, uintptr_t& ptr) { auto const base{16}; - ptr = std::stoll(str, nullptr, base); + ptr = (str == "(nil)") ? 0 : std::stoll(str, nullptr, base); }; std::vector pointers = csv.GetColumn("Pointer", parse_pointer); diff --git a/cmake/thirdparty/get_fmt.cmake b/cmake/thirdparty/get_fmt.cmake deleted file mode 100644 index 5787fb73f..000000000 --- a/cmake/thirdparty/get_fmt.cmake +++ /dev/null @@ -1,22 +0,0 @@ -# ============================================================================= -# Copyright (c) 2023, 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. -# ============================================================================= - -# Use CPM to find or clone fmt -function(find_and_configure_fmt) - - include(${rapids-cmake-dir}/cpm/fmt.cmake) - rapids_cpm_fmt(INSTALL_EXPORT_SET rmm-exports BUILD_EXPORT_SET rmm-exports) -endfunction() - -find_and_configure_fmt() diff --git a/include/rmm/detail/format.hpp b/include/rmm/detail/format.hpp new file mode 100644 index 000000000..21acac032 --- /dev/null +++ b/include/rmm/detail/format.hpp @@ -0,0 +1,101 @@ +/* + * 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. + */ + +#pragma once + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace RMM_NAMESPACE { +namespace detail { + +/** + * @brief Format a message string with printf-style formatting + * + * This function performs printf-style formatting to avoid the need for fmt + * or spdlog's own templated APIs (which would require exposing spdlog + * symbols publicly) and returns the formatted message as a `std::string`. + * + * @param format The format string + * @param args The format arguments + * @return The formatted message + * @throw rmm::logic_error if an error occurs during formatting + */ +template +std::string formatted_log(std::string const& format, Args&&... args) +{ + auto convert_to_c_string = [](auto&& arg) -> decltype(auto) { + using ArgType = std::decay_t; + if constexpr (std::is_same_v) { + return arg.c_str(); + } else { + return std::forward(arg); + } + }; + + // NOLINTBEGIN(cppcoreguidelines-pro-type-vararg) + auto retsize = + std::snprintf(nullptr, 0, format.c_str(), convert_to_c_string(std::forward(args))...); + RMM_EXPECTS(retsize >= 0, "Error during formatting."); + if (retsize == 0) { return {}; } + auto size = static_cast(retsize) + 1; // for null terminator + // NOLINTNEXTLINE(modernize-avoid-c-arrays, cppcoreguidelines-avoid-c-arrays) + std::unique_ptr buf(new char[size]); + std::snprintf(buf.get(), size, format.c_str(), convert_to_c_string(std::forward(args))...); + // NOLINTEND(cppcoreguidelines-pro-type-vararg) + return {buf.get(), buf.get() + size - 1}; // drop '\0' +} + +// specialization for no arguments +template <> +inline std::string formatted_log(std::string const& format) +{ + return format; +} + +// Stringify a size in bytes to a human-readable value +inline std::string format_bytes(std::size_t value) +{ + static std::array units{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"}; + + int index = 0; + auto size = static_cast(value); + while (size > 1024) { + size /= 1024; + index++; + } + + return std::to_string(size) + ' ' + units.at(index); +} + +// Stringify a stream ID +inline std::string format_stream(rmm::cuda_stream_view stream) +{ + std::stringstream sstr{}; + sstr << std::hex << stream.value(); + return sstr.str(); +} + +} // namespace detail +} // namespace RMM_NAMESPACE diff --git a/include/rmm/detail/logging_assert.hpp b/include/rmm/detail/logging_assert.hpp index 7eb667211..4d702ee2b 100644 --- a/include/rmm/detail/logging_assert.hpp +++ b/include/rmm/detail/logging_assert.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, NVIDIA CORPORATION. + * Copyright (c) 2020-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. @@ -38,7 +38,7 @@ if (!success) { \ RMM_LOG_CRITICAL( \ "[" __FILE__ ":" RMM_STRINGIFY(__LINE__) "] Assertion " RMM_STRINGIFY(_expr) " failed."); \ - rmm::logger().flush(); \ + rmm::detail::logger().flush(); \ /* NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay) */ \ assert(success); \ } \ diff --git a/include/rmm/logger.hpp b/include/rmm/logger.hpp index eba3f122b..2cfd921b1 100644 --- a/include/rmm/logger.hpp +++ b/include/rmm/logger.hpp @@ -16,15 +16,13 @@ #pragma once +#include #include +#include -#include -#include #include #include -#include -#include #include namespace RMM_NAMESPACE { @@ -70,32 +68,6 @@ struct logger_wrapper { } }; -/** - * @brief Represent a size in number of bytes. - */ -struct bytes { - std::size_t value; ///< The size in bytes - - /** - * @brief Construct a new bytes object - * - * @param os The output stream - * @param value The size in bytes - */ - friend std::ostream& operator<<(std::ostream& os, bytes const& value) - { - static std::array units{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"}; - - int index = 0; - auto size = static_cast(value.value); - while (size > 1024) { - size /= 1024; - index++; - } - return os << size << ' ' << units.at(index); - } -}; - inline spdlog::logger& logger() { static detail::logger_wrapper wrapped{}; @@ -125,20 +97,21 @@ logger() // The default is INFO, but it should be used sparingly, so that by default a log file is only // output if there is important information, warnings, errors, and critical failures // Log messages that require computation should only be used at level TRACE and DEBUG -#define RMM_LOG_TRACE(...) SPDLOG_LOGGER_TRACE(&rmm::detail::logger(), __VA_ARGS__) -#define RMM_LOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(&rmm::detail::logger(), __VA_ARGS__) -#define RMM_LOG_INFO(...) SPDLOG_LOGGER_INFO(&rmm::detail::logger(), __VA_ARGS__) -#define RMM_LOG_WARN(...) SPDLOG_LOGGER_WARN(&rmm::detail::logger(), __VA_ARGS__) -#define RMM_LOG_ERROR(...) SPDLOG_LOGGER_ERROR(&rmm::detail::logger(), __VA_ARGS__) -#define RMM_LOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(&rmm::detail::logger(), __VA_ARGS__) +#define RMM_LOG_TRACE(...) \ + SPDLOG_LOGGER_TRACE(&rmm::detail::logger(), rmm::detail::formatted_log(__VA_ARGS__)) +#define RMM_LOG_DEBUG(...) \ + SPDLOG_LOGGER_DEBUG(&rmm::detail::logger(), rmm::detail::formatted_log(__VA_ARGS__)) +#define RMM_LOG_INFO(...) \ + SPDLOG_LOGGER_INFO(&rmm::detail::logger(), rmm::detail::formatted_log(__VA_ARGS__)) +#define RMM_LOG_WARN(...) \ + SPDLOG_LOGGER_WARN(&rmm::detail::logger(), rmm::detail::formatted_log(__VA_ARGS__)) +#define RMM_LOG_ERROR(...) \ + SPDLOG_LOGGER_ERROR(&rmm::detail::logger(), rmm::detail::formatted_log(__VA_ARGS__)) +#define RMM_LOG_CRITICAL(...) \ + SPDLOG_LOGGER_CRITICAL(&rmm::detail::logger(), rmm::detail::formatted_log(__VA_ARGS__)) //! @endcond } // namespace RMM_NAMESPACE -// Doxygen doesn't like this because we're overloading something from fmt -//! @cond Doxygen_Suppress -template <> -struct fmt::formatter : fmt::ostream_formatter {}; - //! @endcond diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index 9b380ffb9..d3a4bb09d 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -335,7 +336,8 @@ class arena_memory_resource final : public device_memory_resource { void dump_memory_log(size_t bytes) { logger_->info("**************************************************"); - logger_->info("Ran out of memory trying to allocate {}.", rmm::detail::bytes{bytes}); + logger_->info(rmm::detail::formatted_log("Ran out of memory trying to allocate %s.", + rmm::detail::format_bytes(bytes))); logger_->info("**************************************************"); logger_->info("Global arena:"); global_arena_.dump_memory_log(logger_); diff --git a/include/rmm/mr/device/detail/arena.hpp b/include/rmm/mr/device/detail/arena.hpp index da64ca85b..419c4fcf4 100644 --- a/include/rmm/mr/device/detail/arena.hpp +++ b/include/rmm/mr/device/detail/arena.hpp @@ -21,13 +21,13 @@ #include #include #include +#include #include #include #include #include -#include #include #include @@ -651,33 +651,38 @@ class global_arena final { { std::lock_guard lock(mtx_); - logger->info(" Arena size: {}", rmm::detail::bytes{upstream_block_.size()}); - logger->info(" # superblocks: {}", superblocks_.size()); + logger->info(rmm::detail::formatted_log(" Arena size: %s", + rmm::detail::format_bytes(upstream_block_.size()))); + logger->info(rmm::detail::formatted_log(" # superblocks: %zu", superblocks_.size())); if (!superblocks_.empty()) { - logger->debug(" Total size of superblocks: {}", - rmm::detail::bytes{total_memory_size(superblocks_)}); + logger->debug( + rmm::detail::formatted_log(" Total size of superblocks: %s", + rmm::detail::format_bytes(total_memory_size(superblocks_)))); auto const total_free = total_free_size(superblocks_); auto const max_free = max_free_size(superblocks_); auto const fragmentation = (1 - max_free / static_cast(total_free)) * 100; - logger->info(" Total free memory: {}", rmm::detail::bytes{total_free}); - logger->info(" Largest block of free memory: {}", rmm::detail::bytes{max_free}); - logger->info(" Fragmentation: {:.2f}%", fragmentation); + logger->info(rmm::detail::formatted_log(" Total free memory: %s", + rmm::detail::format_bytes(total_free))); + logger->info(rmm::detail::formatted_log(" Largest block of free memory: %s", + rmm::detail::format_bytes(max_free))); + logger->info(rmm::detail::formatted_log(" Fragmentation: %0.2f", fragmentation)); - auto index = 0; + auto index = decltype(superblocks_.size()){0}; char* prev_end{}; for (auto const& sblk : superblocks_) { if (prev_end == nullptr) { prev_end = sblk.pointer(); } - logger->debug( - " Superblock {}: start={}, end={}, size={}, empty={}, # free blocks={}, max free={}, " - "gap={}", + logger->debug(rmm::detail::formatted_log( + " Superblock %zu: start=%p, end=%p, size=%s, empty=%s, # free blocks=%zu, max " + "free=%s, " + "gap=%s", index, - fmt::ptr(sblk.pointer()), - fmt::ptr(sblk.end()), - rmm::detail::bytes{sblk.size()}, - sblk.empty(), + sblk.pointer(), + sblk.end(), + rmm::detail::format_bytes(sblk.size()), + sblk.empty() ? "T" : "F", sblk.free_blocks(), - rmm::detail::bytes{sblk.max_free_size()}, - rmm::detail::bytes{static_cast(sblk.pointer() - prev_end)}); + rmm::detail::format_bytes(sblk.max_free_size()), + rmm::detail::format_bytes(static_cast(sblk.pointer() - prev_end)))); prev_end = sblk.end(); index++; } diff --git a/include/rmm/mr/device/detail/coalescing_free_list.hpp b/include/rmm/mr/device/detail/coalescing_free_list.hpp index 8d5cbf9ed..8b056e6d9 100644 --- a/include/rmm/mr/device/detail/coalescing_free_list.hpp +++ b/include/rmm/mr/device/detail/coalescing_free_list.hpp @@ -20,8 +20,6 @@ #include #include -#include - #include #include #include @@ -131,10 +129,7 @@ struct block : public block_base { /** * @brief Print this block. For debugging. */ - inline void print() const - { - std::cout << fmt::format("{} {} B", fmt::ptr(pointer()), size()) << std::endl; - } + inline void print() const { std::cout << pointer() << " " << size() << " B" << std::endl; } #endif private: @@ -146,7 +141,7 @@ struct block : public block_base { /// Print block on an ostream inline std::ostream& operator<<(std::ostream& out, const block& blk) { - out << fmt::format("{} {} B\n", fmt::ptr(blk.pointer()), blk.size()); + out << blk.pointer() << " " << blk.size() << " B" << std::endl; return out; } #endif diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index 9cf674d6e..f177504f2 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -19,13 +19,12 @@ #include #include #include +#include #include #include #include -#include - #include #include #include @@ -201,7 +200,7 @@ class stream_ordered_memory_resource : public crtp, public device_ */ void* do_allocate(std::size_t size, cuda_stream_view stream) override { - RMM_LOG_TRACE("[A][stream {:p}][{}B]", fmt::ptr(stream.value()), size); + RMM_LOG_TRACE("[A][stream %s][%zuB]", rmm::detail::format_stream(stream), size); if (size <= 0) { return nullptr; } @@ -215,10 +214,10 @@ class stream_ordered_memory_resource : public crtp, public device_ rmm::out_of_memory); auto const block = this->underlying().get_block(size, stream_event); - RMM_LOG_TRACE("[A][stream {:p}][{}B][{:p}]", - fmt::ptr(stream_event.stream), + RMM_LOG_TRACE("[A][stream %s][%zuB][%p]", + rmm::detail::format_stream(stream_event.stream), size, - fmt::ptr(block.pointer())); + block.pointer()); log_summary_trace(); @@ -234,7 +233,7 @@ class stream_ordered_memory_resource : public crtp, public device_ */ void do_deallocate(void* ptr, std::size_t size, cuda_stream_view stream) override { - RMM_LOG_TRACE("[D][stream {:p}][{}B][{:p}]", fmt::ptr(stream.value()), size, ptr); + RMM_LOG_TRACE("[D][stream %s][%zuB][%p]", rmm::detail::format_stream(stream), size, ptr); if (size <= 0 || ptr == nullptr) { return; } @@ -384,10 +383,10 @@ class stream_ordered_memory_resource : public crtp, public device_ if (merge_first) { merge_lists(stream_event, blocks, other_event, std::move(other_blocks)); - RMM_LOG_DEBUG("[A][Stream {:p}][{}B][Merged stream {:p}]", - fmt::ptr(stream_event.stream), + RMM_LOG_DEBUG("[A][Stream %s][%zuB][Merged stream %s]", + rmm::detail::format_stream(stream_event.stream), size, - fmt::ptr(iter->first.stream)); + rmm::detail::format_stream(iter->first.stream)); stream_free_blocks_.erase(iter); @@ -414,11 +413,11 @@ class stream_ordered_memory_resource : public crtp, public device_ block_type const block = find_block(iter); if (block.is_valid()) { - RMM_LOG_DEBUG((merge_first) ? "[A][Stream {:p}][{}B][Found after merging stream {:p}]" - : "[A][Stream {:p}][{}B][Taken from stream {:p}]", - fmt::ptr(stream_event.stream), + RMM_LOG_DEBUG((merge_first) ? "[A][Stream %s][%zuB][Found after merging stream %s]" + : "[A][Stream %s][%zuB][Taken from stream %s]", + rmm::detail::format_stream(stream_event.stream), size, - fmt::ptr(iter->first.stream)); + rmm::detail::format_stream(iter->first.stream)); return block; } } @@ -471,7 +470,7 @@ class stream_ordered_memory_resource : public crtp, public device_ max_block = std::max(summary.first, max_block); free_mem += summary.second; }); - RMM_LOG_TRACE("[Summary][Free lists: {}][Blocks: {}][Max Block: {}][Total Free: {}]", + RMM_LOG_TRACE("[Summary][Free lists: %zu][Blocks: %zu][Max Block: %zu][Total Free: %zu]", stream_free_blocks_.size(), num_blocks, max_block, diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 595ab2e4e..578543852 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -18,16 +18,17 @@ #include #include #include +#include #include #include -#include #include #include #include #include #include +#include #include #include #include @@ -297,10 +298,12 @@ class logging_resource_adaptor final : public device_memory_resource { { try { auto const ptr = get_upstream_resource().allocate_async(bytes, stream); - logger_->info("allocate,{},{},{}", ptr, bytes, fmt::ptr(stream.value())); + logger_->info(rmm::detail::formatted_log( + "allocate,%p,%zu,%s", ptr, bytes, rmm::detail::format_stream(stream))); return ptr; } catch (...) { - logger_->info("allocate failure,{},{},{}", nullptr, bytes, fmt::ptr(stream.value())); + logger_->info(rmm::detail::formatted_log( + "allocate failure,%p,%zu,%s", nullptr, bytes, rmm::detail::format_stream(stream))); throw; } } @@ -321,7 +324,8 @@ class logging_resource_adaptor final : public device_memory_resource { */ void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override { - logger_->info("free,{},{},{}", ptr, bytes, fmt::ptr(stream.value())); + logger_->info( + rmm::detail::formatted_log("free,%p,%zu,%s", ptr, bytes, rmm::detail::format_stream(stream))); get_upstream_resource().deallocate_async(ptr, bytes, stream); } diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index f63de21ff..037147de3 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -34,8 +35,6 @@ #include #include -#include - #include #include #include @@ -271,8 +270,8 @@ class pool_memory_resource final } try_size = std::max(min_size, try_size / 2); } - RMM_LOG_ERROR("[A][Stream {}][Upstream {}B][FAILURE maximum pool size exceeded]", - fmt::ptr(stream.value()), + RMM_LOG_ERROR("[A][Stream %s][Upstream %zuB][FAILURE maximum pool size exceeded]", + rmm::detail::format_stream(stream), min_size); RMM_FAIL("Maximum pool size exceeded", rmm::out_of_memory); } @@ -351,7 +350,7 @@ class pool_memory_resource final */ std::optional block_from_upstream(std::size_t size, cuda_stream_view stream) { - RMM_LOG_DEBUG("[A][Stream {}][Upstream {}B]", fmt::ptr(stream.value()), size); + RMM_LOG_DEBUG("[A][Stream %s][Upstream %zuB]", rmm::detail::format_stream(stream), size); if (size == 0) { return {}; } diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index 6a5916e5c..8131eef4d 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -23,8 +23,6 @@ #include #include -#include - #include #include #include @@ -188,7 +186,7 @@ class tracking_resource_adaptor final : public device_memory_resource { void log_outstanding_allocations() const { #if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_DEBUG - RMM_LOG_DEBUG("Outstanding Allocations: {}", get_outstanding_allocations_str()); + RMM_LOG_DEBUG("Outstanding Allocations: %s", get_outstanding_allocations_str()); #endif // SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_DEBUG } @@ -236,12 +234,12 @@ class tracking_resource_adaptor final : public device_memory_resource { // Ensure the allocation is found and the number of bytes match if (found == allocations_.end()) { - // Don't throw but log an error. Throwing in a descructor (or any noexcept) will call + // Don't throw but log an error. Throwing in a destructor (or any noexcept) will call // std::terminate RMM_LOG_ERROR( - "Deallocating a pointer that was not tracked. Ptr: {:p} [{}B], Current Num. Allocations: " - "{}", - fmt::ptr(ptr), + "Deallocating a pointer that was not tracked. Ptr: %p [%zuB], Current Num. Allocations: " + "%zu", + ptr, bytes, this->allocations_.size()); } else { @@ -250,10 +248,10 @@ class tracking_resource_adaptor final : public device_memory_resource { auto allocated_bytes = found->second.allocation_size; if (allocated_bytes != bytes) { - // Don't throw but log an error. Throwing in a descructor (or any noexcept) will call + // Don't throw but log an error. Throwing in a destructor (or any noexcept) will call // std::terminate RMM_LOG_ERROR( - "Alloc bytes ({}) and Dealloc bytes ({}) do not match", allocated_bytes, bytes); + "Alloc bytes (%zu) and Dealloc bytes (%zu) do not match", allocated_bytes, bytes); bytes = allocated_bytes; } diff --git a/tests/logger_tests.cpp b/tests/logger_tests.cpp index 643281d91..8a5d37be2 100644 --- a/tests/logger_tests.cpp +++ b/tests/logger_tests.cpp @@ -112,7 +112,6 @@ void expect_log_events(std::string const& filename, // EXPECT_EQ(expected.thread_id, actual.thread_id); // EXPECT_EQ(expected.stream, actual.stream); EXPECT_EQ(expected.act, actual.act); - // device_memory_resource automatically pads an allocation to a multiple of 8 bytes EXPECT_EQ(expected.size, actual.size); EXPECT_EQ(expected.pointer, actual.pointer); return true; diff --git a/tests/mr/device/arena_mr_tests.cpp b/tests/mr/device/arena_mr_tests.cpp index 95cc9c9c1..67f183a23 100644 --- a/tests/mr/device/arena_mr_tests.cpp +++ b/tests/mr/device/arena_mr_tests.cpp @@ -574,10 +574,10 @@ TEST_F(ArenaTest, DumpLogOnFailure) // NOLINT std::size_t num_threads{4}; threads.reserve(num_threads); for (std::size_t i = 0; i < num_threads; ++i) { - threads.emplace_back(std::thread([&] { + threads.emplace_back([&] { void* ptr = mr.allocate(32_KiB); mr.deallocate(ptr, 32_KiB); - })); + }); } for (auto& thread : threads) { diff --git a/tests/mr/device/callback_mr_tests.cpp b/tests/mr/device/callback_mr_tests.cpp index a56efa60c..a7f6ab7be 100644 --- a/tests/mr/device/callback_mr_tests.cpp +++ b/tests/mr/device/callback_mr_tests.cpp @@ -23,11 +23,11 @@ #include #include -#include #include #include #include +#include namespace rmm::test { namespace { @@ -78,8 +78,9 @@ TEST(CallbackTest, LoggingTest) auto* ptr = mr.allocate(size); mr.deallocate(ptr, size); - std::string output = testing::internal::GetCapturedStdout(); - std::string expect = fmt::format("Allocating {} bytes\nDeallocating {} bytes\n", size, size); + auto output = testing::internal::GetCapturedStdout(); + auto expect = std::string("Allocating ") + std::to_string(size) + " bytes\nDeallocating " + + std::to_string(size) + " bytes\n"; ASSERT_EQ(expect, output); } From c7fc01794a78ccb6b4dc173d4ed20db156ebb39a Mon Sep 17 00:00:00 2001 From: Mike Sarahan Date: Thu, 14 Nov 2024 15:11:20 -0600 Subject: [PATCH 498/675] adding telemetry (#1692) close #1691 Authors: - Mike Sarahan (https://github.com/msarahan) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1692 --- .github/workflows/pr.yaml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 4dfcaf1ae..6780298c3 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -19,6 +19,7 @@ jobs: - conda-python-build - conda-python-tests - docs-build + - telemetry-setup - wheel-build-cpp - wheel-build-python - wheel-tests @@ -28,7 +29,17 @@ jobs: if: always() with: needs: ${{ toJSON(needs) }} + telemetry-setup: + runs-on: ubuntu-latest + continue-on-error: true + env: + OTEL_SERVICE_NAME: "pr-rmm" + steps: + - name: Telemetry setup + uses: rapidsai/shared-actions/telemetry-dispatch-stash-base-env-vars@main changed-files: + needs: + - telemetry-setup secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-24.12 with: @@ -50,9 +61,12 @@ jobs: - '!img/**' checks: secrets: inherit + needs: + - telemetry-setup uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.12 with: enable_check_generated_files: false + ignored_pr_jobs: telemetry-summarize conda-cpp-build: needs: checks secrets: inherit @@ -114,6 +128,8 @@ jobs: script: ci/test_wheel.sh devcontainer: secrets: inherit + needs: + - telemetry-setup uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.12 with: arch: '["amd64"]' @@ -122,3 +138,18 @@ jobs: sccache -z; build-all -DBUILD_BENCHMARKS=ON --verbose; sccache -s; + + telemetry-summarize: + runs-on: ubuntu-latest + needs: pr-builder + if: always() + continue-on-error: true + steps: + - name: Load stashed telemetry env vars + uses: rapidsai/shared-actions/telemetry-dispatch-load-base-env-vars@main + with: + load_service_name: true + - name: Telemetry summarize + uses: rapidsai/shared-actions/telemetry-dispatch-write-summary@main + with: + cert_concat: "${{ secrets.OTEL_EXPORTER_OTLP_CA_CERTIFICATE }};${{ secrets.OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE }};${{ secrets.OTEL_EXPORTER_OTLP_CLIENT_KEY }}" From 96418d36eed56b63ae02fce0cd7a6880fba02030 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Fri, 15 Nov 2024 09:35:22 -0500 Subject: [PATCH 499/675] DOC v25.02 Updates [skip ci] --- .../cuda11.8-conda/devcontainer.json | 6 ++--- .devcontainer/cuda11.8-pip/devcontainer.json | 6 ++--- .../cuda12.5-conda/devcontainer.json | 6 ++--- .devcontainer/cuda12.5-pip/devcontainer.json | 6 ++--- .github/workflows/build.yaml | 16 ++++++------- .github/workflows/pr.yaml | 24 +++++++++---------- .github/workflows/test.yaml | 6 ++--- VERSION | 2 +- dependencies.yaml | 6 ++--- python/rmm/pyproject.toml | 2 +- 10 files changed, 40 insertions(+), 40 deletions(-) diff --git a/.devcontainer/cuda11.8-conda/devcontainer.json b/.devcontainer/cuda11.8-conda/devcontainer.json index 549ffa67b..cf93b101a 100644 --- a/.devcontainer/cuda11.8-conda/devcontainer.json +++ b/.devcontainer/cuda11.8-conda/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:24.12-cpp-cuda11.8-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.02-cpp-cuda11.8-mambaforge-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.12-cuda11.8-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.02-cuda11.8-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.12": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.2": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda11.8-pip/devcontainer.json b/.devcontainer/cuda11.8-pip/devcontainer.json index d6dd7b6ce..bd3aa8665 100644 --- a/.devcontainer/cuda11.8-pip/devcontainer.json +++ b/.devcontainer/cuda11.8-pip/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:24.12-cpp-cuda11.8-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.02-cpp-cuda11.8-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.12-cuda11.8-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.02-cuda11.8-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.12": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.2": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.5-conda/devcontainer.json b/.devcontainer/cuda12.5-conda/devcontainer.json index 17e8d5cd0..eba61f0b9 100644 --- a/.devcontainer/cuda12.5-conda/devcontainer.json +++ b/.devcontainer/cuda12.5-conda/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "12.5", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:24.12-cpp-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.02-cpp-mambaforge-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.12-cuda12.5-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.02-cuda12.5-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.12": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.2": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.5-pip/devcontainer.json b/.devcontainer/cuda12.5-pip/devcontainer.json index 54964d880..48aa3f083 100644 --- a/.devcontainer/cuda12.5-pip/devcontainer.json +++ b/.devcontainer/cuda12.5-pip/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "12.5", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:24.12-cpp-cuda12.5-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.02-cpp-cuda12.5-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-24.12-cuda12.5-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.02-cuda12.5-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:24.12": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.2": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6fa11225e..f7abc2d58 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-25.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build-cpp: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -79,7 +79,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -89,7 +89,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -100,7 +100,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 6780298c3..d0287319f 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -25,7 +25,7 @@ jobs: - wheel-tests - devcontainer secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-25.02 if: always() with: needs: ${{ toJSON(needs) }} @@ -41,7 +41,7 @@ jobs: needs: - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-25.02 with: files_yaml: | test_cpp: @@ -63,40 +63,40 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-25.02 with: enable_check_generated_files: false ignored_pr_jobs: telemetry-summarize conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.02 with: build_type: pull-request conda-cpp-tests: needs: [conda-cpp-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.02 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.02 with: build_type: pull-request conda-python-tests: needs: [conda-python-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.02 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.02 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -106,7 +106,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -114,14 +114,14 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 with: build_type: pull-request script: ci/build_wheel_python.sh wheel-tests: needs: [wheel-build-python, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.02 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request @@ -130,7 +130,7 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-25.02 with: arch: '["amd64"]' cuda: '["12.5"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 34a0f746d..b38c1e3cb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.02 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.02 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.02 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/VERSION b/VERSION index af28c42b5..72eefaf7c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -24.12.00 +25.02.00 diff --git a/dependencies.yaml b/dependencies.yaml index 3e2c2eb29..070248edb 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -163,15 +163,15 @@ dependencies: cuda: "12.*" cuda_suffixed: "true" packages: - - librmm-cu12==24.12.*,>=0.0.0a0 + - librmm-cu12==25.2.*,>=0.0.0a0 - matrix: cuda: "11.*" cuda_suffixed: "true" packages: - - librmm-cu11==24.12.*,>=0.0.0a0 + - librmm-cu11==25.2.*,>=0.0.0a0 - matrix: null packages: - - librmm==24.12.*,>=0.0.0a0 + - librmm==25.2.*,>=0.0.0a0 checks: common: - output_types: [conda, requirements] diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index aaaa15482..dfa680a98 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -130,7 +130,7 @@ requires = [ "cmake>=3.26.4,!=3.30.0", "cuda-python>=11.7.1,<12.0a0,<=11.8.3", "cython>=3.0.0", - "librmm==24.12.*,>=0.0.0a0", + "librmm==25.2.*,>=0.0.0a0", "ninja", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. From 929a595e639b61b583cc584b1c291f9559cef673 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 19 Nov 2024 09:51:53 -0500 Subject: [PATCH 500/675] Make `cudaMallocAsync` logic non-optional as we require CUDA 11.2+ (#1667) We can remove the optimizations around `CUDA_STATIC_RUNTIME` and instead see if the function is already in the process space so that RMM doesn't need to have any build context to run properly Fixes #1679 Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Mark Harris (https://github.com/harrism) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1667 --- CMakeLists.txt | 1 - .../multi_stream_allocations_bench.cu | 6 - .../random_allocations/random_allocations.cpp | 6 - include/rmm/detail/dynamic_load_runtime.hpp | 191 ------------------ include/rmm/detail/runtime_async_alloc.hpp | 79 ++++++++ .../mr/device/cuda_async_memory_resource.hpp | 54 ++--- .../cuda_async_view_memory_resource.hpp | 32 +-- python/rmm/rmm/tests/test_rmm.py | 34 +--- tests/CMakeLists.txt | 17 +- tests/mr/device/cuda_async_mr_tests.cpp | 17 +- tests/mr/device/cuda_async_view_mr_tests.cpp | 13 +- .../mr/device/mr_ref_multithreaded_tests.cpp | 16 +- tests/mr/device/mr_ref_test.hpp | 2 +- tests/mr/device/mr_ref_tests.cpp | 4 - tests/mr/device/thrust_allocator_tests.cu | 16 +- tests/prefetch_tests.cpp | 2 +- 16 files changed, 131 insertions(+), 359 deletions(-) delete mode 100644 include/rmm/detail/dynamic_load_runtime.hpp create mode 100644 include/rmm/detail/runtime_async_alloc.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 44d7fbb79..07bd368ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,7 +89,6 @@ target_include_directories(rmm INTERFACE "$Apply(benchmark_range); return; } -#endif if (name == "pool") { BENCHMARK_CAPTURE(BM_MultiStreamAllocations, pool_mr, &make_pool) // @@ -248,9 +244,7 @@ int main(int argc, char** argv) resource_names.emplace_back(args["resource"].as()); } else { resource_names.emplace_back("cuda"); -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT resource_names.emplace_back("cuda_async"); -#endif resource_names.emplace_back("pool"); resource_names.emplace_back("arena"); resource_names.emplace_back("binning"); diff --git a/benchmarks/random_allocations/random_allocations.cpp b/benchmarks/random_allocations/random_allocations.cpp index 57116743b..2971f7e40 100644 --- a/benchmarks/random_allocations/random_allocations.cpp +++ b/benchmarks/random_allocations/random_allocations.cpp @@ -316,9 +316,7 @@ int main(int argc, char** argv) std::map const funcs({{"arena", &make_arena}, {"binning", &make_binning}, {"cuda", &make_cuda}, -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT {"cuda_async", &make_cuda_async}, -#endif {"pool", &make_pool}}); auto resource = args["resource"].as(); @@ -340,11 +338,7 @@ int main(int argc, char** argv) std::string mr_name = args["resource"].as(); declare_benchmark(mr_name); } else { -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT std::vector mrs{"pool", "binning", "arena", "cuda_async", "cuda"}; -#else - std::vector mrs{"pool", "binning", "arena", "cuda"}; -#endif std::for_each( std::cbegin(mrs), std::cend(mrs), [](auto const& mr) { declare_benchmark(mr); }); } diff --git a/include/rmm/detail/dynamic_load_runtime.hpp b/include/rmm/detail/dynamic_load_runtime.hpp deleted file mode 100644 index 214228752..000000000 --- a/include/rmm/detail/dynamic_load_runtime.hpp +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 2022-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. - */ -#pragma once - -#include -#include - -#include - -#include - -#include -#include - -namespace RMM_NAMESPACE { -namespace detail { - -/** - * @brief `dynamic_load_runtime` loads the cuda runtime library at runtime - * - * By loading the cudart library at runtime we can use functions that - * are added in newer minor versions of the cuda runtime. - */ -struct dynamic_load_runtime { - static void* get_cuda_runtime_handle() - { - auto close_cudart = [](void* handle) { ::dlclose(handle); }; - auto open_cudart = []() { - ::dlerror(); - const int major = CUDART_VERSION / 1000; - - // In CUDA 12 the SONAME is correctly defined as libcudart.12, but for - // CUDA<=11 it includes an extra 0 minor version e.g. libcudart.11.0. We - // also allow finding the linker name. - const std::string libname_ver_cuda_11 = "libcudart.so." + std::to_string(major) + ".0"; - const std::string libname_ver_cuda_12 = "libcudart.so." + std::to_string(major); - const std::string libname = "libcudart.so"; - - void* ptr = nullptr; - for (auto&& name : {libname_ver_cuda_12, libname_ver_cuda_11, libname}) { - ptr = dlopen(name.c_str(), RTLD_LAZY); - if (ptr != nullptr) break; - } - - if (ptr != nullptr) { return ptr; } - - RMM_FAIL("Unable to dlopen cudart"); - }; - static std::unique_ptr cudart_handle{open_cudart(), close_cudart}; - return cudart_handle.get(); - } - - template - using function_sig = std::add_pointer_t; - - template - static std::optional function(const char* func_name) - { - auto* runtime = get_cuda_runtime_handle(); - auto* handle = ::dlsym(runtime, func_name); - if (!handle) { return std::nullopt; } - auto* function_ptr = reinterpret_cast(handle); - return std::optional(function_ptr); - } -}; - -#if defined(RMM_STATIC_CUDART) -// clang-format off -#define RMM_CUDART_API_WRAPPER(name, signature) \ - template \ - static cudaError_t name(Args... args) \ - { \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Waddress\"") \ - static_assert(static_cast(::name), \ - "Failed to find #name function with arguments #signature"); \ - _Pragma("GCC diagnostic pop") \ - return ::name(args...); \ - } -// clang-format on -#else -#define RMM_CUDART_API_WRAPPER(name, signature) \ - template \ - static cudaError_t name(Args... args) \ - { \ - static const auto func = dynamic_load_runtime::function(#name); \ - if (func) { return (*func)(args...); } \ - RMM_FAIL("Failed to find #name function in libcudart.so"); \ - } -#endif - -#if CUDART_VERSION >= 11020 // 11.2 introduced cudaMallocAsync -/** - * @brief Bind to the stream-ordered memory allocator functions - * at runtime. - * - * This allows RMM users to compile/link against CUDA 11.2+ and run with - * < CUDA 11.2 runtime as these functions are found at call time. - */ -struct async_alloc { - static bool is_supported() - { -#if defined(RMM_STATIC_CUDART) - static bool runtime_supports_pool = (CUDART_VERSION >= 11020); -#else - static bool runtime_supports_pool = - dynamic_load_runtime::function>( - "cudaFreeAsync") - .has_value(); -#endif - - static auto driver_supports_pool{[] { - int cuda_pool_supported{}; - auto result = cudaDeviceGetAttribute(&cuda_pool_supported, - cudaDevAttrMemoryPoolsSupported, - rmm::get_current_cuda_device().value()); - return result == cudaSuccess and cuda_pool_supported == 1; - }()}; - return runtime_supports_pool and driver_supports_pool; - } - - /** - * @brief Check whether the specified `cudaMemAllocationHandleType` is supported on the present - * CUDA driver/runtime version. - * - * @note This query was introduced in CUDA 11.3 so on CUDA 11.2 this function will only return - * true for `cudaMemHandleTypeNone`. - * - * @param handle_type An IPC export handle type to check for support. - * @return true if supported - * @return false if unsupported - */ - static bool is_export_handle_type_supported(cudaMemAllocationHandleType handle_type) - { - int supported_handle_types_bitmask{}; -#if CUDART_VERSION >= 11030 // 11.3 introduced cudaDevAttrMemoryPoolSupportedHandleTypes - if (cudaMemHandleTypeNone != handle_type) { - auto const result = cudaDeviceGetAttribute(&supported_handle_types_bitmask, - cudaDevAttrMemoryPoolSupportedHandleTypes, - rmm::get_current_cuda_device().value()); - - // Don't throw on cudaErrorInvalidValue - auto const unsupported_runtime = (result == cudaErrorInvalidValue); - if (unsupported_runtime) return false; - // throw any other error that may have occurred - RMM_CUDA_TRY(result); - } - -#endif - return (supported_handle_types_bitmask & handle_type) == handle_type; - } - - template - using cudart_sig = dynamic_load_runtime::function_sig; - - using cudaMemPoolCreate_sig = cudart_sig; - RMM_CUDART_API_WRAPPER(cudaMemPoolCreate, cudaMemPoolCreate_sig); - - using cudaMemPoolSetAttribute_sig = cudart_sig; - RMM_CUDART_API_WRAPPER(cudaMemPoolSetAttribute, cudaMemPoolSetAttribute_sig); - - using cudaMemPoolDestroy_sig = cudart_sig; - RMM_CUDART_API_WRAPPER(cudaMemPoolDestroy, cudaMemPoolDestroy_sig); - - using cudaMallocFromPoolAsync_sig = cudart_sig; - RMM_CUDART_API_WRAPPER(cudaMallocFromPoolAsync, cudaMallocFromPoolAsync_sig); - - using cudaFreeAsync_sig = cudart_sig; - RMM_CUDART_API_WRAPPER(cudaFreeAsync, cudaFreeAsync_sig); - - using cudaDeviceGetDefaultMemPool_sig = cudart_sig; - RMM_CUDART_API_WRAPPER(cudaDeviceGetDefaultMemPool, cudaDeviceGetDefaultMemPool_sig); -}; -#endif - -#undef RMM_CUDART_API_WRAPPER -} // namespace detail -} // namespace RMM_NAMESPACE diff --git a/include/rmm/detail/runtime_async_alloc.hpp b/include/rmm/detail/runtime_async_alloc.hpp new file mode 100644 index 000000000..6ddb2228b --- /dev/null +++ b/include/rmm/detail/runtime_async_alloc.hpp @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2022-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. + */ +#pragma once + +#include +#include + +#include + +#include + +#include +#include + +namespace RMM_NAMESPACE { +namespace detail { + +/** + * @brief Determine at runtime if the CUDA driver supports the stream-ordered + * memory allocator functions. + * + * This allows RMM users to compile/link against CUDA 11.2+ and run with + * older drivers. + */ + +struct runtime_async_alloc { + static bool is_supported() + { + static auto driver_supports_pool{[] { + int cuda_pool_supported{}; + auto result = cudaDeviceGetAttribute(&cuda_pool_supported, + cudaDevAttrMemoryPoolsSupported, + rmm::get_current_cuda_device().value()); + return result == cudaSuccess and cuda_pool_supported == 1; + }()}; + return driver_supports_pool; + } + + /** + * @brief Check whether the specified `cudaMemAllocationHandleType` is supported on the present + * CUDA driver/runtime version. + * + * @param handle_type An IPC export handle type to check for support. + * @return true if supported + * @return false if unsupported + */ + static bool is_export_handle_type_supported(cudaMemAllocationHandleType handle_type) + { + int supported_handle_types_bitmask{}; + if (cudaMemHandleTypeNone != handle_type) { + auto const result = cudaDeviceGetAttribute(&supported_handle_types_bitmask, + cudaDevAttrMemoryPoolSupportedHandleTypes, + rmm::get_current_cuda_device().value()); + + // Don't throw on cudaErrorInvalidValue + auto const unsupported_runtime = (result == cudaErrorInvalidValue); + if (unsupported_runtime) return false; + // throw any other error that may have occurred + RMM_CUDA_TRY(result); + } + return (supported_handle_types_bitmask & handle_type) == handle_type; + } +}; + +} // namespace detail +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 52fd2fe4e..b1fc0b112 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -17,9 +17,9 @@ #include #include -#include #include #include +#include #include #include #include @@ -31,12 +31,6 @@ #include #include -#if CUDART_VERSION >= 11020 // 11.2 introduced cudaMallocAsync -#ifndef RMM_DISABLE_CUDA_MALLOC_ASYNC -#define RMM_CUDA_MALLOC_ASYNC_SUPPORT -#endif -#endif - namespace RMM_NAMESPACE { namespace mr { /** @@ -91,9 +85,8 @@ class cuda_async_memory_resource final : public device_memory_resource { std::optional release_threshold = {}, std::optional export_handle_type = {}) { -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT // Check if cudaMallocAsync Memory pool supported - RMM_EXPECTS(rmm::detail::async_alloc::is_supported(), + RMM_EXPECTS(rmm::detail::runtime_async_alloc::is_supported(), "cudaMallocAsync not supported with this CUDA driver/runtime version"); // Construct explicit pool @@ -101,12 +94,13 @@ class cuda_async_memory_resource final : public device_memory_resource { pool_props.allocType = cudaMemAllocationTypePinned; pool_props.handleTypes = static_cast( export_handle_type.value_or(allocation_handle_type::none)); - RMM_EXPECTS(rmm::detail::async_alloc::is_export_handle_type_supported(pool_props.handleTypes), - "Requested IPC memory handle type not supported"); + RMM_EXPECTS( + rmm::detail::runtime_async_alloc::is_export_handle_type_supported(pool_props.handleTypes), + "Requested IPC memory handle type not supported"); pool_props.location.type = cudaMemLocationTypeDevice; pool_props.location.id = rmm::get_current_cuda_device().value(); cudaMemPool_t cuda_pool_handle{}; - RMM_CUDA_TRY(rmm::detail::async_alloc::cudaMemPoolCreate(&cuda_pool_handle, &pool_props)); + RMM_CUDA_TRY(cudaMemPoolCreate(&cuda_pool_handle, &pool_props)); pool_ = cuda_async_view_memory_resource{cuda_pool_handle}; // CUDA drivers before 11.5 have known incompatibilities with the async allocator. @@ -117,41 +111,34 @@ class cuda_async_memory_resource final : public device_memory_resource { constexpr auto min_async_version{11050}; if (driver_version < min_async_version) { int disabled{0}; - RMM_CUDA_TRY(rmm::detail::async_alloc::cudaMemPoolSetAttribute( - pool_handle(), cudaMemPoolReuseAllowOpportunistic, &disabled)); + RMM_CUDA_TRY( + cudaMemPoolSetAttribute(pool_handle(), cudaMemPoolReuseAllowOpportunistic, &disabled)); } auto const [free, total] = rmm::available_device_memory(); // Need an l-value to take address to pass to cudaMemPoolSetAttribute uint64_t threshold = release_threshold.value_or(total); - RMM_CUDA_TRY(rmm::detail::async_alloc::cudaMemPoolSetAttribute( - pool_handle(), cudaMemPoolAttrReleaseThreshold, &threshold)); + RMM_CUDA_TRY( + cudaMemPoolSetAttribute(pool_handle(), cudaMemPoolAttrReleaseThreshold, &threshold)); // Allocate and immediately deallocate the initial_pool_size to prime the pool with the // specified size auto const pool_size = initial_pool_size.value_or(free / 2); auto* ptr = do_allocate(pool_size, cuda_stream_default); do_deallocate(ptr, pool_size, cuda_stream_default); -#else - RMM_FAIL( - "cudaMallocAsync not supported by the version of the CUDA Toolkit used for this build"); -#endif } -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT /** * @brief Returns the underlying native handle to the CUDA pool * + * @return cudaMemPool_t Handle to the underlying CUDA pool */ [[nodiscard]] cudaMemPool_t pool_handle() const noexcept { return pool_.pool_handle(); } -#endif ~cuda_async_memory_resource() override { -#if defined(RMM_CUDA_MALLOC_ASYNC_SUPPORT) - RMM_ASSERT_CUDA_SUCCESS(rmm::detail::async_alloc::cudaMemPoolDestroy(pool_handle())); -#endif + RMM_ASSERT_CUDA_SUCCESS(cudaMemPoolDestroy(pool_handle())); } cuda_async_memory_resource(cuda_async_memory_resource const&) = delete; cuda_async_memory_resource(cuda_async_memory_resource&&) = delete; @@ -159,9 +146,7 @@ class cuda_async_memory_resource final : public device_memory_resource { cuda_async_memory_resource& operator=(cuda_async_memory_resource&&) = delete; private: -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT cuda_async_view_memory_resource pool_{}; -#endif /** * @brief Allocates memory of size at least \p bytes. @@ -175,12 +160,7 @@ class cuda_async_memory_resource final : public device_memory_resource { void* do_allocate(std::size_t bytes, rmm::cuda_stream_view stream) override { void* ptr{nullptr}; -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT ptr = pool_.allocate(bytes, stream); -#else - (void)bytes; - (void)stream; -#endif return ptr; } @@ -194,13 +174,7 @@ class cuda_async_memory_resource final : public device_memory_resource { */ void do_deallocate(void* ptr, std::size_t bytes, rmm::cuda_stream_view stream) override { -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT pool_.deallocate(ptr, bytes, stream); -#else - (void)ptr; - (void)bytes; - (void)stream; -#endif } /** @@ -213,11 +187,7 @@ class cuda_async_memory_resource final : public device_memory_resource { [[nodiscard]] bool do_is_equal(device_memory_resource const& other) const noexcept override { auto const* async_mr = dynamic_cast(&other); -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT return (async_mr != nullptr) && (this->pool_handle() == async_mr->pool_handle()); -#else - return async_mr != nullptr; -#endif } }; diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index 3e1900e72..180c412ee 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -17,7 +17,6 @@ #include #include -#include #include #include #include @@ -28,10 +27,6 @@ #include #include -#if CUDART_VERSION >= 11020 // 11.2 introduced cudaMallocAsync -#define RMM_CUDA_MALLOC_ASYNC_SUPPORT -#endif - namespace RMM_NAMESPACE { namespace mr { /** @@ -46,13 +41,12 @@ namespace mr { */ class cuda_async_view_memory_resource final : public device_memory_resource { public: -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT /** * @brief Constructs a cuda_async_view_memory_resource which uses an existing CUDA memory pool. * The provided pool is not owned by cuda_async_view_memory_resource and must remain valid * during the lifetime of the memory resource. * - * @throws rmm::runtime_error if the CUDA version does not support `cudaMallocAsync` + * @throws rmm::logic_error if the CUDA version does not support `cudaMallocAsync` * * @param valid_pool_handle Handle to a CUDA memory pool which will be used to * serve allocation requests. @@ -71,15 +65,13 @@ class cuda_async_view_memory_resource final : public device_memory_resource { RMM_EXPECTS(result == cudaSuccess && cuda_pool_supported, "cudaMallocAsync not supported with this CUDA driver/runtime version"); } -#endif -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT /** * @brief Returns the underlying native handle to the CUDA pool * + * @return cudaMemPool_t Handle to the underlying CUDA pool */ [[nodiscard]] cudaMemPool_t pool_handle() const noexcept { return cuda_pool_handle_; } -#endif cuda_async_view_memory_resource() = default; cuda_async_view_memory_resource(cuda_async_view_memory_resource const&) = @@ -92,9 +84,7 @@ class cuda_async_view_memory_resource final : public device_memory_resource { default; ///< @default_move_assignment{cuda_async_view_memory_resource} private: -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT cudaMemPool_t cuda_pool_handle_{}; -#endif /** * @brief Allocates memory of size at least \p bytes. @@ -108,15 +98,9 @@ class cuda_async_view_memory_resource final : public device_memory_resource { void* do_allocate(std::size_t bytes, rmm::cuda_stream_view stream) override { void* ptr{nullptr}; -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT if (bytes > 0) { - RMM_CUDA_TRY_ALLOC(rmm::detail::async_alloc::cudaMallocFromPoolAsync( - &ptr, bytes, pool_handle(), stream.value())); + RMM_CUDA_TRY_ALLOC(cudaMallocFromPoolAsync(&ptr, bytes, pool_handle(), stream.value())); } -#else - (void)bytes; - (void)stream; -#endif return ptr; } @@ -132,15 +116,7 @@ class cuda_async_view_memory_resource final : public device_memory_resource { [[maybe_unused]] std::size_t bytes, rmm::cuda_stream_view stream) override { -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT - if (ptr != nullptr) { - RMM_ASSERT_CUDA_SUCCESS(rmm::detail::async_alloc::cudaFreeAsync(ptr, stream.value())); - } -#else - (void)ptr; - (void)bytes; - (void)stream; -#endif + if (ptr != nullptr) { RMM_ASSERT_CUDA_SUCCESS(cudaFreeAsync(ptr, stream.value())); } } /** diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index b52ea0179..d7d692287 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -32,12 +32,6 @@ cuda.set_memory_manager(RMMNumbaManager) -_driver_version = rmm._cuda.gpu.driverGetVersion() -_runtime_version = rmm._cuda.gpu.runtimeGetVersion() -_CUDAMALLOC_ASYNC_SUPPORTED = (_driver_version >= 11020) and ( - _runtime_version >= 11020 -) - _SYSTEM_MEMORY_SUPPORTED = rmm._cuda.gpu.getDeviceAttribute( cudart.cudaDeviceAttr.cudaDevAttrPageableMemoryAccess, rmm._cuda.gpu.getDevice(), @@ -657,10 +651,6 @@ def test_mr_upstream_lifetime(): del pool_mr -@pytest.mark.skipif( - not _CUDAMALLOC_ASYNC_SUPPORTED, - reason="cudaMallocAsync not supported", -) @pytest.mark.parametrize("dtype", _dtypes) @pytest.mark.parametrize("nelem", _nelems) @pytest.mark.parametrize("alloc", _allocs) @@ -671,15 +661,11 @@ def test_cuda_async_memory_resource(dtype, nelem, alloc): array_tester(dtype, nelem, alloc) -@pytest.mark.skipif( - not _CUDAMALLOC_ASYNC_SUPPORTED, - reason="cudaMallocAsync not supported", -) def test_cuda_async_memory_resource_ipc(): # TODO: We don't have a great way to check if IPC is supported in Python, # without using the C++ function - # rmm::detail::async_alloc::is_export_handle_type_supported. We can't - # accurately test driver and runtime versions for this via Python because + # rmm::detail::runtime_async_alloc::is_export_handle_type_supported. + # We can't accurately test this via Python because # cuda-python always has the IPC handle enum defined (which normally # requires a CUDA 11.3 runtime) and the cuda-compat package in Docker # containers prevents us from assuming that the driver we see actually @@ -702,10 +688,6 @@ def test_cuda_async_memory_resource_ipc(): assert rmm.mr.get_current_device_resource_type() is type(mr) -@pytest.mark.skipif( - not _CUDAMALLOC_ASYNC_SUPPORTED, - reason="cudaMallocAsync not supported", -) @pytest.mark.parametrize("nelems", _nelems) def test_cuda_async_memory_resource_stream(nelems): # test that using CudaAsyncMemoryResource @@ -719,10 +701,6 @@ def test_cuda_async_memory_resource_stream(nelems): np.testing.assert_equal(expected, result) -@pytest.mark.skipif( - not _CUDAMALLOC_ASYNC_SUPPORTED, - reason="cudaMallocAsync not supported", -) @pytest.mark.parametrize("nelem", _nelems) @pytest.mark.parametrize("alloc", _allocs) def test_cuda_async_memory_resource_threshold(nelem, alloc): @@ -739,13 +717,7 @@ def test_cuda_async_memory_resource_threshold(nelem, alloc): "mr", [ rmm.mr.CudaMemoryResource, - pytest.param( - rmm.mr.CudaAsyncMemoryResource, - marks=pytest.mark.skipif( - not _CUDAMALLOC_ASYNC_SUPPORTED, - reason="cudaMallocAsync not supported", - ), - ), + pytest.param(rmm.mr.CudaAsyncMemoryResource), ], ) def test_limiting_resource_adaptor(mr): diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a482c8cc1..476028af0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -84,7 +84,7 @@ endfunction() function(ConfigureTest TEST_NAME) set(options) - set(one_value GPUS PERCENT) + set(one_value CUDART GPUS PERCENT) set(multi_value) cmake_parse_arguments(_RMM_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN}) if(NOT DEFINED _RMM_TEST_GPUS AND NOT DEFINED _RMM_TEST_PERCENT) @@ -98,13 +98,23 @@ function(ConfigureTest TEST_NAME) set(_RMM_TEST_PERCENT 100) endif() + if(_RMM_TEST_CUDART STREQUAL SHARED) + set(cudart_link_libs $ CUDA::cudart) + elseif(_RMM_TEST_CUDART STREQUAL STATIC) + set(cudart_link_libs $ CUDA::cudart_static) + else() + set(cudart_link_libs rmm) + endif() + # Test with legacy default stream. ConfigureTestInternal(${TEST_NAME} ${_RMM_TEST_UNPARSED_ARGUMENTS}) + target_link_libraries(${TEST_NAME} ${cudart_link_libs}) # Test with per-thread default stream. string(REGEX REPLACE "_TEST$" "_PTDS_TEST" PTDS_TEST_NAME "${TEST_NAME}") ConfigureTestInternal("${PTDS_TEST_NAME}" ${_RMM_TEST_UNPARSED_ARGUMENTS}) target_compile_definitions("${PTDS_TEST_NAME}" PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM) + target_link_libraries(${PTDS_TEST_NAME} ${cudart_link_libs}) foreach(name ${TEST_NAME} ${PTDS_TEST_NAME} ${NS_TEST_NAME}) rapids_test_add( @@ -130,7 +140,10 @@ ConfigureTest(ADAPTOR_TEST mr/device/adaptor_tests.cpp) ConfigureTest(POOL_MR_TEST mr/device/pool_mr_tests.cpp GPUS 1 PERCENT 100) # cuda_async mr tests -ConfigureTest(CUDA_ASYNC_MR_TEST mr/device/cuda_async_mr_tests.cpp GPUS 1 PERCENT 60) +ConfigureTest(CUDA_ASYNC_MR_STATIC_CUDART_TEST mr/device/cuda_async_mr_tests.cpp GPUS 1 PERCENT 60 + CUDART STATIC) +ConfigureTest(CUDA_ASYNC_MR_SHARED_CUDART_TEST mr/device/cuda_async_mr_tests.cpp GPUS 1 PERCENT 60 + CUDART SHARED) # thrust allocator tests ConfigureTest(THRUST_ALLOCATOR_TEST mr/device/thrust_allocator_tests.cu GPUS 1 PERCENT 60) diff --git a/tests/mr/device/cuda_async_mr_tests.cpp b/tests/mr/device/cuda_async_mr_tests.cpp index 90c7b0ff9..a39188548 100644 --- a/tests/mr/device/cuda_async_mr_tests.cpp +++ b/tests/mr/device/cuda_async_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2021-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. @@ -31,24 +31,13 @@ class AsyncMRTest : public ::testing::Test { protected: void SetUp() override { - if (!rmm::detail::async_alloc::is_supported()) { + if (!rmm::detail::runtime_async_alloc::is_supported()) { GTEST_SKIP() << "Skipping tests since cudaMallocAsync not supported with this CUDA " << "driver/runtime version"; } } }; -TEST_F(AsyncMRTest, ThrowIfNotSupported) -{ - auto construct_mr = []() { cuda_async_mr mr; }; -#ifndef RMM_CUDA_MALLOC_ASYNC_SUPPORT - EXPECT_THROW(construct_mr(), rmm::logic_error); -#else - EXPECT_NO_THROW(construct_mr()); -#endif -} - -#if defined(RMM_CUDA_MALLOC_ASYNC_SUPPORT) TEST_F(AsyncMRTest, ExplicitInitialPoolSize) { const auto pool_init_size{100}; @@ -77,7 +66,5 @@ TEST_F(AsyncMRTest, DifferentPoolsUnequal) EXPECT_FALSE(mr1.is_equal(mr2)); } -#endif - } // namespace } // namespace rmm::test diff --git a/tests/mr/device/cuda_async_view_mr_tests.cpp b/tests/mr/device/cuda_async_view_mr_tests.cpp index fe82431a9..f3a02cbf0 100644 --- a/tests/mr/device/cuda_async_view_mr_tests.cpp +++ b/tests/mr/device/cuda_async_view_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-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. @@ -29,13 +29,10 @@ using cuda_async_view_mr = rmm::mr::cuda_async_view_memory_resource; static_assert(cuda::mr::resource_with); static_assert(cuda::mr::async_resource_with); -#if defined(RMM_CUDA_MALLOC_ASYNC_SUPPORT) - TEST(PoolTest, UsePool) { cudaMemPool_t memPool{}; - RMM_CUDA_TRY(rmm::detail::async_alloc::cudaDeviceGetDefaultMemPool( - &memPool, rmm::get_current_cuda_device().value())); + RMM_CUDA_TRY(cudaDeviceGetDefaultMemPool(&memPool, rmm::get_current_cuda_device().value())); const auto pool_init_size{100}; cuda_async_view_mr mr{memPool}; @@ -53,7 +50,7 @@ TEST(PoolTest, NotTakingOwnershipOfPool) cudaMemPool_t memPool{}; - RMM_CUDA_TRY(rmm::detail::async_alloc::cudaMemPoolCreate(&memPool, &poolProps)); + RMM_CUDA_TRY(cudaMemPoolCreate(&memPool, &poolProps)); { const auto pool_init_size{100}; @@ -64,7 +61,7 @@ TEST(PoolTest, NotTakingOwnershipOfPool) } auto destroy_valid_pool = [&]() { - auto result = rmm::detail::async_alloc::cudaMemPoolDestroy(memPool); + auto result = cudaMemPoolDestroy(memPool); RMM_EXPECTS(result == cudaSuccess, "Pool wrapper did destroy pool"); }; @@ -81,7 +78,5 @@ TEST(PoolTest, ThrowIfNullptrPool) EXPECT_THROW(construct_mr(), rmm::logic_error); } -#endif - } // namespace } // namespace rmm::test diff --git a/tests/mr/device/mr_ref_multithreaded_tests.cpp b/tests/mr/device/mr_ref_multithreaded_tests.cpp index 944ba1807..9e7c8c2e8 100644 --- a/tests/mr/device/mr_ref_multithreaded_tests.cpp +++ b/tests/mr/device/mr_ref_multithreaded_tests.cpp @@ -36,17 +36,11 @@ namespace { struct mr_ref_test_mt : public mr_ref_test {}; -INSTANTIATE_TEST_CASE_P(MultiThreadResourceTests, - mr_ref_test_mt, - ::testing::Values("CUDA", -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT - "CUDA_Async", -#endif - "Managed", - "Pool", - "Arena", - "Binning"), - [](auto const& info) { return info.param; }); +INSTANTIATE_TEST_CASE_P( + MultiThreadResourceTests, + mr_ref_test_mt, + ::testing::Values("CUDA", "CUDA_Async", "Managed", "Pool", "Arena", "Binning"), + [](auto const& info) { return info.param; }); template void spawn_n(std::size_t num_threads, Task task, Arguments&&... args) diff --git a/tests/mr/device/mr_ref_test.hpp b/tests/mr/device/mr_ref_test.hpp index 6e63b3838..2af0eff44 100644 --- a/tests/mr/device/mr_ref_test.hpp +++ b/tests/mr/device/mr_ref_test.hpp @@ -347,7 +347,7 @@ inline auto make_host_pinned() { return std::make_shared(); } return std::shared_ptr{nullptr}; diff --git a/tests/mr/device/mr_ref_tests.cpp b/tests/mr/device/mr_ref_tests.cpp index 55e91d765..41af050a0 100644 --- a/tests/mr/device/mr_ref_tests.cpp +++ b/tests/mr/device/mr_ref_tests.cpp @@ -30,9 +30,7 @@ namespace { INSTANTIATE_TEST_SUITE_P(ResourceTests, mr_ref_test, ::testing::Values("CUDA", -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT "CUDA_Async", -#endif "Managed", "System", "Pool", @@ -46,9 +44,7 @@ INSTANTIATE_TEST_SUITE_P(ResourceTests, INSTANTIATE_TEST_SUITE_P(ResourceAllocationTests, mr_ref_allocation_test, ::testing::Values("CUDA", -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT "CUDA_Async", -#endif "Managed", "System" "Pool", diff --git a/tests/mr/device/thrust_allocator_tests.cu b/tests/mr/device/thrust_allocator_tests.cu index 84f599957..46447aa09 100644 --- a/tests/mr/device/thrust_allocator_tests.cu +++ b/tests/mr/device/thrust_allocator_tests.cu @@ -69,17 +69,11 @@ TEST_P(allocator_test, multi_device) }()); } -INSTANTIATE_TEST_CASE_P(ThrustAllocatorTests, - allocator_test, - ::testing::Values("CUDA", -#ifdef RMM_CUDA_MALLOC_ASYNC_SUPPORT - "CUDA_Async", -#endif - "Managed", - "Pool", - "Arena", - "Binning"), - [](auto const& info) { return info.param; }); +INSTANTIATE_TEST_CASE_P( + ThrustAllocatorTests, + allocator_test, + ::testing::Values("CUDA", "CUDA_Async", "Managed", "Pool", "Arena", "Binning"), + [](auto const& info) { return info.param; }); } // namespace } // namespace rmm::test diff --git a/tests/prefetch_tests.cpp b/tests/prefetch_tests.cpp index 6c7bb2dd3..4a2c41a2b 100644 --- a/tests/prefetch_tests.cpp +++ b/tests/prefetch_tests.cpp @@ -53,8 +53,8 @@ struct PrefetchTest : public ::testing::Test { // https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g8048f6ea5ad77917444567656c140c5a // specifically for when cudaMemRangeAttribute::cudaMemRangeAttributeLastPrefetchLocation is // used. - constexpr size_t prefetch_data_size = 4; if constexpr (std::is_same_v) { + constexpr size_t prefetch_data_size = 4; int prefetch_location{0}; RMM_CUDA_TRY( cudaMemRangeGetAttribute(&prefetch_location, From 3b5f6af2eaa0519643ccc2a4c1395307bfd3ad7e Mon Sep 17 00:00:00 2001 From: Mark Harris <783069+harrism@users.noreply.github.com> Date: Wed, 20 Nov 2024 12:22:49 +1100 Subject: [PATCH 501/675] Query total memory in failure_callback_resource_adaptor tests (#1734) Fixes #1733 by querying total device memory and using twice as much in tests that are expected to fail allocation. Authors: - Mark Harris (https://github.com/harrism) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1734 --- python/rmm/rmm/tests/test_rmm.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index d7d692287..182434dc5 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -795,10 +795,28 @@ def callback(nbytes: int) -> bool: rmm.mr.set_current_device_resource(mr) with pytest.raises(MemoryError): - rmm.DeviceBuffer(size=int(1e11)) + from rmm.mr import available_device_memory + + total_memory = available_device_memory()[1] + rmm.DeviceBuffer(size=total_memory * 2) assert retried[0] +def test_failure_callback_resource_adaptor_error(): + def callback(nbytes: int) -> bool: + raise RuntimeError("MyError") + + cuda_mr = rmm.mr.CudaMemoryResource() + mr = rmm.mr.FailureCallbackResourceAdaptor(cuda_mr, callback) + rmm.mr.set_current_device_resource(mr) + + with pytest.raises(RuntimeError, match="MyError"): + from rmm.mr import available_device_memory + + total_memory = available_device_memory()[1] + rmm.DeviceBuffer(size=total_memory * 2) + + @pytest.mark.parametrize("managed", [True, False]) def test_prefetch_resource_adaptor(managed): if managed: @@ -823,18 +841,6 @@ def test_prefetch_resource_adaptor(managed): assert_prefetched(db, device) -def test_failure_callback_resource_adaptor_error(): - def callback(nbytes: int) -> bool: - raise RuntimeError("MyError") - - cuda_mr = rmm.mr.CudaMemoryResource() - mr = rmm.mr.FailureCallbackResourceAdaptor(cuda_mr, callback) - rmm.mr.set_current_device_resource(mr) - - with pytest.raises(RuntimeError, match="MyError"): - rmm.DeviceBuffer(size=int(1e11)) - - def test_dev_buf_circle_ref_dealloc(): # This test creates a reference cycle containing a `DeviceBuffer` # and ensures that the garbage collector does not clear it, i.e., From 4cfa31fae4cac9294f34f636d37414b724fdbd14 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 26 Nov 2024 12:23:40 -0800 Subject: [PATCH 502/675] Create logger wrapper around spdlog that can be easily reused in other libraries (#1722) This PR defines a new way to produce a logger wrapping spdlog. The logger's interface is declared in a template header file that can be processed by CMake to produce an interface that may be customized for placement into any project. The new implementation uses the PImpl idiom to isolate the spdlog (and transitively, fmt) dependency from the public API of the logger. The implementation is defined in an impl header. A corresponding source template file is provided that simply includes this header. All of these files are wrapped in some CMake logic for producing a custom target for a given project. rmm leverages this new logger by requesting the creation of a logger target and a corresponding implementation. This is a breaking change because consumers of rmm will need to link the new `rmm_logger_impl` target into their own libraries to get logging support. Once this gets merged, the plan is to move this implementation out of rmm into its own repository. At that point, the logger may also be used to completely replace logger implementations in cudf, raft, and cuml (as well as any other RAPIDS libraries that are aiming to provide their own logging implementation). Once everything in RAPIDS is migrated to using the new logger, we will update the way that it uses spdlog to completely hide all spdlog symbols, which solves a half dozen different problems for us when it comes to packaging (symbol collision issues, ABI compatibility, conda environment conflicts, bundling of headers into conda packages, etc). Resolves #1709 Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Robert Maynard (https://github.com/robertmaynard) - Mark Harris (https://github.com/harrism) - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1722 --- CMakeLists.txt | 6 +- README.md | 4 +- benchmarks/CMakeLists.txt | 11 +- benchmarks/replay/replay.cpp | 4 +- ci/check_symbols.sh | 23 +- cmake/thirdparty/get_spdlog.cmake | 3 +- include/rmm/detail/format.hpp | 48 -- include/rmm/detail/logging_assert.hpp | 2 +- include/rmm/logger.hpp | 117 ---- .../rmm/mr/device/arena_memory_resource.hpp | 26 +- include/rmm/mr/device/detail/arena.hpp | 28 +- .../detail/stream_ordered_memory_resource.hpp | 2 +- .../mr/device/logging_resource_adaptor.hpp | 64 +-- .../mr/device/tracking_resource_adaptor.hpp | 4 +- python/rmm/CMakeLists.txt | 6 +- python/rmm/docs/conf.py | 2 + python/rmm/rmm/__init__.py | 4 +- python/rmm/rmm/_cuda/CMakeLists.txt | 2 +- python/rmm/rmm/librmm/CMakeLists.txt | 2 +- python/rmm/rmm/librmm/_logger.pxd | 71 +-- python/rmm/rmm/librmm/_logger.pyx | 2 - python/rmm/rmm/pylibrmm/CMakeLists.txt | 2 +- python/rmm/rmm/pylibrmm/logger.pyx | 24 +- python/rmm/rmm/tests/test_rmm.py | 12 +- rapids_logger/CMakeLists.txt | 177 ++++++ rapids_logger/README.md | 22 + rapids_logger/logger.cpp.in | 17 + rapids_logger/logger.hpp.in | 504 ++++++++++++++++++ rapids_logger/logger_impl.hpp.in | 205 +++++++ tests/CMakeLists.txt | 19 +- tests/logger_tests.cpp | 4 +- tests/mr/device/tracking_mr_tests.cpp | 15 +- 32 files changed, 1068 insertions(+), 364 deletions(-) delete mode 100644 include/rmm/logger.hpp create mode 100644 rapids_logger/CMakeLists.txt create mode 100644 rapids_logger/README.md create mode 100644 rapids_logger/logger.cpp.in create mode 100644 rapids_logger/logger.hpp.in create mode 100644 rapids_logger/logger_impl.hpp.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 07bd368ee..7a7ba3525 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,7 +73,9 @@ rapids_find_package( # add third party dependencies using CPM rapids_cpm_init() -include(cmake/thirdparty/get_spdlog.cmake) +add_subdirectory(rapids_logger) +rapids_make_logger(rmm EXPORT_SET rmm-exports) + include(cmake/thirdparty/get_cccl.cmake) include(cmake/thirdparty/get_nvtx.cmake) @@ -93,8 +95,8 @@ else() target_link_libraries(rmm INTERFACE CUDA::cudart) endif() +target_link_libraries(rmm INTERFACE rmm_logger) target_link_libraries(rmm INTERFACE CCCL::CCCL) -target_link_libraries(rmm INTERFACE spdlog::spdlog_header_only) target_link_libraries(rmm INTERFACE dl) target_link_libraries(rmm INTERFACE nvtx3::nvtx3-cpp) target_compile_features(rmm INTERFACE cxx_std_17 $) diff --git a/README.md b/README.md index 0a25cd348..d72d411f5 100644 --- a/README.md +++ b/README.md @@ -658,8 +658,8 @@ of more detailed logging. The default is `INFO`. Available levels are `TRACE`, ` The log relies on the [spdlog](https://github.com/gabime/spdlog.git) library. Note that to see logging below the `INFO` level, the application must also set the logging level at -run time. C++ applications must must call `rmm::logger().set_level()`, for example to enable all -levels of logging down to `TRACE`, call `rmm::logger().set_level(spdlog::level::trace)` (and compile +run time. C++ applications must must call `rmm::default_logger().set_level()`, for example to enable all +levels of logging down to `TRACE`, call `rmm::default_logger().set_level(spdlog::level::trace)` (and compile librmm with `-DRMM_LOGGING_LEVEL=TRACE`). Python applications must call `rmm.set_logging_level()`, for example to enable all levels of logging down to `TRACE`, call `rmm.set_logging_level("trace")` (and compile the RMM Python module with `-DRMM_LOGGING_LEVEL=TRACE`). diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 0487a2dfa..b3b60cfcb 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -34,9 +34,9 @@ function(ConfigureBench BENCH_NAME) RUNTIME_OUTPUT_DIRECTORY "$" CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}" INSTALL_RPATH "\$ORIGIN/../../../lib") - target_link_libraries(${BENCH_NAME} benchmark::benchmark pthread rmm) + target_link_libraries(${BENCH_NAME} PRIVATE benchmark::benchmark pthread rmm) target_compile_definitions(${BENCH_NAME} - PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") + PUBLIC "RMM_LOG_ACTIVE_LEVEL=RMM_LOG_LEVEL_${RMM_LOGGING_LEVEL}") if(PER_THREAD_DEFAULT_STREAM) target_compile_definitions(${BENCH_NAME} PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM) @@ -44,6 +44,9 @@ function(ConfigureBench BENCH_NAME) target_compile_options(${BENCH_NAME} PUBLIC $<$:-Wall -Werror -Wno-unknown-pragmas>) + + target_link_libraries(${BENCH_NAME} PRIVATE rmm_bench_logger) + if(DISABLE_DEPRECATION_WARNING) target_compile_options( ${BENCH_NAME} PUBLIC $<$:-Xcompiler=-Wno-deprecated-declarations>) @@ -58,6 +61,10 @@ function(ConfigureBench BENCH_NAME) EXCLUDE_FROM_ALL) endfunction(ConfigureBench) +# Create an object library for the logger so that we don't have to recompile it. +add_library(rmm_bench_logger OBJECT) +target_link_libraries(rmm_bench_logger PRIVATE rmm_logger_impl) + # random allocations benchmark ConfigureBench(RANDOM_ALLOCATIONS_BENCH random_allocations/random_allocations.cpp) diff --git a/benchmarks/replay/replay.cpp b/benchmarks/replay/replay.cpp index 7f45b7691..8edbf11f9 100644 --- a/benchmarks/replay/replay.cpp +++ b/benchmarks/replay/replay.cpp @@ -33,10 +33,10 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -403,7 +403,7 @@ int main(int argc, char** argv) auto const num_threads = per_thread_events.size(); // Uncomment to enable / change default log level - // rmm::detail::logger().set_level(spdlog::level::trace); + // rmm::logger().set_level(rmm::level_enum::trace); if (args.count("resource") > 0) { std::string mr_name = args["resource"].as(); diff --git a/ci/check_symbols.sh b/ci/check_symbols.sh index 1d73a082b..155e509da 100755 --- a/ci/check_symbols.sh +++ b/ci/check_symbols.sh @@ -47,32 +47,13 @@ for dso_file in ${dso_files}; do echo " * WEAK: $(grep --count -E ' WEAK ' < ${symbol_file})" echo " * LOCAL: $(grep --count -E ' LOCAL ' < ${symbol_file})" - # Explanation for '-v' uses here: - # - # * 'format_error' symbols are intentionally exported, that type of error - # can be thrown across library boundaries. See "Problems with C++ exceptions" - # at https://gcc.gnu.org/wiki/Visibility. echo "checking for 'fmt::' symbols..." - if grep -E 'fmt\:\:' < "${symbol_file}" \ - | grep -v 'format_error' - then + if grep -E 'fmt\:\:' < "${symbol_file}"; then raise-symbols-found-error 'fmt::' fi - # Explanation for '-v' uses here: - # - # * trivially-destructible objects sometimes get an entry in the symbol table - # for a specialization of `std::_Destroy_aux()` called to destroy them. - # There is one for `spdlog::details::log_msg_buffer like that: - # - # 'std::_Destroy_aux::__destroy' - # - # That should be safe to export. - # echo "checking for 'spdlog::' symbols..." - if grep -E 'spdlog\:\:' < "${symbol_file}" \ - | grep -v 'std\:\:_Destroy_aux' - then + if grep -E 'spdlog\:\:' < "${symbol_file}"; then raise-symbols-found-error 'spdlog::' fi echo "No symbol visibility issues found" diff --git a/cmake/thirdparty/get_spdlog.cmake b/cmake/thirdparty/get_spdlog.cmake index 7f80b3726..212f604c3 100644 --- a/cmake/thirdparty/get_spdlog.cmake +++ b/cmake/thirdparty/get_spdlog.cmake @@ -12,7 +12,7 @@ # the License. # ============================================================================= -# Use CPM to find or clone speedlog +# Use CPM to find or clone speedlog. function(find_and_configure_spdlog) include(${rapids-cmake-dir}/cpm/spdlog.cmake) @@ -20,7 +20,6 @@ function(find_and_configure_spdlog) FMT_OPTION "EXTERNAL_FMT_HO" INSTALL_EXPORT_SET rmm-exports BUILD_EXPORT_SET rmm-exports) - endfunction() find_and_configure_spdlog() diff --git a/include/rmm/detail/format.hpp b/include/rmm/detail/format.hpp index 21acac032..6cd1dd9d2 100644 --- a/include/rmm/detail/format.hpp +++ b/include/rmm/detail/format.hpp @@ -20,60 +20,12 @@ #include #include -#include -#include -#include #include -#include #include namespace RMM_NAMESPACE { namespace detail { -/** - * @brief Format a message string with printf-style formatting - * - * This function performs printf-style formatting to avoid the need for fmt - * or spdlog's own templated APIs (which would require exposing spdlog - * symbols publicly) and returns the formatted message as a `std::string`. - * - * @param format The format string - * @param args The format arguments - * @return The formatted message - * @throw rmm::logic_error if an error occurs during formatting - */ -template -std::string formatted_log(std::string const& format, Args&&... args) -{ - auto convert_to_c_string = [](auto&& arg) -> decltype(auto) { - using ArgType = std::decay_t; - if constexpr (std::is_same_v) { - return arg.c_str(); - } else { - return std::forward(arg); - } - }; - - // NOLINTBEGIN(cppcoreguidelines-pro-type-vararg) - auto retsize = - std::snprintf(nullptr, 0, format.c_str(), convert_to_c_string(std::forward(args))...); - RMM_EXPECTS(retsize >= 0, "Error during formatting."); - if (retsize == 0) { return {}; } - auto size = static_cast(retsize) + 1; // for null terminator - // NOLINTNEXTLINE(modernize-avoid-c-arrays, cppcoreguidelines-avoid-c-arrays) - std::unique_ptr buf(new char[size]); - std::snprintf(buf.get(), size, format.c_str(), convert_to_c_string(std::forward(args))...); - // NOLINTEND(cppcoreguidelines-pro-type-vararg) - return {buf.get(), buf.get() + size - 1}; // drop '\0' -} - -// specialization for no arguments -template <> -inline std::string formatted_log(std::string const& format) -{ - return format; -} - // Stringify a size in bytes to a human-readable value inline std::string format_bytes(std::size_t value) { diff --git a/include/rmm/detail/logging_assert.hpp b/include/rmm/detail/logging_assert.hpp index 4d702ee2b..c3b12ffe3 100644 --- a/include/rmm/detail/logging_assert.hpp +++ b/include/rmm/detail/logging_assert.hpp @@ -31,7 +31,7 @@ */ #ifdef NDEBUG #define RMM_LOGGING_ASSERT(_expr) (void)0 -#elif SPDLOG_ACTIVE_LEVEL < SPDLOG_LEVEL_OFF +#elif RMM_LOG_ACTIVE_LEVEL < RMM_LOG_LEVEL_OFF #define RMM_LOGGING_ASSERT(_expr) \ do { \ bool const success = (_expr); \ diff --git a/include/rmm/logger.hpp b/include/rmm/logger.hpp deleted file mode 100644 index 2cfd921b1..000000000 --- a/include/rmm/logger.hpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2020-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. - */ - -#pragma once - -#include -#include -#include - -#include -#include - -#include - -namespace RMM_NAMESPACE { - -namespace detail { - -/** - * @brief Returns the default log filename for the RMM global logger. - * - * If the environment variable `RMM_DEBUG_LOG_FILE` is defined, its value is used as the path and - * name of the log file. Otherwise, the file `rmm_log.txt` in the current working directory is used. - * - * @return std::string The default log file name. - */ -inline std::string default_log_filename() -{ - auto* filename = std::getenv("RMM_DEBUG_LOG_FILE"); - return (filename == nullptr) ? std::string{"rmm_log.txt"} : std::string{filename}; -} - -/** - * @brief Simple wrapper around a spdlog::logger that performs RMM-specific initialization - */ -struct logger_wrapper { - spdlog::logger logger_; ///< The underlying logger - - logger_wrapper() - : logger_{"RMM", - std::make_shared( - default_log_filename(), true // truncate file - )} - { - logger_.set_pattern("[%6t][%H:%M:%S:%f][%-6l] %v"); - logger_.flush_on(spdlog::level::warn); -#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_INFO -#ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM - logger_.info("----- RMM LOG BEGIN [PTDS ENABLED] -----"); -#else - logger_.info("----- RMM LOG BEGIN [PTDS DISABLED] -----"); -#endif - logger_.flush(); -#endif - } -}; - -inline spdlog::logger& logger() -{ - static detail::logger_wrapper wrapped{}; - return wrapped.logger_; -} -} // namespace detail - -/** - * @brief Returns the global RMM logger - * - * @ingroup logging - * - * This is a spdlog logger. The easiest way to log messages is to use the `RMM_LOG_*` macros. - * - * @return spdlog::logger& The logger. - */ -[[deprecated( - "Support for direct access to spdlog loggers in rmm is planned for " - "removal")]] RMM_EXPORT inline spdlog::logger& -logger() -{ - return detail::logger(); -} - -//! @cond Doxygen_Suppress -// -// The default is INFO, but it should be used sparingly, so that by default a log file is only -// output if there is important information, warnings, errors, and critical failures -// Log messages that require computation should only be used at level TRACE and DEBUG -#define RMM_LOG_TRACE(...) \ - SPDLOG_LOGGER_TRACE(&rmm::detail::logger(), rmm::detail::formatted_log(__VA_ARGS__)) -#define RMM_LOG_DEBUG(...) \ - SPDLOG_LOGGER_DEBUG(&rmm::detail::logger(), rmm::detail::formatted_log(__VA_ARGS__)) -#define RMM_LOG_INFO(...) \ - SPDLOG_LOGGER_INFO(&rmm::detail::logger(), rmm::detail::formatted_log(__VA_ARGS__)) -#define RMM_LOG_WARN(...) \ - SPDLOG_LOGGER_WARN(&rmm::detail::logger(), rmm::detail::formatted_log(__VA_ARGS__)) -#define RMM_LOG_ERROR(...) \ - SPDLOG_LOGGER_ERROR(&rmm::detail::logger(), rmm::detail::formatted_log(__VA_ARGS__)) -#define RMM_LOG_CRITICAL(...) \ - SPDLOG_LOGGER_CRITICAL(&rmm::detail::logger(), rmm::detail::formatted_log(__VA_ARGS__)) - -//! @endcond - -} // namespace RMM_NAMESPACE - -//! @endcond diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index d3a4bb09d..fe07aab04 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -27,8 +27,6 @@ #include -#include - #include #include #include @@ -98,12 +96,9 @@ class arena_memory_resource final : public device_memory_resource { : global_arena_{upstream_mr, arena_size}, dump_log_on_failure_{dump_log_on_failure} { if (dump_log_on_failure_) { - logger_ = - std::make_shared("arena_memory_dump", - std::make_shared( - "rmm_arena_memory_dump.log", true /*truncate file*/)); + logger_ = std::make_shared("arena_memory_dump", "rmm_arena_memory_dump.log"); // Set the level to `debug` for more detailed output. - logger_->set_level(spdlog::level::info); + logger_->set_level(level_enum::info); } } @@ -120,17 +115,9 @@ class arena_memory_resource final : public device_memory_resource { explicit arena_memory_resource(Upstream* upstream_mr, std::optional arena_size = std::nullopt, bool dump_log_on_failure = false) - : global_arena_{to_device_async_resource_ref_checked(upstream_mr), arena_size}, - dump_log_on_failure_{dump_log_on_failure} + : arena_memory_resource{ + to_device_async_resource_ref_checked(upstream_mr), arena_size, dump_log_on_failure} { - if (dump_log_on_failure_) { - logger_ = - std::make_shared("arena_memory_dump", - std::make_shared( - "rmm_arena_memory_dump.log", true /*truncate file*/)); - // Set the level to `debug` for more detailed output. - logger_->set_level(spdlog::level::info); - } } ~arena_memory_resource() override = default; @@ -336,8 +323,7 @@ class arena_memory_resource final : public device_memory_resource { void dump_memory_log(size_t bytes) { logger_->info("**************************************************"); - logger_->info(rmm::detail::formatted_log("Ran out of memory trying to allocate %s.", - rmm::detail::format_bytes(bytes))); + logger_->info("Ran out of memory trying to allocate %s.", rmm::detail::format_bytes(bytes)); logger_->info("**************************************************"); logger_->info("Global arena:"); global_arena_.dump_memory_log(logger_); @@ -366,7 +352,7 @@ class arena_memory_resource final : public device_memory_resource { /// If true, dump memory information to log on allocation failure. bool dump_log_on_failure_{}; /// The logger for memory dump. - std::shared_ptr logger_{}; + std::shared_ptr logger_{}; /// Mutex for read and write locks on arena maps. mutable std::shared_mutex map_mtx_; /// Mutex for shared and unique locks on the mr. diff --git a/include/rmm/mr/device/detail/arena.hpp b/include/rmm/mr/device/detail/arena.hpp index 419c4fcf4..20095d504 100644 --- a/include/rmm/mr/device/detail/arena.hpp +++ b/include/rmm/mr/device/detail/arena.hpp @@ -28,8 +28,6 @@ #include -#include - #include #include #include @@ -645,33 +643,29 @@ class global_arena final { /** * @brief Dump memory to log. * - * @param logger the spdlog logger to use + * @param logger the logger to use */ - RMM_HIDDEN void dump_memory_log(std::shared_ptr const& logger) const + void dump_memory_log(std::shared_ptr const& logger) const { std::lock_guard lock(mtx_); - logger->info(rmm::detail::formatted_log(" Arena size: %s", - rmm::detail::format_bytes(upstream_block_.size()))); - logger->info(rmm::detail::formatted_log(" # superblocks: %zu", superblocks_.size())); + logger->info(" Arena size: %s", rmm::detail::format_bytes(upstream_block_.size())); + logger->info(" # superblocks: %zu", superblocks_.size()); if (!superblocks_.empty()) { - logger->debug( - rmm::detail::formatted_log(" Total size of superblocks: %s", - rmm::detail::format_bytes(total_memory_size(superblocks_)))); + logger->debug(" Total size of superblocks: %s", + rmm::detail::format_bytes(total_memory_size(superblocks_))); auto const total_free = total_free_size(superblocks_); auto const max_free = max_free_size(superblocks_); auto const fragmentation = (1 - max_free / static_cast(total_free)) * 100; - logger->info(rmm::detail::formatted_log(" Total free memory: %s", - rmm::detail::format_bytes(total_free))); - logger->info(rmm::detail::formatted_log(" Largest block of free memory: %s", - rmm::detail::format_bytes(max_free))); - logger->info(rmm::detail::formatted_log(" Fragmentation: %0.2f", fragmentation)); + logger->info(" Total free memory: %s", rmm::detail::format_bytes(total_free)); + logger->info(" Largest block of free memory: %s", rmm::detail::format_bytes(max_free)); + logger->info(" Fragmentation: %0.2f", fragmentation); auto index = decltype(superblocks_.size()){0}; char* prev_end{}; for (auto const& sblk : superblocks_) { if (prev_end == nullptr) { prev_end = sblk.pointer(); } - logger->debug(rmm::detail::formatted_log( + logger->debug( " Superblock %zu: start=%p, end=%p, size=%s, empty=%s, # free blocks=%zu, max " "free=%s, " "gap=%s", @@ -682,7 +676,7 @@ class global_arena final { sblk.empty() ? "T" : "F", sblk.free_blocks(), rmm::detail::format_bytes(sblk.max_free_size()), - rmm::detail::format_bytes(static_cast(sblk.pointer() - prev_end)))); + rmm::detail::format_bytes(static_cast(sblk.pointer() - prev_end))); prev_end = sblk.end(); index++; } diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index f177504f2..0900d44b2 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -458,7 +458,7 @@ class stream_ordered_memory_resource : public crtp, public device_ void log_summary_trace() { -#if (SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE) +#if (RMM_LOG_ACTIVE_LEVEL <= RMM_LOG_LEVEL_TRACE) std::size_t num_blocks{0}; std::size_t max_block{0}; std::size_t free_mem{0}; diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 578543852..3e6e5babc 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -19,14 +19,10 @@ #include #include #include +#include #include #include -#include -#include -#include -#include - #include #include #include @@ -35,6 +31,7 @@ namespace RMM_NAMESPACE { namespace mr { + /** * @addtogroup device_resource_adaptors * @{ @@ -78,9 +75,8 @@ class logging_resource_adaptor final : public device_memory_resource { logging_resource_adaptor(Upstream* upstream, std::string const& filename = get_default_filename(), bool auto_flush = false) - : logger_{make_logger(filename)}, upstream_{to_device_async_resource_ref_checked(upstream)} + : logging_resource_adaptor(to_device_async_resource_ref_checked(upstream), filename, auto_flush) { - init_logger(auto_flush); } /** @@ -98,9 +94,8 @@ class logging_resource_adaptor final : public device_memory_resource { * performance. */ logging_resource_adaptor(Upstream* upstream, std::ostream& stream, bool auto_flush = false) - : logger_{make_logger(stream)}, upstream_{to_device_async_resource_ref_checked(upstream)} + : logging_resource_adaptor(to_device_async_resource_ref_checked(upstream), stream, auto_flush) { - init_logger(auto_flush); } /** @@ -118,11 +113,10 @@ class logging_resource_adaptor final : public device_memory_resource { * performance. */ logging_resource_adaptor(Upstream* upstream, - spdlog::sinks_init_list sinks, + std::initializer_list sinks, bool auto_flush = false) - : logger_{make_logger(sinks)}, upstream_{to_device_async_resource_ref_checked(upstream)} + : logging_resource_adaptor{to_device_async_resource_ref_checked(upstream), sinks, auto_flush} { - init_logger(auto_flush); } /** @@ -148,9 +142,8 @@ class logging_resource_adaptor final : public device_memory_resource { logging_resource_adaptor(device_async_resource_ref upstream, std::string const& filename = get_default_filename(), bool auto_flush = false) - : logger_{make_logger(filename)}, upstream_{upstream} + : logging_resource_adaptor{make_logger(filename), upstream, auto_flush} { - init_logger(auto_flush); } /** @@ -168,9 +161,8 @@ class logging_resource_adaptor final : public device_memory_resource { logging_resource_adaptor(device_async_resource_ref upstream, std::ostream& stream, bool auto_flush = false) - : logger_{make_logger(stream)}, upstream_{upstream} + : logging_resource_adaptor{make_logger(stream), upstream, auto_flush} { - init_logger(auto_flush); } /** @@ -186,11 +178,10 @@ class logging_resource_adaptor final : public device_memory_resource { * performance. */ logging_resource_adaptor(device_async_resource_ref upstream, - spdlog::sinks_init_list sinks, + std::initializer_list sinks, bool auto_flush = false) - : logger_{make_logger(sinks)}, upstream_{upstream} + : logging_resource_adaptor{make_logger(sinks), upstream, auto_flush} { - init_logger(auto_flush); } logging_resource_adaptor() = delete; @@ -241,29 +232,24 @@ class logging_resource_adaptor final : public device_memory_resource { } private: - static auto make_logger(std::ostream& stream) - { - return std::make_shared( - "RMM", std::make_shared(stream)); - } + static auto make_logger(std::ostream& stream) { return std::make_shared("RMM", stream); } static auto make_logger(std::string const& filename) { - return std::make_shared( - "RMM", std::make_shared(filename, true /*truncate file*/)); + return std::make_shared("RMM", filename); } - static auto make_logger(spdlog::sinks_init_list sinks) + static auto make_logger(std::initializer_list sinks) { - return std::make_shared("RMM", sinks); + return std::make_shared("RMM", sinks); } - /** - * @brief Initialize the logger. - */ - void init_logger(bool auto_flush) + logging_resource_adaptor(std::shared_ptr logger, + device_async_resource_ref upstream, + bool auto_flush) + : logger_{logger}, upstream_{upstream} { - if (auto_flush) { logger_->flush_on(spdlog::level::info); } + if (auto_flush) { logger_->flush_on(level_enum::info); } logger_->set_pattern("%v"); logger_->info(header()); logger_->set_pattern("%t,%H:%M:%S.%f,%v"); @@ -298,12 +284,11 @@ class logging_resource_adaptor final : public device_memory_resource { { try { auto const ptr = get_upstream_resource().allocate_async(bytes, stream); - logger_->info(rmm::detail::formatted_log( - "allocate,%p,%zu,%s", ptr, bytes, rmm::detail::format_stream(stream))); + logger_->info("allocate,%p,%zu,%s", ptr, bytes, rmm::detail::format_stream(stream)); return ptr; } catch (...) { - logger_->info(rmm::detail::formatted_log( - "allocate failure,%p,%zu,%s", nullptr, bytes, rmm::detail::format_stream(stream))); + logger_->info( + "allocate failure,%p,%zu,%s", nullptr, bytes, rmm::detail::format_stream(stream)); throw; } } @@ -324,8 +309,7 @@ class logging_resource_adaptor final : public device_memory_resource { */ void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override { - logger_->info( - rmm::detail::formatted_log("free,%p,%zu,%s", ptr, bytes, rmm::detail::format_stream(stream))); + logger_->info("free,%p,%zu,%s", ptr, bytes, rmm::detail::format_stream(stream)); get_upstream_resource().deallocate_async(ptr, bytes, stream); } @@ -344,7 +328,7 @@ class logging_resource_adaptor final : public device_memory_resource { return get_upstream_resource() == cast->get_upstream_resource(); } - std::shared_ptr logger_; ///< spdlog logger object + std::shared_ptr logger_{}; device_async_resource_ref upstream_; ///< The upstream resource used for satisfying ///< allocation requests diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index 8131eef4d..09631960e 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -185,9 +185,9 @@ class tracking_resource_adaptor final : public device_memory_resource { */ void log_outstanding_allocations() const { -#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_DEBUG +#if RMM_LOG_ACTIVE_LEVEL <= RMM_LOG_LEVEL_DEBUG RMM_LOG_DEBUG("Outstanding Allocations: %s", get_outstanding_allocations_str()); -#endif // SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_DEBUG +#endif // RMM_LOG_ACTIVE_LEVEL <= RMM_LOG_LEVEL_DEBUG } private: diff --git a/python/rmm/CMakeLists.txt b/python/rmm/CMakeLists.txt index ac8495e14..a39ac8868 100644 --- a/python/rmm/CMakeLists.txt +++ b/python/rmm/CMakeLists.txt @@ -27,7 +27,11 @@ include(rapids-cython-core) rapids_cython_init() # pass through logging level to spdlog -add_compile_definitions("SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") +add_compile_definitions("RMM_LOG_ACTIVE_LEVEL=RMM_LOG_LEVEL_${RMM_LOGGING_LEVEL}") + +# Create an object library for the logger so that we don't have to recompile it. +add_library(cpp_logger OBJECT) +target_link_libraries(cpp_logger PRIVATE rmm::rmm_logger_impl) add_subdirectory(rmm/_cuda) add_subdirectory(rmm/librmm) diff --git a/python/rmm/docs/conf.py b/python/rmm/docs/conf.py index 2aad3a82c..99242daa5 100644 --- a/python/rmm/docs/conf.py +++ b/python/rmm/docs/conf.py @@ -238,6 +238,8 @@ def on_missing_reference(app, env, node, contnode): "thrust", "spdlog", "stream_ref", + # logger names (we may eventually want to link out for those) + "sink_ptr", # libcu++ names "cuda", "cuda::mr", diff --git a/python/rmm/rmm/__init__.py b/python/rmm/rmm/__init__.py index 832fec095..5c865eba8 100644 --- a/python/rmm/rmm/__init__.py +++ b/python/rmm/rmm/__init__.py @@ -22,7 +22,7 @@ flush_logger, get_flush_level, get_logging_level, - logging_level, + level_enum, set_flush_level, set_logging_level, should_log, @@ -45,7 +45,7 @@ "get_log_filenames", "get_logging_level", "is_initialized", - "logging_level", + "level_enum", "mr", "register_reinitialize_hook", "reinitialize", diff --git a/python/rmm/rmm/_cuda/CMakeLists.txt b/python/rmm/rmm/_cuda/CMakeLists.txt index 7fd27d110..7759432d3 100644 --- a/python/rmm/rmm/_cuda/CMakeLists.txt +++ b/python/rmm/rmm/_cuda/CMakeLists.txt @@ -13,7 +13,7 @@ # ============================================================================= set(cython_sources stream.pyx) -set(linked_libraries rmm::rmm) +set(linked_libraries rmm::rmm cpp_logger) rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}" CXX) diff --git a/python/rmm/rmm/librmm/CMakeLists.txt b/python/rmm/rmm/librmm/CMakeLists.txt index 5da2a1a01..dc807fdba 100644 --- a/python/rmm/rmm/librmm/CMakeLists.txt +++ b/python/rmm/rmm/librmm/CMakeLists.txt @@ -13,7 +13,7 @@ # ============================================================================= set(cython_sources _logger.pyx) -set(linked_libraries rmm::rmm) +set(linked_libraries rmm::rmm cpp_logger) # Build all of the Cython targets rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}" diff --git a/python/rmm/rmm/librmm/_logger.pxd b/python/rmm/rmm/librmm/_logger.pxd index fb2126b2f..bd0728bc1 100644 --- a/python/rmm/rmm/librmm/_logger.pxd +++ b/python/rmm/rmm/librmm/_logger.pxd @@ -13,54 +13,27 @@ # limitations under the License. from libcpp cimport bool - - -cdef extern from "spdlog/common.h" namespace "spdlog::level" nogil: - cpdef enum logging_level "spdlog::level::level_enum": - """ - The debug logging level for RMM. - - Debug logging prints messages to a log file. See - `Debug Logging `_ - for more information. - - Valid levels, in decreasing order of verbosity, are TRACE, DEBUG, - INFO, WARN, ERR, CRITICAL, and OFF. Default is INFO. - - Examples - -------- - >>> import rmm - >>> rmm.logging_level.DEBUG - - >>> rmm.logging_level.DEBUG.value - 1 - >>> rmm.logging_level.DEBUG.name - 'DEBUG' - - See Also - -------- - set_logging_level : Set the debug logging level - get_logging_level : Get the current debug logging level - """ - TRACE "spdlog::level::trace" - DEBUG "spdlog::level::debug" - INFO "spdlog::level::info" - WARN "spdlog::level::warn" - ERR "spdlog::level::err" - CRITICAL "spdlog::level::critical" - OFF "spdlog::level::off" - - -cdef extern from "spdlog/spdlog.h" namespace "spdlog" nogil: - cdef cppclass spdlog_logger "spdlog::logger": - spdlog_logger() except + - void set_level(logging_level level) - logging_level level() +from libcpp.string cimport string + + +cdef extern from "rmm/logger.hpp" namespace "rmm" nogil: + cpdef enum class level_enum: + trace + debug + info + warn + error + critical + off + n_levels + + cdef cppclass logger: + logger(string name, string filename) except + + void set_level(level_enum log_level) except + + level_enum level() except + void flush() except + - void flush_on(logging_level level) - logging_level flush_level() - bool should_log(logging_level msg_level) - + void flush_on(level_enum level) except + + level_enum flush_level() except + + bool should_log(level_enum msg_level) except + -cdef extern from "rmm/logger.hpp" namespace "rmm::detail" nogil: - cdef spdlog_logger& logger() except + + cdef logger& default_logger() except + diff --git a/python/rmm/rmm/librmm/_logger.pyx b/python/rmm/rmm/librmm/_logger.pyx index 4392cb106..57bbf5c62 100644 --- a/python/rmm/rmm/librmm/_logger.pyx +++ b/python/rmm/rmm/librmm/_logger.pyx @@ -11,5 +11,3 @@ # 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. - -from rmm.librmm._logger cimport logging_level # no-cython-lint diff --git a/python/rmm/rmm/pylibrmm/CMakeLists.txt b/python/rmm/rmm/pylibrmm/CMakeLists.txt index 0e88f01bb..0012cb93d 100644 --- a/python/rmm/rmm/pylibrmm/CMakeLists.txt +++ b/python/rmm/rmm/pylibrmm/CMakeLists.txt @@ -13,7 +13,7 @@ # ============================================================================= set(cython_sources device_buffer.pyx logger.pyx memory_resource.pyx cuda_stream.pyx helper.pyx) -set(linked_libraries rmm::rmm) +set(linked_libraries rmm::rmm cpp_logger) # Build all of the Cython targets rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}" diff --git a/python/rmm/rmm/pylibrmm/logger.pyx b/python/rmm/rmm/pylibrmm/logger.pyx index 119e1c92f..9d5877fae 100644 --- a/python/rmm/rmm/pylibrmm/logger.pyx +++ b/python/rmm/rmm/pylibrmm/logger.pyx @@ -14,14 +14,14 @@ import warnings -from rmm.librmm._logger cimport logger +from rmm.librmm._logger cimport default_logger -from rmm.librmm._logger import logging_level +from rmm.librmm._logger import level_enum def _validate_level_type(level): - if not isinstance(level, logging_level): - raise TypeError("level must be an instance of the logging_level enum") + if not isinstance(level, level_enum): + raise TypeError("level must be an instance of the level_enum enum") def should_log(level): @@ -54,7 +54,7 @@ def should_log(level): If the logging level is not an instance of the ``logging_level`` enum. """ _validate_level_type(level) - return logger().should_log(level) + return default_logger().should_log(level) def set_logging_level(level): @@ -86,10 +86,10 @@ def set_logging_level(level): >>> rmm.set_logging_level(rmm.logging_level.WARN) # set logging level to warn """ _validate_level_type(level) - logger().set_level(level) + default_logger().set_level(level) if not should_log(level): - warnings.warn(f"RMM will not log logging_level.{level.name}. This " + warnings.warn(f"RMM will not log level_enum.{level.name}. This " "may be because the C++ library is compiled for a " "less-verbose logging level.") @@ -118,7 +118,7 @@ def get_logging_level(): >>> rmm.get_logging_level() # get current logging level """ - return logging_level(logger().level()) + return default_logger().level() def flush_logger(): @@ -140,7 +140,7 @@ def flush_logger(): >>> import rmm >>> rmm.flush_logger() # flush the logger """ - logger().flush() + default_logger().flush() def set_flush_level(level): @@ -174,10 +174,10 @@ def set_flush_level(level): >>> rmm.flush_on(rmm.logging_level.WARN) # set flush level to warn """ _validate_level_type(level) - logger().flush_on(level) + default_logger().flush_on(level) if not should_log(level): - warnings.warn(f"RMM will not log logging_level.{level.name}. This " + warnings.warn(f"RMM will not log level_enum.{level.name}. This " "may be because the C++ library is compiled for a " "less-verbose logging level.") @@ -208,4 +208,4 @@ def get_flush_level(): >>> rmm.flush_level() # get current flush level """ - return logging_level(logger().flush_level()) + return default_logger().flush_level() diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index 182434dc5..7d13b5cac 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -29,6 +29,7 @@ import rmm._cuda.stream from rmm.allocators.cupy import rmm_cupy_allocator from rmm.allocators.numba import RMMNumbaManager +from rmm.pylibrmm.logger import level_enum cuda.set_memory_manager(RMMNumbaManager) @@ -1033,22 +1034,23 @@ def test_rmm_device_buffer_copy(cuda_ary, make_copy): np.testing.assert_equal(expected, result) -@pytest.mark.parametrize("level", rmm.logging_level) +@pytest.mark.parametrize("level", level_enum) def test_valid_logging_level(level): + default_level = level_enum.info with warnings.catch_warnings(): warnings.filterwarnings( - "ignore", message="RMM will not log logging_level.TRACE." + "ignore", message="RMM will not log level_enum.trace." ) warnings.filterwarnings( - "ignore", message="RMM will not log logging_level.DEBUG." + "ignore", message="RMM will not log level_enum.debug." ) rmm.set_logging_level(level) assert rmm.get_logging_level() == level - rmm.set_logging_level(rmm.logging_level.INFO) # reset to default + rmm.set_logging_level(default_level) # reset to default rmm.set_flush_level(level) assert rmm.get_flush_level() == level - rmm.set_flush_level(rmm.logging_level.INFO) # reset to default + rmm.set_flush_level(default_level) # reset to default rmm.should_log(level) diff --git a/rapids_logger/CMakeLists.txt b/rapids_logger/CMakeLists.txt new file mode 100644 index 000000000..fd50276ca --- /dev/null +++ b/rapids_logger/CMakeLists.txt @@ -0,0 +1,177 @@ +# ============================================================================= +# 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. +# ============================================================================= + +# cmake-lint: disable=R0915 + +include_guard(GLOBAL) + +cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) + +include(../rapids_config.cmake) + +include(rapids-cmake) +include(rapids-cpm) + +project( + RAPIDS_LOGGER + VERSION 0.0.1 + LANGUAGES CXX) + +rapids_cmake_build_type(Release) + +rapids_cpm_init() + +include(../cmake/thirdparty/get_spdlog.cmake) + +#[=======================================================================[.rst: +rapids_make_logger +------------------ + +Generate a logger implementation customized for the specified namespace. + +.. code-block:: cmake + + rapids_make_logger( + [EXPORT_SET ] + [LOGGER_TARGET ] + [LOGGER_HEADER_DIR ] + [LOGGER_MACRO_PREFIX ] + ) + +This function produces an interface target named that, when linked to by other targets, provides them a header file that defines a logger interface for the specified namespace. The logger is generated from the provided template files and is configured to use the specified namespace and macro prefix. The generated logger is placed in the specified header directory. + +The logger implementation lives in a separate header file that is not included in the declaration header. The logger implementation is compiled into a separate target that must be linked to by any target that uses the logger. + + +``logger_namespace`` + The namespace for which to generate the logger implementation. + +``EXPORT_SET`` + The name of the export set to which the logger target should be added. If not specified, the logger target is not added to any export set. + +``LOGGER_TARGET`` + The name of the logger (and logger impl) target to create. If not specified, defaults to _logger. + +``LOGGER_HEADER_DIR`` + The directory in which to place the generated logger header file. If not specified, the logger header file is placed in include/. + +``LOGGER_MACRO_PREFIX`` + The prefix to use for the logger macros. If not specified, the macro prefix is the uppercase version of the logger namespace. + +Result Targets +^^^^^^^^^^^^^^^^ + is an interface target that provides the logger interface for the specified namespace. + + _impl is an interface target that provides the logger implementation for the specified namespace. This target must be linked to by any target that uses the logger. Targets linking to this target will have the logger implementation compiled into them. + +Examples +^^^^^^^^ + +Example on how to use :cmake:command:`rapids_make_logger`. + + +.. code-block:: cmake + + # Generate a logger for the namespace "rapids" and associate it with the + # export set "rapids-exports". + rapids_make_logger(rapids + EXPORT_SET rapids-exports + ) + + # Generate a logger for the namespace "rmm" that does not support logging. + rapids_make_logger(rapids) + + +#]=======================================================================] +function(rapids_make_logger logger_namespace) + list(APPEND CMAKE_MESSAGE_CONTEXT "rapids_make_logger") + + set(_rapids_options) + set(_rapids_one_value EXPORT_SET LOGGER_TARGET LOGGER_HEADER_DIR LOGGER_MACRO_PREFIX) + set(_rapids_multi_value) + cmake_parse_arguments(_RAPIDS "${_rapids_options}" "${_rapids_one_value}" + "${_rapids_multi_value}" ${ARGN}) + + # Most arguments are optional and can be inferred from the namespace by default. + set(_RAPIDS_LOGGER_NAMESPACE ${logger_namespace}) + if(NOT _RAPIDS_LOGGER_TARGET) + set(_RAPIDS_LOGGER_TARGET "${logger_namespace}_logger") + endif() + if(NOT _RAPIDS_LOGGER_HEADER_DIR) + set(_RAPIDS_LOGGER_HEADER_DIR "include/${logger_namespace}") + endif() + if(NOT _RAPIDS_LOGGER_MACRO_PREFIX) + string(TOUPPER ${logger_namespace} _RAPIDS_LOGGER_MACRO_PREFIX) + endif() + + # All paths are computed relative to the current source/binary dir of the file from which the + # function is invoked. As a result we cannot use relative paths here because CMake will root these + # paths incorrectly for configure_file/install. + set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${_RAPIDS_LOGGER_HEADER_DIR}) + # TODO: Verify that installation works correctly with prefix removed. + set(INSTALL_DIR ${_RAPIDS_LOGGER_HEADER_DIR}) + + set(LOGGER_OUTPUT_FILE ${BUILD_DIR}/logger.hpp) + configure_file(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/logger.hpp.in ${LOGGER_OUTPUT_FILE}) + install(FILES ${LOGGER_OUTPUT_FILE} DESTINATION ${INSTALL_DIR}) + + set(LOGGER_IMPL_OUTPUT_FILE ${BUILD_DIR}/logger_impl/logger_impl.hpp) + configure_file(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/logger_impl.hpp.in ${LOGGER_IMPL_OUTPUT_FILE}) + install(FILES ${LOGGER_IMPL_OUTPUT_FILE} DESTINATION ${INSTALL_DIR}/logger_impl) + + add_library(${_RAPIDS_LOGGER_TARGET} INTERFACE) + include(GNUInstallDirs) + # Note: The BUILD_INTERFACE setting assumes that LOGGER_HEADER_DIR is the subdirectory of + # CMAKE_INSTALL_INCLUDEDIR relative to which all includes are rooted in the C++ code files. I + # think that is a safe assumption though since if it were violated then the INSTALL_INTERFACE + # would not only be incorrect (if computed using LOGGER_HEADER_DIR), but it would also break + # consumers of the installed package who expect to be able to write `#include + # <${LOGGER_HEADER_DIR/include\//}/logger.hpp>` and have it work. + target_include_directories( + ${_RAPIDS_LOGGER_TARGET} + INTERFACE "$" + "$") + target_compile_features(${_RAPIDS_LOGGER_TARGET} INTERFACE cxx_std_17) + + # Create an interface target that will trigger compilation of the logger implementation in any + # target that is linked to it. + set(LOGGER_IMPL_SRC_OUTPUT_FILE ${BUILD_DIR}/logger_impl/logger.cpp) + configure_file(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/logger.cpp.in ${LOGGER_IMPL_SRC_OUTPUT_FILE}) + install(FILES ${LOGGER_IMPL_SRC_OUTPUT_FILE} DESTINATION ${INSTALL_DIR}/logger_impl) + + # Note that we cannot specify the source files directly in add_library, see the CMake + # documentation explaining that these do not populate INTERFACE_SOURCES. + # https://cmake.org/cmake/help/latest/command/add_library.html#interface-with-sources + set(impl_target ${_RAPIDS_LOGGER_TARGET}_impl) + add_library(${impl_target} INTERFACE) + target_sources( + ${impl_target} + INTERFACE $ + $) + target_link_libraries(${impl_target} INTERFACE ${_RAPIDS_LOGGER_TARGET} + spdlog::spdlog_header_only) + set_target_properties(${impl_target} PROPERTIES POSITION_INDEPENDENT_CODE ON + INTERFACE_POSITION_INDEPENDENT_CODE ON) + + set(_install_export) + if(_RAPIDS_EXPORT_SET) + set(_install_export EXPORT ${_RAPIDS_EXPORT_SET}) + endif() + + install(TARGETS ${_RAPIDS_LOGGER_TARGET} ${_install_export}) + if(TARGET ${impl_target}) + install(TARGETS ${impl_target} ${_install_export}) + endif() + +endfunction() diff --git a/rapids_logger/README.md b/rapids_logger/README.md new file mode 100644 index 000000000..00e505fc7 --- /dev/null +++ b/rapids_logger/README.md @@ -0,0 +1,22 @@ +# About + +The `rapids-logger` project defines an easy way to produce a project-specific logger using the excellent [spdlog](https://github.com/gabime/spdlog) package. +The goal of this project is to ensure that projects wishing to provide their own logger may do so easily without needing to reimplement their own custom wrappers around spdlog. +A core goal of the project is to ensure that the custom logger implementation does not leak any spdlog symbols, allowing the safe coexistence of different projects in the same environment even if they use different versions of spdlog. +That goal is the primary reason to prefer using this project rather than directly exposing a specialized instance of a spdlog logger in your own project. + +`rapids-logger` is designed to be used via CMake. +Its CMake defines a function `rapids_make_logger` that can be used to produce a project-specific logger class in a provided namespace. +The resulting logger exposes spdlog-like functionality via the [PImpl idiom](https://en.cppreference.com/w/cpp/language/pimpl) to avoid exposing spdlog symbols publicly. +It uses CMake and template C++ files to generate a public header file to describe the user interface and an inline header that should be placed in a single TU by consumers to compile the implementation. +To simplify usage, each invocation of the function produces two CMake targets, one representing the public header and one representing a trivial source file including the inline header. +Projects using `rapids-logger` should make the first target part of their public link interface while the latter should be linked to privately so that it is compiled into the project's library without public exposure. + +To mirror spdlog, each generated logger also ships with a set of logging macros `_LOG_` that may be used to control logging at compile-time as well as runtime using a compile-time variable `_LOG_ACTIVE_LEVEL`. +For example, a project called "rapids" will be able to write code like this: +``` +RAPIDS_LOG_WARN("Some message to be shown when the warning level is enabled"); +``` +and control whether that warning is shown by compiling the code with `RAPIDS_LOG_ACTIVE_LEVEL=RAPIDS_LOG_LEVEL_WARN`. +Each project is endowed with its own definition of levels, so different projects in the same environment may be safely configured independently of each other and of spdlog. +Each project is also given a `default_logger` function that produces a global logger that may be used anywhere, but projects may also freely instantiate additional loggers as needed. diff --git a/rapids_logger/logger.cpp.in b/rapids_logger/logger.cpp.in new file mode 100644 index 000000000..36bb2ce02 --- /dev/null +++ b/rapids_logger/logger.cpp.in @@ -0,0 +1,17 @@ +/* + * 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. + */ + +#include "logger_impl.hpp" diff --git a/rapids_logger/logger.hpp.in b/rapids_logger/logger.hpp.in new file mode 100644 index 000000000..cd2bb2c79 --- /dev/null +++ b/rapids_logger/logger.hpp.in @@ -0,0 +1,504 @@ +/* + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +namespace __attribute__((visibility("default"))) @_RAPIDS_LOGGER_NAMESPACE@ { + +// These values must be kept in sync with spdlog! +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_TRACE 0 +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_DEBUG 1 +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_INFO 2 +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_WARN 3 +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_ERROR 4 +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_CRITICAL 5 +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_OFF 6 + +/** + * @brief The log levels supported by the logger. + * + * These levels correspond to the levels defined by spdlog. + */ +enum class level_enum : int32_t { + trace = @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_TRACE, + debug = @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_DEBUG, + info = @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_INFO, + warn = @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_WARN, + error = @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_ERROR, + critical = @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_CRITICAL, + off = @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_OFF, + n_levels +}; + +namespace detail { +// Forward declare the implementation classes. +class logger_impl; +class sink_impl; +} + +// Forward declare for the sink for the logger to use. +class sink; +using sink_ptr = std::shared_ptr; + +/** + * @class logger + * @brief A logger class that either uses the real implementation (via spdlog) or performs no-ops if + * not supported. + */ +class logger { + public: + logger() = delete; ///< Not default constructible + logger(logger const&) = delete; ///< Not copy constructible + logger& operator=(logger const&) = delete; ///< Not copy assignable + + logger(logger&& other); ///< @default_move_constructor + logger& operator=(logger&& other); ///< @default_move_assignment{logger} + + /** + * @brief A class to manage a vector of sinks. + * + * This class is used internally by the logger class to manage its sinks. It handles synchronization of the sinks with the sinks in the underlying spdlog logger such that all vector-like operations performed on this class are reflected in the underlying spdlog logger's set of sinks. + */ + class sink_vector { + public: + using Iterator = std::vector::iterator; ///< The iterator type + using ConstIterator = std::vector::const_iterator; ///< The const iterator type + + /** + * @brief Construct a new sink_vector object + * + * @param parent The logger whose sinks are being managed + * @param sinks The sinks to manage + */ + explicit sink_vector(logger& parent, std::vector sinks={}) : parent{parent}, sinks_{sinks} {} + + /** + * @brief Add a sink to the vector. + * + * @param sink The sink to add + */ + void push_back(sink_ptr const& sink); + + /** + * @brief Add a sink to the vector. + * + * @param sink The sink to add + */ + void push_back(sink_ptr&& sink); + + /** + * @brief Remove the last sink from the vector. + */ + void pop_back(); + + /** + * @brief Remove all sinks from the vector. + */ + void clear(); + + /** + * @brief Get an iterator to the beginning of the vector. + * + * @return Iterator The iterator + */ + Iterator begin() { return sinks_.begin(); } + + /** + * @brief Get an iterator to the end of the vector. + * + * @return Iterator The iterator + */ + Iterator end() { return sinks_.end(); } + + /** + * @brief Get a const iterator to the beginning of the vector. + * + * @return ConstIterator The const iterator + */ + ConstIterator begin() const { return sinks_.begin(); } + + /** + * @brief Get a const iterator to the end of the vector. + * + * @return ConstIterator The const iterator + */ + ConstIterator end() const { return sinks_.end(); } + + /** + * @brief Get a const iterator to the beginning of the vector. + * + * @return ConstIterator The const iterator + */ + ConstIterator cbegin() const { return sinks_.cbegin(); } + + /** + * @brief Get a const iterator to the end of the vector. + * + * @return ConstIterator The const iterator + */ + ConstIterator cend() const { return sinks_.cend(); } + private: + logger& parent; ///< The logger this vector belongs to + std::vector sinks_; ///< The sinks + }; + + // TODO: When we migrate to C++20 we can use std::format and format strings + // instead of the printf-style printing used here. + /** + * @brief Format and log a message at the specified level. + * + * This function performs printf-style formatting to avoid the need for fmt + * or spdlog's own templated APIs (which would require exposing spdlog + * symbols publicly) and then invokes the base implementation with the + * preformatted string. + * + * @param lvl The log level + * @param format The format string + * @param args The format arguments + */ + template + void log(level_enum lvl, std::string const& format, Args&&... args) { + auto convert_to_c_string = [](auto&& arg) -> decltype(auto) { + using ArgType = std::decay_t; + if constexpr (std::is_same_v) { + return arg.c_str(); + } else { + return std::forward(arg); + } + }; + + // NOLINTBEGIN(cppcoreguidelines-pro-type-vararg) + auto formatted_size = + std::snprintf(nullptr, 0, format.c_str(), convert_to_c_string(std::forward(args))...); + if (formatted_size < 0) { throw std::runtime_error("Error during formatting."); } + if (formatted_size == 0) { log(lvl, {}); } + auto size = static_cast(formatted_size) + 1; // for null terminator + // NOLINTNEXTLINE(modernize-avoid-c-arrays, cppcoreguidelines-avoid-c-arrays) + std::unique_ptr buf(new char[size]); + std::snprintf(buf.get(), size, format.c_str(), convert_to_c_string(std::forward(args))...); + // NOLINTEND(cppcoreguidelines-pro-type-vararg) + log(lvl, {buf.get(), buf.get() + size - 1}); // drop '\0' + }; + + /** + * @brief Log a message at the TRACE level. + * + * @param format The format string + * @param args The format arguments + */ + template + void trace(std::string const& format, Args&&... args) + { + log(level_enum::trace, format, std::forward(args)...); + } + + /** + * @brief Log a message at the DEBUG level. + * + * @param format The format string + * @param args The format arguments + */ + template + void debug(std::string const& format, Args&&... args) + { + log(level_enum::debug, format, std::forward(args)...); + } + + /** + * @brief Log a message at the INFO level. + * + * @param format The format string + * @param args The format arguments + */ + template + void info(std::string const& format, Args&&... args) + { + log(level_enum::info, format, std::forward(args)...); + } + + /** + * @brief Log a message at the WARN level. + * + * @param format The format string + * @param args The format arguments + */ + template + void warn(std::string const& format, Args&&... args) + { + log(level_enum::warn, format, std::forward(args)...); + } + + /** + * @brief Log a message at the ERROR level. + * + * @param format The format string + * @param args The format arguments + */ + template + void error(std::string const& format, Args&&... args) + { + log(level_enum::error, format, std::forward(args)...); + } + + /** + * @brief Log a message at the CRITICAL level. + * + * @param format The format string + * @param args The format arguments + */ + template + void critical(std::string const& format, Args&&... args) + { + log(level_enum::critical, format, std::forward(args)...); + } + + // Everything below here is conditionally compiled based on whether logging is supported. + /** + * @brief Construct a new logger object + * + * @param name The name of the logger + * @param filename The name of the log file + */ + logger(std::string name, std::string filename); + + /** + * @brief Construct a new logger object + * + * @param name The name of the logger + * @param stream The stream to log to + */ + logger(std::string name, std::ostream& stream); + + /** + * @brief Construct a new logger object + * + * @param name The name of the logger + * @param sinks The sinks to log to + * + * Note that we must use a vector because initializer_lists are not flexible + * enough to support programmatic construction in callers, and an + * iterator-based API would require templating and thus exposing spdlog + * types. + */ + logger(std::string name, std::vector sinks); + + /** + * @brief Destroy the logger object + */ + ~logger(); + + /** + * @brief Log a message at the specified level. + * + * This is the core logging routine that dispatches to spdlog. + * + * @param lvl The log level + * @param message The message to log + */ + void log(level_enum lvl, std::string const& message); + + /** + * @brief Get the sinks for the logger. + * + * @return The sinks + */ + const sink_vector& sinks() const; + + /** + * @brief Get the sinks for the logger. + * + * @return The sinks + */ + sink_vector& sinks(); + + /** + * @brief Get the current log level. + * + * @return The current log level + */ + level_enum level() const; + + /** + * @brief Set the log level. + * + * @param log_level The new log level + */ + void set_level(level_enum log_level); + + /** + * @brief Flush the logger. + */ + void flush(); + + /** + * @brief Flush all writes on the specified level or above. + */ + void flush_on(level_enum log_level); + + /** + * @brief Get the current flush level. + */ + level_enum flush_level() const; + + /** + * @brief Check if the logger should log a message at the specified level. + * + * @param msg_level The level of the message + * @return true if the message should be logged, false otherwise + */ + bool should_log(level_enum msg_level) const; + + /** + * @brief Set the pattern for the logger. + * + * @param pattern The pattern to use + */ + void set_pattern(std::string pattern); + + private: + std::unique_ptr impl; ///< The logger implementation + sink_vector sinks_; ///< The sinks for the logger +}; + +/** + * @brief A sink for the logger. + * + * These sinks are wrappers around the spdlog sinks that allow us to keep the + * spdlog types private and avoid exposing them in the public API. + */ +class sink { + public: + ~sink(); + protected: + explicit sink(std::unique_ptr impl); + std::unique_ptr impl; + // The sink vector needs to be able to pass the underlying sink to the spdlog logger. + friend class logger::sink_vector; +}; + +/** + * @brief A sink that writes to a file. + * + * See spdlog::sinks::basic_file_sink_mt for more information. + */ +class basic_file_sink_mt : public sink { + public: + basic_file_sink_mt(std::string const& filename, bool truncate = false); +}; + +/** + * @brief A sink that writes to an ostream. + * + * See spdlog::sinks::ostream_sink_mt for more information. + */ +class ostream_sink_mt : public sink { + public: + ostream_sink_mt(std::ostream& stream, bool force_flush = false); +}; + + +/** + * @brief Returns the default log filename for the global logger. + * + * If the environment variable `@_RAPIDS_LOGGER_NAMESPACE@_DEBUG_LOG_FILE` is defined, its value is used as the path and + * name of the log file. Otherwise, the file `@_RAPIDS_LOGGER_NAMESPACE@_log.txt` in the current working directory is used. + * + * @return std::string The default log file name. + */ +inline std::string default_log_filename() +{ + auto* filename = std::getenv("@_RAPIDS_LOGGER_MACRO_PREFIX@_DEBUG_LOG_FILE"); + // TODO: Do we prefer rmm's default (a file rmm_log.txt) or cudf's default (a + // stderr sink)? I think the latter is better. + return (filename == nullptr) ? std::string{"@_RAPIDS_LOGGER_NAMESPACE@_log.txt"} : std::string{filename}; +} + +/** + * @brief Get the default logger. + * + * @return logger& The default logger + */ +inline logger& default_logger() +{ + static logger logger_ = [] { + logger logger_ { + "@_RAPIDS_LOGGER_MACRO_PREFIX@", default_log_filename() + }; +#if @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL <= @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_INFO +#ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM + logger_.info("----- @_RAPIDS_LOGGER_MACRO_PREFIX@ LOG BEGIN [PTDS ENABLED] -----"); +#else + logger_.info("----- @_RAPIDS_LOGGER_MACRO_PREFIX@ LOG BEGIN [PTDS DISABLED] -----"); +#endif +#endif + return logger_; + }(); + return logger_; +} + +// Macros for easier logging, similar to spdlog. +#if !defined(@_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL) +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_INFO +#endif + +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOGGER_CALL(logger, level, ...) (logger).log(level, __VA_ARGS__) + +#if @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL <= @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_TRACE +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_TRACE(...) \ + @_RAPIDS_LOGGER_MACRO_PREFIX@_LOGGER_CALL(@_RAPIDS_LOGGER_NAMESPACE@::default_logger(), @_RAPIDS_LOGGER_NAMESPACE@::level_enum::trace, __VA_ARGS__) +#else +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_TRACE(...) (void)0 +#endif + +#if @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL <= @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_DEBUG +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_DEBUG(...) \ + @_RAPIDS_LOGGER_MACRO_PREFIX@_LOGGER_CALL(@_RAPIDS_LOGGER_NAMESPACE@::default_logger(), @_RAPIDS_LOGGER_NAMESPACE@::level_enum::debug, __VA_ARGS__) +#else +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_DEBUG(...) (void)0 +#endif + +#if @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL <= @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_INFO +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_INFO(...) @_RAPIDS_LOGGER_MACRO_PREFIX@_LOGGER_CALL(@_RAPIDS_LOGGER_NAMESPACE@::default_logger(), @_RAPIDS_LOGGER_NAMESPACE@::level_enum::info, __VA_ARGS__) +#else +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_INFO(...) (void)0 +#endif + +#if @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL <= @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_WARN +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_WARN(...) @_RAPIDS_LOGGER_MACRO_PREFIX@_LOGGER_CALL(@_RAPIDS_LOGGER_NAMESPACE@::default_logger(), @_RAPIDS_LOGGER_NAMESPACE@::level_enum::warn, __VA_ARGS__) +#else +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_WARN(...) (void)0 +#endif + +#if @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL <= @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_ERROR +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ERROR(...) \ + @_RAPIDS_LOGGER_MACRO_PREFIX@_LOGGER_CALL(@_RAPIDS_LOGGER_NAMESPACE@::default_logger(), @_RAPIDS_LOGGER_NAMESPACE@::level_enum::error, __VA_ARGS__) +#else +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ERROR(...) (void)0 +#endif + +#if @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL <= @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_CRITICAL +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_CRITICAL(...) \ + @_RAPIDS_LOGGER_MACRO_PREFIX@_LOGGER_CALL(@_RAPIDS_LOGGER_NAMESPACE@::default_logger(), @_RAPIDS_LOGGER_NAMESPACE@::level_enum::critical, __VA_ARGS__) +#else +#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_CRITICAL(...) (void)0 +#endif + +} // namespace @_RAPIDS_LOGGER_NAMESPACE@ diff --git a/rapids_logger/logger_impl.hpp.in b/rapids_logger/logger_impl.hpp.in new file mode 100644 index 000000000..717a00ac9 --- /dev/null +++ b/rapids_logger/logger_impl.hpp.in @@ -0,0 +1,205 @@ +/* + * 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. + */ + +#pragma once + +#include "../logger.hpp" + +// Include C headers for which we need symbols to be made public and don't want +// the below symbol hiding pattern to apply. +#include +#include +#include + +// Start hiding before including spdlog headers. +#pragma GCC visibility push(hidden) + +#include +#include +#include + +#include +#include +#include + +namespace @_RAPIDS_LOGGER_NAMESPACE@ { + +namespace detail { +namespace { + +/** + * @brief Convert a string to a log level. + * + * This function is used to process env-var specifications of log levels. + * @param env_lvl_str The string to convert. + * @return The log level. + */ +level_enum string_to_level(std::string_view const env_lvl_str) +{ + if (env_lvl_str == "TRACE") return level_enum::trace; + if (env_lvl_str == "DEBUG") return level_enum::debug; + if (env_lvl_str == "INFO") return level_enum::info; + if (env_lvl_str == "WARN") return level_enum::warn; + if (env_lvl_str == "ERROR") return level_enum::error; + if (env_lvl_str == "CRITICAL") return level_enum::critical; + if (env_lvl_str == "OFF") return level_enum::off; + std::ostringstream os{}; + os << "Invalid logging level: " << env_lvl_str; + throw std::invalid_argument(os.str()); +} + +/** + * @brief Convert a log level to an spdlog log level. + * + * @param lvl The log level to convert. + * @return The spdlog log level. + */ +spdlog::level::level_enum to_spdlog_level(level_enum lvl) +{ + return static_cast(static_cast(lvl)); +} + +/** + * @brief Convert an spdlog log level to a log level. + * + * @param lvl The spdlog log level to convert. + * @return The log level. + */ +level_enum from_spdlog_level(spdlog::level::level_enum lvl) +{ + return static_cast(static_cast(lvl)); +} +} + +/** + * @brief The sink_impl class is a wrapper around an spdlog sink. + * + * This class is the impl part of the PImpl for the sink. + */ +class sink_impl { +public: + sink_impl(std::shared_ptr sink) : underlying{sink} {} +private: + std::shared_ptr underlying; + // The sink_vector needs to be able to pass the underlying sink to the spdlog logger. + friend class logger::sink_vector; +}; + +/** + * @brief The logger_impl class is a wrapper around an spdlog logger. + * + * This class is the impl part of the PImpl for the logger. + */ +class logger_impl { + public: + logger_impl(std::string name) : underlying{spdlog::logger{name}} { + underlying.set_pattern("[%6t][%H:%M:%S:%f][%-6l] %v"); + auto const env_logging_level = + std::getenv("@_RAPIDS_LOGGER_MACRO_PREFIX@_DEFAULT_LOGGING_LEVEL"); + if (env_logging_level != nullptr) { set_level(detail::string_to_level(env_logging_level)); } + auto const env_flush_level = std::getenv("@_RAPIDS_LOGGER_MACRO_PREFIX@_DEFAULT_FLUSH_LEVEL"); + if (env_flush_level != nullptr) { flush_on(detail::string_to_level(env_flush_level)); } + } + + void log(level_enum lvl, std::string const& message) { underlying.log(to_spdlog_level(lvl), message); } + void set_level(level_enum log_level) { underlying.set_level(to_spdlog_level(log_level)); } + void flush() { underlying.flush(); } + void flush_on(level_enum log_level) { underlying.flush_on(to_spdlog_level(log_level)); } + level_enum flush_level() const { return from_spdlog_level(underlying.flush_level()); } + bool should_log(level_enum lvl) const { return underlying.should_log(to_spdlog_level(lvl)); } + level_enum level() const { return from_spdlog_level(underlying.level()); } + void set_pattern(std::string pattern) { underlying.set_pattern(pattern); } + const std::vector &sinks() const { return underlying.sinks(); } + std::vector &sinks() { return underlying.sinks(); } + +private: + spdlog::logger underlying; ///< The spdlog logger +}; + +} // namespace detail + +// Sink vector functions +void logger::sink_vector::push_back(sink_ptr const& sink) { + sinks_.push_back(sink); + parent.impl->sinks().push_back(sink->impl->underlying); +} +void logger::sink_vector::push_back(sink_ptr&& sink) { + sinks_.push_back(sink); + parent.impl->sinks().push_back(sink->impl->underlying); +} +void logger::sink_vector::pop_back() { + sinks_.pop_back(); + parent.impl->sinks().pop_back(); +} +void logger::sink_vector::clear() { + sinks_.clear(); + parent.impl->sinks().clear(); +} + +// Sink methods +sink::sink(std::unique_ptr impl) : impl{std::move(impl)} {} + +sink::~sink() = default; + +basic_file_sink_mt::basic_file_sink_mt(std::string const& filename, bool truncate) + : sink{std::make_unique(std::make_shared(filename, truncate))} {} + +ostream_sink_mt::ostream_sink_mt(std::ostream& stream, bool force_flush) + : sink{std::make_unique(std::make_shared(stream, force_flush))} {} + +// Logger methods +logger::logger(std::string name, std::string filename) + : impl{std::make_unique(name)}, sinks_{*this} { + sinks_.push_back(std::make_shared(filename, true)); +} + +logger::logger(std::string name, std::ostream& stream) + : impl{std::make_unique(name)}, sinks_{*this} { + sinks_.push_back(std::make_shared(stream)); +} + +logger::logger(std::string name, std::vector sinks) + : impl{std::make_unique(name)}, sinks_{*this} { + for (auto const& s : sinks) { + sinks_.push_back(s); + } +} + +logger::~logger() = default; +logger::logger(logger&& other) = default; +logger& logger::operator=(logger&& other) { + impl = std::move(other.impl); + sinks_.clear(); + for (auto const& s : other.sinks_) { + sinks_.push_back(s); + } + return *this; +} + +void logger::log(level_enum lvl, std::string const& message) { impl->log(lvl, message); } +void logger::set_level(level_enum log_level) { impl->set_level(log_level); } +void logger::flush() { impl->flush(); } +void logger::flush_on(level_enum log_level) { impl->flush_on(log_level); } +level_enum logger::flush_level() const { return impl->flush_level(); } +bool logger::should_log(level_enum lvl) const { return impl->should_log(lvl); } +level_enum logger::level() const { return impl->level(); } +void logger::set_pattern(std::string pattern) { impl->set_pattern(pattern); } +const logger::sink_vector& logger::sinks() const { return sinks_; } +logger::sink_vector& logger::sinks() { return sinks_; } + +} // namespace @_RAPIDS_LOGGER_NAMESPACE@ +// This visibility pragma must be here so that both our logger types and those coming from includes are hidden. +#pragma GCC visibility pop diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 476028af0..b718691ca 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -27,8 +27,9 @@ rapids_cmake_support_conda_env(conda_env) function(ConfigureTestInternal TEST_NAME) add_executable(${TEST_NAME} ${ARGN}) target_include_directories(${TEST_NAME} PRIVATE "$") - target_link_libraries(${TEST_NAME} GTest::gmock GTest::gtest GTest::gmock_main GTest::gtest_main - pthread rmm $) + target_link_libraries( + ${TEST_NAME} PRIVATE GTest::gmock GTest::gtest GTest::gmock_main GTest::gtest_main pthread rmm + $) set_target_properties( ${TEST_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON @@ -40,9 +41,11 @@ function(ConfigureTestInternal TEST_NAME) CUDA_STANDARD 17 CUDA_STANDARD_REQUIRED ON) target_compile_definitions(${TEST_NAME} - PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}") + PUBLIC "RMM_LOG_ACTIVE_LEVEL=RMM_LOG_LEVEL_${RMM_LOGGING_LEVEL}") target_compile_options(${TEST_NAME} PUBLIC $<$:-Wall -Werror>) + target_link_libraries(${TEST_NAME} PRIVATE rmm_test_logger) + if(DISABLE_DEPRECATION_WARNING) target_compile_options( ${TEST_NAME} PUBLIC $<$:-Xcompiler=-Wno-deprecated-declarations>) @@ -127,6 +130,12 @@ function(ConfigureTest TEST_NAME) endfunction() +# Create an object library for the logger so that we don't have to recompile it. +add_library(rmm_test_logger OBJECT) +target_link_libraries(rmm_test_logger PRIVATE rmm_logger_impl) + +include(../cmake/thirdparty/get_spdlog.cmake) + # test sources # device mr_ref tests @@ -159,6 +168,8 @@ ConfigureTest(STATISTICS_TEST mr/device/statistics_mr_tests.cpp) # tracking adaptor tests ConfigureTest(TRACKING_TEST mr/device/tracking_mr_tests.cpp) +target_link_libraries(TRACKING_TEST PRIVATE spdlog::spdlog_header_only) +target_link_libraries(TRACKING_PTDS_TEST PRIVATE spdlog::spdlog_header_only) # out-of-memory callback adaptor tests ConfigureTest(FAILURE_CALLBACK_TEST mr/device/failure_callback_mr_tests.cpp) @@ -195,6 +206,8 @@ ConfigureTest(PREFETCH_TEST prefetch_tests.cpp) # logger tests ConfigureTest(LOGGER_TEST logger_tests.cpp) +target_link_libraries(LOGGER_TEST PRIVATE spdlog::spdlog_header_only) +target_link_libraries(LOGGER_PTDS_TEST PRIVATE spdlog::spdlog_header_only) # arena MR tests ConfigureTest(ARENA_MR_TEST mr/device/arena_mr_tests.cpp GPUS 1 PERCENT 100) diff --git a/tests/logger_tests.cpp b/tests/logger_tests.cpp index 8a5d37be2..619143294 100644 --- a/tests/logger_tests.cpp +++ b/tests/logger_tests.cpp @@ -152,8 +152,8 @@ TEST(Adaptor, MultiSinkConstructor) std::string filename2{temp_dir.generate_path("test_multi_2.txt")}; rmm::mr::cuda_memory_resource upstream; - auto file_sink1 = std::make_shared(filename1, true); - auto file_sink2 = std::make_shared(filename2, true); + auto file_sink1 = std::make_shared(filename1, true); + auto file_sink2 = std::make_shared(filename2, true); rmm::mr::logging_resource_adaptor log_mr{&upstream, {file_sink1, file_sink2}}; diff --git a/tests/mr/device/tracking_mr_tests.cpp b/tests/mr/device/tracking_mr_tests.cpp index 3fce55fb8..c40a9127d 100644 --- a/tests/mr/device/tracking_mr_tests.cpp +++ b/tests/mr/device/tracking_mr_tests.cpp @@ -23,7 +23,6 @@ #include #include -#include namespace rmm::test { namespace { @@ -203,9 +202,9 @@ TEST(TrackingTest, DeallocWrongBytes) TEST(TrackingTest, LogOutstandingAllocations) { std::ostringstream oss; - auto oss_sink = std::make_shared(oss); - rmm::detail::logger().sinks().push_back(oss_sink); - auto old_level = rmm::detail::logger().level(); + auto oss_sink = std::make_shared(oss); + auto old_level = rmm::default_logger().level(); + rmm::default_logger().sinks().push_back(oss_sink); tracking_adaptor mr{rmm::mr::get_current_device_resource_ref()}; std::vector allocations; @@ -213,10 +212,10 @@ TEST(TrackingTest, LogOutstandingAllocations) allocations.push_back(mr.allocate(ten_MiB)); } - rmm::detail::logger().set_level(spdlog::level::debug); + rmm::default_logger().set_level(rmm::level_enum::debug); EXPECT_NO_THROW(mr.log_outstanding_allocations()); -#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_DEBUG +#if RMM_LOG_ACTIVE_LEVEL <= RMM_LOG_LEVEL_DEBUG EXPECT_NE(oss.str().find("Outstanding Allocations"), std::string::npos); #endif @@ -224,8 +223,8 @@ TEST(TrackingTest, LogOutstandingAllocations) mr.deallocate(allocation, ten_MiB); } - rmm::detail::logger().set_level(old_level); - rmm::detail::logger().sinks().pop_back(); + rmm::default_logger().set_level(old_level); + rmm::default_logger().sinks().pop_back(); } } // namespace From c9c6039ab71f91fb41376abea7ec36b8a2563de1 Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Tue, 26 Nov 2024 15:27:22 -0600 Subject: [PATCH 503/675] Add breaking change workflow trigger (#1719) * add breaking change notifier [skip ci] * test commit * use target --- .../trigger-breaking-change-alert.yaml | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/trigger-breaking-change-alert.yaml diff --git a/.github/workflows/trigger-breaking-change-alert.yaml b/.github/workflows/trigger-breaking-change-alert.yaml new file mode 100644 index 000000000..3b972f31c --- /dev/null +++ b/.github/workflows/trigger-breaking-change-alert.yaml @@ -0,0 +1,26 @@ +name: Trigger Breaking Change Notifications + +on: + pull_request_target: + types: + - closed + - reopened + - labeled + - unlabeled + +jobs: + trigger-notifier: + if: contains(github.event.pull_request.labels.*.name, 'breaking') + secrets: inherit + uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@branch-24.12 + with: + sender_login: ${{ github.event.sender.login }} + sender_avatar: ${{ github.event.sender.avatar_url }} + repo: ${{ github.repository }} + pr_number: ${{ github.event.pull_request.number }} + pr_title: "${{ github.event.pull_request.title }}" + pr_body: "${{ github.event.pull_request.body || '_Empty PR description_' }}" + pr_base_ref: ${{ github.event.pull_request.base.ref }} + pr_author: ${{ github.event.pull_request.user.login }} + event_action: ${{ github.event.action }} + pr_merged: ${{ github.event.pull_request.merged }} From a6a455dc23404b531db8271aaf84b688b2ffabc9 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 26 Nov 2024 16:38:51 -0600 Subject: [PATCH 504/675] Require approval to run CI on draft PRs (#1737) By default, CI runs on draft PRs. This leads to many CI runs that may be unnecessary. With this PR's change to `.github/copy-pr-bot.yaml`, an `/ok to test` comment from a trusted user is required to trigger CI on draft PRs. Non-draft PRs will run CI by default, assuming that all commits are signed by trusted users. Otherwise an `/ok to test` is required (as before) -- see the `copy-pr-bot` docs at https://docs.gha-runners.nvidia.com/apps/copy-pr-bot/ for more information. Part of https://github.com/rapidsai/build-planning/issues/123. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1737 --- .github/copy-pr-bot.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/copy-pr-bot.yaml b/.github/copy-pr-bot.yaml index 895ba83ee..e0ea775aa 100644 --- a/.github/copy-pr-bot.yaml +++ b/.github/copy-pr-bot.yaml @@ -2,3 +2,4 @@ # https://docs.gha-runners.nvidia.com/apps/copy-pr-bot/ enabled: true +auto_sync_draft: false From f9b9f843466b2dcd8872f1707d274ad15be37324 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 26 Nov 2024 15:45:55 -0800 Subject: [PATCH 505/675] Use consistent signature for target_link_libraries (#1738) It looks like while #1722 introduced usage of the modern target_link_libraries syntax it did not adjust all other calls because I wasn't setting up coverage usage locally or anywhere else in CI. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Kyle Edwards (https://github.com/KyleFromNVIDIA) - Robert Maynard (https://github.com/robertmaynard) URL: https://github.com/rapidsai/rmm/pull/1738 --- tests/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b718691ca..413f27f26 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -69,7 +69,7 @@ function(ConfigureTestInternal TEST_NAME) ${TEST_NAME} PUBLIC $<$:-O0 --coverage -fprofile-abs-path -fkeep-inline-functions -fno-elide-constructors>) target_link_options(${TEST_NAME} PRIVATE --coverage) - target_link_libraries(${TEST_NAME} gcov) + target_link_libraries(${TEST_NAME} PRIVATE gcov) endif() # Add coverage-generated files to clean target @@ -111,13 +111,13 @@ function(ConfigureTest TEST_NAME) # Test with legacy default stream. ConfigureTestInternal(${TEST_NAME} ${_RMM_TEST_UNPARSED_ARGUMENTS}) - target_link_libraries(${TEST_NAME} ${cudart_link_libs}) + target_link_libraries(${TEST_NAME} PRIVATE ${cudart_link_libs}) # Test with per-thread default stream. string(REGEX REPLACE "_TEST$" "_PTDS_TEST" PTDS_TEST_NAME "${TEST_NAME}") ConfigureTestInternal("${PTDS_TEST_NAME}" ${_RMM_TEST_UNPARSED_ARGUMENTS}) target_compile_definitions("${PTDS_TEST_NAME}" PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM) - target_link_libraries(${PTDS_TEST_NAME} ${cudart_link_libs}) + target_link_libraries(${PTDS_TEST_NAME} PRIVATE ${cudart_link_libs}) foreach(name ${TEST_NAME} ${PTDS_TEST_NAME} ${NS_TEST_NAME}) rapids_test_add( From d4066fa611c803430c9bc5dbe8e243f89bb9a25c Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 27 Nov 2024 06:42:20 -0800 Subject: [PATCH 506/675] Fix some logger issues (#1739) This fixes a handful of issues uncovered in downstream CI after #1722. The following are bugs introduced in #1722: - When using rmm from the build directory rather than an installation, the namespaced targets are not present so we must generate aliases. - The `RMM_LOGGING_ASSERT` macro is never used in rmm itself, so we didn't catch that it was still using the old version of the logger. While fixing the above, I also uncovered that building fmt in this environment unearths a gcc bug. The following are underlying issues uncovered by #1722: - spdlog's fmt CMake linkage is determined at build time. As a result, the conda package for spdlog is hardcoded to use fmt as a library (static or shared depends on what the `fmt::fmt` target winds up being when a consumer using spdlog finds fmt in CMake), which means that is propagated to all consumers of the librmm package via its CMake. This means that we often wind up with both fmt_header_only and fmt as link targets for many RAPIDS libraries. For now, this PR makes it so that if `rapids_cpm_find(spdlog)` does not find a copy of spdlog locally, the cloned version will use an external header-only fmt via rapids-cmake's logic, which ensures that packages like wheels do not export a libfmt or libspdlog dependency. However, in environments where `rapids_cpm_find(spdlog)` does find a preexisting package, we allow that package's fmt linkage to propagate. In conda environments, we know that this fmt linkage is to the library, so we keep fmt as part of rmm's runtime dependencies (by placing it in host and relying on the run export) so that libfmt is always available in environments using rmm. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1739 --- CMakeLists.txt | 2 ++ ci/check_symbols.sh | 4 +++- cmake/thirdparty/get_spdlog.cmake | 8 ++++++++ conda/environments/all_cuda-118_arch-x86_64.yaml | 1 - conda/environments/all_cuda-125_arch-x86_64.yaml | 1 - conda/recipes/librmm/meta.yaml | 14 +++++++------- dependencies.yaml | 1 - include/rmm/detail/logging_assert.hpp | 2 +- rapids_logger/logger_impl.hpp.in | 6 ++++++ 9 files changed, 27 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a7ba3525..8c5bd5428 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,6 +75,8 @@ rapids_cpm_init() add_subdirectory(rapids_logger) rapids_make_logger(rmm EXPORT_SET rmm-exports) +add_library(rmm::rmm_logger ALIAS rmm_logger) +add_library(rmm::rmm_logger_impl ALIAS rmm_logger_impl) include(cmake/thirdparty/get_cccl.cmake) include(cmake/thirdparty/get_nvtx.cmake) diff --git a/ci/check_symbols.sh b/ci/check_symbols.sh index 155e509da..377a93cac 100755 --- a/ci/check_symbols.sh +++ b/ci/check_symbols.sh @@ -53,7 +53,9 @@ for dso_file in ${dso_files}; do fi echo "checking for 'spdlog::' symbols..." - if grep -E 'spdlog\:\:' < "${symbol_file}"; then + if grep -E 'spdlog\:\:' < "${symbol_file}" \ + | grep -v 'std\:\:_Destroy_aux' + then raise-symbols-found-error 'spdlog::' fi echo "No symbol visibility issues found" diff --git a/cmake/thirdparty/get_spdlog.cmake b/cmake/thirdparty/get_spdlog.cmake index 212f604c3..febdf4c5c 100644 --- a/cmake/thirdparty/get_spdlog.cmake +++ b/cmake/thirdparty/get_spdlog.cmake @@ -17,6 +17,14 @@ function(find_and_configure_spdlog) include(${rapids-cmake-dir}/cpm/spdlog.cmake) rapids_cpm_spdlog( + # The conda package for fmt is hard-coded to assume that we use a preexisting fmt library. This + # is why we have always had a libfmt linkage despite choosing to specify the header-only version + # of fmt. We need a more robust way of modifying this to support fully self-contained build and + # usage even in environments where fmt and/or spdlog are already present. The crudest solution + # would be to modify the interface compile definitions and link libraries of the spdlog target, + # if necessary. For now I'm specifying EXTERNAL_FMT_HO here so that in environments where spdlog + # is cloned and built from source we wind up with the behavior that we expect, but we'll have to + # resolve this properly eventually. FMT_OPTION "EXTERNAL_FMT_HO" INSTALL_EXPORT_SET rmm-exports BUILD_EXPORT_SET rmm-exports) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 519c056b5..ad2cbf9e6 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -35,7 +35,6 @@ dependencies: - python>=3.10,<3.13 - rapids-build-backend>=0.3.0,<0.4.0.dev0 - scikit-build-core >=0.10.0 -- spdlog>=1.14.1,<1.15 - sphinx - sphinx-copybutton - sphinx-markdown-tables diff --git a/conda/environments/all_cuda-125_arch-x86_64.yaml b/conda/environments/all_cuda-125_arch-x86_64.yaml index 86e887c21..520c7d743 100644 --- a/conda/environments/all_cuda-125_arch-x86_64.yaml +++ b/conda/environments/all_cuda-125_arch-x86_64.yaml @@ -34,7 +34,6 @@ dependencies: - python>=3.10,<3.13 - rapids-build-backend>=0.3.0,<0.4.0.dev0 - scikit-build-core >=0.10.0 -- spdlog>=1.14.1,<1.15 - sphinx - sphinx-copybutton - sphinx-markdown-tables diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 53e16ebdc..31aaf0e63 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -26,13 +26,13 @@ requirements: - {{ stdlib("c") }} host: - cuda-version ={{ cuda_version }} - # We require spdlog and fmt (which was de-vendored from spdlog - # conda-forge packages in 1.11.0) so that the spdlog headers are not - # pulled by CPM and installed as a part of the rmm packages. However, - # building against librmm still requires these headers. They are also - # added as a run requirement via the packages' run_exports. + # We need fmt here for now because the conda spdlog package is hard-coded + # to use fmt as a compiled library, not header-only, so we must ensure that + # the library is present for now so that if a downstream library tries to + # build against rmm and some other package in its build environment uses + # fmt (or spdlog) that the default rmm build is consistent with such + # environments. - fmt {{ fmt_version }} - - spdlog {{ spdlog_version }} build: script_env: @@ -77,8 +77,8 @@ outputs: {% if cuda_major == "11" %} - cudatoolkit {% endif %} + # See comment about fmt in the build section above. - fmt {{ fmt_version }} - - spdlog {{ spdlog_version }} test: commands: - test -d "${PREFIX}/include/rmm" diff --git a/dependencies.yaml b/dependencies.yaml index 070248edb..f92268639 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -112,7 +112,6 @@ dependencies: - c-compiler - cxx-compiler - fmt>=11.0.2,<12 - - spdlog>=1.14.1,<1.15 specific: - output_types: conda matrices: diff --git a/include/rmm/detail/logging_assert.hpp b/include/rmm/detail/logging_assert.hpp index c3b12ffe3..d5b2ca10a 100644 --- a/include/rmm/detail/logging_assert.hpp +++ b/include/rmm/detail/logging_assert.hpp @@ -38,7 +38,7 @@ if (!success) { \ RMM_LOG_CRITICAL( \ "[" __FILE__ ":" RMM_STRINGIFY(__LINE__) "] Assertion " RMM_STRINGIFY(_expr) " failed."); \ - rmm::detail::logger().flush(); \ + rmm::default_logger().flush(); \ /* NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay) */ \ assert(success); \ } \ diff --git a/rapids_logger/logger_impl.hpp.in b/rapids_logger/logger_impl.hpp.in index 717a00ac9..d5b467571 100644 --- a/rapids_logger/logger_impl.hpp.in +++ b/rapids_logger/logger_impl.hpp.in @@ -26,10 +26,16 @@ // Start hiding before including spdlog headers. #pragma GCC visibility push(hidden) +// This issue claims to have been resolved in gcc 8, but we still seem to encounter it here. +// The code compiles and links and all tests pass, and nm shows symbols resolved as expected. +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80947 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wattributes" #include #include #include +#pragma GCC diagnostic pop #include #include From 00287e067f036854fb94658c4050800b61bd5e6f Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 4 Dec 2024 18:21:22 -0600 Subject: [PATCH 507/675] Remove upper bounds on cuda-python to allow 12.6.2 and 11.8.5 (#1729) Now that some upstream bugs have been fixed, we can allow cuda-python 12.6.2 and 11.8.5. See https://github.com/NVIDIA/cuda-python/issues/226#issuecomment-2472355738 for more information. Authors: - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1729 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-125_arch-x86_64.yaml | 2 +- conda/recipes/rmm/meta.yaml | 8 ++++---- dependencies.yaml | 4 ++-- python/rmm/pyproject.toml | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index ad2cbf9e6..f3ffc02c3 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -10,7 +10,7 @@ dependencies: - clang-tools==16.0.6 - clang==16.0.6 - cmake>=3.26.4,!=3.30.0 -- cuda-python>=11.7.1,<12.0a0,<=11.8.3 +- cuda-python>=11.7.1,<12.0a0 - cuda-version=11.8 - cudatoolkit - cxx-compiler diff --git a/conda/environments/all_cuda-125_arch-x86_64.yaml b/conda/environments/all_cuda-125_arch-x86_64.yaml index 520c7d743..057db5ba9 100644 --- a/conda/environments/all_cuda-125_arch-x86_64.yaml +++ b/conda/environments/all_cuda-125_arch-x86_64.yaml @@ -11,7 +11,7 @@ dependencies: - clang==16.0.6 - cmake>=3.26.4,!=3.30.0 - cuda-nvcc -- cuda-python>=12.0,<13.0a0,<=12.6.0 +- cuda-python>=12.0,<13.0a0 - cuda-version=12.5 - cxx-compiler - cython>=3.0.0 diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 8f6e13fd7..fa0d1e25f 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -57,10 +57,10 @@ requirements: - cuda-version ={{ cuda_version }} {% if cuda_major == "11" %} - cudatoolkit - - cuda-python >=11.7.1,<12.0a0,<=11.8.3 + - cuda-python >=11.7.1,<12.0a0 {% else %} - cuda-cudart-dev - - cuda-python >=12.0,<13.0a0,<=12.6.0 + - cuda-python >=12.0,<13.0a0 {% endif %} - cython >=3.0.0 - rapids-build-backend >=0.3.0,<0.4.0.dev0 @@ -70,10 +70,10 @@ requirements: run: {% if cuda_major == "11" %} - cudatoolkit - - cuda-python >=11.7.1,<12.0a0,<=11.8.3 + - cuda-python >=11.7.1,<12.0a0 {% else %} - cuda-cudart - - cuda-python >=12.0,<13.0a0,<=12.6.0 + - cuda-python >=12.0,<13.0a0 {% endif %} - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - numba >=0.57 diff --git a/dependencies.yaml b/dependencies.yaml index f92268639..ab248e02f 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -152,10 +152,10 @@ dependencies: - matrix: cuda: "12.*" packages: - - &cuda_python12 cuda-python>=12.0,<13.0a0,<=12.6.0 + - &cuda_python12 cuda-python>=12.0,<13.0a0 - matrix: # All CUDA 11 versions packages: - - &cuda_python11 cuda-python>=11.7.1,<12.0a0,<=11.8.3 + - &cuda_python11 cuda-python>=11.7.1,<12.0a0 - output_types: [requirements, pyproject] matrices: - matrix: diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index dfa680a98..fb479bc17 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -30,7 +30,7 @@ authors = [ license = { text = "Apache 2.0" } requires-python = ">=3.10" dependencies = [ - "cuda-python>=11.7.1,<12.0a0,<=11.8.3", + "cuda-python>=11.7.1,<12.0a0", "numba>=0.57", "numpy>=1.23,<3.0a0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. @@ -128,7 +128,7 @@ dependencies-file = "../../dependencies.yaml" matrix-entry = "cuda_suffixed=true" requires = [ "cmake>=3.26.4,!=3.30.0", - "cuda-python>=11.7.1,<12.0a0,<=11.8.3", + "cuda-python>=11.7.1,<12.0a0", "cython>=3.0.0", "librmm==25.2.*,>=0.0.0a0", "ninja", From 9b0e71df27da4e0d608617cd3e26cabfaed12d3c Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 6 Dec 2024 09:48:57 -0600 Subject: [PATCH 508/675] Revise README. (#1747) This PR applies some minor README revisions, like fixing outdated links. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1747 --- README.md | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index d72d411f5..1d1f7a8ee 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,11 @@ ## Resources -- [RMM Reference Documentation](https://docs.rapids.ai/api/rmm/stable/): Python API reference, tutorials, and topic guides. -- [librmm Reference Documentation](https://docs.rapids.ai/api/librmm/stable/): C/C++ CUDA library API reference. -- [Getting Started](https://rapids.ai/start.html): Instructions for installing RMM. -- [RAPIDS Community](https://rapids.ai/community.html): Get help, contribute, and collaborate. -- [GitHub repository](https://github.com/rapidsai/rmm): Download the RMM source code. -- [Issue tracker](https://github.com/rapidsai/rmm/issues): Report issues or request features. +- [RMM Reference Documentation](https://docs.rapids.ai/api/rmm/stable/): Python and C++ API references, tutorials, and topic guides. +- [RAPIDS Installation Guide](https://docs.rapids.ai/install/): Instructions for installing RMM. +- [GitHub Repository](https://github.com/rapidsai/rmm): Download the RMM source code. +- [Issue Tracker](https://github.com/rapidsai/rmm/issues): Report issues or request features. +- [RAPIDS Community](https://rapids.ai/learn-more/#get-involved): Get help, contribute, and collaborate. ## Overview @@ -48,7 +47,7 @@ Note: RMM is supported only on Linux, and only tested with Python versions 3.10, Note: The RMM package from conda requires building with GCC 9 or later. Otherwise, your application may fail to build. -See the [Get RAPIDS version picker](https://rapids.ai/start.html) for more OS and version info. +See the [RAPIDS Installation Guide](https://docs.rapids.ai/install/) for system requirements. ## Building from Source @@ -82,16 +81,16 @@ For more details, see [pyproject.toml](python/rmm/pyproject.toml) To install RMM from source, ensure the dependencies are met and follow the steps below: -- Clone the repository and submodules +- Clone the repository ```bash -$ git clone --recurse-submodules https://github.com/rapidsai/rmm.git +$ git clone https://github.com/rapidsai/rmm.git $ cd rmm ``` - Create the conda development environment `rmm_dev` ```bash # create the conda environment (assuming in base `rmm` directory) -$ conda env create --name rmm_dev --file conda/environments/all_cuda-118_arch-x86_64.yaml +$ conda env create --name rmm_dev --file conda/environments/all_cuda-125_arch-x86_64.yaml # activate the environment $ conda activate rmm_dev ``` @@ -153,7 +152,7 @@ directory to avoid repeated downloads of the third-party dependencies. ## Using RMM in a downstream CMake project The installed RMM library provides a set of config files that makes it easy to -integrate RMM into your own CMake project. In your `CMakeLists.txt`, just add +integrate RMM into your own CMake project. Add the following to `CMakeLists.txt`: ```cmake find_package(rmm [VERSION]) @@ -367,8 +366,8 @@ deallocation is performed (including in the destructor). The user must therefore the device active during _creation_ of an `rmm::device_buffer` matches the active device of the memory resource being used. -Here is an incorrect example that creates a memory resource on device zero and then uses it to -allocate a `device_buffer` on device one: +Here is an incorrect example that creates a memory resource on device `0` and then uses it to +allocate a `device_buffer` on device `1`: ```c++ { @@ -382,7 +381,7 @@ allocate a `device_buffer` on device one: } ``` -A correct example creates the device buffer with device zero active. After that it is safe to switch +A correct example creates the device buffer with device `0` active. After that it is safe to switch devices and let the buffer go out of scope and destruct with a different device active. For example, this code is correct: @@ -879,7 +878,7 @@ Out[6]: 'total_count': 1} ``` -## Taking ownership of C++ objects from Python. +## Taking ownership of C++ objects from Python When interacting with a C++ library that uses RMM from Python, one must be careful when taking ownership of `rmm::device_buffer` objects From e0e451751ddf92e2377d430714f622c2bb72e3f1 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 6 Dec 2024 08:57:13 -0800 Subject: [PATCH 509/675] Update build.sh (#1749) Resolves #1742 Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1749 --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 4d61aceee..5a712c69b 100755 --- a/build.sh +++ b/build.sh @@ -170,7 +170,7 @@ fi # Build and install the rmm Python package if (( NUMARGS == 0 )) || hasArg rmm; then echo "building and installing rmm..." - SKBUILD_CMAKE_ARGS="${EXTRA_CMAKE_ARGS}" python -m pip install \ + SKBUILD_CMAKE_ARGS="-DCMAKE_PREFIX_PATH=${INSTALL_PREFIX};${EXTRA_CMAKE_ARGS}" python -m pip install \ --no-build-isolation \ --no-deps \ --config-settings rapidsai.disable-cuda=true \ From fc9c1389307db60c25a5bd015f21a835fc708226 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 6 Dec 2024 18:43:55 -0600 Subject: [PATCH 510/675] Update cuda-python lower bounds to 12.6.2 / 11.8.5 (#1751) We require a newer cuda-python lower bound for new features and to use the new layout. This will fix a number of errors observed when the runtime version of cuda-python is older than the version used to build packages using Cython features from cuda-python. See https://github.com/rapidsai/build-planning/issues/117#issuecomment-2524250915 for details. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1751 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-125_arch-x86_64.yaml | 2 +- conda/recipes/rmm/meta.yaml | 8 ++++---- dependencies.yaml | 4 ++-- python/rmm/pyproject.toml | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index f3ffc02c3..b885e77cf 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -10,7 +10,7 @@ dependencies: - clang-tools==16.0.6 - clang==16.0.6 - cmake>=3.26.4,!=3.30.0 -- cuda-python>=11.7.1,<12.0a0 +- cuda-python>=11.8.5,<12.0a0 - cuda-version=11.8 - cudatoolkit - cxx-compiler diff --git a/conda/environments/all_cuda-125_arch-x86_64.yaml b/conda/environments/all_cuda-125_arch-x86_64.yaml index 057db5ba9..0d0659215 100644 --- a/conda/environments/all_cuda-125_arch-x86_64.yaml +++ b/conda/environments/all_cuda-125_arch-x86_64.yaml @@ -11,7 +11,7 @@ dependencies: - clang==16.0.6 - cmake>=3.26.4,!=3.30.0 - cuda-nvcc -- cuda-python>=12.0,<13.0a0 +- cuda-python>=12.6.2,<13.0a0 - cuda-version=12.5 - cxx-compiler - cython>=3.0.0 diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index fa0d1e25f..206a80c46 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -57,10 +57,10 @@ requirements: - cuda-version ={{ cuda_version }} {% if cuda_major == "11" %} - cudatoolkit - - cuda-python >=11.7.1,<12.0a0 + - cuda-python >=11.8.5,<12.0a0 {% else %} - cuda-cudart-dev - - cuda-python >=12.0,<13.0a0 + - cuda-python >=12.6.2,<13.0a0 {% endif %} - cython >=3.0.0 - rapids-build-backend >=0.3.0,<0.4.0.dev0 @@ -70,10 +70,10 @@ requirements: run: {% if cuda_major == "11" %} - cudatoolkit - - cuda-python >=11.7.1,<12.0a0 + - cuda-python >=11.8.5,<12.0a0 {% else %} - cuda-cudart - - cuda-python >=12.0,<13.0a0 + - cuda-python >=12.6.2,<13.0a0 {% endif %} - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - numba >=0.57 diff --git a/dependencies.yaml b/dependencies.yaml index ab248e02f..671809a66 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -152,10 +152,10 @@ dependencies: - matrix: cuda: "12.*" packages: - - &cuda_python12 cuda-python>=12.0,<13.0a0 + - &cuda_python12 cuda-python>=12.6.2,<13.0a0 - matrix: # All CUDA 11 versions packages: - - &cuda_python11 cuda-python>=11.7.1,<12.0a0 + - &cuda_python11 cuda-python>=11.8.5,<12.0a0 - output_types: [requirements, pyproject] matrices: - matrix: diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index fb479bc17..a235130e1 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -30,7 +30,7 @@ authors = [ license = { text = "Apache 2.0" } requires-python = ">=3.10" dependencies = [ - "cuda-python>=11.7.1,<12.0a0", + "cuda-python>=11.8.5,<12.0a0", "numba>=0.57", "numpy>=1.23,<3.0a0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. @@ -128,7 +128,7 @@ dependencies-file = "../../dependencies.yaml" matrix-entry = "cuda_suffixed=true" requires = [ "cmake>=3.26.4,!=3.30.0", - "cuda-python>=11.7.1,<12.0a0", + "cuda-python>=11.8.5,<12.0a0", "cython>=3.0.0", "librmm==25.2.*,>=0.0.0a0", "ninja", From 83a897155e40ab52c4876bfcf9425105be748688 Mon Sep 17 00:00:00 2001 From: Alessandro Bellina Date: Sat, 7 Dec 2024 12:09:43 -0600 Subject: [PATCH 511/675] Adds fabric handle and memory protection flags to cuda_async_memory_resource (#1743) This PR adds a new `fabric` handle type in `allocation_handle_type`. It also adds an optional `access_flags` to set the memory access desired when exporting (`prot_none`, or `prot_read_write`). Pools that are not meant to be shareable should omit these flags. Please note that I can't add a unit test that exports or imports these fabric handles, because it would require system setup that doesn't look to be portable. Authors: - Alessandro Bellina (https://github.com/abellina) Approvers: - Rong Ou (https://github.com/rongou) - Lawrence Mitchell (https://github.com/wence-) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1743 --- .../mr/device/cuda_async_memory_resource.hpp | 36 +++++++++++++++--- tests/mr/device/cuda_async_mr_tests.cpp | 38 +++++++++++++++++++ 2 files changed, 69 insertions(+), 5 deletions(-) diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index b1fc0b112..dbb324a1b 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -53,14 +53,31 @@ class cuda_async_memory_resource final : public device_memory_resource { * memory pools (CUDA 11.2) did not support these flags, so we need a placeholder that can be * used consistently in the constructor of `cuda_async_memory_resource` with all versions of * CUDA >= 11.2. See the `cudaMemAllocationHandleType` docs at - * https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html + * https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html and ensure the enum + * values are kept in sync with the CUDA documentation. */ enum class allocation_handle_type { none = 0x0, ///< Does not allow any export mechanism. posix_file_descriptor = 0x1, ///< Allows a file descriptor to be used for exporting. Permitted ///< only on POSIX systems. win32 = 0x2, ///< Allows a Win32 NT handle to be used for exporting. (HANDLE) - win32_kmt = 0x4 ///< Allows a Win32 KMT handle to be used for exporting. (D3DKMT_HANDLE) + win32_kmt = 0x4, ///< Allows a Win32 KMT handle to be used for exporting. (D3DKMT_HANDLE) + fabric = 0x8 ///< Allows a fabric handle to be used for exporting. (cudaMemFabricHandle_t) + }; + + /** + * @brief Flags for specifying the memory pool accessibility from other devices. + * + * @note These values are exact copies from `cudaMemAccessFlags`. See the `cudaMemAccessFlags` + * docs at https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html and ensure the + * enum values are kept in sync with the CUDA documentation. The default, `none`, marks the pool's + * memory as private to the device in which it was created. `read_write` should only be used if + * memory sharing among devices is required. Note that there is a `cudaMemAccessFlagsProtRead` + * documented, but memory pools don't support read-only access, so it has been omitted. + */ + enum class access_flags { + none = 0, ///< Default, make pool not accessible. + read_write = 3 ///< Make pool read-write accessible. }; /** @@ -77,13 +94,16 @@ class cuda_async_memory_resource final : public device_memory_resource { * @param release_threshold Optional release threshold size in bytes of the pool. If no value is * provided, the release threshold is set to the total amount of memory on the current device. * @param export_handle_type Optional `cudaMemAllocationHandleType` that allocations from this - * resource should support interprocess communication (IPC). Default is - * `cudaMemHandleTypeNone` for no IPC support. + * resource should support interprocess communication (IPC). Default is `cudaMemHandleTypeNone` + * for no IPC support. + * @param access_flag Optional `cudaMemAccessFlags` that controls pool memory accessibility + * from other devices. Default is `cudaMemAccessFlagsProtNone` for no accessibility. */ // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) cuda_async_memory_resource(std::optional initial_pool_size = {}, std::optional release_threshold = {}, - std::optional export_handle_type = {}) + std::optional export_handle_type = {}, + std::optional access_flag = {}) { // Check if cudaMallocAsync Memory pool supported RMM_EXPECTS(rmm::detail::runtime_async_alloc::is_supported(), @@ -115,6 +135,12 @@ class cuda_async_memory_resource final : public device_memory_resource { cudaMemPoolSetAttribute(pool_handle(), cudaMemPoolReuseAllowOpportunistic, &disabled)); } + if (access_flag) { + cudaMemAccessDesc desc = {.location = pool_props.location, + .flags = static_cast(*access_flag)}; + RMM_CUDA_TRY(cudaMemPoolSetAccess(pool_handle(), &desc, 1)); + } + auto const [free, total] = rmm::available_device_memory(); // Need an l-value to take address to pass to cudaMemPoolSetAttribute diff --git a/tests/mr/device/cuda_async_mr_tests.cpp b/tests/mr/device/cuda_async_mr_tests.cpp index a39188548..167adf1e1 100644 --- a/tests/mr/device/cuda_async_mr_tests.cpp +++ b/tests/mr/device/cuda_async_mr_tests.cpp @@ -66,5 +66,43 @@ TEST_F(AsyncMRTest, DifferentPoolsUnequal) EXPECT_FALSE(mr1.is_equal(mr2)); } +class AsyncMRFabricTest : public AsyncMRTest { + void SetUp() override + { + AsyncMRTest::SetUp(); + + auto handle_type = static_cast( + rmm::mr::cuda_async_memory_resource::allocation_handle_type::fabric); + if (!rmm::detail::runtime_async_alloc::is_export_handle_type_supported(handle_type)) { + GTEST_SKIP() << "Fabric handles are not supported in this environment. Skipping test."; + } + } +}; + +TEST_F(AsyncMRFabricTest, FabricHandlesSupport) +{ + const auto pool_init_size{100}; + const auto pool_release_threshold{1000}; + cuda_async_mr mr{pool_init_size, + pool_release_threshold, + rmm::mr::cuda_async_memory_resource::allocation_handle_type::fabric}; + void* ptr = mr.allocate(pool_init_size); + mr.deallocate(ptr, pool_init_size); + RMM_CUDA_TRY(cudaDeviceSynchronize()); +} + +TEST_F(AsyncMRFabricTest, FabricHandlesSupportReadWriteShareable) +{ + const auto pool_init_size{100}; + const auto pool_release_threshold{1000}; + cuda_async_mr mr{pool_init_size, + pool_release_threshold, + rmm::mr::cuda_async_memory_resource::allocation_handle_type::fabric, + rmm::mr::cuda_async_memory_resource::access_flags::read_write}; + void* ptr = mr.allocate(pool_init_size); + mr.deallocate(ptr, pool_init_size); + RMM_CUDA_TRY(cudaDeviceSynchronize()); +} + } // namespace } // namespace rmm::test From 09f7f627b34721578ced7a0324654867af20b9a0 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 9 Dec 2024 09:43:27 -0600 Subject: [PATCH 512/675] Add configuration for pre-commit.ci, update pre-commit hooks (#1746) This PR adds configuration for pre-commit.ci, reformats the pre-commit config file, and updates pre-commit hooks. See https://github.com/rapidsai/build-planning/issues/124 for the motivation. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Ray Douglass (https://github.com/raydouglass) - Matthew Murray (https://github.com/Matt711) - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1746 --- .pre-commit-config.yaml | 185 +++++++++++++++++++++------------------- pyproject.toml | 4 +- python/rmm/docs/conf.py | 2 +- 3 files changed, 101 insertions(+), 90 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 56c972b4e..2f8385092 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,91 +1,100 @@ -# Copyright (c) 2022-2023, NVIDIA CORPORATION. +# Copyright (c) 2022-2024, NVIDIA CORPORATION. +ci: + autofix_commit_msg: "[pre-commit.ci] auto code formatting" + autofix_prs: false + autoupdate_branch: "" + autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate" + autoupdate_schedule: quarterly + skip: ["verify-alpha-spec"] + submodules: false + repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - args: ["--settings-path=python/rmm/pyproject.toml"] - files: python/.* - types_or: [python, cython, pyi] - - repo: https://github.com/ambv/black - rev: 22.3.0 - hooks: - - id: black - args: ["--config=python/rmm/pyproject.toml"] - - repo: https://github.com/MarcoGorelli/cython-lint - rev: v0.15.0 - hooks: - - id: cython-lint - - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v16.0.6 - hooks: - - id: clang-format - types_or: [c, c++, cuda] - args: ["-fallback-style=none", "-style=file", "-i"] - - repo: https://github.com/sirosen/texthooks - rev: 0.4.0 - hooks: - - id: fix-smartquotes - exclude: | - (?x)^( - ^benchmarks/utilities/cxxopts.hpp - ) - - repo: https://github.com/codespell-project/codespell - rev: v2.2.4 - hooks: - - id: codespell - exclude: | - (?x)^( - pyproject.toml| - benchmarks/utilities/cxxopts.hpp - ) - - repo: local - hooks: - - id: cmake-format - name: cmake-format - entry: ./scripts/run-cmake-format.sh cmake-format - language: python - types: [cmake] - # Note that pre-commit autoupdate does not update the versions - # of dependencies, so we'll have to update this manually. - additional_dependencies: - - cmakelang==0.6.13 - - id: cmake-lint - name: cmake-lint - entry: ./scripts/run-cmake-format.sh cmake-lint - language: python - types: [cmake] - # Note that pre-commit autoupdate does not update the versions - # of dependencies, so we'll have to update this manually. - additional_dependencies: - - cmakelang==0.6.13 - - id: doxygen-check - name: doxygen-check - entry: ./scripts/doxygen.sh - types_or: [file] - language: system - pass_filenames: false - verbose: true - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.278 - hooks: - - id: ruff - files: python/.*$ - - repo: https://github.com/rapidsai/pre-commit-hooks - rev: v0.4.0 - hooks: - - id: verify-copyright - - id: verify-alpha-spec - - repo: https://github.com/rapidsai/dependency-file-generator - rev: v1.16.0 - hooks: - - id: rapids-dependency-file-generator - args: ["--clean"] + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - repo: https://github.com/PyCQA/isort + rev: 5.13.2 + hooks: + - id: isort + args: ["--settings-path=python/rmm/pyproject.toml"] + files: python/.* + types_or: [python, cython, pyi] + - repo: https://github.com/ambv/black + rev: 24.10.0 + hooks: + - id: black + args: ["--config=python/rmm/pyproject.toml"] + - repo: https://github.com/MarcoGorelli/cython-lint + rev: v0.16.6 + hooks: + - id: cython-lint + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v16.0.6 + hooks: + - id: clang-format + types_or: [c, c++, cuda] + args: ["-fallback-style=none", "-style=file", "-i"] + - repo: https://github.com/sirosen/texthooks + rev: 0.6.8 + hooks: + - id: fix-smartquotes + exclude: | + (?x)^( + ^benchmarks/utilities/cxxopts.hpp + ) + - repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + exclude: | + (?x)^( + pyproject.toml| + benchmarks/utilities/cxxopts.hpp + ) + - repo: local + hooks: + - id: cmake-format + name: cmake-format + entry: ./scripts/run-cmake-format.sh cmake-format + language: python + types: [cmake] + # Note that pre-commit autoupdate does not update the versions + # of dependencies, so we'll have to update this manually. + additional_dependencies: + - cmakelang==0.6.13 + - id: cmake-lint + name: cmake-lint + entry: ./scripts/run-cmake-format.sh cmake-lint + language: python + types: [cmake] + # Note that pre-commit autoupdate does not update the versions + # of dependencies, so we'll have to update this manually. + additional_dependencies: + - cmakelang==0.6.13 + - id: doxygen-check + name: doxygen-check + entry: ./scripts/doxygen.sh + types_or: [file] + language: system + pass_filenames: false + verbose: true + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.8.2 + hooks: + - id: ruff + files: python/.*$ + - repo: https://github.com/rapidsai/pre-commit-hooks + rev: v0.4.0 + hooks: + - id: verify-copyright + - id: verify-alpha-spec + - repo: https://github.com/rapidsai/dependency-file-generator + rev: v1.16.0 + hooks: + - id: rapids-dependency-file-generator + args: ["--clean"] default_language_version: - python: python3 + python: python3 diff --git a/pyproject.toml b/pyproject.toml index 285098f99..929d5e563 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,12 @@ +# Copyright (c) 2024, NVIDIA CORPORATION. + [tool.codespell] # note: pre-commit passes explicit lists of files here, which this skip file list doesn't override - # this is only to allow you to run codespell interactively skip = "./pyproject.toml,./.git,./.github,./cpp/build,.*egg-info.*,./.mypy_cache,./benchmarks/utilities/cxxopts.hpp" # ignore short words, and typename parameters like OffsetT ignore-regex = "\\b(.{1,4}|[A-Z]\\w*T)\\b" -ignore-words-list = "inout" +ignore-words-list = "inout,thirdparty" builtin = "clear" quiet-level = 3 diff --git a/python/rmm/docs/conf.py b/python/rmm/docs/conf.py index 99242daa5..a21698ded 100644 --- a/python/rmm/docs/conf.py +++ b/python/rmm/docs/conf.py @@ -278,7 +278,7 @@ def on_missing_reference(app, env, node, contnode): # all that's missing. Include the empty prefix in case we're searching # for a stripped template. extra_prefixes = ["rmm::", "rmm::mr::", "mr::", ""] - for (name, dispname, typ, docname, anchor, priority) in env.domains[ + for name, dispname, typ, docname, anchor, priority in env.domains[ "cpp" ].get_objects(): for prefix in extra_prefixes: From ff59ea43b0af9b534005687b85af9ab7fa5fd510 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 9 Dec 2024 09:57:26 -0600 Subject: [PATCH 513/675] stop installing 'wheel' in wheel-building script (#1748) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We're now pre-installing `wheel` in the CI images: https://github.com/rapidsai/ci-imgs/pull/215 This proposes removing a `pip install wheel` in CI here... fewer network requests = fewer random CI failures 😁 Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1748 --- ci/build_wheel_cpp.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/build_wheel_cpp.sh b/ci/build_wheel_cpp.sh index 1ec979372..e21792910 100755 --- a/ci/build_wheel_cpp.sh +++ b/ci/build_wheel_cpp.sh @@ -20,7 +20,6 @@ python -m pip wheel . -w dist -v --no-deps --disable-pip-version-check sccache --show-adv-stats -python -m pip install wheel python -m wheel tags --platform any dist/* --remove ../../ci/validate_wheel.sh dist From 8d41610688da7ef8f2ced0a52798b7ba979c6c83 Mon Sep 17 00:00:00 2001 From: Alessandro Bellina Date: Mon, 9 Dec 2024 17:04:19 -0600 Subject: [PATCH 514/675] Remove memory access flags from cuda_async_memory_resource (#1754) Closes https://github.com/rapidsai/rmm/issues/1753 It is a follow up from https://github.com/rapidsai/rmm/pull/1743 I would like for https://github.com/rapidsai/cudf/pull/17553 to merge first, that way I don't break the build. I've learned that I was using `cudaMemPoolSetAccess` incorrectly. This API should only be used from a `peer` device, not from the device that created the pool. This is the reason why calling `cudaMemPoolSetAccess` with none throws an error as documented here https://github.com/rapidsai/rmm/issues/1753. I have tested that I can still export the fabric handles and import them using UCX in a peer device with the default access that pool owner device gets (read+write is the default). Note that this read+write default access cannot be revoked from the owner, as it wouldn't make sense to have memory that nobody has access to, but peers can call `cudaMemPoolSetAccess` to gain read+write access or to stop accessing (none) a peer's pool memory. Authors: - Alessandro Bellina (https://github.com/abellina) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1754 --- .../mr/device/cuda_async_memory_resource.hpp | 26 +------------------ tests/mr/device/cuda_async_mr_tests.cpp | 13 ---------- 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index dbb324a1b..12b835982 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -65,21 +65,6 @@ class cuda_async_memory_resource final : public device_memory_resource { fabric = 0x8 ///< Allows a fabric handle to be used for exporting. (cudaMemFabricHandle_t) }; - /** - * @brief Flags for specifying the memory pool accessibility from other devices. - * - * @note These values are exact copies from `cudaMemAccessFlags`. See the `cudaMemAccessFlags` - * docs at https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html and ensure the - * enum values are kept in sync with the CUDA documentation. The default, `none`, marks the pool's - * memory as private to the device in which it was created. `read_write` should only be used if - * memory sharing among devices is required. Note that there is a `cudaMemAccessFlagsProtRead` - * documented, but memory pools don't support read-only access, so it has been omitted. - */ - enum class access_flags { - none = 0, ///< Default, make pool not accessible. - read_write = 3 ///< Make pool read-write accessible. - }; - /** * @brief Constructs a cuda_async_memory_resource with the optionally specified initial pool size * and release threshold. @@ -96,14 +81,11 @@ class cuda_async_memory_resource final : public device_memory_resource { * @param export_handle_type Optional `cudaMemAllocationHandleType` that allocations from this * resource should support interprocess communication (IPC). Default is `cudaMemHandleTypeNone` * for no IPC support. - * @param access_flag Optional `cudaMemAccessFlags` that controls pool memory accessibility - * from other devices. Default is `cudaMemAccessFlagsProtNone` for no accessibility. */ // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) cuda_async_memory_resource(std::optional initial_pool_size = {}, std::optional release_threshold = {}, - std::optional export_handle_type = {}, - std::optional access_flag = {}) + std::optional export_handle_type = {}) { // Check if cudaMallocAsync Memory pool supported RMM_EXPECTS(rmm::detail::runtime_async_alloc::is_supported(), @@ -135,12 +117,6 @@ class cuda_async_memory_resource final : public device_memory_resource { cudaMemPoolSetAttribute(pool_handle(), cudaMemPoolReuseAllowOpportunistic, &disabled)); } - if (access_flag) { - cudaMemAccessDesc desc = {.location = pool_props.location, - .flags = static_cast(*access_flag)}; - RMM_CUDA_TRY(cudaMemPoolSetAccess(pool_handle(), &desc, 1)); - } - auto const [free, total] = rmm::available_device_memory(); // Need an l-value to take address to pass to cudaMemPoolSetAttribute diff --git a/tests/mr/device/cuda_async_mr_tests.cpp b/tests/mr/device/cuda_async_mr_tests.cpp index 167adf1e1..e56d224ed 100644 --- a/tests/mr/device/cuda_async_mr_tests.cpp +++ b/tests/mr/device/cuda_async_mr_tests.cpp @@ -91,18 +91,5 @@ TEST_F(AsyncMRFabricTest, FabricHandlesSupport) RMM_CUDA_TRY(cudaDeviceSynchronize()); } -TEST_F(AsyncMRFabricTest, FabricHandlesSupportReadWriteShareable) -{ - const auto pool_init_size{100}; - const auto pool_release_threshold{1000}; - cuda_async_mr mr{pool_init_size, - pool_release_threshold, - rmm::mr::cuda_async_memory_resource::allocation_handle_type::fabric, - rmm::mr::cuda_async_memory_resource::access_flags::read_write}; - void* ptr = mr.allocate(pool_init_size); - mr.deallocate(ptr, pool_init_size); - RMM_CUDA_TRY(cudaDeviceSynchronize()); -} - } // namespace } // namespace rmm::test From 46b232e1b0ba9386079bb0e0dbabe9cf8e7afec6 Mon Sep 17 00:00:00 2001 From: Mike Sarahan Date: Mon, 9 Dec 2024 17:58:56 -0600 Subject: [PATCH 515/675] gate telemetry dispatch calls on TELEMETRY_ENABLED env var (#1752) Because of the switch away from certificates/mTLS, we are having to rework a few things. In the meantime, telemetry jobs are failing. This PR adds a switch to turn all of the telemetry stuff off - to skip it instead. It is meant to be controlled by an org-wide environment variable, which can be applied to individual repos by ops. At the time of submitting this PR, the environment variable is 'false' and no telemetry is being reported. Authors: - Mike Sarahan (https://github.com/msarahan) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1752 --- .github/workflows/pr.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index d0287319f..3ecd52c7e 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -36,6 +36,7 @@ jobs: OTEL_SERVICE_NAME: "pr-rmm" steps: - name: Telemetry setup + if: ${{ vars.TELEMETRY_ENABLED == 'true' }} uses: rapidsai/shared-actions/telemetry-dispatch-stash-base-env-vars@main changed-files: needs: @@ -142,7 +143,7 @@ jobs: telemetry-summarize: runs-on: ubuntu-latest needs: pr-builder - if: always() + if: ${{ vars.TELEMETRY_ENABLED == 'true' && !cancelled() }} continue-on-error: true steps: - name: Load stashed telemetry env vars From c3841ddfd312f65db69c1e28aa2d6c11a034f80c Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 9 Dec 2024 23:21:45 -0600 Subject: [PATCH 516/675] Use bindings layout for all cuda-python imports. (#1756) Closes #1755. Replaces #1675. Authors: - Bradley Dice (https://github.com/bdice) - Matthew Murray (https://github.com/Matt711) Approvers: - Matthew Murray (https://github.com/Matt711) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1756 --- python/rmm/rmm/_cuda/gpu.py | 67 ++++++++++----------- python/rmm/rmm/_cuda/stream.pxd | 2 +- python/rmm/rmm/_cuda/stream.pyx | 2 +- python/rmm/rmm/allocators/numba.py | 2 +- python/rmm/rmm/librmm/cuda_stream.pxd | 2 +- python/rmm/rmm/librmm/cuda_stream_view.pxd | 4 +- python/rmm/rmm/pylibrmm/cuda_stream.pxd | 2 +- python/rmm/rmm/pylibrmm/cuda_stream.pyx | 2 +- python/rmm/rmm/pylibrmm/device_buffer.pyx | 5 +- python/rmm/rmm/pylibrmm/memory_resource.pyx | 2 +- 10 files changed, 44 insertions(+), 46 deletions(-) diff --git a/python/rmm/rmm/_cuda/gpu.py b/python/rmm/rmm/_cuda/gpu.py index 2a23b41e6..8ed7abc93 100644 --- a/python/rmm/rmm/_cuda/gpu.py +++ b/python/rmm/rmm/_cuda/gpu.py @@ -1,14 +1,14 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. -from cuda import cuda, cudart +from cuda.bindings import driver, runtime class CUDARuntimeError(RuntimeError): - def __init__(self, status: cudart.cudaError_t): + def __init__(self, status: runtime.cudaError_t): self.status = status - _, name = cudart.cudaGetErrorName(status) - _, msg = cudart.cudaGetErrorString(status) + _, name = runtime.cudaGetErrorName(status) + _, msg = runtime.cudaGetErrorString(status) super(CUDARuntimeError, self).__init__( f"{name.decode()}: {msg.decode()}" @@ -19,11 +19,11 @@ def __reduce__(self): class CUDADriverError(RuntimeError): - def __init__(self, status: cuda.CUresult): + def __init__(self, status: driver.CUresult): self.status = status - _, name = cuda.cuGetErrorName(status) - _, msg = cuda.cuGetErrorString(status) + _, name = driver.cuGetErrorName(status) + _, msg = driver.cuGetErrorString(status) super(CUDADriverError, self).__init__( f"{name.decode()}: {msg.decode()}" @@ -43,8 +43,8 @@ def driverGetVersion(): This function automatically raises CUDARuntimeError with error message and status code. """ - status, version = cudart.cudaDriverGetVersion() - if status != cudart.cudaError_t.cudaSuccess: + status, version = runtime.cudaDriverGetVersion() + if status != runtime.cudaError_t.cudaSuccess: raise CUDARuntimeError(status) return version @@ -53,8 +53,8 @@ def getDevice(): """ Get the current CUDA device """ - status, device = cudart.cudaGetDevice() - if status != cudart.cudaError_t.cudaSuccess: + status, device = runtime.cudaGetDevice() + if status != runtime.cudaError_t.cudaSuccess: raise CUDARuntimeError(status) return device @@ -67,26 +67,25 @@ def setDevice(device: int): device : int The ID of the device to set as current """ - (status,) = cudart.cudaSetDevice(device) - if status != cudart.cudaError_t.cudaSuccess: + (status,) = runtime.cudaSetDevice(device) + if status != runtime.cudaError_t.cudaSuccess: raise CUDARuntimeError(status) def runtimeGetVersion(): """ - Returns the version number of the current CUDA Runtime instance. - The version is returned as (1000 major + 10 minor). For example, - CUDA 9.2 would be represented by 9020. + Returns the version number of the local CUDA runtime. - This calls numba.cuda.runtime.get_version() rather than cuda-python due to - current limitations in cuda-python. - """ - # TODO: Replace this with `cuda.cudart.cudaRuntimeGetVersion()` when the - # limitation is fixed. - import numba.cuda + The version is returned as ``(1000 * major + 10 * minor)``. For example, + CUDA 12.5 would be represented by 12050. - major, minor = numba.cuda.runtime.get_version() - return major * 1000 + minor * 10 + This function automatically raises CUDARuntimeError with error message + and status code. + """ + status, version = runtime.getLocalRuntimeVersion() + if status != runtime.cudaError_t.cudaSuccess: + raise CUDARuntimeError(status) + return version def getDeviceCount(): @@ -97,13 +96,13 @@ def getDeviceCount(): This function automatically raises CUDARuntimeError with error message and status code. """ - status, count = cudart.cudaGetDeviceCount() - if status != cudart.cudaError_t.cudaSuccess: + status, count = runtime.cudaGetDeviceCount() + if status != runtime.cudaError_t.cudaSuccess: raise CUDARuntimeError(status) return count -def getDeviceAttribute(attr: cudart.cudaDeviceAttr, device: int): +def getDeviceAttribute(attr: runtime.cudaDeviceAttr, device: int): """ Returns information about the device. @@ -117,8 +116,8 @@ def getDeviceAttribute(attr: cudart.cudaDeviceAttr, device: int): This function automatically raises CUDARuntimeError with error message and status code. """ - status, value = cudart.cudaDeviceGetAttribute(attr, device) - if status != cudart.cudaError_t.cudaSuccess: + status, value = runtime.cudaDeviceGetAttribute(attr, device) + if status != runtime.cudaError_t.cudaSuccess: raise CUDARuntimeError(status) return value @@ -135,8 +134,8 @@ def getDeviceProperties(device: int): This function automatically raises CUDARuntimeError with error message and status code. """ - status, prop = cudart.cudaGetDeviceProperties(device) - if status != cudart.cudaError_t.cudaSuccess: + status, prop = runtime.cudaGetDeviceProperties(device) + if status != runtime.cudaError_t.cudaSuccess: raise CUDARuntimeError(status) return prop @@ -154,7 +153,7 @@ def deviceGetName(device: int): and status code. """ - status, device_name = cuda.cuDeviceGetName(256, cuda.CUdevice(device)) - if status != cuda.CUresult.CUDA_SUCCESS: + status, device_name = driver.cuDeviceGetName(256, driver.CUdevice(device)) + if status != driver.CUresult.CUDA_SUCCESS: raise CUDADriverError(status) return device_name.decode() diff --git a/python/rmm/rmm/_cuda/stream.pxd b/python/rmm/rmm/_cuda/stream.pxd index e91e2ce58..219b75864 100644 --- a/python/rmm/rmm/_cuda/stream.pxd +++ b/python/rmm/rmm/_cuda/stream.pxd @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cuda.ccudart cimport cudaStream_t +from cuda.bindings.cyruntime cimport cudaStream_t from libc.stdint cimport uintptr_t from libcpp cimport bool diff --git a/python/rmm/rmm/_cuda/stream.pyx b/python/rmm/rmm/_cuda/stream.pyx index 37dcbd610..951f3f40c 100644 --- a/python/rmm/rmm/_cuda/stream.pyx +++ b/python/rmm/rmm/_cuda/stream.pyx @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cuda.ccudart cimport cudaStream_t +from cuda.bindings.cyruntime cimport cudaStream_t from libc.stdint cimport uintptr_t from libcpp cimport bool diff --git a/python/rmm/rmm/allocators/numba.py b/python/rmm/rmm/allocators/numba.py index fd9bacb5a..f02fff240 100644 --- a/python/rmm/rmm/allocators/numba.py +++ b/python/rmm/rmm/allocators/numba.py @@ -15,7 +15,7 @@ import ctypes import inspect -from cuda.cuda import CUdeviceptr, cuIpcGetMemHandle +from cuda.bindings.driver import CUdeviceptr, cuIpcGetMemHandle from numba import config, cuda from numba.cuda import HostOnlyCUDAMemoryManager, IpcHandle, MemoryPointer diff --git a/python/rmm/rmm/librmm/cuda_stream.pxd b/python/rmm/rmm/librmm/cuda_stream.pxd index 3f2ac3361..5fb6a065a 100644 --- a/python/rmm/rmm/librmm/cuda_stream.pxd +++ b/python/rmm/rmm/librmm/cuda_stream.pxd @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cuda.ccudart cimport cudaStream_t +from cuda.bindings.cyruntime cimport cudaStream_t from libcpp cimport bool from rmm.librmm.cuda_stream_view cimport cuda_stream_view diff --git a/python/rmm/rmm/librmm/cuda_stream_view.pxd b/python/rmm/rmm/librmm/cuda_stream_view.pxd index bf0d33c24..4343638d1 100644 --- a/python/rmm/rmm/librmm/cuda_stream_view.pxd +++ b/python/rmm/rmm/librmm/cuda_stream_view.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-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. @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cuda.ccudart cimport cudaStream_t +from cuda.bindings.cyruntime cimport cudaStream_t from libcpp cimport bool diff --git a/python/rmm/rmm/pylibrmm/cuda_stream.pxd b/python/rmm/rmm/pylibrmm/cuda_stream.pxd index dd38387c2..2cd319a55 100644 --- a/python/rmm/rmm/pylibrmm/cuda_stream.pxd +++ b/python/rmm/rmm/pylibrmm/cuda_stream.pxd @@ -13,7 +13,7 @@ # limitations under the License. cimport cython -from cuda.ccudart cimport cudaStream_t +from cuda.bindings.cyruntime cimport cudaStream_t from libcpp cimport bool from libcpp.memory cimport unique_ptr diff --git a/python/rmm/rmm/pylibrmm/cuda_stream.pyx b/python/rmm/rmm/pylibrmm/cuda_stream.pyx index d6aa4edc7..beb89996c 100644 --- a/python/rmm/rmm/pylibrmm/cuda_stream.pyx +++ b/python/rmm/rmm/pylibrmm/cuda_stream.pyx @@ -13,7 +13,7 @@ # limitations under the License. cimport cython -from cuda.ccudart cimport cudaStream_t +from cuda.bindings.cyruntime cimport cudaStream_t from libcpp cimport bool from rmm.librmm.cuda_stream cimport cuda_stream diff --git a/python/rmm/rmm/pylibrmm/device_buffer.pyx b/python/rmm/rmm/pylibrmm/device_buffer.pyx index c2e95e845..9343d77c1 100644 --- a/python/rmm/rmm/pylibrmm/device_buffer.pyx +++ b/python/rmm/rmm/pylibrmm/device_buffer.pyx @@ -23,8 +23,7 @@ from rmm._cuda.stream cimport Stream from rmm._cuda.stream import DEFAULT_STREAM -cimport cuda.ccudart as ccudart -from cuda.ccudart cimport ( +from cuda.bindings.cyruntime cimport ( cudaError, cudaError_t, cudaMemcpyAsync, @@ -421,7 +420,7 @@ cpdef DeviceBuffer to_device(const unsigned char[::1] b, cdef void _copy_async(const void* src, void* dst, size_t count, - ccudart.cudaMemcpyKind kind, + cudaMemcpyKind kind, cuda_stream_view stream) except * nogil: """ Asynchronously copy data between host and/or device pointers. diff --git a/python/rmm/rmm/pylibrmm/memory_resource.pyx b/python/rmm/rmm/pylibrmm/memory_resource.pyx index b41890fca..ca9ee01ac 100644 --- a/python/rmm/rmm/pylibrmm/memory_resource.pyx +++ b/python/rmm/rmm/pylibrmm/memory_resource.pyx @@ -28,7 +28,7 @@ from libcpp.memory cimport make_unique, unique_ptr from libcpp.optional cimport optional from libcpp.pair cimport pair -from cuda.cudart import cudaError_t +from cuda.bindings.runtime import cudaError_t from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice From 73a66c990265dc05f6d588dcbe6d5c5b250de975 Mon Sep 17 00:00:00 2001 From: Jake Awe <50372925+AyodeAwe@users.noreply.github.com> Date: Tue, 10 Dec 2024 13:21:34 -0600 Subject: [PATCH 517/675] fix version references (skip ci) (#1757) --- .github/workflows/trigger-breaking-change-alert.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger-breaking-change-alert.yaml b/.github/workflows/trigger-breaking-change-alert.yaml index 3b972f31c..01dd2436b 100644 --- a/.github/workflows/trigger-breaking-change-alert.yaml +++ b/.github/workflows/trigger-breaking-change-alert.yaml @@ -12,7 +12,7 @@ jobs: trigger-notifier: if: contains(github.event.pull_request.labels.*.name, 'breaking') secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@branch-24.12 + uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@branch-25.02 with: sender_login: ${{ github.event.sender.login }} sender_avatar: ${{ github.event.sender.avatar_url }} From b391ce867a62bbfc3283779d70231be5b00e2e84 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Wed, 11 Dec 2024 13:12:21 -0500 Subject: [PATCH 518/675] Update Changelog [skip ci] --- CHANGELOG.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1268762b2..817a0c8c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,48 @@ +# rmm 24.12.00 (11 Dec 2024) + +## 🚨 Breaking Changes + +- Deprecate support for directly accessing logger ([#1690](https://github.com/rapidsai/rmm/pull/1690)) [@vyasr](https://github.com/vyasr) + +## 🐛 Bug Fixes + +- Query total memory in failure_callback_resource_adaptor tests ([#1734](https://github.com/rapidsai/rmm/pull/1734)) [@harrism](https://github.com/harrism) +- Treat deprecation warnings as errors and fix deprecation warnings in replay benchmark ([#1728](https://github.com/rapidsai/rmm/pull/1728)) [@harrism](https://github.com/harrism) +- Disallow cuda-python 12.6.1 and 11.8.4 ([#1720](https://github.com/rapidsai/rmm/pull/1720)) [@bdice](https://github.com/bdice) +- Fix typos in .gitignore ([#1697](https://github.com/rapidsai/rmm/pull/1697)) [@charlesbluca](https://github.com/charlesbluca) +- Fix `rmm ._lib` imports ([#1693](https://github.com/rapidsai/rmm/pull/1693)) [@Matt711](https://github.com/Matt711) + +## 📖 Documentation + +- Fix docs warning ([#1706](https://github.com/rapidsai/rmm/pull/1706)) [@bdice](https://github.com/bdice) +- Update cross-link to cuda-python object ([#1699](https://github.com/rapidsai/rmm/pull/1699)) [@wence-](https://github.com/wence-) + +## 🚀 New Features + +- Correct rmm tests for validity of device pointers ([#1714](https://github.com/rapidsai/rmm/pull/1714)) [@robertmaynard](https://github.com/robertmaynard) +- Update rmm tests to use rapids_cmake_support_conda_env ([#1707](https://github.com/rapidsai/rmm/pull/1707)) [@robertmaynard](https://github.com/robertmaynard) +- adding telemetry ([#1692](https://github.com/rapidsai/rmm/pull/1692)) [@msarahan](https://github.com/msarahan) +- Make `cudaMallocAsync` logic non-optional as we require CUDA 11.2+ ([#1667](https://github.com/rapidsai/rmm/pull/1667)) [@robertmaynard](https://github.com/robertmaynard) + +## 🛠️ Improvements + +- enforce wheel size limits, README formatting in CI ([#1726](https://github.com/rapidsai/rmm/pull/1726)) [@jameslamb](https://github.com/jameslamb) +- Remove all explicit usage of fmtlib ([#1724](https://github.com/rapidsai/rmm/pull/1724)) [@harrism](https://github.com/harrism) +- WIP: put a ceiling on cuda-python ([#1723](https://github.com/rapidsai/rmm/pull/1723)) [@jameslamb](https://github.com/jameslamb) +- use rapids-generate-pip-constraints to pin to oldest dependencies in CI ([#1716](https://github.com/rapidsai/rmm/pull/1716)) [@jameslamb](https://github.com/jameslamb) +- Deprecate `rmm._lib` ([#1713](https://github.com/rapidsai/rmm/pull/1713)) [@Matt711](https://github.com/Matt711) +- print sccache stats in builds ([#1712](https://github.com/rapidsai/rmm/pull/1712)) [@jameslamb](https://github.com/jameslamb) +- [fea] Expose the arena mr to the Python interface. ([#1711](https://github.com/rapidsai/rmm/pull/1711)) [@trivialfis](https://github.com/trivialfis) +- devcontainer: replace `VAULT_HOST` with `AWS_ROLE_ARN` ([#1708](https://github.com/rapidsai/rmm/pull/1708)) [@jjacobelli](https://github.com/jjacobelli) +- make conda installs in CI stricter (part 2) ([#1703](https://github.com/rapidsai/rmm/pull/1703)) [@jameslamb](https://github.com/jameslamb) +- Add BUILD_SHARED_LIBS option defaulting to ON ([#1702](https://github.com/rapidsai/rmm/pull/1702)) [@wence-](https://github.com/wence-) +- make conda installs in CI stricter ([#1696](https://github.com/rapidsai/rmm/pull/1696)) [@jameslamb](https://github.com/jameslamb) +- Prune workflows based on changed files ([#1695](https://github.com/rapidsai/rmm/pull/1695)) [@KyleFromNVIDIA](https://github.com/KyleFromNVIDIA) +- Deprecate support for directly accessing logger ([#1690](https://github.com/rapidsai/rmm/pull/1690)) [@vyasr](https://github.com/vyasr) +- Use `rmm::percent_of_free_device_memory` in arena test ([#1689](https://github.com/rapidsai/rmm/pull/1689)) [@wence-](https://github.com/wence-) +- exclude 'gcovr' from list of development pip packages ([#1688](https://github.com/rapidsai/rmm/pull/1688)) [@jameslamb](https://github.com/jameslamb) +- [Improvement] Reorganize Cython to separate C++ bindings and make Cython classes public ([#1676](https://github.com/rapidsai/rmm/pull/1676)) [@Matt711](https://github.com/Matt711) + # rmm 24.10.00 (9 Oct 2024) ## 🚨 Breaking Changes From 3cad8fed150c3905962ca849b11bfc12fadd2517 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 11 Dec 2024 12:15:22 -0600 Subject: [PATCH 519/675] Use ruff, remove isort and black. (#1759) Closes #1758. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Matthew Murray (https://github.com/Matt711) - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1759 --- .pre-commit-config.yaml | 35 +++++--------- pyproject.toml | 88 +++++++++++++++++++++++++++++++++++- python/rmm/pyproject.toml | 64 +++++--------------------- python/rmm/rmm/_cuda/gpu.py | 1 + python/rmm/rmm/mr.py | 12 ++--- python/rmm/rmm/statistics.py | 12 ++--- 6 files changed, 122 insertions(+), 90 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2f8385092..9349f45cd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,12 @@ # Copyright (c) 2022-2024, NVIDIA CORPORATION. ci: - autofix_commit_msg: "[pre-commit.ci] auto code formatting" - autofix_prs: false - autoupdate_branch: "" - autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate" - autoupdate_schedule: quarterly - skip: ["verify-alpha-spec"] - submodules: false + autofix_commit_msg: "[pre-commit.ci] auto code formatting" + autofix_prs: false + autoupdate_branch: "" + autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate" + autoupdate_schedule: quarterly + skip: ["verify-alpha-spec"] + submodules: false repos: - repo: https://github.com/pre-commit/pre-commit-hooks @@ -14,18 +14,12 @@ repos: hooks: - id: trailing-whitespace - id: end-of-file-fixer - - repo: https://github.com/PyCQA/isort - rev: 5.13.2 - hooks: - - id: isort - args: ["--settings-path=python/rmm/pyproject.toml"] - files: python/.* - types_or: [python, cython, pyi] - - repo: https://github.com/ambv/black - rev: 24.10.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.8.2 hooks: - - id: black - args: ["--config=python/rmm/pyproject.toml"] + - id: ruff + args: ["--fix"] + - id: ruff-format - repo: https://github.com/MarcoGorelli/cython-lint rev: v0.16.6 hooks: @@ -80,11 +74,6 @@ repos: language: system pass_filenames: false verbose: true - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.2 - hooks: - - id: ruff - files: python/.*$ - repo: https://github.com/rapidsai/pre-commit-hooks rev: v0.4.0 hooks: diff --git a/pyproject.toml b/pyproject.toml index 929d5e563..b99bf800c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,14 +11,98 @@ builtin = "clear" quiet-level = 3 [tool.ruff] -select = ["E", "F", "W"] +line-length = 79 +target-version = "py310" + +[tool.ruff.lint] +select = [ + # pycodestyle Error + "E", + # Pyflakes + "F", + # pycodestyle Warning + "W", + # isort + "I", + # no-blank-line-before-function + "D201", + # one-blank-line-after-class + "D204", + # indent-with-spaces + "D206", + # under-indentation + "D207", + # over-indentation + "D208", + # new-line-after-last-paragraph + "D209", + # surrounding-whitespace + "D210", + # blank-line-before-class + "D211", + # section-not-over-indented + "D214", + # section-underline-not-over-indented + "D215", + # triple-single-quotes + "D300", + # escape-sequence-in-docstring + "D301", + # first-line-capitalized + "D403", + # capitalize-section-name + "D405", + # new-line-after-section-name + "D406", + # dashed-underline-after-section + "D407", + # section-underline-after-name + "D408", + # section-underline-matches-section-length + "D409", + # no-blank-line-after-section + "D410", + # no-blank-line-before-section + "D411", + # blank-lines-between-header-and-content + "D412", + # empty-docstring-section + "D414", + # overload-with-docstring + "D418", + # flake8-type-checking + "TCH", + # flake8-future-annotations + "FA", + # non-pep585-annotation + "UP006", + # non-pep604-annotation + "UP007", + # Import from `collections.abc` instead: `Callable` + "UP035", + # usage of legacy `np.random` function calls + "NPY002", + # Ruff-specific rules + "RUF", +] ignore = [ # whitespace before : "E203", + # line-too-long (due to Copyright header) + "E501", + # type-comparison, disabled because we compare types to numpy dtypes + "E721", + # String contains ambiguous character + "RUF001", + # Parenthesize `a and b` expressions when chaining `and` and `or` + # together, to make the precedence clear + "RUF021", + # Mutable class attributes should be annotated with + # `typing.ClassVar` + "RUF012", ] fixable = ["ALL"] exclude = [ # TODO: Remove this in a follow-up where we fix __all__. "__init__.py", ] -line-length = 79 diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index a235130e1..e2dbb9711 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -54,59 +54,6 @@ test = [ [project.urls] Homepage = "https://github.com/rapidsai/rmm" -[tool.black] -line-length = 79 -target-version = ["py310"] -include = '\.py?$' -exclude = ''' -/( - thirdparty | - \.eggs | - \.git | - \.hg | - \.mypy_cache | - \.tox | - \.venv | - _build | - buck-out | - build | - dist -)/ -''' - -[tool.isort] -line_length = 79 -multi_line_output = 3 -include_trailing_comma = true -force_grid_wrap = 0 -combine_as_imports = true -order_by_type = true -known_first_party = [ - "rmm", -] -default_section = "THIRDPARTY" -sections = [ - "FUTURE", - "STDLIB", - "THIRDPARTY", - "FIRSTPARTY", - "LOCALFOLDER", -] -skip = [ - "thirdparty", - ".eggs", - ".git", - ".hg", - ".mypy_cache", - ".tox", - ".venv", - "_build", - "buck-out", - "build", - "dist", - "__init__.py", -] - [tool.scikit-build] build-dir = "build/{wheel_tag}" cmake.build-type = "Release" @@ -148,3 +95,14 @@ filterwarnings = [ "error", "ignore:.*cuda..* module is deprecated.*:DeprecationWarning" ] + +[tool.ruff] +extend = "../../pyproject.toml" + +[tool.ruff.lint.isort] +combine-as-imports = true +known-first-party = ["rmm"] +section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"] + +[tool.ruff.lint.per-file-ignores] +"__init__.py" = ["E402", "F401"] diff --git a/python/rmm/rmm/_cuda/gpu.py b/python/rmm/rmm/_cuda/gpu.py index 8ed7abc93..75f9fa0f9 100644 --- a/python/rmm/rmm/_cuda/gpu.py +++ b/python/rmm/rmm/_cuda/gpu.py @@ -62,6 +62,7 @@ def getDevice(): def setDevice(device: int): """ Set the current CUDA device + Parameters ---------- device : int diff --git a/python/rmm/rmm/mr.py b/python/rmm/rmm/mr.py index 82729271f..673ffde82 100644 --- a/python/rmm/rmm/mr.py +++ b/python/rmm/rmm/mr.py @@ -52,6 +52,7 @@ "CudaAsyncMemoryResource", "CudaMemoryResource", "DeviceMemoryResource", + "FailureCallbackResourceAdaptor", "FixedSizeMemoryResource", "LimitingResourceAdaptor", "LoggingResourceAdaptor", @@ -62,19 +63,18 @@ "StatisticsResourceAdaptor", "SystemMemoryResource", "TrackingResourceAdaptor", - "FailureCallbackResourceAdaptor", "UpstreamResourceAdaptor", "_flush_logs", "_initialize", "available_device_memory", - "set_per_device_resource", - "enable_logging", "disable_logging", - "get_per_device_resource", - "set_current_device_resource", + "enable_logging", "get_current_device_resource", - "get_per_device_resource_type", "get_current_device_resource_type", "get_log_filenames", + "get_per_device_resource", + "get_per_device_resource_type", "is_initialized", + "set_current_device_resource", + "set_per_device_resource", ] diff --git a/python/rmm/rmm/statistics.py b/python/rmm/rmm/statistics.py index 2dabedce6..f7908c3f1 100644 --- a/python/rmm/rmm/statistics.py +++ b/python/rmm/rmm/statistics.py @@ -18,7 +18,7 @@ from contextlib import contextmanager from dataclasses import dataclass from functools import wraps -from typing import Dict, Literal, Optional +from typing import Literal import rmm.mr @@ -71,7 +71,7 @@ def enable_statistics() -> None: ) -def get_statistics() -> Optional[Statistics]: +def get_statistics() -> Statistics | None: """Get the current allocation statistics. Returns @@ -85,7 +85,7 @@ def get_statistics() -> Optional[Statistics]: return None -def push_statistics() -> Optional[Statistics]: +def push_statistics() -> Statistics | None: """Push new counters on the current allocation statistics stack. This returns the current tracked statistics and pushes a new set @@ -105,7 +105,7 @@ def push_statistics() -> Optional[Statistics]: return None -def pop_statistics() -> Optional[Statistics]: +def pop_statistics() -> Statistics | None: """Pop the counters of the current allocation statistics stack. This returns the counters of current tracked statistics and pops @@ -193,7 +193,7 @@ def add(self, memory_total: int, memory_peak: int): def __init__(self) -> None: self._lock = threading.Lock() - self._records: Dict[str, ProfilerRecords.MemoryRecord] = defaultdict( + self._records: dict[str, ProfilerRecords.MemoryRecord] = defaultdict( ProfilerRecords.MemoryRecord ) @@ -215,7 +215,7 @@ def add(self, name: str, data: Statistics) -> None: ) @property - def records(self) -> Dict[str, MemoryRecord]: + def records(self) -> dict[str, MemoryRecord]: """Dictionary mapping record names to their memory statistics.""" return dict(self._records) From 9aff75594b1c5a2ee73a6626bf8e34153fd2c88c Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 13 Dec 2024 22:45:59 -0600 Subject: [PATCH 520/675] Merge branch-24.12 into branch-25.02 From bf606efbca83bde14e2926a0f99ea057df819cd6 Mon Sep 17 00:00:00 2001 From: Matthew Murray <41342305+Matt711@users.noreply.github.com> Date: Sat, 14 Dec 2024 00:19:07 -0500 Subject: [PATCH 521/675] Remove `rmm._lib` (#1765) Closes #1762 Authors: - Matthew Murray (https://github.com/Matt711) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1765 --- python/rmm/rmm/__init__.py | 16 ------ python/rmm/rmm/_lib/__init__.py | 23 -------- python/rmm/rmm/_lib/cuda_stream.pxd | 16 ------ python/rmm/rmm/_lib/cuda_stream.py | 15 ----- python/rmm/rmm/_lib/cuda_stream_pool.pxd | 15 ----- python/rmm/rmm/_lib/cuda_stream_view.pxd | 20 ------- python/rmm/rmm/_lib/device_buffer.pxd | 27 --------- python/rmm/rmm/_lib/device_buffer.py | 21 ------- python/rmm/rmm/_lib/device_uvector.pxd | 15 ----- python/rmm/rmm/_lib/helper.pxd | 15 ----- python/rmm/rmm/_lib/logger.pxd | 24 -------- python/rmm/rmm/_lib/logger.py | 24 -------- python/rmm/rmm/_lib/memory_resource.pxd | 62 --------------------- python/rmm/rmm/_lib/memory_resource.py | 45 --------------- python/rmm/rmm/_lib/per_device_resource.pxd | 21 ------- python/rmm/rmm/tests/test_rmm.py | 6 -- 16 files changed, 365 deletions(-) delete mode 100644 python/rmm/rmm/_lib/__init__.py delete mode 100644 python/rmm/rmm/_lib/cuda_stream.pxd delete mode 100644 python/rmm/rmm/_lib/cuda_stream.py delete mode 100644 python/rmm/rmm/_lib/cuda_stream_pool.pxd delete mode 100644 python/rmm/rmm/_lib/cuda_stream_view.pxd delete mode 100644 python/rmm/rmm/_lib/device_buffer.pxd delete mode 100644 python/rmm/rmm/_lib/device_buffer.py delete mode 100644 python/rmm/rmm/_lib/device_uvector.pxd delete mode 100644 python/rmm/rmm/_lib/helper.pxd delete mode 100644 python/rmm/rmm/_lib/logger.pxd delete mode 100644 python/rmm/rmm/_lib/logger.py delete mode 100644 python/rmm/rmm/_lib/memory_resource.pxd delete mode 100644 python/rmm/rmm/_lib/memory_resource.py delete mode 100644 python/rmm/rmm/_lib/per_device_resource.pxd diff --git a/python/rmm/rmm/__init__.py b/python/rmm/rmm/__init__.py index 5c865eba8..f1d6e2d7e 100644 --- a/python/rmm/rmm/__init__.py +++ b/python/rmm/rmm/__init__.py @@ -54,19 +54,3 @@ "should_log", "unregister_reinitialize_hook", ] - - -def __getattr__(name): - if name == "_lib": - import importlib - - warnings.warn( - "The `rmm._lib` module is deprecated in will be removed in a future release. Use `rmm.pylibrmm` instead.", - FutureWarning, - stacklevel=2, - ) - - module = importlib.import_module("rmm.pylibrmm") - return module - else: - raise AttributeError(f"Module '{__name__}' has no attribute '{name}'") diff --git a/python/rmm/rmm/_lib/__init__.py b/python/rmm/rmm/_lib/__init__.py deleted file mode 100644 index 7e01bda77..000000000 --- a/python/rmm/rmm/_lib/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (c) 2018-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. - -import warnings - -from rmm.pylibrmm import * - -warnings.warn( - "The `rmm._lib` module is deprecated in will be removed in a future release. Use `rmm.pylibrmm` instead.", - FutureWarning, - stacklevel=2, -) diff --git a/python/rmm/rmm/_lib/cuda_stream.pxd b/python/rmm/rmm/_lib/cuda_stream.pxd deleted file mode 100644 index afc365fbb..000000000 --- a/python/rmm/rmm/_lib/cuda_stream.pxd +++ /dev/null @@ -1,16 +0,0 @@ -# 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. - -from rmm.librmm.cuda_stream cimport cuda_stream -from rmm.pylibrmm.cuda_stream cimport CudaStream diff --git a/python/rmm/rmm/_lib/cuda_stream.py b/python/rmm/rmm/_lib/cuda_stream.py deleted file mode 100644 index 1eb424e12..000000000 --- a/python/rmm/rmm/_lib/cuda_stream.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2018-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. - -from rmm.pylibrmm.cuda_stream import CudaStream # noqa: F401 diff --git a/python/rmm/rmm/_lib/cuda_stream_pool.pxd b/python/rmm/rmm/_lib/cuda_stream_pool.pxd deleted file mode 100644 index 4da59cc68..000000000 --- a/python/rmm/rmm/_lib/cuda_stream_pool.pxd +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2021-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. - -from rmm.librmm.cuda_stream_pool cimport cuda_stream_pool diff --git a/python/rmm/rmm/_lib/cuda_stream_view.pxd b/python/rmm/rmm/_lib/cuda_stream_view.pxd deleted file mode 100644 index c336b0fe8..000000000 --- a/python/rmm/rmm/_lib/cuda_stream_view.pxd +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2020-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. - -from rmm.librmm.cuda_stream_view cimport ( - cuda_stream_default, - cuda_stream_legacy, - cuda_stream_per_thread, - cuda_stream_view, -) diff --git a/python/rmm/rmm/_lib/device_buffer.pxd b/python/rmm/rmm/_lib/device_buffer.pxd deleted file mode 100644 index 22833b1b8..000000000 --- a/python/rmm/rmm/_lib/device_buffer.pxd +++ /dev/null @@ -1,27 +0,0 @@ -# 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. - -from rmm.librmm.device_buffer cimport ( - cuda_device_id, - device_buffer, - get_current_cuda_device, - prefetch, -) -from rmm.pylibrmm.device_buffer cimport ( - DeviceBuffer, - copy_device_to_ptr, - copy_host_to_ptr, - copy_ptr_to_host, - to_device, -) diff --git a/python/rmm/rmm/_lib/device_buffer.py b/python/rmm/rmm/_lib/device_buffer.py deleted file mode 100644 index c531bca5f..000000000 --- a/python/rmm/rmm/_lib/device_buffer.py +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) 2018-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. - -from rmm.pylibrmm.device_buffer import ( # noqa: F401 - DeviceBuffer, - copy_device_to_ptr, - copy_host_to_ptr, - copy_ptr_to_host, - to_device, -) diff --git a/python/rmm/rmm/_lib/device_uvector.pxd b/python/rmm/rmm/_lib/device_uvector.pxd deleted file mode 100644 index 230b0afb3..000000000 --- a/python/rmm/rmm/_lib/device_uvector.pxd +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2021-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. - -from rmm.librmm.device_uvector cimport device_uvector diff --git a/python/rmm/rmm/_lib/helper.pxd b/python/rmm/rmm/_lib/helper.pxd deleted file mode 100644 index 4a5159435..000000000 --- a/python/rmm/rmm/_lib/helper.pxd +++ /dev/null @@ -1,15 +0,0 @@ -# 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. - -from rmm.pylibrmm.helper cimport parse_bytes diff --git a/python/rmm/rmm/_lib/logger.pxd b/python/rmm/rmm/_lib/logger.pxd deleted file mode 100644 index bef05c903..000000000 --- a/python/rmm/rmm/_lib/logger.pxd +++ /dev/null @@ -1,24 +0,0 @@ -# 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. - -from rmm.librmm._logger cimport logger, logging_level, spdlog_logger -from rmm.pylibrmm.logger cimport ( - _validate_level_type, - flush_logger, - get_flush_level, - get_logging_level, - set_flush_level, - set_logging_level, - should_log, -) diff --git a/python/rmm/rmm/_lib/logger.py b/python/rmm/rmm/_lib/logger.py deleted file mode 100644 index 1e9b519b8..000000000 --- a/python/rmm/rmm/_lib/logger.py +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2018-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. - -from rmm.librmm._logger import logging_level # noqa: F401 -from rmm.pylibrmm.logger import ( # noqa: F401 - _validate_level_type, - flush_logger, - get_flush_level, - get_logging_level, - set_flush_level, - set_logging_level, - should_log, -) diff --git a/python/rmm/rmm/_lib/memory_resource.pxd b/python/rmm/rmm/_lib/memory_resource.pxd deleted file mode 100644 index 0d11001a4..000000000 --- a/python/rmm/rmm/_lib/memory_resource.pxd +++ /dev/null @@ -1,62 +0,0 @@ -# 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. - -from rmm.librmm.memory_resource cimport ( - CppExcept, - allocate_callback_t, - allocation_handle_type, - available_device_memory, - binning_memory_resource, - callback_memory_resource, - cuda_async_memory_resource, - cuda_memory_resource, - deallocate_callback_t, - device_memory_resource, - failure_callback_resource_adaptor, - failure_callback_t, - fixed_size_memory_resource, - limiting_resource_adaptor, - logging_resource_adaptor, - managed_memory_resource, - percent_of_free_device_memory, - pool_memory_resource, - prefetch_resource_adaptor, - sam_headroom_memory_resource, - statistics_resource_adaptor, - system_memory_resource, - throw_cpp_except, - tracking_resource_adaptor, - translate_python_except_to_cpp, -) -from rmm.pylibrmm.memory_resource cimport ( - ArenaMemoryResource, - BinningMemoryResource, - CallbackMemoryResource, - CudaAsyncMemoryResource, - CudaMemoryResource, - DeviceMemoryResource, - FailureCallbackResourceAdaptor, - FixedSizeMemoryResource, - LimitingResourceAdaptor, - LoggingResourceAdaptor, - ManagedMemoryResource, - PoolMemoryResource, - PrefetchResourceAdaptor, - SamHeadroomMemoryResource, - StatisticsResourceAdaptor, - SystemMemoryResource, - TrackingResourceAdaptor, - UpstreamResourceAdaptor, - get_current_device_resource, -) diff --git a/python/rmm/rmm/_lib/memory_resource.py b/python/rmm/rmm/_lib/memory_resource.py deleted file mode 100644 index f3a24f635..000000000 --- a/python/rmm/rmm/_lib/memory_resource.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (c) 2018-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. - -from rmm.pylibrmm.memory_resource import ( # noqa: F401 - ArenaMemoryResource, - BinningMemoryResource, - CallbackMemoryResource, - CudaAsyncMemoryResource, - CudaMemoryResource, - DeviceMemoryResource, - FailureCallbackResourceAdaptor, - FixedSizeMemoryResource, - LimitingResourceAdaptor, - LoggingResourceAdaptor, - ManagedMemoryResource, - PoolMemoryResource, - PrefetchResourceAdaptor, - SamHeadroomMemoryResource, - StatisticsResourceAdaptor, - SystemMemoryResource, - TrackingResourceAdaptor, - UpstreamResourceAdaptor, - _flush_logs, - available_device_memory, - disable_logging, - enable_logging, - get_current_device_resource, - get_current_device_resource_type, - get_log_filenames, - get_per_device_resource_type, - is_initialized, - set_current_device_resource, - set_per_device_resource, -) diff --git a/python/rmm/rmm/_lib/per_device_resource.pxd b/python/rmm/rmm/_lib/per_device_resource.pxd deleted file mode 100644 index 29487f503..000000000 --- a/python/rmm/rmm/_lib/per_device_resource.pxd +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (c) 2019-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. - -from rmm.librmm.per_device_resource cimport ( - cuda_device_id, - get_current_device_resource, - get_per_device_resource, - set_current_device_resource, - set_per_device_resource, -) diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index 7d13b5cac..f655b4616 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -1078,9 +1078,3 @@ def test_available_device_memory(): assert initial_memory[1] == final_memory[1] assert initial_memory[0] > 0 assert final_memory[0] > 0 - - -# TODO: Remove test when rmm._lib is removed in 25.02 -def test_deprecate_rmm_lib(): - with pytest.warns(FutureWarning): - rmm._lib.device_buffer.DeviceBuffer(size=100) From a83c2ea7d00a3caa290d24b6a9a574c28c04e72a Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 17 Dec 2024 12:38:03 -0600 Subject: [PATCH 522/675] Remove ignored cuda-python deprecation warning. (#1768) Following https://github.com/rapidsai/rmm/pull/1756, we no longer need to guard against this deprecation warning. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Matthew Murray (https://github.com/Matt711) - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1768 --- python/rmm/pyproject.toml | 1 - python/rmm/rmm/tests/test_rmm.py | 24 ++++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index e2dbb9711..6ff45a337 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -93,7 +93,6 @@ max_allowed_size_compressed = '75M' # treat warnings as errors filterwarnings = [ "error", - "ignore:.*cuda..* module is deprecated.*:DeprecationWarning" ] [tool.ruff] diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index f655b4616..de363e4b4 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -20,9 +20,9 @@ import warnings from itertools import product -import cuda.cudart as cudart import numpy as np import pytest +from cuda.bindings import runtime from numba import cuda import rmm @@ -34,7 +34,7 @@ cuda.set_memory_manager(RMMNumbaManager) _SYSTEM_MEMORY_SUPPORTED = rmm._cuda.gpu.getDeviceAttribute( - cudart.cudaDeviceAttr.cudaDevAttrPageableMemoryAccess, + runtime.cudaDeviceAttr.cudaDevAttrPageableMemoryAccess, rmm._cuda.gpu.getDevice(), ) @@ -319,13 +319,13 @@ def test_rmm_device_buffer_pickle_roundtrip(hb): def assert_prefetched(buffer, device_id): - err, dev = cudart.cudaMemRangeGetAttribute( + err, dev = runtime.cudaMemRangeGetAttribute( 4, - cudart.cudaMemRangeAttribute.cudaMemRangeAttributeLastPrefetchLocation, + runtime.cudaMemRangeAttribute.cudaMemRangeAttributeLastPrefetchLocation, buffer.ptr, buffer.size, ) - assert err == cudart.cudaError_t.cudaSuccess + assert err == runtime.cudaError_t.cudaSuccess assert dev == device_id @@ -336,11 +336,11 @@ def test_rmm_device_buffer_prefetch(pool, managed): rmm.reinitialize(pool_allocator=pool, managed_memory=managed) db = rmm.DeviceBuffer.to_device(np.zeros(256, dtype="u1")) if managed: - assert_prefetched(db, cudart.cudaInvalidDeviceId) + assert_prefetched(db, runtime.cudaInvalidDeviceId) db.prefetch() # just test that it doesn't throw if managed: - err, device = cudart.cudaGetDevice() - assert err == cudart.cudaError_t.cudaSuccess + err, device = runtime.cudaGetDevice() + assert err == runtime.cudaError_t.cudaSuccess assert_prefetched(db, device) @@ -830,15 +830,15 @@ def test_prefetch_resource_adaptor(managed): # This allocation should be prefetched db = rmm.DeviceBuffer.to_device(np.zeros(256, dtype="u1")) - err, device = cudart.cudaGetDevice() - assert err == cudart.cudaError_t.cudaSuccess + err, device = runtime.cudaGetDevice() + assert err == runtime.cudaError_t.cudaSuccess if managed: assert_prefetched(db, device) db.prefetch() # just test that it doesn't throw if managed: - err, device = cudart.cudaGetDevice() - assert err == cudart.cudaError_t.cudaSuccess + err, device = runtime.cudaGetDevice() + assert err == runtime.cudaError_t.cudaSuccess assert_prefetched(db, device) From c7c38fa5396bf27c25904acfc196fe712f14564d Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 17 Dec 2024 12:55:54 -0600 Subject: [PATCH 523/675] Fix codespell behavior. (#1769) Recently, I added support for `codespell` in CCCL (https://github.com/NVIDIA/cccl/pull/3168). @shwina noticed some issues in my PR that were fixed in https://github.com/NVIDIA/cccl/pull/3182. This PR ports similar fixes to RMM, to make `codespell` work better when run both inside and outside of `pre-commit`. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Mike Sarahan (https://github.com/msarahan) URL: https://github.com/rapidsai/rmm/pull/1769 --- .pre-commit-config.yaml | 2 ++ pyproject.toml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9349f45cd..647bf76c3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,6 +42,8 @@ repos: rev: v2.3.0 hooks: - id: codespell + additional_dependencies: [tomli] + args: ["--toml", "pyproject.toml"] exclude: | (?x)^( pyproject.toml| diff --git a/pyproject.toml b/pyproject.toml index b99bf800c..e6fec0296 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,10 +3,10 @@ [tool.codespell] # note: pre-commit passes explicit lists of files here, which this skip file list doesn't override - # this is only to allow you to run codespell interactively -skip = "./pyproject.toml,./.git,./.github,./cpp/build,.*egg-info.*,./.mypy_cache,./benchmarks/utilities/cxxopts.hpp" +skip = "./.git,./build,./python/_skbuild/,.*egg-info.*,./.mypy_cache,./pyproject.toml,./benchmarks/utilities/cxxopts.hpp" # ignore short words, and typename parameters like OffsetT ignore-regex = "\\b(.{1,4}|[A-Z]\\w*T)\\b" -ignore-words-list = "inout,thirdparty" +ignore-words-list = "thirdparty,couldn" builtin = "clear" quiet-level = 3 From 65858a94b1c1b3af124faae623b08a1561c2ef96 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 17 Dec 2024 14:23:28 -0600 Subject: [PATCH 524/675] Remove deprecated factory functions from resource adaptors. (#1767) Closes #1616. This removes factory functions for resource adaptors that were previously deprecated in RMM 24.10, in PR #1626. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1767 --- .../mr/device/limiting_resource_adaptor.hpp | 19 -------- .../mr/device/logging_resource_adaptor.hpp | 46 ------------------- .../rmm/mr/device/polymorphic_allocator.hpp | 19 -------- .../mr/device/statistics_resource_adaptor.hpp | 17 ------- .../mr/device/tracking_resource_adaptor.hpp | 17 ------- 5 files changed, 118 deletions(-) diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index d19fa3a0a..16729fd68 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -194,25 +194,6 @@ class limiting_resource_adaptor final : public device_memory_resource { std::size_t alignment_; }; -/** - * @brief Convenience factory to return a `limiting_resource_adaptor` around the - * upstream resource `upstream`. - * - * @tparam Upstream Type of the upstream `device_memory_resource`. - * @param upstream Pointer to the upstream resource - * @param allocation_limit Maximum amount of memory to allocate - * @return The new limiting resource adaptor - */ -template -[[deprecated( - "make_limiting_adaptor is deprecated in RMM 24.10. Use the limiting_resource_adaptor constructor " - "instead.")]] -limiting_resource_adaptor make_limiting_adaptor(Upstream* upstream, - std::size_t allocation_limit) -{ - return limiting_resource_adaptor{upstream, allocation_limit}; -} - /** @} */ // end of group } // namespace mr } // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 3e6e5babc..2d2291e3f 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -334,52 +334,6 @@ class logging_resource_adaptor final : public device_memory_resource { ///< allocation requests }; -/** - * @brief Convenience factory to return a `logging_resource_adaptor` around the - * upstream resource `upstream`. - * - * @tparam Upstream Type of the upstream `device_memory_resource`. - * @param upstream Pointer to the upstream resource - * @param filename Name of the file to write log info. If not specified, - * retrieves the log file name from the environment variable "RMM_LOG_FILE". - * @param auto_flush If true, flushes the log for every (de)allocation. Warning, this will degrade - * performance. - * @return The new logging resource adaptor - */ -template -[[deprecated( - "make_logging_adaptor is deprecated in RMM 24.10. Use the logging_resource_adaptor constructor " - "instead.")]] -logging_resource_adaptor make_logging_adaptor( - Upstream* upstream, - std::string const& filename = logging_resource_adaptor::get_default_filename(), - bool auto_flush = false) -{ - return logging_resource_adaptor{upstream, filename, auto_flush}; -} - -/** - * @brief Convenience factory to return a `logging_resource_adaptor` around the - * upstream resource `upstream`. - * - * @tparam Upstream Type of the upstream `device_memory_resource`. - * @param upstream Pointer to the upstream resource - * @param stream The ostream to write log info. - * @param auto_flush If true, flushes the log for every (de)allocation. Warning, this will degrade - * performance. - * @return The new logging resource adaptor - */ -template -[[deprecated( - "make_logging_adaptor is deprecated in RMM 24.10. Use the logging_resource_adaptor constructor " - "instead.")]] -logging_resource_adaptor make_logging_adaptor(Upstream* upstream, - std::ostream& stream, - bool auto_flush = false) -{ - return logging_resource_adaptor{upstream, stream, auto_flush}; -} - /** @} */ // end of group } // namespace mr } // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/polymorphic_allocator.hpp b/include/rmm/mr/device/polymorphic_allocator.hpp index 442632d4f..2e6fcd70d 100644 --- a/include/rmm/mr/device/polymorphic_allocator.hpp +++ b/include/rmm/mr/device/polymorphic_allocator.hpp @@ -293,25 +293,6 @@ bool operator!=(stream_allocator_adaptor const& lhs, stream_allocator_adaptor return not(lhs == rhs); } -/** - * @brief Factory to construct a `stream_allocator_adaptor` from an existing stream-ordered - * allocator. - * - * @tparam Allocator Type of the stream-ordered allocator - * @param allocator The allocator to use as the underlying allocator of the - * `stream_allocator_adaptor` - * @param stream The stream on which the `stream_allocator_adaptor` will perform (de)allocations - * @return A `stream_allocator_adaptor` wrapping `allocator` and `s` - */ -template -[[deprecated( - "make_stream_allocator_adaptor is deprecated in RMM 24.10. Use the stream_allocator_adaptor " - "constructor " - "instead.")]] -auto make_stream_allocator_adaptor(Allocator const& allocator, cuda_stream_view stream) -{ - return stream_allocator_adaptor{allocator, stream}; -} /** @} */ // end of group } // namespace mr } // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/statistics_resource_adaptor.hpp b/include/rmm/mr/device/statistics_resource_adaptor.hpp index 025c51aa7..8de6e1fe6 100644 --- a/include/rmm/mr/device/statistics_resource_adaptor.hpp +++ b/include/rmm/mr/device/statistics_resource_adaptor.hpp @@ -287,23 +287,6 @@ class statistics_resource_adaptor final : public device_memory_resource { device_async_resource_ref upstream_; }; -/** - * @brief Convenience factory to return a `statistics_resource_adaptor` around the - * upstream resource `upstream`. - * - * @param upstream Pointer to the upstream resource - * @return The new statistics resource adaptor - */ -template -[[deprecated( - "make_statistics_adaptor is deprecated in RMM 24.10. Use the statistics_resource_adaptor " - "constructor " - "instead.")]] -statistics_resource_adaptor make_statistics_adaptor(Upstream* upstream) -{ - return statistics_resource_adaptor{upstream}; -} - /** @} */ // end of group } // namespace mr } // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index 09631960e..1b2c13ba9 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -283,23 +283,6 @@ class tracking_resource_adaptor final : public device_memory_resource { // allocation requests }; -/** - * @brief Convenience factory to return a `tracking_resource_adaptor` around the - * upstream resource `upstream`. - * - * @tparam Upstream Type of the upstream `device_memory_resource`. - * @param upstream Pointer to the upstream resource - * @return The new tracking resource adaptor - */ -template -[[deprecated( - "make_tracking_adaptor is deprecated in RMM 24.10. Use the tracking_resource_adaptor constructor " - "instead.")]] -tracking_resource_adaptor make_tracking_adaptor(Upstream* upstream) -{ - return tracking_resource_adaptor{upstream}; -} - /** @} */ // end of group } // namespace mr } // namespace RMM_NAMESPACE From 1af03eb55ce51a376c3df2dc0cdf3c81738b2dd6 Mon Sep 17 00:00:00 2001 From: Mike Sarahan Date: Tue, 17 Dec 2024 14:45:48 -0600 Subject: [PATCH 525/675] remove certs and simplify telemetry summarize (#1750) The goal here is to remove the need for certificates. Any worker that is not in our VPC can talk directly to fluentbit, and fluentbit will be configured with certificates to talk to Tempo. The implementation implication is that we need to run telemetry stuff ONLY on nodes in our VPC. To avoid needing to move all jobs to these nodes, we instead temporarily store telemetry data as artifacts, and in one final job, we process and send telemetry info for all jobs from one job. Part of https://github.com/rapidsai/shared-workflows/pull/269 and https://github.com/rapidsai/shared-actions/pull/28 Authors: - Mike Sarahan (https://github.com/msarahan) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1750 --- .github/workflows/pr.yaml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 3ecd52c7e..e71c8cf64 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -19,11 +19,11 @@ jobs: - conda-python-build - conda-python-tests - docs-build - - telemetry-setup - wheel-build-cpp - wheel-build-python - wheel-tests - devcontainer + - telemetry-setup secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-25.02 if: always() @@ -33,9 +33,11 @@ jobs: runs-on: ubuntu-latest continue-on-error: true env: - OTEL_SERVICE_NAME: "pr-rmm" + OTEL_SERVICE_NAME: "pr-rmm" steps: - name: Telemetry setup + # This gate is here and not at the job level because we need the job to not be skipped, + # since other jobs depend on it. if: ${{ vars.TELEMETRY_ENABLED == 'true' }} uses: rapidsai/shared-actions/telemetry-dispatch-stash-base-env-vars@main changed-files: @@ -141,16 +143,11 @@ jobs: sccache -s; telemetry-summarize: - runs-on: ubuntu-latest + # This job must use a self-hosted runner to record telemetry traces. + runs-on: linux-amd64-cpu4 needs: pr-builder if: ${{ vars.TELEMETRY_ENABLED == 'true' && !cancelled() }} continue-on-error: true steps: - - name: Load stashed telemetry env vars - uses: rapidsai/shared-actions/telemetry-dispatch-load-base-env-vars@main - with: - load_service_name: true - name: Telemetry summarize - uses: rapidsai/shared-actions/telemetry-dispatch-write-summary@main - with: - cert_concat: "${{ secrets.OTEL_EXPORTER_OTLP_CA_CERTIFICATE }};${{ secrets.OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE }};${{ secrets.OTEL_EXPORTER_OTLP_CLIENT_KEY }}" + uses: rapidsai/shared-actions/telemetry-dispatch-summarize@main From 3bf6026be1420e29e394c7c0724b1a6310ea9a38 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 19 Dec 2024 10:22:42 -0500 Subject: [PATCH 526/675] Add missing array header include (#1771) When stack trace is enabled we would run into compile failures since `array.h` wasn't explicitly included. We only work currently due to other headers bringing this include in. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1771 --- include/rmm/detail/stack_trace.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/rmm/detail/stack_trace.hpp b/include/rmm/detail/stack_trace.hpp index 7b3d40bd2..0886ceb51 100644 --- a/include/rmm/detail/stack_trace.hpp +++ b/include/rmm/detail/stack_trace.hpp @@ -32,6 +32,7 @@ #include #include +#include #include #include #include From ba35f8e68afa5983d1e5ee1a4dd78cd844c53481 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 20 Dec 2024 12:42:35 -0600 Subject: [PATCH 527/675] Reduce dependencies on numba. (#1761) This PR makes `numba` an optional dependency of RMM. We are keeping `numba` as a hard dependency in tests, though I explored what it would look like as a soft dependency in e2ff7f1. It turns out that the current RMM test suite relies on `numba` for about 90% of the tests, as a way to copy data from host to device and back (to verify that the allocations are valid and usable). Closes #1760. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Matthew Murray (https://github.com/Matt711) - Mark Harris (https://github.com/harrism) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1761 --- dependencies.yaml | 4 ++-- python/rmm/pyproject.toml | 2 +- python/rmm/rmm/_cuda/stream.pyx | 15 +++++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/dependencies.yaml b/dependencies.yaml index 671809a66..7f94f3f6e 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -274,7 +274,6 @@ dependencies: common: - output_types: [conda, requirements, pyproject] packages: - - numba>=0.57 - numpy>=1.23,<3.0a0 specific: - output_types: [conda, requirements, pyproject] @@ -295,6 +294,7 @@ dependencies: common: - output_types: [conda, requirements, pyproject] packages: + - numba>=0.57 - pytest - pytest-cov specific: @@ -309,7 +309,7 @@ dependencies: - cuda-nvcc - matrix: packages: - - output_types: [conda, requirements] + - output_types: [conda, requirements, pyproject] # Define additional constraints for testing with oldest dependencies. matrices: - matrix: diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 6ff45a337..87795974f 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -31,7 +31,6 @@ license = { text = "Apache 2.0" } requires-python = ">=3.10" dependencies = [ "cuda-python>=11.8.5,<12.0a0", - "numba>=0.57", "numpy>=1.23,<3.0a0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. classifiers = [ @@ -47,6 +46,7 @@ classifiers = [ [project.optional-dependencies] test = [ + "numba>=0.57", "pytest", "pytest-cov", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. diff --git a/python/rmm/rmm/_cuda/stream.pyx b/python/rmm/rmm/_cuda/stream.pyx index 951f3f40c..e51f28721 100644 --- a/python/rmm/rmm/_cuda/stream.pyx +++ b/python/rmm/rmm/_cuda/stream.pyx @@ -90,12 +90,15 @@ cdef class Stream: return self.c_is_default() def _init_from_numba_stream(self, obj): - from numba import cuda - if isinstance(obj, cuda.cudadrv.driver.Stream): - self._cuda_stream = (int(obj)) - self._owner = obj - else: - raise TypeError(f"Cannot create stream from {type(obj)}") + try: + from numba import cuda + if isinstance(obj, cuda.cudadrv.driver.Stream): + self._cuda_stream = (int(obj)) + self._owner = obj + return + except ImportError: + pass + raise TypeError(f"Cannot create stream from {type(obj)}") def _init_from_cupy_stream(self, obj): try: From 8275ba8dc94a7fc63d9513acd81e3a2cf30a85d1 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 2 Jan 2025 08:36:02 -0800 Subject: [PATCH 528/675] Switch to using separate rapids-logger repo (#1774) This PR removes rmm's logger code in favor of using the [rapids-logger repo](https://github.com/rapidsai/rapids-logger) to which that code was moved. The main material change is that with the latest commit on that repo rmm will dump output to stderr instead of to a file by default, which was the generally requested behavior and also aligns with the rest of RAPIDS's loggers pre-rapids-logger. Nonetheless, I've marked that as a breaking change (also because the rapids-logger code is no longer available from this repository). Contributes to https://github.com/rapidsai/build-planning/issues/104. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1774 --- .gitignore | 3 - CMakeLists.txt | 8 +- README.md | 4 +- rapids_logger/CMakeLists.txt | 177 ----------- rapids_logger/README.md | 22 -- rapids_logger/logger.cpp.in | 17 -- rapids_logger/logger.hpp.in | 504 ------------------------------- rapids_logger/logger_impl.hpp.in | 211 ------------- 8 files changed, 6 insertions(+), 940 deletions(-) delete mode 100644 rapids_logger/CMakeLists.txt delete mode 100644 rapids_logger/README.md delete mode 100644 rapids_logger/logger.cpp.in delete mode 100644 rapids_logger/logger.hpp.in delete mode 100644 rapids_logger/logger_impl.hpp.in diff --git a/.gitignore b/.gitignore index df9d920d5..52ad86cbc 100644 --- a/.gitignore +++ b/.gitignore @@ -155,9 +155,6 @@ ENV/ # mypy .mypy_cache/ -# RMM log files -rmm_log.txt - # cibuildwheel /wheelhouse diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c5bd5428..d281d047e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2018-2024, NVIDIA CORPORATION. +# Copyright (c) 2018-2025, 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 @@ -73,10 +73,10 @@ rapids_find_package( # add third party dependencies using CPM rapids_cpm_init() -add_subdirectory(rapids_logger) +CPMAddPackage( + NAME rapids_logger GITHUB_REPOSITORY rapidsai/rapids-logger GIT_SHALLOW FALSE GIT_TAG + 1043e0f3989d75ad52f5212544b8154777e86fc9 VERSION 1043e0f3989d75ad52f5212544b8154777e86fc9) rapids_make_logger(rmm EXPORT_SET rmm-exports) -add_library(rmm::rmm_logger ALIAS rmm_logger) -add_library(rmm::rmm_logger_impl ALIAS rmm_logger_impl) include(cmake/thirdparty/get_cccl.cmake) include(cmake/thirdparty/get_nvtx.cmake) diff --git a/README.md b/README.md index 1d1f7a8ee..62ac48805 100644 --- a/README.md +++ b/README.md @@ -647,8 +647,8 @@ set to `True`. The log file name can be set using the `log_file_name` parameter. RMM includes a debug logger which can be enabled to log trace and debug information to a file. This information can show when errors occur, when additional memory is allocated from upstream resources, -etc. The default log file is `rmm_log.txt` in the current working directory, but the environment -variable `RMM_DEBUG_LOG_FILE` can be set to specify the path and file name. +etc. By default output is logged to stderr, but the environment variable +`RMM_DEBUG_LOG_FILE` can be set to specify a path and file name to dump the logs to instead. There is a CMake configuration variable `RMM_LOGGING_LEVEL`, which can be set to enable compilation of more detailed logging. The default is `INFO`. Available levels are `TRACE`, `DEBUG`, `INFO`, diff --git a/rapids_logger/CMakeLists.txt b/rapids_logger/CMakeLists.txt deleted file mode 100644 index fd50276ca..000000000 --- a/rapids_logger/CMakeLists.txt +++ /dev/null @@ -1,177 +0,0 @@ -# ============================================================================= -# 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. -# ============================================================================= - -# cmake-lint: disable=R0915 - -include_guard(GLOBAL) - -cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) - -include(../rapids_config.cmake) - -include(rapids-cmake) -include(rapids-cpm) - -project( - RAPIDS_LOGGER - VERSION 0.0.1 - LANGUAGES CXX) - -rapids_cmake_build_type(Release) - -rapids_cpm_init() - -include(../cmake/thirdparty/get_spdlog.cmake) - -#[=======================================================================[.rst: -rapids_make_logger ------------------- - -Generate a logger implementation customized for the specified namespace. - -.. code-block:: cmake - - rapids_make_logger( - [EXPORT_SET ] - [LOGGER_TARGET ] - [LOGGER_HEADER_DIR ] - [LOGGER_MACRO_PREFIX ] - ) - -This function produces an interface target named that, when linked to by other targets, provides them a header file that defines a logger interface for the specified namespace. The logger is generated from the provided template files and is configured to use the specified namespace and macro prefix. The generated logger is placed in the specified header directory. - -The logger implementation lives in a separate header file that is not included in the declaration header. The logger implementation is compiled into a separate target that must be linked to by any target that uses the logger. - - -``logger_namespace`` - The namespace for which to generate the logger implementation. - -``EXPORT_SET`` - The name of the export set to which the logger target should be added. If not specified, the logger target is not added to any export set. - -``LOGGER_TARGET`` - The name of the logger (and logger impl) target to create. If not specified, defaults to _logger. - -``LOGGER_HEADER_DIR`` - The directory in which to place the generated logger header file. If not specified, the logger header file is placed in include/. - -``LOGGER_MACRO_PREFIX`` - The prefix to use for the logger macros. If not specified, the macro prefix is the uppercase version of the logger namespace. - -Result Targets -^^^^^^^^^^^^^^^^ - is an interface target that provides the logger interface for the specified namespace. - - _impl is an interface target that provides the logger implementation for the specified namespace. This target must be linked to by any target that uses the logger. Targets linking to this target will have the logger implementation compiled into them. - -Examples -^^^^^^^^ - -Example on how to use :cmake:command:`rapids_make_logger`. - - -.. code-block:: cmake - - # Generate a logger for the namespace "rapids" and associate it with the - # export set "rapids-exports". - rapids_make_logger(rapids - EXPORT_SET rapids-exports - ) - - # Generate a logger for the namespace "rmm" that does not support logging. - rapids_make_logger(rapids) - - -#]=======================================================================] -function(rapids_make_logger logger_namespace) - list(APPEND CMAKE_MESSAGE_CONTEXT "rapids_make_logger") - - set(_rapids_options) - set(_rapids_one_value EXPORT_SET LOGGER_TARGET LOGGER_HEADER_DIR LOGGER_MACRO_PREFIX) - set(_rapids_multi_value) - cmake_parse_arguments(_RAPIDS "${_rapids_options}" "${_rapids_one_value}" - "${_rapids_multi_value}" ${ARGN}) - - # Most arguments are optional and can be inferred from the namespace by default. - set(_RAPIDS_LOGGER_NAMESPACE ${logger_namespace}) - if(NOT _RAPIDS_LOGGER_TARGET) - set(_RAPIDS_LOGGER_TARGET "${logger_namespace}_logger") - endif() - if(NOT _RAPIDS_LOGGER_HEADER_DIR) - set(_RAPIDS_LOGGER_HEADER_DIR "include/${logger_namespace}") - endif() - if(NOT _RAPIDS_LOGGER_MACRO_PREFIX) - string(TOUPPER ${logger_namespace} _RAPIDS_LOGGER_MACRO_PREFIX) - endif() - - # All paths are computed relative to the current source/binary dir of the file from which the - # function is invoked. As a result we cannot use relative paths here because CMake will root these - # paths incorrectly for configure_file/install. - set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${_RAPIDS_LOGGER_HEADER_DIR}) - # TODO: Verify that installation works correctly with prefix removed. - set(INSTALL_DIR ${_RAPIDS_LOGGER_HEADER_DIR}) - - set(LOGGER_OUTPUT_FILE ${BUILD_DIR}/logger.hpp) - configure_file(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/logger.hpp.in ${LOGGER_OUTPUT_FILE}) - install(FILES ${LOGGER_OUTPUT_FILE} DESTINATION ${INSTALL_DIR}) - - set(LOGGER_IMPL_OUTPUT_FILE ${BUILD_DIR}/logger_impl/logger_impl.hpp) - configure_file(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/logger_impl.hpp.in ${LOGGER_IMPL_OUTPUT_FILE}) - install(FILES ${LOGGER_IMPL_OUTPUT_FILE} DESTINATION ${INSTALL_DIR}/logger_impl) - - add_library(${_RAPIDS_LOGGER_TARGET} INTERFACE) - include(GNUInstallDirs) - # Note: The BUILD_INTERFACE setting assumes that LOGGER_HEADER_DIR is the subdirectory of - # CMAKE_INSTALL_INCLUDEDIR relative to which all includes are rooted in the C++ code files. I - # think that is a safe assumption though since if it were violated then the INSTALL_INTERFACE - # would not only be incorrect (if computed using LOGGER_HEADER_DIR), but it would also break - # consumers of the installed package who expect to be able to write `#include - # <${LOGGER_HEADER_DIR/include\//}/logger.hpp>` and have it work. - target_include_directories( - ${_RAPIDS_LOGGER_TARGET} - INTERFACE "$" - "$") - target_compile_features(${_RAPIDS_LOGGER_TARGET} INTERFACE cxx_std_17) - - # Create an interface target that will trigger compilation of the logger implementation in any - # target that is linked to it. - set(LOGGER_IMPL_SRC_OUTPUT_FILE ${BUILD_DIR}/logger_impl/logger.cpp) - configure_file(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/logger.cpp.in ${LOGGER_IMPL_SRC_OUTPUT_FILE}) - install(FILES ${LOGGER_IMPL_SRC_OUTPUT_FILE} DESTINATION ${INSTALL_DIR}/logger_impl) - - # Note that we cannot specify the source files directly in add_library, see the CMake - # documentation explaining that these do not populate INTERFACE_SOURCES. - # https://cmake.org/cmake/help/latest/command/add_library.html#interface-with-sources - set(impl_target ${_RAPIDS_LOGGER_TARGET}_impl) - add_library(${impl_target} INTERFACE) - target_sources( - ${impl_target} - INTERFACE $ - $) - target_link_libraries(${impl_target} INTERFACE ${_RAPIDS_LOGGER_TARGET} - spdlog::spdlog_header_only) - set_target_properties(${impl_target} PROPERTIES POSITION_INDEPENDENT_CODE ON - INTERFACE_POSITION_INDEPENDENT_CODE ON) - - set(_install_export) - if(_RAPIDS_EXPORT_SET) - set(_install_export EXPORT ${_RAPIDS_EXPORT_SET}) - endif() - - install(TARGETS ${_RAPIDS_LOGGER_TARGET} ${_install_export}) - if(TARGET ${impl_target}) - install(TARGETS ${impl_target} ${_install_export}) - endif() - -endfunction() diff --git a/rapids_logger/README.md b/rapids_logger/README.md deleted file mode 100644 index 00e505fc7..000000000 --- a/rapids_logger/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# About - -The `rapids-logger` project defines an easy way to produce a project-specific logger using the excellent [spdlog](https://github.com/gabime/spdlog) package. -The goal of this project is to ensure that projects wishing to provide their own logger may do so easily without needing to reimplement their own custom wrappers around spdlog. -A core goal of the project is to ensure that the custom logger implementation does not leak any spdlog symbols, allowing the safe coexistence of different projects in the same environment even if they use different versions of spdlog. -That goal is the primary reason to prefer using this project rather than directly exposing a specialized instance of a spdlog logger in your own project. - -`rapids-logger` is designed to be used via CMake. -Its CMake defines a function `rapids_make_logger` that can be used to produce a project-specific logger class in a provided namespace. -The resulting logger exposes spdlog-like functionality via the [PImpl idiom](https://en.cppreference.com/w/cpp/language/pimpl) to avoid exposing spdlog symbols publicly. -It uses CMake and template C++ files to generate a public header file to describe the user interface and an inline header that should be placed in a single TU by consumers to compile the implementation. -To simplify usage, each invocation of the function produces two CMake targets, one representing the public header and one representing a trivial source file including the inline header. -Projects using `rapids-logger` should make the first target part of their public link interface while the latter should be linked to privately so that it is compiled into the project's library without public exposure. - -To mirror spdlog, each generated logger also ships with a set of logging macros `_LOG_` that may be used to control logging at compile-time as well as runtime using a compile-time variable `_LOG_ACTIVE_LEVEL`. -For example, a project called "rapids" will be able to write code like this: -``` -RAPIDS_LOG_WARN("Some message to be shown when the warning level is enabled"); -``` -and control whether that warning is shown by compiling the code with `RAPIDS_LOG_ACTIVE_LEVEL=RAPIDS_LOG_LEVEL_WARN`. -Each project is endowed with its own definition of levels, so different projects in the same environment may be safely configured independently of each other and of spdlog. -Each project is also given a `default_logger` function that produces a global logger that may be used anywhere, but projects may also freely instantiate additional loggers as needed. diff --git a/rapids_logger/logger.cpp.in b/rapids_logger/logger.cpp.in deleted file mode 100644 index 36bb2ce02..000000000 --- a/rapids_logger/logger.cpp.in +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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. - */ - -#include "logger_impl.hpp" diff --git a/rapids_logger/logger.hpp.in b/rapids_logger/logger.hpp.in deleted file mode 100644 index cd2bb2c79..000000000 --- a/rapids_logger/logger.hpp.in +++ /dev/null @@ -1,504 +0,0 @@ -/* - * 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. - */ - -#pragma once - -#include -#include -#include -#include - -namespace __attribute__((visibility("default"))) @_RAPIDS_LOGGER_NAMESPACE@ { - -// These values must be kept in sync with spdlog! -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_TRACE 0 -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_DEBUG 1 -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_INFO 2 -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_WARN 3 -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_ERROR 4 -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_CRITICAL 5 -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_OFF 6 - -/** - * @brief The log levels supported by the logger. - * - * These levels correspond to the levels defined by spdlog. - */ -enum class level_enum : int32_t { - trace = @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_TRACE, - debug = @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_DEBUG, - info = @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_INFO, - warn = @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_WARN, - error = @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_ERROR, - critical = @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_CRITICAL, - off = @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_OFF, - n_levels -}; - -namespace detail { -// Forward declare the implementation classes. -class logger_impl; -class sink_impl; -} - -// Forward declare for the sink for the logger to use. -class sink; -using sink_ptr = std::shared_ptr; - -/** - * @class logger - * @brief A logger class that either uses the real implementation (via spdlog) or performs no-ops if - * not supported. - */ -class logger { - public: - logger() = delete; ///< Not default constructible - logger(logger const&) = delete; ///< Not copy constructible - logger& operator=(logger const&) = delete; ///< Not copy assignable - - logger(logger&& other); ///< @default_move_constructor - logger& operator=(logger&& other); ///< @default_move_assignment{logger} - - /** - * @brief A class to manage a vector of sinks. - * - * This class is used internally by the logger class to manage its sinks. It handles synchronization of the sinks with the sinks in the underlying spdlog logger such that all vector-like operations performed on this class are reflected in the underlying spdlog logger's set of sinks. - */ - class sink_vector { - public: - using Iterator = std::vector::iterator; ///< The iterator type - using ConstIterator = std::vector::const_iterator; ///< The const iterator type - - /** - * @brief Construct a new sink_vector object - * - * @param parent The logger whose sinks are being managed - * @param sinks The sinks to manage - */ - explicit sink_vector(logger& parent, std::vector sinks={}) : parent{parent}, sinks_{sinks} {} - - /** - * @brief Add a sink to the vector. - * - * @param sink The sink to add - */ - void push_back(sink_ptr const& sink); - - /** - * @brief Add a sink to the vector. - * - * @param sink The sink to add - */ - void push_back(sink_ptr&& sink); - - /** - * @brief Remove the last sink from the vector. - */ - void pop_back(); - - /** - * @brief Remove all sinks from the vector. - */ - void clear(); - - /** - * @brief Get an iterator to the beginning of the vector. - * - * @return Iterator The iterator - */ - Iterator begin() { return sinks_.begin(); } - - /** - * @brief Get an iterator to the end of the vector. - * - * @return Iterator The iterator - */ - Iterator end() { return sinks_.end(); } - - /** - * @brief Get a const iterator to the beginning of the vector. - * - * @return ConstIterator The const iterator - */ - ConstIterator begin() const { return sinks_.begin(); } - - /** - * @brief Get a const iterator to the end of the vector. - * - * @return ConstIterator The const iterator - */ - ConstIterator end() const { return sinks_.end(); } - - /** - * @brief Get a const iterator to the beginning of the vector. - * - * @return ConstIterator The const iterator - */ - ConstIterator cbegin() const { return sinks_.cbegin(); } - - /** - * @brief Get a const iterator to the end of the vector. - * - * @return ConstIterator The const iterator - */ - ConstIterator cend() const { return sinks_.cend(); } - private: - logger& parent; ///< The logger this vector belongs to - std::vector sinks_; ///< The sinks - }; - - // TODO: When we migrate to C++20 we can use std::format and format strings - // instead of the printf-style printing used here. - /** - * @brief Format and log a message at the specified level. - * - * This function performs printf-style formatting to avoid the need for fmt - * or spdlog's own templated APIs (which would require exposing spdlog - * symbols publicly) and then invokes the base implementation with the - * preformatted string. - * - * @param lvl The log level - * @param format The format string - * @param args The format arguments - */ - template - void log(level_enum lvl, std::string const& format, Args&&... args) { - auto convert_to_c_string = [](auto&& arg) -> decltype(auto) { - using ArgType = std::decay_t; - if constexpr (std::is_same_v) { - return arg.c_str(); - } else { - return std::forward(arg); - } - }; - - // NOLINTBEGIN(cppcoreguidelines-pro-type-vararg) - auto formatted_size = - std::snprintf(nullptr, 0, format.c_str(), convert_to_c_string(std::forward(args))...); - if (formatted_size < 0) { throw std::runtime_error("Error during formatting."); } - if (formatted_size == 0) { log(lvl, {}); } - auto size = static_cast(formatted_size) + 1; // for null terminator - // NOLINTNEXTLINE(modernize-avoid-c-arrays, cppcoreguidelines-avoid-c-arrays) - std::unique_ptr buf(new char[size]); - std::snprintf(buf.get(), size, format.c_str(), convert_to_c_string(std::forward(args))...); - // NOLINTEND(cppcoreguidelines-pro-type-vararg) - log(lvl, {buf.get(), buf.get() + size - 1}); // drop '\0' - }; - - /** - * @brief Log a message at the TRACE level. - * - * @param format The format string - * @param args The format arguments - */ - template - void trace(std::string const& format, Args&&... args) - { - log(level_enum::trace, format, std::forward(args)...); - } - - /** - * @brief Log a message at the DEBUG level. - * - * @param format The format string - * @param args The format arguments - */ - template - void debug(std::string const& format, Args&&... args) - { - log(level_enum::debug, format, std::forward(args)...); - } - - /** - * @brief Log a message at the INFO level. - * - * @param format The format string - * @param args The format arguments - */ - template - void info(std::string const& format, Args&&... args) - { - log(level_enum::info, format, std::forward(args)...); - } - - /** - * @brief Log a message at the WARN level. - * - * @param format The format string - * @param args The format arguments - */ - template - void warn(std::string const& format, Args&&... args) - { - log(level_enum::warn, format, std::forward(args)...); - } - - /** - * @brief Log a message at the ERROR level. - * - * @param format The format string - * @param args The format arguments - */ - template - void error(std::string const& format, Args&&... args) - { - log(level_enum::error, format, std::forward(args)...); - } - - /** - * @brief Log a message at the CRITICAL level. - * - * @param format The format string - * @param args The format arguments - */ - template - void critical(std::string const& format, Args&&... args) - { - log(level_enum::critical, format, std::forward(args)...); - } - - // Everything below here is conditionally compiled based on whether logging is supported. - /** - * @brief Construct a new logger object - * - * @param name The name of the logger - * @param filename The name of the log file - */ - logger(std::string name, std::string filename); - - /** - * @brief Construct a new logger object - * - * @param name The name of the logger - * @param stream The stream to log to - */ - logger(std::string name, std::ostream& stream); - - /** - * @brief Construct a new logger object - * - * @param name The name of the logger - * @param sinks The sinks to log to - * - * Note that we must use a vector because initializer_lists are not flexible - * enough to support programmatic construction in callers, and an - * iterator-based API would require templating and thus exposing spdlog - * types. - */ - logger(std::string name, std::vector sinks); - - /** - * @brief Destroy the logger object - */ - ~logger(); - - /** - * @brief Log a message at the specified level. - * - * This is the core logging routine that dispatches to spdlog. - * - * @param lvl The log level - * @param message The message to log - */ - void log(level_enum lvl, std::string const& message); - - /** - * @brief Get the sinks for the logger. - * - * @return The sinks - */ - const sink_vector& sinks() const; - - /** - * @brief Get the sinks for the logger. - * - * @return The sinks - */ - sink_vector& sinks(); - - /** - * @brief Get the current log level. - * - * @return The current log level - */ - level_enum level() const; - - /** - * @brief Set the log level. - * - * @param log_level The new log level - */ - void set_level(level_enum log_level); - - /** - * @brief Flush the logger. - */ - void flush(); - - /** - * @brief Flush all writes on the specified level or above. - */ - void flush_on(level_enum log_level); - - /** - * @brief Get the current flush level. - */ - level_enum flush_level() const; - - /** - * @brief Check if the logger should log a message at the specified level. - * - * @param msg_level The level of the message - * @return true if the message should be logged, false otherwise - */ - bool should_log(level_enum msg_level) const; - - /** - * @brief Set the pattern for the logger. - * - * @param pattern The pattern to use - */ - void set_pattern(std::string pattern); - - private: - std::unique_ptr impl; ///< The logger implementation - sink_vector sinks_; ///< The sinks for the logger -}; - -/** - * @brief A sink for the logger. - * - * These sinks are wrappers around the spdlog sinks that allow us to keep the - * spdlog types private and avoid exposing them in the public API. - */ -class sink { - public: - ~sink(); - protected: - explicit sink(std::unique_ptr impl); - std::unique_ptr impl; - // The sink vector needs to be able to pass the underlying sink to the spdlog logger. - friend class logger::sink_vector; -}; - -/** - * @brief A sink that writes to a file. - * - * See spdlog::sinks::basic_file_sink_mt for more information. - */ -class basic_file_sink_mt : public sink { - public: - basic_file_sink_mt(std::string const& filename, bool truncate = false); -}; - -/** - * @brief A sink that writes to an ostream. - * - * See spdlog::sinks::ostream_sink_mt for more information. - */ -class ostream_sink_mt : public sink { - public: - ostream_sink_mt(std::ostream& stream, bool force_flush = false); -}; - - -/** - * @brief Returns the default log filename for the global logger. - * - * If the environment variable `@_RAPIDS_LOGGER_NAMESPACE@_DEBUG_LOG_FILE` is defined, its value is used as the path and - * name of the log file. Otherwise, the file `@_RAPIDS_LOGGER_NAMESPACE@_log.txt` in the current working directory is used. - * - * @return std::string The default log file name. - */ -inline std::string default_log_filename() -{ - auto* filename = std::getenv("@_RAPIDS_LOGGER_MACRO_PREFIX@_DEBUG_LOG_FILE"); - // TODO: Do we prefer rmm's default (a file rmm_log.txt) or cudf's default (a - // stderr sink)? I think the latter is better. - return (filename == nullptr) ? std::string{"@_RAPIDS_LOGGER_NAMESPACE@_log.txt"} : std::string{filename}; -} - -/** - * @brief Get the default logger. - * - * @return logger& The default logger - */ -inline logger& default_logger() -{ - static logger logger_ = [] { - logger logger_ { - "@_RAPIDS_LOGGER_MACRO_PREFIX@", default_log_filename() - }; -#if @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL <= @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_INFO -#ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM - logger_.info("----- @_RAPIDS_LOGGER_MACRO_PREFIX@ LOG BEGIN [PTDS ENABLED] -----"); -#else - logger_.info("----- @_RAPIDS_LOGGER_MACRO_PREFIX@ LOG BEGIN [PTDS DISABLED] -----"); -#endif -#endif - return logger_; - }(); - return logger_; -} - -// Macros for easier logging, similar to spdlog. -#if !defined(@_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL) -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_INFO -#endif - -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOGGER_CALL(logger, level, ...) (logger).log(level, __VA_ARGS__) - -#if @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL <= @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_TRACE -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_TRACE(...) \ - @_RAPIDS_LOGGER_MACRO_PREFIX@_LOGGER_CALL(@_RAPIDS_LOGGER_NAMESPACE@::default_logger(), @_RAPIDS_LOGGER_NAMESPACE@::level_enum::trace, __VA_ARGS__) -#else -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_TRACE(...) (void)0 -#endif - -#if @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL <= @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_DEBUG -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_DEBUG(...) \ - @_RAPIDS_LOGGER_MACRO_PREFIX@_LOGGER_CALL(@_RAPIDS_LOGGER_NAMESPACE@::default_logger(), @_RAPIDS_LOGGER_NAMESPACE@::level_enum::debug, __VA_ARGS__) -#else -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_DEBUG(...) (void)0 -#endif - -#if @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL <= @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_INFO -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_INFO(...) @_RAPIDS_LOGGER_MACRO_PREFIX@_LOGGER_CALL(@_RAPIDS_LOGGER_NAMESPACE@::default_logger(), @_RAPIDS_LOGGER_NAMESPACE@::level_enum::info, __VA_ARGS__) -#else -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_INFO(...) (void)0 -#endif - -#if @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL <= @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_WARN -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_WARN(...) @_RAPIDS_LOGGER_MACRO_PREFIX@_LOGGER_CALL(@_RAPIDS_LOGGER_NAMESPACE@::default_logger(), @_RAPIDS_LOGGER_NAMESPACE@::level_enum::warn, __VA_ARGS__) -#else -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_WARN(...) (void)0 -#endif - -#if @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL <= @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_ERROR -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ERROR(...) \ - @_RAPIDS_LOGGER_MACRO_PREFIX@_LOGGER_CALL(@_RAPIDS_LOGGER_NAMESPACE@::default_logger(), @_RAPIDS_LOGGER_NAMESPACE@::level_enum::error, __VA_ARGS__) -#else -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ERROR(...) (void)0 -#endif - -#if @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_ACTIVE_LEVEL <= @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_LEVEL_CRITICAL -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_CRITICAL(...) \ - @_RAPIDS_LOGGER_MACRO_PREFIX@_LOGGER_CALL(@_RAPIDS_LOGGER_NAMESPACE@::default_logger(), @_RAPIDS_LOGGER_NAMESPACE@::level_enum::critical, __VA_ARGS__) -#else -#define @_RAPIDS_LOGGER_MACRO_PREFIX@_LOG_CRITICAL(...) (void)0 -#endif - -} // namespace @_RAPIDS_LOGGER_NAMESPACE@ diff --git a/rapids_logger/logger_impl.hpp.in b/rapids_logger/logger_impl.hpp.in deleted file mode 100644 index d5b467571..000000000 --- a/rapids_logger/logger_impl.hpp.in +++ /dev/null @@ -1,211 +0,0 @@ -/* - * 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. - */ - -#pragma once - -#include "../logger.hpp" - -// Include C headers for which we need symbols to be made public and don't want -// the below symbol hiding pattern to apply. -#include -#include -#include - -// Start hiding before including spdlog headers. -#pragma GCC visibility push(hidden) -// This issue claims to have been resolved in gcc 8, but we still seem to encounter it here. -// The code compiles and links and all tests pass, and nm shows symbols resolved as expected. -// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80947 -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wattributes" - -#include -#include -#include -#pragma GCC diagnostic pop - -#include -#include -#include - -namespace @_RAPIDS_LOGGER_NAMESPACE@ { - -namespace detail { -namespace { - -/** - * @brief Convert a string to a log level. - * - * This function is used to process env-var specifications of log levels. - * @param env_lvl_str The string to convert. - * @return The log level. - */ -level_enum string_to_level(std::string_view const env_lvl_str) -{ - if (env_lvl_str == "TRACE") return level_enum::trace; - if (env_lvl_str == "DEBUG") return level_enum::debug; - if (env_lvl_str == "INFO") return level_enum::info; - if (env_lvl_str == "WARN") return level_enum::warn; - if (env_lvl_str == "ERROR") return level_enum::error; - if (env_lvl_str == "CRITICAL") return level_enum::critical; - if (env_lvl_str == "OFF") return level_enum::off; - std::ostringstream os{}; - os << "Invalid logging level: " << env_lvl_str; - throw std::invalid_argument(os.str()); -} - -/** - * @brief Convert a log level to an spdlog log level. - * - * @param lvl The log level to convert. - * @return The spdlog log level. - */ -spdlog::level::level_enum to_spdlog_level(level_enum lvl) -{ - return static_cast(static_cast(lvl)); -} - -/** - * @brief Convert an spdlog log level to a log level. - * - * @param lvl The spdlog log level to convert. - * @return The log level. - */ -level_enum from_spdlog_level(spdlog::level::level_enum lvl) -{ - return static_cast(static_cast(lvl)); -} -} - -/** - * @brief The sink_impl class is a wrapper around an spdlog sink. - * - * This class is the impl part of the PImpl for the sink. - */ -class sink_impl { -public: - sink_impl(std::shared_ptr sink) : underlying{sink} {} -private: - std::shared_ptr underlying; - // The sink_vector needs to be able to pass the underlying sink to the spdlog logger. - friend class logger::sink_vector; -}; - -/** - * @brief The logger_impl class is a wrapper around an spdlog logger. - * - * This class is the impl part of the PImpl for the logger. - */ -class logger_impl { - public: - logger_impl(std::string name) : underlying{spdlog::logger{name}} { - underlying.set_pattern("[%6t][%H:%M:%S:%f][%-6l] %v"); - auto const env_logging_level = - std::getenv("@_RAPIDS_LOGGER_MACRO_PREFIX@_DEFAULT_LOGGING_LEVEL"); - if (env_logging_level != nullptr) { set_level(detail::string_to_level(env_logging_level)); } - auto const env_flush_level = std::getenv("@_RAPIDS_LOGGER_MACRO_PREFIX@_DEFAULT_FLUSH_LEVEL"); - if (env_flush_level != nullptr) { flush_on(detail::string_to_level(env_flush_level)); } - } - - void log(level_enum lvl, std::string const& message) { underlying.log(to_spdlog_level(lvl), message); } - void set_level(level_enum log_level) { underlying.set_level(to_spdlog_level(log_level)); } - void flush() { underlying.flush(); } - void flush_on(level_enum log_level) { underlying.flush_on(to_spdlog_level(log_level)); } - level_enum flush_level() const { return from_spdlog_level(underlying.flush_level()); } - bool should_log(level_enum lvl) const { return underlying.should_log(to_spdlog_level(lvl)); } - level_enum level() const { return from_spdlog_level(underlying.level()); } - void set_pattern(std::string pattern) { underlying.set_pattern(pattern); } - const std::vector &sinks() const { return underlying.sinks(); } - std::vector &sinks() { return underlying.sinks(); } - -private: - spdlog::logger underlying; ///< The spdlog logger -}; - -} // namespace detail - -// Sink vector functions -void logger::sink_vector::push_back(sink_ptr const& sink) { - sinks_.push_back(sink); - parent.impl->sinks().push_back(sink->impl->underlying); -} -void logger::sink_vector::push_back(sink_ptr&& sink) { - sinks_.push_back(sink); - parent.impl->sinks().push_back(sink->impl->underlying); -} -void logger::sink_vector::pop_back() { - sinks_.pop_back(); - parent.impl->sinks().pop_back(); -} -void logger::sink_vector::clear() { - sinks_.clear(); - parent.impl->sinks().clear(); -} - -// Sink methods -sink::sink(std::unique_ptr impl) : impl{std::move(impl)} {} - -sink::~sink() = default; - -basic_file_sink_mt::basic_file_sink_mt(std::string const& filename, bool truncate) - : sink{std::make_unique(std::make_shared(filename, truncate))} {} - -ostream_sink_mt::ostream_sink_mt(std::ostream& stream, bool force_flush) - : sink{std::make_unique(std::make_shared(stream, force_flush))} {} - -// Logger methods -logger::logger(std::string name, std::string filename) - : impl{std::make_unique(name)}, sinks_{*this} { - sinks_.push_back(std::make_shared(filename, true)); -} - -logger::logger(std::string name, std::ostream& stream) - : impl{std::make_unique(name)}, sinks_{*this} { - sinks_.push_back(std::make_shared(stream)); -} - -logger::logger(std::string name, std::vector sinks) - : impl{std::make_unique(name)}, sinks_{*this} { - for (auto const& s : sinks) { - sinks_.push_back(s); - } -} - -logger::~logger() = default; -logger::logger(logger&& other) = default; -logger& logger::operator=(logger&& other) { - impl = std::move(other.impl); - sinks_.clear(); - for (auto const& s : other.sinks_) { - sinks_.push_back(s); - } - return *this; -} - -void logger::log(level_enum lvl, std::string const& message) { impl->log(lvl, message); } -void logger::set_level(level_enum log_level) { impl->set_level(log_level); } -void logger::flush() { impl->flush(); } -void logger::flush_on(level_enum log_level) { impl->flush_on(log_level); } -level_enum logger::flush_level() const { return impl->flush_level(); } -bool logger::should_log(level_enum lvl) const { return impl->should_log(lvl); } -level_enum logger::level() const { return impl->level(); } -void logger::set_pattern(std::string pattern) { impl->set_pattern(pattern); } -const logger::sink_vector& logger::sinks() const { return sinks_; } -logger::sink_vector& logger::sinks() { return sinks_; } - -} // namespace @_RAPIDS_LOGGER_NAMESPACE@ -// This visibility pragma must be here so that both our logger types and those coming from includes are hidden. -#pragma GCC visibility pop From 0a8e9208b305022d4c838b07d50e29df87dd1dfb Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Thu, 2 Jan 2025 20:35:03 -0800 Subject: [PATCH 529/675] Check if nightlies have succeeded recently enough (#1772) Contributes to https://github.com/rapidsai/build-planning/issues/127 This PR cannot be merged unless nightly CI has passed within the past 7 days, so if it remains unmerged that will itself be an indication that nightly CI needs fixing. Authors: - Vyas Ramasubramani (https://github.com/vyasr) - Bradley Dice (https://github.com/bdice) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1772 --- .github/workflows/pr.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index e71c8cf64..29c9ae6e5 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -12,6 +12,7 @@ concurrency: jobs: pr-builder: needs: + - check-nightly-ci - changed-files - checks - conda-cpp-build @@ -40,6 +41,18 @@ jobs: # since other jobs depend on it. if: ${{ vars.TELEMETRY_ENABLED == 'true' }} uses: rapidsai/shared-actions/telemetry-dispatch-stash-base-env-vars@main + check-nightly-ci: + # Switch to ubuntu-latest once it defaults to a version of Ubuntu that + # provides at least Python 3.11 (see + # https://docs.python.org/3/library/datetime.html#datetime.date.fromisoformat) + runs-on: ubuntu-24.04 + env: + RAPIDS_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Check if nightly CI is passing + uses: rapidsai/shared-actions/check_nightly_success/dispatch@main + with: + repo: rmm changed-files: needs: - telemetry-setup From b4c43c5fd03cf93fd935343a4e8b2ccfa763afdb Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 3 Jan 2025 09:39:14 -0800 Subject: [PATCH 530/675] Use rapids-cmake for the logger (#1776) This PR switches rmm to use rapids-cmake to fetch rapids-logger so that it uses a consistent version with the rest of RAPIDS to avoid any cases where transitive CPM loads result in multiple packages being built from source that require a different version of rapids-logger. Depends on https://github.com/rapidsai/rapids-cmake/pull/737 Contributes to rapidsai/build-planning#104. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1776 --- CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d281d047e..859e4022e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,9 +73,8 @@ rapids_find_package( # add third party dependencies using CPM rapids_cpm_init() -CPMAddPackage( - NAME rapids_logger GITHUB_REPOSITORY rapidsai/rapids-logger GIT_SHALLOW FALSE GIT_TAG - 1043e0f3989d75ad52f5212544b8154777e86fc9 VERSION 1043e0f3989d75ad52f5212544b8154777e86fc9) +include(${rapids-cmake-dir}/cpm/rapids_logger.cmake) +rapids_cpm_rapids_logger() rapids_make_logger(rmm EXPORT_SET rmm-exports) include(cmake/thirdparty/get_cccl.cmake) From d70bd4be2ebe1804313e2bb680fe89c102d72cb7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 7 Jan 2025 20:38:10 +0000 Subject: [PATCH 531/675] [pre-commit.ci] pre-commit autoupdate (#1778) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.2 → v0.8.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.2...v0.8.6) - [github.com/pre-commit/mirrors-clang-format: v16.0.6 → v19.1.6](https://github.com/pre-commit/mirrors-clang-format/compare/v16.0.6...v19.1.6) - [github.com/rapidsai/dependency-file-generator: v1.16.0 → v1.17.0](https://github.com/rapidsai/dependency-file-generator/compare/v1.16.0...v1.17.0) Authors: - https://github.com/apps/pre-commit-ci - Bradley Dice (https://github.com/bdice) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1778 --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 647bf76c3..85e30844a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.2 + rev: v0.8.6 hooks: - id: ruff args: ["--fix"] @@ -82,7 +82,7 @@ repos: - id: verify-copyright - id: verify-alpha-spec - repo: https://github.com/rapidsai/dependency-file-generator - rev: v1.16.0 + rev: v1.17.0 hooks: - id: rapids-dependency-file-generator args: ["--clean"] From c1ccdadb7f3b2677fb3f0419342fb9946bfc5d08 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Wed, 8 Jan 2025 15:22:22 -0800 Subject: [PATCH 532/675] Add spdlog back as a requirement for now (#1780) See discussion in https://github.com/rapidsai/rapids-logger/issues/10#issuecomment-2578787497 and https://github.com/rapidsai/rmm/issues/1779. spdlog will remain a requirement for 25.02, but we will remove it in favor of a precompiled rapids-logger library in 25.04 (and that library will completely hide everything related to spdlog: APIs, package requirements, symbols, etc). Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1780 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 1 + conda/environments/all_cuda-125_arch-x86_64.yaml | 1 + conda/recipes/librmm/meta.yaml | 11 +++-------- dependencies.yaml | 1 + 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index b885e77cf..3dde94a78 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -35,6 +35,7 @@ dependencies: - python>=3.10,<3.13 - rapids-build-backend>=0.3.0,<0.4.0.dev0 - scikit-build-core >=0.10.0 +- spdlog>=1.14.1,<1.15 - sphinx - sphinx-copybutton - sphinx-markdown-tables diff --git a/conda/environments/all_cuda-125_arch-x86_64.yaml b/conda/environments/all_cuda-125_arch-x86_64.yaml index 0d0659215..5d702c681 100644 --- a/conda/environments/all_cuda-125_arch-x86_64.yaml +++ b/conda/environments/all_cuda-125_arch-x86_64.yaml @@ -34,6 +34,7 @@ dependencies: - python>=3.10,<3.13 - rapids-build-backend>=0.3.0,<0.4.0.dev0 - scikit-build-core >=0.10.0 +- spdlog>=1.14.1,<1.15 - sphinx - sphinx-copybutton - sphinx-markdown-tables diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 31aaf0e63..ab2cfcc88 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2018-2024, NVIDIA CORPORATION. +# Copyright (c) 2018-2025, NVIDIA CORPORATION. {% set version = environ['RAPIDS_PACKAGE_VERSION'].lstrip('v') %} {% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} @@ -26,13 +26,8 @@ requirements: - {{ stdlib("c") }} host: - cuda-version ={{ cuda_version }} - # We need fmt here for now because the conda spdlog package is hard-coded - # to use fmt as a compiled library, not header-only, so we must ensure that - # the library is present for now so that if a downstream library tries to - # build against rmm and some other package in its build environment uses - # fmt (or spdlog) that the default rmm build is consistent with such - # environments. - fmt {{ fmt_version }} + - spdlog {{ spdlog_version }} build: script_env: @@ -77,8 +72,8 @@ outputs: {% if cuda_major == "11" %} - cudatoolkit {% endif %} - # See comment about fmt in the build section above. - fmt {{ fmt_version }} + - spdlog {{ spdlog_version }} test: commands: - test -d "${PREFIX}/include/rmm" diff --git a/dependencies.yaml b/dependencies.yaml index 7f94f3f6e..7c4e64a46 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -112,6 +112,7 @@ dependencies: - c-compiler - cxx-compiler - fmt>=11.0.2,<12 + - spdlog>=1.14.1,<1.15 specific: - output_types: conda matrices: From fb5e6bc9d0d0758572a5ba5cd7443bdee1eb79da Mon Sep 17 00:00:00 2001 From: Matthew Murray <41342305+Matt711@users.noreply.github.com> Date: Thu, 16 Jan 2025 17:57:14 -0500 Subject: [PATCH 533/675] Make the stream module a part of the public API (#1775) Closes #1770. Authors: - Matthew Murray (https://github.com/Matt711) - Bradley Dice (https://github.com/bdice) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1775 --- python/rmm/docs/guide.md | 2 +- python/rmm/rmm/_cuda/CMakeLists.txt | 3 +- python/rmm/rmm/_cuda/stream.pxd | 22 ++---------- python/rmm/rmm/_cuda/stream.py | 35 +++++++++++++++++++ python/rmm/rmm/allocators/cupy.py | 4 +-- python/rmm/rmm/pylibrmm/CMakeLists.txt | 5 +-- python/rmm/rmm/pylibrmm/device_buffer.pxd | 4 +-- python/rmm/rmm/pylibrmm/device_buffer.pyx | 6 ++-- python/rmm/rmm/pylibrmm/memory_resource.pyx | 6 ++-- python/rmm/rmm/pylibrmm/stream.pxd | 33 +++++++++++++++++ python/rmm/rmm/{_cuda => pylibrmm}/stream.pyx | 0 python/rmm/rmm/tests/test_rmm.py | 12 +++---- 12 files changed, 91 insertions(+), 41 deletions(-) create mode 100644 python/rmm/rmm/_cuda/stream.py create mode 100644 python/rmm/rmm/pylibrmm/stream.pxd rename python/rmm/rmm/{_cuda => pylibrmm}/stream.pyx (100%) diff --git a/python/rmm/docs/guide.md b/python/rmm/docs/guide.md index c7e940497..4b9d305ab 100644 --- a/python/rmm/docs/guide.md +++ b/python/rmm/docs/guide.md @@ -93,7 +93,7 @@ destination device ID and stream are optional parameters. ```python >>> import rmm >>> rmm.reinitialize(managed_memory=True) ->>> from rmm._cuda.stream import Stream +>>> from rmm.pylibrmm.stream import Stream >>> stream = Stream() >>> buf = rmm.DeviceBuffer(size=100, stream=stream) >>> buf.prefetch(device=3, stream=stream) # prefetch to device on stream. diff --git a/python/rmm/rmm/_cuda/CMakeLists.txt b/python/rmm/rmm/_cuda/CMakeLists.txt index 7759432d3..1617ead7f 100644 --- a/python/rmm/rmm/_cuda/CMakeLists.txt +++ b/python/rmm/rmm/_cuda/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2022-2024, NVIDIA CORPORATION. +# Copyright (c) 2022-2025, 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 @@ -12,7 +12,6 @@ # the License. # ============================================================================= -set(cython_sources stream.pyx) set(linked_libraries rmm::rmm cpp_logger) rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}" diff --git a/python/rmm/rmm/_cuda/stream.pxd b/python/rmm/rmm/_cuda/stream.pxd index 219b75864..026830162 100644 --- a/python/rmm/rmm/_cuda/stream.pxd +++ b/python/rmm/rmm/_cuda/stream.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2024, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,22 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cuda.bindings.cyruntime cimport cudaStream_t -from libc.stdint cimport uintptr_t -from libcpp cimport bool - -from rmm.librmm.cuda_stream_view cimport cuda_stream_view - - -cdef class Stream: - cdef cudaStream_t _cuda_stream - cdef object _owner - - @staticmethod - cdef Stream _from_cudaStream_t(cudaStream_t s, object owner=*) - - cdef cuda_stream_view view(self) except * nogil - cdef void c_synchronize(self) except * nogil - cdef bool c_is_default(self) except * nogil - cdef void _init_with_new_cuda_stream(self) except * - cdef void _init_from_stream(self, Stream stream) except * +from rmm.pylibrmm.stream cimport Stream diff --git a/python/rmm/rmm/_cuda/stream.py b/python/rmm/rmm/_cuda/stream.py new file mode 100644 index 000000000..f912b9ae6 --- /dev/null +++ b/python/rmm/rmm/_cuda/stream.py @@ -0,0 +1,35 @@ +# Copyright (c) 2025, 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. + +import warnings + +from rmm.pylibrmm.stream import ( + DEFAULT_STREAM, + LEGACY_DEFAULT_STREAM, + PER_THREAD_DEFAULT_STREAM, + Stream, +) + +__all__ = [ + "DEFAULT_STREAM", + "LEGACY_DEFAULT_STREAM", + "PER_THREAD_DEFAULT_STREAM", + "Stream", +] + +warnings.warn( + "The `rmm._cuda.stream` module is deprecated in 25.02 and will be removed in a future release. Use `rmm.pylibrmm.stream` instead.", + FutureWarning, + stacklevel=2, +) diff --git a/python/rmm/rmm/allocators/cupy.py b/python/rmm/rmm/allocators/cupy.py index 780ff2abf..47210e8d6 100644 --- a/python/rmm/rmm/allocators/cupy.py +++ b/python/rmm/rmm/allocators/cupy.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023-2024, NVIDIA CORPORATION. +# Copyright (c) 2023-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. from rmm import pylibrmm -from rmm._cuda.stream import Stream +from rmm.pylibrmm.stream import Stream try: import cupy diff --git a/python/rmm/rmm/pylibrmm/CMakeLists.txt b/python/rmm/rmm/pylibrmm/CMakeLists.txt index 0012cb93d..1be58c32e 100644 --- a/python/rmm/rmm/pylibrmm/CMakeLists.txt +++ b/python/rmm/rmm/pylibrmm/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2022-2024, NVIDIA CORPORATION. +# Copyright (c) 2022-2025, 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 @@ -12,7 +12,8 @@ # the License. # ============================================================================= -set(cython_sources device_buffer.pyx logger.pyx memory_resource.pyx cuda_stream.pyx helper.pyx) +set(cython_sources device_buffer.pyx logger.pyx memory_resource.pyx cuda_stream.pyx helper.pyx + stream.pyx) set(linked_libraries rmm::rmm cpp_logger) # Build all of the Cython targets diff --git a/python/rmm/rmm/pylibrmm/device_buffer.pxd b/python/rmm/rmm/pylibrmm/device_buffer.pxd index a0d287423..295c2494e 100644 --- a/python/rmm/rmm/pylibrmm/device_buffer.pxd +++ b/python/rmm/rmm/pylibrmm/device_buffer.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2024, NVIDIA CORPORATION. +# Copyright (c) 2019-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,9 +15,9 @@ from libc.stdint cimport uintptr_t from libcpp.memory cimport unique_ptr -from rmm._cuda.stream cimport Stream from rmm.librmm.device_buffer cimport device_buffer from rmm.pylibrmm.memory_resource cimport DeviceMemoryResource +from rmm.pylibrmm.stream cimport Stream cdef class DeviceBuffer: diff --git a/python/rmm/rmm/pylibrmm/device_buffer.pyx b/python/rmm/rmm/pylibrmm/device_buffer.pyx index 9343d77c1..0d6825ed8 100644 --- a/python/rmm/rmm/pylibrmm/device_buffer.pyx +++ b/python/rmm/rmm/pylibrmm/device_buffer.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2024, NVIDIA CORPORATION. +# Copyright (c) 2019-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,9 +19,9 @@ from libc.stdint cimport uintptr_t from libcpp.memory cimport unique_ptr from libcpp.utility cimport move -from rmm._cuda.stream cimport Stream +from rmm.pylibrmm.stream cimport Stream -from rmm._cuda.stream import DEFAULT_STREAM +from rmm.pylibrmm.stream import DEFAULT_STREAM from cuda.bindings.cyruntime cimport ( cudaError, diff --git a/python/rmm/rmm/pylibrmm/memory_resource.pyx b/python/rmm/rmm/pylibrmm/memory_resource.pyx index ca9ee01ac..0189a58b5 100644 --- a/python/rmm/rmm/pylibrmm/memory_resource.pyx +++ b/python/rmm/rmm/pylibrmm/memory_resource.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2024, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,9 +32,9 @@ from cuda.bindings.runtime import cudaError_t from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice -from rmm._cuda.stream cimport Stream +from rmm.pylibrmm.stream cimport Stream -from rmm._cuda.stream import DEFAULT_STREAM +from rmm.pylibrmm.stream import DEFAULT_STREAM from rmm.librmm.cuda_stream_view cimport cuda_stream_view from rmm.librmm.per_device_resource cimport ( diff --git a/python/rmm/rmm/pylibrmm/stream.pxd b/python/rmm/rmm/pylibrmm/stream.pxd new file mode 100644 index 000000000..219b75864 --- /dev/null +++ b/python/rmm/rmm/pylibrmm/stream.pxd @@ -0,0 +1,33 @@ +# Copyright (c) 2020-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. + +from cuda.bindings.cyruntime cimport cudaStream_t +from libc.stdint cimport uintptr_t +from libcpp cimport bool + +from rmm.librmm.cuda_stream_view cimport cuda_stream_view + + +cdef class Stream: + cdef cudaStream_t _cuda_stream + cdef object _owner + + @staticmethod + cdef Stream _from_cudaStream_t(cudaStream_t s, object owner=*) + + cdef cuda_stream_view view(self) except * nogil + cdef void c_synchronize(self) except * nogil + cdef bool c_is_default(self) except * nogil + cdef void _init_with_new_cuda_stream(self) except * + cdef void _init_from_stream(self, Stream stream) except * diff --git a/python/rmm/rmm/_cuda/stream.pyx b/python/rmm/rmm/pylibrmm/stream.pyx similarity index 100% rename from python/rmm/rmm/_cuda/stream.pyx rename to python/rmm/rmm/pylibrmm/stream.pyx diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index de363e4b4..ee02d5d0e 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2024, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,10 +26,10 @@ from numba import cuda import rmm -import rmm._cuda.stream from rmm.allocators.cupy import rmm_cupy_allocator from rmm.allocators.numba import RMMNumbaManager from rmm.pylibrmm.logger import level_enum +from rmm.pylibrmm.stream import Stream cuda.set_memory_manager(RMMNumbaManager) @@ -348,8 +348,8 @@ def test_rmm_device_buffer_prefetch(pool, managed): def test_rmm_pool_numba_stream(stream): rmm.reinitialize(pool_allocator=True) - stream = rmm._cuda.stream.Stream(stream) - a = rmm.pylibrmm.device_buffer.DeviceBuffer(size=3, stream=stream) + stream = Stream(stream) + a = rmm.DeviceBuffer(size=3, stream=stream) assert a.size == 3 assert a.ptr != 0 @@ -600,7 +600,7 @@ def test_mr_devicebuffer_lifetime(): ) # Creates a new non-default stream - stream = rmm._cuda.stream.Stream() + stream = rmm.pylibrmm.stream.Stream() # Allocate DeviceBuffer with Pool and Stream a = rmm.DeviceBuffer(size=10, stream=stream) @@ -695,7 +695,7 @@ def test_cuda_async_memory_resource_stream(nelems): # with a non-default stream works mr = rmm.mr.CudaAsyncMemoryResource() rmm.mr.set_current_device_resource(mr) - stream = rmm._cuda.stream.Stream() + stream = Stream() expected = np.full(nelems, 5, dtype="u1") dbuf = rmm.DeviceBuffer.to_device(expected, stream=stream) result = np.asarray(dbuf.copy_to_host()) From d750a6e8578a4e61159faae59baeb4470e2ed81f Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 17 Jan 2025 14:14:00 -0600 Subject: [PATCH 534/675] Use GCC 13 in CUDA 12 conda builds. (#1773) conda-forge is using GCC 13 for CUDA 12 builds. This PR updates CUDA 12 conda builds to use GCC 13, for alignment. These PRs should be merged in a specific order, see https://github.com/rapidsai/build-planning/issues/129 for details. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1773 --- .../all_cuda-118_arch-x86_64.yaml | 2 +- .../all_cuda-125_arch-x86_64.yaml | 4 ++-- conda/recipes/librmm/conda_build_config.yaml | 21 ++++++++++--------- conda/recipes/librmm/meta.yaml | 10 ++------- conda/recipes/rmm/conda_build_config.yaml | 15 ++++++------- conda/recipes/rmm/meta.yaml | 8 +++---- dependencies.yaml | 18 ++++++++++++++-- 7 files changed, 43 insertions(+), 35 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 3dde94a78..45cdc5d85 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -40,5 +40,5 @@ dependencies: - sphinx-copybutton - sphinx-markdown-tables - sphinx_rtd_theme -- sysroot_linux-64==2.17 +- sysroot_linux-64==2.28 name: all_cuda-118_arch-x86_64 diff --git a/conda/environments/all_cuda-125_arch-x86_64.yaml b/conda/environments/all_cuda-125_arch-x86_64.yaml index 5d702c681..cef9757b9 100644 --- a/conda/environments/all_cuda-125_arch-x86_64.yaml +++ b/conda/environments/all_cuda-125_arch-x86_64.yaml @@ -17,7 +17,7 @@ dependencies: - cython>=3.0.0 - doxygen=1.9.1 - fmt>=11.0.2,<12 -- gcc_linux-64=11.* +- gcc_linux-64=13.* - gcovr>=5.0 - graphviz - identify>=2.5.20 @@ -39,5 +39,5 @@ dependencies: - sphinx-copybutton - sphinx-markdown-tables - sphinx_rtd_theme -- sysroot_linux-64==2.17 +- sysroot_linux-64==2.28 name: all_cuda-125_arch-x86_64 diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index b4791745f..2980a8d5c 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -1,14 +1,20 @@ c_compiler_version: - - 11 + - 13 # [not os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] + - 11 # [os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] cxx_compiler_version: - - 11 + - 13 # [not os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] + - 11 # [os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] cuda_compiler: - - cuda-nvcc + - cuda-nvcc # [not os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] + - nvcc # [os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] -cuda11_compiler: - - nvcc +c_stdlib: + - sysroot + +c_stdlib_version: + - "2.28" cmake_version: - ">=3.26.4,!=3.30.0" @@ -18,8 +24,3 @@ fmt_version: spdlog_version: - ">=1.14.1,<1.15" - -c_stdlib: - - sysroot -c_stdlib_version: - - "2.17" diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index ab2cfcc88..22f53cdc6 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -18,7 +18,7 @@ requirements: - {{ compiler('c') }} - {{ compiler('cxx') }} {% if cuda_major == "11" %} - - {{ compiler('cuda11') }} {{ cuda_version }} + - {{ compiler('cuda') }} {{ cuda_version }} {% else %} - {{ compiler('cuda') }} {% endif %} @@ -57,11 +57,7 @@ outputs: run_exports: - {{ pin_subpackage("librmm", max_pin="x.x") }} ignore_run_exports_from: - {% if cuda_major == "11" %} - - {{ compiler('cuda11') }} - {% else %} - {{ compiler('cuda') }} - {% endif %} requirements: build: - cmake {{ cmake_version }} @@ -88,10 +84,8 @@ outputs: number: {{ GIT_DESCRIBE_NUMBER }} string: cuda{{ cuda_major }}_{{ date_string }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} ignore_run_exports_from: - {% if cuda_major == "11" %} - - {{ compiler('cuda11') }} - {% else %} - {{ compiler('cuda') }} + {% if cuda_major != "11" %} - cuda-cudart-dev {% endif %} requirements: diff --git a/conda/recipes/rmm/conda_build_config.yaml b/conda/recipes/rmm/conda_build_config.yaml index 68947bade..83f5ebcb1 100644 --- a/conda/recipes/rmm/conda_build_config.yaml +++ b/conda/recipes/rmm/conda_build_config.yaml @@ -1,19 +1,20 @@ c_compiler_version: - - 11 + - 13 # [not os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] + - 11 # [os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] cxx_compiler_version: - - 11 + - 13 # [not os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] + - 11 # [os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] cuda_compiler: - - cuda-nvcc - -cuda11_compiler: - - nvcc + - cuda-nvcc # [not os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] + - nvcc # [os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] c_stdlib: - sysroot + c_stdlib_version: - - "2.17" + - "2.28" cmake_version: - ">=3.26.4,!=3.30.0" diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 206a80c46..03d5cd758 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2024, NVIDIA CORPORATION. +# Copyright (c) 2019-2025, NVIDIA CORPORATION. {% set version = environ['RAPIDS_PACKAGE_VERSION'].strip().lstrip('v') %} {% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} @@ -32,10 +32,8 @@ build: - SCCACHE_S3_USE_SSL - SCCACHE_S3_NO_CREDENTIALS ignore_run_exports_from: - {% if cuda_major == "11" %} - - {{ compiler('cuda11') }} - {% else %} - {{ compiler('cuda') }} + {% if cuda_major != "11" %} - cuda-cudart-dev {% endif %} - cuda-python @@ -47,7 +45,7 @@ requirements: - {{ compiler('c') }} - {{ compiler('cxx') }} {% if cuda_major == "11" %} - - {{ compiler('cuda11') }} {{ cuda_version }} + - {{ compiler('cuda') }} {{ cuda_version }} {% else %} - {{ compiler('cuda') }} {% endif %} diff --git a/dependencies.yaml b/dependencies.yaml index 7c4e64a46..994af5126 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -118,14 +118,28 @@ dependencies: matrices: - matrix: arch: x86_64 + cuda: "11.*" packages: - gcc_linux-64=11.* - - sysroot_linux-64==2.17 + - &sysroot_x86_64 sysroot_linux-64==2.28 + - matrix: + arch: x86_64 + cuda: "12.*" + packages: + - gcc_linux-64=13.* + - *sysroot_x86_64 - matrix: arch: aarch64 + cuda: "11.*" packages: - gcc_linux-aarch64=11.* - - sysroot_linux-aarch64==2.17 + - &sysroot_aarch64 sysroot_linux-aarch64==2.28 + - matrix: + arch: aarch64 + cuda: "12.*" + packages: + - gcc_linux-aarch64=13.* + - *sysroot_aarch64 - output_types: conda matrices: - matrix: From 67fd94d0b821a66de335fe0fc59109b908cc7f74 Mon Sep 17 00:00:00 2001 From: GALI PREM SAGAR Date: Wed, 22 Jan 2025 10:12:45 -0600 Subject: [PATCH 535/675] Add upper bound to prevent usage of numba 0.61.0 (#1789) Numba 0.61.0 just got released with a couple of breaking changes, this pr is required to unblock the ci. xref: https://github.com/rapidsai/cudf/pull/17777 Authors: - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1789 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-125_arch-x86_64.yaml | 2 +- conda/recipes/rmm/meta.yaml | 2 +- dependencies.yaml | 4 ++-- python/rmm/pyproject.toml | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 45cdc5d85..daba1b604 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -25,7 +25,7 @@ dependencies: - make - nbsphinx - ninja -- numba>=0.57 +- numba>=0.59.1,<0.61.0a0 - numpy>=1.23,<3.0a0 - numpydoc - nvcc_linux-64=11.8 diff --git a/conda/environments/all_cuda-125_arch-x86_64.yaml b/conda/environments/all_cuda-125_arch-x86_64.yaml index cef9757b9..eae1076fc 100644 --- a/conda/environments/all_cuda-125_arch-x86_64.yaml +++ b/conda/environments/all_cuda-125_arch-x86_64.yaml @@ -25,7 +25,7 @@ dependencies: - make - nbsphinx - ninja -- numba>=0.57 +- numba>=0.59.1,<0.61.0a0 - numpy>=1.23,<3.0a0 - numpydoc - pre-commit diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml index 03d5cd758..58c606c1f 100644 --- a/conda/recipes/rmm/meta.yaml +++ b/conda/recipes/rmm/meta.yaml @@ -74,7 +74,7 @@ requirements: - cuda-python >=12.6.2,<13.0a0 {% endif %} - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - - numba >=0.57 + - numba >=0.59.1,<0.61.0a0 - numpy >=1.23,<3.0a0 - python diff --git a/dependencies.yaml b/dependencies.yaml index 994af5126..972f20f6c 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -309,7 +309,7 @@ dependencies: common: - output_types: [conda, requirements, pyproject] packages: - - numba>=0.57 + - numba>=0.59.1,<0.61.0a0 - pytest - pytest-cov specific: @@ -330,7 +330,7 @@ dependencies: - matrix: dependencies: "oldest" packages: - - numba==0.57.* + - numba==0.59.1 - numpy==1.23.* - matrix: packages: diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 87795974f..73de5d839 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024, NVIDIA CORPORATION. +# Copyright (c) 2021-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ classifiers = [ [project.optional-dependencies] test = [ - "numba>=0.57", + "numba>=0.59.1,<0.61.0a0", "pytest", "pytest-cov", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. From c0bdd33e0b4b3c07d6990e2a8ae734a809444c21 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Thu, 23 Jan 2025 15:03:08 -0500 Subject: [PATCH 536/675] DOC v25.04 Updates [skip ci] --- .../cuda11.8-conda/devcontainer.json | 6 ++--- .devcontainer/cuda11.8-pip/devcontainer.json | 6 ++--- .../cuda12.5-conda/devcontainer.json | 6 ++--- .devcontainer/cuda12.5-pip/devcontainer.json | 6 ++--- .github/workflows/build.yaml | 16 ++++++------- .github/workflows/pr.yaml | 24 +++++++++---------- .github/workflows/test.yaml | 6 ++--- .../trigger-breaking-change-alert.yaml | 2 +- VERSION | 2 +- dependencies.yaml | 6 ++--- python/rmm/pyproject.toml | 2 +- 11 files changed, 41 insertions(+), 41 deletions(-) diff --git a/.devcontainer/cuda11.8-conda/devcontainer.json b/.devcontainer/cuda11.8-conda/devcontainer.json index cf93b101a..e962a832e 100644 --- a/.devcontainer/cuda11.8-conda/devcontainer.json +++ b/.devcontainer/cuda11.8-conda/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:25.02-cpp-cuda11.8-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.04-cpp-cuda11.8-mambaforge-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.02-cuda11.8-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.04-cuda11.8-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.2": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.4": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda11.8-pip/devcontainer.json b/.devcontainer/cuda11.8-pip/devcontainer.json index bd3aa8665..9e2c567bc 100644 --- a/.devcontainer/cuda11.8-pip/devcontainer.json +++ b/.devcontainer/cuda11.8-pip/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:25.02-cpp-cuda11.8-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.04-cpp-cuda11.8-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.02-cuda11.8-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.04-cuda11.8-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.2": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.4": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.5-conda/devcontainer.json b/.devcontainer/cuda12.5-conda/devcontainer.json index eba61f0b9..3a5ffb4df 100644 --- a/.devcontainer/cuda12.5-conda/devcontainer.json +++ b/.devcontainer/cuda12.5-conda/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "12.5", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:25.02-cpp-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.04-cpp-mambaforge-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.02-cuda12.5-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.04-cuda12.5-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.2": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.4": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.5-pip/devcontainer.json b/.devcontainer/cuda12.5-pip/devcontainer.json index 48aa3f083..d55978822 100644 --- a/.devcontainer/cuda12.5-pip/devcontainer.json +++ b/.devcontainer/cuda12.5-pip/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "12.5", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:25.02-cpp-cuda12.5-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.04-cpp-cuda12.5-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.02-cuda12.5-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.04-cuda12.5-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.2": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.4": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f7abc2d58..0defb453d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-25.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build-cpp: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.04 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -79,7 +79,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -89,7 +89,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -100,7 +100,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 29c9ae6e5..e52ac112a 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -26,7 +26,7 @@ jobs: - devcontainer - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-25.04 if: always() with: needs: ${{ toJSON(needs) }} @@ -57,7 +57,7 @@ jobs: needs: - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-25.04 with: files_yaml: | test_cpp: @@ -79,40 +79,40 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-25.04 with: enable_check_generated_files: false ignored_pr_jobs: telemetry-summarize conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.04 with: build_type: pull-request conda-cpp-tests: needs: [conda-cpp-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.04 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.04 with: build_type: pull-request conda-python-tests: needs: [conda-python-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.04 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.04 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -122,7 +122,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.04 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -130,14 +130,14 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.04 with: build_type: pull-request script: ci/build_wheel_python.sh wheel-tests: needs: [wheel-build-python, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.04 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request @@ -146,7 +146,7 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-25.04 with: arch: '["amd64"]' cuda: '["12.5"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b38c1e3cb..6159c56f5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.04 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.04 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.04 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/.github/workflows/trigger-breaking-change-alert.yaml b/.github/workflows/trigger-breaking-change-alert.yaml index 01dd2436b..9764c62c1 100644 --- a/.github/workflows/trigger-breaking-change-alert.yaml +++ b/.github/workflows/trigger-breaking-change-alert.yaml @@ -12,7 +12,7 @@ jobs: trigger-notifier: if: contains(github.event.pull_request.labels.*.name, 'breaking') secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@branch-25.04 with: sender_login: ${{ github.event.sender.login }} sender_avatar: ${{ github.event.sender.avatar_url }} diff --git a/VERSION b/VERSION index 72eefaf7c..b922658ff 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -25.02.00 +25.04.00 diff --git a/dependencies.yaml b/dependencies.yaml index 972f20f6c..1c4235214 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -177,15 +177,15 @@ dependencies: cuda: "12.*" cuda_suffixed: "true" packages: - - librmm-cu12==25.2.*,>=0.0.0a0 + - librmm-cu12==25.4.*,>=0.0.0a0 - matrix: cuda: "11.*" cuda_suffixed: "true" packages: - - librmm-cu11==25.2.*,>=0.0.0a0 + - librmm-cu11==25.4.*,>=0.0.0a0 - matrix: null packages: - - librmm==25.2.*,>=0.0.0a0 + - librmm==25.4.*,>=0.0.0a0 checks: common: - output_types: [conda, requirements] diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 73de5d839..6036e9c56 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -77,7 +77,7 @@ requires = [ "cmake>=3.26.4,!=3.30.0", "cuda-python>=11.8.5,<12.0a0", "cython>=3.0.0", - "librmm==25.2.*,>=0.0.0a0", + "librmm==25.4.*,>=0.0.0a0", "ninja", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. From dcd37acbe58c73192f74bd6bb1ec5f1b9f1f2dd4 Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Fri, 24 Jan 2025 18:39:42 -0500 Subject: [PATCH 537/675] Add shellcheck to pre-commit and fix warnings (#1788) `shellcheck` is a fast, static analysis tool for shell scripts. It's good at flagging up unused variables, unintentional glob expansions, and other potential execution and security headaches that arise from the wonders of `bash` (and other shlangs). This PR adds a `pre-commit` hook to run `shellcheck` on all of the `sh-lang` files in the `ci/` directory, and the changes requested by `shellcheck` to make the existing files pass the check. xref: rapidsai/build-planning#135 Authors: - Gil Forsyth (https://github.com/gforsyth) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1788 --- .pre-commit-config.yaml | 6 ++++++ ci/build_cpp.sh | 3 +-- ci/build_docs.sh | 10 +++++++--- ci/build_python.sh | 3 +-- ci/build_wheel_cpp.sh | 4 ++-- ci/build_wheel_python.sh | 6 +++--- ci/check_style.sh | 10 ++++++---- ci/release/update-version.sh | 12 ++++-------- ci/test_cpp.sh | 4 ++-- ci/test_python.sh | 5 +++-- ci/test_wheel.sh | 6 +++--- ci/validate_wheel.sh | 6 +++--- 12 files changed, 41 insertions(+), 34 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 85e30844a..de2af6c40 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -86,6 +86,12 @@ repos: hooks: - id: rapids-dependency-file-generator args: ["--clean"] + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.10.0.1 + hooks: + - id: shellcheck + args: ["--severity=warning"] + files: ^ci/ default_language_version: python: python3 diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 9d14cd072..1ab555bc0 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -1,12 +1,11 @@ #!/bin/bash -# Copyright (c) 2020-2024, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. set -euo pipefail rapids-configure-conda-channels source rapids-configure-sccache - source rapids-date-string export CMAKE_GENERATOR=Ninja diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 844dae1c6..a3562d973 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -1,13 +1,15 @@ #!/bin/bash -# Copyright (c) 2020-2024, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. set -euo pipefail rapids-logger "Create test conda environment" + . /opt/conda/etc/profile.d/conda.sh RAPIDS_VERSION="$(rapids-version)" -export RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)" +RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)" +export RAPIDS_VERSION_MAJOR_MINOR rapids-dependency-file-generator \ --output conda \ @@ -29,7 +31,9 @@ rapids-mamba-retry install \ "rmm=${RAPIDS_VERSION}" \ "librmm=${RAPIDS_VERSION}" -export RAPIDS_DOCS_DIR="$(mktemp -d)" +RAPIDS_DOCS_DIR="$(mktemp -d)" +export RAPIDS_DOCS_DIR + rapids-logger "Build CPP docs" pushd doxygen diff --git a/ci/build_python.sh b/ci/build_python.sh index 7a9df5fc7..98f57c34b 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -1,12 +1,11 @@ #!/bin/bash -# Copyright (c) 2020-2024, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. set -euo pipefail rapids-configure-conda-channels source rapids-configure-sccache - source rapids-date-string export CMAKE_GENERATOR=Ninja diff --git a/ci/build_wheel_cpp.sh b/ci/build_wheel_cpp.sh index e21792910..a05a44b61 100755 --- a/ci/build_wheel_cpp.sh +++ b/ci/build_wheel_cpp.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2024, NVIDIA CORPORATION. +# Copyright (c) 2024-2025, NVIDIA CORPORATION. set -euo pipefail @@ -10,7 +10,7 @@ source rapids-date-string rapids-generate-version > ./VERSION -RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" +RAPIDS_PY_CUDA_SUFFIX=$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}") cd "${package_dir}" diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index 4e4d3bf61..c2aef4a1a 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2023-2024, NVIDIA CORPORATION. +# Copyright (c) 2023-2025, NVIDIA CORPORATION. set -euo pipefail @@ -13,14 +13,14 @@ rapids-generate-version > ./VERSION pushd "${package_dir}" -RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" +RAPIDS_PY_CUDA_SUFFIX=$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}") CPP_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp /tmp/librmm_dist) # ensure 'rmm' wheel builds always use the 'librmm' just built in the same CI run # # using env variable PIP_CONSTRAINT is necessary to ensure the constraints # are used when created the isolated build environment -echo "librmm-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo ${CPP_WHEELHOUSE}/librmm_${RAPIDS_PY_CUDA_SUFFIX}*.whl)" > ./build-constraints.txt +echo "librmm-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo "${CPP_WHEELHOUSE}"/librmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)" > ./build-constraints.txt sccache --zero-stats diff --git a/ci/check_style.sh b/ci/check_style.sh index 9d9151417..c6825dfbd 100755 --- a/ci/check_style.sh +++ b/ci/check_style.sh @@ -1,9 +1,10 @@ #!/bin/bash -# Copyright (c) 2020-2024, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. set -euo pipefail rapids-logger "Create checks conda environment" + . /opt/conda/etc/profile.d/conda.sh rapids-dependency-file-generator \ @@ -16,9 +17,10 @@ conda activate checks RAPIDS_VERSION_NUMBER="$(rapids-version-major-minor)" FORMAT_FILE_URL="https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${RAPIDS_VERSION_NUMBER}/cmake-format-rapids-cmake.json" -export RAPIDS_CMAKE_FORMAT_FILE=/tmp/rapids_cmake_ci/cmake-formats-rapids-cmake.json -mkdir -p $(dirname ${RAPIDS_CMAKE_FORMAT_FILE}) -wget -O ${RAPIDS_CMAKE_FORMAT_FILE} ${FORMAT_FILE_URL} +RAPIDS_CMAKE_FORMAT_FILE=/tmp/rapids_cmake_ci/cmake-formats-rapids-cmake.json +export RAPIDS_CMAKE_FORMAT_FILE +mkdir -p "$(dirname ${RAPIDS_CMAKE_FORMAT_FILE})" +wget -O ${RAPIDS_CMAKE_FORMAT_FILE} "${FORMAT_FILE_URL}" # Run pre-commit checks pre-commit run --all-files --show-diff-on-failure diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index ddd093bea..5b5217602 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2024, NVIDIA CORPORATION. +# Copyright (c) 2024-2025, NVIDIA CORPORATION. ######################## # RMM Version Updater # ######################## @@ -13,14 +13,10 @@ NEXT_FULL_TAG=$1 # Get current version CURRENT_TAG=$(git tag --merged HEAD | grep -xE '^v.*' | sort --version-sort | tail -n 1 | tr -d 'v') -CURRENT_MAJOR=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[1]}') -CURRENT_MINOR=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[2]}') -CURRENT_PATCH=$(echo $CURRENT_TAG | awk '{split($0, a, "."); print a[3]}') -CURRENT_SHORT_TAG=${CURRENT_MAJOR}.${CURRENT_MINOR} # Get . for next version -NEXT_MAJOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[1]}') -NEXT_MINOR=$(echo $NEXT_FULL_TAG | awk '{split($0, a, "."); print a[2]}') +NEXT_MAJOR=$(echo "$NEXT_FULL_TAG" | awk '{split($0, a, "."); print a[1]}') +NEXT_MINOR=$(echo "$NEXT_FULL_TAG" | awk '{split($0, a, "."); print a[2]}') NEXT_SHORT_TAG=${NEXT_MAJOR}.${NEXT_MINOR} # Need to distutils-normalize the original version @@ -30,7 +26,7 @@ echo "Preparing release $CURRENT_TAG => $NEXT_FULL_TAG" # Inplace sed replace; workaround for Linux and Mac function sed_runner() { - sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak + sed -i.bak ''"$1"'' "$2" && rm -f "${2}".bak } # Centralized version file update diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 975477a6e..e0612c94b 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2020-2024, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. set -euo pipefail @@ -44,4 +44,4 @@ export GTEST_OUTPUT=xml:${RAPIDS_TESTS_DIR}/ ./ci/run_ctests.sh -j20 && EXITCODE=$? || EXITCODE=$?; rapids-logger "Test script exiting with value: $EXITCODE" -exit ${EXITCODE} +exit "${EXITCODE}" diff --git a/ci/test_python.sh b/ci/test_python.sh index 51d0a48c3..377882c59 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2020-2024, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. set -euo pipefail @@ -7,6 +7,7 @@ set -euo pipefail cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../ rapids-logger "Create test conda environment" + . /opt/conda/etc/profile.d/conda.sh RAPIDS_VERSION="$(rapids-version)" @@ -51,4 +52,4 @@ rapids-logger "pytest rmm" && EXITCODE=$? || EXITCODE=$?; rapids-logger "Test script exiting with value: $EXITCODE" -exit ${EXITCODE} +exit "${EXITCODE}" diff --git a/ci/test_wheel.sh b/ci/test_wheel.sh index 2f39b197b..700f44dcc 100755 --- a/ci/test_wheel.sh +++ b/ci/test_wheel.sh @@ -1,9 +1,9 @@ #!/bin/bash -# Copyright (c) 2023-2024, NVIDIA CORPORATION. +# Copyright (c) 2023-2025, NVIDIA CORPORATION. set -eou pipefail -RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})" +RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}")" WHEELHOUSE="${PWD}/dist/" RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 python "${WHEELHOUSE}" @@ -14,6 +14,6 @@ rapids-generate-pip-constraints test_python ./constraints.txt python -m pip install \ -v \ --constraint ./constraints.txt \ - "$(echo "${WHEELHOUSE}"/rmm_${RAPIDS_PY_CUDA_SUFFIX}*.whl)[test]" + "$(echo "${WHEELHOUSE}"/rmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)[test]" python -m pytest ./python/rmm/rmm/tests diff --git a/ci/validate_wheel.sh b/ci/validate_wheel.sh index 60a80fce6..5d3d0c6c3 100755 --- a/ci/validate_wheel.sh +++ b/ci/validate_wheel.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2024, NVIDIA CORPORATION. +# Copyright (c) 2024-2025, NVIDIA CORPORATION. set -euo pipefail @@ -9,10 +9,10 @@ rapids-logger "validate packages with 'pydistcheck'" pydistcheck \ --inspect \ - "$(echo ${wheel_dir_relative_path}/*.whl)" + "$(echo "${wheel_dir_relative_path}"/*.whl)" rapids-logger "validate packages with 'twine'" twine check \ --strict \ - "$(echo ${wheel_dir_relative_path}/*.whl)" + "$(echo "${wheel_dir_relative_path}"/*.whl)" From 401483cc4498a7082355c796fcdf1fe2eafe331c Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 28 Jan 2025 12:40:23 -0600 Subject: [PATCH 538/675] Build and test with CUDA 12.8.0 (#1797) This PR uses CUDA 12.8.0 to build and test. xref: https://github.com/rapidsai/build-planning/issues/139 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1797 --- .../devcontainer.json | 8 +++--- .../devcontainer.json | 10 +++---- .github/workflows/build.yaml | 16 ++++++------ .github/workflows/pr.yaml | 26 +++++++++---------- .github/workflows/test.yaml | 6 ++--- .../trigger-breaking-change-alert.yaml | 2 +- README.md | 4 +-- ..._64.yaml => all_cuda-128_arch-x86_64.yaml} | 4 +-- dependencies.yaml | 6 ++++- 9 files changed, 43 insertions(+), 39 deletions(-) rename .devcontainer/{cuda12.5-conda => cuda12.8-conda}/devcontainer.json (91%) rename .devcontainer/{cuda12.5-pip => cuda12.8-pip}/devcontainer.json (87%) rename conda/environments/{all_cuda-125_arch-x86_64.yaml => all_cuda-128_arch-x86_64.yaml} (94%) diff --git a/.devcontainer/cuda12.5-conda/devcontainer.json b/.devcontainer/cuda12.8-conda/devcontainer.json similarity index 91% rename from .devcontainer/cuda12.5-conda/devcontainer.json rename to .devcontainer/cuda12.8-conda/devcontainer.json index eba61f0b9..3262411ee 100644 --- a/.devcontainer/cuda12.5-conda/devcontainer.json +++ b/.devcontainer/cuda12.8-conda/devcontainer.json @@ -3,7 +3,7 @@ "context": "${localWorkspaceFolder}/.devcontainer", "dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile", "args": { - "CUDA": "12.5", + "CUDA": "12.8", "PYTHON_PACKAGE_MANAGER": "conda", "BASE": "rapidsai/devcontainers:25.02-cpp-mambaforge-ubuntu22.04" } @@ -11,7 +11,7 @@ "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.02-cuda12.5-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.02-cuda12.8-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { @@ -20,7 +20,7 @@ "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" ], - "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config,conda/pkgs,conda/${localWorkspaceFolderBasename}-cuda12.5-envs}"], + "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config,conda/pkgs,conda/${localWorkspaceFolderBasename}-cuda12.8-envs}"], "postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"], "workspaceFolder": "/home/coder", "workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent", @@ -29,7 +29,7 @@ "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.conda/pkgs,target=/home/coder/.conda/pkgs,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.conda/${localWorkspaceFolderBasename}-cuda12.5-envs,target=/home/coder/.conda/envs,type=bind,consistency=consistent" + "source=${localWorkspaceFolder}/../.conda/${localWorkspaceFolderBasename}-cuda12.8-envs,target=/home/coder/.conda/envs,type=bind,consistency=consistent" ], "customizations": { "vscode": { diff --git a/.devcontainer/cuda12.5-pip/devcontainer.json b/.devcontainer/cuda12.8-pip/devcontainer.json similarity index 87% rename from .devcontainer/cuda12.5-pip/devcontainer.json rename to .devcontainer/cuda12.8-pip/devcontainer.json index 48aa3f083..60fa6a6e9 100644 --- a/.devcontainer/cuda12.5-pip/devcontainer.json +++ b/.devcontainer/cuda12.8-pip/devcontainer.json @@ -3,15 +3,15 @@ "context": "${localWorkspaceFolder}/.devcontainer", "dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile", "args": { - "CUDA": "12.5", + "CUDA": "12.8", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:25.02-cpp-cuda12.5-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.02-cpp-cuda12.8-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.02-cuda12.5-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.02-cuda12.8-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { @@ -20,7 +20,7 @@ "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" ], - "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config/pip,local/share/${localWorkspaceFolderBasename}-cuda12.5-venvs}"], + "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config/pip,local/share/${localWorkspaceFolderBasename}-cuda12.8-venvs}"], "postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"], "workspaceFolder": "/home/coder", "workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent", @@ -28,7 +28,7 @@ "source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.local/share/${localWorkspaceFolderBasename}-cuda12.5-venvs,target=/home/coder/.local/share/venvs,type=bind,consistency=consistent" + "source=${localWorkspaceFolder}/../.local/share/${localWorkspaceFolderBasename}-cuda12.8-venvs,target=/home/coder/.local/share/venvs,type=bind,consistency=consistent" ], "customizations": { "vscode": { diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f7abc2d58..ac8bf1d95 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@cuda-12.8.0 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@cuda-12.8.0 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@cuda-12.8.0 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@cuda-12.8.0 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build-cpp: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.8.0 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -79,7 +79,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.8.0 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -89,7 +89,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@cuda-12.8.0 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -100,7 +100,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@cuda-12.8.0 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 29c9ae6e5..eb8bc439e 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -26,7 +26,7 @@ jobs: - devcontainer - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@cuda-12.8.0 if: always() with: needs: ${{ toJSON(needs) }} @@ -57,7 +57,7 @@ jobs: needs: - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@cuda-12.8.0 with: files_yaml: | test_cpp: @@ -79,40 +79,40 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@cuda-12.8.0 with: enable_check_generated_files: false ignored_pr_jobs: telemetry-summarize conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@cuda-12.8.0 with: build_type: pull-request conda-cpp-tests: needs: [conda-cpp-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-12.8.0 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@cuda-12.8.0 with: build_type: pull-request conda-python-tests: needs: [conda-python-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@cuda-12.8.0 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@cuda-12.8.0 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -122,7 +122,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.8.0 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -130,14 +130,14 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.8.0 with: build_type: pull-request script: ci/build_wheel_python.sh wheel-tests: needs: [wheel-build-python, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@cuda-12.8.0 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request @@ -146,10 +146,10 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@cuda-12.8.0 with: arch: '["amd64"]' - cuda: '["12.5"]' + cuda: '["12.8"]' build_command: | sccache -z; build-all -DBUILD_BENCHMARKS=ON --verbose; diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b38c1e3cb..af9d3db6f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-12.8.0 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@cuda-12.8.0 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@cuda-12.8.0 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/.github/workflows/trigger-breaking-change-alert.yaml b/.github/workflows/trigger-breaking-change-alert.yaml index 01dd2436b..07f0f83cc 100644 --- a/.github/workflows/trigger-breaking-change-alert.yaml +++ b/.github/workflows/trigger-breaking-change-alert.yaml @@ -12,7 +12,7 @@ jobs: trigger-notifier: if: contains(github.event.pull_request.labels.*.name, 'breaking') secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@cuda-12.8.0 with: sender_login: ${{ github.event.sender.login }} sender_avatar: ${{ github.event.sender.avatar_url }} diff --git a/README.md b/README.md index 62ac48805..44c262ac5 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ RMM can be installed with conda. You can get a minimal conda installation with [ Install RMM with: ```bash -conda install -c rapidsai -c conda-forge -c nvidia rmm cuda-version=12.0 +conda install -c rapidsai -c conda-forge -c nvidia rmm cuda-version=12.8 ``` We also provide [nightly conda packages](https://anaconda.org/rapidsai-nightly) built from the HEAD @@ -90,7 +90,7 @@ $ cd rmm - Create the conda development environment `rmm_dev` ```bash # create the conda environment (assuming in base `rmm` directory) -$ conda env create --name rmm_dev --file conda/environments/all_cuda-125_arch-x86_64.yaml +$ conda env create --name rmm_dev --file conda/environments/all_cuda-128_arch-x86_64.yaml # activate the environment $ conda activate rmm_dev ``` diff --git a/conda/environments/all_cuda-125_arch-x86_64.yaml b/conda/environments/all_cuda-128_arch-x86_64.yaml similarity index 94% rename from conda/environments/all_cuda-125_arch-x86_64.yaml rename to conda/environments/all_cuda-128_arch-x86_64.yaml index eae1076fc..e22c9b5c3 100644 --- a/conda/environments/all_cuda-125_arch-x86_64.yaml +++ b/conda/environments/all_cuda-128_arch-x86_64.yaml @@ -12,7 +12,7 @@ dependencies: - cmake>=3.26.4,!=3.30.0 - cuda-nvcc - cuda-python>=12.6.2,<13.0a0 -- cuda-version=12.5 +- cuda-version=12.8 - cxx-compiler - cython>=3.0.0 - doxygen=1.9.1 @@ -40,4 +40,4 @@ dependencies: - sphinx-markdown-tables - sphinx_rtd_theme - sysroot_linux-64==2.28 -name: all_cuda-125_arch-x86_64 +name: all_cuda-128_arch-x86_64 diff --git a/dependencies.yaml b/dependencies.yaml index 972f20f6c..90a267e66 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -3,7 +3,7 @@ files: all: output: conda matrix: - cuda: ["11.8", "12.5"] + cuda: ["11.8", "12.8"] arch: [x86_64] includes: - build @@ -233,6 +233,10 @@ dependencies: cuda: "12.5" packages: - cuda-version=12.5 + - matrix: + cuda: "12.8" + packages: + - cuda-version=12.8 cuda: specific: - output_types: conda From b5bc0a019e366abbbf7c06ec4c3efd6910ca9d30 Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Thu, 30 Jan 2025 19:24:11 +0100 Subject: [PATCH 539/675] Disable exec checks for `device_uvector::operator=` (#1790) We already suppress those for the constructors Authors: - Michael Schellenberger Costa (https://github.com/miscco) - Bradley Dice (https://github.com/bdice) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Rong Ou (https://github.com/rongou) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1790 --- doxygen/Doxyfile | 2 +- include/rmm/device_uvector.hpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index dbd4194ab..5cc7accc1 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -2180,7 +2180,7 @@ INCLUDE_FILE_PATTERNS = # Since we are excluding detail files in EXCLUDE_PATTERNS there # appears to be no way of getting doxygen to still parse that file and # make the definitions available via the preprocessor :( -PREDEFINED = RMM_EXPORT RMM_HIDDEN RMM_NAMESPACE=rmm +PREDEFINED = RMM_EXPORT RMM_HIDDEN RMM_EXEC_CHECK_DISABLE RMM_NAMESPACE=rmm # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/include/rmm/device_uvector.hpp b/include/rmm/device_uvector.hpp index 13f566150..8f2c5936e 100644 --- a/include/rmm/device_uvector.hpp +++ b/include/rmm/device_uvector.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,6 +95,7 @@ class device_uvector { RMM_EXEC_CHECK_DISABLE device_uvector(device_uvector&&) noexcept = default; ///< @default_move_constructor + RMM_EXEC_CHECK_DISABLE device_uvector& operator=(device_uvector&&) noexcept = default; ///< @default_move_assignment{device_uvector} From 2550156919aeb456988bc85a315177ea569d60b4 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 31 Jan 2025 04:01:10 -0800 Subject: [PATCH 540/675] Revert CUDA 12.8 shared workflow branch changes (#1805) This PR points the shared workflow branches back to the default 25.02 branches. xref: https://github.com/rapidsai/build-planning/issues/139 Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1805 --- .github/workflows/build.yaml | 16 ++++++------- .github/workflows/pr.yaml | 24 +++++++++---------- .github/workflows/test.yaml | 6 ++--- .../trigger-breaking-change-alert.yaml | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ac8bf1d95..f7abc2d58 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-25.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build-cpp: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -79,7 +79,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -89,7 +89,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -100,7 +100,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.02 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index eb8bc439e..58159f679 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -26,7 +26,7 @@ jobs: - devcontainer - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-25.02 if: always() with: needs: ${{ toJSON(needs) }} @@ -57,7 +57,7 @@ jobs: needs: - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-25.02 with: files_yaml: | test_cpp: @@ -79,40 +79,40 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-25.02 with: enable_check_generated_files: false ignored_pr_jobs: telemetry-summarize conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.02 with: build_type: pull-request conda-cpp-tests: needs: [conda-cpp-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.02 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.02 with: build_type: pull-request conda-python-tests: needs: [conda-python-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.02 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.02 with: build_type: pull-request node_type: "gpu-v100-latest-1" @@ -122,7 +122,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -130,14 +130,14 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 with: build_type: pull-request script: ci/build_wheel_python.sh wheel-tests: needs: [wheel-build-python, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.02 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request @@ -146,7 +146,7 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-25.02 with: arch: '["amd64"]' cuda: '["12.8"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index af9d3db6f..b38c1e3cb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.02 with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.02 with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.02 with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/.github/workflows/trigger-breaking-change-alert.yaml b/.github/workflows/trigger-breaking-change-alert.yaml index 07f0f83cc..01dd2436b 100644 --- a/.github/workflows/trigger-breaking-change-alert.yaml +++ b/.github/workflows/trigger-breaking-change-alert.yaml @@ -12,7 +12,7 @@ jobs: trigger-notifier: if: contains(github.event.pull_request.labels.*.name, 'breaking') secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@cuda-12.8.0 + uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@branch-25.02 with: sender_login: ${{ github.event.sender.login }} sender_avatar: ${{ github.event.sender.avatar_url }} From 05e810a535c55f9e8712b248d47760af1ce4512d Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 31 Jan 2025 10:13:32 -0600 Subject: [PATCH 541/675] disallow fallback to Make in wheel builds (#1804) Contributes to https://github.com/rapidsai/build-planning/issues/146 Proposes: * setting `[tool.scikit-build].ninja.make-fallback = false`, so `scikit-build-core` will not silently fallback to using GNU Make if `ninja` is not available Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1804 --- python/librmm/pyproject.toml | 4 ++-- python/rmm/pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/librmm/pyproject.toml b/python/librmm/pyproject.toml index bae2ef36b..6fee31c9a 100644 --- a/python/librmm/pyproject.toml +++ b/python/librmm/pyproject.toml @@ -1,4 +1,4 @@ -# Copyright (c) 2024, NVIDIA CORPORATION. +# Copyright (c) 2024-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ build-dir = "build/{wheel_tag}" cmake.build-type = "Release" cmake.version = "CMakeLists.txt" minimum-version = "build-system.requires" -ninja.make-fallback = true +ninja.make-fallback = false sdist.reproducible = true wheel.packages = ["librmm"] wheel.install-dir = "librmm" diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 6036e9c56..d457b0913 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -59,7 +59,7 @@ build-dir = "build/{wheel_tag}" cmake.build-type = "Release" cmake.version = "CMakeLists.txt" minimum-version = "build-system.requires" -ninja.make-fallback = true +ninja.make-fallback = false sdist.exclude = ["*tests*"] sdist.reproducible = true wheel.packages = ["rmm"] From f23ae316dc79fff2d3fed0d453fb56f0269d79fa Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 31 Jan 2025 10:22:26 -0600 Subject: [PATCH 542/675] Merge branch-25.02 into branch-25.04 From 45a44463472003e86c7ade2248d8d799fb97758e Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 31 Jan 2025 18:16:54 -0600 Subject: [PATCH 543/675] Migrate to NVKS for amd64 CI runners (#1803) This migrates amd64 CI jobs (PRs and nightlies) to use L4 GPUs from the NVKS cluster. xref: https://github.com/rapidsai/build-infra/issues/184 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Gil Forsyth (https://github.com/gforsyth) URL: https://github.com/rapidsai/rmm/pull/1803 --- .github/workflows/build.yaml | 18 ++++++------- .github/workflows/pr.yaml | 26 +++++++++---------- .github/workflows/test.yaml | 6 ++--- .../trigger-breaking-change-alert.yaml | 2 +- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f7abc2d58..b5a88c995 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@nvks-runners with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@nvks-runners with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@nvks-runners with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,19 +56,19 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@nvks-runners with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} sha: ${{ inputs.sha }} date: ${{ inputs.date }} - node_type: "gpu-v100-latest-1" + node_type: "gpu-l4-latest-1" arch: "amd64" container_image: "rapidsai/ci-conda:latest" run_script: "ci/build_docs.sh" wheel-build-cpp: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@nvks-runners with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -79,7 +79,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@nvks-runners with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -89,7 +89,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@nvks-runners with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -100,7 +100,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@nvks-runners with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 58159f679..699efc636 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -26,7 +26,7 @@ jobs: - devcontainer - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@nvks-runners if: always() with: needs: ${{ toJSON(needs) }} @@ -57,7 +57,7 @@ jobs: needs: - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@nvks-runners with: files_yaml: | test_cpp: @@ -79,50 +79,50 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@nvks-runners with: enable_check_generated_files: false ignored_pr_jobs: telemetry-summarize conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@nvks-runners with: build_type: pull-request conda-cpp-tests: needs: [conda-cpp-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@nvks-runners if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@nvks-runners with: build_type: pull-request conda-python-tests: needs: [conda-python-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@nvks-runners if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@nvks-runners with: build_type: pull-request - node_type: "gpu-v100-latest-1" + node_type: "gpu-l4-latest-1" arch: "amd64" container_image: "rapidsai/ci-conda:latest" run_script: "ci/build_docs.sh" wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@nvks-runners with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -130,14 +130,14 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@nvks-runners with: build_type: pull-request script: ci/build_wheel_python.sh wheel-tests: needs: [wheel-build-python, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@nvks-runners if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request @@ -146,7 +146,7 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@nvks-runners with: arch: '["amd64"]' cuda: '["12.8"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b38c1e3cb..ebe1273a2 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@nvks-runners with: build_type: nightly branch: ${{ inputs.branch }} @@ -24,7 +24,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@nvks-runners with: build_type: nightly branch: ${{ inputs.branch }} @@ -32,7 +32,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@nvks-runners with: build_type: nightly branch: ${{ inputs.branch }} diff --git a/.github/workflows/trigger-breaking-change-alert.yaml b/.github/workflows/trigger-breaking-change-alert.yaml index 01dd2436b..7b5b4810f 100644 --- a/.github/workflows/trigger-breaking-change-alert.yaml +++ b/.github/workflows/trigger-breaking-change-alert.yaml @@ -12,7 +12,7 @@ jobs: trigger-notifier: if: contains(github.event.pull_request.labels.*.name, 'breaking') secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@branch-25.02 + uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@nvks-runners with: sender_login: ${{ github.event.sender.login }} sender_avatar: ${{ github.event.sender.avatar_url }} From fe66a2437423a957030d4b46548bde1a575f17df Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Mon, 3 Feb 2025 17:37:39 -0500 Subject: [PATCH 544/675] Add `build_type` to workflow inputs (#1811) xref https://github.com/rapidsai/build-planning/issues/147 Authors: - Gil Forsyth (https://github.com/gforsyth) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1811 --- .github/workflows/test.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ebe1273a2..ad640d10a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -12,6 +12,9 @@ on: sha: required: true type: string + build_type: + type: string + default: nightly jobs: cpp-tests: From 5dbb28bb1fdb165d4bc5dcfe67eb5bb0e56cdb5d Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 3 Feb 2025 18:45:47 -0800 Subject: [PATCH 545/675] Use build_type input (#1812) Fixes `build_type` input not being used in `test` workflows. See https://github.com/rapidsai/rmm/pull/1811#issuecomment-2632393464. --- .github/workflows/test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ad640d10a..241680b99 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -21,7 +21,7 @@ jobs: secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@nvks-runners with: - build_type: nightly + build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} date: ${{ inputs.date }} sha: ${{ inputs.sha }} @@ -29,7 +29,7 @@ jobs: secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@nvks-runners with: - build_type: nightly + build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} date: ${{ inputs.date }} sha: ${{ inputs.sha }} @@ -37,7 +37,7 @@ jobs: secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@nvks-runners with: - build_type: nightly + build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} date: ${{ inputs.date }} sha: ${{ inputs.sha }} From 51283b0a79fe2f973e86384a6bc36f65d0fb943d Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 4 Feb 2025 09:38:02 -0800 Subject: [PATCH 546/675] Use nightly matrix for branch tests. (#1813) ## Description Testing https://github.com/rapidsai/shared-workflows/pull/276. We will merge this PR and then we can try running manual branch tests. ## Checklist - [x] I am familiar with the [Contributing Guidelines](https://github.com/rapidsai/rmm/blob/HEAD/CONTRIBUTING.md). - [x] New or existing tests cover these changes. - [x] The documentation is up to date with these changes. --- .github/workflows/build.yaml | 16 ++++++++-------- .github/workflows/pr.yaml | 24 ++++++++++++------------ .github/workflows/test.yaml | 6 +++--- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b5a88c995..786597402 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@use-nightly-matrix-for-branch-tests with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@use-nightly-matrix-for-branch-tests with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@use-nightly-matrix-for-branch-tests with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@use-nightly-matrix-for-branch-tests with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build-cpp: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@use-nightly-matrix-for-branch-tests with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -79,7 +79,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@use-nightly-matrix-for-branch-tests with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -89,7 +89,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@use-nightly-matrix-for-branch-tests with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -100,7 +100,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@use-nightly-matrix-for-branch-tests with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 699efc636..35a7228ae 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -26,7 +26,7 @@ jobs: - devcontainer - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@use-nightly-matrix-for-branch-tests if: always() with: needs: ${{ toJSON(needs) }} @@ -57,7 +57,7 @@ jobs: needs: - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@use-nightly-matrix-for-branch-tests with: files_yaml: | test_cpp: @@ -79,40 +79,40 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@use-nightly-matrix-for-branch-tests with: enable_check_generated_files: false ignored_pr_jobs: telemetry-summarize conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@use-nightly-matrix-for-branch-tests with: build_type: pull-request conda-cpp-tests: needs: [conda-cpp-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@use-nightly-matrix-for-branch-tests if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@use-nightly-matrix-for-branch-tests with: build_type: pull-request conda-python-tests: needs: [conda-python-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@use-nightly-matrix-for-branch-tests if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@use-nightly-matrix-for-branch-tests with: build_type: pull-request node_type: "gpu-l4-latest-1" @@ -122,7 +122,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@use-nightly-matrix-for-branch-tests with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -130,14 +130,14 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@use-nightly-matrix-for-branch-tests with: build_type: pull-request script: ci/build_wheel_python.sh wheel-tests: needs: [wheel-build-python, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@use-nightly-matrix-for-branch-tests if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request @@ -146,7 +146,7 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@use-nightly-matrix-for-branch-tests with: arch: '["amd64"]' cuda: '["12.8"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 241680b99..2d3dd9d2e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,7 +19,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@use-nightly-matrix-for-branch-tests with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} @@ -27,7 +27,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@use-nightly-matrix-for-branch-tests with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} @@ -35,7 +35,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@use-nightly-matrix-for-branch-tests with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} From 1eb989536d9f00ca3e3c7ee01ec778959052b7ea Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Wed, 5 Feb 2025 12:58:56 -0500 Subject: [PATCH 547/675] Use `rapids-pip-retry` in CI jobs that might need retries (#1814) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Uses a retry wrapper for `pip` commands to try to alleviate CI failures due to hash mismatches that result from network hiccups xref rapidsai/build-planning#148 This will retry failures that show up in CI like: ``` Collecting nvidia-cublas-cu12 (from libraft-cu12==25.2.*,>=0.0.0a0) Downloading https://pypi.nvidia.com/nvidia-cublas-cu12/nvidia_cublas_cu12-12.8.3.14-py3-none-manylinux_2_27_aarch64.whl (604.9 MB) ━━━━━━━━━━━━━━━━━━━━━ 350.2/604.9 MB 229.2 MB/s eta 0:00:02 ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them. nvidia-cublas-cu12 from https://pypi.nvidia.com/nvidia-cublas-cu12/nvidia_cublas_cu12-12.8.3.14-py3-none-manylinux_2_27_aarch64.whl#sha256=93a4e0e386cc7f6e56c822531396de8170ed17068a1e18f987574895044cd8c3 (from libraft-cu12==25.2.*,>=0.0.0a0): Expected sha256 93a4e0e386cc7f6e56c822531396de8170ed17068a1e18f987574895044cd8c3 Got 849c88d155cb4b4a3fdfebff9270fb367c58370b4243a2bdbcb1b9e7e940b7be ``` Authors: - Gil Forsyth (https://github.com/gforsyth) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1814 --- .github/workflows/build.yaml | 16 ++++++++-------- .github/workflows/pr.yaml | 24 ++++++++++++------------ .github/workflows/test.yaml | 6 +++--- ci/build_wheel_cpp.sh | 2 +- ci/build_wheel_python.sh | 2 +- ci/test_wheel.sh | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 786597402..b5a88c995 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@nvks-runners with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@nvks-runners with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@nvks-runners with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@nvks-runners with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build-cpp: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@nvks-runners with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -79,7 +79,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@nvks-runners with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -89,7 +89,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@nvks-runners with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -100,7 +100,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@nvks-runners with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 35a7228ae..699efc636 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -26,7 +26,7 @@ jobs: - devcontainer - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@nvks-runners if: always() with: needs: ${{ toJSON(needs) }} @@ -57,7 +57,7 @@ jobs: needs: - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@nvks-runners with: files_yaml: | test_cpp: @@ -79,40 +79,40 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@nvks-runners with: enable_check_generated_files: false ignored_pr_jobs: telemetry-summarize conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@nvks-runners with: build_type: pull-request conda-cpp-tests: needs: [conda-cpp-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@nvks-runners if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@nvks-runners with: build_type: pull-request conda-python-tests: needs: [conda-python-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@nvks-runners if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@nvks-runners with: build_type: pull-request node_type: "gpu-l4-latest-1" @@ -122,7 +122,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@nvks-runners with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -130,14 +130,14 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@nvks-runners with: build_type: pull-request script: ci/build_wheel_python.sh wheel-tests: needs: [wheel-build-python, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@nvks-runners if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request @@ -146,7 +146,7 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@nvks-runners with: arch: '["amd64"]' cuda: '["12.8"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2d3dd9d2e..241680b99 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,7 +19,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@nvks-runners with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} @@ -27,7 +27,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@nvks-runners with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} @@ -35,7 +35,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@use-nightly-matrix-for-branch-tests + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@nvks-runners with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} diff --git a/ci/build_wheel_cpp.sh b/ci/build_wheel_cpp.sh index a05a44b61..9396e9cc5 100755 --- a/ci/build_wheel_cpp.sh +++ b/ci/build_wheel_cpp.sh @@ -16,7 +16,7 @@ cd "${package_dir}" sccache --zero-stats -python -m pip wheel . -w dist -v --no-deps --disable-pip-version-check +rapids-pip-retry wheel . -w dist -v --no-deps --disable-pip-version-check sccache --show-adv-stats diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index c2aef4a1a..c61397fe2 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -25,7 +25,7 @@ echo "librmm-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo "${CPP_WHEELHOUSE}"/librmm sccache --zero-stats PIP_CONSTRAINT="${PWD}/build-constraints.txt" \ - python -m pip wheel . -w dist -v --no-deps --disable-pip-version-check + rapids-pip-retry wheel . -w dist -v --no-deps --disable-pip-version-check sccache --show-adv-stats diff --git a/ci/test_wheel.sh b/ci/test_wheel.sh index 700f44dcc..f3807afdd 100755 --- a/ci/test_wheel.sh +++ b/ci/test_wheel.sh @@ -11,7 +11,7 @@ RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from- rapids-generate-pip-constraints test_python ./constraints.txt # echo to expand wildcard before adding '[extra]' requires for pip -python -m pip install \ +rapids-pip-retry install \ -v \ --constraint ./constraints.txt \ "$(echo "${WHEELHOUSE}"/rmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)[test]" From 3953d1c58f6095b63783c1ff9ae9b9ecdf3ed044 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 7 Feb 2025 09:13:58 -0800 Subject: [PATCH 548/675] Use shared-workflows branch-25.04 (#1816) This completes the migration to NVKS runners now that all libraries have been tested and https://github.com/rapidsai/shared-workflows/pull/273 has been merged. xref: https://github.com/rapidsai/build-infra/issues/184 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1816 --- .github/workflows/build.yaml | 16 ++++++------- .github/workflows/pr.yaml | 24 +++++++++---------- .github/workflows/test.yaml | 6 ++--- .../trigger-breaking-change-alert.yaml | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b5a88c995..29e7fc451 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,7 +28,7 @@ concurrency: jobs: cpp-build: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -37,7 +37,7 @@ jobs: python-build: needs: [cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -46,7 +46,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-25.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -56,7 +56,7 @@ jobs: if: github.ref_type == 'branch' needs: python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: run_script: "ci/build_docs.sh" wheel-build-cpp: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.04 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -79,7 +79,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -89,7 +89,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -100,7 +100,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.04 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 699efc636..a5c44b0c2 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -26,7 +26,7 @@ jobs: - devcontainer - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-25.04 if: always() with: needs: ${{ toJSON(needs) }} @@ -57,7 +57,7 @@ jobs: needs: - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-25.04 with: files_yaml: | test_cpp: @@ -79,40 +79,40 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-25.04 with: enable_check_generated_files: false ignored_pr_jobs: telemetry-summarize conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.04 with: build_type: pull-request conda-cpp-tests: needs: [conda-cpp-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.04 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.04 with: build_type: pull-request conda-python-tests: needs: [conda-python-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.04 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.04 with: build_type: pull-request node_type: "gpu-l4-latest-1" @@ -122,7 +122,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.04 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -130,14 +130,14 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.04 with: build_type: pull-request script: ci/build_wheel_python.sh wheel-tests: needs: [wheel-build-python, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.04 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request @@ -146,7 +146,7 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-25.04 with: arch: '["amd64"]' cuda: '["12.8"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 241680b99..b66687b63 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,7 +19,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.04 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} @@ -27,7 +27,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.04 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} @@ -35,7 +35,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.04 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/trigger-breaking-change-alert.yaml b/.github/workflows/trigger-breaking-change-alert.yaml index 7b5b4810f..9764c62c1 100644 --- a/.github/workflows/trigger-breaking-change-alert.yaml +++ b/.github/workflows/trigger-breaking-change-alert.yaml @@ -12,7 +12,7 @@ jobs: trigger-notifier: if: contains(github.event.pull_request.labels.*.name, 'breaking') secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@nvks-runners + uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@branch-25.04 with: sender_login: ${{ github.event.sender.login }} sender_avatar: ${{ github.event.sender.avatar_url }} From f0a784a05ea55f144a66ba48f3d426fafc4fb400 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 10 Feb 2025 14:53:00 -0800 Subject: [PATCH 549/675] Use new rapids-logger library (#1808) This change helps completely insulate rmm (and transitively) the rest of RAPIDS from fmt and spdlog as dependencies, thereby solving a large number of issues around ABI stability, symbol visibility, package clobbering, and more. See rapidsai/build-planning#104 for more information. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Matthew Murray (https://github.com/Matt711) - Bradley Dice (https://github.com/bdice) - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1808 --- CMakeLists.txt | 12 ++-- README.md | 11 ++- benchmarks/CMakeLists.txt | 8 +-- benchmarks/replay/replay.cpp | 4 +- ci/build_wheel_python.sh | 5 +- ci/check_symbols.sh | 13 +--- ci/test_wheel.sh | 2 + cmake/thirdparty/get_spdlog.cmake | 33 --------- .../all_cuda-118_arch-x86_64.yaml | 3 +- .../all_cuda-128_arch-x86_64.yaml | 3 +- conda/recipes/librmm/conda_build_config.yaml | 6 -- conda/recipes/librmm/meta.yaml | 6 +- dependencies.yaml | 62 ++++++++++++---- include/rmm/logger.hpp | 72 +++++++++++++++++++ .../rmm/mr/device/arena_memory_resource.hpp | 9 +-- include/rmm/mr/device/detail/arena.hpp | 4 +- .../mr/device/logging_resource_adaptor.hpp | 23 +++--- python/librmm/librmm/__init__.py | 5 +- python/librmm/librmm/load.py | 25 +++++++ python/librmm/pyproject.toml | 4 ++ python/rmm/CMakeLists.txt | 6 +- python/rmm/docs/conf.py | 6 +- python/rmm/pyproject.toml | 1 + python/rmm/rmm/__init__.py | 11 ++- python/rmm/rmm/_cuda/CMakeLists.txt | 2 +- python/rmm/rmm/librmm/CMakeLists.txt | 4 +- python/rmm/rmm/librmm/_logger.pxd | 6 +- python/rmm/rmm/pylibrmm/CMakeLists.txt | 2 +- tests/CMakeLists.txt | 14 +--- tests/logger_tests.cpp | 6 +- tests/mr/device/tracking_mr_tests.cpp | 6 +- 31 files changed, 228 insertions(+), 146 deletions(-) delete mode 100644 cmake/thirdparty/get_spdlog.cmake create mode 100644 include/rmm/logger.hpp create mode 100644 python/librmm/librmm/load.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 859e4022e..480ae4445 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,8 +74,8 @@ rapids_find_package( rapids_cpm_init() include(${rapids-cmake-dir}/cpm/rapids_logger.cmake) -rapids_cpm_rapids_logger() -rapids_make_logger(rmm EXPORT_SET rmm-exports) +rapids_cpm_rapids_logger(BUILD_EXPORT_SET rmm-exports INSTALL_EXPORT_SET rmm-exports) +create_logger_macros(RMM "rmm::default_logger()" include/rmm) include(cmake/thirdparty/get_cccl.cmake) include(cmake/thirdparty/get_nvtx.cmake) @@ -86,8 +86,10 @@ include(cmake/thirdparty/get_nvtx.cmake) add_library(rmm INTERFACE) add_library(rmm::rmm ALIAS rmm) -target_include_directories(rmm INTERFACE "$" - "$") +target_include_directories( + rmm + INTERFACE "$" + "$" "$") if(CUDA_STATIC_RUNTIME) message(STATUS "RMM: Enabling static linking of cudart") @@ -96,10 +98,10 @@ else() target_link_libraries(rmm INTERFACE CUDA::cudart) endif() -target_link_libraries(rmm INTERFACE rmm_logger) target_link_libraries(rmm INTERFACE CCCL::CCCL) target_link_libraries(rmm INTERFACE dl) target_link_libraries(rmm INTERFACE nvtx3::nvtx3-cpp) +target_link_libraries(rmm INTERFACE rapids_logger::rapids_logger) target_compile_features(rmm INTERFACE cxx_std_17 $) target_compile_definitions(rmm INTERFACE LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE) diff --git a/README.md b/README.md index 44c262ac5..54bab2eab 100644 --- a/README.md +++ b/README.md @@ -645,17 +645,16 @@ set to `True`. The log file name can be set using the `log_file_name` parameter. ### Debug Logging -RMM includes a debug logger which can be enabled to log trace and debug information to a file. This -information can show when errors occur, when additional memory is allocated from upstream resources, -etc. By default output is logged to stderr, but the environment variable -`RMM_DEBUG_LOG_FILE` can be set to specify a path and file name to dump the logs to instead. +RMM leverages [`rapids-logger`](https://github.com/rapidsai/rapids-logger) to log trace and debug +information to a file. This information can show when errors occur, when additional memory is +allocated from upstream resources, etc. By default output is logged to stderr, but the environment +variable `RMM_DEBUG_LOG_FILE` can be set to specify a path and file name to dump the logs to +instead. There is a CMake configuration variable `RMM_LOGGING_LEVEL`, which can be set to enable compilation of more detailed logging. The default is `INFO`. Available levels are `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `CRITICAL` and `OFF`. -The log relies on the [spdlog](https://github.com/gabime/spdlog.git) library. - Note that to see logging below the `INFO` level, the application must also set the logging level at run time. C++ applications must must call `rmm::default_logger().set_level()`, for example to enable all levels of logging down to `TRACE`, call `rmm::default_logger().set_level(spdlog::level::trace)` (and compile diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index b3b60cfcb..adf24a969 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2018-2024, NVIDIA CORPORATION. +# Copyright (c) 2018-2025, 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 @@ -45,8 +45,6 @@ function(ConfigureBench BENCH_NAME) target_compile_options(${BENCH_NAME} PUBLIC $<$:-Wall -Werror -Wno-unknown-pragmas>) - target_link_libraries(${BENCH_NAME} PRIVATE rmm_bench_logger) - if(DISABLE_DEPRECATION_WARNING) target_compile_options( ${BENCH_NAME} PUBLIC $<$:-Xcompiler=-Wno-deprecated-declarations>) @@ -61,10 +59,6 @@ function(ConfigureBench BENCH_NAME) EXCLUDE_FROM_ALL) endfunction(ConfigureBench) -# Create an object library for the logger so that we don't have to recompile it. -add_library(rmm_bench_logger OBJECT) -target_link_libraries(rmm_bench_logger PRIVATE rmm_logger_impl) - # random allocations benchmark ConfigureBench(RANDOM_ALLOCATIONS_BENCH random_allocations/random_allocations.cpp) diff --git a/benchmarks/replay/replay.cpp b/benchmarks/replay/replay.cpp index 8edbf11f9..c115d9e42 100644 --- a/benchmarks/replay/replay.cpp +++ b/benchmarks/replay/replay.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -403,7 +403,7 @@ int main(int argc, char** argv) auto const num_threads = per_thread_events.size(); // Uncomment to enable / change default log level - // rmm::logger().set_level(rmm::level_enum::trace); + // rmm::logger().set_level(rapids_logger::level_enum::trace); if (args.count("resource") > 0) { std::string mr_name = args["resource"].as(); diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index c61397fe2..3fff53dfe 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -30,7 +30,10 @@ PIP_CONSTRAINT="${PWD}/build-constraints.txt" \ sccache --show-adv-stats mkdir -p final_dist -python -m auditwheel repair -w final_dist dist/* +EXCLUDE_ARGS=( + --exclude "librapids_logger.so" +) +python -m auditwheel repair "${EXCLUDE_ARGS[@]}" -w final_dist dist/* ../../ci/validate_wheel.sh final_dist diff --git a/ci/check_symbols.sh b/ci/check_symbols.sh index 377a93cac..688862aaf 100755 --- a/ci/check_symbols.sh +++ b/ci/check_symbols.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2024, NVIDIA CORPORATION. +# Copyright (c) 2024-2025, NVIDIA CORPORATION. set -eEuo pipefail @@ -47,17 +47,6 @@ for dso_file in ${dso_files}; do echo " * WEAK: $(grep --count -E ' WEAK ' < ${symbol_file})" echo " * LOCAL: $(grep --count -E ' LOCAL ' < ${symbol_file})" - echo "checking for 'fmt::' symbols..." - if grep -E 'fmt\:\:' < "${symbol_file}"; then - raise-symbols-found-error 'fmt::' - fi - - echo "checking for 'spdlog::' symbols..." - if grep -E 'spdlog\:\:' < "${symbol_file}" \ - | grep -v 'std\:\:_Destroy_aux' - then - raise-symbols-found-error 'spdlog::' - fi echo "No symbol visibility issues found" done diff --git a/ci/test_wheel.sh b/ci/test_wheel.sh index f3807afdd..ef53afa12 100755 --- a/ci/test_wheel.sh +++ b/ci/test_wheel.sh @@ -5,6 +5,7 @@ set -eou pipefail RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}")" WHEELHOUSE="${PWD}/dist/" +RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp "${WHEELHOUSE}" RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 python "${WHEELHOUSE}" # generate constraints (possibly pinning to oldest support versions of dependencies) @@ -14,6 +15,7 @@ rapids-generate-pip-constraints test_python ./constraints.txt rapids-pip-retry install \ -v \ --constraint ./constraints.txt \ + "$(echo "${WHEELHOUSE}"/librmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)" \ "$(echo "${WHEELHOUSE}"/rmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)[test]" python -m pytest ./python/rmm/rmm/tests diff --git a/cmake/thirdparty/get_spdlog.cmake b/cmake/thirdparty/get_spdlog.cmake deleted file mode 100644 index febdf4c5c..000000000 --- a/cmake/thirdparty/get_spdlog.cmake +++ /dev/null @@ -1,33 +0,0 @@ -# ============================================================================= -# Copyright (c) 2021-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. -# ============================================================================= - -# Use CPM to find or clone speedlog. -function(find_and_configure_spdlog) - - include(${rapids-cmake-dir}/cpm/spdlog.cmake) - rapids_cpm_spdlog( - # The conda package for fmt is hard-coded to assume that we use a preexisting fmt library. This - # is why we have always had a libfmt linkage despite choosing to specify the header-only version - # of fmt. We need a more robust way of modifying this to support fully self-contained build and - # usage even in environments where fmt and/or spdlog are already present. The crudest solution - # would be to modify the interface compile definitions and link libraries of the spdlog target, - # if necessary. For now I'm specifying EXTERNAL_FMT_HO here so that in environments where spdlog - # is cloned and built from source we wind up with the behavior that we expect, but we'll have to - # resolve this properly eventually. - FMT_OPTION "EXTERNAL_FMT_HO" - INSTALL_EXPORT_SET rmm-exports - BUILD_EXPORT_SET rmm-exports) -endfunction() - -find_and_configure_spdlog() diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index daba1b604..6dfc4771a 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -16,7 +16,6 @@ dependencies: - cxx-compiler - cython>=3.0.0 - doxygen=1.9.1 -- fmt>=11.0.2,<12 - gcc_linux-64=11.* - gcovr>=5.0 - graphviz @@ -34,8 +33,8 @@ dependencies: - pytest-cov - python>=3.10,<3.13 - rapids-build-backend>=0.3.0,<0.4.0.dev0 +- rapids-logger==0.1.*,>=0.0.0a0 - scikit-build-core >=0.10.0 -- spdlog>=1.14.1,<1.15 - sphinx - sphinx-copybutton - sphinx-markdown-tables diff --git a/conda/environments/all_cuda-128_arch-x86_64.yaml b/conda/environments/all_cuda-128_arch-x86_64.yaml index e22c9b5c3..c4eddb72a 100644 --- a/conda/environments/all_cuda-128_arch-x86_64.yaml +++ b/conda/environments/all_cuda-128_arch-x86_64.yaml @@ -16,7 +16,6 @@ dependencies: - cxx-compiler - cython>=3.0.0 - doxygen=1.9.1 -- fmt>=11.0.2,<12 - gcc_linux-64=13.* - gcovr>=5.0 - graphviz @@ -33,8 +32,8 @@ dependencies: - pytest-cov - python>=3.10,<3.13 - rapids-build-backend>=0.3.0,<0.4.0.dev0 +- rapids-logger==0.1.*,>=0.0.0a0 - scikit-build-core >=0.10.0 -- spdlog>=1.14.1,<1.15 - sphinx - sphinx-copybutton - sphinx-markdown-tables diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index 2980a8d5c..83f5ebcb1 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -18,9 +18,3 @@ c_stdlib_version: cmake_version: - ">=3.26.4,!=3.30.0" - -fmt_version: - - ">=11.0.2,<12" - -spdlog_version: - - ">=1.14.1,<1.15" diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml index 22f53cdc6..f927315c6 100644 --- a/conda/recipes/librmm/meta.yaml +++ b/conda/recipes/librmm/meta.yaml @@ -26,8 +26,7 @@ requirements: - {{ stdlib("c") }} host: - cuda-version ={{ cuda_version }} - - fmt {{ fmt_version }} - - spdlog {{ spdlog_version }} + - rapids-logger =0.1 build: script_env: @@ -68,8 +67,7 @@ outputs: {% if cuda_major == "11" %} - cudatoolkit {% endif %} - - fmt {{ fmt_version }} - - spdlog {{ spdlog_version }} + - rapids-logger =0.1 test: commands: - test -d "${PREFIX}/include/rmm" diff --git a/dependencies.yaml b/dependencies.yaml index d010a9972..a50d0f884 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -11,6 +11,7 @@ files: - checks - cuda - cuda_version + - depends_on_rapids_logger - develop - docs - py_version @@ -54,6 +55,14 @@ files: key: requires includes: - build + - depends_on_rapids_logger + py_cpp_run: + output: pyproject + pyproject_dir: python/librmm + extras: + table: project + includes: + - depends_on_rapids_logger py_build: output: pyproject pyproject_dir: python/rmm @@ -70,6 +79,7 @@ files: includes: - build - cython_build + - depends_on_librmm py_run: output: pyproject pyproject_dir: python/rmm @@ -77,6 +87,7 @@ files: table: project includes: - run + - depends_on_librmm py_optional_test: output: pyproject pyproject_dir: python/rmm @@ -111,8 +122,6 @@ dependencies: packages: - c-compiler - cxx-compiler - - fmt>=11.0.2,<12 - - spdlog>=1.14.1,<1.15 specific: - output_types: conda matrices: @@ -171,21 +180,33 @@ dependencies: - matrix: # All CUDA 11 versions packages: - &cuda_python11 cuda-python>=11.8.5,<12.0a0 + depends_on_librmm: + common: + - output_types: conda + packages: + - &librmm_unsuffixed librmm==25.4.*,>=0.0.0a0 + - output_types: requirements + packages: + # pip recognizes the index as a global option for the requirements.txt file + # This index is needed for librmm-cu{11,12}. + - --extra-index-url=https://pypi.nvidia.com + - --extra-index-url=https://pypi.anaconda.org/rapidsai-wheels-nightly/simple + specific: - output_types: [requirements, pyproject] matrices: - - matrix: - cuda: "12.*" - cuda_suffixed: "true" - packages: - - librmm-cu12==25.4.*,>=0.0.0a0 - - matrix: - cuda: "11.*" - cuda_suffixed: "true" - packages: - - librmm-cu11==25.4.*,>=0.0.0a0 - - matrix: null - packages: - - librmm==25.4.*,>=0.0.0a0 + - matrix: + cuda: "12.*" + cuda_suffixed: "true" + packages: + - librmm-cu12==25.4.*,>=0.0.0a0 + - matrix: + cuda: "11.*" + cuda_suffixed: "true" + packages: + - librmm-cu11==25.4.*,>=0.0.0a0 + - matrix: + packages: + - *librmm_unsuffixed checks: common: - output_types: [conda, requirements] @@ -338,3 +359,14 @@ dependencies: - numpy==1.23.* - matrix: packages: + depends_on_rapids_logger: + common: + - output_types: [conda, requirements, pyproject] + packages: + - rapids-logger==0.1.*,>=0.0.0a0 + - output_types: requirements + packages: + # pip recognizes the index as a global option for the requirements.txt file + # This index is needed for rapids_logger + - --extra-index-url=https://pypi.nvidia.com + - --extra-index-url=https://pypi.anaconda.org/rapidsai-wheels-nightly/simple diff --git a/include/rmm/logger.hpp b/include/rmm/logger.hpp new file mode 100644 index 000000000..acbc69e77 --- /dev/null +++ b/include/rmm/logger.hpp @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2025, 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. + */ + +#pragma once + +#include +#include + +#include + +namespace RMM_NAMESPACE { + +/** + * @brief Returns the default sink for the global logger. + * + * If the environment variable `RMM_DEBUG_LOG_FILE` is defined, the default sink is a sink to that + * file. Otherwise, the default is to dump to stderr. + * + * @return sink_ptr The sink to use + */ +inline rapids_logger::sink_ptr default_sink() +{ + auto* filename = std::getenv("RMM_DEBUG_LOG_FILE"); + if (filename != nullptr) { + return std::make_shared(filename, true); + } + return std::make_shared(); +} + +/** + * @brief Returns the default log pattern for the global logger. + * + * @return std::string The default log pattern. + */ +inline std::string default_pattern() { return "[%6t][%H:%M:%S:%f][%-6l] %v"; } + +/** + * @brief Get the default logger. + * + * @return logger& The default logger + */ +inline rapids_logger::logger& default_logger() +{ + static rapids_logger::logger logger_ = [] { + rapids_logger::logger logger_{"RMM", {default_sink()}}; + logger_.set_pattern(default_pattern()); +#if RMM_LOG_ACTIVE_LEVEL <= RMM_LOG_LEVEL_DEBUG +#ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM + logger_.debug("----- RMM LOG [PTDS ENABLED] -----"); +#else + logger_.debug("----- RMM LOG [PTDS DISABLED] -----"); +#endif +#endif + return logger_; + }(); + return logger_; +} + +} // namespace RMM_NAMESPACE diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index fe07aab04..f8e4e16cb 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -96,9 +96,10 @@ class arena_memory_resource final : public device_memory_resource { : global_arena_{upstream_mr, arena_size}, dump_log_on_failure_{dump_log_on_failure} { if (dump_log_on_failure_) { - logger_ = std::make_shared("arena_memory_dump", "rmm_arena_memory_dump.log"); + logger_ = + std::make_shared("arena_memory_dump", "rmm_arena_memory_dump.log"); // Set the level to `debug` for more detailed output. - logger_->set_level(level_enum::info); + logger_->set_level(rapids_logger::level_enum::info); } } @@ -352,7 +353,7 @@ class arena_memory_resource final : public device_memory_resource { /// If true, dump memory information to log on allocation failure. bool dump_log_on_failure_{}; /// The logger for memory dump. - std::shared_ptr logger_{}; + std::shared_ptr logger_{}; /// Mutex for read and write locks on arena maps. mutable std::shared_mutex map_mtx_; /// Mutex for shared and unique locks on the mr. diff --git a/include/rmm/mr/device/detail/arena.hpp b/include/rmm/mr/device/detail/arena.hpp index 20095d504..de09a1a53 100644 --- a/include/rmm/mr/device/detail/arena.hpp +++ b/include/rmm/mr/device/detail/arena.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2024, NVIDIA CORPORATION. + * Copyright (c) 2019-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -645,7 +645,7 @@ class global_arena final { * * @param logger the logger to use */ - void dump_memory_log(std::shared_ptr const& logger) const + void dump_memory_log(std::shared_ptr const& logger) const { std::lock_guard lock(mtx_); diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 2d2291e3f..4f62d842b 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -113,7 +113,7 @@ class logging_resource_adaptor final : public device_memory_resource { * performance. */ logging_resource_adaptor(Upstream* upstream, - std::initializer_list sinks, + std::initializer_list sinks, bool auto_flush = false) : logging_resource_adaptor{to_device_async_resource_ref_checked(upstream), sinks, auto_flush} { @@ -178,7 +178,7 @@ class logging_resource_adaptor final : public device_memory_resource { * performance. */ logging_resource_adaptor(device_async_resource_ref upstream, - std::initializer_list sinks, + std::initializer_list sinks, bool auto_flush = false) : logging_resource_adaptor{make_logger(sinks), upstream, auto_flush} { @@ -232,24 +232,27 @@ class logging_resource_adaptor final : public device_memory_resource { } private: - static auto make_logger(std::ostream& stream) { return std::make_shared("RMM", stream); } + static auto make_logger(std::ostream& stream) + { + return std::make_shared("RMM", stream); + } static auto make_logger(std::string const& filename) { - return std::make_shared("RMM", filename); + return std::make_shared("RMM", filename); } - static auto make_logger(std::initializer_list sinks) + static auto make_logger(std::initializer_list sinks) { - return std::make_shared("RMM", sinks); + return std::make_shared("RMM", sinks); } - logging_resource_adaptor(std::shared_ptr logger, + logging_resource_adaptor(std::shared_ptr logger, device_async_resource_ref upstream, bool auto_flush) : logger_{logger}, upstream_{upstream} { - if (auto_flush) { logger_->flush_on(level_enum::info); } + if (auto_flush) { logger_->flush_on(rapids_logger::level_enum::info); } logger_->set_pattern("%v"); logger_->info(header()); logger_->set_pattern("%t,%H:%M:%S.%f,%v"); @@ -328,7 +331,7 @@ class logging_resource_adaptor final : public device_memory_resource { return get_upstream_resource() == cast->get_upstream_resource(); } - std::shared_ptr logger_{}; + std::shared_ptr logger_{}; device_async_resource_ref upstream_; ///< The upstream resource used for satisfying ///< allocation requests diff --git a/python/librmm/librmm/__init__.py b/python/librmm/librmm/__init__.py index b914ecdc3..fac8ca0cb 100644 --- a/python/librmm/librmm/__init__.py +++ b/python/librmm/librmm/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2024, NVIDIA CORPORATION. +# Copyright (c) 2024-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,3 +13,6 @@ # limitations under the License. from librmm._version import __git_commit__, __version__ +from librmm.load import load_library + +__all__ = ["__git_commit__", "__version__", "load_library"] diff --git a/python/librmm/librmm/load.py b/python/librmm/librmm/load.py new file mode 100644 index 000000000..1d32434f8 --- /dev/null +++ b/python/librmm/librmm/load.py @@ -0,0 +1,25 @@ +# Copyright (c) 2025, 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. +# + + +def load_library(): + """Librmm is header-only, this function loads its (non-header-only) dependencies""" + try: + import rapids_logger + except ModuleNotFoundError: + pass + else: + rapids_logger.load_library() + del rapids_logger diff --git a/python/librmm/pyproject.toml b/python/librmm/pyproject.toml index 6fee31c9a..f7a6f7088 100644 --- a/python/librmm/pyproject.toml +++ b/python/librmm/pyproject.toml @@ -36,6 +36,9 @@ classifiers = [ "Programming Language :: C++", "Environment :: GPU :: NVIDIA CUDA", ] +dependencies = [ + "rapids-logger==0.1.*,>=0.0.0a0", +] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. [project.urls] Homepage = "https://github.com/rapidsai/rmm" @@ -50,6 +53,7 @@ matrix-entry = "cuda_suffixed=true" requires = [ "cmake>=3.26.4,!=3.30.0", "ninja", + "rapids-logger==0.1.*,>=0.0.0a0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. [tool.scikit-build] diff --git a/python/rmm/CMakeLists.txt b/python/rmm/CMakeLists.txt index a39ac8868..2ee07605b 100644 --- a/python/rmm/CMakeLists.txt +++ b/python/rmm/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2022-2024, NVIDIA CORPORATION. +# Copyright (c) 2022-2025, 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 @@ -29,10 +29,6 @@ rapids_cython_init() # pass through logging level to spdlog add_compile_definitions("RMM_LOG_ACTIVE_LEVEL=RMM_LOG_LEVEL_${RMM_LOGGING_LEVEL}") -# Create an object library for the logger so that we don't have to recompile it. -add_library(cpp_logger OBJECT) -target_link_libraries(cpp_logger PRIVATE rmm::rmm_logger_impl) - add_subdirectory(rmm/_cuda) add_subdirectory(rmm/librmm) add_subdirectory(rmm/pylibrmm) diff --git a/python/rmm/docs/conf.py b/python/rmm/docs/conf.py index a21698ded..b81f309ce 100644 --- a/python/rmm/docs/conf.py +++ b/python/rmm/docs/conf.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2024, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Configuration file for the Sphinx documentation builder. # @@ -238,8 +238,8 @@ def on_missing_reference(app, env, node, contnode): "thrust", "spdlog", "stream_ref", - # logger names (we may eventually want to link out for those) - "sink_ptr", + # rapids_logger names + "rapids_logger", # libcu++ names "cuda", "cuda::mr", diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index d457b0913..2771ee027 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -31,6 +31,7 @@ license = { text = "Apache 2.0" } requires-python = ">=3.10" dependencies = [ "cuda-python>=11.8.5,<12.0a0", + "librmm==25.4.*,>=0.0.0a0", "numpy>=1.23,<3.0a0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. classifiers = [ diff --git a/python/rmm/rmm/__init__.py b/python/rmm/rmm/__init__.py index f1d6e2d7e..c813ec42b 100644 --- a/python/rmm/rmm/__init__.py +++ b/python/rmm/rmm/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018-2024, NVIDIA CORPORATION. +# Copyright (c) 2018-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,6 +14,15 @@ import warnings +# This path is only taken for wheels where librmm is a separate Python package. +try: + import librmm +except ModuleNotFoundError: + pass +else: + librmm.load_library() + del librmm + from rmm import mr from rmm._version import __git_commit__, __version__ from rmm.mr import disable_logging, enable_logging, get_log_filenames diff --git a/python/rmm/rmm/_cuda/CMakeLists.txt b/python/rmm/rmm/_cuda/CMakeLists.txt index 1617ead7f..f45c07aea 100644 --- a/python/rmm/rmm/_cuda/CMakeLists.txt +++ b/python/rmm/rmm/_cuda/CMakeLists.txt @@ -12,7 +12,7 @@ # the License. # ============================================================================= -set(linked_libraries rmm::rmm cpp_logger) +set(linked_libraries rmm::rmm) rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}" CXX) diff --git a/python/rmm/rmm/librmm/CMakeLists.txt b/python/rmm/rmm/librmm/CMakeLists.txt index dc807fdba..006b24227 100644 --- a/python/rmm/rmm/librmm/CMakeLists.txt +++ b/python/rmm/rmm/librmm/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2022-2024, NVIDIA CORPORATION. +# Copyright (c) 2022-2025, 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 @@ -13,7 +13,7 @@ # ============================================================================= set(cython_sources _logger.pyx) -set(linked_libraries rmm::rmm cpp_logger) +set(linked_libraries rmm::rmm) # Build all of the Cython targets rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}" diff --git a/python/rmm/rmm/librmm/_logger.pxd b/python/rmm/rmm/librmm/_logger.pxd index bd0728bc1..b820b4e4e 100644 --- a/python/rmm/rmm/librmm/_logger.pxd +++ b/python/rmm/rmm/librmm/_logger.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2023-2024, NVIDIA CORPORATION. +# Copyright (c) 2023-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ from libcpp cimport bool from libcpp.string cimport string -cdef extern from "rmm/logger.hpp" namespace "rmm" nogil: +cdef extern from "rapids_logger/logger.hpp" namespace "rapids_logger" nogil: cpdef enum class level_enum: trace debug @@ -36,4 +36,6 @@ cdef extern from "rmm/logger.hpp" namespace "rmm" nogil: level_enum flush_level() except + bool should_log(level_enum msg_level) except + + +cdef extern from "rmm/logger.hpp" namespace "rmm" nogil: cdef logger& default_logger() except + diff --git a/python/rmm/rmm/pylibrmm/CMakeLists.txt b/python/rmm/rmm/pylibrmm/CMakeLists.txt index 1be58c32e..56399fd4e 100644 --- a/python/rmm/rmm/pylibrmm/CMakeLists.txt +++ b/python/rmm/rmm/pylibrmm/CMakeLists.txt @@ -14,7 +14,7 @@ set(cython_sources device_buffer.pyx logger.pyx memory_resource.pyx cuda_stream.pyx helper.pyx stream.pyx) -set(linked_libraries rmm::rmm cpp_logger) +set(linked_libraries rmm::rmm) # Build all of the Cython targets rapids_cython_create_modules(SOURCE_FILES "${cython_sources}" LINKED_LIBRARIES "${linked_libraries}" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 413f27f26..d026c56e2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2018-2024, NVIDIA CORPORATION. +# Copyright (c) 2018-2025, 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 @@ -44,8 +44,6 @@ function(ConfigureTestInternal TEST_NAME) PUBLIC "RMM_LOG_ACTIVE_LEVEL=RMM_LOG_LEVEL_${RMM_LOGGING_LEVEL}") target_compile_options(${TEST_NAME} PUBLIC $<$:-Wall -Werror>) - target_link_libraries(${TEST_NAME} PRIVATE rmm_test_logger) - if(DISABLE_DEPRECATION_WARNING) target_compile_options( ${TEST_NAME} PUBLIC $<$:-Xcompiler=-Wno-deprecated-declarations>) @@ -130,12 +128,6 @@ function(ConfigureTest TEST_NAME) endfunction() -# Create an object library for the logger so that we don't have to recompile it. -add_library(rmm_test_logger OBJECT) -target_link_libraries(rmm_test_logger PRIVATE rmm_logger_impl) - -include(../cmake/thirdparty/get_spdlog.cmake) - # test sources # device mr_ref tests @@ -168,8 +160,6 @@ ConfigureTest(STATISTICS_TEST mr/device/statistics_mr_tests.cpp) # tracking adaptor tests ConfigureTest(TRACKING_TEST mr/device/tracking_mr_tests.cpp) -target_link_libraries(TRACKING_TEST PRIVATE spdlog::spdlog_header_only) -target_link_libraries(TRACKING_PTDS_TEST PRIVATE spdlog::spdlog_header_only) # out-of-memory callback adaptor tests ConfigureTest(FAILURE_CALLBACK_TEST mr/device/failure_callback_mr_tests.cpp) @@ -206,8 +196,6 @@ ConfigureTest(PREFETCH_TEST prefetch_tests.cpp) # logger tests ConfigureTest(LOGGER_TEST logger_tests.cpp) -target_link_libraries(LOGGER_TEST PRIVATE spdlog::spdlog_header_only) -target_link_libraries(LOGGER_PTDS_TEST PRIVATE spdlog::spdlog_header_only) # arena MR tests ConfigureTest(ARENA_MR_TEST mr/device/arena_mr_tests.cpp GPUS 1 PERCENT 100) diff --git a/tests/logger_tests.cpp b/tests/logger_tests.cpp index 619143294..6f4ab96cd 100644 --- a/tests/logger_tests.cpp +++ b/tests/logger_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -152,8 +152,8 @@ TEST(Adaptor, MultiSinkConstructor) std::string filename2{temp_dir.generate_path("test_multi_2.txt")}; rmm::mr::cuda_memory_resource upstream; - auto file_sink1 = std::make_shared(filename1, true); - auto file_sink2 = std::make_shared(filename2, true); + auto file_sink1 = std::make_shared(filename1, true); + auto file_sink2 = std::make_shared(filename2, true); rmm::mr::logging_resource_adaptor log_mr{&upstream, {file_sink1, file_sink2}}; diff --git a/tests/mr/device/tracking_mr_tests.cpp b/tests/mr/device/tracking_mr_tests.cpp index c40a9127d..f723e0c65 100644 --- a/tests/mr/device/tracking_mr_tests.cpp +++ b/tests/mr/device/tracking_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -202,7 +202,7 @@ TEST(TrackingTest, DeallocWrongBytes) TEST(TrackingTest, LogOutstandingAllocations) { std::ostringstream oss; - auto oss_sink = std::make_shared(oss); + auto oss_sink = std::make_shared(oss); auto old_level = rmm::default_logger().level(); rmm::default_logger().sinks().push_back(oss_sink); @@ -212,7 +212,7 @@ TEST(TrackingTest, LogOutstandingAllocations) allocations.push_back(mr.allocate(ten_MiB)); } - rmm::default_logger().set_level(rmm::level_enum::debug); + rmm::default_logger().set_level(rapids_logger::level_enum::debug); EXPECT_NO_THROW(mr.log_outstanding_allocations()); #if RMM_LOG_ACTIVE_LEVEL <= RMM_LOG_LEVEL_DEBUG From ac8a99bdf285d6066e2158be9e4454b7095b6f6b Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 10 Feb 2025 15:24:30 -0800 Subject: [PATCH 550/675] Remove unnecessary index (#1820) Addresses https://github.com/rapidsai/rmm/pull/1808#discussion_r1950013925 Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1820 --- dependencies.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/dependencies.yaml b/dependencies.yaml index a50d0f884..9a79a0fc3 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -367,6 +367,4 @@ dependencies: - output_types: requirements packages: # pip recognizes the index as a global option for the requirements.txt file - # This index is needed for rapids_logger - - --extra-index-url=https://pypi.nvidia.com - --extra-index-url=https://pypi.anaconda.org/rapidsai-wheels-nightly/simple From 670dcbb0eeca35f3674c54ddee1a2c427fa7f573 Mon Sep 17 00:00:00 2001 From: Nicholas Sielicki Date: Tue, 11 Feb 2025 04:27:21 -0800 Subject: [PATCH 551/675] mr/host: fix incorrect docs usage of device_memory_resource (#1809) A pair of doxygen comments in `host_memory_resource` referenced `device_memory_resource` when it didn't mean to, very likely a simple copy/paste issue. #1794 Authors: - Nicholas Sielicki (https://github.com/aws-nslick) - Bradley Dice (https://github.com/bdice) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1809 --- include/rmm/mr/host/host_memory_resource.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/rmm/mr/host/host_memory_resource.hpp b/include/rmm/mr/host/host_memory_resource.hpp index 71c63cfb3..9bcd1c9eb 100644 --- a/include/rmm/mr/host/host_memory_resource.hpp +++ b/include/rmm/mr/host/host_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -121,7 +121,7 @@ class host_memory_resource { } /** - * @brief Comparison operator with another device_memory_resource + * @brief Comparison operator with another host_memory_resource * * @param other The other resource to compare to * @return true If the two resources are equivalent @@ -133,7 +133,7 @@ class host_memory_resource { } /** - * @brief Comparison operator with another device_memory_resource + * @brief Comparison operator with another host_memory_resource * * @param other The other resource to compare to * @return false If the two resources are equivalent From 6e8539e42d51852faab5f9b330232168f9223eee Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 11 Feb 2025 07:17:04 -0800 Subject: [PATCH 552/675] Apply IWYU changes and fix deprecated GTest usage (#1821) This is a cleanup PR. I found that we were extraneously including `` in the pool memory resource (also `thrust::optional` is deprecated in favor of `cuda::std::optional` in the upcoming major release of CCCL). I did a pass with IWYU to see what else could be fixed. IWYU could only really analyze our tests, since RMM is header-only. There are a lot of false positives/negatives, so I don't think it is appropriate to automate IWYU in our CI. However, this felt valuable enough to open a refactoring PR. I also updated some deprecated GTest code which was using `TYPED_TEST_CASE` instead of `TYPED_TEST_SUITE` and replaced some uses of `::value` with the corresponding `_v` STL features. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Lawrence Mitchell (https://github.com/wence-) URL: https://github.com/rapidsai/rmm/pull/1821 --- include/rmm/cuda_device.hpp | 5 ++++- include/rmm/cuda_stream_view.hpp | 4 +--- include/rmm/detail/aligned.hpp | 4 +--- include/rmm/detail/runtime_async_alloc.hpp | 5 +---- include/rmm/detail/stack_trace.hpp | 4 +--- include/rmm/device_buffer.hpp | 3 +-- include/rmm/device_scalar.hpp | 4 ++-- include/rmm/device_uvector.hpp | 9 +++++---- include/rmm/mr/device/aligned_resource_adaptor.hpp | 3 +-- include/rmm/mr/device/binning_memory_resource.hpp | 3 +-- .../rmm/mr/device/cuda_async_memory_resource.hpp | 3 +-- .../mr/device/cuda_async_view_memory_resource.hpp | 3 +-- .../rmm/mr/device/detail/coalescing_free_list.hpp | 5 +++-- .../rmm/mr/device/detail/fixed_size_free_list.hpp | 3 +-- include/rmm/mr/device/detail/free_list.hpp | 4 +++- .../detail/stream_ordered_memory_resource.hpp | 6 +++++- include/rmm/mr/device/device_memory_resource.hpp | 3 +-- .../rmm/mr/device/fixed_size_memory_resource.hpp | 4 +--- include/rmm/mr/device/limiting_resource_adaptor.hpp | 3 ++- include/rmm/mr/device/logging_resource_adaptor.hpp | 5 +++-- include/rmm/mr/device/owning_wrapper.hpp | 4 +--- include/rmm/mr/device/polymorphic_allocator.hpp | 3 +-- include/rmm/mr/device/pool_memory_resource.hpp | 9 +-------- include/rmm/mr/device/prefetch_resource_adaptor.hpp | 5 +---- .../rmm/mr/device/sam_headroom_memory_resource.hpp | 5 ++++- include/rmm/mr/device/system_memory_resource.hpp | 5 ++++- include/rmm/mr/device/tracking_resource_adaptor.hpp | 3 ++- include/rmm/mr/host/host_memory_resource.hpp | 1 - include/rmm/mr/host/new_delete_resource.hpp | 3 +-- include/rmm/mr/host/pinned_memory_resource.hpp | 3 +-- include/rmm/mr/pinned_host_memory_resource.hpp | 3 +-- tests/container_multidevice_tests.cu | 7 +++++-- tests/cuda_stream_pool_tests.cpp | 4 +++- tests/cuda_stream_tests.cpp | 4 +++- tests/device_buffer_tests.cu | 4 ++-- tests/device_scalar_tests.cpp | 13 ++++++------- tests/device_uvector_tests.cpp | 8 ++++++-- tests/logger_tests.cpp | 7 +++++-- tests/mr/device/adaptor_tests.cpp | 8 ++++---- tests/mr/device/aligned_mr_tests.cpp | 6 ++++-- tests/mr/device/arena_mr_tests.cpp | 10 ++++++---- tests/mr/device/binning_mr_tests.cpp | 3 ++- tests/mr/device/callback_mr_tests.cpp | 8 ++++---- tests/mr/device/cuda_async_mr_tests.cpp | 5 +++-- tests/mr/device/failure_callback_mr_tests.cpp | 5 ++--- tests/mr/device/limiting_mr_tests.cpp | 5 ++--- tests/mr/device/mr_ref_multithreaded_tests.cpp | 4 ++-- tests/mr/device/polymorphic_allocator_tests.cpp | 5 +++-- tests/mr/device/pool_mr_tests.cpp | 8 +++++--- tests/mr/device/prefetch_resource_adaptor_tests.cpp | 4 ++-- tests/mr/device/statistics_mr_tests.cpp | 9 +++++++-- tests/mr/device/stream_allocator_adaptor_tests.cpp | 12 ++++++------ tests/mr/device/system_mr_tests.cu | 8 ++++++-- tests/mr/device/thrust_allocator_tests.cu | 4 ++-- tests/mr/device/tracking_mr_tests.cpp | 5 +++++ tests/mr/host/mr_ref_tests.cpp | 4 ++-- tests/mr/host/pinned_pool_mr_tests.cpp | 7 ++----- tests/prefetch_tests.cpp | 4 ++-- 58 files changed, 157 insertions(+), 141 deletions(-) diff --git a/include/rmm/cuda_device.hpp b/include/rmm/cuda_device.hpp index 124404679..2b56d6d0a 100644 --- a/include/rmm/cuda_device.hpp +++ b/include/rmm/cuda_device.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, NVIDIA CORPORATION. + * Copyright (c) 2021-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,9 @@ #include +#include +#include + namespace RMM_NAMESPACE { struct cuda_device_id; diff --git a/include/rmm/cuda_stream_view.hpp b/include/rmm/cuda_stream_view.hpp index 2aaa17a59..d1b8aff15 100644 --- a/include/rmm/cuda_stream_view.hpp +++ b/include/rmm/cuda_stream_view.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,9 +22,7 @@ #include #include -#include #include -#include namespace RMM_NAMESPACE { /** diff --git a/include/rmm/detail/aligned.hpp b/include/rmm/detail/aligned.hpp index 6d4f5244f..69bdaf410 100644 --- a/include/rmm/detail/aligned.hpp +++ b/include/rmm/detail/aligned.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,9 +21,7 @@ #include #include -#include #include -#include namespace RMM_NAMESPACE { namespace detail { diff --git a/include/rmm/detail/runtime_async_alloc.hpp b/include/rmm/detail/runtime_async_alloc.hpp index 6ddb2228b..833d8659a 100644 --- a/include/rmm/detail/runtime_async_alloc.hpp +++ b/include/rmm/detail/runtime_async_alloc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024, NVIDIA CORPORATION. + * Copyright (c) 2022-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,9 +22,6 @@ #include -#include -#include - namespace RMM_NAMESPACE { namespace detail { diff --git a/include/rmm/detail/stack_trace.hpp b/include/rmm/detail/stack_trace.hpp index 0886ceb51..98b281aa4 100644 --- a/include/rmm/detail/stack_trace.hpp +++ b/include/rmm/detail/stack_trace.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,8 +25,6 @@ #define RMM_ENABLE_STACK_TRACES #endif -#include - #if defined(RMM_ENABLE_STACK_TRACES) #include #include diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index 3ddd37415..cbb2853c3 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2024, NVIDIA CORPORATION. + * Copyright (c) 2019-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,6 @@ #include #include -#include #include namespace RMM_NAMESPACE { diff --git a/include/rmm/device_scalar.hpp b/include/rmm/device_scalar.hpp index 62b004e2f..6a7b7037e 100644 --- a/include/rmm/device_scalar.hpp +++ b/include/rmm/device_scalar.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2024, NVIDIA CORPORATION. + * Copyright (c) 2019-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ namespace RMM_NAMESPACE { template class device_scalar { public: - static_assert(std::is_trivially_copyable::value, "Scalar type must be trivially copyable"); + static_assert(std::is_trivially_copyable_v, "Scalar type must be trivially copyable"); using value_type = typename device_uvector::value_type; ///< T, the type of the scalar element using size_type = typename device_uvector::size_type; ///< The type used for the size diff --git a/include/rmm/device_uvector.hpp b/include/rmm/device_uvector.hpp index 8f2c5936e..625e9ab71 100644 --- a/include/rmm/device_uvector.hpp +++ b/include/rmm/device_uvector.hpp @@ -27,7 +27,8 @@ #include #include -#include +#include +#include namespace RMM_NAMESPACE { /** @@ -75,7 +76,7 @@ namespace RMM_NAMESPACE { */ template class device_uvector { - static_assert(std::is_trivially_copyable::value, + static_assert(std::is_trivially_copyable_v, "device_uvector only supports types that are trivially copyable."); public: @@ -219,13 +220,13 @@ class device_uvector { RMM_EXPECTS( element_index < size(), "Attempt to access out of bounds element.", rmm::out_of_range); - if constexpr (std::is_same::value) { + if constexpr (std::is_same_v) { RMM_CUDA_TRY( cudaMemsetAsync(element_ptr(element_index), value, sizeof(value), stream.value())); return; } - if constexpr (std::is_fundamental::value) { + if constexpr (std::is_fundamental_v) { if (value == value_type{0}) { set_element_to_zero_async(element_index, stream); return; diff --git a/include/rmm/mr/device/aligned_resource_adaptor.hpp b/include/rmm/mr/device/aligned_resource_adaptor.hpp index 4df2c4d2d..78d50dcc6 100644 --- a/include/rmm/mr/device/aligned_resource_adaptor.hpp +++ b/include/rmm/mr/device/aligned_resource_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, NVIDIA CORPORATION. + * Copyright (c) 2021-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,6 @@ #include #include -#include #include namespace RMM_NAMESPACE { diff --git a/include/rmm/mr/device/binning_memory_resource.hpp b/include/rmm/mr/device/binning_memory_resource.hpp index a5ef64665..6011fac3c 100644 --- a/include/rmm/mr/device/binning_memory_resource.hpp +++ b/include/rmm/mr/device/binning_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ #include -#include #include #include #include diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 12b835982..0a4d17afc 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, NVIDIA CORPORATION. + * Copyright (c) 2021-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,6 @@ #include #include -#include #include namespace RMM_NAMESPACE { diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index 180c412ee..a4ae74394 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, NVIDIA CORPORATION. + * Copyright (c) 2021-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,6 @@ #include #include -#include namespace RMM_NAMESPACE { namespace mr { diff --git a/include/rmm/mr/device/detail/coalescing_free_list.hpp b/include/rmm/mr/device/detail/coalescing_free_list.hpp index 8b056e6d9..e352a4fbf 100644 --- a/include/rmm/mr/device/detail/coalescing_free_list.hpp +++ b/include/rmm/mr/device/detail/coalescing_free_list.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2024, NVIDIA CORPORATION. + * Copyright (c) 2019-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +23,10 @@ #include #include #include +#ifdef RMM_DEBUG_PRINT #include +#endif #include -#include namespace RMM_NAMESPACE { namespace mr::detail { diff --git a/include/rmm/mr/device/detail/fixed_size_free_list.hpp b/include/rmm/mr/device/detail/fixed_size_free_list.hpp index deb0e1646..2827f5945 100644 --- a/include/rmm/mr/device/detail/fixed_size_free_list.hpp +++ b/include/rmm/mr/device/detail/fixed_size_free_list.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ #include #include -#include namespace RMM_NAMESPACE { namespace mr::detail { diff --git a/include/rmm/mr/device/detail/free_list.hpp b/include/rmm/mr/device/detail/free_list.hpp index 07b1dbcae..2e33fc695 100644 --- a/include/rmm/mr/device/detail/free_list.hpp +++ b/include/rmm/mr/device/detail/free_list.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2024, NVIDIA CORPORATION. + * Copyright (c) 2019-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,9 @@ #include #include +#ifdef RMM_DEBUG_PRINT #include +#endif #include namespace RMM_NAMESPACE { diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index 0900d44b2..ad676bfd2 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,10 +25,14 @@ #include +#include #include #include #include #include +#ifdef RMM_DEBUG_PRINT +#include +#endif namespace RMM_NAMESPACE { namespace mr::detail { diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index aae9aeaf2..9ae390d8c 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2024, NVIDIA CORPORATION. + * Copyright (c) 2019-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ #include #include -#include namespace RMM_NAMESPACE { namespace mr { diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/include/rmm/mr/device/fixed_size_memory_resource.hpp index 249af77dd..b59e5c312 100644 --- a/include/rmm/mr/device/fixed_size_memory_resource.hpp +++ b/include/rmm/mr/device/fixed_size_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,8 +31,6 @@ #include #include -#include -#include #include #include diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index 16729fd68..96d730191 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, NVIDIA CORPORATION. + * Copyright (c) 2021-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ #include #include +#include #include namespace RMM_NAMESPACE { diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/include/rmm/mr/device/logging_resource_adaptor.hpp index 4f62d842b..4a4329a6b 100644 --- a/include/rmm/mr/device/logging_resource_adaptor.hpp +++ b/include/rmm/mr/device/logging_resource_adaptor.hpp @@ -25,9 +25,10 @@ #include #include +#include #include -#include -#include +#include +#include namespace RMM_NAMESPACE { namespace mr { diff --git a/include/rmm/mr/device/owning_wrapper.hpp b/include/rmm/mr/device/owning_wrapper.hpp index 0fa28d59e..ff456ff42 100644 --- a/include/rmm/mr/device/owning_wrapper.hpp +++ b/include/rmm/mr/device/owning_wrapper.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,6 @@ #include #include -#include -#include #include #include diff --git a/include/rmm/mr/device/polymorphic_allocator.hpp b/include/rmm/mr/device/polymorphic_allocator.hpp index 2e6fcd70d..faab921f5 100644 --- a/include/rmm/mr/device/polymorphic_allocator.hpp +++ b/include/rmm/mr/device/polymorphic_allocator.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ #include #include -#include namespace RMM_NAMESPACE { namespace mr { diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 037147de3..dee0471b9 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,19 +33,12 @@ #include #include #include -#include #include #include -#include -#include #include -#include #include #include -#include -#include -#include namespace RMM_NAMESPACE { namespace mr { diff --git a/include/rmm/mr/device/prefetch_resource_adaptor.hpp b/include/rmm/mr/device/prefetch_resource_adaptor.hpp index d3a4c676a..8cc7cc5e8 100644 --- a/include/rmm/mr/device/prefetch_resource_adaptor.hpp +++ b/include/rmm/mr/device/prefetch_resource_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, NVIDIA CORPORATION. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,9 +21,6 @@ #include #include -#include -#include -#include namespace RMM_NAMESPACE { namespace mr { diff --git a/include/rmm/mr/device/sam_headroom_memory_resource.hpp b/include/rmm/mr/device/sam_headroom_memory_resource.hpp index db5d8034f..e3e1aa820 100644 --- a/include/rmm/mr/device/sam_headroom_memory_resource.hpp +++ b/include/rmm/mr/device/sam_headroom_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, NVIDIA CORPORATION. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,9 @@ #include #include +#include +#include + namespace RMM_NAMESPACE { namespace mr { /** diff --git a/include/rmm/mr/device/system_memory_resource.hpp b/include/rmm/mr/device/system_memory_resource.hpp index 6ac74192d..666a7a9c4 100644 --- a/include/rmm/mr/device/system_memory_resource.hpp +++ b/include/rmm/mr/device/system_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, NVIDIA CORPORATION. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,9 @@ #include #include +#include +#include + namespace RMM_NAMESPACE { namespace mr { diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/include/rmm/mr/device/tracking_resource_adaptor.hpp index 1b2c13ba9..888bd3ff0 100644 --- a/include/rmm/mr/device/tracking_resource_adaptor.hpp +++ b/include/rmm/mr/device/tracking_resource_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ #include #include +#include #include #include #include diff --git a/include/rmm/mr/host/host_memory_resource.hpp b/include/rmm/mr/host/host_memory_resource.hpp index 9bcd1c9eb..ac0ace4ab 100644 --- a/include/rmm/mr/host/host_memory_resource.hpp +++ b/include/rmm/mr/host/host_memory_resource.hpp @@ -21,7 +21,6 @@ #include #include -#include namespace RMM_NAMESPACE { namespace mr { diff --git a/include/rmm/mr/host/new_delete_resource.hpp b/include/rmm/mr/host/new_delete_resource.hpp index c7ad4a758..1ed7292bb 100644 --- a/include/rmm/mr/host/new_delete_resource.hpp +++ b/include/rmm/mr/host/new_delete_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ #include #include -#include namespace RMM_NAMESPACE { namespace mr { diff --git a/include/rmm/mr/host/pinned_memory_resource.hpp b/include/rmm/mr/host/pinned_memory_resource.hpp index 6d9e419b0..cf746f5ac 100644 --- a/include/rmm/mr/host/pinned_memory_resource.hpp +++ b/include/rmm/mr/host/pinned_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ #include #include -#include namespace RMM_NAMESPACE { namespace mr { diff --git a/include/rmm/mr/pinned_host_memory_resource.hpp b/include/rmm/mr/pinned_host_memory_resource.hpp index 0b23d9112..b5689b3ed 100644 --- a/include/rmm/mr/pinned_host_memory_resource.hpp +++ b/include/rmm/mr/pinned_host_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, NVIDIA CORPORATION. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,6 @@ #include #include -#include namespace RMM_NAMESPACE { namespace mr { diff --git a/tests/container_multidevice_tests.cu b/tests/container_multidevice_tests.cu index 55432feb0..8e5e909c4 100644 --- a/tests/container_multidevice_tests.cu +++ b/tests/container_multidevice_tests.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,9 +22,12 @@ #include #include +#include + #include #include +#include template struct ContainerMultiDeviceTest : public ::testing::Test {}; @@ -32,7 +35,7 @@ struct ContainerMultiDeviceTest : public ::testing::Test {}; using containers = ::testing::Types, rmm::device_scalar>; -TYPED_TEST_CASE(ContainerMultiDeviceTest, containers); +TYPED_TEST_SUITE(ContainerMultiDeviceTest, containers); TYPED_TEST(ContainerMultiDeviceTest, CreateDestroyDifferentActiveDevice) { diff --git a/tests/cuda_stream_pool_tests.cpp b/tests/cuda_stream_pool_tests.cpp index ad1d421d7..f025146cd 100644 --- a/tests/cuda_stream_pool_tests.cpp +++ b/tests/cuda_stream_pool_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,8 @@ #include +#include + struct CudaStreamPoolTest : public ::testing::Test { rmm::cuda_stream_pool pool{}; }; diff --git a/tests/cuda_stream_tests.cpp b/tests/cuda_stream_tests.cpp index ec7e6c3e9..d268bbe62 100644 --- a/tests/cuda_stream_tests.cpp +++ b/tests/cuda_stream_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,9 @@ #include #include +#include #include +#include struct CudaStreamTest : public ::testing::Test {}; diff --git a/tests/device_buffer_tests.cu b/tests/device_buffer_tests.cu index 5e48504d6..7f17f4bec 100644 --- a/tests/device_buffer_tests.cu +++ b/tests/device_buffer_tests.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2024, NVIDIA CORPORATION. + * Copyright (c) 2019-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ struct DeviceBufferTest : public ::testing::Test { using resources = ::testing::Types; -TYPED_TEST_CASE(DeviceBufferTest, resources); +TYPED_TEST_SUITE(DeviceBufferTest, resources); TYPED_TEST(DeviceBufferTest, EmptyBuffer) { diff --git a/tests/device_scalar_tests.cpp b/tests/device_scalar_tests.cpp index 323894a6a..189d571e0 100644 --- a/tests/device_scalar_tests.cpp +++ b/tests/device_scalar_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2024, NVIDIA CORPORATION. + * Copyright (c) 2019-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,16 +42,15 @@ struct DeviceScalarTest : public ::testing::Test { DeviceScalarTest() : value{random_value()} {} - template ::value, bool> = true> + template , bool> = true> U random_value() { static std::bernoulli_distribution distribution{}; return distribution(generator); } - template < - typename U = T, - std::enable_if_t<(std::is_integral::value && not std::is_same::value), bool> = true> + template && not std::is_same_v), bool> = true> U random_value() { static std::uniform_int_distribution distribution{std::numeric_limits::lowest(), @@ -59,7 +58,7 @@ struct DeviceScalarTest : public ::testing::Test { return distribution(generator); } - template ::value, bool> = true> + template , bool> = true> U random_value() { auto const mean{100}; @@ -71,7 +70,7 @@ struct DeviceScalarTest : public ::testing::Test { using Types = ::testing::Types; -TYPED_TEST_CASE(DeviceScalarTest, Types); +TYPED_TEST_SUITE(DeviceScalarTest, Types); TYPED_TEST(DeviceScalarTest, Uninitialized) { diff --git a/tests/device_uvector_tests.cpp b/tests/device_uvector_tests.cpp index 90955c24c..faa8a9994 100644 --- a/tests/device_uvector_tests.cpp +++ b/tests/device_uvector_tests.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,10 @@ #include #include +#include +#include +#include + // explicit instantiation for test coverage purposes. template class rmm::device_uvector; @@ -33,7 +37,7 @@ struct TypedUVectorTest : ::testing::Test { using TestTypes = ::testing::Types; -TYPED_TEST_CASE(TypedUVectorTest, TestTypes); +TYPED_TEST_SUITE(TypedUVectorTest, TestTypes); TYPED_TEST(TypedUVectorTest, MemoryResource) { diff --git a/tests/logger_tests.cpp b/tests/logger_tests.cpp index 6f4ab96cd..5ce49ec5a 100644 --- a/tests/logger_tests.cpp +++ b/tests/logger_tests.cpp @@ -20,12 +20,15 @@ #include #include -#include #include +#include #include #include -#include +#include +#include +#include +#include namespace rmm::test { namespace { diff --git a/tests/mr/device/adaptor_tests.cpp b/tests/mr/device/adaptor_tests.cpp index 286daa841..e04fa1ebb 100644 --- a/tests/mr/device/adaptor_tests.cpp +++ b/tests/mr/device/adaptor_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, NVIDIA CORPORATION. + * Copyright (c) 2021-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,7 @@ #include "../../byte_literals.hpp" -#include -#include +#include #include #include #include @@ -36,6 +35,7 @@ #include #include +#include #include using cuda_mr = rmm::mr::cuda_memory_resource; @@ -110,7 +110,7 @@ struct AdaptorTest : public ::testing::Test { } }; -TYPED_TEST_CASE(AdaptorTest, adaptors); +TYPED_TEST_SUITE(AdaptorTest, adaptors); TYPED_TEST(AdaptorTest, NullUpstream) { diff --git a/tests/mr/device/aligned_mr_tests.cpp b/tests/mr/device/aligned_mr_tests.cpp index 9b90bf751..f664b132c 100644 --- a/tests/mr/device/aligned_mr_tests.cpp +++ b/tests/mr/device/aligned_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, NVIDIA CORPORATION. + * Copyright (c) 2021-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ #include "../../mock_resource.hpp" #include -#include +#include #include #include #include @@ -25,6 +25,8 @@ #include #include +#include + namespace rmm::test { namespace { diff --git a/tests/mr/device/arena_mr_tests.cpp b/tests/mr/device/arena_mr_tests.cpp index 67f183a23..033e135b8 100644 --- a/tests/mr/device/arena_mr_tests.cpp +++ b/tests/mr/device/arena_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, NVIDIA CORPORATION. + * Copyright (c) 2021-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,14 +16,12 @@ #include "../../byte_literals.hpp" -#include #include #include -#include +#include #include #include #include -#include #include @@ -31,8 +29,12 @@ #include #include +#include +#include #include +#include #include +#include #include namespace rmm::test { diff --git a/tests/mr/device/binning_mr_tests.cpp b/tests/mr/device/binning_mr_tests.cpp index 68fc66322..409b4a3d9 100644 --- a/tests/mr/device/binning_mr_tests.cpp +++ b/tests/mr/device/binning_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include diff --git a/tests/mr/device/callback_mr_tests.cpp b/tests/mr/device/callback_mr_tests.cpp index a7f6ab7be..eae3d6789 100644 --- a/tests/mr/device/callback_mr_tests.cpp +++ b/tests/mr/device/callback_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024, NVIDIA CORPORATION. + * Copyright (c) 2022-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,15 +18,15 @@ #include "../../mock_resource.hpp" #include -#include -#include #include -#include +#include +#include #include #include #include +#include #include namespace rmm::test { diff --git a/tests/mr/device/cuda_async_mr_tests.cpp b/tests/mr/device/cuda_async_mr_tests.cpp index e56d224ed..ecd29f34f 100644 --- a/tests/mr/device/cuda_async_mr_tests.cpp +++ b/tests/mr/device/cuda_async_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, NVIDIA CORPORATION. + * Copyright (c) 2021-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,10 +14,11 @@ * limitations under the License. */ -#include #include #include +#include + #include namespace rmm::test { diff --git a/tests/mr/device/failure_callback_mr_tests.cpp b/tests/mr/device/failure_callback_mr_tests.cpp index 4b3d084d5..263e0128c 100644 --- a/tests/mr/device/failure_callback_mr_tests.cpp +++ b/tests/mr/device/failure_callback_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, NVIDIA CORPORATION. + * Copyright (c) 2021-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,8 +17,7 @@ #include "../../byte_literals.hpp" #include -#include -#include +#include #include #include diff --git a/tests/mr/device/limiting_mr_tests.cpp b/tests/mr/device/limiting_mr_tests.cpp index e6cc97029..d90da009b 100644 --- a/tests/mr/device/limiting_mr_tests.cpp +++ b/tests/mr/device/limiting_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2024, NVIDIA CORPORATION. + * Copyright (c) 2019-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,7 @@ #include "../../byte_literals.hpp" -#include -#include +#include #include #include diff --git a/tests/mr/device/mr_ref_multithreaded_tests.cpp b/tests/mr/device/mr_ref_multithreaded_tests.cpp index 9e7c8c2e8..4507793e7 100644 --- a/tests/mr/device/mr_ref_multithreaded_tests.cpp +++ b/tests/mr/device/mr_ref_multithreaded_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ namespace { struct mr_ref_test_mt : public mr_ref_test {}; -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( MultiThreadResourceTests, mr_ref_test_mt, ::testing::Values("CUDA", "CUDA_Async", "Managed", "Pool", "Arena", "Binning"), diff --git a/tests/mr/device/polymorphic_allocator_tests.cpp b/tests/mr/device/polymorphic_allocator_tests.cpp index d433e010c..c2e1580b1 100644 --- a/tests/mr/device/polymorphic_allocator_tests.cpp +++ b/tests/mr/device/polymorphic_allocator_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ #include #include +#include namespace { @@ -103,7 +104,7 @@ TEST_F(allocator_test, rebind) using Rebound = std::allocator_traits::rebind_alloc; - EXPECT_TRUE((std::is_same::value_type, double>::value)); + EXPECT_TRUE((std::is_same_v::value_type, double>)); } TEST_F(allocator_test, allocate_deallocate) diff --git a/tests/mr/device/pool_mr_tests.cpp b/tests/mr/device/pool_mr_tests.cpp index 9db63eb1b..e59dd6bca 100644 --- a/tests/mr/device/pool_mr_tests.cpp +++ b/tests/mr/device/pool_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,11 +14,9 @@ * limitations under the License. */ -#include #include #include #include -#include #include #include #include @@ -27,6 +25,10 @@ #include +#include +#include +#include + // explicit instantiation for test coverage purposes template class rmm::mr::pool_memory_resource; diff --git a/tests/mr/device/prefetch_resource_adaptor_tests.cpp b/tests/mr/device/prefetch_resource_adaptor_tests.cpp index 9d15c07f2..44a87852e 100644 --- a/tests/mr/device/prefetch_resource_adaptor_tests.cpp +++ b/tests/mr/device/prefetch_resource_adaptor_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, NVIDIA CORPORATION. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,7 +69,7 @@ struct PrefetchAdaptorTest : public ::testing::Test { using resources = ::testing::Types; -TYPED_TEST_CASE(PrefetchAdaptorTest, resources); +TYPED_TEST_SUITE(PrefetchAdaptorTest, resources); // The following tests simply test compilation and that there are no exceptions thrown // due to prefetching non-managed memory. diff --git a/tests/mr/device/statistics_mr_tests.cpp b/tests/mr/device/statistics_mr_tests.cpp index f796a4c00..27b84c1fd 100644 --- a/tests/mr/device/statistics_mr_tests.cpp +++ b/tests/mr/device/statistics_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,12 +17,17 @@ #include "../../byte_literals.hpp" #include -#include #include +#include #include #include +#include +#include +#include +#include + namespace rmm::test { namespace { diff --git a/tests/mr/device/stream_allocator_adaptor_tests.cpp b/tests/mr/device/stream_allocator_adaptor_tests.cpp index 72a014bfa..b56d27706 100644 --- a/tests/mr/device/stream_allocator_adaptor_tests.cpp +++ b/tests/mr/device/stream_allocator_adaptor_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,12 +17,12 @@ #include #include #include -#include #include #include #include +#include namespace { @@ -35,7 +35,7 @@ TEST_F(allocator_test, factory) { using Adaptor = rmm::mr::stream_allocator_adaptor; auto adapted = rmm::mr::stream_allocator_adaptor(allocator, stream); - static_assert((std::is_same::value)); + static_assert((std::is_same_v)); EXPECT_EQ(adapted.underlying_allocator(), allocator); EXPECT_EQ(adapted.stream(), stream); } @@ -98,10 +98,10 @@ TEST_F(allocator_test, rebind) { auto adapted = rmm::mr::stream_allocator_adaptor(allocator, stream); using Rebound = std::allocator_traits::rebind_alloc; - static_assert((std::is_same::value_type, double>::value)); + static_assert(std::is_same_v::value_type, double>); static_assert( - std::is_same>>::value); + std::is_same_v>>); Rebound rebound{adapted}; } diff --git a/tests/mr/device/system_mr_tests.cu b/tests/mr/device/system_mr_tests.cu index 00084c4e2..27706b127 100644 --- a/tests/mr/device/system_mr_tests.cu +++ b/tests/mr/device/system_mr_tests.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, NVIDIA CORPORATION. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,12 +17,16 @@ #include "../../byte_literals.hpp" #include -#include +#include #include #include +#include + #include +#include + namespace rmm::test { namespace { diff --git a/tests/mr/device/thrust_allocator_tests.cu b/tests/mr/device/thrust_allocator_tests.cu index 46447aa09..86405459e 100644 --- a/tests/mr/device/thrust_allocator_tests.cu +++ b/tests/mr/device/thrust_allocator_tests.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2024, NVIDIA CORPORATION. + * Copyright (c) 2019-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,7 +69,7 @@ TEST_P(allocator_test, multi_device) }()); } -INSTANTIATE_TEST_CASE_P( +INSTANTIATE_TEST_SUITE_P( ThrustAllocatorTests, allocator_test, ::testing::Values("CUDA", "CUDA_Async", "Managed", "Pool", "Arena", "Binning"), diff --git a/tests/mr/device/tracking_mr_tests.cpp b/tests/mr/device/tracking_mr_tests.cpp index f723e0c65..28e8b2f00 100644 --- a/tests/mr/device/tracking_mr_tests.cpp +++ b/tests/mr/device/tracking_mr_tests.cpp @@ -24,6 +24,11 @@ #include +#include +#include +#include +#include + namespace rmm::test { namespace { diff --git a/tests/mr/host/mr_ref_tests.cpp b/tests/mr/host/mr_ref_tests.cpp index 071739575..5d8eb8350 100644 --- a/tests/mr/host/mr_ref_tests.cpp +++ b/tests/mr/host/mr_ref_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ using resources = ::testing::Types); static_assert(cuda::mr::resource_with); -TYPED_TEST_CASE(MRRefTest, resources); +TYPED_TEST_SUITE(MRRefTest, resources); TYPED_TEST(MRRefTest, SelfEquality) { EXPECT_TRUE(this->ref == this->ref); } diff --git a/tests/mr/host/pinned_pool_mr_tests.cpp b/tests/mr/host/pinned_pool_mr_tests.cpp index d10b85e72..436fdfd1d 100644 --- a/tests/mr/host/pinned_pool_mr_tests.cpp +++ b/tests/mr/host/pinned_pool_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, NVIDIA CORPORATION. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,10 +14,7 @@ * limitations under the License. */ -#include -#include -#include -#include +#include #include #include diff --git a/tests/prefetch_tests.cpp b/tests/prefetch_tests.cpp index 4a2c41a2b..d4029eefc 100644 --- a/tests/prefetch_tests.cpp +++ b/tests/prefetch_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2024, NVIDIA CORPORATION. + * Copyright (c) 2019-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,7 +69,7 @@ struct PrefetchTest : public ::testing::Test { using resources = ::testing::Types; -TYPED_TEST_CASE(PrefetchTest, resources); +TYPED_TEST_SUITE(PrefetchTest, resources); // The following tests simply test compilation and that there are no exceptions thrown // due to prefetching non-managed memory. From 9f2e6343c71c4f3ea99d89edff3a1d9eb9004c81 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 12 Feb 2025 16:06:35 -0500 Subject: [PATCH 553/675] Create Conda CI test env in one step (#1824) Issue: https://github.com/rapidsai/build-planning/issues/22 Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1824 --- ci/release/update-version.sh | 2 ++ ci/test_cpp.sh | 17 ++++++----------- ci/test_python.sh | 19 +++++++------------ dependencies.yaml | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 5b5217602..ef409d68e 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -46,6 +46,8 @@ done DEPENDENCIES=( librmm + librmm-tests + rmm ) for DEP in "${DEPENDENCIES[@]}"; do for FILE in dependencies.yaml conda/environments/*.yaml; do diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index e0612c94b..d834deed5 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -8,13 +8,17 @@ cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../ . /opt/conda/etc/profile.d/conda.sh -RAPIDS_VERSION="$(rapids-version)" +CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) +RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"}/ +mkdir -p "${RAPIDS_TESTS_DIR}" rapids-logger "Generate C++ testing dependencies" rapids-dependency-file-generator \ --output conda \ --file-key test_cpp \ - --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch)" | tee env.yaml + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch)" \ + --prepend-channel "${CPP_CHANNEL}" \ + | tee env.yaml rapids-mamba-retry env create --yes -f env.yaml -n test @@ -23,17 +27,8 @@ set +u conda activate test set -u -CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) -RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"}/ -mkdir -p "${RAPIDS_TESTS_DIR}" - rapids-print-env -rapids-mamba-retry install \ - --channel "${CPP_CHANNEL}" \ - "librmm=${RAPIDS_VERSION}" \ - "librmm-tests=${RAPIDS_VERSION}" - rapids-logger "Check GPU usage" nvidia-smi diff --git a/ci/test_python.sh b/ci/test_python.sh index 377882c59..b2934f261 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -10,12 +10,17 @@ rapids-logger "Create test conda environment" . /opt/conda/etc/profile.d/conda.sh -RAPIDS_VERSION="$(rapids-version)" +rapids-logger "Downloading artifacts from previous jobs" +CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) +PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) rapids-dependency-file-generator \ --output conda \ --file-key test_python \ - --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION};dependencies=${RAPIDS_DEPENDENCIES}" | tee env.yaml + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION};dependencies=${RAPIDS_DEPENDENCIES}" \ + --prepend-channel "${CPP_CHANNEL}" \ + --prepend-channel "${PYTHON_CHANNEL}" \ + | tee env.yaml rapids-mamba-retry env create --yes -f env.yaml -n test set +u @@ -24,16 +29,6 @@ set -u rapids-print-env -rapids-logger "Downloading artifacts from previous jobs" -CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) -PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) - -rapids-mamba-retry install \ - --channel "${CPP_CHANNEL}" \ - --channel "${PYTHON_CHANNEL}" \ - "rmm=${RAPIDS_VERSION}" \ - "librmm=${RAPIDS_VERSION}" - RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"} RAPIDS_COVERAGE_DIR=${RAPIDS_COVERAGE_DIR:-"${PWD}/coverage-results"} mkdir -p "${RAPIDS_TESTS_DIR}" "${RAPIDS_COVERAGE_DIR}" diff --git a/dependencies.yaml b/dependencies.yaml index 9a79a0fc3..53427d2dc 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -24,11 +24,15 @@ files: - cuda_version - py_version - test_python + - depends_on_librmm + - depends_on_rmm test_cpp: output: none includes: - cuda_version - test_cpp + - depends_on_librmm + - depends_on_librmm_tests checks: output: none includes: @@ -207,6 +211,16 @@ dependencies: - matrix: packages: - *librmm_unsuffixed + depends_on_rmm: + common: + - output_types: conda + packages: + - rmm=25.4.*,>=0.0.0a0 + depends_on_librmm_tests: + common: + - output_types: conda + packages: + - librmm-tests=25.4.*,>=0.0.0a0 checks: common: - output_types: [conda, requirements] From 17ba5ed882ed656180a0ac3e5cac2ad535c5956c Mon Sep 17 00:00:00 2001 From: Jake Awe Date: Thu, 13 Feb 2025 09:45:25 -0600 Subject: [PATCH 554/675] Update Changelog [skip ci] --- CHANGELOG.md | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 817a0c8c2..1df0eeeeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,62 @@ +# rmm 25.02.00 (13 Feb 2025) + +## 🚨 Breaking Changes + +- Switch to using separate rapids-logger repo ([#1774](https://github.com/rapidsai/rmm/pull/1774)) [@vyasr](https://github.com/vyasr) +- Remove deprecated factory functions from resource adaptors. ([#1767](https://github.com/rapidsai/rmm/pull/1767)) [@bdice](https://github.com/bdice) +- Remove `rmm._lib` ([#1765](https://github.com/rapidsai/rmm/pull/1765)) [@Matt711](https://github.com/Matt711) +- Remove memory access flags from cuda_async_memory_resource ([#1754](https://github.com/rapidsai/rmm/pull/1754)) [@abellina](https://github.com/abellina) +- Create logger wrapper around spdlog that can be easily reused in other libraries ([#1722](https://github.com/rapidsai/rmm/pull/1722)) [@vyasr](https://github.com/vyasr) + +## 🐛 Bug Fixes + +- Add missing array header include ([#1771](https://github.com/rapidsai/rmm/pull/1771)) [@robertmaynard](https://github.com/robertmaynard) +- Remove memory access flags from cuda_async_memory_resource ([#1754](https://github.com/rapidsai/rmm/pull/1754)) [@abellina](https://github.com/abellina) +- Update build.sh ([#1749](https://github.com/rapidsai/rmm/pull/1749)) [@vyasr](https://github.com/vyasr) +- Fix some logger issues ([#1739](https://github.com/rapidsai/rmm/pull/1739)) [@vyasr](https://github.com/vyasr) +- Use consistent signature for target_link_libraries ([#1738](https://github.com/rapidsai/rmm/pull/1738)) [@vyasr](https://github.com/vyasr) + +## 📖 Documentation + +- Revise README. ([#1747](https://github.com/rapidsai/rmm/pull/1747)) [@bdice](https://github.com/bdice) + +## 🚀 New Features + +- Make the stream module a part of the public API ([#1775](https://github.com/rapidsai/rmm/pull/1775)) [@Matt711](https://github.com/Matt711) +- Remove deprecated factory functions from resource adaptors. ([#1767](https://github.com/rapidsai/rmm/pull/1767)) [@bdice](https://github.com/bdice) +- Remove `rmm._lib` ([#1765](https://github.com/rapidsai/rmm/pull/1765)) [@Matt711](https://github.com/Matt711) +- Reduce dependencies on numba. ([#1761](https://github.com/rapidsai/rmm/pull/1761)) [@bdice](https://github.com/bdice) +- Use ruff, remove isort and black. ([#1759](https://github.com/rapidsai/rmm/pull/1759)) [@bdice](https://github.com/bdice) +- Use bindings layout for all cuda-python imports. ([#1756](https://github.com/rapidsai/rmm/pull/1756)) [@bdice](https://github.com/bdice) +- Add configuration for pre-commit.ci, update pre-commit hooks ([#1746](https://github.com/rapidsai/rmm/pull/1746)) [@bdice](https://github.com/bdice) +- Adds fabric handle and memory protection flags to cuda_async_memory_resource ([#1743](https://github.com/rapidsai/rmm/pull/1743)) [@abellina](https://github.com/abellina) +- Remove upper bounds on cuda-python to allow 12.6.2 and 11.8.5 ([#1729](https://github.com/rapidsai/rmm/pull/1729)) [@bdice](https://github.com/bdice) + +## 🛠️ Improvements + +- Revert CUDA 12.8 shared workflow branch changes ([#1805](https://github.com/rapidsai/rmm/pull/1805)) [@vyasr](https://github.com/vyasr) +- Build and test with CUDA 12.8.0 ([#1797](https://github.com/rapidsai/rmm/pull/1797)) [@bdice](https://github.com/bdice) +- Disable exec checks for `device_uvector::operator=` ([#1790](https://github.com/rapidsai/rmm/pull/1790)) [@miscco](https://github.com/miscco) +- Add upper bound to prevent usage of numba 0.61.0 ([#1789](https://github.com/rapidsai/rmm/pull/1789)) [@galipremsagar](https://github.com/galipremsagar) +- Add shellcheck to pre-commit and fix warnings ([#1788](https://github.com/rapidsai/rmm/pull/1788)) [@gforsyth](https://github.com/gforsyth) +- Add spdlog back as a requirement for now ([#1780](https://github.com/rapidsai/rmm/pull/1780)) [@vyasr](https://github.com/vyasr) +- [pre-commit.ci] pre-commit autoupdate ([#1778](https://github.com/rapidsai/rmm/pull/1778)) [@pre-commit-ci[bot]](https://github.com/pre-commit-ci[bot]) +- Use rapids-cmake for the logger ([#1776](https://github.com/rapidsai/rmm/pull/1776)) [@vyasr](https://github.com/vyasr) +- Switch to using separate rapids-logger repo ([#1774](https://github.com/rapidsai/rmm/pull/1774)) [@vyasr](https://github.com/vyasr) +- Use GCC 13 in CUDA 12 conda builds. ([#1773](https://github.com/rapidsai/rmm/pull/1773)) [@bdice](https://github.com/bdice) +- Check if nightlies have succeeded recently enough ([#1772](https://github.com/rapidsai/rmm/pull/1772)) [@vyasr](https://github.com/vyasr) +- Fix codespell behavior. ([#1769](https://github.com/rapidsai/rmm/pull/1769)) [@bdice](https://github.com/bdice) +- Remove ignored cuda-python deprecation warning. ([#1768](https://github.com/rapidsai/rmm/pull/1768)) [@bdice](https://github.com/bdice) +- Forward-merge branch-24.12 to branch-25.02 ([#1766](https://github.com/rapidsai/rmm/pull/1766)) [@bdice](https://github.com/bdice) +- Update version references in workflow ([#1757](https://github.com/rapidsai/rmm/pull/1757)) [@AyodeAwe](https://github.com/AyodeAwe) +- gate telemetry dispatch calls on TELEMETRY_ENABLED env var ([#1752](https://github.com/rapidsai/rmm/pull/1752)) [@msarahan](https://github.com/msarahan) +- Update cuda-python lower bounds to 12.6.2 / 11.8.5 ([#1751](https://github.com/rapidsai/rmm/pull/1751)) [@bdice](https://github.com/bdice) +- remove certs and simplify telemetry summarize ([#1750](https://github.com/rapidsai/rmm/pull/1750)) [@msarahan](https://github.com/msarahan) +- stop installing 'wheel' in wheel-building script ([#1748](https://github.com/rapidsai/rmm/pull/1748)) [@jameslamb](https://github.com/jameslamb) +- Require approval to run CI on draft PRs ([#1737](https://github.com/rapidsai/rmm/pull/1737)) [@bdice](https://github.com/bdice) +- Create logger wrapper around spdlog that can be easily reused in other libraries ([#1722](https://github.com/rapidsai/rmm/pull/1722)) [@vyasr](https://github.com/vyasr) +- Add breaking change workflow trigger ([#1719](https://github.com/rapidsai/rmm/pull/1719)) [@AyodeAwe](https://github.com/AyodeAwe) + # rmm 24.12.00 (11 Dec 2024) ## 🚨 Breaking Changes From cc969b60bb55636a3ab08c40153ce80008e872ff Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Thu, 13 Feb 2025 16:47:07 -0500 Subject: [PATCH 555/675] Port to rattler-build (#1796) Summary: ## `recipe.yaml` - We use the [multi-output cache](https://rattler.build/latest/multiple_output_cache/) to avoid double-compiling. The `build` environment compiles things, the individual outputs call `cmake --install` - We make use of the built-in `git` functions for grabbing the short-SHA (https://rattler.build/latest/experimental_features/#git-functions) - We use `load_from_file` to pull in metadata from the corresponding `pyproject.toml` (https://rattler.build/latest/experimental_features/#load_from_filefile_path) - Relatively "simple" `*_build.sh` scripts are inlined into `recipe.yaml` instead of existing as separate files ## `build_*.sh` - We use `--no-build-id` to allow `sccache` to look in a predictable place, see: https://rattler.build/latest/tips_and_tricks/#using-sccache-or-ccache-with-rattler-build - Depending on whether `rapids-is-release-build`, we include either `rapidsai` (release) or `rapidsai-nightly` (non-release) in the channel listing - Channels must be specified at the command-line - This uses https://github.com/rapidsai/gha-tools/blob/main/tools/rapids-rattler-channel-string to generate an array of channels - We remove the `build_cache` directory after building so it doesn't get packaged up with the other artifacts and uploaded to S3 xref: https://github.com/rapidsai/build-planning/issues/47 Authors: - Gil Forsyth (https://github.com/gforsyth) Approvers: - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1796 --- .gitignore | 4 +- ci/build_cpp.sh | 20 +++- ci/build_python.sh | 21 +++- conda/recipes/librmm/install_librmm.sh | 3 - conda/recipes/librmm/install_librmm_tests.sh | 3 - conda/recipes/librmm/meta.yaml | 110 ------------------- conda/recipes/librmm/recipe.yaml | 107 ++++++++++++++++++ conda/recipes/rmm/meta.yaml | 90 --------------- conda/recipes/rmm/recipe.yaml | 91 +++++++++++++++ dependencies.yaml | 1 + python/librmm/pyproject.toml | 2 +- python/rmm/pyproject.toml | 2 +- 12 files changed, 240 insertions(+), 214 deletions(-) delete mode 100644 conda/recipes/librmm/install_librmm.sh delete mode 100644 conda/recipes/librmm/install_librmm_tests.sh delete mode 100644 conda/recipes/librmm/meta.yaml create mode 100644 conda/recipes/librmm/recipe.yaml delete mode 100644 conda/recipes/rmm/meta.yaml create mode 100644 conda/recipes/rmm/recipe.yaml diff --git a/.gitignore b/.gitignore index 52ad86cbc..c2df58adb 100644 --- a/.gitignore +++ b/.gitignore @@ -22,8 +22,8 @@ rmm.egg-info/ python/build python/*/build python/rmm/docs/_build -python/rmm/**/librmm/**/*.cpp -!python/rmm/librmm/_torch_allocator.cpp +python/rmm/rmm/librmm/*.cpp +!python/rmm/rmm/librmm/_torch_allocator.cpp python/rmm/**/librmm/**/*.h python/rmm/**/librmm/.nfs* python/rmm/**/pylibrmm/**/*.cpp diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 1ab555bc0..8cf64b7b7 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -16,9 +16,25 @@ rapids-logger "Begin cpp build" sccache --zero-stats -# This calls mambabuild when boa is installed (as is the case in the CI images) -RAPIDS_PACKAGE_VERSION=$(rapids-generate-version) rapids-conda-retry mambabuild conda/recipes/librmm +RAPIDS_PACKAGE_VERSION=$(rapids-generate-version) +export RAPIDS_PACKAGE_VERSION + +# Creates and exports $RATTLER_CHANNELS +source rapids-rattler-channel-string + +# --no-build-id allows for caching with `sccache` +# more info is available at +# https://rattler.build/latest/tips_and_tricks/#using-sccache-or-ccache-with-rattler-build +rattler-build build --recipe conda/recipes/librmm \ + --experimental \ + --no-build-id \ + --channel-priority disabled \ + --output-dir "$RAPIDS_CONDA_BLD_OUTPUT_DIR" \ + "${RATTLER_CHANNELS[@]}" sccache --show-adv-stats +# remove build_cache directory +rm -rf "$RAPIDS_CONDA_BLD_OUTPUT_DIR"/build_cache + rapids-upload-conda-to-s3 cpp diff --git a/ci/build_python.sh b/ci/build_python.sh index 98f57c34b..4f9b30ce7 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -20,9 +20,26 @@ CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) sccache --zero-stats -# This calls mambabuild when boa is installed (as is the case in the CI images) -RAPIDS_PACKAGE_VERSION=$(head -1 ./VERSION) rapids-conda-retry mambabuild -c "${CPP_CHANNEL}" conda/recipes/rmm +RAPIDS_PACKAGE_VERSION=$(head -1 ./VERSION) +export RAPIDS_PACKAGE_VERSION + +# Creates and exports $RATTLER_CHANNELS +source rapids-rattler-channel-string + +# --no-build-id allows for caching with `sccache` +# more info is available at +# https://rattler.build/latest/tips_and_tricks/#using-sccache-or-ccache-with-rattler-build +rattler-build build --recipe conda/recipes/rmm \ + --experimental \ + --no-build-id \ + --channel-priority disabled \ + --output-dir "$RAPIDS_CONDA_BLD_OUTPUT_DIR" \ + -c "${CPP_CHANNEL}" \ + "${RATTLER_CHANNELS[@]}" sccache --show-adv-stats +# See https://github.com/prefix-dev/rattler-build/issues/1424 +rm -rf "$RAPIDS_CONDA_BLD_OUTPUT_DIR"/build_cache + rapids-upload-conda-to-s3 python diff --git a/conda/recipes/librmm/install_librmm.sh b/conda/recipes/librmm/install_librmm.sh deleted file mode 100644 index cc4722354..000000000 --- a/conda/recipes/librmm/install_librmm.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -cmake --install build diff --git a/conda/recipes/librmm/install_librmm_tests.sh b/conda/recipes/librmm/install_librmm_tests.sh deleted file mode 100644 index 9993e1ba9..000000000 --- a/conda/recipes/librmm/install_librmm_tests.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -cmake --install build --component testing diff --git a/conda/recipes/librmm/meta.yaml b/conda/recipes/librmm/meta.yaml deleted file mode 100644 index f927315c6..000000000 --- a/conda/recipes/librmm/meta.yaml +++ /dev/null @@ -1,110 +0,0 @@ -# Copyright (c) 2018-2025, NVIDIA CORPORATION. - -{% set version = environ['RAPIDS_PACKAGE_VERSION'].lstrip('v') %} -{% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} -{% set cuda_major = cuda_version.split('.')[0] %} -{% set date_string = environ['RAPIDS_DATE_STRING'] %} - -package: - name: librmm-split - -source: - path: ../../.. - -requirements: - build: - - cmake {{ cmake_version }} - - ninja - - {{ compiler('c') }} - - {{ compiler('cxx') }} - {% if cuda_major == "11" %} - - {{ compiler('cuda') }} {{ cuda_version }} - {% else %} - - {{ compiler('cuda') }} - {% endif %} - - cuda-version ={{ cuda_version }} - - {{ stdlib("c") }} - host: - - cuda-version ={{ cuda_version }} - - rapids-logger =0.1 - -build: - script_env: - - AWS_ACCESS_KEY_ID - - AWS_SECRET_ACCESS_KEY - - AWS_SESSION_TOKEN - - CMAKE_C_COMPILER_LAUNCHER - - CMAKE_CUDA_COMPILER_LAUNCHER - - CMAKE_CXX_COMPILER_LAUNCHER - - CMAKE_GENERATOR - - PARALLEL_LEVEL - - SCCACHE_BUCKET - - SCCACHE_IDLE_TIMEOUT - - SCCACHE_REGION - - SCCACHE_S3_KEY_PREFIX=librmm-aarch64 # [aarch64] - - SCCACHE_S3_KEY_PREFIX=librmm-linux64 # [linux64] - - SCCACHE_S3_USE_SSL - - SCCACHE_S3_NO_CREDENTIALS - -outputs: - - name: librmm - version: {{ version }} - script: install_librmm.sh - build: - number: {{ GIT_DESCRIBE_NUMBER }} - string: cuda{{ cuda_major }}_{{ date_string }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} - run_exports: - - {{ pin_subpackage("librmm", max_pin="x.x") }} - ignore_run_exports_from: - - {{ compiler('cuda') }} - requirements: - build: - - cmake {{ cmake_version }} - host: - - cuda-version ={{ cuda_version }} - run: - - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - {% if cuda_major == "11" %} - - cudatoolkit - {% endif %} - - rapids-logger =0.1 - test: - commands: - - test -d "${PREFIX}/include/rmm" - about: - home: https://rapids.ai/ - license: Apache-2.0 - summary: librmm library - - name: librmm-tests - version: {{ version }} - script: install_librmm_tests.sh - build: - number: {{ GIT_DESCRIBE_NUMBER }} - string: cuda{{ cuda_major }}_{{ date_string }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} - ignore_run_exports_from: - - {{ compiler('cuda') }} - {% if cuda_major != "11" %} - - cuda-cudart-dev - {% endif %} - requirements: - build: - - cmake {{ cmake_version }} - host: - - cuda-version ={{ cuda_version }} - {% if cuda_major == "11" %} - - cudatoolkit - {% else %} - - cuda-cudart-dev - {% endif %} - run: - {% if cuda_major == "11" %} - - cudatoolkit - {% else %} - - cuda-cudart - {% endif %} - - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - - {{ pin_subpackage('librmm', exact=True) }} - about: - home: https://rapids.ai/ - license: Apache-2.0 - summary: librmm test & benchmark executables diff --git a/conda/recipes/librmm/recipe.yaml b/conda/recipes/librmm/recipe.yaml new file mode 100644 index 000000000..115eb6202 --- /dev/null +++ b/conda/recipes/librmm/recipe.yaml @@ -0,0 +1,107 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/prefix-dev/recipe-format/main/schema.json +# Copyright (c) 2018-2025, NVIDIA CORPORATION. +schema_version: 1 + +context: + version: ${{ env.get("RAPIDS_PACKAGE_VERSION") }} + cuda_version: ${{ (env.get("RAPIDS_CUDA_VERSION") | split("."))[:2] | join(".") }} + cuda_major: ${{ (env.get("RAPIDS_CUDA_VERSION") | split("."))[0] }} + date_string: ${{ env.get("RAPIDS_DATE_STRING") }} + head_rev: ${{ git.head_rev(".")[:8] }} + +recipe: + name: librmm-split + +cache: + source: + path: ../../.. + + requirements: + build: + - cmake ${{ cmake_version }} + - ninja + - ${{ compiler("c") }} + - ${{ compiler("cxx") }} + - ${{ compiler("cuda") }} + - cuda-version =${{ cuda_version }} + - ${{ stdlib("c") }} + + build: + script: + file: build.sh + secrets: + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + - AWS_SESSION_TOKEN + + env: + CMAKE_C_COMPILER_LAUNCHER: ${{ env.get("CMAKE_C_COMPILER_LAUNCHER") }} + CMAKE_CUDA_COMPILER_LAUNCHER: ${{ env.get("CMAKE_CUDA_COMPILER_LAUNCHER") }} + CMAKE_CXX_COMPILER_LAUNCHER: ${{ env.get("CMAKE_CXX_COMPILER_LAUNCHER") }} + CMAKE_GENERATOR: ${{ env.get("CMAKE_GENERATOR") }} + PARALLEL_LEVEL: ${{ env.get("PARALLEL_LEVEL") }} + SCCACHE_BUCKET: ${{ env.get("SCCACHE_BUCKET") }} + SCCACHE_IDLE_TIMEOUT: ${{ env.get("SCCACHE_IDLE_TIMEOUT") }} + SCCACHE_REGION: ${{ env.get("SCCACHE_REGION") }} + SCCACHE_S3_USE_SSL: ${{ env.get("SCCACHE_S3_USE_SSL") }} + SCCACHE_S3_NO_CREDENTIALS: ${{ env.get("SCCACHE_S3_NO_CREDENTIALS") }} + SCCACHE_S3_KEY_PREFIX: librmm-${{ env.get("RAPIDS_CONDA_ARCH") }} + +outputs: + - package: + name: librmm + version: ${{ version }} + build: + string: cuda${{ cuda_major }}_${{ date_string }}_${{ head_rev }} + script: + - cmake --install build + requirements: + host: + - cmake ${{ cmake_version }} + - cuda-version =${{ cuda_version }} + run: + - ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }} + - if: cuda_major == "11" + then: cudatoolkit + - rapids-logger =0.1 + run_exports: + - ${{ pin_subpackage("librmm", upper_bound="x.x") }} + ignore_run_exports: + from_package: + - ${{ compiler("cuda") }} + tests: + - script: + - "test -d \"${PREFIX}/include/rmm\"" + about: + homepage: ${{ load_from_file("python/librmm/pyproject.toml").project.urls.Homepage }} + license: ${{ load_from_file("python/librmm/pyproject.toml").project.license.text }} + summary: ${{ load_from_file("python/librmm/pyproject.toml").project.description }} + - package: + name: librmm-tests + version: ${{ version }} + build: + string: cuda${{ cuda_major }}_${{ date_string }}_${{ head_rev }} + script: + - cmake --install build --component testing + requirements: + host: + - cmake ${{ cmake_version }} + - cuda-version =${{ cuda_version }} + - if: cuda_major == "11" + then: cudatoolkit + else: cuda-cudart-dev + run: + - if: cuda_major == "11" + then: cudatoolkit + else: cuda-cudart + - ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }} + - ${{ pin_subpackage("librmm", exact=True) }} + ignore_run_exports: + from_package: + - ${{ compiler("cuda") }} + - if: cuda_major == "11" + then: cuda-cudart-dev + about: + homepage: ${{ load_from_file("python/librmm/pyproject.toml").project.urls.Homepage }} + license: ${{ load_from_file("python/librmm/pyproject.toml").project.license.text | replace(" ", "-") }} + summary: librmm test & benchmark executables diff --git a/conda/recipes/rmm/meta.yaml b/conda/recipes/rmm/meta.yaml deleted file mode 100644 index 58c606c1f..000000000 --- a/conda/recipes/rmm/meta.yaml +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright (c) 2019-2025, NVIDIA CORPORATION. - -{% set version = environ['RAPIDS_PACKAGE_VERSION'].strip().lstrip('v') %} -{% set cuda_version = '.'.join(environ['RAPIDS_CUDA_VERSION'].split('.')[:2]) %} -{% set cuda_major = cuda_version.split('.')[0] %} -{% set py_version = environ['CONDA_PY'] %} -{% set date_string = environ['RAPIDS_DATE_STRING'] %} - -package: - name: rmm - version: {{ version }} - -source: - path: ../../.. - -build: - number: {{ GIT_DESCRIBE_NUMBER }} - string: cuda{{ cuda_major }}_py{{ py_version }}_{{ date_string }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} - script_env: - - AWS_ACCESS_KEY_ID - - AWS_SECRET_ACCESS_KEY - - AWS_SESSION_TOKEN - - CMAKE_C_COMPILER_LAUNCHER - - CMAKE_CUDA_COMPILER_LAUNCHER - - CMAKE_CXX_COMPILER_LAUNCHER - - CMAKE_GENERATOR - - SCCACHE_BUCKET - - SCCACHE_IDLE_TIMEOUT - - SCCACHE_REGION - - SCCACHE_S3_KEY_PREFIX=rmm-aarch64 # [aarch64] - - SCCACHE_S3_KEY_PREFIX=rmm-linux64 # [linux64] - - SCCACHE_S3_USE_SSL - - SCCACHE_S3_NO_CREDENTIALS - ignore_run_exports_from: - - {{ compiler('cuda') }} - {% if cuda_major != "11" %} - - cuda-cudart-dev - {% endif %} - - cuda-python - -requirements: - build: - - cmake {{ cmake_version }} - - ninja - - {{ compiler('c') }} - - {{ compiler('cxx') }} - {% if cuda_major == "11" %} - - {{ compiler('cuda') }} {{ cuda_version }} - {% else %} - - {{ compiler('cuda') }} - {% endif %} - - cuda-version ={{ cuda_version }} - - {{ stdlib("c") }} - host: - - cuda-version ={{ cuda_version }} - {% if cuda_major == "11" %} - - cudatoolkit - - cuda-python >=11.8.5,<12.0a0 - {% else %} - - cuda-cudart-dev - - cuda-python >=12.6.2,<13.0a0 - {% endif %} - - cython >=3.0.0 - - rapids-build-backend >=0.3.0,<0.4.0.dev0 - - librmm ={{ version }} - - python - - scikit-build-core >=0.10.0 - run: - {% if cuda_major == "11" %} - - cudatoolkit - - cuda-python >=11.8.5,<12.0a0 - {% else %} - - cuda-cudart - - cuda-python >=12.6.2,<13.0a0 - {% endif %} - - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - - numba >=0.59.1,<0.61.0a0 - - numpy >=1.23,<3.0a0 - - python - -test: - imports: - - rmm - -about: - home: https://rapids.ai/ - license: Apache-2.0 - license_family: Apache - license_file: LICENSE - summary: rmm library diff --git a/conda/recipes/rmm/recipe.yaml b/conda/recipes/rmm/recipe.yaml new file mode 100644 index 000000000..f85d44913 --- /dev/null +++ b/conda/recipes/rmm/recipe.yaml @@ -0,0 +1,91 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/prefix-dev/recipe-format/main/schema.json +# Copyright (c) 2019-2025, NVIDIA CORPORATION. + +context: + version: ${{ env.get("RAPIDS_PACKAGE_VERSION") }} + cuda_version: ${{ (env.get("RAPIDS_CUDA_VERSION") | split("."))[:2] | join(".") }} + cuda_major: ${{ (env.get("RAPIDS_CUDA_VERSION") | split("."))[0] }} + date_string: ${{ env.get("RAPIDS_DATE_STRING") }} + py_version: ${{ env.get("RAPIDS_PY_VERSION") }} + head_rev: ${{ git.head_rev(".")[:8] }} + +package: + name: rmm + version: ${{ version }} + +source: + - path: ../../.. + +build: + string: cuda${{ cuda_major }}_py${{ py_version }}_${{ date_string }}_${{ head_rev }} + script: + file: build.sh + secrets: + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + - AWS_SESSION_TOKEN + + env: + CMAKE_C_COMPILER_LAUNCHER: ${{ env.get("CMAKE_C_COMPILER_LAUNCHER") }} + CMAKE_CUDA_COMPILER_LAUNCHER: ${{ env.get("CMAKE_CUDA_COMPILER_LAUNCHER") }} + CMAKE_CXX_COMPILER_LAUNCHER: ${{ env.get("CMAKE_CXX_COMPILER_LAUNCHER") }} + CMAKE_GENERATOR: ${{ env.get("CMAKE_GENERATOR") }} + SCCACHE_BUCKET: ${{ env.get("SCCACHE_BUCKET") }} + SCCACHE_IDLE_TIMEOUT: ${{ env.get("SCCACHE_IDLE_TIMEOUT") }} + SCCACHE_REGION: ${{ env.get("SCCACHE_REGION") }} + SCCACHE_S3_USE_SSL: ${{ env.get("SCCACHE_S3_USE_SSL") }} + SCCACHE_S3_NO_CREDENTIALS: ${{ env.get("SCCACHE_S3_NO_CREDENTIALS") }} + SCCACHE_S3_KEY_PREFIX: rmm-${{ env.get("RAPIDS_CONDA_ARCH") }} + +requirements: + build: + - cmake ${{ cmake_version }} + - ninja + - ${{ compiler("c") }} + - ${{ compiler("cxx") }} + - ${{ compiler("cuda") }} + - cuda-version =${{ cuda_version }} + - ${{ stdlib("c") }} + host: + - cuda-version =${{ cuda_version }} + - if: cuda_major == "11" + then: + - cudatoolkit + - cuda-python >=11.8.5,<12.0a0 + else: + - cuda-cudart-dev + - cuda-python >=12.6.2,<13.0a0 + - cython >=3.0.0 + - rapids-build-backend >=0.3.0,<0.4.0.dev0 + - librmm =${{ version }} + - python + - pip + - scikit-build-core >=0.10.0 + run: + - if: cuda_major == "11" + then: + - cudatoolkit + - cuda-python >=11.8.5,<12.0a0 + else: + - cuda-cudart + - cuda-python >=12.6.2,<13.0a0 + - ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }} + - numpy >=1.23,<3.0a0 + - python + ignore_run_exports: + from_package: + - ${{ compiler("cuda") }} + - cuda-python + - if: not (cuda_major == "11") + then: "cuda-cudart-dev" + +tests: + - python: + imports: + - rmm + pip_check: false + +about: + homepage: ${{ load_from_file("python/rmm/pyproject.toml").project.urls.Homepage }} + license: ${{ load_from_file("python/rmm/pyproject.toml").project.license.text }} + summary: ${{ load_from_file("python/rmm/pyproject.toml").project.description }} diff --git a/dependencies.yaml b/dependencies.yaml index 53427d2dc..00edc5596 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -300,6 +300,7 @@ dependencies: - ipython - make - nbsphinx + - numba>=0.59.1,<0.61.0a0 - numpydoc - sphinx - sphinx_rtd_theme diff --git a/python/librmm/pyproject.toml b/python/librmm/pyproject.toml index f7a6f7088..930663066 100644 --- a/python/librmm/pyproject.toml +++ b/python/librmm/pyproject.toml @@ -27,7 +27,7 @@ readme = { file = "README.md", content-type = "text/markdown" } authors = [ { name = "NVIDIA Corporation" }, ] -license = { text = "Apache 2.0" } +license = { text = "Apache-2.0" } classifiers = [ "Intended Audience :: Developers", "Topic :: Database", diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 2771ee027..f6ba5415a 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -27,7 +27,7 @@ readme = { file = "README.md", content-type = "text/markdown" } authors = [ { name = "NVIDIA Corporation" }, ] -license = { text = "Apache 2.0" } +license = { text = "Apache-2.0" } requires-python = ">=3.10" dependencies = [ "cuda-python>=11.8.5,<12.0a0", From 0d6083b4f3e880b9b299c3ab083f563be00a085b Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Fri, 14 Feb 2025 13:51:43 -0500 Subject: [PATCH 556/675] Consolidate more Conda solves in CI (#1828) Issue: https://github.com/rapidsai/build-planning/issues/22 Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1828 --- ci/build_docs.sh | 20 ++++++++------------ dependencies.yaml | 2 ++ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/ci/build_docs.sh b/ci/build_docs.sh index a3562d973..ceb21ee80 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -3,34 +3,30 @@ set -euo pipefail +rapids-logger "Downloading artifacts from previous jobs" +CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) +PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) + rapids-logger "Create test conda environment" . /opt/conda/etc/profile.d/conda.sh -RAPIDS_VERSION="$(rapids-version)" RAPIDS_VERSION_MAJOR_MINOR="$(rapids-version-major-minor)" export RAPIDS_VERSION_MAJOR_MINOR rapids-dependency-file-generator \ --output conda \ --file-key docs \ - --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee env.yaml + --matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" \ + --prepend-channel "${CPP_CHANNEL}" \ + --prepend-channel "${PYTHON_CHANNEL}" \ + | tee env.yaml rapids-mamba-retry env create --yes -f env.yaml -n docs conda activate docs rapids-print-env -rapids-logger "Downloading artifacts from previous jobs" -CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) -PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) - -rapids-mamba-retry install \ - --channel "${CPP_CHANNEL}" \ - --channel "${PYTHON_CHANNEL}" \ - "rmm=${RAPIDS_VERSION}" \ - "librmm=${RAPIDS_VERSION}" - RAPIDS_DOCS_DIR="$(mktemp -d)" export RAPIDS_DOCS_DIR diff --git a/dependencies.yaml b/dependencies.yaml index 00edc5596..8b3b7a44a 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -44,6 +44,8 @@ files: - cuda_version - docs - py_version + - depends_on_rmm + - depends_on_librmm py_cpp_build: output: pyproject pyproject_dir: python/librmm From 1032c107a1e69f8d17f5db54a66d301d729a5308 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 21 Feb 2025 15:35:25 -0500 Subject: [PATCH 557/675] Require CMake 3.30.4 (#1826) Update CMake minimum required to 3.30.4 across all of RAPIDS Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Gil Forsyth (https://github.com/gforsyth) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1826 --- CMakeLists.txt | 2 +- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-128_arch-x86_64.yaml | 2 +- conda/recipes/librmm/conda_build_config.yaml | 2 +- conda/recipes/rmm/conda_build_config.yaml | 2 +- dependencies.yaml | 2 +- python/librmm/CMakeLists.txt | 4 ++-- python/librmm/pyproject.toml | 2 +- python/rmm/CMakeLists.txt | 2 +- python/rmm/pyproject.toml | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 480ae4445..19f851c06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ # the License. # ============================================================================= -cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) +cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR) include(rapids_config.cmake) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 6dfc4771a..a4c3b4cda 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -9,7 +9,7 @@ dependencies: - c-compiler - clang-tools==16.0.6 - clang==16.0.6 -- cmake>=3.26.4,!=3.30.0 +- cmake>=3.30.4 - cuda-python>=11.8.5,<12.0a0 - cuda-version=11.8 - cudatoolkit diff --git a/conda/environments/all_cuda-128_arch-x86_64.yaml b/conda/environments/all_cuda-128_arch-x86_64.yaml index c4eddb72a..0d4f5c378 100644 --- a/conda/environments/all_cuda-128_arch-x86_64.yaml +++ b/conda/environments/all_cuda-128_arch-x86_64.yaml @@ -9,7 +9,7 @@ dependencies: - c-compiler - clang-tools==16.0.6 - clang==16.0.6 -- cmake>=3.26.4,!=3.30.0 +- cmake>=3.30.4 - cuda-nvcc - cuda-python>=12.6.2,<13.0a0 - cuda-version=12.8 diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index 83f5ebcb1..0a1108eb5 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -17,4 +17,4 @@ c_stdlib_version: - "2.28" cmake_version: - - ">=3.26.4,!=3.30.0" + - ">=3.30.4" diff --git a/conda/recipes/rmm/conda_build_config.yaml b/conda/recipes/rmm/conda_build_config.yaml index 83f5ebcb1..0a1108eb5 100644 --- a/conda/recipes/rmm/conda_build_config.yaml +++ b/conda/recipes/rmm/conda_build_config.yaml @@ -17,4 +17,4 @@ c_stdlib_version: - "2.28" cmake_version: - - ">=3.26.4,!=3.30.0" + - ">=3.30.4" diff --git a/dependencies.yaml b/dependencies.yaml index 8b3b7a44a..2b0afbf3e 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -122,7 +122,7 @@ dependencies: common: - output_types: [conda, requirements, pyproject] packages: - - &cmake_ver cmake>=3.26.4,!=3.30.0 + - &cmake_ver cmake>=3.30.4 - ninja - output_types: conda packages: diff --git a/python/librmm/CMakeLists.txt b/python/librmm/CMakeLists.txt index a6035ac83..322215833 100644 --- a/python/librmm/CMakeLists.txt +++ b/python/librmm/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2024, NVIDIA CORPORATION. +# Copyright (c) 2024-2025, 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 @@ -12,7 +12,7 @@ # the License. # ============================================================================= -cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) +cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR) include(../../rapids_config.cmake) diff --git a/python/librmm/pyproject.toml b/python/librmm/pyproject.toml index 930663066..ad328415c 100644 --- a/python/librmm/pyproject.toml +++ b/python/librmm/pyproject.toml @@ -51,7 +51,7 @@ build-backend = "scikit_build_core.build" dependencies-file = "../../dependencies.yaml" matrix-entry = "cuda_suffixed=true" requires = [ - "cmake>=3.26.4,!=3.30.0", + "cmake>=3.30.4", "ninja", "rapids-logger==0.1.*,>=0.0.0a0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. diff --git a/python/rmm/CMakeLists.txt b/python/rmm/CMakeLists.txt index 2ee07605b..5e36025b2 100644 --- a/python/rmm/CMakeLists.txt +++ b/python/rmm/CMakeLists.txt @@ -12,7 +12,7 @@ # the License. # ============================================================================= -cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR) +cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR) include(../../rapids_config.cmake) diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index f6ba5415a..cc61bad98 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -75,7 +75,7 @@ build-backend = "scikit_build_core.build" dependencies-file = "../../dependencies.yaml" matrix-entry = "cuda_suffixed=true" requires = [ - "cmake>=3.26.4,!=3.30.0", + "cmake>=3.30.4", "cuda-python>=11.8.5,<12.0a0", "cython>=3.0.0", "librmm==25.4.*,>=0.0.0a0", From aa5d0b22065478c479aec5ea6906b5da9d29ddd6 Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Fri, 21 Feb 2025 18:31:39 -0500 Subject: [PATCH 558/675] Update rattler-build recipe with assorted small fixes (#1832) Removes the `.` from the `py_version` context variable and standardizes whitespace and section ordering Authors: - Gil Forsyth (https://github.com/gforsyth) - https://github.com/apps/pre-commit-ci - Bradley Dice (https://github.com/bdice) - James Lamb (https://github.com/jameslamb) Approvers: - James Lamb (https://github.com/jameslamb) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1832 --- .../all_cuda-118_arch-x86_64.yaml | 2 +- .../all_cuda-128_arch-x86_64.yaml | 2 +- conda/recipes/librmm/build.sh | 3 --- conda/recipes/librmm/recipe.yaml | 24 +++++++++---------- conda/recipes/rmm/build.sh | 4 ---- conda/recipes/rmm/recipe.yaml | 6 ++--- dependencies.yaml | 3 ++- 7 files changed, 19 insertions(+), 25 deletions(-) delete mode 100644 conda/recipes/librmm/build.sh delete mode 100644 conda/recipes/rmm/build.sh diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index a4c3b4cda..fd68b4c75 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -35,9 +35,9 @@ dependencies: - rapids-build-backend>=0.3.0,<0.4.0.dev0 - rapids-logger==0.1.*,>=0.0.0a0 - scikit-build-core >=0.10.0 -- sphinx - sphinx-copybutton - sphinx-markdown-tables +- sphinx<8.2.0 - sphinx_rtd_theme - sysroot_linux-64==2.28 name: all_cuda-118_arch-x86_64 diff --git a/conda/environments/all_cuda-128_arch-x86_64.yaml b/conda/environments/all_cuda-128_arch-x86_64.yaml index 0d4f5c378..0b1f61546 100644 --- a/conda/environments/all_cuda-128_arch-x86_64.yaml +++ b/conda/environments/all_cuda-128_arch-x86_64.yaml @@ -34,9 +34,9 @@ dependencies: - rapids-build-backend>=0.3.0,<0.4.0.dev0 - rapids-logger==0.1.*,>=0.0.0a0 - scikit-build-core >=0.10.0 -- sphinx - sphinx-copybutton - sphinx-markdown-tables +- sphinx<8.2.0 - sphinx_rtd_theme - sysroot_linux-64==2.28 name: all_cuda-128_arch-x86_64 diff --git a/conda/recipes/librmm/build.sh b/conda/recipes/librmm/build.sh deleted file mode 100644 index 8bf1cb7e3..000000000 --- a/conda/recipes/librmm/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -# Copyright (c) 2018-2022, NVIDIA CORPORATION. - -./build.sh -n -v clean librmm tests benchmarks --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" diff --git a/conda/recipes/librmm/recipe.yaml b/conda/recipes/librmm/recipe.yaml index 115eb6202..2519ff5b6 100644 --- a/conda/recipes/librmm/recipe.yaml +++ b/conda/recipes/librmm/recipe.yaml @@ -16,24 +16,14 @@ cache: source: path: ../../.. - requirements: - build: - - cmake ${{ cmake_version }} - - ninja - - ${{ compiler("c") }} - - ${{ compiler("cxx") }} - - ${{ compiler("cuda") }} - - cuda-version =${{ cuda_version }} - - ${{ stdlib("c") }} - build: script: - file: build.sh + content: + - ./build.sh -n -v clean librmm tests benchmarks --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" secrets: - AWS_ACCESS_KEY_ID - AWS_SECRET_ACCESS_KEY - AWS_SESSION_TOKEN - env: CMAKE_C_COMPILER_LAUNCHER: ${{ env.get("CMAKE_C_COMPILER_LAUNCHER") }} CMAKE_CUDA_COMPILER_LAUNCHER: ${{ env.get("CMAKE_CUDA_COMPILER_LAUNCHER") }} @@ -47,6 +37,16 @@ cache: SCCACHE_S3_NO_CREDENTIALS: ${{ env.get("SCCACHE_S3_NO_CREDENTIALS") }} SCCACHE_S3_KEY_PREFIX: librmm-${{ env.get("RAPIDS_CONDA_ARCH") }} + requirements: + build: + - cmake ${{ cmake_version }} + - ninja + - ${{ compiler("c") }} + - ${{ compiler("cxx") }} + - ${{ compiler("cuda") }} + - cuda-version =${{ cuda_version }} + - ${{ stdlib("c") }} + outputs: - package: name: librmm diff --git a/conda/recipes/rmm/build.sh b/conda/recipes/rmm/build.sh deleted file mode 100644 index 4facfce60..000000000 --- a/conda/recipes/rmm/build.sh +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (c) 2018-2019, NVIDIA CORPORATION. - -# Script assumes the script is executed from the root of the repo directory -./build.sh -v clean rmm --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" diff --git a/conda/recipes/rmm/recipe.yaml b/conda/recipes/rmm/recipe.yaml index f85d44913..f6469262b 100644 --- a/conda/recipes/rmm/recipe.yaml +++ b/conda/recipes/rmm/recipe.yaml @@ -6,7 +6,7 @@ context: cuda_version: ${{ (env.get("RAPIDS_CUDA_VERSION") | split("."))[:2] | join(".") }} cuda_major: ${{ (env.get("RAPIDS_CUDA_VERSION") | split("."))[0] }} date_string: ${{ env.get("RAPIDS_DATE_STRING") }} - py_version: ${{ env.get("RAPIDS_PY_VERSION") }} + py_version: ${{ env.get("RAPIDS_PY_VERSION") | version_to_buildstring }} head_rev: ${{ git.head_rev(".")[:8] }} package: @@ -19,12 +19,12 @@ source: build: string: cuda${{ cuda_major }}_py${{ py_version }}_${{ date_string }}_${{ head_rev }} script: - file: build.sh + content: + - ./build.sh -v clean rmm --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" secrets: - AWS_ACCESS_KEY_ID - AWS_SECRET_ACCESS_KEY - AWS_SESSION_TOKEN - env: CMAKE_C_COMPILER_LAUNCHER: ${{ env.get("CMAKE_C_COMPILER_LAUNCHER") }} CMAKE_CUDA_COMPILER_LAUNCHER: ${{ env.get("CMAKE_CUDA_COMPILER_LAUNCHER") }} diff --git a/dependencies.yaml b/dependencies.yaml index 2b0afbf3e..8b74437b0 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -304,7 +304,8 @@ dependencies: - nbsphinx - numba>=0.59.1,<0.61.0a0 - numpydoc - - sphinx + # this pin can be reverted when https://github.com/spatialaudio/nbsphinx/issues/825 is resolved + - sphinx<8.2.0 - sphinx_rtd_theme - sphinx-copybutton - sphinx-markdown-tables From 3f674e33236e3138f95eefc1dfed311c738d906a Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 24 Feb 2025 09:30:22 -0600 Subject: [PATCH 559/675] Depend on rapids-logger in host to prevent redistribution (#1834) Fixes redistribution of `rapids-logger` code which can cause clobbering. See #1833. After this change, the following paths should _not_ be in the `librmm` package: - `lib/librapids_logger.so` - `lib/cmake/rapids_logger/*` - `include/rapids_logger/*` Authors: - Bradley Dice (https://github.com/bdice) Approvers: - https://github.com/jakirkham - Gil Forsyth (https://github.com/gforsyth) URL: https://github.com/rapidsai/rmm/pull/1834 --- conda/recipes/librmm/recipe.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conda/recipes/librmm/recipe.yaml b/conda/recipes/librmm/recipe.yaml index 2519ff5b6..cbc96941c 100644 --- a/conda/recipes/librmm/recipe.yaml +++ b/conda/recipes/librmm/recipe.yaml @@ -46,6 +46,8 @@ cache: - ${{ compiler("cuda") }} - cuda-version =${{ cuda_version }} - ${{ stdlib("c") }} + host: + - rapids-logger =0.1 outputs: - package: From aa89babeb040dda520d08a55b6d4ce58e9eed275 Mon Sep 17 00:00:00 2001 From: Mike Sarahan Date: Mon, 24 Feb 2025 09:43:45 -0600 Subject: [PATCH 560/675] Sccache stats telemetry (#1830) This pr uses new functionality added to shared-actions and shared-workflows to capture sccache hit rate information. To add this to other repos, we'll need to make the slight alteration here: `sccache --show-adv-stats | tee ../../telemetry-artifacts/sccache-stats.txt` That is, output the sccache stats to a file with a particular name in the telemetry-artifacts folder. Authors: - Mike Sarahan (https://github.com/msarahan) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1830 --- .github/workflows/pr.yaml | 8 ++++---- ci/build_cpp.sh | 4 ++-- ci/build_python.sh | 4 ++-- ci/build_wheel_cpp.sh | 4 ++-- ci/build_wheel_python.sh | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index a5c44b0c2..43169c3f9 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -82,7 +82,7 @@ jobs: uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-25.04 with: enable_check_generated_files: false - ignored_pr_jobs: telemetry-summarize + ignored_pr_jobs: "telemetry-summarize" conda-cpp-build: needs: checks secrets: inherit @@ -151,9 +151,9 @@ jobs: arch: '["amd64"]' cuda: '["12.8"]' build_command: | - sccache -z; - build-all -DBUILD_BENCHMARKS=ON --verbose; - sccache -s; + sccache --zero-stats; + build-all -DBUILD_BENCHMARKS=ON --verbose 2>&1 | tee telemetry-artifacts/build.log; + sccache --show-adv-stats | tee telemetry-artifacts/sccache-stats.txt; telemetry-summarize: # This job must use a self-hosted runner to record telemetry traces. diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 8cf64b7b7..6e6737d71 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -30,9 +30,9 @@ rattler-build build --recipe conda/recipes/librmm \ --no-build-id \ --channel-priority disabled \ --output-dir "$RAPIDS_CONDA_BLD_OUTPUT_DIR" \ - "${RATTLER_CHANNELS[@]}" + "${RATTLER_CHANNELS[@]}" 2>&1 | tee telemetry-artifacts/build.log -sccache --show-adv-stats +sccache --show-adv-stats | tee telemetry-artifacts/sccache-stats.txt # remove build_cache directory rm -rf "$RAPIDS_CONDA_BLD_OUTPUT_DIR"/build_cache diff --git a/ci/build_python.sh b/ci/build_python.sh index 4f9b30ce7..7ae21b873 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -35,9 +35,9 @@ rattler-build build --recipe conda/recipes/rmm \ --channel-priority disabled \ --output-dir "$RAPIDS_CONDA_BLD_OUTPUT_DIR" \ -c "${CPP_CHANNEL}" \ - "${RATTLER_CHANNELS[@]}" + "${RATTLER_CHANNELS[@]}" 2>&1 | tee telemetry-artifacts/build.log -sccache --show-adv-stats +sccache --show-adv-stats | tee telemetry-artifacts/sccache-stats.txt # See https://github.com/prefix-dev/rattler-build/issues/1424 rm -rf "$RAPIDS_CONDA_BLD_OUTPUT_DIR"/build_cache diff --git a/ci/build_wheel_cpp.sh b/ci/build_wheel_cpp.sh index 9396e9cc5..23f325322 100755 --- a/ci/build_wheel_cpp.sh +++ b/ci/build_wheel_cpp.sh @@ -16,9 +16,9 @@ cd "${package_dir}" sccache --zero-stats -rapids-pip-retry wheel . -w dist -v --no-deps --disable-pip-version-check +rapids-pip-retry wheel . -w dist -v --no-deps --disable-pip-version-check 2>&1 | tee ../../telemetry-artifacts/build.log -sccache --show-adv-stats +sccache --show-adv-stats | tee ../../telemetry-artifacts/sccache-stats.txt python -m wheel tags --platform any dist/* --remove diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index 3fff53dfe..44d90b744 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -25,9 +25,9 @@ echo "librmm-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo "${CPP_WHEELHOUSE}"/librmm sccache --zero-stats PIP_CONSTRAINT="${PWD}/build-constraints.txt" \ - rapids-pip-retry wheel . -w dist -v --no-deps --disable-pip-version-check + rapids-pip-retry wheel . -w dist -v --no-deps --disable-pip-version-check 2>&1 | tee ../../telemetry-artifacts/build.log -sccache --show-adv-stats +sccache --show-adv-stats | tee ../../telemetry-artifacts/sccache-stats.txt mkdir -p final_dist EXCLUDE_ARGS=( From 88eaaaf4cfffdc4c4cdab805829e55be65707ee0 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 24 Feb 2025 10:15:15 -0600 Subject: [PATCH 561/675] Fixes for rattler recipe (#1835) Fixes for `build`/`host` dependencies in the rattler recipe for librmm. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Gil Forsyth (https://github.com/gforsyth) URL: https://github.com/rapidsai/rmm/pull/1835 --- conda/recipes/librmm/recipe.yaml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/conda/recipes/librmm/recipe.yaml b/conda/recipes/librmm/recipe.yaml index cbc96941c..809004610 100644 --- a/conda/recipes/librmm/recipe.yaml +++ b/conda/recipes/librmm/recipe.yaml @@ -58,8 +58,9 @@ outputs: script: - cmake --install build requirements: - host: + build: - cmake ${{ cmake_version }} + host: - cuda-version =${{ cuda_version }} run: - ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }} @@ -69,8 +70,8 @@ outputs: run_exports: - ${{ pin_subpackage("librmm", upper_bound="x.x") }} ignore_run_exports: - from_package: - - ${{ compiler("cuda") }} + by_name: + - cuda-version tests: - script: - "test -d \"${PREFIX}/include/rmm\"" @@ -86,8 +87,9 @@ outputs: script: - cmake --install build --component testing requirements: - host: + build: - cmake ${{ cmake_version }} + host: - cuda-version =${{ cuda_version }} - if: cuda_major == "11" then: cudatoolkit @@ -100,9 +102,10 @@ outputs: - ${{ pin_subpackage("librmm", exact=True) }} ignore_run_exports: from_package: - - ${{ compiler("cuda") }} - - if: cuda_major == "11" + - if: cuda_major != "11" then: cuda-cudart-dev + by_name: + - cuda-version about: homepage: ${{ load_from_file("python/librmm/pyproject.toml").project.urls.Homepage }} license: ${{ load_from_file("python/librmm/pyproject.toml").project.license.text | replace(" ", "-") }} From e9f7f21dbab0e22d757dd58bb21f4bc8135cdb36 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 25 Feb 2025 12:29:54 -0600 Subject: [PATCH 562/675] Use static gbench (#1837) RMM benchmarks should statically link Google Benchmark. We saw they were linking to `libbenchmark.so` while working with rattler-build: https://github.com/rapidsai/rmm/pull/1836#discussion_r1970206227 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Gil Forsyth (https://github.com/gforsyth) - Kyle Edwards (https://github.com/KyleFromNVIDIA) URL: https://github.com/rapidsai/rmm/pull/1837 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 19f851c06..f97e3c5a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,7 +140,7 @@ endif() if(BUILD_BENCHMARKS AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) include(${rapids-cmake-dir}/cpm/gbench.cmake) - rapids_cpm_gbench() + rapids_cpm_gbench(BUILD_STATIC) add_subdirectory(benchmarks) endif() From 0e34885c429725607f80512b6651cb374bd1cb80 Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Tue, 25 Feb 2025 17:49:02 -0500 Subject: [PATCH 563/675] fix(rattler): resolve all overlinking errors (#1836) Turns on erroring for overlinking errors and fixes all of those errors. I've reduced the number of overdepending warnings, but `rapids-logger` seems to consistently cause an overdepending warning, so I haven't yet switched that to error mode. Authors: - Gil Forsyth (https://github.com/gforsyth) - Bradley Dice (https://github.com/bdice) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1836 --- conda/recipes/librmm/recipe.yaml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/conda/recipes/librmm/recipe.yaml b/conda/recipes/librmm/recipe.yaml index 809004610..34d11be8d 100644 --- a/conda/recipes/librmm/recipe.yaml +++ b/conda/recipes/librmm/recipe.yaml @@ -57,6 +57,8 @@ outputs: string: cuda${{ cuda_major }}_${{ date_string }}_${{ head_rev }} script: - cmake --install build + dynamic_linking: + overlinking_behavior: "error" requirements: build: - cmake ${{ cmake_version }} @@ -72,6 +74,8 @@ outputs: ignore_run_exports: by_name: - cuda-version + - if: cuda_major == "11" + then: cudatoolkit tests: - script: - "test -d \"${PREFIX}/include/rmm\"" @@ -79,33 +83,40 @@ outputs: homepage: ${{ load_from_file("python/librmm/pyproject.toml").project.urls.Homepage }} license: ${{ load_from_file("python/librmm/pyproject.toml").project.license.text }} summary: ${{ load_from_file("python/librmm/pyproject.toml").project.description }} + - package: name: librmm-tests version: ${{ version }} build: string: cuda${{ cuda_major }}_${{ date_string }}_${{ head_rev }} - script: - - cmake --install build --component testing + script: cmake --install build --component testing + dynamic_linking: + overlinking_behavior: "error" requirements: build: - cmake ${{ cmake_version }} + - ${{ stdlib("c") }} # this is here to help with overlinking errors against libm.so.6 and friends host: + - ${{ pin_subpackage("librmm", exact=True) }} - cuda-version =${{ cuda_version }} - if: cuda_major == "11" then: cudatoolkit else: cuda-cudart-dev run: + - ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }} + - ${{ pin_subpackage("librmm", exact=True) }} + - rapids-logger =0.1 - if: cuda_major == "11" then: cudatoolkit else: cuda-cudart - - ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }} - - ${{ pin_subpackage("librmm", exact=True) }} ignore_run_exports: from_package: - if: cuda_major != "11" then: cuda-cudart-dev by_name: - cuda-version + - if: cuda_major == "11" + then: cudatoolkit about: homepage: ${{ load_from_file("python/librmm/pyproject.toml").project.urls.Homepage }} license: ${{ load_from_file("python/librmm/pyproject.toml").project.license.text | replace(" ", "-") }} From a7577403c90baf6ea93c67e71703933efa884570 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 25 Feb 2025 18:56:44 -0600 Subject: [PATCH 564/675] Add telemetry setup to build workflows (#1838) Telemetry is causing build workflows to fail. This adds `telemetry-setup` to the `build.yaml` workflow. Authors: - Bradley Dice (https://github.com/bdice) - Mike Sarahan (https://github.com/msarahan) Approvers: - Mike Sarahan (https://github.com/msarahan) URL: https://github.com/rapidsai/rmm/pull/1838 --- .github/workflows/build.yaml | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 29e7fc451..8b66806f6 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -26,7 +26,19 @@ concurrency: cancel-in-progress: true jobs: + telemetry-setup: + runs-on: ubuntu-latest + continue-on-error: true + env: + OTEL_SERVICE_NAME: "build-rmm" + steps: + - name: Telemetry setup + # This gate is here and not at the job level because we need the job to not be skipped, + # since other jobs depend on it. + if: ${{ vars.TELEMETRY_ENABLED == 'true' }} + uses: rapidsai/shared-actions/telemetry-dispatch-stash-base-env-vars@main cpp-build: + needs: [telemetry-setup] secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.04 with: @@ -35,7 +47,7 @@ jobs: date: ${{ inputs.date }} sha: ${{ inputs.sha }} python-build: - needs: [cpp-build] + needs: [telemetry-setup, cpp-build] secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.04 with: @@ -54,7 +66,7 @@ jobs: sha: ${{ inputs.sha }} docs-build: if: github.ref_type == 'branch' - needs: python-build + needs: [python-build] secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.04 with: @@ -67,6 +79,7 @@ jobs: container_image: "rapidsai/ci-conda:latest" run_script: "ci/build_docs.sh" wheel-build-cpp: + needs: [telemetry-setup] secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.04 with: @@ -77,7 +90,7 @@ jobs: date: ${{ inputs.date }} script: ci/build_wheel_cpp.sh wheel-build-python: - needs: wheel-build-cpp + needs: [telemetry-setup, wheel-build-cpp] secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.04 with: @@ -108,3 +121,12 @@ jobs: date: ${{ inputs.date }} package-name: rmm package-type: python + telemetry-summarize: + # This job must use a self-hosted runner to record telemetry traces. + runs-on: linux-amd64-cpu4 + needs: [wheel-publish-cpp, wheel-publish-python, upload-conda, docs-build] + if: ${{ vars.TELEMETRY_ENABLED == 'true' && !cancelled() }} + continue-on-error: true + steps: + - name: Telemetry summarize + uses: rapidsai/shared-actions/telemetry-dispatch-summarize@main From f26cc7e2e7dc2eda67054d1509a532315a241513 Mon Sep 17 00:00:00 2001 From: Mike Sarahan Date: Wed, 26 Feb 2025 07:55:44 -0600 Subject: [PATCH 565/675] use gha-tools rapids-telemetry-setup for mkdir -p (#1839) Please refer to https://github.com/rapidsai/gha-tools/pull/148 for explanation here. Authors: - Mike Sarahan (https://github.com/msarahan) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1839 --- ci/build_cpp.sh | 7 +++++-- ci/build_python.sh | 7 +++++-- ci/build_wheel_cpp.sh | 7 +++++-- ci/build_wheel_python.sh | 7 +++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 6e6737d71..8321215fa 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -22,6 +22,9 @@ export RAPIDS_PACKAGE_VERSION # Creates and exports $RATTLER_CHANNELS source rapids-rattler-channel-string +# Creates artifacts directory for telemetry +source rapids-telemetry-setup + # --no-build-id allows for caching with `sccache` # more info is available at # https://rattler.build/latest/tips_and_tricks/#using-sccache-or-ccache-with-rattler-build @@ -30,9 +33,9 @@ rattler-build build --recipe conda/recipes/librmm \ --no-build-id \ --channel-priority disabled \ --output-dir "$RAPIDS_CONDA_BLD_OUTPUT_DIR" \ - "${RATTLER_CHANNELS[@]}" 2>&1 | tee telemetry-artifacts/build.log + "${RATTLER_CHANNELS[@]}" 2>&1 | tee ${GITHUB_WORKSPACE}/telemetry-artifacts/build.log -sccache --show-adv-stats | tee telemetry-artifacts/sccache-stats.txt +sccache --show-adv-stats | tee ${GITHUB_WORKSPACE}/telemetry-artifacts/sccache-stats.txt # remove build_cache directory rm -rf "$RAPIDS_CONDA_BLD_OUTPUT_DIR"/build_cache diff --git a/ci/build_python.sh b/ci/build_python.sh index 7ae21b873..f822efd50 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -26,6 +26,9 @@ export RAPIDS_PACKAGE_VERSION # Creates and exports $RATTLER_CHANNELS source rapids-rattler-channel-string +# Creates artifacts directory for telemetry +source rapids-telemetry-setup + # --no-build-id allows for caching with `sccache` # more info is available at # https://rattler.build/latest/tips_and_tricks/#using-sccache-or-ccache-with-rattler-build @@ -35,9 +38,9 @@ rattler-build build --recipe conda/recipes/rmm \ --channel-priority disabled \ --output-dir "$RAPIDS_CONDA_BLD_OUTPUT_DIR" \ -c "${CPP_CHANNEL}" \ - "${RATTLER_CHANNELS[@]}" 2>&1 | tee telemetry-artifacts/build.log + "${RATTLER_CHANNELS[@]}" 2>&1 | tee ${GITHUB_WORKSPACE}/telemetry-artifacts/build.log -sccache --show-adv-stats | tee telemetry-artifacts/sccache-stats.txt +sccache --show-adv-stats | tee ${GITHUB_WORKSPACE}/telemetry-artifacts/sccache-stats.txt # See https://github.com/prefix-dev/rattler-build/issues/1424 rm -rf "$RAPIDS_CONDA_BLD_OUTPUT_DIR"/build_cache diff --git a/ci/build_wheel_cpp.sh b/ci/build_wheel_cpp.sh index 23f325322..0605aafc2 100755 --- a/ci/build_wheel_cpp.sh +++ b/ci/build_wheel_cpp.sh @@ -16,9 +16,12 @@ cd "${package_dir}" sccache --zero-stats -rapids-pip-retry wheel . -w dist -v --no-deps --disable-pip-version-check 2>&1 | tee ../../telemetry-artifacts/build.log +# Creates artifacts directory for telemetry +source rapids-telemetry-setup -sccache --show-adv-stats | tee ../../telemetry-artifacts/sccache-stats.txt +rapids-pip-retry wheel . -w dist -v --no-deps --disable-pip-version-check 2>&1 | tee ${GITHUB_WORKSPACE}/telemetry-artifacts/build.log + +sccache --show-adv-stats | tee ${GITHUB_WORKSPACE}/telemetry-artifacts/sccache-stats.txt python -m wheel tags --platform any dist/* --remove diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index 44d90b744..7438b102e 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -24,10 +24,13 @@ echo "librmm-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo "${CPP_WHEELHOUSE}"/librmm sccache --zero-stats +# Creates artifacts directory for telemetry +source rapids-telemetry-setup + PIP_CONSTRAINT="${PWD}/build-constraints.txt" \ - rapids-pip-retry wheel . -w dist -v --no-deps --disable-pip-version-check 2>&1 | tee ../../telemetry-artifacts/build.log + rapids-pip-retry wheel . -w dist -v --no-deps --disable-pip-version-check 2>&1 | tee ${GITHUB_WORKSPACE}/telemetry-artifacts/build.log -sccache --show-adv-stats | tee ../../telemetry-artifacts/sccache-stats.txt +sccache --show-adv-stats | tee ${GITHUB_WORKSPACE}/telemetry-artifacts/sccache-stats.txt mkdir -p final_dist EXCLUDE_ARGS=( From d1a5f1baf61128ff35222df5e9be7744bec6d66e Mon Sep 17 00:00:00 2001 From: Paul Mattione <156858817+pmattione-nvidia@users.noreply.github.com> Date: Wed, 26 Feb 2025 11:15:44 -0500 Subject: [PATCH 566/675] Add OOM fail reason, attempted allocation size to exception messages (#1827) This PR addresses the following issues: 1. Closes [Issue 1791](https://github.com/rapidsai/rmm/issues/1791): It forwards on the details for why we got an OOM exception in `try_to_expand()`. It also does a more thorough job of forwarding on failure details in other locations. A test has been added to test this case explicitly. 2. Closes [Issue 1134](https://github.com/rapidsai/rmm/issues/1134): It adds the size of attempted allocations to the OOM and bad_alloc exceptions. Notes: 1. These code paths are already tested by the numerous `EXPECT_THROW()` macros already in the tests, and one more test was explicitly added. 2. The modified loop in `try_to_expand()` in `pool_memory_resource.hpp` attempts to allocate for the case where `try_size` is less than `min_size`, whereas before it just immediately errored. If this isn't the behavior we want I can change it. Previously it was just erroring that we didn't have enough memory, which isn't right either. Authors: - Paul Mattione (https://github.com/pmattione-nvidia) - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) - Alessandro Bellina (https://github.com/abellina) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1827 --- .../multi_stream_allocations_bench.cu | 8 ++- .../utilities/simulated_memory_resource.hpp | 7 ++- include/rmm/detail/error.hpp | 41 ++++++++------- .../rmm/mr/device/arena_memory_resource.hpp | 4 +- .../cuda_async_view_memory_resource.hpp | 3 +- .../rmm/mr/device/cuda_memory_resource.hpp | 4 +- .../detail/stream_ordered_memory_resource.hpp | 3 +- .../mr/device/limiting_resource_adaptor.hpp | 5 +- .../rmm/mr/device/managed_memory_resource.hpp | 4 +- .../rmm/mr/device/pool_memory_resource.hpp | 51 +++++++++++-------- .../rmm/mr/device/system_memory_resource.hpp | 5 +- .../rmm/mr/host/pinned_memory_resource.hpp | 3 +- .../rmm/mr/pinned_host_memory_resource.hpp | 2 +- 13 files changed, 82 insertions(+), 58 deletions(-) diff --git a/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu b/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu index b5edbb536..8ada45262 100644 --- a/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu +++ b/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, NVIDIA CORPORATION. + * Copyright (c) 2021-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -138,9 +138,7 @@ MRFactoryFunc get_mr_factory(std::string const& resource_name) if (resource_name == "arena") { return &make_arena; } if (resource_name == "binning") { return &make_binning; } - std::cout << "Error: invalid memory_resource name: " << resource_name << std::endl; - - RMM_FAIL(); + RMM_FAIL("Invalid memory_resource name: " + resource_name); } void declare_benchmark(std::string const& name) @@ -175,7 +173,7 @@ void declare_benchmark(std::string const& name) return; } - std::cout << "Error: invalid memory_resource name: " << name << std::endl; + RMM_FAIL("Invalid memory_resource name: " + name); } // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) diff --git a/benchmarks/utilities/simulated_memory_resource.hpp b/benchmarks/utilities/simulated_memory_resource.hpp index 556afb889..4ca243e1c 100644 --- a/benchmarks/utilities/simulated_memory_resource.hpp +++ b/benchmarks/utilities/simulated_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,7 +65,10 @@ class simulated_memory_resource final : public device_memory_resource { void* do_allocate(std::size_t bytes, cuda_stream_view) override { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - RMM_EXPECTS(begin_ + bytes <= end_, "Simulated memory size exceeded", rmm::bad_alloc); + RMM_EXPECTS(begin_ + bytes <= end_, + "Simulated memory size exceeded (failed to allocate " + + rmm::detail::format_bytes(bytes) + ")", + rmm::bad_alloc); auto* ptr = static_cast(begin_); begin_ += bytes; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) return ptr; diff --git a/include/rmm/detail/error.hpp b/include/rmm/detail/error.hpp index 79219eff0..5bf50a89b 100644 --- a/include/rmm/detail/error.hpp +++ b/include/rmm/detail/error.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,11 +55,11 @@ GET_RMM_EXPECTS_MACRO(__VA_ARGS__, RMM_EXPECTS_3, RMM_EXPECTS_2) \ (__VA_ARGS__) #define GET_RMM_EXPECTS_MACRO(_1, _2, _3, NAME, ...) NAME -#define RMM_EXPECTS_3(_condition, _reason, _exception_type) \ - (!!(_condition)) ? static_cast(0) \ - : throw _exception_type /*NOLINT(bugprone-macro-parentheses)*/ \ - { \ - "RMM failure at: " __FILE__ ":" RMM_STRINGIFY(__LINE__) ": " _reason \ +#define RMM_EXPECTS_3(_condition, _reason, _exception_type) \ + (!!(_condition)) ? static_cast(0) \ + : throw _exception_type /*NOLINT(bugprone-macro-parentheses)*/ \ + { \ + std::string("RMM failure at: " __FILE__ ":" RMM_STRINGIFY(__LINE__) ": ") + _reason \ } #define RMM_EXPECTS_2(_condition, _reason) RMM_EXPECTS_3(_condition, _reason, rmm::logic_error) @@ -79,9 +79,10 @@ GET_RMM_FAIL_MACRO(__VA_ARGS__, RMM_FAIL_2, RMM_FAIL_1) \ (__VA_ARGS__) #define GET_RMM_FAIL_MACRO(_1, _2, NAME, ...) NAME -#define RMM_FAIL_2(_what, _exception_type) \ - /*NOLINTNEXTLINE(bugprone-macro-parentheses)*/ \ - throw _exception_type{"RMM failure at:" __FILE__ ":" RMM_STRINGIFY(__LINE__) ": " _what}; +#define RMM_FAIL_2(_what, _exception_type) \ + /*NOLINTNEXTLINE(bugprone-macro-parentheses)*/ \ + throw _exception_type{std::string{"RMM failure at:" __FILE__ ":" RMM_STRINGIFY(__LINE__) ": "} + \ + _what}; #define RMM_FAIL_1(_what) RMM_FAIL_2(_what, rmm::logic_error) /** @@ -132,16 +133,18 @@ * Defaults to throwing rmm::bad_alloc, but when `cudaErrorMemoryAllocation` is returned, * rmm::out_of_memory is thrown instead. */ -#define RMM_CUDA_TRY_ALLOC(_call) \ - do { \ - cudaError_t const error = (_call); \ - if (cudaSuccess != error) { \ - cudaGetLastError(); \ - auto const msg = std::string{"CUDA error at: "} + __FILE__ + ":" + RMM_STRINGIFY(__LINE__) + \ - ": " + cudaGetErrorName(error) + " " + cudaGetErrorString(error); \ - if (cudaErrorMemoryAllocation == error) { throw rmm::out_of_memory{msg}; } \ - throw rmm::bad_alloc{msg}; \ - } \ +#define RMM_CUDA_TRY_ALLOC(_call, num_bytes) \ + do { \ + cudaError_t const error = (_call); \ + if (cudaSuccess != error) { \ + cudaGetLastError(); \ + auto const msg = std::string{"CUDA error (failed to allocate "} + \ + std::to_string(num_bytes) + " bytes) at: " + __FILE__ + ":" + \ + RMM_STRINGIFY(__LINE__) + ": " + cudaGetErrorName(error) + " " + \ + cudaGetErrorString(error); \ + if (cudaErrorMemoryAllocation == error) { throw rmm::out_of_memory{msg}; } \ + throw rmm::bad_alloc{msg}; \ + } \ } while (0) /** diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index f8e4e16cb..6aaa659ec 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -166,7 +166,9 @@ class arena_memory_resource final : public device_memory_resource { void* pointer = arena.allocate(bytes); if (pointer == nullptr) { if (dump_log_on_failure_) { dump_memory_log(bytes); } - RMM_FAIL("Maximum pool size exceeded", rmm::out_of_memory); + auto const msg = std::string("Maximum pool size exceeded (failed to allocate ") + + rmm::detail::format_bytes(bytes) + "): No room in arena."; + RMM_FAIL(msg.c_str(), rmm::out_of_memory); } return pointer; } diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index a4ae74394..92aea2072 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -98,7 +98,8 @@ class cuda_async_view_memory_resource final : public device_memory_resource { { void* ptr{nullptr}; if (bytes > 0) { - RMM_CUDA_TRY_ALLOC(cudaMallocFromPoolAsync(&ptr, bytes, pool_handle(), stream.value())); + RMM_CUDA_TRY_ALLOC(cudaMallocFromPoolAsync(&ptr, bytes, pool_handle(), stream.value()), + bytes); } return ptr; } diff --git a/include/rmm/mr/device/cuda_memory_resource.hpp b/include/rmm/mr/device/cuda_memory_resource.hpp index 4e88ac81e..e4afbf711 100644 --- a/include/rmm/mr/device/cuda_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2024, NVIDIA CORPORATION. + * Copyright (c) 2019-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ class cuda_memory_resource final : public device_memory_resource { void* do_allocate(std::size_t bytes, [[maybe_unused]] cuda_stream_view stream) override { void* ptr{nullptr}; - RMM_CUDA_TRY_ALLOC(cudaMalloc(&ptr, bytes)); + RMM_CUDA_TRY_ALLOC(cudaMalloc(&ptr, bytes), bytes); return ptr; } diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index ad676bfd2..5b1476d37 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -214,7 +214,8 @@ class stream_ordered_memory_resource : public crtp, public device_ size = rmm::align_up(size, rmm::CUDA_ALLOCATION_ALIGNMENT); RMM_EXPECTS(size <= this->underlying().get_maximum_allocation_size(), - "Maximum allocation size exceeded", + std::string("Maximum allocation size exceeded (failed to allocate ") + + rmm::detail::format_bytes(size) + ")", rmm::out_of_memory); auto const block = this->underlying().get_block(size, stream_event); diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index 96d730191..d551fbdb3 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -150,7 +151,9 @@ class limiting_resource_adaptor final : public device_memory_resource { } allocated_bytes_ -= proposed_size; - RMM_FAIL("Exceeded memory limit", rmm::out_of_memory); + auto const msg = std::string("Exceeded memory limit (failed to allocate ") + + rmm::detail::format_bytes(bytes) + ")"; + RMM_FAIL(msg.c_str(), rmm::out_of_memory); } /** diff --git a/include/rmm/mr/device/managed_memory_resource.hpp b/include/rmm/mr/device/managed_memory_resource.hpp index 6fc0cdd4c..3ade7fb53 100644 --- a/include/rmm/mr/device/managed_memory_resource.hpp +++ b/include/rmm/mr/device/managed_memory_resource.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2024, NVIDIA CORPORATION. + * Copyright (c) 2019-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +63,7 @@ class managed_memory_resource final : public device_memory_resource { if (bytes == 0) { return nullptr; } void* ptr{nullptr}; - RMM_CUDA_TRY_ALLOC(cudaMallocManaged(&ptr, bytes)); + RMM_CUDA_TRY_ALLOC(cudaMallocManaged(&ptr, bytes), bytes); return ptr; } diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index dee0471b9..46920da15 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -252,21 +252,24 @@ class pool_memory_resource final */ block_type try_to_expand(std::size_t try_size, std::size_t min_size, cuda_stream_view stream) { - while (try_size >= min_size) { - auto block = block_from_upstream(try_size, stream); - if (block.has_value()) { - current_pool_size_ += block.value().size(); - return block.value(); - } - if (try_size == min_size) { - break; // only try `size` once + while (true) { + try { + auto block = block_from_upstream(try_size, stream); + current_pool_size_ += block.size(); + return block; + } catch (std::exception const& e) { + if (try_size <= min_size) { + RMM_LOG_ERROR("[A][Stream %s][Upstream %zuB][FAILURE maximum pool size exceeded: %s]", + rmm::detail::format_stream(stream), + try_size, + e.what()); + auto const msg = std::string("Maximum pool size exceeded (failed to allocate ") + + rmm::detail::format_bytes(try_size) + std::string("): ") + e.what(); + RMM_FAIL(msg.c_str(), rmm::out_of_memory); + } } try_size = std::max(min_size, try_size / 2); } - RMM_LOG_ERROR("[A][Stream %s][Upstream %zuB][FAILURE maximum pool size exceeded]", - rmm::detail::format_stream(stream), - min_size); - RMM_FAIL("Maximum pool size exceeded", rmm::out_of_memory); } /** @@ -307,6 +310,18 @@ class pool_memory_resource final // limit each time. If it is not set, grow exponentially, e.g. by doubling the pool size each // time. Upon failure, attempt to back off exponentially, e.g. by half the attempted size, // until either success or the attempt is less than the requested size. + + if (maximum_pool_size_.has_value()) { + auto const max_size = maximum_pool_size_.value(); + if (size > max_size) { + auto const msg = std::string("Maximum pool size exceeded (failed to allocate ") + + rmm::detail::format_bytes(size) + + std::string("): Request larger than capacity (") + + rmm::detail::format_bytes(max_size) + std::string(")"); + RMM_FAIL(msg.c_str(), rmm::out_of_memory); + } + } + return try_to_expand(size_to_grow(size), size, stream); } @@ -339,21 +354,17 @@ class pool_memory_resource final * * @param size The size in bytes to allocate from the upstream resource * @param stream The stream on which the memory is to be used. + * @throws if call to allocate_async() throws * @return block_type The allocated block */ - std::optional block_from_upstream(std::size_t size, cuda_stream_view stream) + block_type block_from_upstream(std::size_t size, cuda_stream_view stream) { RMM_LOG_DEBUG("[A][Stream %s][Upstream %zuB]", rmm::detail::format_stream(stream), size); if (size == 0) { return {}; } - try { - void* ptr = get_upstream_resource().allocate_async(size, stream); - return std::optional{ - *upstream_blocks_.emplace(static_cast(ptr), size, true).first}; - } catch (std::exception const& e) { - return std::nullopt; - } + void* ptr = get_upstream_resource().allocate_async(size, stream); + return *upstream_blocks_.emplace(static_cast(ptr), size, true).first; } /** diff --git a/include/rmm/mr/device/system_memory_resource.hpp b/include/rmm/mr/device/system_memory_resource.hpp index 666a7a9c4..34c16f719 100644 --- a/include/rmm/mr/device/system_memory_resource.hpp +++ b/include/rmm/mr/device/system_memory_resource.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -103,7 +104,9 @@ class system_memory_resource final : public device_memory_resource { return rmm::detail::aligned_host_allocate( bytes, CUDA_ALLOCATION_ALIGNMENT, [](std::size_t size) { return ::operator new(size); }); } catch (std::bad_alloc const& e) { - RMM_FAIL("Failed to allocate memory: " + std::string{e.what()}, rmm::out_of_memory); + auto const msg = std::string("Failed to allocate ") + rmm::detail::format_bytes(bytes) + + std::string("of memory: ") + e.what(); + RMM_FAIL(msg.c_str(), rmm::out_of_memory); } } diff --git a/include/rmm/mr/host/pinned_memory_resource.hpp b/include/rmm/mr/host/pinned_memory_resource.hpp index cf746f5ac..f75a8f7be 100644 --- a/include/rmm/mr/host/pinned_memory_resource.hpp +++ b/include/rmm/mr/host/pinned_memory_resource.hpp @@ -122,8 +122,7 @@ class pinned_memory_resource final : public host_memory_resource { return rmm::detail::aligned_host_allocate(bytes, alignment, [](std::size_t size) { void* ptr{nullptr}; - auto status = cudaMallocHost(&ptr, size); - if (cudaSuccess != status) { throw std::bad_alloc{}; } + RMM_CUDA_TRY_ALLOC(cudaMallocHost(&ptr, size), size); return ptr; }); } diff --git a/include/rmm/mr/pinned_host_memory_resource.hpp b/include/rmm/mr/pinned_host_memory_resource.hpp index b5689b3ed..3f5878171 100644 --- a/include/rmm/mr/pinned_host_memory_resource.hpp +++ b/include/rmm/mr/pinned_host_memory_resource.hpp @@ -72,7 +72,7 @@ class pinned_host_memory_resource { return rmm::detail::aligned_host_allocate(bytes, alignment, [](std::size_t size) { void* ptr{nullptr}; - RMM_CUDA_TRY_ALLOC(cudaHostAlloc(&ptr, size, cudaHostAllocDefault)); + RMM_CUDA_TRY_ALLOC(cudaHostAlloc(&ptr, size, cudaHostAllocDefault), size); return ptr; }); } From 81ea8641e2cc5bf60e757fad8649709839bf4ffd Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Wed, 26 Feb 2025 15:35:51 -0500 Subject: [PATCH 567/675] fix(rattler): force `cuda_major` and `date_string` to be strings (#1842) Downstream `cudf` is having trouble solving because `rmm` claims it needs `cuda12` for a `cuda11` environment. This is because `rattler` likes to make things integers and the string comparisons fail for the selectors. So we force them to be strings. Authors: - Gil Forsyth (https://github.com/gforsyth) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1842 --- conda/recipes/librmm/recipe.yaml | 4 ++-- conda/recipes/rmm/recipe.yaml | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/conda/recipes/librmm/recipe.yaml b/conda/recipes/librmm/recipe.yaml index 34d11be8d..a59f67122 100644 --- a/conda/recipes/librmm/recipe.yaml +++ b/conda/recipes/librmm/recipe.yaml @@ -5,8 +5,8 @@ schema_version: 1 context: version: ${{ env.get("RAPIDS_PACKAGE_VERSION") }} cuda_version: ${{ (env.get("RAPIDS_CUDA_VERSION") | split("."))[:2] | join(".") }} - cuda_major: ${{ (env.get("RAPIDS_CUDA_VERSION") | split("."))[0] }} - date_string: ${{ env.get("RAPIDS_DATE_STRING") }} + cuda_major: '${{ (env.get("RAPIDS_CUDA_VERSION") | split("."))[0] }}' + date_string: '${{ env.get("RAPIDS_DATE_STRING") }}' head_rev: ${{ git.head_rev(".")[:8] }} recipe: diff --git a/conda/recipes/rmm/recipe.yaml b/conda/recipes/rmm/recipe.yaml index f6469262b..82d77f3d3 100644 --- a/conda/recipes/rmm/recipe.yaml +++ b/conda/recipes/rmm/recipe.yaml @@ -4,9 +4,10 @@ context: version: ${{ env.get("RAPIDS_PACKAGE_VERSION") }} cuda_version: ${{ (env.get("RAPIDS_CUDA_VERSION") | split("."))[:2] | join(".") }} - cuda_major: ${{ (env.get("RAPIDS_CUDA_VERSION") | split("."))[0] }} - date_string: ${{ env.get("RAPIDS_DATE_STRING") }} - py_version: ${{ env.get("RAPIDS_PY_VERSION") | version_to_buildstring }} + cuda_major: '${{ (env.get("RAPIDS_CUDA_VERSION") | split("."))[0] }}' + date_string: '${{ env.get("RAPIDS_DATE_STRING") }}' + py_version: ${{ env.get("RAPIDS_PY_VERSION") }} + py_buildstring : ${{ py_version | version_to_buildstring }} head_rev: ${{ git.head_rev(".")[:8] }} package: @@ -17,7 +18,7 @@ source: - path: ../../.. build: - string: cuda${{ cuda_major }}_py${{ py_version }}_${{ date_string }}_${{ head_rev }} + string: cuda${{ cuda_major }}_py${{ py_buildstring }}_${{ date_string }}_${{ head_rev }} script: content: - ./build.sh -v clean rmm --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" @@ -58,7 +59,7 @@ requirements: - cython >=3.0.0 - rapids-build-backend >=0.3.0,<0.4.0.dev0 - librmm =${{ version }} - - python + - python =${{ py_version }} - pip - scikit-build-core >=0.10.0 run: From 01edf5a66819b30f8fd2409732f074df01ecdb1a Mon Sep 17 00:00:00 2001 From: Paul Mattione <156858817+pmattione-nvidia@users.noreply.github.com> Date: Wed, 26 Feb 2025 18:12:14 -0500 Subject: [PATCH 568/675] Revert "Add OOM fail reason, attempted allocation size to exception messages" (#1843) Reverts rapidsai/rmm#1827 This appears to be causing downstream issues in cuDF, reverting for now until we determine the root cause and fix it. Authors: - Paul Mattione (https://github.com/pmattione-nvidia) - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) - Vyas Ramasubramani (https://github.com/vyasr) - Rong Ou (https://github.com/rongou) URL: https://github.com/rapidsai/rmm/pull/1843 --- .../multi_stream_allocations_bench.cu | 6 ++- .../utilities/simulated_memory_resource.hpp | 5 +- include/rmm/detail/error.hpp | 39 +++++++------- .../rmm/mr/device/arena_memory_resource.hpp | 4 +- .../cuda_async_view_memory_resource.hpp | 3 +- .../rmm/mr/device/cuda_memory_resource.hpp | 2 +- .../detail/stream_ordered_memory_resource.hpp | 3 +- .../mr/device/limiting_resource_adaptor.hpp | 5 +- .../rmm/mr/device/managed_memory_resource.hpp | 2 +- .../rmm/mr/device/pool_memory_resource.hpp | 51 ++++++++----------- .../rmm/mr/device/system_memory_resource.hpp | 5 +- .../rmm/mr/host/pinned_memory_resource.hpp | 3 +- .../rmm/mr/pinned_host_memory_resource.hpp | 2 +- 13 files changed, 53 insertions(+), 77 deletions(-) diff --git a/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu b/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu index 8ada45262..b313f1f05 100644 --- a/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu +++ b/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu @@ -138,7 +138,9 @@ MRFactoryFunc get_mr_factory(std::string const& resource_name) if (resource_name == "arena") { return &make_arena; } if (resource_name == "binning") { return &make_binning; } - RMM_FAIL("Invalid memory_resource name: " + resource_name); + std::cout << "Error: invalid memory_resource name: " << resource_name << std::endl; + + RMM_FAIL(); } void declare_benchmark(std::string const& name) @@ -173,7 +175,7 @@ void declare_benchmark(std::string const& name) return; } - RMM_FAIL("Invalid memory_resource name: " + name); + std::cout << "Error: invalid memory_resource name: " << name << std::endl; } // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) diff --git a/benchmarks/utilities/simulated_memory_resource.hpp b/benchmarks/utilities/simulated_memory_resource.hpp index 4ca243e1c..73e2a4d37 100644 --- a/benchmarks/utilities/simulated_memory_resource.hpp +++ b/benchmarks/utilities/simulated_memory_resource.hpp @@ -65,10 +65,7 @@ class simulated_memory_resource final : public device_memory_resource { void* do_allocate(std::size_t bytes, cuda_stream_view) override { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - RMM_EXPECTS(begin_ + bytes <= end_, - "Simulated memory size exceeded (failed to allocate " + - rmm::detail::format_bytes(bytes) + ")", - rmm::bad_alloc); + RMM_EXPECTS(begin_ + bytes <= end_, "Simulated memory size exceeded", rmm::bad_alloc); auto* ptr = static_cast(begin_); begin_ += bytes; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) return ptr; diff --git a/include/rmm/detail/error.hpp b/include/rmm/detail/error.hpp index 5bf50a89b..3a05d69eb 100644 --- a/include/rmm/detail/error.hpp +++ b/include/rmm/detail/error.hpp @@ -55,11 +55,11 @@ GET_RMM_EXPECTS_MACRO(__VA_ARGS__, RMM_EXPECTS_3, RMM_EXPECTS_2) \ (__VA_ARGS__) #define GET_RMM_EXPECTS_MACRO(_1, _2, _3, NAME, ...) NAME -#define RMM_EXPECTS_3(_condition, _reason, _exception_type) \ - (!!(_condition)) ? static_cast(0) \ - : throw _exception_type /*NOLINT(bugprone-macro-parentheses)*/ \ - { \ - std::string("RMM failure at: " __FILE__ ":" RMM_STRINGIFY(__LINE__) ": ") + _reason \ +#define RMM_EXPECTS_3(_condition, _reason, _exception_type) \ + (!!(_condition)) ? static_cast(0) \ + : throw _exception_type /*NOLINT(bugprone-macro-parentheses)*/ \ + { \ + "RMM failure at: " __FILE__ ":" RMM_STRINGIFY(__LINE__) ": " _reason \ } #define RMM_EXPECTS_2(_condition, _reason) RMM_EXPECTS_3(_condition, _reason, rmm::logic_error) @@ -79,10 +79,9 @@ GET_RMM_FAIL_MACRO(__VA_ARGS__, RMM_FAIL_2, RMM_FAIL_1) \ (__VA_ARGS__) #define GET_RMM_FAIL_MACRO(_1, _2, NAME, ...) NAME -#define RMM_FAIL_2(_what, _exception_type) \ - /*NOLINTNEXTLINE(bugprone-macro-parentheses)*/ \ - throw _exception_type{std::string{"RMM failure at:" __FILE__ ":" RMM_STRINGIFY(__LINE__) ": "} + \ - _what}; +#define RMM_FAIL_2(_what, _exception_type) \ + /*NOLINTNEXTLINE(bugprone-macro-parentheses)*/ \ + throw _exception_type{"RMM failure at:" __FILE__ ":" RMM_STRINGIFY(__LINE__) ": " _what}; #define RMM_FAIL_1(_what) RMM_FAIL_2(_what, rmm::logic_error) /** @@ -133,18 +132,16 @@ * Defaults to throwing rmm::bad_alloc, but when `cudaErrorMemoryAllocation` is returned, * rmm::out_of_memory is thrown instead. */ -#define RMM_CUDA_TRY_ALLOC(_call, num_bytes) \ - do { \ - cudaError_t const error = (_call); \ - if (cudaSuccess != error) { \ - cudaGetLastError(); \ - auto const msg = std::string{"CUDA error (failed to allocate "} + \ - std::to_string(num_bytes) + " bytes) at: " + __FILE__ + ":" + \ - RMM_STRINGIFY(__LINE__) + ": " + cudaGetErrorName(error) + " " + \ - cudaGetErrorString(error); \ - if (cudaErrorMemoryAllocation == error) { throw rmm::out_of_memory{msg}; } \ - throw rmm::bad_alloc{msg}; \ - } \ +#define RMM_CUDA_TRY_ALLOC(_call) \ + do { \ + cudaError_t const error = (_call); \ + if (cudaSuccess != error) { \ + cudaGetLastError(); \ + auto const msg = std::string{"CUDA error at: "} + __FILE__ + ":" + RMM_STRINGIFY(__LINE__) + \ + ": " + cudaGetErrorName(error) + " " + cudaGetErrorString(error); \ + if (cudaErrorMemoryAllocation == error) { throw rmm::out_of_memory{msg}; } \ + throw rmm::bad_alloc{msg}; \ + } \ } while (0) /** diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index 6aaa659ec..f8e4e16cb 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -166,9 +166,7 @@ class arena_memory_resource final : public device_memory_resource { void* pointer = arena.allocate(bytes); if (pointer == nullptr) { if (dump_log_on_failure_) { dump_memory_log(bytes); } - auto const msg = std::string("Maximum pool size exceeded (failed to allocate ") + - rmm::detail::format_bytes(bytes) + "): No room in arena."; - RMM_FAIL(msg.c_str(), rmm::out_of_memory); + RMM_FAIL("Maximum pool size exceeded", rmm::out_of_memory); } return pointer; } diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index 92aea2072..a4ae74394 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -98,8 +98,7 @@ class cuda_async_view_memory_resource final : public device_memory_resource { { void* ptr{nullptr}; if (bytes > 0) { - RMM_CUDA_TRY_ALLOC(cudaMallocFromPoolAsync(&ptr, bytes, pool_handle(), stream.value()), - bytes); + RMM_CUDA_TRY_ALLOC(cudaMallocFromPoolAsync(&ptr, bytes, pool_handle(), stream.value())); } return ptr; } diff --git a/include/rmm/mr/device/cuda_memory_resource.hpp b/include/rmm/mr/device/cuda_memory_resource.hpp index e4afbf711..522145d93 100644 --- a/include/rmm/mr/device/cuda_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_memory_resource.hpp @@ -59,7 +59,7 @@ class cuda_memory_resource final : public device_memory_resource { void* do_allocate(std::size_t bytes, [[maybe_unused]] cuda_stream_view stream) override { void* ptr{nullptr}; - RMM_CUDA_TRY_ALLOC(cudaMalloc(&ptr, bytes), bytes); + RMM_CUDA_TRY_ALLOC(cudaMalloc(&ptr, bytes)); return ptr; } diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index 5b1476d37..ad676bfd2 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -214,8 +214,7 @@ class stream_ordered_memory_resource : public crtp, public device_ size = rmm::align_up(size, rmm::CUDA_ALLOCATION_ALIGNMENT); RMM_EXPECTS(size <= this->underlying().get_maximum_allocation_size(), - std::string("Maximum allocation size exceeded (failed to allocate ") + - rmm::detail::format_bytes(size) + ")", + "Maximum allocation size exceeded", rmm::out_of_memory); auto const block = this->underlying().get_block(size, stream_event); diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index d551fbdb3..96d730191 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -151,9 +150,7 @@ class limiting_resource_adaptor final : public device_memory_resource { } allocated_bytes_ -= proposed_size; - auto const msg = std::string("Exceeded memory limit (failed to allocate ") + - rmm::detail::format_bytes(bytes) + ")"; - RMM_FAIL(msg.c_str(), rmm::out_of_memory); + RMM_FAIL("Exceeded memory limit", rmm::out_of_memory); } /** diff --git a/include/rmm/mr/device/managed_memory_resource.hpp b/include/rmm/mr/device/managed_memory_resource.hpp index 3ade7fb53..2bb807a31 100644 --- a/include/rmm/mr/device/managed_memory_resource.hpp +++ b/include/rmm/mr/device/managed_memory_resource.hpp @@ -63,7 +63,7 @@ class managed_memory_resource final : public device_memory_resource { if (bytes == 0) { return nullptr; } void* ptr{nullptr}; - RMM_CUDA_TRY_ALLOC(cudaMallocManaged(&ptr, bytes), bytes); + RMM_CUDA_TRY_ALLOC(cudaMallocManaged(&ptr, bytes)); return ptr; } diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index 46920da15..dee0471b9 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -252,24 +252,21 @@ class pool_memory_resource final */ block_type try_to_expand(std::size_t try_size, std::size_t min_size, cuda_stream_view stream) { - while (true) { - try { - auto block = block_from_upstream(try_size, stream); - current_pool_size_ += block.size(); - return block; - } catch (std::exception const& e) { - if (try_size <= min_size) { - RMM_LOG_ERROR("[A][Stream %s][Upstream %zuB][FAILURE maximum pool size exceeded: %s]", - rmm::detail::format_stream(stream), - try_size, - e.what()); - auto const msg = std::string("Maximum pool size exceeded (failed to allocate ") + - rmm::detail::format_bytes(try_size) + std::string("): ") + e.what(); - RMM_FAIL(msg.c_str(), rmm::out_of_memory); - } + while (try_size >= min_size) { + auto block = block_from_upstream(try_size, stream); + if (block.has_value()) { + current_pool_size_ += block.value().size(); + return block.value(); + } + if (try_size == min_size) { + break; // only try `size` once } try_size = std::max(min_size, try_size / 2); } + RMM_LOG_ERROR("[A][Stream %s][Upstream %zuB][FAILURE maximum pool size exceeded]", + rmm::detail::format_stream(stream), + min_size); + RMM_FAIL("Maximum pool size exceeded", rmm::out_of_memory); } /** @@ -310,18 +307,6 @@ class pool_memory_resource final // limit each time. If it is not set, grow exponentially, e.g. by doubling the pool size each // time. Upon failure, attempt to back off exponentially, e.g. by half the attempted size, // until either success or the attempt is less than the requested size. - - if (maximum_pool_size_.has_value()) { - auto const max_size = maximum_pool_size_.value(); - if (size > max_size) { - auto const msg = std::string("Maximum pool size exceeded (failed to allocate ") + - rmm::detail::format_bytes(size) + - std::string("): Request larger than capacity (") + - rmm::detail::format_bytes(max_size) + std::string(")"); - RMM_FAIL(msg.c_str(), rmm::out_of_memory); - } - } - return try_to_expand(size_to_grow(size), size, stream); } @@ -354,17 +339,21 @@ class pool_memory_resource final * * @param size The size in bytes to allocate from the upstream resource * @param stream The stream on which the memory is to be used. - * @throws if call to allocate_async() throws * @return block_type The allocated block */ - block_type block_from_upstream(std::size_t size, cuda_stream_view stream) + std::optional block_from_upstream(std::size_t size, cuda_stream_view stream) { RMM_LOG_DEBUG("[A][Stream %s][Upstream %zuB]", rmm::detail::format_stream(stream), size); if (size == 0) { return {}; } - void* ptr = get_upstream_resource().allocate_async(size, stream); - return *upstream_blocks_.emplace(static_cast(ptr), size, true).first; + try { + void* ptr = get_upstream_resource().allocate_async(size, stream); + return std::optional{ + *upstream_blocks_.emplace(static_cast(ptr), size, true).first}; + } catch (std::exception const& e) { + return std::nullopt; + } } /** diff --git a/include/rmm/mr/device/system_memory_resource.hpp b/include/rmm/mr/device/system_memory_resource.hpp index 34c16f719..666a7a9c4 100644 --- a/include/rmm/mr/device/system_memory_resource.hpp +++ b/include/rmm/mr/device/system_memory_resource.hpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include @@ -104,9 +103,7 @@ class system_memory_resource final : public device_memory_resource { return rmm::detail::aligned_host_allocate( bytes, CUDA_ALLOCATION_ALIGNMENT, [](std::size_t size) { return ::operator new(size); }); } catch (std::bad_alloc const& e) { - auto const msg = std::string("Failed to allocate ") + rmm::detail::format_bytes(bytes) + - std::string("of memory: ") + e.what(); - RMM_FAIL(msg.c_str(), rmm::out_of_memory); + RMM_FAIL("Failed to allocate memory: " + std::string{e.what()}, rmm::out_of_memory); } } diff --git a/include/rmm/mr/host/pinned_memory_resource.hpp b/include/rmm/mr/host/pinned_memory_resource.hpp index f75a8f7be..cf746f5ac 100644 --- a/include/rmm/mr/host/pinned_memory_resource.hpp +++ b/include/rmm/mr/host/pinned_memory_resource.hpp @@ -122,7 +122,8 @@ class pinned_memory_resource final : public host_memory_resource { return rmm::detail::aligned_host_allocate(bytes, alignment, [](std::size_t size) { void* ptr{nullptr}; - RMM_CUDA_TRY_ALLOC(cudaMallocHost(&ptr, size), size); + auto status = cudaMallocHost(&ptr, size); + if (cudaSuccess != status) { throw std::bad_alloc{}; } return ptr; }); } diff --git a/include/rmm/mr/pinned_host_memory_resource.hpp b/include/rmm/mr/pinned_host_memory_resource.hpp index 3f5878171..b5689b3ed 100644 --- a/include/rmm/mr/pinned_host_memory_resource.hpp +++ b/include/rmm/mr/pinned_host_memory_resource.hpp @@ -72,7 +72,7 @@ class pinned_host_memory_resource { return rmm::detail::aligned_host_allocate(bytes, alignment, [](std::size_t size) { void* ptr{nullptr}; - RMM_CUDA_TRY_ALLOC(cudaHostAlloc(&ptr, size, cudaHostAllocDefault), size); + RMM_CUDA_TRY_ALLOC(cudaHostAlloc(&ptr, size, cudaHostAllocDefault)); return ptr; }); } From 844464b404cdbe8c2a3b86954e2ca1981bf05270 Mon Sep 17 00:00:00 2001 From: Mike Sarahan Date: Fri, 28 Feb 2025 09:24:57 -0600 Subject: [PATCH 569/675] fix GITHUB_WORKSPACE not being present locally (#1841) #1839 introduced a hard dependence on GITHUB_WORKSPACE being defined. That is not true outside of github actions. This PR fixes it to fall back to the current folder. Authors: - Mike Sarahan (https://github.com/msarahan) - Bradley Dice (https://github.com/bdice) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1841 --- .github/workflows/pr.yaml | 2 +- ci/build_cpp.sh | 17 +++++++++-------- ci/build_python.sh | 19 ++++++++++--------- ci/build_wheel_cpp.sh | 4 ++-- ci/build_wheel_python.sh | 4 ++-- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 43169c3f9..c71d5f391 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -159,7 +159,7 @@ jobs: # This job must use a self-hosted runner to record telemetry traces. runs-on: linux-amd64-cpu4 needs: pr-builder - if: ${{ vars.TELEMETRY_ENABLED == 'true' && !cancelled() }} + if: ${{ vars.TELEMETRY_ENABLED == 'true' && !cancelled() && github.run_attempt == '1' }} continue-on-error: true steps: - name: Telemetry summarize diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 8321215fa..6248247c9 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -28,14 +28,15 @@ source rapids-telemetry-setup # --no-build-id allows for caching with `sccache` # more info is available at # https://rattler.build/latest/tips_and_tricks/#using-sccache-or-ccache-with-rattler-build -rattler-build build --recipe conda/recipes/librmm \ - --experimental \ - --no-build-id \ - --channel-priority disabled \ - --output-dir "$RAPIDS_CONDA_BLD_OUTPUT_DIR" \ - "${RATTLER_CHANNELS[@]}" 2>&1 | tee ${GITHUB_WORKSPACE}/telemetry-artifacts/build.log - -sccache --show-adv-stats | tee ${GITHUB_WORKSPACE}/telemetry-artifacts/sccache-stats.txt +rapids-telemetry-record build.log rattler-build build \ + --recipe conda/recipes/librmm \ + --experimental \ + --no-build-id \ + --channel-priority disabled \ + --output-dir "$RAPIDS_CONDA_BLD_OUTPUT_DIR" \ + "${RATTLER_CHANNELS[@]}" + +rapids-telemetry-record sccache-stats.txt sccache --show-adv-stats # remove build_cache directory rm -rf "$RAPIDS_CONDA_BLD_OUTPUT_DIR"/build_cache diff --git a/ci/build_python.sh b/ci/build_python.sh index f822efd50..c744e9422 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -32,15 +32,16 @@ source rapids-telemetry-setup # --no-build-id allows for caching with `sccache` # more info is available at # https://rattler.build/latest/tips_and_tricks/#using-sccache-or-ccache-with-rattler-build -rattler-build build --recipe conda/recipes/rmm \ - --experimental \ - --no-build-id \ - --channel-priority disabled \ - --output-dir "$RAPIDS_CONDA_BLD_OUTPUT_DIR" \ - -c "${CPP_CHANNEL}" \ - "${RATTLER_CHANNELS[@]}" 2>&1 | tee ${GITHUB_WORKSPACE}/telemetry-artifacts/build.log - -sccache --show-adv-stats | tee ${GITHUB_WORKSPACE}/telemetry-artifacts/sccache-stats.txt +rapids-telemetry-record build.log rattler-build build \ + --recipe conda/recipes/rmm \ + --experimental \ + --no-build-id \ + --channel-priority disabled \ + --output-dir "$RAPIDS_CONDA_BLD_OUTPUT_DIR" \ + -c "${CPP_CHANNEL}" \ + "${RATTLER_CHANNELS[@]}" + +rapids-telemetry-record sccache-stats.txt sccache --show-adv-stats # See https://github.com/prefix-dev/rattler-build/issues/1424 rm -rf "$RAPIDS_CONDA_BLD_OUTPUT_DIR"/build_cache diff --git a/ci/build_wheel_cpp.sh b/ci/build_wheel_cpp.sh index 0605aafc2..bcbf91b05 100755 --- a/ci/build_wheel_cpp.sh +++ b/ci/build_wheel_cpp.sh @@ -19,9 +19,9 @@ sccache --zero-stats # Creates artifacts directory for telemetry source rapids-telemetry-setup -rapids-pip-retry wheel . -w dist -v --no-deps --disable-pip-version-check 2>&1 | tee ${GITHUB_WORKSPACE}/telemetry-artifacts/build.log +rapids-telemetry-record build.log rapids-pip-retry wheel . -w dist -v --no-deps --disable-pip-version-check -sccache --show-adv-stats | tee ${GITHUB_WORKSPACE}/telemetry-artifacts/sccache-stats.txt +rapids-telemetry-record sccache-stats.txt sccache --show-adv-stats python -m wheel tags --platform any dist/* --remove diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index 7438b102e..7cffc045c 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -28,9 +28,9 @@ sccache --zero-stats source rapids-telemetry-setup PIP_CONSTRAINT="${PWD}/build-constraints.txt" \ - rapids-pip-retry wheel . -w dist -v --no-deps --disable-pip-version-check 2>&1 | tee ${GITHUB_WORKSPACE}/telemetry-artifacts/build.log + rapids-telemetry-record build.log rapids-pip-retry wheel . -w dist -v --no-deps --disable-pip-version-check -sccache --show-adv-stats | tee ${GITHUB_WORKSPACE}/telemetry-artifacts/sccache-stats.txt +rapids-telemetry-record sccache-stats.txt sccache --show-adv-stats mkdir -p final_dist EXCLUDE_ARGS=( From b44ebb66abd3ae06e7425bca719271e2afd8d18e Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 28 Feb 2025 19:07:29 -0600 Subject: [PATCH 570/675] Add basic example. (#1800) This is a skeleton for adding examples, requested in issue #1784. I plan to merge some minimal form of this, and then add a few examples that answer common questions about RMM, such as how to use specific memory resource adaptors or how to use RMM for managing multi-thread, multi-stream work. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Jake Awe (https://github.com/AyodeAwe) - Mark Harris (https://github.com/harrism) - Lawrence Mitchell (https://github.com/wence-) URL: https://github.com/rapidsai/rmm/pull/1800 --- .../cuda12.8-conda/devcontainer.json | 2 +- .devcontainer/cuda12.8-pip/devcontainer.json | 2 +- README.md | 2 +- ci/release/update-version.sh | 3 + conda/recipes/librmm/recipe.yaml | 56 +++++++++++++++++- examples/README.md | 7 +++ examples/basic/CMakeLists.txt | 25 ++++++++ examples/basic/README.md | 19 ++++++ examples/basic/src/basic.cpp | 41 +++++++++++++ examples/build.sh | 58 +++++++++++++++++++ examples/fetch_dependencies.cmake | 30 ++++++++++ examples/set_cuda_architecture.cmake | 27 +++++++++ examples/versions.cmake | 15 +++++ include/rmm/device_buffer.hpp | 3 +- .../rmm/mr/device/device_memory_resource.hpp | 2 +- 15 files changed, 284 insertions(+), 8 deletions(-) create mode 100644 examples/README.md create mode 100644 examples/basic/CMakeLists.txt create mode 100644 examples/basic/README.md create mode 100644 examples/basic/src/basic.cpp create mode 100755 examples/build.sh create mode 100644 examples/fetch_dependencies.cmake create mode 100644 examples/set_cuda_architecture.cmake create mode 100644 examples/versions.cmake diff --git a/.devcontainer/cuda12.8-conda/devcontainer.json b/.devcontainer/cuda12.8-conda/devcontainer.json index f8ccb3a59..fcf20229d 100644 --- a/.devcontainer/cuda12.8-conda/devcontainer.json +++ b/.devcontainer/cuda12.8-conda/devcontainer.json @@ -15,7 +15,7 @@ ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.2": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.4": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.8-pip/devcontainer.json b/.devcontainer/cuda12.8-pip/devcontainer.json index 3a890397d..6620e32a1 100644 --- a/.devcontainer/cuda12.8-pip/devcontainer.json +++ b/.devcontainer/cuda12.8-pip/devcontainer.json @@ -15,7 +15,7 @@ ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.2": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.4": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/README.md b/README.md index 54bab2eab..6e6fdc43a 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Compiler requirements: * `gcc` version 9.3+ * `nvcc` version 11.4+ -* `cmake` version 3.26.4+ +* `cmake` version 3.30.4+ CUDA/GPU requirements: diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index ef409d68e..21d76a117 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -32,6 +32,9 @@ function sed_runner() { # Centralized version file update echo "${NEXT_FULL_TAG}" > VERSION +# Examples update +sed_runner "s/RMM_TAG branch-[0-9.]*/RMM_TAG branch-${NEXT_SHORT_TAG}/" examples/versions.cmake + # CI files for FILE in .github/workflows/*.yaml; do sed_runner "/shared-workflows/ s/@.*/@branch-${NEXT_SHORT_TAG}/g" "${FILE}" diff --git a/conda/recipes/librmm/recipe.yaml b/conda/recipes/librmm/recipe.yaml index a59f67122..5003180e5 100644 --- a/conda/recipes/librmm/recipe.yaml +++ b/conda/recipes/librmm/recipe.yaml @@ -18,8 +18,8 @@ cache: build: script: - content: - - ./build.sh -n -v clean librmm tests benchmarks --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" + content: | + ./build.sh -n -v clean librmm tests benchmarks --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" secrets: - AWS_ACCESS_KEY_ID - AWS_SECRET_ACCESS_KEY @@ -121,3 +121,55 @@ outputs: homepage: ${{ load_from_file("python/librmm/pyproject.toml").project.urls.Homepage }} license: ${{ load_from_file("python/librmm/pyproject.toml").project.license.text | replace(" ", "-") }} summary: librmm test & benchmark executables + + - package: + name: librmm-example + version: ${{ version }} + build: + string: cuda${{ cuda_major }}_${{ date_string }}_${{ head_rev }} + script: + content: | + ./examples/build.sh --install + env: + CMAKE_C_COMPILER_LAUNCHER: ${{ env.get("CMAKE_C_COMPILER_LAUNCHER") }} + CMAKE_CUDA_COMPILER_LAUNCHER: ${{ env.get("CMAKE_CUDA_COMPILER_LAUNCHER") }} + CMAKE_CXX_COMPILER_LAUNCHER: ${{ env.get("CMAKE_CXX_COMPILER_LAUNCHER") }} + CMAKE_GENERATOR: ${{ env.get("CMAKE_GENERATOR") }} + PARALLEL_LEVEL: ${{ env.get("PARALLEL_LEVEL") }} + SCCACHE_BUCKET: ${{ env.get("SCCACHE_BUCKET") }} + SCCACHE_IDLE_TIMEOUT: ${{ env.get("SCCACHE_IDLE_TIMEOUT") }} + SCCACHE_REGION: ${{ env.get("SCCACHE_REGION") }} + SCCACHE_S3_USE_SSL: ${{ env.get("SCCACHE_S3_USE_SSL") }} + SCCACHE_S3_NO_CREDENTIALS: ${{ env.get("SCCACHE_S3_NO_CREDENTIALS") }} + SCCACHE_S3_KEY_PREFIX: librmm-${{ env.get("RAPIDS_CONDA_ARCH") }} + requirements: + build: + - cmake ${{ cmake_version }} + - ninja + - ${{ compiler("c") }} + - ${{ compiler("cxx") }} + - ${{ compiler("cuda") }} + - cuda-version =${{ cuda_version }} + host: + - cuda-version =${{ cuda_version }} + - if: cuda_major == "11" + then: cudatoolkit + else: cuda-cudart-dev + - ${{ pin_subpackage("librmm", exact=True) }} + run: + - if: cuda_major == "11" + then: cudatoolkit + else: cuda-cudart + - ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }} + - ${{ pin_subpackage("librmm", exact=True) }} + ignore_run_exports: + from_package: + - if: cuda_major != "11" + then: cuda-cudart-dev + by_name: + - cuda-version + - librmm + about: + homepage: ${{ load_from_file("python/librmm/pyproject.toml").project.urls.Homepage }} + license: ${{ load_from_file("python/librmm/pyproject.toml").project.license.text | replace(" ", "-") }} + summary: librmm example executables diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 000000000..138f3ac0e --- /dev/null +++ b/examples/README.md @@ -0,0 +1,7 @@ +# RMM C++ Examples + +This folder contains examples to demonstrate librmm use cases. Running `build.sh` builds all examples. + +Current examples: + +- Basic: demonstrates memory resource construction and allocating a `device_uvector` on a stream. diff --git a/examples/basic/CMakeLists.txt b/examples/basic/CMakeLists.txt new file mode 100644 index 000000000..d74a934a5 --- /dev/null +++ b/examples/basic/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) 2020-2025, NVIDIA CORPORATION. + +cmake_minimum_required(VERSION 3.30.4) + +include(../set_cuda_architecture.cmake) + +# initialize cuda architecture +rapids_cuda_init_architectures(basic_example) + +project( + basic_example + VERSION 0.0.1 + LANGUAGES CXX CUDA) + +include(../fetch_dependencies.cmake) + +include(rapids-cmake) +rapids_cmake_build_type("Release") + +# Configure your project here +add_executable(basic_example src/basic.cpp) +target_link_libraries(basic_example PRIVATE rmm::rmm) +target_compile_features(basic_example PRIVATE cxx_std_17) + +install(TARGETS basic_example DESTINATION bin/examples/librmm) diff --git a/examples/basic/README.md b/examples/basic/README.md new file mode 100644 index 000000000..5d85fdcbc --- /dev/null +++ b/examples/basic/README.md @@ -0,0 +1,19 @@ +# Basic Standalone librmm CUDA C++ application + +This C++ example demonstrates a basic librmm use case and provides a minimal +example of building your own application based on librmm using CMake. + +The example source code creates a device memory resource, sets it to the +current device resource, and then uses it to allocate a buffer. The buffer is +initialized with data and then deallocated. + +## Compile and execute + +```bash +# Configure project +cmake -S . -B build/ +# Build +cmake --build build/ --parallel $PARALLEL_LEVEL +# Execute +build/basic_example +``` diff --git a/examples/basic/src/basic.cpp b/examples/basic/src/basic.cpp new file mode 100644 index 000000000..1f31ccfef --- /dev/null +++ b/examples/basic/src/basic.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025, 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. + */ + +#include +#include +#include +#include + +int main(int argc, char** argv) +{ + // Construct a CUDA async memory resource using RAPIDS Memory Manager (RMM). + // This uses a memory pool managed by the CUDA driver, using half of the + // available GPU memory. + rmm::mr::cuda_async_memory_resource mr{rmm::percent_of_free_device_memory(50)}; + + // Create a CUDA stream for asynchronous allocations + auto stream = rmm::cuda_stream{}; + + // Create a device_uvector with this stream and memory resource + auto const size{12345}; + rmm::device_uvector vec(size, stream, mr); + std::cout << "vec size: " << vec.size() << std::endl; + + // Synchronize the stream + stream.synchronize(); + + return 0; +} diff --git a/examples/build.sh b/examples/build.sh new file mode 100755 index 000000000..318e57f73 --- /dev/null +++ b/examples/build.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# Copyright (c) 2025, NVIDIA CORPORATION. + +# librmm examples build script + +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")") + +# Set up default librmm 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 + +# librmm build directory +LIB_BUILD_DIR=${LIB_BUILD_DIR:-$(readlink -f "${EXAMPLES_DIR}/../build")} + +################################################################################ +# Add individual librmm examples build scripts down below + +build_example() { + example_dir=${1} + example_dir="${EXAMPLES_DIR}/${example_dir}" + build_dir="${example_dir}/build" + + # Configure + cmake -S ${example_dir} -B ${build_dir} -Drmm_ROOT="${LIB_BUILD_DIR}" + # Build + cmake --build ${build_dir} -j${PARALLEL_LEVEL} + # Install if needed + if [ "$INSTALL_EXAMPLES" = true ]; then + cmake --install ${build_dir} --prefix ${INSTALL_PREFIX:-${example_dir}/install} + fi +} + +build_example basic diff --git a/examples/fetch_dependencies.cmake b/examples/fetch_dependencies.cmake new file mode 100644 index 000000000..0c949769b --- /dev/null +++ b/examples/fetch_dependencies.cmake @@ -0,0 +1,30 @@ +# ============================================================================= +# Copyright (c) 2025, 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. +# ============================================================================= + +include(${CMAKE_CURRENT_LIST_DIR}/versions.cmake) + +set(CPM_DOWNLOAD_VERSION v0.40.5) +file( + DOWNLOAD + https://github.com/cpm-cmake/CPM.cmake/releases/download/${CPM_DOWNLOAD_VERSION}/get_cpm.cmake + ${CMAKE_BINARY_DIR}/cmake/get_cpm.cmake) +include(${CMAKE_BINARY_DIR}/cmake/get_cpm.cmake) + +# find or build it via CPM +CPMFindPackage( + NAME rmm + FIND_PACKAGE_ARGUMENTS "PATHS ${rmm_ROOT} ${rmm_ROOT}/latest" GIT_REPOSITORY + https://github.com/rapidsai/rmm + GIT_TAG ${RMM_TAG} + GIT_SHALLOW TRUE) diff --git a/examples/set_cuda_architecture.cmake b/examples/set_cuda_architecture.cmake new file mode 100644 index 000000000..e8b3d9b56 --- /dev/null +++ b/examples/set_cuda_architecture.cmake @@ -0,0 +1,27 @@ +# ============================================================================= +# Copyright (c) 2025, 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. +# ============================================================================= + +include(${CMAKE_CURRENT_LIST_DIR}/versions.cmake) + +if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/librmm_cpp_examples_RAPIDS.cmake) + file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/${RMM_TAG}/RAPIDS.cmake + ${CMAKE_CURRENT_BINARY_DIR}/librmm_cpp_examples_RAPIDS.cmake) +endif() +include(${CMAKE_CURRENT_BINARY_DIR}/librmm_cpp_examples_RAPIDS.cmake) + +include(rapids-cmake) +include(rapids-cpm) +include(rapids-cuda) +include(rapids-export) +include(rapids-find) diff --git a/examples/versions.cmake b/examples/versions.cmake new file mode 100644 index 000000000..9969c695c --- /dev/null +++ b/examples/versions.cmake @@ -0,0 +1,15 @@ +# ============================================================================= +# Copyright (c) 2025, 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(RMM_TAG branch-25.04) diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index cbb2853c3..25b921614 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -92,8 +92,7 @@ class device_buffer { */ // Note: we cannot use `device_buffer() = default;` because nvcc implicitly adds // `__host__ __device__` specifiers to the defaulted constructor when it is called within the - // context of both host and device functions. Specifically, the `cudf::type_dispatcher` is a host- - // device function. This causes warnings/errors because this ctor invokes host-only functions. + // context of both host and device functions. device_buffer() : _mr{rmm::mr::get_current_device_resource_ref()} {} /** diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index 9ae390d8c..b1c5ff7d3 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -33,7 +33,7 @@ namespace mr { */ /** - * @brief Base class for all libcudf device memory allocation. + * @brief Base class for all librmm device memory allocation. * * This class serves as the interface that all custom device memory * implementations must satisfy. From dea0b21134c0c5ad056a4a12c8ad67aa7c5c5d67 Mon Sep 17 00:00:00 2001 From: Paul Mattione <156858817+pmattione-nvidia@users.noreply.github.com> Date: Tue, 4 Mar 2025 10:46:59 -0500 Subject: [PATCH 571/675] Retry error logging (#1844) Retry getting improved error throwing and logging, with bugs fixed and test added that repros the cudf failure. [Original PR](https://github.com/rapidsai/rmm/pull/1827) that was [reverted](https://github.com/rapidsai/rmm/pull/1843). The changes to the previously-approved PR that includes the fixes and test is [this commit](https://github.com/rapidsai/rmm/pull/1844/commits/c8a8505854de2b1094c802b6a9507e908573661f). The [original while loop](https://github.com/rapidsai/rmm/blob/6e8539e42d51852faab5f9b330232168f9223eee/include/rmm/mr/device/pool_memory_resource.hpp#L253) has been restored with better error handling. Note that this changes the interface of the macros, one of which is called in cudf that will be changed [here](https://github.com/rapidsai/cudf/pull/18108) after this goes in. Authors: - Paul Mattione (https://github.com/pmattione-nvidia) - Bradley Dice (https://github.com/bdice) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1844 --- .../multi_stream_allocations_bench.cu | 6 +-- .../utilities/simulated_memory_resource.hpp | 5 +- include/rmm/detail/error.hpp | 42 +++++++++++---- .../rmm/mr/device/arena_memory_resource.hpp | 4 +- .../cuda_async_view_memory_resource.hpp | 3 +- .../rmm/mr/device/cuda_memory_resource.hpp | 2 +- .../detail/stream_ordered_memory_resource.hpp | 3 +- .../mr/device/limiting_resource_adaptor.hpp | 5 +- .../rmm/mr/device/managed_memory_resource.hpp | 2 +- .../rmm/mr/device/pool_memory_resource.hpp | 52 +++++++++++-------- .../rmm/mr/device/system_memory_resource.hpp | 5 +- .../rmm/mr/host/pinned_memory_resource.hpp | 3 +- .../rmm/mr/pinned_host_memory_resource.hpp | 2 +- tests/mr/host/pinned_pool_mr_tests.cpp | 11 ++++ 14 files changed, 100 insertions(+), 45 deletions(-) diff --git a/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu b/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu index b313f1f05..8ada45262 100644 --- a/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu +++ b/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu @@ -138,9 +138,7 @@ MRFactoryFunc get_mr_factory(std::string const& resource_name) if (resource_name == "arena") { return &make_arena; } if (resource_name == "binning") { return &make_binning; } - std::cout << "Error: invalid memory_resource name: " << resource_name << std::endl; - - RMM_FAIL(); + RMM_FAIL("Invalid memory_resource name: " + resource_name); } void declare_benchmark(std::string const& name) @@ -175,7 +173,7 @@ void declare_benchmark(std::string const& name) return; } - std::cout << "Error: invalid memory_resource name: " << name << std::endl; + RMM_FAIL("Invalid memory_resource name: " + name); } // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) diff --git a/benchmarks/utilities/simulated_memory_resource.hpp b/benchmarks/utilities/simulated_memory_resource.hpp index 73e2a4d37..4ca243e1c 100644 --- a/benchmarks/utilities/simulated_memory_resource.hpp +++ b/benchmarks/utilities/simulated_memory_resource.hpp @@ -65,7 +65,10 @@ class simulated_memory_resource final : public device_memory_resource { void* do_allocate(std::size_t bytes, cuda_stream_view) override { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - RMM_EXPECTS(begin_ + bytes <= end_, "Simulated memory size exceeded", rmm::bad_alloc); + RMM_EXPECTS(begin_ + bytes <= end_, + "Simulated memory size exceeded (failed to allocate " + + rmm::detail::format_bytes(bytes) + ")", + rmm::bad_alloc); auto* ptr = static_cast(begin_); begin_ += bytes; // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) return ptr; diff --git a/include/rmm/detail/error.hpp b/include/rmm/detail/error.hpp index 3a05d69eb..ae5b37acf 100644 --- a/include/rmm/detail/error.hpp +++ b/include/rmm/detail/error.hpp @@ -55,11 +55,11 @@ GET_RMM_EXPECTS_MACRO(__VA_ARGS__, RMM_EXPECTS_3, RMM_EXPECTS_2) \ (__VA_ARGS__) #define GET_RMM_EXPECTS_MACRO(_1, _2, _3, NAME, ...) NAME -#define RMM_EXPECTS_3(_condition, _reason, _exception_type) \ - (!!(_condition)) ? static_cast(0) \ - : throw _exception_type /*NOLINT(bugprone-macro-parentheses)*/ \ - { \ - "RMM failure at: " __FILE__ ":" RMM_STRINGIFY(__LINE__) ": " _reason \ +#define RMM_EXPECTS_3(_condition, _reason, _exception_type) \ + (!!(_condition)) ? static_cast(0) \ + : throw _exception_type /*NOLINT(bugprone-macro-parentheses)*/ \ + { \ + std::string("RMM failure at: " __FILE__ ":" RMM_STRINGIFY(__LINE__) ": ") + _reason \ } #define RMM_EXPECTS_2(_condition, _reason) RMM_EXPECTS_3(_condition, _reason, rmm::logic_error) @@ -79,9 +79,10 @@ GET_RMM_FAIL_MACRO(__VA_ARGS__, RMM_FAIL_2, RMM_FAIL_1) \ (__VA_ARGS__) #define GET_RMM_FAIL_MACRO(_1, _2, NAME, ...) NAME -#define RMM_FAIL_2(_what, _exception_type) \ - /*NOLINTNEXTLINE(bugprone-macro-parentheses)*/ \ - throw _exception_type{"RMM failure at:" __FILE__ ":" RMM_STRINGIFY(__LINE__) ": " _what}; +#define RMM_FAIL_2(_what, _exception_type) \ + /*NOLINTNEXTLINE(bugprone-macro-parentheses)*/ \ + throw _exception_type{std::string{"RMM failure at:" __FILE__ ":" RMM_STRINGIFY(__LINE__) ": "} + \ + _what}; #define RMM_FAIL_1(_what) RMM_FAIL_2(_what, rmm::logic_error) /** @@ -131,8 +132,31 @@ * * Defaults to throwing rmm::bad_alloc, but when `cudaErrorMemoryAllocation` is returned, * rmm::out_of_memory is thrown instead. + * + * Can be called with either 1 or 2 arguments: + * - RMM_CUDA_TRY_ALLOC(cuda_call): Performs error checking without specifying bytes + * - RMM_CUDA_TRY_ALLOC(cuda_call, num_bytes): Includes the number of bytes in the error message */ -#define RMM_CUDA_TRY_ALLOC(_call) \ +#define RMM_CUDA_TRY_ALLOC(...) \ + GET_RMM_CUDA_TRY_ALLOC_MACRO(__VA_ARGS__, RMM_CUDA_TRY_ALLOC_2, RMM_CUDA_TRY_ALLOC_1) \ + (__VA_ARGS__) +#define GET_RMM_CUDA_TRY_ALLOC_MACRO(_1, _2, NAME, ...) NAME + +#define RMM_CUDA_TRY_ALLOC_2(_call, num_bytes) \ + do { \ + cudaError_t const error = (_call); \ + if (cudaSuccess != error) { \ + cudaGetLastError(); \ + auto const msg = std::string{"CUDA error (failed to allocate "} + \ + std::to_string(num_bytes) + " bytes) at: " + __FILE__ + ":" + \ + RMM_STRINGIFY(__LINE__) + ": " + cudaGetErrorName(error) + " " + \ + cudaGetErrorString(error); \ + if (cudaErrorMemoryAllocation == error) { throw rmm::out_of_memory{msg}; } \ + throw rmm::bad_alloc{msg}; \ + } \ + } while (0) + +#define RMM_CUDA_TRY_ALLOC_1(_call) \ do { \ cudaError_t const error = (_call); \ if (cudaSuccess != error) { \ diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/include/rmm/mr/device/arena_memory_resource.hpp index f8e4e16cb..6aaa659ec 100644 --- a/include/rmm/mr/device/arena_memory_resource.hpp +++ b/include/rmm/mr/device/arena_memory_resource.hpp @@ -166,7 +166,9 @@ class arena_memory_resource final : public device_memory_resource { void* pointer = arena.allocate(bytes); if (pointer == nullptr) { if (dump_log_on_failure_) { dump_memory_log(bytes); } - RMM_FAIL("Maximum pool size exceeded", rmm::out_of_memory); + auto const msg = std::string("Maximum pool size exceeded (failed to allocate ") + + rmm::detail::format_bytes(bytes) + "): No room in arena."; + RMM_FAIL(msg.c_str(), rmm::out_of_memory); } return pointer; } diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index a4ae74394..92aea2072 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -98,7 +98,8 @@ class cuda_async_view_memory_resource final : public device_memory_resource { { void* ptr{nullptr}; if (bytes > 0) { - RMM_CUDA_TRY_ALLOC(cudaMallocFromPoolAsync(&ptr, bytes, pool_handle(), stream.value())); + RMM_CUDA_TRY_ALLOC(cudaMallocFromPoolAsync(&ptr, bytes, pool_handle(), stream.value()), + bytes); } return ptr; } diff --git a/include/rmm/mr/device/cuda_memory_resource.hpp b/include/rmm/mr/device/cuda_memory_resource.hpp index 522145d93..e4afbf711 100644 --- a/include/rmm/mr/device/cuda_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_memory_resource.hpp @@ -59,7 +59,7 @@ class cuda_memory_resource final : public device_memory_resource { void* do_allocate(std::size_t bytes, [[maybe_unused]] cuda_stream_view stream) override { void* ptr{nullptr}; - RMM_CUDA_TRY_ALLOC(cudaMalloc(&ptr, bytes)); + RMM_CUDA_TRY_ALLOC(cudaMalloc(&ptr, bytes), bytes); return ptr; } diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index ad676bfd2..5b1476d37 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -214,7 +214,8 @@ class stream_ordered_memory_resource : public crtp, public device_ size = rmm::align_up(size, rmm::CUDA_ALLOCATION_ALIGNMENT); RMM_EXPECTS(size <= this->underlying().get_maximum_allocation_size(), - "Maximum allocation size exceeded", + std::string("Maximum allocation size exceeded (failed to allocate ") + + rmm::detail::format_bytes(size) + ")", rmm::out_of_memory); auto const block = this->underlying().get_block(size, stream_event); diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/include/rmm/mr/device/limiting_resource_adaptor.hpp index 96d730191..d551fbdb3 100644 --- a/include/rmm/mr/device/limiting_resource_adaptor.hpp +++ b/include/rmm/mr/device/limiting_resource_adaptor.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -150,7 +151,9 @@ class limiting_resource_adaptor final : public device_memory_resource { } allocated_bytes_ -= proposed_size; - RMM_FAIL("Exceeded memory limit", rmm::out_of_memory); + auto const msg = std::string("Exceeded memory limit (failed to allocate ") + + rmm::detail::format_bytes(bytes) + ")"; + RMM_FAIL(msg.c_str(), rmm::out_of_memory); } /** diff --git a/include/rmm/mr/device/managed_memory_resource.hpp b/include/rmm/mr/device/managed_memory_resource.hpp index 2bb807a31..3ade7fb53 100644 --- a/include/rmm/mr/device/managed_memory_resource.hpp +++ b/include/rmm/mr/device/managed_memory_resource.hpp @@ -63,7 +63,7 @@ class managed_memory_resource final : public device_memory_resource { if (bytes == 0) { return nullptr; } void* ptr{nullptr}; - RMM_CUDA_TRY_ALLOC(cudaMallocManaged(&ptr, bytes)); + RMM_CUDA_TRY_ALLOC(cudaMallocManaged(&ptr, bytes), bytes); return ptr; } diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/include/rmm/mr/device/pool_memory_resource.hpp index dee0471b9..6abf10e2c 100644 --- a/include/rmm/mr/device/pool_memory_resource.hpp +++ b/include/rmm/mr/device/pool_memory_resource.hpp @@ -242,8 +242,8 @@ class pool_memory_resource final * Attempts to allocate `try_size` bytes from upstream. If it fails, it iteratively reduces the * attempted size by half until `min_size`, returning the allocated block once it succeeds. * - * @throws rmm::bad_alloc if `min_size` bytes cannot be allocated from upstream or maximum pool - * size is exceeded. + * @throws rmm::out_of_memory if `min_size` bytes cannot be allocated from upstream or maximum + * pool size is exceeded. * * @param try_size The initial requested size to try allocating. * @param min_size The minimum requested size to try allocating. @@ -252,21 +252,34 @@ class pool_memory_resource final */ block_type try_to_expand(std::size_t try_size, std::size_t min_size, cuda_stream_view stream) { + auto report_error = [&](const char* reason) { + RMM_LOG_ERROR("[A][Stream %s][Upstream %zuB][FAILURE maximum pool size exceeded: %s]", + rmm::detail::format_stream(stream), + min_size, + reason); + auto const msg = std::string("Maximum pool size exceeded (failed to allocate ") + + rmm::detail::format_bytes(min_size) + std::string("): ") + reason; + RMM_FAIL(msg.c_str(), rmm::out_of_memory); + }; + while (try_size >= min_size) { - auto block = block_from_upstream(try_size, stream); - if (block.has_value()) { - current_pool_size_ += block.value().size(); - return block.value(); - } - if (try_size == min_size) { - break; // only try `size` once + try { + auto block = block_from_upstream(try_size, stream); + current_pool_size_ += block.size(); + return block; + } catch (std::exception const& e) { + if (try_size == min_size) { report_error(e.what()); } } try_size = std::max(min_size, try_size / 2); } - RMM_LOG_ERROR("[A][Stream %s][Upstream %zuB][FAILURE maximum pool size exceeded]", - rmm::detail::format_stream(stream), - min_size); - RMM_FAIL("Maximum pool size exceeded", rmm::out_of_memory); + + auto const max_size = maximum_pool_size_.value_or(std::numeric_limits::max()); + auto const msg = std::string("Not enough room to grow, current/max/try size = ") + + rmm::detail::format_bytes(pool_size()) + ", " + + rmm::detail::format_bytes(max_size) + ", " + + rmm::detail::format_bytes(min_size); + report_error(msg.c_str()); + return {}; } /** @@ -307,6 +320,7 @@ class pool_memory_resource final // limit each time. If it is not set, grow exponentially, e.g. by doubling the pool size each // time. Upon failure, attempt to back off exponentially, e.g. by half the attempted size, // until either success or the attempt is less than the requested size. + return try_to_expand(size_to_grow(size), size, stream); } @@ -339,21 +353,17 @@ class pool_memory_resource final * * @param size The size in bytes to allocate from the upstream resource * @param stream The stream on which the memory is to be used. + * @throws if call to allocate_async() throws * @return block_type The allocated block */ - std::optional block_from_upstream(std::size_t size, cuda_stream_view stream) + block_type block_from_upstream(std::size_t size, cuda_stream_view stream) { RMM_LOG_DEBUG("[A][Stream %s][Upstream %zuB]", rmm::detail::format_stream(stream), size); if (size == 0) { return {}; } - try { - void* ptr = get_upstream_resource().allocate_async(size, stream); - return std::optional{ - *upstream_blocks_.emplace(static_cast(ptr), size, true).first}; - } catch (std::exception const& e) { - return std::nullopt; - } + void* ptr = get_upstream_resource().allocate_async(size, stream); + return *upstream_blocks_.emplace(static_cast(ptr), size, true).first; } /** diff --git a/include/rmm/mr/device/system_memory_resource.hpp b/include/rmm/mr/device/system_memory_resource.hpp index 666a7a9c4..34c16f719 100644 --- a/include/rmm/mr/device/system_memory_resource.hpp +++ b/include/rmm/mr/device/system_memory_resource.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -103,7 +104,9 @@ class system_memory_resource final : public device_memory_resource { return rmm::detail::aligned_host_allocate( bytes, CUDA_ALLOCATION_ALIGNMENT, [](std::size_t size) { return ::operator new(size); }); } catch (std::bad_alloc const& e) { - RMM_FAIL("Failed to allocate memory: " + std::string{e.what()}, rmm::out_of_memory); + auto const msg = std::string("Failed to allocate ") + rmm::detail::format_bytes(bytes) + + std::string("of memory: ") + e.what(); + RMM_FAIL(msg.c_str(), rmm::out_of_memory); } } diff --git a/include/rmm/mr/host/pinned_memory_resource.hpp b/include/rmm/mr/host/pinned_memory_resource.hpp index cf746f5ac..f75a8f7be 100644 --- a/include/rmm/mr/host/pinned_memory_resource.hpp +++ b/include/rmm/mr/host/pinned_memory_resource.hpp @@ -122,8 +122,7 @@ class pinned_memory_resource final : public host_memory_resource { return rmm::detail::aligned_host_allocate(bytes, alignment, [](std::size_t size) { void* ptr{nullptr}; - auto status = cudaMallocHost(&ptr, size); - if (cudaSuccess != status) { throw std::bad_alloc{}; } + RMM_CUDA_TRY_ALLOC(cudaMallocHost(&ptr, size), size); return ptr; }); } diff --git a/include/rmm/mr/pinned_host_memory_resource.hpp b/include/rmm/mr/pinned_host_memory_resource.hpp index b5689b3ed..3f5878171 100644 --- a/include/rmm/mr/pinned_host_memory_resource.hpp +++ b/include/rmm/mr/pinned_host_memory_resource.hpp @@ -72,7 +72,7 @@ class pinned_host_memory_resource { return rmm::detail::aligned_host_allocate(bytes, alignment, [](std::size_t size) { void* ptr{nullptr}; - RMM_CUDA_TRY_ALLOC(cudaHostAlloc(&ptr, size, cudaHostAllocDefault)); + RMM_CUDA_TRY_ALLOC(cudaHostAlloc(&ptr, size, cudaHostAllocDefault), size); return ptr; }); } diff --git a/tests/mr/host/pinned_pool_mr_tests.cpp b/tests/mr/host/pinned_pool_mr_tests.cpp index 436fdfd1d..0a28ead7c 100644 --- a/tests/mr/host/pinned_pool_mr_tests.cpp +++ b/tests/mr/host/pinned_pool_mr_tests.cpp @@ -88,5 +88,16 @@ TEST(PinnedPoolTest, NonAlignedPoolSize) rmm::logic_error); } +TEST(PinnedPoolTest, ThrowOutOfMemory) +{ + rmm::mr::pinned_memory_resource pinned_mr{}; + const auto initial{0}; + const auto maximum{1024}; + pool_mr mr{pinned_mr, initial, maximum}; + mr.allocate(1024); + + EXPECT_THROW(mr.allocate(1024), rmm::out_of_memory); +} + } // namespace } // namespace rmm::test From 4a1727e78dce17b638a167786e9761775f36ddfa Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 4 Mar 2025 11:58:13 -0600 Subject: [PATCH 572/675] Fix for -fdebug-prefix-map breaking sccache (#1846) Fix for `-fdebug-prefix-map` breaking sccache (it contains the librmm build number). Workaround for https://github.com/prefix-dev/rattler-build/issues/1458. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Gil Forsyth (https://github.com/gforsyth) URL: https://github.com/rapidsai/rmm/pull/1846 --- conda/recipes/librmm/recipe.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/conda/recipes/librmm/recipe.yaml b/conda/recipes/librmm/recipe.yaml index 5003180e5..151278784 100644 --- a/conda/recipes/librmm/recipe.yaml +++ b/conda/recipes/librmm/recipe.yaml @@ -19,7 +19,15 @@ cache: build: script: content: | - ./build.sh -n -v clean librmm tests benchmarks --cmake-args=\"-DCMAKE_INSTALL_LIBDIR=lib\" + # Remove `-fdebug-prefix-map` line from CFLAGS and CXXFLAGS so the + # incrementing version number in the compile line doesn't break the + # cache + set -x + export CFLAGS=$(echo $CFLAGS | sed -E 's@\-fdebug\-prefix\-map[^ ]*@@g') + export CXXFLAGS=$(echo $CXXFLAGS | sed -E 's@\-fdebug\-prefix\-map[^ ]*@@g') + set +x + + ./build.sh -n -v clean librmm tests benchmarks secrets: - AWS_ACCESS_KEY_ID - AWS_SECRET_ACCESS_KEY From 866a40e758bdea5c33066c650cc750a398088379 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 5 Mar 2025 11:23:06 -0600 Subject: [PATCH 573/675] Add tests for RMM internal macros. (#1847) This PR adds tests for internal macros. Closes #1848. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1847 --- tests/CMakeLists.txt | 3 + tests/error_macros_tests.cpp | 215 +++++++++++++++++++++++++++++++++++ 2 files changed, 218 insertions(+) create mode 100644 tests/error_macros_tests.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d026c56e2..9ff885c5a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -212,4 +212,7 @@ ConfigureTest(SYSTEM_MR_TEST mr/device/system_mr_tests.cu) # container multidevice tests ConfigureTest(CONTAINER_MULTIDEVICE_TEST container_multidevice_tests.cu) +# error macros tests +ConfigureTest(ERROR_MACROS_TEST error_macros_tests.cpp) + rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing DESTINATION bin/gtests/librmm) diff --git a/tests/error_macros_tests.cpp b/tests/error_macros_tests.cpp new file mode 100644 index 000000000..9f349b3de --- /dev/null +++ b/tests/error_macros_tests.cpp @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2025, 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. + */ + +#include +#include + +#include + +#include + +#include +#include +#include + +/* + * This file contains tests for the RMM error macros. + * + * RMM macros are not public API but are used externally, so we test them to + * avoid regressions. + * + * The macros are tested for: + * - Successful operations (should not throw) + * - Failed operations (should throw the appropriate exception) + * - Error message formatting + * - Actual CUDA operations + */ + +// Test RMM_EXPECTS macro with condition that evaluates to true (should not throw) +TEST(ErrorMacrosTest, ExpectsNoThrow) +{ + EXPECT_NO_THROW(RMM_EXPECTS(true, "This should not throw")); + EXPECT_NO_THROW(RMM_EXPECTS(true, "This should not throw", std::runtime_error)); +} + +// Test RMM_EXPECTS macro with condition that evaluates to false (should throw) +TEST(ErrorMacrosTest, ExpectsThrow) +{ + EXPECT_THROW(RMM_EXPECTS(false, "Expected exception"), rmm::logic_error); + EXPECT_THROW(RMM_EXPECTS(false, "Expected runtime error", std::runtime_error), + std::runtime_error); +} + +// Test RMM_FAIL macro (should always throw) +TEST(ErrorMacrosTest, FailThrow) +{ + EXPECT_THROW(RMM_FAIL("This should throw logic_error"), rmm::logic_error); + EXPECT_THROW(RMM_FAIL("This should throw runtime_error", std::runtime_error), std::runtime_error); +} + +// Test RMM_CUDA_TRY macro with successful CUDA call (should not throw) +TEST(ErrorMacrosTest, CudaTryNoThrow) +{ + EXPECT_NO_THROW(RMM_CUDA_TRY(cudaSuccess)); + EXPECT_NO_THROW(RMM_CUDA_TRY(cudaSuccess, std::runtime_error)); +} + +// Test RMM_CUDA_TRY macro with failed CUDA call (should throw) +TEST(ErrorMacrosTest, CudaTryThrow) +{ + EXPECT_THROW(RMM_CUDA_TRY(cudaErrorInvalidValue), rmm::cuda_error); + EXPECT_THROW(RMM_CUDA_TRY(cudaErrorInvalidValue, std::runtime_error), std::runtime_error); +} + +// Test RMM_CUDA_TRY_ALLOC macro with successful CUDA call (should not throw) +TEST(ErrorMacrosTest, CudaTryAllocNoThrow) +{ + EXPECT_NO_THROW(RMM_CUDA_TRY_ALLOC(cudaSuccess)); + EXPECT_NO_THROW(RMM_CUDA_TRY_ALLOC(cudaSuccess, 1024)); +} + +// Test RMM_CUDA_TRY_ALLOC macro with general CUDA error (should throw bad_alloc) +TEST(ErrorMacrosTest, CudaTryAllocThrowBadAlloc) +{ + EXPECT_THROW(RMM_CUDA_TRY_ALLOC(cudaErrorInvalidValue), rmm::bad_alloc); + EXPECT_THROW(RMM_CUDA_TRY_ALLOC(cudaErrorInvalidValue, 1024), rmm::bad_alloc); +} + +// Test RMM_CUDA_TRY_ALLOC macro with memory allocation error (should throw out_of_memory) +TEST(ErrorMacrosTest, CudaTryAllocThrowOutOfMemory) +{ + EXPECT_THROW(RMM_CUDA_TRY_ALLOC(cudaErrorMemoryAllocation), rmm::out_of_memory); + EXPECT_THROW(RMM_CUDA_TRY_ALLOC(cudaErrorMemoryAllocation, 1024), rmm::out_of_memory); +} + +// Test RMM_ASSERT_CUDA_SUCCESS macro +// Note: This test is limited since the macro behavior changes based on NDEBUG +// In release builds (NDEBUG defined), it just executes the call +// In debug builds, it asserts on failure which can't be caught in tests +TEST(ErrorMacrosTest, AssertCudaSuccess) +{ + // This should always work regardless of build type + EXPECT_NO_FATAL_FAILURE(RMM_ASSERT_CUDA_SUCCESS([]() { return cudaSuccess; }())); + +// We can't really test the failure case properly in a unit test +// since it would call assert() which terminates the program +#ifdef NDEBUG + // In release builds, this should not crash + EXPECT_NO_FATAL_FAILURE(RMM_ASSERT_CUDA_SUCCESS([]() { return cudaErrorInvalidValue; }())); +#endif +} + +// Test that error messages contain expected information +TEST(ErrorMacrosTest, ErrorMessages) +{ + // Test RMM_EXPECTS error message + try { + RMM_EXPECTS(false, "Test message"); + FAIL() << "Expected RMM_EXPECTS to throw an exception"; + } catch (const rmm::logic_error& e) { + std::string error_message = e.what(); + EXPECT_TRUE(error_message.find("RMM failure at:") != std::string::npos); + EXPECT_TRUE(error_message.find("Test message") != std::string::npos); + } + + // Test RMM_FAIL error message + try { + RMM_FAIL("Test failure message"); + FAIL() << "Expected RMM_FAIL to throw an exception"; + } catch (const rmm::logic_error& e) { + std::string error_message = e.what(); + EXPECT_TRUE(error_message.find("RMM failure at:") != std::string::npos); + EXPECT_TRUE(error_message.find("Test failure message") != std::string::npos); + } + + // Test RMM_CUDA_TRY error message + try { + RMM_CUDA_TRY(cudaErrorInvalidValue); + FAIL() << "Expected RMM_CUDA_TRY to throw an exception"; + } catch (const rmm::cuda_error& e) { + std::string error_message = e.what(); + EXPECT_TRUE(error_message.find("CUDA error at:") != std::string::npos); + EXPECT_TRUE(error_message.find("invalid argument") != std::string::npos); + } + + // Test RMM_CUDA_TRY_ALLOC error message (without bytes) + try { + RMM_CUDA_TRY_ALLOC(cudaErrorInvalidValue); + FAIL() << "Expected RMM_CUDA_TRY_ALLOC to throw an exception"; + } catch (const rmm::bad_alloc& e) { + std::string error_message = e.what(); + EXPECT_TRUE(error_message.find("CUDA error at:") != std::string::npos); + EXPECT_TRUE(error_message.find("invalid argument") != std::string::npos); + } + + // Test RMM_CUDA_TRY_ALLOC error message (with bytes) + try { + RMM_CUDA_TRY_ALLOC(cudaErrorInvalidValue, 1024); + FAIL() << "Expected RMM_CUDA_TRY_ALLOC to throw an exception"; + } catch (const rmm::bad_alloc& e) { + std::string error_message = e.what(); + EXPECT_TRUE(error_message.find("CUDA error (failed to allocate 1024 bytes)") != + std::string::npos); + EXPECT_TRUE(error_message.find("invalid argument") != std::string::npos); + } + + // Test RMM_CUDA_TRY_ALLOC out_of_memory error message + try { + RMM_CUDA_TRY_ALLOC(cudaErrorMemoryAllocation, 2048); + FAIL() << "Expected RMM_CUDA_TRY_ALLOC to throw an exception"; + } catch (const rmm::out_of_memory& e) { + std::string error_message = e.what(); + EXPECT_TRUE(error_message.find("out_of_memory") != std::string::npos); + EXPECT_TRUE(error_message.find("failed to allocate 2048 bytes") != std::string::npos); + EXPECT_TRUE(error_message.find("out of memory") != std::string::npos); + } +} + +// Test actual CUDA operations with the macros +TEST(ErrorMacrosTest, ActualCudaOperations) +{ + // Test successful memory allocation and free + void* d_ptr = nullptr; + constexpr size_t test_allocation_size = 1024; + + EXPECT_NO_THROW( + RMM_CUDA_TRY_ALLOC(cudaMalloc(&d_ptr, test_allocation_size), test_allocation_size)); + ASSERT_NE(d_ptr, nullptr); + + EXPECT_NO_THROW(RMM_CUDA_TRY(cudaFree(d_ptr))); + + // Test successful CUDA operation + std::array h_data = {1, 2, 3, 4, 5}; + int* d_data = nullptr; + + EXPECT_NO_THROW(RMM_CUDA_TRY_ALLOC(cudaMalloc(reinterpret_cast(&d_data), sizeof(h_data)), + sizeof(h_data))); + + ASSERT_NE(d_data, nullptr); + + EXPECT_NO_THROW( + RMM_CUDA_TRY(cudaMemcpy(d_data, h_data.data(), sizeof(h_data), cudaMemcpyHostToDevice))); + + std::array h_result = {0}; + EXPECT_NO_THROW( + RMM_CUDA_TRY(cudaMemcpy(h_result.data(), d_data, sizeof(h_result), cudaMemcpyDeviceToHost))); + + for (size_t i = 0; i < h_data.size(); ++i) { + EXPECT_EQ(h_data[i], h_result[i]); + } + + EXPECT_NO_THROW(RMM_CUDA_TRY(cudaFree(d_data))); +} From d8b7dacdeda302d2e37313c02d14ef5e1d1e98ea Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 6 Mar 2025 06:48:52 -0600 Subject: [PATCH 574/675] Run examples in CI (#1850) This PR runs C++ examples in CI. Closes #1845. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1850 --- ci/release/update-version.sh | 1 + ci/test_cpp.sh | 13 +++++++++++++ dependencies.yaml | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 21d76a117..ce4dcab1c 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -50,6 +50,7 @@ done DEPENDENCIES=( librmm librmm-tests + librmm-example rmm ) for DEP in "${DEPENDENCIES[@]}"; do diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index d834deed5..86b2100e3 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -38,5 +38,18 @@ rapids-logger "Run gtests" export GTEST_OUTPUT=xml:${RAPIDS_TESTS_DIR}/ ./ci/run_ctests.sh -j20 && EXITCODE=$? || EXITCODE=$?; +# Run all examples from librmm-example package +for example in ${CONDA_PREFIX}/bin/examples/librmm/*; do + if [ -x "$example" ]; then + rapids-logger "Running example: $(basename "$example")" + "$example" && EXAMPLE_EXITCODE=$? || EXAMPLE_EXITCODE=$?; + if [ $EXAMPLE_EXITCODE -ne 0 ]; then + rapids-logger "Example $(basename "$example") failed with exit code: $EXAMPLE_EXITCODE" + EXITCODE=$EXAMPLE_EXITCODE + break + fi + fi +done + rapids-logger "Test script exiting with value: $EXITCODE" exit "${EXITCODE}" diff --git a/dependencies.yaml b/dependencies.yaml index 8b74437b0..97a23f64f 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -33,6 +33,7 @@ files: - test_cpp - depends_on_librmm - depends_on_librmm_tests + - depends_on_librmm_example checks: output: none includes: @@ -223,6 +224,11 @@ dependencies: - output_types: conda packages: - librmm-tests=25.4.*,>=0.0.0a0 + depends_on_librmm_example: + common: + - output_types: conda + packages: + - librmm-example=25.4.*,>=0.0.0a0 checks: common: - output_types: [conda, requirements] From 9432761ef19d8731daef00077c59e09fe865f6b9 Mon Sep 17 00:00:00 2001 From: Ray Douglass <3107146+raydouglass@users.noreply.github.com> Date: Thu, 13 Mar 2025 16:20:13 -0400 Subject: [PATCH 575/675] Fix dependencies.yaml for update-version.sh (#1859) Updates several `dependencies.yaml` entries to match the others in the file which allows the `update-version.sh` script to work correctly. --- dependencies.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dependencies.yaml b/dependencies.yaml index 97a23f64f..ae6030ddb 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -218,17 +218,17 @@ dependencies: common: - output_types: conda packages: - - rmm=25.4.*,>=0.0.0a0 + - rmm==25.4.*,>=0.0.0a0 depends_on_librmm_tests: common: - output_types: conda packages: - - librmm-tests=25.4.*,>=0.0.0a0 + - librmm-tests==25.4.*,>=0.0.0a0 depends_on_librmm_example: common: - output_types: conda packages: - - librmm-example=25.4.*,>=0.0.0a0 + - librmm-example==25.4.*,>=0.0.0a0 checks: common: - output_types: [conda, requirements] From 015b3e9f90bbbbb8db2240d00cb33c5ffa842e55 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Thu, 13 Mar 2025 16:31:50 -0400 Subject: [PATCH 576/675] DOC v25.06 Updates [skip ci] --- .../cuda11.8-conda/devcontainer.json | 6 ++--- .devcontainer/cuda11.8-pip/devcontainer.json | 6 ++--- .../cuda12.8-conda/devcontainer.json | 6 ++--- .devcontainer/cuda12.8-pip/devcontainer.json | 6 ++--- .github/workflows/build.yaml | 16 ++++++------- .github/workflows/pr.yaml | 24 +++++++++---------- .github/workflows/test.yaml | 6 ++--- .../trigger-breaking-change-alert.yaml | 2 +- VERSION | 2 +- dependencies.yaml | 12 +++++----- examples/versions.cmake | 2 +- python/rmm/pyproject.toml | 4 ++-- 12 files changed, 46 insertions(+), 46 deletions(-) diff --git a/.devcontainer/cuda11.8-conda/devcontainer.json b/.devcontainer/cuda11.8-conda/devcontainer.json index e962a832e..623564437 100644 --- a/.devcontainer/cuda11.8-conda/devcontainer.json +++ b/.devcontainer/cuda11.8-conda/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:25.04-cpp-cuda11.8-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.06-cpp-cuda11.8-mambaforge-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.04-cuda11.8-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.06-cuda11.8-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.4": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.6": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda11.8-pip/devcontainer.json b/.devcontainer/cuda11.8-pip/devcontainer.json index 9e2c567bc..00e38435d 100644 --- a/.devcontainer/cuda11.8-pip/devcontainer.json +++ b/.devcontainer/cuda11.8-pip/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:25.04-cpp-cuda11.8-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.06-cpp-cuda11.8-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.04-cuda11.8-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.06-cuda11.8-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.4": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.6": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.8-conda/devcontainer.json b/.devcontainer/cuda12.8-conda/devcontainer.json index fcf20229d..faa81b709 100644 --- a/.devcontainer/cuda12.8-conda/devcontainer.json +++ b/.devcontainer/cuda12.8-conda/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "12.8", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:25.04-cpp-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.06-cpp-mambaforge-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.04-cuda12.8-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.06-cuda12.8-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.4": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.6": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.8-pip/devcontainer.json b/.devcontainer/cuda12.8-pip/devcontainer.json index 6620e32a1..e89ed2218 100644 --- a/.devcontainer/cuda12.8-pip/devcontainer.json +++ b/.devcontainer/cuda12.8-pip/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "12.8", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:25.04-cpp-cuda12.8-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.06-cpp-cuda12.8-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.04-cuda12.8-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.06-cuda12.8-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.4": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.6": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8b66806f6..a3506bf18 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -40,7 +40,7 @@ jobs: cpp-build: needs: [telemetry-setup] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -49,7 +49,7 @@ jobs: python-build: needs: [telemetry-setup, cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -58,7 +58,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-25.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: if: github.ref_type == 'branch' needs: [python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -81,7 +81,7 @@ jobs: wheel-build-cpp: needs: [telemetry-setup] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.06 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -92,7 +92,7 @@ jobs: wheel-build-python: needs: [telemetry-setup, wheel-build-cpp] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -102,7 +102,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -113,7 +113,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index c71d5f391..1219279a6 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -26,7 +26,7 @@ jobs: - devcontainer - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-25.06 if: always() with: needs: ${{ toJSON(needs) }} @@ -57,7 +57,7 @@ jobs: needs: - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-25.06 with: files_yaml: | test_cpp: @@ -79,40 +79,40 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-25.06 with: enable_check_generated_files: false ignored_pr_jobs: "telemetry-summarize" conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.06 with: build_type: pull-request conda-cpp-tests: needs: [conda-cpp-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.06 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.06 with: build_type: pull-request conda-python-tests: needs: [conda-python-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.06 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.06 with: build_type: pull-request node_type: "gpu-l4-latest-1" @@ -122,7 +122,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.06 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -130,14 +130,14 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.06 with: build_type: pull-request script: ci/build_wheel_python.sh wheel-tests: needs: [wheel-build-python, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.06 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request @@ -146,7 +146,7 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-25.06 with: arch: '["amd64"]' cuda: '["12.8"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b66687b63..7744b7263 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,7 +19,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.06 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} @@ -27,7 +27,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.06 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} @@ -35,7 +35,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.06 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/trigger-breaking-change-alert.yaml b/.github/workflows/trigger-breaking-change-alert.yaml index 9764c62c1..475380cb6 100644 --- a/.github/workflows/trigger-breaking-change-alert.yaml +++ b/.github/workflows/trigger-breaking-change-alert.yaml @@ -12,7 +12,7 @@ jobs: trigger-notifier: if: contains(github.event.pull_request.labels.*.name, 'breaking') secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@branch-25.04 + uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@branch-25.06 with: sender_login: ${{ github.event.sender.login }} sender_avatar: ${{ github.event.sender.avatar_url }} diff --git a/VERSION b/VERSION index b922658ff..cc83d7ab4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -25.04.00 +25.06.00 diff --git a/dependencies.yaml b/dependencies.yaml index ae6030ddb..809773143 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -191,7 +191,7 @@ dependencies: common: - output_types: conda packages: - - &librmm_unsuffixed librmm==25.4.*,>=0.0.0a0 + - &librmm_unsuffixed librmm==25.6.*,>=0.0.0a0 - output_types: requirements packages: # pip recognizes the index as a global option for the requirements.txt file @@ -205,12 +205,12 @@ dependencies: cuda: "12.*" cuda_suffixed: "true" packages: - - librmm-cu12==25.4.*,>=0.0.0a0 + - librmm-cu12==25.6.*,>=0.0.0a0 - matrix: cuda: "11.*" cuda_suffixed: "true" packages: - - librmm-cu11==25.4.*,>=0.0.0a0 + - librmm-cu11==25.6.*,>=0.0.0a0 - matrix: packages: - *librmm_unsuffixed @@ -218,17 +218,17 @@ dependencies: common: - output_types: conda packages: - - rmm==25.4.*,>=0.0.0a0 + - rmm==25.6.*,>=0.0.0a0 depends_on_librmm_tests: common: - output_types: conda packages: - - librmm-tests==25.4.*,>=0.0.0a0 + - librmm-tests==25.6.*,>=0.0.0a0 depends_on_librmm_example: common: - output_types: conda packages: - - librmm-example==25.4.*,>=0.0.0a0 + - librmm-example==25.6.*,>=0.0.0a0 checks: common: - output_types: [conda, requirements] diff --git a/examples/versions.cmake b/examples/versions.cmake index 9969c695c..feac5e0a9 100644 --- a/examples/versions.cmake +++ b/examples/versions.cmake @@ -12,4 +12,4 @@ # the License. # ============================================================================= -set(RMM_TAG branch-25.04) +set(RMM_TAG branch-25.06) diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index cc61bad98..0b23cfc19 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -31,7 +31,7 @@ license = { text = "Apache-2.0" } requires-python = ">=3.10" dependencies = [ "cuda-python>=11.8.5,<12.0a0", - "librmm==25.4.*,>=0.0.0a0", + "librmm==25.6.*,>=0.0.0a0", "numpy>=1.23,<3.0a0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. classifiers = [ @@ -78,7 +78,7 @@ requires = [ "cmake>=3.30.4", "cuda-python>=11.8.5,<12.0a0", "cython>=3.0.0", - "librmm==25.4.*,>=0.0.0a0", + "librmm==25.6.*,>=0.0.0a0", "ninja", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. From f87d7a64e2451fc54a98bc267e556a371fcff1e3 Mon Sep 17 00:00:00 2001 From: jakirkham Date: Thu, 13 Mar 2025 15:04:32 -0700 Subject: [PATCH 577/675] Embed `__FILE__` as C-string for prefix replacement (#1858) Recently PR ( https://github.com/rapidsai/rmm/pull/1844 ) changed how error messages were generated when pointing to a particular file and line number. In particular they changed from using the typical C-string (`const char*`), which is `\0` terminated, to a C++ `std::string` object, which is not `\0` terminated. This change in turn was picked up when RMM headers are used to compile libraries (like cuDF) including file paths in strings that are not `\0` terminated. Conda in turn would detect the paths in these error messages and attempt to fix them as part of the prefix replacement process. When Conda did the prefix replacement would add an additional `\0` terminating character to string. However as the strings are now `std::string` based which lack `\0` terminating characters the final string written out by Conda would be one byte longer. This could mean overwriting other text data in the library or writing outside the text block. This is known bug in Conda ( https://github.com/conda/conda-build/issues/1674 ). Thus when cuDF started building with the aforementioned RMM change last week, the packages it created lacked had file paths in error messages lacking the `\0` terminating character. These in turn would be inadvertently corrupted by Conda when installing the packages in an environment. This led to a quite hairy bug detailed in issue ( https://github.com/rapidsai/cudf/issues/18251 ). To correct this issue, we drop the `std::string` constructor that was added in the aforementioned PR. More specifically we adapted the following code from cuDF's [`CUDF_EXPECTS_3`]( https://github.com/rapidsai/cudf/blob/8041ac8e370b092229841508fdfd1efb88fef034/cpp/include/cudf/utilities/error.hpp#L186-L192 ) and [`CUDF_FAIL_2`]( https://github.com/rapidsai/cudf/blob/86eb82399f0e056731e2062dc95a4583c26e9af1/cpp/include/cudf/utilities/error.hpp#L225-L227 ), which still uses a C-style string. Also to address the need for runtime generation of some errors. We use `std::string` for only an initial snippet of the string and add other contents like the `__FILE__` after. This keeps the latter bits as C-style strings. Authors: - https://github.com/jakirkham Approvers: - Bradley Dice (https://github.com/bdice) - Paul Mattione (https://github.com/pmattione-nvidia) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1858 --- include/rmm/detail/error.hpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/include/rmm/detail/error.hpp b/include/rmm/detail/error.hpp index ae5b37acf..606c7638a 100644 --- a/include/rmm/detail/error.hpp +++ b/include/rmm/detail/error.hpp @@ -21,8 +21,10 @@ #include #include +#include #include #include +#include #define STRINGIFY_DETAIL(x) #x #define RMM_STRINGIFY(x) STRINGIFY_DETAIL(x) @@ -55,12 +57,14 @@ GET_RMM_EXPECTS_MACRO(__VA_ARGS__, RMM_EXPECTS_3, RMM_EXPECTS_2) \ (__VA_ARGS__) #define GET_RMM_EXPECTS_MACRO(_1, _2, _3, NAME, ...) NAME -#define RMM_EXPECTS_3(_condition, _reason, _exception_type) \ - (!!(_condition)) ? static_cast(0) \ - : throw _exception_type /*NOLINT(bugprone-macro-parentheses)*/ \ - { \ - std::string("RMM failure at: " __FILE__ ":" RMM_STRINGIFY(__LINE__) ": ") + _reason \ - } +#define RMM_EXPECTS_3(_condition, _reason, _exception_type) \ + do { \ + static_assert(std::is_base_of_v); \ + /*NOLINTNEXTLINE(bugprone-macro-parentheses)*/ \ + (!!(_condition)) ? static_cast(0) \ + : throw _exception_type{std::string{"RMM failure at: "} + __FILE__ + ":" + \ + RMM_STRINGIFY(__LINE__) + ": " + _reason}; \ + } while (0) #define RMM_EXPECTS_2(_condition, _reason) RMM_EXPECTS_3(_condition, _reason, rmm::logic_error) /** @@ -79,10 +83,12 @@ GET_RMM_FAIL_MACRO(__VA_ARGS__, RMM_FAIL_2, RMM_FAIL_1) \ (__VA_ARGS__) #define GET_RMM_FAIL_MACRO(_1, _2, NAME, ...) NAME -#define RMM_FAIL_2(_what, _exception_type) \ - /*NOLINTNEXTLINE(bugprone-macro-parentheses)*/ \ - throw _exception_type{std::string{"RMM failure at:" __FILE__ ":" RMM_STRINGIFY(__LINE__) ": "} + \ - _what}; +#define RMM_FAIL_2(_what, _exception_type) \ + /*NOLINTNEXTLINE(bugprone-macro-parentheses)*/ \ + throw _exception_type \ + { \ + std::string{"RMM failure at:"} + __FILE__ + ":" + RMM_STRINGIFY(__LINE__) + ": " + _what \ + } #define RMM_FAIL_1(_what) RMM_FAIL_2(_what, rmm::logic_error) /** From 019228de3afb61ba15aa554f416ac3a8a01bd1ac Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 17 Mar 2025 05:55:59 -0700 Subject: [PATCH 578/675] Fix run export on cudatoolkit (#1862) rmm nightlies are currently failing on CUDA 11.4 because CUDA 11 librmm-examples package is overconstrained. --- conda/recipes/librmm/recipe.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conda/recipes/librmm/recipe.yaml b/conda/recipes/librmm/recipe.yaml index 151278784..c5b3ba8c4 100644 --- a/conda/recipes/librmm/recipe.yaml +++ b/conda/recipes/librmm/recipe.yaml @@ -177,6 +177,8 @@ outputs: by_name: - cuda-version - librmm + - if: cuda_major == "11" + then: cudatoolkit about: homepage: ${{ load_from_file("python/librmm/pyproject.toml").project.urls.Homepage }} license: ${{ load_from_file("python/librmm/pyproject.toml").project.license.text | replace(" ", "-") }} From c66ded571957b3a90213a15d04bf51870c3a7928 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 18 Mar 2025 17:56:57 -0500 Subject: [PATCH 579/675] Add async view memory resource bindings to Python. (#1864) Closes #1611. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Lawrence Mitchell (https://github.com/wence-) URL: https://github.com/rapidsai/rmm/pull/1864 --- .../cuda_async_view_memory_resource.hpp | 13 +++--- python/rmm/rmm/librmm/memory_resource.pxd | 12 ++++- python/rmm/rmm/mr.py | 4 +- python/rmm/rmm/pylibrmm/memory_resource.pxd | 5 +- python/rmm/rmm/pylibrmm/memory_resource.pyx | 46 ++++++++++++++++++- python/rmm/rmm/tests/test_rmm.py | 39 ++++++++++++++++ 6 files changed, 108 insertions(+), 11 deletions(-) diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp index 92aea2072..0ef159c9f 100644 --- a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_view_memory_resource.hpp @@ -47,13 +47,13 @@ class cuda_async_view_memory_resource final : public device_memory_resource { * * @throws rmm::logic_error if the CUDA version does not support `cudaMallocAsync` * - * @param valid_pool_handle Handle to a CUDA memory pool which will be used to + * @param pool_handle Handle to a CUDA memory pool which will be used to * serve allocation requests. */ - cuda_async_view_memory_resource(cudaMemPool_t valid_pool_handle) - : cuda_pool_handle_{[valid_pool_handle]() { - RMM_EXPECTS(nullptr != valid_pool_handle, "Unexpected null pool handle."); - return valid_pool_handle; + cuda_async_view_memory_resource(cudaMemPool_t pool_handle) + : cuda_pool_handle_{[pool_handle]() { + RMM_EXPECTS(nullptr != pool_handle, "Unexpected null pool handle."); + return pool_handle; }()} { // Check if cudaMallocAsync Memory pool supported @@ -72,7 +72,8 @@ class cuda_async_view_memory_resource final : public device_memory_resource { */ [[nodiscard]] cudaMemPool_t pool_handle() const noexcept { return cuda_pool_handle_; } - cuda_async_view_memory_resource() = default; + cuda_async_view_memory_resource() = default; + ~cuda_async_view_memory_resource() = default; cuda_async_view_memory_resource(cuda_async_view_memory_resource const&) = default; ///< @default_copy_constructor cuda_async_view_memory_resource(cuda_async_view_memory_resource&&) = diff --git a/python/rmm/rmm/librmm/memory_resource.pxd b/python/rmm/rmm/librmm/memory_resource.pxd index 9e7b70c4f..3ded7a9be 100644 --- a/python/rmm/rmm/librmm/memory_resource.pxd +++ b/python/rmm/rmm/librmm/memory_resource.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2024, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,6 +23,8 @@ from libcpp.optional cimport optional from libcpp.pair cimport pair from libcpp.string cimport string +from cuda.bindings.cyruntime cimport cudaMemPool_t + from rmm.librmm.cuda_stream_view cimport cuda_stream_view from rmm.librmm.memory_resource cimport device_memory_resource @@ -108,6 +110,14 @@ cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ optional[size_t] release_threshold, optional[allocation_handle_type] export_handle_type) except + +cdef extern from "rmm/mr/device/cuda_async_view_memory_resource.hpp" \ + namespace "rmm::mr" nogil: + + cdef cppclass cuda_async_view_memory_resource(device_memory_resource): + cuda_async_view_memory_resource( + cudaMemPool_t pool_handle) except + + cudaMemPool_t pool_handle() const + # TODO: when we adopt Cython 3.0 use enum class cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ namespace \ diff --git a/python/rmm/rmm/mr.py b/python/rmm/rmm/mr.py index 673ffde82..eada9b21b 100644 --- a/python/rmm/rmm/mr.py +++ b/python/rmm/rmm/mr.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2024, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ BinningMemoryResource, CallbackMemoryResource, CudaAsyncMemoryResource, + CudaAsyncViewMemoryResource, CudaMemoryResource, DeviceMemoryResource, FailureCallbackResourceAdaptor, @@ -50,6 +51,7 @@ "BinningMemoryResource", "CallbackMemoryResource", "CudaAsyncMemoryResource", + "CudaAsyncViewMemoryResource", "CudaMemoryResource", "DeviceMemoryResource", "FailureCallbackResourceAdaptor", diff --git a/python/rmm/rmm/pylibrmm/memory_resource.pxd b/python/rmm/rmm/pylibrmm/memory_resource.pxd index d1e5610db..8ccd07a02 100644 --- a/python/rmm/rmm/pylibrmm/memory_resource.pxd +++ b/python/rmm/rmm/pylibrmm/memory_resource.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2024, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -44,6 +44,9 @@ cdef class SamHeadroomMemoryResource(DeviceMemoryResource): cdef class CudaAsyncMemoryResource(DeviceMemoryResource): pass +cdef class CudaAsyncViewMemoryResource(DeviceMemoryResource): + pass + cdef class PoolMemoryResource(UpstreamResourceAdaptor): pass diff --git a/python/rmm/rmm/pylibrmm/memory_resource.pyx b/python/rmm/rmm/pylibrmm/memory_resource.pyx index 0189a58b5..253352e7c 100644 --- a/python/rmm/rmm/pylibrmm/memory_resource.pyx +++ b/python/rmm/rmm/pylibrmm/memory_resource.pyx @@ -28,7 +28,8 @@ from libcpp.memory cimport make_unique, unique_ptr from libcpp.optional cimport optional from libcpp.pair cimport pair -from cuda.bindings.runtime import cudaError_t +from cuda.bindings cimport cyruntime +from cuda.bindings import driver, runtime from rmm._cuda.gpu import CUDARuntimeError, getDevice, setDevice @@ -54,6 +55,7 @@ from rmm.librmm.memory_resource cimport ( binning_memory_resource, callback_memory_resource, cuda_async_memory_resource, + cuda_async_view_memory_resource, cuda_memory_resource, deallocate_callback_t, device_memory_resource, @@ -203,6 +205,46 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): ) +cdef class CudaAsyncViewMemoryResource(DeviceMemoryResource): + """ + Memory resource that uses ``cudaMallocAsync``/``cudaFreeAsync`` for + allocation/deallocation with an existing CUDA memory pool. + + This resource uses an existing CUDA memory pool handle (such as the default pool) + instead of creating a new one. This is useful for integrating with existing GPU + applications that already use a CUDA memory pool, or customizing the flags + used by the memory pool. + + The memory pool passed in must not be destroyed during the lifetime of this + memory resource. + + Parameters + ---------- + pool_handle : cudaMemPool_t or CUmemoryPool + Handle to a CUDA memory pool which will be used to serve allocation + requests. + """ + def __cinit__( + self, + pool_handle + ): + # Convert the pool_handle to a cyruntime.cudaMemPool_t + if not isinstance(pool_handle, (runtime.cudaMemPool_t, driver.CUmemoryPool)): + raise ValueError("pool_handle must be a cudaMemPool_t or CUmemoryPool") + + cdef cyruntime.cudaMemPool_t c_pool_handle + c_pool_handle = int(pool_handle) + + self.c_obj.reset( + new cuda_async_view_memory_resource(c_pool_handle) + ) + + def pool_handle(self): + cdef cuda_async_view_memory_resource* c_mr = \ + self.c_obj.get() + return c_mr.pool_handle() + + cdef class ManagedMemoryResource(DeviceMemoryResource): def __cinit__(self): self.c_obj.reset( @@ -991,7 +1033,7 @@ cpdef void _initialize( try: original_device = getDevice() except CUDARuntimeError as e: - if e.status == cudaError_t.cudaErrorNoDevice: + if e.status == runtime.cudaError_t.cudaErrorNoDevice: warnings.warn(e.msg) else: raise e diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index ee02d5d0e..2fc917863 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -1078,3 +1078,42 @@ def test_available_device_memory(): assert initial_memory[1] == final_memory[1] assert initial_memory[0] > 0 assert final_memory[0] > 0 + + +@pytest.mark.parametrize("dtype", _dtypes) +@pytest.mark.parametrize("nelem", _nelems) +@pytest.mark.parametrize("alloc", _allocs) +def test_cuda_async_view_memory_resource_default_pool(dtype, nelem, alloc): + # Get the default memory pool handle + current_device = rmm._cuda.gpu.getDevice() + err, pool = runtime.cudaDeviceGetDefaultMemPool(current_device) + assert err == runtime.cudaError_t.cudaSuccess + + mr = rmm.mr.CudaAsyncViewMemoryResource(pool) + rmm.mr.set_current_device_resource(mr) + assert rmm.mr.get_current_device_resource_type() is type(mr) + array_tester(dtype, nelem, alloc) + + +@pytest.mark.parametrize("dtype", _dtypes) +@pytest.mark.parametrize("nelem", _nelems) +@pytest.mark.parametrize("alloc", _allocs) +def test_cuda_async_view_memory_resource_custom_pool(dtype, nelem, alloc): + # Create a memory pool handle + props = runtime.cudaMemPoolProps() + props.allocType = runtime.cudaMemAllocationType.cudaMemAllocationTypePinned + props.location.id = rmm._cuda.gpu.getDevice() + props.location.type = runtime.cudaMemLocationType.cudaMemLocationTypeDevice + err, pool = runtime.cudaMemPoolCreate(props) + assert err == runtime.cudaError_t.cudaSuccess + + mr = rmm.mr.CudaAsyncViewMemoryResource(pool) + rmm.mr.set_current_device_resource(mr) + assert rmm.mr.get_current_device_resource_type() is type(mr) + array_tester(dtype, nelem, alloc) + + # After the pool is destroyed, new allocations should raise + (err,) = runtime.cudaMemPoolDestroy(pool) + assert err == runtime.cudaError_t.cudaSuccess + with pytest.raises(MemoryError): + array_tester(dtype, nelem, alloc) From 71db9be186e60c297766e66257fd5b3944173a24 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 18 Mar 2025 18:09:11 -0500 Subject: [PATCH 580/675] Error if LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE is not defined. (#1852) Closes #1783. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Lawrence Mitchell (https://github.com/wence-) - James Lamb (https://github.com/jameslamb) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1852 --- ci/build_cpp.sh | 4 ++ include/rmm/detail/cuda_memory_resource.hpp | 23 +++++++++++ include/rmm/device_buffer.hpp | 1 - include/rmm/device_uvector.hpp | 2 - .../rmm/mr/device/device_memory_resource.hpp | 3 +- .../mr/device/thrust_allocator_adaptor.hpp | 4 +- include/rmm/mr/host/host_memory_resource.hpp | 3 +- include/rmm/mr/is_resource_adaptor.hpp | 4 +- .../rmm/mr/pinned_host_memory_resource.hpp | 2 +- include/rmm/resource_ref.hpp | 5 +-- tests/device_scalar_tests.cpp | 2 +- tests/libcudacxx_flag_test/README.md | 1 + .../libcudacxx_flag_test.cpp | 33 ++++++++++++++++ .../libcudacxx_flag_test.sh | 39 +++++++++++++++++++ tests/mr/device/adaptor_tests.cpp | 3 +- tests/mr/device/cuda_async_view_mr_tests.cpp | 5 +-- .../mr/device/mr_ref_multithreaded_tests.cpp | 2 - tests/mr/device/mr_ref_test.hpp | 4 +- tests/mr/device/mr_ref_tests.cpp | 4 +- tests/mr/host/mr_ref_tests.cpp | 2 +- 20 files changed, 116 insertions(+), 30 deletions(-) create mode 100644 include/rmm/detail/cuda_memory_resource.hpp create mode 100644 tests/libcudacxx_flag_test/README.md create mode 100644 tests/libcudacxx_flag_test/libcudacxx_flag_test.cpp create mode 100755 tests/libcudacxx_flag_test/libcudacxx_flag_test.sh diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 6248247c9..3bac033f9 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -41,4 +41,8 @@ rapids-telemetry-record sccache-stats.txt sccache --show-adv-stats # remove build_cache directory rm -rf "$RAPIDS_CONDA_BLD_OUTPUT_DIR"/build_cache +# Run the libcudacxx flag test at build time, since compilers are available +rapids-logger "Run libcudacxx_flag_test" +./tests/libcudacxx_flag_test/libcudacxx_flag_test.sh + rapids-upload-conda-to-s3 cpp diff --git a/include/rmm/detail/cuda_memory_resource.hpp b/include/rmm/detail/cuda_memory_resource.hpp new file mode 100644 index 000000000..cebc7886f --- /dev/null +++ b/include/rmm/detail/cuda_memory_resource.hpp @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025, 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. + */ +#pragma once + +#ifndef LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE +#error \ + "RMM requires LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE to be defined. Please add -DLIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE to the compiler flags (this is done automatically when using RMM via CMake)." +#endif + +#include diff --git a/include/rmm/device_buffer.hpp b/include/rmm/device_buffer.hpp index 25b921614..ea4a28b00 100644 --- a/include/rmm/device_buffer.hpp +++ b/include/rmm/device_buffer.hpp @@ -22,7 +22,6 @@ #include #include -#include #include #include diff --git a/include/rmm/device_uvector.hpp b/include/rmm/device_uvector.hpp index 625e9ab71..b790584db 100644 --- a/include/rmm/device_uvector.hpp +++ b/include/rmm/device_uvector.hpp @@ -24,8 +24,6 @@ #include #include -#include - #include #include #include diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/include/rmm/mr/device/device_memory_resource.hpp index b1c5ff7d3..8a0de78f1 100644 --- a/include/rmm/mr/device/device_memory_resource.hpp +++ b/include/rmm/mr/device/device_memory_resource.hpp @@ -17,11 +17,10 @@ #include #include +#include #include #include -#include - #include namespace RMM_NAMESPACE { diff --git a/include/rmm/mr/device/thrust_allocator_adaptor.hpp b/include/rmm/mr/device/thrust_allocator_adaptor.hpp index b7b990c3d..0857336d7 100644 --- a/include/rmm/mr/device/thrust_allocator_adaptor.hpp +++ b/include/rmm/mr/device/thrust_allocator_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2024, NVIDIA CORPORATION. + * Copyright (c) 2019-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,12 +17,12 @@ #pragma once #include +#include #include #include #include #include -#include #include #include #include diff --git a/include/rmm/mr/host/host_memory_resource.hpp b/include/rmm/mr/host/host_memory_resource.hpp index ac0ace4ab..d10ef0ac8 100644 --- a/include/rmm/mr/host/host_memory_resource.hpp +++ b/include/rmm/mr/host/host_memory_resource.hpp @@ -15,11 +15,10 @@ */ #pragma once +#include #include #include -#include - #include namespace RMM_NAMESPACE { diff --git a/include/rmm/mr/is_resource_adaptor.hpp b/include/rmm/mr/is_resource_adaptor.hpp index 64f0e61d2..941c89496 100644 --- a/include/rmm/mr/is_resource_adaptor.hpp +++ b/include/rmm/mr/is_resource_adaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, NVIDIA CORPORATION. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,9 +15,9 @@ */ #pragma once +#include #include -#include #include namespace RMM_NAMESPACE { diff --git a/include/rmm/mr/pinned_host_memory_resource.hpp b/include/rmm/mr/pinned_host_memory_resource.hpp index 3f5878171..865fedb40 100644 --- a/include/rmm/mr/pinned_host_memory_resource.hpp +++ b/include/rmm/mr/pinned_host_memory_resource.hpp @@ -17,11 +17,11 @@ #include #include +#include #include #include #include -#include #include #include diff --git a/include/rmm/resource_ref.hpp b/include/rmm/resource_ref.hpp index 285726478..c42319300 100644 --- a/include/rmm/resource_ref.hpp +++ b/include/rmm/resource_ref.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, NVIDIA CORPORATION. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,11 +15,10 @@ */ #pragma once +#include #include #include -#include - namespace RMM_NAMESPACE { /** diff --git a/tests/device_scalar_tests.cpp b/tests/device_scalar_tests.cpp index 189d571e0..ca96d5f7f 100644 --- a/tests/device_scalar_tests.cpp +++ b/tests/device_scalar_tests.cpp @@ -15,12 +15,12 @@ */ #include +#include #include #include #include #include -#include #include #include diff --git a/tests/libcudacxx_flag_test/README.md b/tests/libcudacxx_flag_test/README.md new file mode 100644 index 000000000..1a278e5a7 --- /dev/null +++ b/tests/libcudacxx_flag_test/README.md @@ -0,0 +1 @@ +This directory contains test files to verify that RMM reports a compile error when the `LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE` preprocessor macro is not defined. diff --git a/tests/libcudacxx_flag_test/libcudacxx_flag_test.cpp b/tests/libcudacxx_flag_test/libcudacxx_flag_test.cpp new file mode 100644 index 000000000..787f3d5e5 --- /dev/null +++ b/tests/libcudacxx_flag_test/libcudacxx_flag_test.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025, 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. + */ + +/** + * @file libcudacxx_flag_test.cpp + * @brief Test that verifies the error message when `LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE` + * is not defined. + * + * This test is expected to fail to compile with a clear error message. + * To run this test, you need to compile it separately without defining + * `LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE`. + * + * Example: + * `g++ -std=c++17 -I../../include libcudacxx_flag_test.cpp` + */ + +// Include a header that requires LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE +#include + +int main() { return 0; } diff --git a/tests/libcudacxx_flag_test/libcudacxx_flag_test.sh b/tests/libcudacxx_flag_test/libcudacxx_flag_test.sh new file mode 100755 index 000000000..8e319d9e9 --- /dev/null +++ b/tests/libcudacxx_flag_test/libcudacxx_flag_test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Copyright (c) 2025, NVIDIA CORPORATION. + +set -euo pipefail + +# Get the directory of this script +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "${SCRIPT_DIR}" + +# Path to the RMM include directory (absolute path) +RMM_INCLUDE_DIR="${SCRIPT_DIR}/../../include" + +echo "Testing compilation failure when LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE is not defined" +echo "Using RMM include directory: ${RMM_INCLUDE_DIR}" + +# Create a temporary file for compilation errors +ERROR_FILE=$(mktemp) +trap 'rm -f "${ERROR_FILE}"' EXIT + +# Try to compile the file without defining LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE +set +e +g++ -std=c++17 -I"${RMM_INCLUDE_DIR}" libcudacxx_flag_test.cpp -o libcudacxx_flag_test 2> "${ERROR_FILE}" +set -e + +if $?; then + echo "Test failed: Compilation succeeded when it should have failed" + exit 1 +fi + +# Check if the error message contains the expected text +if ! grep -q "RMM requires LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE to be defined" "${ERROR_FILE}"; then + echo "Test failed: Compilation failed but with an unexpected error message:" + cat "${ERROR_FILE}" + exit 1 +fi + +# Don't show the error message, to avoid confusing it with a real error in the CI logs. +echo "Test passed: Compilation failed with the expected error message" +exit 0 diff --git a/tests/mr/device/adaptor_tests.cpp b/tests/mr/device/adaptor_tests.cpp index e04fa1ebb..7ac43e24c 100644 --- a/tests/mr/device/adaptor_tests.cpp +++ b/tests/mr/device/adaptor_tests.cpp @@ -16,6 +16,7 @@ #include "../../byte_literals.hpp" +#include #include #include #include @@ -30,8 +31,6 @@ #include #include -#include - #include #include diff --git a/tests/mr/device/cuda_async_view_mr_tests.cpp b/tests/mr/device/cuda_async_view_mr_tests.cpp index f3a02cbf0..c9d75db50 100644 --- a/tests/mr/device/cuda_async_view_mr_tests.cpp +++ b/tests/mr/device/cuda_async_view_mr_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, NVIDIA CORPORATION. + * Copyright (c) 2021-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,11 +15,10 @@ */ #include +#include #include #include -#include - #include namespace rmm::test { diff --git a/tests/mr/device/mr_ref_multithreaded_tests.cpp b/tests/mr/device/mr_ref_multithreaded_tests.cpp index 4507793e7..47961f4fb 100644 --- a/tests/mr/device/mr_ref_multithreaded_tests.cpp +++ b/tests/mr/device/mr_ref_multithreaded_tests.cpp @@ -24,8 +24,6 @@ #include #include -#include - #include #include diff --git a/tests/mr/device/mr_ref_test.hpp b/tests/mr/device/mr_ref_test.hpp index 2af0eff44..ea0a86eab 100644 --- a/tests/mr/device/mr_ref_test.hpp +++ b/tests/mr/device/mr_ref_test.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,8 +36,6 @@ #include #include -#include - #include #include diff --git a/tests/mr/device/mr_ref_tests.cpp b/tests/mr/device/mr_ref_tests.cpp index 41af050a0..080bac2c4 100644 --- a/tests/mr/device/mr_ref_tests.cpp +++ b/tests/mr/device/mr_ref_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024, NVIDIA CORPORATION. + * Copyright (c) 2023-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,6 @@ #include #include -#include - #include namespace rmm::test { diff --git a/tests/mr/host/mr_ref_tests.cpp b/tests/mr/host/mr_ref_tests.cpp index 5d8eb8350..f1adbe1fc 100644 --- a/tests/mr/host/mr_ref_tests.cpp +++ b/tests/mr/host/mr_ref_tests.cpp @@ -17,11 +17,11 @@ #include "../../byte_literals.hpp" #include +#include #include #include #include -#include #include #include From 7f0cead1b9c6970687ce6ef84091d08471b913cd Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Tue, 18 Mar 2025 23:46:49 +0000 Subject: [PATCH 581/675] Set mempool hw_decompress flag if driver supports it (#1854) If the driver supports the flag, unconditionally set the async memory pool usage property to include a request to support HW decompression. - Closes #1849 Authors: - Lawrence Mitchell (https://github.com/wence-) - Vyas Ramasubramani (https://github.com/vyasr) - Bradley Dice (https://github.com/bdice) Approvers: - Rong Ou (https://github.com/rongou) - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1854 --- conda/recipes/librmm/recipe.yaml | 6 ++ .../mr/device/cuda_async_memory_resource.hpp | 18 ++++- tests/CMakeLists.txt | 11 ++- tests/mr/device/hwdecompress_tests.cpp | 76 +++++++++++++++++++ 4 files changed, 107 insertions(+), 4 deletions(-) create mode 100644 tests/mr/device/hwdecompress_tests.cpp diff --git a/conda/recipes/librmm/recipe.yaml b/conda/recipes/librmm/recipe.yaml index c5b3ba8c4..3e0c40886 100644 --- a/conda/recipes/librmm/recipe.yaml +++ b/conda/recipes/librmm/recipe.yaml @@ -56,6 +56,8 @@ cache: - ${{ stdlib("c") }} host: - rapids-logger =0.1 + - if: cuda_major != "11" + then: cuda-driver-dev outputs: - package: @@ -100,12 +102,16 @@ outputs: script: cmake --install build --component testing dynamic_linking: overlinking_behavior: "error" + missing_dso_allowlist: + - "libcuda.so.1" requirements: build: - cmake ${{ cmake_version }} - ${{ stdlib("c") }} # this is here to help with overlinking errors against libm.so.6 and friends host: - ${{ pin_subpackage("librmm", exact=True) }} + - if: cuda_major != "11" + then: cuda-driver-dev - cuda-version =${{ cuda_version }} - if: cuda_major == "11" then: cudatoolkit diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 0a4d17afc..313ce3c71 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -64,6 +64,17 @@ class cuda_async_memory_resource final : public device_memory_resource { fabric = 0x8 ///< Allows a fabric handle to be used for exporting. (cudaMemFabricHandle_t) }; + /** + * @brief Flags for specifying memory pool usage. + * + * @note These values are exact copies from the runtime API. The only value so far is + * `cudaMemPoolCreateUsageHwDecompress` + */ + enum class mempool_usage : unsigned short { + hw_decompress = 0x2, ///< If set indicates that the memory can be used as a buffer for hardware + ///< accelerated decompression. + }; + /** * @brief Constructs a cuda_async_memory_resource with the optionally specified initial pool size * and release threshold. @@ -90,11 +101,16 @@ class cuda_async_memory_resource final : public device_memory_resource { RMM_EXPECTS(rmm::detail::runtime_async_alloc::is_supported(), "cudaMallocAsync not supported with this CUDA driver/runtime version"); + int driver_version{}; + RMM_CUDA_TRY(cudaDriverGetVersion(&driver_version)); // Construct explicit pool cudaMemPoolProps pool_props{}; pool_props.allocType = cudaMemAllocationTypePinned; pool_props.handleTypes = static_cast( export_handle_type.value_or(allocation_handle_type::none)); +#if defined(CUDART_VERSION) && CUDART_VERSION >= 12080 + pool_props.usage = static_cast(mempool_usage::hw_decompress); +#endif RMM_EXPECTS( rmm::detail::runtime_async_alloc::is_export_handle_type_supported(pool_props.handleTypes), "Requested IPC memory handle type not supported"); @@ -107,8 +123,6 @@ class cuda_async_memory_resource final : public device_memory_resource { // CUDA drivers before 11.5 have known incompatibilities with the async allocator. // We'll disable `cudaMemPoolReuseAllowOpportunistic` if cuda driver < 11.5. // See https://github.com/NVIDIA/spark-rapids/issues/4710. - int driver_version{}; - RMM_CUDA_TRY(cudaDriverGetVersion(&driver_version)); constexpr auto min_async_version{11050}; if (driver_version < min_async_version) { int disabled{0}; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9ff885c5a..b7a9e7133 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -84,7 +84,7 @@ endfunction() # stream function(ConfigureTest TEST_NAME) - set(options) + set(options OPTIONAL LINK_DRIVER) set(one_value CUDART GPUS PERCENT) set(multi_value) cmake_parse_arguments(_RMM_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN}) @@ -110,12 +110,17 @@ function(ConfigureTest TEST_NAME) # Test with legacy default stream. ConfigureTestInternal(${TEST_NAME} ${_RMM_TEST_UNPARSED_ARGUMENTS}) target_link_libraries(${TEST_NAME} PRIVATE ${cudart_link_libs}) - + if(_RMM_TEST_LINK_DRIVER) + target_link_libraries(${TEST_NAME} PRIVATE CUDA::cuda_driver) + endif() # Test with per-thread default stream. string(REGEX REPLACE "_TEST$" "_PTDS_TEST" PTDS_TEST_NAME "${TEST_NAME}") ConfigureTestInternal("${PTDS_TEST_NAME}" ${_RMM_TEST_UNPARSED_ARGUMENTS}) target_compile_definitions("${PTDS_TEST_NAME}" PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM) target_link_libraries(${PTDS_TEST_NAME} PRIVATE ${cudart_link_libs}) + if(_RMM_TEST_LINK_DRIVER) + target_link_libraries(${PTDS_TEST_NAME} PRIVATE CUDA::cuda_driver) + endif() foreach(name ${TEST_NAME} ${PTDS_TEST_NAME} ${NS_TEST_NAME}) rapids_test_add( @@ -140,6 +145,8 @@ ConfigureTest(ADAPTOR_TEST mr/device/adaptor_tests.cpp) # pool mr tests ConfigureTest(POOL_MR_TEST mr/device/pool_mr_tests.cpp GPUS 1 PERCENT 100) +ConfigureTest(HWDECOMPRESS_TEST mr/device/hwdecompress_tests.cpp LINK_DRIVER) + # cuda_async mr tests ConfigureTest(CUDA_ASYNC_MR_STATIC_CUDART_TEST mr/device/cuda_async_mr_tests.cpp GPUS 1 PERCENT 60 CUDART STATIC) diff --git a/tests/mr/device/hwdecompress_tests.cpp b/tests/mr/device/hwdecompress_tests.cpp new file mode 100644 index 000000000..4e3224841 --- /dev/null +++ b/tests/mr/device/hwdecompress_tests.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2025, 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. + */ + +#include +#include +#include + +#include +#include + +#include + +namespace rmm::test { +namespace { + +class HWDecompressTest : public ::testing::Test { + protected: + static void check_decompress_capable(void* ptr) + { + int driver_version{}; + RMM_CUDA_TRY(cudaDriverGetVersion(&driver_version)); + auto const min_hw_decompress_version{12080}; + if (driver_version >= min_hw_decompress_version) { +#if defined(CUDA_VERSION) && CUDA_VERSION >= 12080 + bool is_capable{}; + auto err = + cuPointerGetAttribute(static_cast(&is_capable), + CU_POINTER_ATTRIBUTE_IS_HW_DECOMPRESS_CAPABLE, + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) + reinterpret_cast(ptr)); + EXPECT_EQ(err, CUDA_SUCCESS); + EXPECT_TRUE(is_capable); +#endif + } + } +}; + +TEST_F(HWDecompressTest, CudaMalloc) +{ + const auto allocation_size{100}; + rmm::mr::cuda_memory_resource mr{}; + void* ptr = mr.allocate(allocation_size); + HWDecompressTest::check_decompress_capable(ptr); + mr.deallocate(ptr, allocation_size); + RMM_CUDA_TRY(cudaDeviceSynchronize()); +} + +TEST_F(HWDecompressTest, CudaMallocAsync) +{ + if (!rmm::detail::runtime_async_alloc::is_supported()) { + GTEST_SKIP() << "Skipping since cudaMallocAsync not supported with this CUDA " + << "driver/runtime version"; + } + const auto pool_init_size{100}; + rmm::mr::cuda_async_memory_resource mr{pool_init_size}; + void* ptr = mr.allocate(pool_init_size); + HWDecompressTest::check_decompress_capable(ptr); + mr.deallocate(ptr, pool_init_size); + RMM_CUDA_TRY(cudaDeviceSynchronize()); +} + +} // namespace +} // namespace rmm::test From c6773f2780b4c7dd463245dce4c6ea27799914dc Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Wed, 19 Mar 2025 16:40:08 +0000 Subject: [PATCH 582/675] Revert "Set mempool hw_decompress flag if driver supports it (#1854)" (#1873) This reverts commit 7f0cead1b9c6970687ce6ef84091d08471b913cd. - Closes #1872 Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1873 --- conda/recipes/librmm/recipe.yaml | 6 -- .../mr/device/cuda_async_memory_resource.hpp | 18 +---- tests/CMakeLists.txt | 11 +-- tests/mr/device/hwdecompress_tests.cpp | 76 ------------------- 4 files changed, 4 insertions(+), 107 deletions(-) delete mode 100644 tests/mr/device/hwdecompress_tests.cpp diff --git a/conda/recipes/librmm/recipe.yaml b/conda/recipes/librmm/recipe.yaml index 3e0c40886..c5b3ba8c4 100644 --- a/conda/recipes/librmm/recipe.yaml +++ b/conda/recipes/librmm/recipe.yaml @@ -56,8 +56,6 @@ cache: - ${{ stdlib("c") }} host: - rapids-logger =0.1 - - if: cuda_major != "11" - then: cuda-driver-dev outputs: - package: @@ -102,16 +100,12 @@ outputs: script: cmake --install build --component testing dynamic_linking: overlinking_behavior: "error" - missing_dso_allowlist: - - "libcuda.so.1" requirements: build: - cmake ${{ cmake_version }} - ${{ stdlib("c") }} # this is here to help with overlinking errors against libm.so.6 and friends host: - ${{ pin_subpackage("librmm", exact=True) }} - - if: cuda_major != "11" - then: cuda-driver-dev - cuda-version =${{ cuda_version }} - if: cuda_major == "11" then: cudatoolkit diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 313ce3c71..0a4d17afc 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -64,17 +64,6 @@ class cuda_async_memory_resource final : public device_memory_resource { fabric = 0x8 ///< Allows a fabric handle to be used for exporting. (cudaMemFabricHandle_t) }; - /** - * @brief Flags for specifying memory pool usage. - * - * @note These values are exact copies from the runtime API. The only value so far is - * `cudaMemPoolCreateUsageHwDecompress` - */ - enum class mempool_usage : unsigned short { - hw_decompress = 0x2, ///< If set indicates that the memory can be used as a buffer for hardware - ///< accelerated decompression. - }; - /** * @brief Constructs a cuda_async_memory_resource with the optionally specified initial pool size * and release threshold. @@ -101,16 +90,11 @@ class cuda_async_memory_resource final : public device_memory_resource { RMM_EXPECTS(rmm::detail::runtime_async_alloc::is_supported(), "cudaMallocAsync not supported with this CUDA driver/runtime version"); - int driver_version{}; - RMM_CUDA_TRY(cudaDriverGetVersion(&driver_version)); // Construct explicit pool cudaMemPoolProps pool_props{}; pool_props.allocType = cudaMemAllocationTypePinned; pool_props.handleTypes = static_cast( export_handle_type.value_or(allocation_handle_type::none)); -#if defined(CUDART_VERSION) && CUDART_VERSION >= 12080 - pool_props.usage = static_cast(mempool_usage::hw_decompress); -#endif RMM_EXPECTS( rmm::detail::runtime_async_alloc::is_export_handle_type_supported(pool_props.handleTypes), "Requested IPC memory handle type not supported"); @@ -123,6 +107,8 @@ class cuda_async_memory_resource final : public device_memory_resource { // CUDA drivers before 11.5 have known incompatibilities with the async allocator. // We'll disable `cudaMemPoolReuseAllowOpportunistic` if cuda driver < 11.5. // See https://github.com/NVIDIA/spark-rapids/issues/4710. + int driver_version{}; + RMM_CUDA_TRY(cudaDriverGetVersion(&driver_version)); constexpr auto min_async_version{11050}; if (driver_version < min_async_version) { int disabled{0}; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b7a9e7133..9ff885c5a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -84,7 +84,7 @@ endfunction() # stream function(ConfigureTest TEST_NAME) - set(options OPTIONAL LINK_DRIVER) + set(options) set(one_value CUDART GPUS PERCENT) set(multi_value) cmake_parse_arguments(_RMM_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN}) @@ -110,17 +110,12 @@ function(ConfigureTest TEST_NAME) # Test with legacy default stream. ConfigureTestInternal(${TEST_NAME} ${_RMM_TEST_UNPARSED_ARGUMENTS}) target_link_libraries(${TEST_NAME} PRIVATE ${cudart_link_libs}) - if(_RMM_TEST_LINK_DRIVER) - target_link_libraries(${TEST_NAME} PRIVATE CUDA::cuda_driver) - endif() + # Test with per-thread default stream. string(REGEX REPLACE "_TEST$" "_PTDS_TEST" PTDS_TEST_NAME "${TEST_NAME}") ConfigureTestInternal("${PTDS_TEST_NAME}" ${_RMM_TEST_UNPARSED_ARGUMENTS}) target_compile_definitions("${PTDS_TEST_NAME}" PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM) target_link_libraries(${PTDS_TEST_NAME} PRIVATE ${cudart_link_libs}) - if(_RMM_TEST_LINK_DRIVER) - target_link_libraries(${PTDS_TEST_NAME} PRIVATE CUDA::cuda_driver) - endif() foreach(name ${TEST_NAME} ${PTDS_TEST_NAME} ${NS_TEST_NAME}) rapids_test_add( @@ -145,8 +140,6 @@ ConfigureTest(ADAPTOR_TEST mr/device/adaptor_tests.cpp) # pool mr tests ConfigureTest(POOL_MR_TEST mr/device/pool_mr_tests.cpp GPUS 1 PERCENT 100) -ConfigureTest(HWDECOMPRESS_TEST mr/device/hwdecompress_tests.cpp LINK_DRIVER) - # cuda_async mr tests ConfigureTest(CUDA_ASYNC_MR_STATIC_CUDART_TEST mr/device/cuda_async_mr_tests.cpp GPUS 1 PERCENT 60 CUDART STATIC) diff --git a/tests/mr/device/hwdecompress_tests.cpp b/tests/mr/device/hwdecompress_tests.cpp deleted file mode 100644 index 4e3224841..000000000 --- a/tests/mr/device/hwdecompress_tests.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2025, 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. - */ - -#include -#include -#include - -#include -#include - -#include - -namespace rmm::test { -namespace { - -class HWDecompressTest : public ::testing::Test { - protected: - static void check_decompress_capable(void* ptr) - { - int driver_version{}; - RMM_CUDA_TRY(cudaDriverGetVersion(&driver_version)); - auto const min_hw_decompress_version{12080}; - if (driver_version >= min_hw_decompress_version) { -#if defined(CUDA_VERSION) && CUDA_VERSION >= 12080 - bool is_capable{}; - auto err = - cuPointerGetAttribute(static_cast(&is_capable), - CU_POINTER_ATTRIBUTE_IS_HW_DECOMPRESS_CAPABLE, - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) - reinterpret_cast(ptr)); - EXPECT_EQ(err, CUDA_SUCCESS); - EXPECT_TRUE(is_capable); -#endif - } - } -}; - -TEST_F(HWDecompressTest, CudaMalloc) -{ - const auto allocation_size{100}; - rmm::mr::cuda_memory_resource mr{}; - void* ptr = mr.allocate(allocation_size); - HWDecompressTest::check_decompress_capable(ptr); - mr.deallocate(ptr, allocation_size); - RMM_CUDA_TRY(cudaDeviceSynchronize()); -} - -TEST_F(HWDecompressTest, CudaMallocAsync) -{ - if (!rmm::detail::runtime_async_alloc::is_supported()) { - GTEST_SKIP() << "Skipping since cudaMallocAsync not supported with this CUDA " - << "driver/runtime version"; - } - const auto pool_init_size{100}; - rmm::mr::cuda_async_memory_resource mr{pool_init_size}; - void* ptr = mr.allocate(pool_init_size); - HWDecompressTest::check_decompress_capable(ptr); - mr.deallocate(ptr, pool_init_size); - RMM_CUDA_TRY(cudaDeviceSynchronize()); -} - -} // namespace -} // namespace rmm::test From ef8eca48008ff8239df9e628b1317f32ab7ee9de Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Fri, 21 Mar 2025 09:30:44 -0400 Subject: [PATCH 583/675] refactor(rattler): enable strict channel priority for builds (#1867) This PR enables strict channel priority for building conda packages with `rattler-build`. The other change is removing the `rapids-configure-conda-channels` call since `rattler-build` isn't influenced by `.condarc` files. xref rapidsai/build-planning#84 Authors: - Gil Forsyth (https://github.com/gforsyth) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1867 --- ci/build_cpp.sh | 3 --- ci/build_python.sh | 3 --- 2 files changed, 6 deletions(-) diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 3bac033f9..412d8d01d 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -3,8 +3,6 @@ set -euo pipefail -rapids-configure-conda-channels - source rapids-configure-sccache source rapids-date-string @@ -32,7 +30,6 @@ rapids-telemetry-record build.log rattler-build build \ --recipe conda/recipes/librmm \ --experimental \ --no-build-id \ - --channel-priority disabled \ --output-dir "$RAPIDS_CONDA_BLD_OUTPUT_DIR" \ "${RATTLER_CHANNELS[@]}" diff --git a/ci/build_python.sh b/ci/build_python.sh index c744e9422..92413ec67 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -3,8 +3,6 @@ set -euo pipefail -rapids-configure-conda-channels - source rapids-configure-sccache source rapids-date-string @@ -36,7 +34,6 @@ rapids-telemetry-record build.log rattler-build build \ --recipe conda/recipes/rmm \ --experimental \ --no-build-id \ - --channel-priority disabled \ --output-dir "$RAPIDS_CONDA_BLD_OUTPUT_DIR" \ -c "${CPP_CHANNEL}" \ "${RATTLER_CHANNELS[@]}" From 0835c54286475b0aa6db5f21e8afe5d6f0a0703d Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Mon, 31 Mar 2025 09:50:07 -0500 Subject: [PATCH 584/675] Fixed documentation example for `DeviceBuffer.to_device` (#1881) This fixes the example showing `rmm.DeviceBuffer.to_device` in the user guide by changing the dtype of the NumPy ndarray from `int8` to `uint8`. Closes #1879 Authors: - Tom Augspurger (https://github.com/TomAugspurger) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Matthew Murray (https://github.com/Matt711) URL: https://github.com/rapidsai/rmm/pull/1881 --- python/rmm/docs/guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/rmm/docs/guide.md b/python/rmm/docs/guide.md index 4b9d305ab..f55c06103 100644 --- a/python/rmm/docs/guide.md +++ b/python/rmm/docs/guide.md @@ -54,7 +54,7 @@ can be accessed via the `.size` and `.ptr` attributes respectively: >>> import rmm >>> import numpy as np >>> a = np.array([1, 2, 3], dtype='float64') ->>> buf = rmm.DeviceBuffer.to_device(a.view("int8")) # to_device expects an 8-bit type or `bytes` +>>> buf = rmm.DeviceBuffer.to_device(a.view("uint8")) # to_device expects an unsigned 8-bit dtype >>> buf.size 24 ``` From 7529f921a0bea3587e357be89d127797a4acea37 Mon Sep 17 00:00:00 2001 From: Jaya Venkatesh Date: Mon, 31 Mar 2025 10:41:26 -0700 Subject: [PATCH 585/675] Streamlining wheel builds to use fixed location and uploading build artifacts to Github (#1810) Exploring the usage of Github Artifact store in place of downloads.rapids.ai, see rapidsai/ops#2982 Authors: - Jaya Venkatesh (https://github.com/VenkateshJaya) - Gil Forsyth (https://github.com/gforsyth) - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1810 --- .github/workflows/build.yaml | 2 ++ .github/workflows/pr.yaml | 2 ++ ci/build_wheel_cpp.sh | 9 +++++---- ci/build_wheel_python.sh | 12 +++++++----- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a3506bf18..df620faae 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -89,6 +89,7 @@ jobs: sha: ${{ inputs.sha }} date: ${{ inputs.date }} script: ci/build_wheel_cpp.sh + package-type: cpp wheel-build-python: needs: [telemetry-setup, wheel-build-cpp] secrets: inherit @@ -99,6 +100,7 @@ jobs: sha: ${{ inputs.sha }} date: ${{ inputs.date }} script: ci/build_wheel_python.sh + package-type: python wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 1219279a6..0cf1a17e1 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -127,6 +127,7 @@ jobs: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request script: ci/build_wheel_cpp.sh + package-type: cpp wheel-build-python: needs: wheel-build-cpp secrets: inherit @@ -134,6 +135,7 @@ jobs: with: build_type: pull-request script: ci/build_wheel_python.sh + package-type: python wheel-tests: needs: [wheel-build-python, changed-files] secrets: inherit diff --git a/ci/build_wheel_cpp.sh b/ci/build_wheel_cpp.sh index bcbf91b05..db1989166 100755 --- a/ci/build_wheel_cpp.sh +++ b/ci/build_wheel_cpp.sh @@ -4,6 +4,7 @@ set -euo pipefail package_dir="python/librmm" +wheel_dir=${RAPIDS_WHEEL_BLD_OUTPUT_DIR} source rapids-configure-sccache source rapids-date-string @@ -19,12 +20,12 @@ sccache --zero-stats # Creates artifacts directory for telemetry source rapids-telemetry-setup -rapids-telemetry-record build.log rapids-pip-retry wheel . -w dist -v --no-deps --disable-pip-version-check +rapids-telemetry-record build.log rapids-pip-retry wheel . -w "${wheel_dir}" -v --no-deps --disable-pip-version-check rapids-telemetry-record sccache-stats.txt sccache --show-adv-stats -python -m wheel tags --platform any dist/* --remove +python -m wheel tags --platform any "${wheel_dir}"/* --remove -../../ci/validate_wheel.sh dist +../../ci/validate_wheel.sh "${wheel_dir}" -RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 cpp dist +RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 cpp "${wheel_dir}" diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index 7cffc045c..c1e91e2d4 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -6,6 +6,8 @@ set -euo pipefail package_name="rmm" package_dir="python/rmm" +wheel_dir=${RAPIDS_WHEEL_BLD_OUTPUT_DIR} + source rapids-configure-sccache source rapids-date-string @@ -32,16 +34,16 @@ PIP_CONSTRAINT="${PWD}/build-constraints.txt" \ rapids-telemetry-record sccache-stats.txt sccache --show-adv-stats -mkdir -p final_dist EXCLUDE_ARGS=( --exclude "librapids_logger.so" ) -python -m auditwheel repair "${EXCLUDE_ARGS[@]}" -w final_dist dist/* +python -m auditwheel repair "${EXCLUDE_ARGS[@]}" -w "${wheel_dir}" dist/* -../../ci/validate_wheel.sh final_dist +../../ci/validate_wheel.sh "${wheel_dir}" -RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 python final_dist +RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 python "${wheel_dir}" +absolute_wheel_dir=$(realpath "${wheel_dir}") # switch back to the root of the repo and check symbol visibility popd -ci/check_symbols.sh "$(echo ${package_dir}/final_dist/rmm_*.whl)" +ci/check_symbols.sh "$(echo ${absolute_wheel_dir}/rmm_*.whl)" From ee938a3781a1df4e93179f50415c829e5a4b39ef Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 7 Apr 2025 10:23:24 -0500 Subject: [PATCH 586/675] Fix logger macros (#1884) This was an oversight in #1808. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1884 --- benchmarks/CMakeLists.txt | 4 ++-- python/rmm/CMakeLists.txt | 2 +- tests/CMakeLists.txt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index adf24a969..bfddbc7d2 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -35,8 +35,8 @@ function(ConfigureBench BENCH_NAME) CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}" INSTALL_RPATH "\$ORIGIN/../../../lib") target_link_libraries(${BENCH_NAME} PRIVATE benchmark::benchmark pthread rmm) - target_compile_definitions(${BENCH_NAME} - PUBLIC "RMM_LOG_ACTIVE_LEVEL=RMM_LOG_LEVEL_${RMM_LOGGING_LEVEL}") + target_compile_definitions( + ${BENCH_NAME} PUBLIC "RMM_LOG_ACTIVE_LEVEL=RAPIDS_LOGGER_LOG_LEVEL_${RMM_LOGGING_LEVEL}") if(PER_THREAD_DEFAULT_STREAM) target_compile_definitions(${BENCH_NAME} PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM) diff --git a/python/rmm/CMakeLists.txt b/python/rmm/CMakeLists.txt index 5e36025b2..c0453fec1 100644 --- a/python/rmm/CMakeLists.txt +++ b/python/rmm/CMakeLists.txt @@ -27,7 +27,7 @@ include(rapids-cython-core) rapids_cython_init() # pass through logging level to spdlog -add_compile_definitions("RMM_LOG_ACTIVE_LEVEL=RMM_LOG_LEVEL_${RMM_LOGGING_LEVEL}") +add_compile_definitions("RMM_LOG_ACTIVE_LEVEL=RAPIDS_LOGGER_LOG_LEVEL_${RMM_LOGGING_LEVEL}") add_subdirectory(rmm/_cuda) add_subdirectory(rmm/librmm) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9ff885c5a..7e2dde93d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -40,8 +40,8 @@ function(ConfigureTestInternal TEST_NAME) CXX_STANDARD_REQUIRED ON CUDA_STANDARD 17 CUDA_STANDARD_REQUIRED ON) - target_compile_definitions(${TEST_NAME} - PUBLIC "RMM_LOG_ACTIVE_LEVEL=RMM_LOG_LEVEL_${RMM_LOGGING_LEVEL}") + target_compile_definitions( + ${TEST_NAME} PUBLIC "RMM_LOG_ACTIVE_LEVEL=RAPIDS_LOGGER_LOG_LEVEL_${RMM_LOGGING_LEVEL}") target_compile_options(${TEST_NAME} PUBLIC $<$:-Wall -Werror>) if(DISABLE_DEPRECATION_WARNING) From da3f558357033ee9b1caed70109453d9a35b9630 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 01:28:40 +0000 Subject: [PATCH 587/675] [pre-commit.ci] pre-commit autoupdate (#1885) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.6 → v0.11.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.6...v0.11.4) - [github.com/codespell-project/codespell: v2.3.0 → v2.4.1](https://github.com/codespell-project/codespell/compare/v2.3.0...v2.4.1) - [github.com/rapidsai/pre-commit-hooks: v0.4.0 → v0.6.0](https://github.com/rapidsai/pre-commit-hooks/compare/v0.4.0...v0.6.0) - [github.com/rapidsai/dependency-file-generator: v1.17.0 → v1.18.1](https://github.com/rapidsai/dependency-file-generator/compare/v1.17.0...v1.18.1) Authors: - https://github.com/apps/pre-commit-ci - Bradley Dice (https://github.com/bdice) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1885 --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index de2af6c40..9f6e06da0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.6 + rev: v0.11.4 hooks: - id: ruff args: ["--fix"] @@ -39,7 +39,7 @@ repos: ^benchmarks/utilities/cxxopts.hpp ) - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.1 hooks: - id: codespell additional_dependencies: [tomli] @@ -77,12 +77,12 @@ repos: pass_filenames: false verbose: true - repo: https://github.com/rapidsai/pre-commit-hooks - rev: v0.4.0 + rev: v0.6.0 hooks: - id: verify-copyright - id: verify-alpha-spec - repo: https://github.com/rapidsai/dependency-file-generator - rev: v1.17.0 + rev: v1.18.1 hooks: - id: rapids-dependency-file-generator args: ["--clean"] From 6c23695f25f9891cdac6c3d9a921d9bb4898c156 Mon Sep 17 00:00:00 2001 From: Jake Awe Date: Wed, 9 Apr 2025 09:13:04 -0700 Subject: [PATCH 588/675] Update Changelog [skip ci] --- CHANGELOG.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1df0eeeeb..3c8d9e1e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,63 @@ +# rmm 25.04.00 (9 Apr 2025) + +## 🚨 Breaking Changes + +- Add OOM fail reason, attempted allocation size to exception messages (retry) ([#1844](https://github.com/rapidsai/rmm/pull/1844)) [@pmattione-nvidia](https://github.com/pmattione-nvidia) +- Use new rapids-logger library ([#1808](https://github.com/rapidsai/rmm/pull/1808)) [@vyasr](https://github.com/vyasr) + +## 🐛 Bug Fixes + +- Revert "Set mempool hw_decompress flag if driver supports it ([#1854)" (#1873](https://github.com/rapidsai/rmm/pull/1854)" (#1873)) [@wence-](https://github.com/wence-) +- Fix run export on cudatoolkit ([#1862](https://github.com/rapidsai/rmm/pull/1862)) [@vyasr](https://github.com/vyasr) +- Fix dependencies.yaml for update-version.sh ([#1859](https://github.com/rapidsai/rmm/pull/1859)) [@raydouglass](https://github.com/raydouglass) +- Embed `__FILE__` as C-string for prefix replacement ([#1858](https://github.com/rapidsai/rmm/pull/1858)) [@jakirkham](https://github.com/jakirkham) +- Add OOM fail reason, attempted allocation size to exception messages (retry) ([#1844](https://github.com/rapidsai/rmm/pull/1844)) [@pmattione-nvidia](https://github.com/pmattione-nvidia) +- Revert "Add OOM fail reason, attempted allocation size to exception messages" ([#1843](https://github.com/rapidsai/rmm/pull/1843)) [@pmattione-nvidia](https://github.com/pmattione-nvidia) +- fix GITHUB_WORKSPACE not being present locally ([#1841](https://github.com/rapidsai/rmm/pull/1841)) [@msarahan](https://github.com/msarahan) +- Add telemetry setup to build workflows ([#1838](https://github.com/rapidsai/rmm/pull/1838)) [@bdice](https://github.com/bdice) +- Use static gbench ([#1837](https://github.com/rapidsai/rmm/pull/1837)) [@bdice](https://github.com/bdice) +- Fixes for rattler recipe ([#1835](https://github.com/rapidsai/rmm/pull/1835)) [@bdice](https://github.com/bdice) +- Depend on rapids-logger in host to prevent redistribution ([#1834](https://github.com/rapidsai/rmm/pull/1834)) [@bdice](https://github.com/bdice) +- Add OOM fail reason, attempted allocation size to exception messages ([#1827](https://github.com/rapidsai/rmm/pull/1827)) [@pmattione-nvidia](https://github.com/pmattione-nvidia) + +## 📖 Documentation + +- mr/host: fix incorrect docs usage of device_memory_resource ([#1809](https://github.com/rapidsai/rmm/pull/1809)) [@ghost](https://github.com/ghost) + +## 🚀 New Features + +- Add async view memory resource bindings to Python. ([#1864](https://github.com/rapidsai/rmm/pull/1864)) [@bdice](https://github.com/bdice) +- Run examples in CI ([#1850](https://github.com/rapidsai/rmm/pull/1850)) [@bdice](https://github.com/bdice) +- Add tests for RMM internal macros. ([#1847](https://github.com/rapidsai/rmm/pull/1847)) [@bdice](https://github.com/bdice) +- Add basic example. ([#1800](https://github.com/rapidsai/rmm/pull/1800)) [@bdice](https://github.com/bdice) + +## 🛠️ Improvements + +- Set mempool hw_decompress flag if driver supports it ([#1854](https://github.com/rapidsai/rmm/pull/1854)) [@wence-](https://github.com/wence-) +- Error if LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE is not defined. ([#1852](https://github.com/rapidsai/rmm/pull/1852)) [@bdice](https://github.com/bdice) +- Fix for -fdebug-prefix-map breaking sccache ([#1846](https://github.com/rapidsai/rmm/pull/1846)) [@bdice](https://github.com/bdice) +- fix(rattler): force `cuda_major` and `date_string` to be strings ([#1842](https://github.com/rapidsai/rmm/pull/1842)) [@gforsyth](https://github.com/gforsyth) +- use gha-tools rapids-telemetry-setup for mkdir -p ([#1839](https://github.com/rapidsai/rmm/pull/1839)) [@msarahan](https://github.com/msarahan) +- fix(rattler): resolve all overlinking errors ([#1836](https://github.com/rapidsai/rmm/pull/1836)) [@gforsyth](https://github.com/gforsyth) +- Update rattler-build recipe with assorted small fixes ([#1832](https://github.com/rapidsai/rmm/pull/1832)) [@gforsyth](https://github.com/gforsyth) +- Sccache stats telemetry ([#1830](https://github.com/rapidsai/rmm/pull/1830)) [@msarahan](https://github.com/msarahan) +- Consolidate more Conda solves in CI ([#1828](https://github.com/rapidsai/rmm/pull/1828)) [@KyleFromNVIDIA](https://github.com/KyleFromNVIDIA) +- Require CMake 3.30.4 ([#1826](https://github.com/rapidsai/rmm/pull/1826)) [@robertmaynard](https://github.com/robertmaynard) +- Create Conda CI test env in one step ([#1824](https://github.com/rapidsai/rmm/pull/1824)) [@KyleFromNVIDIA](https://github.com/KyleFromNVIDIA) +- Apply IWYU changes and fix deprecated GTest usage ([#1821](https://github.com/rapidsai/rmm/pull/1821)) [@bdice](https://github.com/bdice) +- Remove unnecessary index ([#1820](https://github.com/rapidsai/rmm/pull/1820)) [@vyasr](https://github.com/vyasr) +- Use shared-workflows branch-25.04 ([#1816](https://github.com/rapidsai/rmm/pull/1816)) [@bdice](https://github.com/bdice) +- Use `rapids-pip-retry` in CI jobs that might need retries ([#1814](https://github.com/rapidsai/rmm/pull/1814)) [@gforsyth](https://github.com/gforsyth) +- Use nightly matrix for branch tests. ([#1813](https://github.com/rapidsai/rmm/pull/1813)) [@bdice](https://github.com/bdice) +- Use build_type input ([#1812](https://github.com/rapidsai/rmm/pull/1812)) [@bdice](https://github.com/bdice) +- Add `build_type` to workflow inputs ([#1811](https://github.com/rapidsai/rmm/pull/1811)) [@gforsyth](https://github.com/gforsyth) +- Use new rapids-logger library ([#1808](https://github.com/rapidsai/rmm/pull/1808)) [@vyasr](https://github.com/vyasr) +- Forward-merge branch-25.02 to branch-25.04 ([#1806](https://github.com/rapidsai/rmm/pull/1806)) [@bdice](https://github.com/bdice) +- disallow fallback to Make in wheel builds ([#1804](https://github.com/rapidsai/rmm/pull/1804)) [@jameslamb](https://github.com/jameslamb) +- Migrate to NVKS for amd64 CI runners ([#1803](https://github.com/rapidsai/rmm/pull/1803)) [@bdice](https://github.com/bdice) +- Branch 25.04 merge branch 25.02 ([#1799](https://github.com/rapidsai/rmm/pull/1799)) [@vyasr](https://github.com/vyasr) +- Port to rattler-build ([#1796](https://github.com/rapidsai/rmm/pull/1796)) [@gforsyth](https://github.com/gforsyth) + # rmm 25.02.00 (13 Feb 2025) ## 🚨 Breaking Changes From 412d6a0df1e9434114ff265c961c4a56df3fdcbd Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 9 Apr 2025 11:26:09 -0500 Subject: [PATCH 589/675] Set mempool hw_decompress flag if driver supports it (#1875) If the driver supports the flag, unconditionally set the async memory pool usage property to include a request to support HW decompression. This was attempted in #1854 and reverted in #1873. This second attempt tries to fix a driver compatibility issue recorded in #1872. Closes #1872, closes #1849. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Rong Ou (https://github.com/rongou) - Lawrence Mitchell (https://github.com/wence-) - James Lamb (https://github.com/jameslamb) - Kyle Edwards (https://github.com/KyleFromNVIDIA) URL: https://github.com/rapidsai/rmm/pull/1875 --- conda/recipes/librmm/recipe.yaml | 6 ++ doxygen/Doxyfile | 5 +- include/rmm/detail/runtime_async_alloc.hpp | 30 +++++++ .../mr/device/cuda_async_memory_resource.hpp | 23 +++++- tests/CMakeLists.txt | 11 ++- tests/mr/device/hwdecompress_tests.cpp | 80 +++++++++++++++++++ 6 files changed, 150 insertions(+), 5 deletions(-) create mode 100644 tests/mr/device/hwdecompress_tests.cpp diff --git a/conda/recipes/librmm/recipe.yaml b/conda/recipes/librmm/recipe.yaml index c5b3ba8c4..3e0c40886 100644 --- a/conda/recipes/librmm/recipe.yaml +++ b/conda/recipes/librmm/recipe.yaml @@ -56,6 +56,8 @@ cache: - ${{ stdlib("c") }} host: - rapids-logger =0.1 + - if: cuda_major != "11" + then: cuda-driver-dev outputs: - package: @@ -100,12 +102,16 @@ outputs: script: cmake --install build --component testing dynamic_linking: overlinking_behavior: "error" + missing_dso_allowlist: + - "libcuda.so.1" requirements: build: - cmake ${{ cmake_version }} - ${{ stdlib("c") }} # this is here to help with overlinking errors against libm.so.6 and friends host: - ${{ pin_subpackage("librmm", exact=True) }} + - if: cuda_major != "11" + then: cuda-driver-dev - cuda-version =${{ cuda_version }} - if: cuda_major == "11" then: cudatoolkit diff --git a/doxygen/Doxyfile b/doxygen/Doxyfile index 5cc7accc1..82b151625 100644 --- a/doxygen/Doxyfile +++ b/doxygen/Doxyfile @@ -2180,7 +2180,10 @@ INCLUDE_FILE_PATTERNS = # Since we are excluding detail files in EXCLUDE_PATTERNS there # appears to be no way of getting doxygen to still parse that file and # make the definitions available via the preprocessor :( -PREDEFINED = RMM_EXPORT RMM_HIDDEN RMM_EXEC_CHECK_DISABLE RMM_NAMESPACE=rmm +PREDEFINED = RMM_EXEC_CHECK_DISABLE \ + RMM_EXPORT \ + RMM_HIDDEN \ + RMM_NAMESPACE=rmm # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/include/rmm/detail/runtime_async_alloc.hpp b/include/rmm/detail/runtime_async_alloc.hpp index 833d8659a..1b20e82dd 100644 --- a/include/rmm/detail/runtime_async_alloc.hpp +++ b/include/rmm/detail/runtime_async_alloc.hpp @@ -25,6 +25,11 @@ namespace RMM_NAMESPACE { namespace detail { +/** + * @brief Minimum CUDA driver version for hardware decompression support + */ +#define RMM_MIN_HWDECOMPRESS_CUDA_DRIVER_VERSION 12080 + /** * @brief Determine at runtime if the CUDA driver supports the stream-ordered * memory allocator functions. @@ -70,6 +75,31 @@ struct runtime_async_alloc { } return (supported_handle_types_bitmask & handle_type) == handle_type; } + + /** + * @brief Check whether `cudaMemPoolCreateUsageHwDecompress` is a supported + * pool property on the present CUDA driver version. + * + * Requires RMM to be built with a supported CUDA version 12.8+, otherwise + * this always returns false. + * + * @return true if supported + * @return false if unsupported + */ + static bool is_hwdecompress_supported() + { +#if defined(CUDA_VERSION) && CUDA_VERSION >= RMM_MIN_HWDECOMPRESS_CUDA_DRIVER_VERSION + // Check if hardware decompression is supported (requires CUDA 12.8 driver or higher) + static bool is_supported = []() { + int driver_version{}; + RMM_CUDA_TRY(cudaDriverGetVersion(&driver_version)); + return driver_version >= RMM_MIN_HWDECOMPRESS_CUDA_DRIVER_VERSION; + }(); + return is_supported; +#else + return false; +#endif + } }; } // namespace detail diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/include/rmm/mr/device/cuda_async_memory_resource.hpp index 0a4d17afc..cbccc3490 100644 --- a/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -64,6 +64,17 @@ class cuda_async_memory_resource final : public device_memory_resource { fabric = 0x8 ///< Allows a fabric handle to be used for exporting. (cudaMemFabricHandle_t) }; + /** + * @brief Flags for specifying memory pool usage. + * + * @note These values are exact copies from the runtime API. The only value so far is + * `cudaMemPoolCreateUsageHwDecompress` + */ + enum class mempool_usage : unsigned short { + hw_decompress = 0x2, ///< If set indicates that the memory can be used as a buffer for hardware + ///< accelerated decompression. + }; + /** * @brief Constructs a cuda_async_memory_resource with the optionally specified initial pool size * and release threshold. @@ -95,6 +106,14 @@ class cuda_async_memory_resource final : public device_memory_resource { pool_props.allocType = cudaMemAllocationTypePinned; pool_props.handleTypes = static_cast( export_handle_type.value_or(allocation_handle_type::none)); + +#if defined(CUDA_VERSION) && CUDA_VERSION >= RMM_MIN_HWDECOMPRESS_CUDA_DRIVER_VERSION + // Enable hardware decompression if supported (requires CUDA 12.8 driver or higher) + if (rmm::detail::runtime_async_alloc::is_hwdecompress_supported()) { + pool_props.usage = static_cast(mempool_usage::hw_decompress); + } +#endif + RMM_EXPECTS( rmm::detail::runtime_async_alloc::is_export_handle_type_supported(pool_props.handleTypes), "Requested IPC memory handle type not supported"); @@ -109,8 +128,8 @@ class cuda_async_memory_resource final : public device_memory_resource { // See https://github.com/NVIDIA/spark-rapids/issues/4710. int driver_version{}; RMM_CUDA_TRY(cudaDriverGetVersion(&driver_version)); - constexpr auto min_async_version{11050}; - if (driver_version < min_async_version) { + constexpr auto min_async_driver_version{11050}; + if (driver_version < min_async_driver_version) { int disabled{0}; RMM_CUDA_TRY( cudaMemPoolSetAttribute(pool_handle(), cudaMemPoolReuseAllowOpportunistic, &disabled)); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7e2dde93d..056253d92 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -84,7 +84,7 @@ endfunction() # stream function(ConfigureTest TEST_NAME) - set(options) + set(options LINK_DRIVER) set(one_value CUDART GPUS PERCENT) set(multi_value) cmake_parse_arguments(_RMM_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN}) @@ -110,12 +110,17 @@ function(ConfigureTest TEST_NAME) # Test with legacy default stream. ConfigureTestInternal(${TEST_NAME} ${_RMM_TEST_UNPARSED_ARGUMENTS}) target_link_libraries(${TEST_NAME} PRIVATE ${cudart_link_libs}) - + if(_RMM_TEST_LINK_DRIVER) + target_link_libraries(${TEST_NAME} PRIVATE CUDA::cuda_driver) + endif() # Test with per-thread default stream. string(REGEX REPLACE "_TEST$" "_PTDS_TEST" PTDS_TEST_NAME "${TEST_NAME}") ConfigureTestInternal("${PTDS_TEST_NAME}" ${_RMM_TEST_UNPARSED_ARGUMENTS}) target_compile_definitions("${PTDS_TEST_NAME}" PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM) target_link_libraries(${PTDS_TEST_NAME} PRIVATE ${cudart_link_libs}) + if(_RMM_TEST_LINK_DRIVER) + target_link_libraries(${PTDS_TEST_NAME} PRIVATE CUDA::cuda_driver) + endif() foreach(name ${TEST_NAME} ${PTDS_TEST_NAME} ${NS_TEST_NAME}) rapids_test_add( @@ -140,6 +145,8 @@ ConfigureTest(ADAPTOR_TEST mr/device/adaptor_tests.cpp) # pool mr tests ConfigureTest(POOL_MR_TEST mr/device/pool_mr_tests.cpp GPUS 1 PERCENT 100) +ConfigureTest(HWDECOMPRESS_TEST mr/device/hwdecompress_tests.cpp LINK_DRIVER) + # cuda_async mr tests ConfigureTest(CUDA_ASYNC_MR_STATIC_CUDART_TEST mr/device/cuda_async_mr_tests.cpp GPUS 1 PERCENT 60 CUDART STATIC) diff --git a/tests/mr/device/hwdecompress_tests.cpp b/tests/mr/device/hwdecompress_tests.cpp new file mode 100644 index 000000000..882be11c2 --- /dev/null +++ b/tests/mr/device/hwdecompress_tests.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2025, 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. + */ + +#include +#include +#include +#include + +#include +#include + +#include + +namespace rmm::test { +namespace { + +class HWDecompressTest : public ::testing::Test { + protected: + static void check_decompress_capable(void* ptr) + { +#if defined(CUDA_VERSION) && CUDA_VERSION >= RMM_MIN_HWDECOMPRESS_CUDA_DRIVER_VERSION + if (rmm::detail::runtime_async_alloc::is_hwdecompress_supported()) { + bool is_capable{}; + auto err = + cuPointerGetAttribute(static_cast(&is_capable), + CU_POINTER_ATTRIBUTE_IS_HW_DECOMPRESS_CAPABLE, + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) + reinterpret_cast(ptr)); + EXPECT_EQ(err, CUDA_SUCCESS); + EXPECT_TRUE(is_capable); + } else { + GTEST_SKIP() << "Skipping since hardware decompression is not supported " + << "by the current CUDA driver."; + } +#else + GTEST_SKIP() << "Skipping since hardware decompression is not supported " + << "by the CUDA version used to build RMM."; +#endif + } +}; + +TEST_F(HWDecompressTest, CudaMalloc) +{ + const auto allocation_size{100}; + rmm::mr::cuda_memory_resource mr{}; + void* ptr = mr.allocate(allocation_size); + HWDecompressTest::check_decompress_capable(ptr); + mr.deallocate(ptr, allocation_size); + RMM_CUDA_TRY(cudaDeviceSynchronize()); +} + +TEST_F(HWDecompressTest, CudaMallocAsync) +{ + if (!rmm::detail::runtime_async_alloc::is_supported()) { + GTEST_SKIP() << "Skipping since cudaMallocAsync not supported with this CUDA " + << "driver/runtime version"; + } + const auto pool_init_size{100}; + rmm::mr::cuda_async_memory_resource mr{pool_init_size}; + void* ptr = mr.allocate(pool_init_size); + HWDecompressTest::check_decompress_capable(ptr); + mr.deallocate(ptr, pool_init_size); + RMM_CUDA_TRY(cudaDeviceSynchronize()); +} + +} // namespace +} // namespace rmm::test From 82c32882985141f0ef5bad06b0535fdeb28d654c Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 10 Apr 2025 11:33:17 -0500 Subject: [PATCH 590/675] Add ARM conda environments (#1889) This PR adds ARM conda environments. xref: https://github.com/rapidsai/build-planning/issues/87 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1889 --- .../all_cuda-118_arch-aarch64.yaml | 43 +++++++++++++++++++ .../all_cuda-128_arch-aarch64.yaml | 42 ++++++++++++++++++ dependencies.yaml | 2 +- 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 conda/environments/all_cuda-118_arch-aarch64.yaml create mode 100644 conda/environments/all_cuda-128_arch-aarch64.yaml diff --git a/conda/environments/all_cuda-118_arch-aarch64.yaml b/conda/environments/all_cuda-118_arch-aarch64.yaml new file mode 100644 index 000000000..d0a88b0f5 --- /dev/null +++ b/conda/environments/all_cuda-118_arch-aarch64.yaml @@ -0,0 +1,43 @@ +# This file is generated by `rapids-dependency-file-generator`. +# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. +channels: +- rapidsai +- rapidsai-nightly +- conda-forge +dependencies: +- breathe>=4.35.0 +- c-compiler +- clang-tools==16.0.6 +- clang==16.0.6 +- cmake>=3.30.4 +- cuda-python>=11.8.5,<12.0a0 +- cuda-version=11.8 +- cudatoolkit +- cxx-compiler +- cython>=3.0.0 +- doxygen=1.9.1 +- gcc_linux-aarch64=11.* +- gcovr>=5.0 +- graphviz +- identify>=2.5.20 +- ipython +- make +- nbsphinx +- ninja +- numba>=0.59.1,<0.61.0a0 +- numpy>=1.23,<3.0a0 +- numpydoc +- nvcc_linux-aarch64=11.8 +- pre-commit +- pytest +- pytest-cov +- python>=3.10,<3.13 +- rapids-build-backend>=0.3.0,<0.4.0.dev0 +- rapids-logger==0.1.*,>=0.0.0a0 +- scikit-build-core >=0.10.0 +- sphinx-copybutton +- sphinx-markdown-tables +- sphinx<8.2.0 +- sphinx_rtd_theme +- sysroot_linux-aarch64==2.28 +name: all_cuda-118_arch-aarch64 diff --git a/conda/environments/all_cuda-128_arch-aarch64.yaml b/conda/environments/all_cuda-128_arch-aarch64.yaml new file mode 100644 index 000000000..c8d667d22 --- /dev/null +++ b/conda/environments/all_cuda-128_arch-aarch64.yaml @@ -0,0 +1,42 @@ +# This file is generated by `rapids-dependency-file-generator`. +# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. +channels: +- rapidsai +- rapidsai-nightly +- conda-forge +dependencies: +- breathe>=4.35.0 +- c-compiler +- clang-tools==16.0.6 +- clang==16.0.6 +- cmake>=3.30.4 +- cuda-nvcc +- cuda-python>=12.6.2,<13.0a0 +- cuda-version=12.8 +- cxx-compiler +- cython>=3.0.0 +- doxygen=1.9.1 +- gcc_linux-aarch64=13.* +- gcovr>=5.0 +- graphviz +- identify>=2.5.20 +- ipython +- make +- nbsphinx +- ninja +- numba>=0.59.1,<0.61.0a0 +- numpy>=1.23,<3.0a0 +- numpydoc +- pre-commit +- pytest +- pytest-cov +- python>=3.10,<3.13 +- rapids-build-backend>=0.3.0,<0.4.0.dev0 +- rapids-logger==0.1.*,>=0.0.0a0 +- scikit-build-core >=0.10.0 +- sphinx-copybutton +- sphinx-markdown-tables +- sphinx<8.2.0 +- sphinx_rtd_theme +- sysroot_linux-aarch64==2.28 +name: all_cuda-128_arch-aarch64 diff --git a/dependencies.yaml b/dependencies.yaml index 809773143..031cc0022 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -4,7 +4,7 @@ files: output: conda matrix: cuda: ["11.8", "12.8"] - arch: [x86_64] + arch: [x86_64, aarch64] includes: - build - cython_build From 9a9bc1df861d449c3f88d8f4505b126d594b50b8 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 10 Apr 2025 11:58:09 -0500 Subject: [PATCH 591/675] Vendor RAPIDS.cmake to avoid network call. (#1886) This works around a problem where GitHub is rejecting requests to the `githubusercontent.com` CDN. We vendor the contents of `RAPIDS.cmake` from `rapidsai/rapids-cmake` to avoid a network call. xref: https://github.com/rapidsai/rapids-cmake/pull/809 xref: https://github.com/rapidsai/build-infra/issues/206 Original motivation for `RAPIDS.cmake`: https://github.com/rapidsai/rapids-cmake/pull/45 The main design question raised by this PR is whether we still need this layer of indirection, or if inlining is acceptable (more lines of code, no centralized logic, but the contents of `RAPIDS.cmake` have been quite stable). Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Peter Andreas Entschev (https://github.com/pentschev) - Kyle Edwards (https://github.com/KyleFromNVIDIA) URL: https://github.com/rapidsai/rmm/pull/1886 --- CMakeLists.txt | 2 +- cmake/RAPIDS.cmake | 89 +++++++++++++++++++ .../rapids_config.cmake | 13 +-- python/librmm/CMakeLists.txt | 2 +- python/rmm/CMakeLists.txt | 2 +- 5 files changed, 96 insertions(+), 12 deletions(-) create mode 100644 cmake/RAPIDS.cmake rename rapids_config.cmake => cmake/rapids_config.cmake (72%) diff --git a/CMakeLists.txt b/CMakeLists.txt index f97e3c5a1..f33b77d4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR) -include(rapids_config.cmake) +include(cmake/rapids_config.cmake) include(rapids-cmake) include(rapids-cpm) diff --git a/cmake/RAPIDS.cmake b/cmake/RAPIDS.cmake new file mode 100644 index 000000000..8f049156d --- /dev/null +++ b/cmake/RAPIDS.cmake @@ -0,0 +1,89 @@ +# ============================================================================= +# Copyright (c) 2021-2025, 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. +# ============================================================================= +# +# This is the preferred entry point for projects using rapids-cmake +# +# Enforce the minimum required CMake version for all users +cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR) + +# Allow users to control which version is used +if(NOT rapids-cmake-version OR NOT rapids-cmake-version MATCHES [[^([0-9][0-9])\.([0-9][0-9])$]]) + message( + FATAL_ERROR "The CMake variable rapids-cmake-version must be defined in the format MAJOR.MINOR." + ) +endif() + +# Allow users to control which GitHub repo is fetched +if(NOT rapids-cmake-repo) + # Define a default repo if the user doesn't set one + set(rapids-cmake-repo rapidsai/rapids-cmake) +endif() + +# Allow users to control which branch is fetched +if(NOT rapids-cmake-branch) + # Define a default branch if the user doesn't set one + set(rapids-cmake-branch "branch-${rapids-cmake-version}") +endif() + +# Allow users to control the exact URL passed to FetchContent +if(NOT rapids-cmake-url) + # Construct a default URL if the user doesn't set one + set(rapids-cmake-url "https://github.com/${rapids-cmake-repo}/") + + # In order of specificity + if(rapids-cmake-fetch-via-git) + if(rapids-cmake-sha) + # An exact git SHA takes precedence over anything + set(rapids-cmake-value-to-clone "${rapids-cmake-sha}") + elseif(rapids-cmake-tag) + # Followed by a git tag name + set(rapids-cmake-value-to-clone "${rapids-cmake-tag}") + else() + # Or if neither of the above two were defined, use a branch + set(rapids-cmake-value-to-clone "${rapids-cmake-branch}") + endif() + else() + if(rapids-cmake-sha) + # An exact git SHA takes precedence over anything + set(rapids-cmake-value-to-clone "archive/${rapids-cmake-sha}.zip") + elseif(rapids-cmake-tag) + # Followed by a git tag name + set(rapids-cmake-value-to-clone "archive/refs/tags/${rapids-cmake-tag}.zip") + else() + # Or if neither of the above two were defined, use a branch + set(rapids-cmake-value-to-clone "archive/refs/heads/${rapids-cmake-branch}.zip") + endif() + endif() +endif() + +include(FetchContent) +if(rapids-cmake-fetch-via-git) + FetchContent_Declare( + rapids-cmake + GIT_REPOSITORY "${rapids-cmake-url}" + GIT_TAG "${rapids-cmake-value-to-clone}") +else() + string(APPEND rapids-cmake-url "${rapids-cmake-value-to-clone}") + FetchContent_Declare(rapids-cmake URL "${rapids-cmake-url}") +endif() +FetchContent_GetProperties(rapids-cmake) +if(rapids-cmake_POPULATED) + # Something else has already populated rapids-cmake, only thing we need to do is setup the + # CMAKE_MODULE_PATH + if(NOT "${rapids-cmake-dir}" IN_LIST CMAKE_MODULE_PATH) + list(APPEND CMAKE_MODULE_PATH "${rapids-cmake-dir}") + endif() +else() + FetchContent_MakeAvailable(rapids-cmake) +endif() diff --git a/rapids_config.cmake b/cmake/rapids_config.cmake similarity index 72% rename from rapids_config.cmake rename to cmake/rapids_config.cmake index 84c20c01e..5aa8e5501 100644 --- a/rapids_config.cmake +++ b/cmake/rapids_config.cmake @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2018-2024, NVIDIA CORPORATION. +# Copyright (c) 2018-2025, 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,7 +11,7 @@ # or implied. See the License for the specific language governing permissions and limitations under # the License. # ============================================================================= -file(READ "${CMAKE_CURRENT_LIST_DIR}/VERSION" _rapids_version) +file(READ "${CMAKE_CURRENT_LIST_DIR}/../VERSION" _rapids_version) if(_rapids_version MATCHES [[^([0-9][0-9])\.([0-9][0-9])\.([0-9][0-9])]]) set(RAPIDS_VERSION_MAJOR "${CMAKE_MATCH_1}") set(RAPIDS_VERSION_MINOR "${CMAKE_MATCH_2}") @@ -25,10 +25,5 @@ else() "Could not determine RAPIDS version. Contents of VERSION file:\n${_rapids_version_formatted}") endif() -if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake") - file( - DOWNLOAD - "https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${RAPIDS_VERSION_MAJOR_MINOR}/RAPIDS.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake") -endif() -include("${CMAKE_CURRENT_BINARY_DIR}/RMM_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake") +set(rapids-cmake-version "${RAPIDS_VERSION_MAJOR_MINOR}") +include("${CMAKE_CURRENT_LIST_DIR}/RAPIDS.cmake") diff --git a/python/librmm/CMakeLists.txt b/python/librmm/CMakeLists.txt index 322215833..5d25750a9 100644 --- a/python/librmm/CMakeLists.txt +++ b/python/librmm/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR) -include(../../rapids_config.cmake) +include(../../cmake/rapids_config.cmake) project( librmm-python diff --git a/python/rmm/CMakeLists.txt b/python/rmm/CMakeLists.txt index c0453fec1..8fb4d9fd3 100644 --- a/python/rmm/CMakeLists.txt +++ b/python/rmm/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR) -include(../../rapids_config.cmake) +include(../../cmake/rapids_config.cmake) project( rmm-python From 8bae350eab03ce15b53ff177605eda85049287bd Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 11 Apr 2025 13:30:52 -0500 Subject: [PATCH 592/675] Auto-sync draft PRs (#1890) Currently draft PRs require `/ok to test`. There is a new requirement that this also needs a hash. Since RMM CI is very fast and there aren't very many developers, I would appreciate having lower friction for working on draft PRs and getting CI feedback before opening for review. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Kyle Edwards (https://github.com/KyleFromNVIDIA) URL: https://github.com/rapidsai/rmm/pull/1890 --- .github/copy-pr-bot.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/copy-pr-bot.yaml b/.github/copy-pr-bot.yaml index e0ea775aa..7052b1a7c 100644 --- a/.github/copy-pr-bot.yaml +++ b/.github/copy-pr-bot.yaml @@ -2,4 +2,4 @@ # https://docs.gha-runners.nvidia.com/apps/copy-pr-bot/ enabled: true -auto_sync_draft: false +auto_sync_draft: true From a828642553fd72610f1361240b3473bb72a46d51 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 15 Apr 2025 16:18:05 -0500 Subject: [PATCH 593/675] Move RMM C++ code into cpp directory. (#1883) Restructures RMM to use a `cpp/` directory like most RAPIDS repos. Closes #1877. https://github.com/rapidsai/devcontainers/pull/490 should be merged just before this PR. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Rong Ou (https://github.com/rongou) - Mark Harris (https://github.com/harrism) - Matthew Murray (https://github.com/Matt711) - Kyle Edwards (https://github.com/KyleFromNVIDIA) URL: https://github.com/rapidsai/rmm/pull/1883 --- .github/workflows/pr.yaml | 1 + .gitignore | 4 ++-- .pre-commit-config.yaml | 12 ++++++------ build.sh | 6 +++--- ci/build_cpp.sh | 2 +- ci/build_docs.sh | 2 +- ci/release/update-version.sh | 2 +- conda/recipes/librmm/recipe.yaml | 6 +++--- .clang-tidy => cpp/.clang-tidy | 0 .clangd => cpp/.clangd | 0 CMakeLists.txt => cpp/CMakeLists.txt | 2 +- {benchmarks => cpp/benchmarks}/CMakeLists.txt | 0 .../cuda_stream_pool/cuda_stream_pool_bench.cpp | 0 .../device_uvector/device_uvector_bench.cu | 0 .../multi_stream_allocations_bench.cu | 0 .../random_allocations/random_allocations.cpp | 0 {benchmarks => cpp/benchmarks}/replay/replay.cpp | 0 .../benchmarks}/synchronization/synchronization.cpp | 0 .../benchmarks}/synchronization/synchronization.hpp | 0 {benchmarks => cpp/benchmarks}/utilities/cxxopts.hpp | 0 .../benchmarks}/utilities/log_parser.hpp | 0 {benchmarks => cpp/benchmarks}/utilities/rapidcsv.h | 0 .../utilities/simulated_memory_resource.hpp | 0 {cmake => cpp/cmake}/config.json | 0 {cmake => cpp/cmake}/thirdparty/get_cccl.cmake | 0 {cmake => cpp/cmake}/thirdparty/get_nvtx.cmake | 0 {doxygen => cpp/doxygen}/Doxyfile | 0 {doxygen => cpp/doxygen}/header.html | 0 {doxygen => cpp/doxygen}/main_page.md | 0 {examples => cpp/examples}/README.md | 0 {examples => cpp/examples}/basic/CMakeLists.txt | 0 {examples => cpp/examples}/basic/README.md | 0 {examples => cpp/examples}/basic/src/basic.cpp | 0 {examples => cpp/examples}/build.sh | 0 {examples => cpp/examples}/fetch_dependencies.cmake | 0 .../examples}/set_cuda_architecture.cmake | 7 +------ {examples => cpp/examples}/versions.cmake | 0 gcovr.cfg => cpp/gcovr.cfg | 0 {include => cpp/include}/doxygen_groups.h | 0 {include => cpp/include}/rmm/aligned.hpp | 0 {include => cpp/include}/rmm/cuda_device.hpp | 0 {include => cpp/include}/rmm/cuda_stream.hpp | 0 {include => cpp/include}/rmm/cuda_stream_pool.hpp | 0 {include => cpp/include}/rmm/cuda_stream_view.hpp | 0 {include => cpp/include}/rmm/detail/aligned.hpp | 0 .../include}/rmm/detail/cuda_memory_resource.hpp | 0 {include => cpp/include}/rmm/detail/error.hpp | 0 .../include}/rmm/detail/exec_check_disable.hpp | 0 {include => cpp/include}/rmm/detail/export.hpp | 0 {include => cpp/include}/rmm/detail/format.hpp | 0 .../include}/rmm/detail/logging_assert.hpp | 0 {include => cpp/include}/rmm/detail/nvtx/ranges.hpp | 0 .../include}/rmm/detail/runtime_async_alloc.hpp | 0 {include => cpp/include}/rmm/detail/stack_trace.hpp | 0 .../include}/rmm/detail/thrust_namespace.h | 0 {include => cpp/include}/rmm/device_buffer.hpp | 0 {include => cpp/include}/rmm/device_scalar.hpp | 0 {include => cpp/include}/rmm/device_uvector.hpp | 0 {include => cpp/include}/rmm/device_vector.hpp | 0 {include => cpp/include}/rmm/error.hpp | 0 {include => cpp/include}/rmm/exec_policy.hpp | 0 {include => cpp/include}/rmm/logger.hpp | 0 .../rmm/mr/device/aligned_resource_adaptor.hpp | 0 .../include}/rmm/mr/device/arena_memory_resource.hpp | 0 .../rmm/mr/device/binning_memory_resource.hpp | 0 .../rmm/mr/device/callback_memory_resource.hpp | 0 .../rmm/mr/device/cuda_async_memory_resource.hpp | 0 .../mr/device/cuda_async_view_memory_resource.hpp | 0 .../include}/rmm/mr/device/cuda_memory_resource.hpp | 0 .../include}/rmm/mr/device/detail/arena.hpp | 0 .../rmm/mr/device/detail/coalescing_free_list.hpp | 0 .../rmm/mr/device/detail/fixed_size_free_list.hpp | 0 .../include}/rmm/mr/device/detail/free_list.hpp | 0 .../device/detail/stream_ordered_memory_resource.hpp | 0 .../rmm/mr/device/device_memory_resource.hpp | 0 .../mr/device/failure_callback_resource_adaptor.hpp | 0 .../rmm/mr/device/fixed_size_memory_resource.hpp | 0 .../rmm/mr/device/limiting_resource_adaptor.hpp | 0 .../rmm/mr/device/logging_resource_adaptor.hpp | 0 .../rmm/mr/device/managed_memory_resource.hpp | 0 .../include}/rmm/mr/device/owning_wrapper.hpp | 0 .../include}/rmm/mr/device/per_device_resource.hpp | 0 .../include}/rmm/mr/device/polymorphic_allocator.hpp | 0 .../include}/rmm/mr/device/pool_memory_resource.hpp | 0 .../rmm/mr/device/prefetch_resource_adaptor.hpp | 0 .../rmm/mr/device/sam_headroom_memory_resource.hpp | 0 .../rmm/mr/device/statistics_resource_adaptor.hpp | 0 .../rmm/mr/device/system_memory_resource.hpp | 0 .../rmm/mr/device/thread_safe_resource_adaptor.hpp | 0 .../rmm/mr/device/thrust_allocator_adaptor.hpp | 0 .../rmm/mr/device/tracking_resource_adaptor.hpp | 0 .../include}/rmm/mr/host/host_memory_resource.hpp | 0 .../include}/rmm/mr/host/new_delete_resource.hpp | 0 .../include}/rmm/mr/host/pinned_memory_resource.hpp | 0 .../include}/rmm/mr/is_resource_adaptor.hpp | 0 .../include}/rmm/mr/pinned_host_memory_resource.hpp | 0 {include => cpp/include}/rmm/prefetch.hpp | 0 {include => cpp/include}/rmm/resource_ref.hpp | 0 {scripts => cpp/scripts}/doxygen.sh | 4 ++-- {scripts => cpp/scripts}/gdb-pretty-printers.py | 0 {scripts => cpp/scripts}/load-pretty-printers.in | 0 {scripts => cpp/scripts}/run-cmake-format.sh | 8 ++++---- {tests => cpp/tests}/CMakeLists.txt | 0 {tests => cpp/tests}/byte_literals.hpp | 0 {tests => cpp/tests}/container_multidevice_tests.cu | 0 {tests => cpp/tests}/cuda_stream_pool_tests.cpp | 0 {tests => cpp/tests}/cuda_stream_tests.cpp | 0 {tests => cpp/tests}/device_buffer_tests.cu | 0 .../tests}/device_check_resource_adaptor.hpp | 0 {tests => cpp/tests}/device_scalar_tests.cpp | 0 {tests => cpp/tests}/device_uvector_tests.cpp | 0 {tests => cpp/tests}/error_macros_tests.cpp | 0 {tests => cpp/tests}/libcudacxx_flag_test/README.md | 0 .../libcudacxx_flag_test/libcudacxx_flag_test.cpp | 0 .../libcudacxx_flag_test/libcudacxx_flag_test.sh | 0 {tests => cpp/tests}/logger_tests.cpp | 0 {tests => cpp/tests}/mock_resource.hpp | 0 {tests => cpp/tests}/mr/device/adaptor_tests.cpp | 0 {tests => cpp/tests}/mr/device/aligned_mr_tests.cpp | 0 {tests => cpp/tests}/mr/device/arena_mr_tests.cpp | 0 {tests => cpp/tests}/mr/device/binning_mr_tests.cpp | 0 {tests => cpp/tests}/mr/device/callback_mr_tests.cpp | 0 .../tests}/mr/device/cuda_async_mr_tests.cpp | 0 .../tests}/mr/device/cuda_async_view_mr_tests.cpp | 0 .../tests}/mr/device/failure_callback_mr_tests.cpp | 0 .../tests}/mr/device/hwdecompress_tests.cpp | 0 {tests => cpp/tests}/mr/device/limiting_mr_tests.cpp | 0 .../tests}/mr/device/mr_ref_multithreaded_tests.cpp | 0 {tests => cpp/tests}/mr/device/mr_ref_test.hpp | 0 {tests => cpp/tests}/mr/device/mr_ref_tests.cpp | 0 .../tests}/mr/device/polymorphic_allocator_tests.cpp | 0 {tests => cpp/tests}/mr/device/pool_mr_tests.cpp | 0 .../mr/device/prefetch_resource_adaptor_tests.cpp | 0 .../tests}/mr/device/statistics_mr_tests.cpp | 0 .../mr/device/stream_allocator_adaptor_tests.cpp | 0 {tests => cpp/tests}/mr/device/system_mr_tests.cu | 0 {tests => cpp/tests}/mr/device/test_utils.hpp | 0 .../tests}/mr/device/thrust_allocator_tests.cu | 0 {tests => cpp/tests}/mr/device/tracking_mr_tests.cpp | 0 {tests => cpp/tests}/mr/host/mr_ref_tests.cpp | 0 .../tests}/mr/host/pinned_pool_mr_tests.cpp | 0 {tests => cpp/tests}/prefetch_tests.cpp | 0 pyproject.toml | 4 ++-- python/librmm/CMakeLists.txt | 2 +- python/rmm/docs/conf.py | 2 +- 145 files changed, 30 insertions(+), 34 deletions(-) rename .clang-tidy => cpp/.clang-tidy (100%) rename .clangd => cpp/.clangd (100%) rename CMakeLists.txt => cpp/CMakeLists.txt (99%) rename {benchmarks => cpp/benchmarks}/CMakeLists.txt (100%) rename {benchmarks => cpp/benchmarks}/cuda_stream_pool/cuda_stream_pool_bench.cpp (100%) rename {benchmarks => cpp/benchmarks}/device_uvector/device_uvector_bench.cu (100%) rename {benchmarks => cpp/benchmarks}/multi_stream_allocations/multi_stream_allocations_bench.cu (100%) rename {benchmarks => cpp/benchmarks}/random_allocations/random_allocations.cpp (100%) rename {benchmarks => cpp/benchmarks}/replay/replay.cpp (100%) rename {benchmarks => cpp/benchmarks}/synchronization/synchronization.cpp (100%) rename {benchmarks => cpp/benchmarks}/synchronization/synchronization.hpp (100%) rename {benchmarks => cpp/benchmarks}/utilities/cxxopts.hpp (100%) rename {benchmarks => cpp/benchmarks}/utilities/log_parser.hpp (100%) rename {benchmarks => cpp/benchmarks}/utilities/rapidcsv.h (100%) rename {benchmarks => cpp/benchmarks}/utilities/simulated_memory_resource.hpp (100%) rename {cmake => cpp/cmake}/config.json (100%) rename {cmake => cpp/cmake}/thirdparty/get_cccl.cmake (100%) rename {cmake => cpp/cmake}/thirdparty/get_nvtx.cmake (100%) rename {doxygen => cpp/doxygen}/Doxyfile (100%) rename {doxygen => cpp/doxygen}/header.html (100%) rename {doxygen => cpp/doxygen}/main_page.md (100%) rename {examples => cpp/examples}/README.md (100%) rename {examples => cpp/examples}/basic/CMakeLists.txt (100%) rename {examples => cpp/examples}/basic/README.md (100%) rename {examples => cpp/examples}/basic/src/basic.cpp (100%) rename {examples => cpp/examples}/build.sh (100%) rename {examples => cpp/examples}/fetch_dependencies.cmake (100%) rename {examples => cpp/examples}/set_cuda_architecture.cmake (73%) rename {examples => cpp/examples}/versions.cmake (100%) rename gcovr.cfg => cpp/gcovr.cfg (100%) rename {include => cpp/include}/doxygen_groups.h (100%) rename {include => cpp/include}/rmm/aligned.hpp (100%) rename {include => cpp/include}/rmm/cuda_device.hpp (100%) rename {include => cpp/include}/rmm/cuda_stream.hpp (100%) rename {include => cpp/include}/rmm/cuda_stream_pool.hpp (100%) rename {include => cpp/include}/rmm/cuda_stream_view.hpp (100%) rename {include => cpp/include}/rmm/detail/aligned.hpp (100%) rename {include => cpp/include}/rmm/detail/cuda_memory_resource.hpp (100%) rename {include => cpp/include}/rmm/detail/error.hpp (100%) rename {include => cpp/include}/rmm/detail/exec_check_disable.hpp (100%) rename {include => cpp/include}/rmm/detail/export.hpp (100%) rename {include => cpp/include}/rmm/detail/format.hpp (100%) rename {include => cpp/include}/rmm/detail/logging_assert.hpp (100%) rename {include => cpp/include}/rmm/detail/nvtx/ranges.hpp (100%) rename {include => cpp/include}/rmm/detail/runtime_async_alloc.hpp (100%) rename {include => cpp/include}/rmm/detail/stack_trace.hpp (100%) rename {include => cpp/include}/rmm/detail/thrust_namespace.h (100%) rename {include => cpp/include}/rmm/device_buffer.hpp (100%) rename {include => cpp/include}/rmm/device_scalar.hpp (100%) rename {include => cpp/include}/rmm/device_uvector.hpp (100%) rename {include => cpp/include}/rmm/device_vector.hpp (100%) rename {include => cpp/include}/rmm/error.hpp (100%) rename {include => cpp/include}/rmm/exec_policy.hpp (100%) rename {include => cpp/include}/rmm/logger.hpp (100%) rename {include => cpp/include}/rmm/mr/device/aligned_resource_adaptor.hpp (100%) rename {include => cpp/include}/rmm/mr/device/arena_memory_resource.hpp (100%) rename {include => cpp/include}/rmm/mr/device/binning_memory_resource.hpp (100%) rename {include => cpp/include}/rmm/mr/device/callback_memory_resource.hpp (100%) rename {include => cpp/include}/rmm/mr/device/cuda_async_memory_resource.hpp (100%) rename {include => cpp/include}/rmm/mr/device/cuda_async_view_memory_resource.hpp (100%) rename {include => cpp/include}/rmm/mr/device/cuda_memory_resource.hpp (100%) rename {include => cpp/include}/rmm/mr/device/detail/arena.hpp (100%) rename {include => cpp/include}/rmm/mr/device/detail/coalescing_free_list.hpp (100%) rename {include => cpp/include}/rmm/mr/device/detail/fixed_size_free_list.hpp (100%) rename {include => cpp/include}/rmm/mr/device/detail/free_list.hpp (100%) rename {include => cpp/include}/rmm/mr/device/detail/stream_ordered_memory_resource.hpp (100%) rename {include => cpp/include}/rmm/mr/device/device_memory_resource.hpp (100%) rename {include => cpp/include}/rmm/mr/device/failure_callback_resource_adaptor.hpp (100%) rename {include => cpp/include}/rmm/mr/device/fixed_size_memory_resource.hpp (100%) rename {include => cpp/include}/rmm/mr/device/limiting_resource_adaptor.hpp (100%) rename {include => cpp/include}/rmm/mr/device/logging_resource_adaptor.hpp (100%) rename {include => cpp/include}/rmm/mr/device/managed_memory_resource.hpp (100%) rename {include => cpp/include}/rmm/mr/device/owning_wrapper.hpp (100%) rename {include => cpp/include}/rmm/mr/device/per_device_resource.hpp (100%) rename {include => cpp/include}/rmm/mr/device/polymorphic_allocator.hpp (100%) rename {include => cpp/include}/rmm/mr/device/pool_memory_resource.hpp (100%) rename {include => cpp/include}/rmm/mr/device/prefetch_resource_adaptor.hpp (100%) rename {include => cpp/include}/rmm/mr/device/sam_headroom_memory_resource.hpp (100%) rename {include => cpp/include}/rmm/mr/device/statistics_resource_adaptor.hpp (100%) rename {include => cpp/include}/rmm/mr/device/system_memory_resource.hpp (100%) rename {include => cpp/include}/rmm/mr/device/thread_safe_resource_adaptor.hpp (100%) rename {include => cpp/include}/rmm/mr/device/thrust_allocator_adaptor.hpp (100%) rename {include => cpp/include}/rmm/mr/device/tracking_resource_adaptor.hpp (100%) rename {include => cpp/include}/rmm/mr/host/host_memory_resource.hpp (100%) rename {include => cpp/include}/rmm/mr/host/new_delete_resource.hpp (100%) rename {include => cpp/include}/rmm/mr/host/pinned_memory_resource.hpp (100%) rename {include => cpp/include}/rmm/mr/is_resource_adaptor.hpp (100%) rename {include => cpp/include}/rmm/mr/pinned_host_memory_resource.hpp (100%) rename {include => cpp/include}/rmm/prefetch.hpp (100%) rename {include => cpp/include}/rmm/resource_ref.hpp (100%) rename {scripts => cpp/scripts}/doxygen.sh (85%) rename {scripts => cpp/scripts}/gdb-pretty-printers.py (100%) rename {scripts => cpp/scripts}/load-pretty-printers.in (100%) rename {scripts => cpp/scripts}/run-cmake-format.sh (90%) rename {tests => cpp/tests}/CMakeLists.txt (100%) rename {tests => cpp/tests}/byte_literals.hpp (100%) rename {tests => cpp/tests}/container_multidevice_tests.cu (100%) rename {tests => cpp/tests}/cuda_stream_pool_tests.cpp (100%) rename {tests => cpp/tests}/cuda_stream_tests.cpp (100%) rename {tests => cpp/tests}/device_buffer_tests.cu (100%) rename {tests => cpp/tests}/device_check_resource_adaptor.hpp (100%) rename {tests => cpp/tests}/device_scalar_tests.cpp (100%) rename {tests => cpp/tests}/device_uvector_tests.cpp (100%) rename {tests => cpp/tests}/error_macros_tests.cpp (100%) rename {tests => cpp/tests}/libcudacxx_flag_test/README.md (100%) rename {tests => cpp/tests}/libcudacxx_flag_test/libcudacxx_flag_test.cpp (100%) rename {tests => cpp/tests}/libcudacxx_flag_test/libcudacxx_flag_test.sh (100%) rename {tests => cpp/tests}/logger_tests.cpp (100%) rename {tests => cpp/tests}/mock_resource.hpp (100%) rename {tests => cpp/tests}/mr/device/adaptor_tests.cpp (100%) rename {tests => cpp/tests}/mr/device/aligned_mr_tests.cpp (100%) rename {tests => cpp/tests}/mr/device/arena_mr_tests.cpp (100%) rename {tests => cpp/tests}/mr/device/binning_mr_tests.cpp (100%) rename {tests => cpp/tests}/mr/device/callback_mr_tests.cpp (100%) rename {tests => cpp/tests}/mr/device/cuda_async_mr_tests.cpp (100%) rename {tests => cpp/tests}/mr/device/cuda_async_view_mr_tests.cpp (100%) rename {tests => cpp/tests}/mr/device/failure_callback_mr_tests.cpp (100%) rename {tests => cpp/tests}/mr/device/hwdecompress_tests.cpp (100%) rename {tests => cpp/tests}/mr/device/limiting_mr_tests.cpp (100%) rename {tests => cpp/tests}/mr/device/mr_ref_multithreaded_tests.cpp (100%) rename {tests => cpp/tests}/mr/device/mr_ref_test.hpp (100%) rename {tests => cpp/tests}/mr/device/mr_ref_tests.cpp (100%) rename {tests => cpp/tests}/mr/device/polymorphic_allocator_tests.cpp (100%) rename {tests => cpp/tests}/mr/device/pool_mr_tests.cpp (100%) rename {tests => cpp/tests}/mr/device/prefetch_resource_adaptor_tests.cpp (100%) rename {tests => cpp/tests}/mr/device/statistics_mr_tests.cpp (100%) rename {tests => cpp/tests}/mr/device/stream_allocator_adaptor_tests.cpp (100%) rename {tests => cpp/tests}/mr/device/system_mr_tests.cu (100%) rename {tests => cpp/tests}/mr/device/test_utils.hpp (100%) rename {tests => cpp/tests}/mr/device/thrust_allocator_tests.cu (100%) rename {tests => cpp/tests}/mr/device/tracking_mr_tests.cpp (100%) rename {tests => cpp/tests}/mr/host/mr_ref_tests.cpp (100%) rename {tests => cpp/tests}/mr/host/pinned_pool_mr_tests.cpp (100%) rename {tests => cpp/tests}/prefetch_tests.cpp (100%) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 0cf1a17e1..4aac91f18 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -153,6 +153,7 @@ jobs: arch: '["amd64"]' cuda: '["12.8"]' build_command: | + mkdir -p telemetry-artifacts; sccache --zero-stats; build-all -DBUILD_BENCHMARKS=ON --verbose 2>&1 | tee telemetry-artifacts/build.log; sccache --show-adv-stats | tee telemetry-artifacts/sccache-stats.txt; diff --git a/.gitignore b/.gitignore index c2df58adb..a37264dbf 100644 --- a/.gitignore +++ b/.gitignore @@ -95,8 +95,8 @@ thirdparty/googletest/ *.iws ## Doxygen -doxygen/html -doxygen/xml +cpp/doxygen/html +cpp/doxygen/xml #Java target diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9f6e06da0..fc0b4f89f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,7 +36,7 @@ repos: - id: fix-smartquotes exclude: | (?x)^( - ^benchmarks/utilities/cxxopts.hpp + ^cpp/benchmarks/utilities/cxxopts.hpp ) - repo: https://github.com/codespell-project/codespell rev: v2.4.1 @@ -46,14 +46,14 @@ repos: args: ["--toml", "pyproject.toml"] exclude: | (?x)^( - pyproject.toml| - benchmarks/utilities/cxxopts.hpp + ^pyproject.toml| + ^cpp/benchmarks/utilities/cxxopts.hpp ) - repo: local hooks: - id: cmake-format name: cmake-format - entry: ./scripts/run-cmake-format.sh cmake-format + entry: ./cpp/scripts/run-cmake-format.sh cmake-format language: python types: [cmake] # Note that pre-commit autoupdate does not update the versions @@ -62,7 +62,7 @@ repos: - cmakelang==0.6.13 - id: cmake-lint name: cmake-lint - entry: ./scripts/run-cmake-format.sh cmake-lint + entry: ./cpp/scripts/run-cmake-format.sh cmake-lint language: python types: [cmake] # Note that pre-commit autoupdate does not update the versions @@ -71,7 +71,7 @@ repos: - cmakelang==0.6.13 - id: doxygen-check name: doxygen-check - entry: ./scripts/doxygen.sh + entry: ./cpp/scripts/doxygen.sh types_or: [file] language: system pass_filenames: false diff --git a/build.sh b/build.sh index 5a712c69b..8689a0887 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2019-2024, NVIDIA CORPORATION. +# Copyright (c) 2019-2025, NVIDIA CORPORATION. # rmm build script @@ -35,7 +35,7 @@ HELP="$0 [clean] [librmm] [rmm] [-v] [-g] [-n] [-s] [--ptds] [--cmake-args=\" VERSION # Examples update -sed_runner "s/RMM_TAG branch-[0-9.]*/RMM_TAG branch-${NEXT_SHORT_TAG}/" examples/versions.cmake +sed_runner "s/RMM_TAG branch-[0-9.]*/RMM_TAG branch-${NEXT_SHORT_TAG}/" cpp/examples/versions.cmake # CI files for FILE in .github/workflows/*.yaml; do diff --git a/conda/recipes/librmm/recipe.yaml b/conda/recipes/librmm/recipe.yaml index 3e0c40886..855f737d3 100644 --- a/conda/recipes/librmm/recipe.yaml +++ b/conda/recipes/librmm/recipe.yaml @@ -66,7 +66,7 @@ outputs: build: string: cuda${{ cuda_major }}_${{ date_string }}_${{ head_rev }} script: - - cmake --install build + - cmake --install cpp/build dynamic_linking: overlinking_behavior: "error" requirements: @@ -99,7 +99,7 @@ outputs: version: ${{ version }} build: string: cuda${{ cuda_major }}_${{ date_string }}_${{ head_rev }} - script: cmake --install build --component testing + script: cmake --install cpp/build --component testing dynamic_linking: overlinking_behavior: "error" missing_dso_allowlist: @@ -143,7 +143,7 @@ outputs: string: cuda${{ cuda_major }}_${{ date_string }}_${{ head_rev }} script: content: | - ./examples/build.sh --install + ./cpp/examples/build.sh --install env: CMAKE_C_COMPILER_LAUNCHER: ${{ env.get("CMAKE_C_COMPILER_LAUNCHER") }} CMAKE_CUDA_COMPILER_LAUNCHER: ${{ env.get("CMAKE_CUDA_COMPILER_LAUNCHER") }} diff --git a/.clang-tidy b/cpp/.clang-tidy similarity index 100% rename from .clang-tidy rename to cpp/.clang-tidy diff --git a/.clangd b/cpp/.clangd similarity index 100% rename from .clangd rename to cpp/.clangd diff --git a/CMakeLists.txt b/cpp/CMakeLists.txt similarity index 99% rename from CMakeLists.txt rename to cpp/CMakeLists.txt index f33b77d4f..aa00cd279 100644 --- a/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR) -include(cmake/rapids_config.cmake) +include(../cmake/rapids_config.cmake) include(rapids-cmake) include(rapids-cpm) diff --git a/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt similarity index 100% rename from benchmarks/CMakeLists.txt rename to cpp/benchmarks/CMakeLists.txt diff --git a/benchmarks/cuda_stream_pool/cuda_stream_pool_bench.cpp b/cpp/benchmarks/cuda_stream_pool/cuda_stream_pool_bench.cpp similarity index 100% rename from benchmarks/cuda_stream_pool/cuda_stream_pool_bench.cpp rename to cpp/benchmarks/cuda_stream_pool/cuda_stream_pool_bench.cpp diff --git a/benchmarks/device_uvector/device_uvector_bench.cu b/cpp/benchmarks/device_uvector/device_uvector_bench.cu similarity index 100% rename from benchmarks/device_uvector/device_uvector_bench.cu rename to cpp/benchmarks/device_uvector/device_uvector_bench.cu diff --git a/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu b/cpp/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu similarity index 100% rename from benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu rename to cpp/benchmarks/multi_stream_allocations/multi_stream_allocations_bench.cu diff --git a/benchmarks/random_allocations/random_allocations.cpp b/cpp/benchmarks/random_allocations/random_allocations.cpp similarity index 100% rename from benchmarks/random_allocations/random_allocations.cpp rename to cpp/benchmarks/random_allocations/random_allocations.cpp diff --git a/benchmarks/replay/replay.cpp b/cpp/benchmarks/replay/replay.cpp similarity index 100% rename from benchmarks/replay/replay.cpp rename to cpp/benchmarks/replay/replay.cpp diff --git a/benchmarks/synchronization/synchronization.cpp b/cpp/benchmarks/synchronization/synchronization.cpp similarity index 100% rename from benchmarks/synchronization/synchronization.cpp rename to cpp/benchmarks/synchronization/synchronization.cpp diff --git a/benchmarks/synchronization/synchronization.hpp b/cpp/benchmarks/synchronization/synchronization.hpp similarity index 100% rename from benchmarks/synchronization/synchronization.hpp rename to cpp/benchmarks/synchronization/synchronization.hpp diff --git a/benchmarks/utilities/cxxopts.hpp b/cpp/benchmarks/utilities/cxxopts.hpp similarity index 100% rename from benchmarks/utilities/cxxopts.hpp rename to cpp/benchmarks/utilities/cxxopts.hpp diff --git a/benchmarks/utilities/log_parser.hpp b/cpp/benchmarks/utilities/log_parser.hpp similarity index 100% rename from benchmarks/utilities/log_parser.hpp rename to cpp/benchmarks/utilities/log_parser.hpp diff --git a/benchmarks/utilities/rapidcsv.h b/cpp/benchmarks/utilities/rapidcsv.h similarity index 100% rename from benchmarks/utilities/rapidcsv.h rename to cpp/benchmarks/utilities/rapidcsv.h diff --git a/benchmarks/utilities/simulated_memory_resource.hpp b/cpp/benchmarks/utilities/simulated_memory_resource.hpp similarity index 100% rename from benchmarks/utilities/simulated_memory_resource.hpp rename to cpp/benchmarks/utilities/simulated_memory_resource.hpp diff --git a/cmake/config.json b/cpp/cmake/config.json similarity index 100% rename from cmake/config.json rename to cpp/cmake/config.json diff --git a/cmake/thirdparty/get_cccl.cmake b/cpp/cmake/thirdparty/get_cccl.cmake similarity index 100% rename from cmake/thirdparty/get_cccl.cmake rename to cpp/cmake/thirdparty/get_cccl.cmake diff --git a/cmake/thirdparty/get_nvtx.cmake b/cpp/cmake/thirdparty/get_nvtx.cmake similarity index 100% rename from cmake/thirdparty/get_nvtx.cmake rename to cpp/cmake/thirdparty/get_nvtx.cmake diff --git a/doxygen/Doxyfile b/cpp/doxygen/Doxyfile similarity index 100% rename from doxygen/Doxyfile rename to cpp/doxygen/Doxyfile diff --git a/doxygen/header.html b/cpp/doxygen/header.html similarity index 100% rename from doxygen/header.html rename to cpp/doxygen/header.html diff --git a/doxygen/main_page.md b/cpp/doxygen/main_page.md similarity index 100% rename from doxygen/main_page.md rename to cpp/doxygen/main_page.md diff --git a/examples/README.md b/cpp/examples/README.md similarity index 100% rename from examples/README.md rename to cpp/examples/README.md diff --git a/examples/basic/CMakeLists.txt b/cpp/examples/basic/CMakeLists.txt similarity index 100% rename from examples/basic/CMakeLists.txt rename to cpp/examples/basic/CMakeLists.txt diff --git a/examples/basic/README.md b/cpp/examples/basic/README.md similarity index 100% rename from examples/basic/README.md rename to cpp/examples/basic/README.md diff --git a/examples/basic/src/basic.cpp b/cpp/examples/basic/src/basic.cpp similarity index 100% rename from examples/basic/src/basic.cpp rename to cpp/examples/basic/src/basic.cpp diff --git a/examples/build.sh b/cpp/examples/build.sh similarity index 100% rename from examples/build.sh rename to cpp/examples/build.sh diff --git a/examples/fetch_dependencies.cmake b/cpp/examples/fetch_dependencies.cmake similarity index 100% rename from examples/fetch_dependencies.cmake rename to cpp/examples/fetch_dependencies.cmake diff --git a/examples/set_cuda_architecture.cmake b/cpp/examples/set_cuda_architecture.cmake similarity index 73% rename from examples/set_cuda_architecture.cmake rename to cpp/examples/set_cuda_architecture.cmake index e8b3d9b56..db0921082 100644 --- a/examples/set_cuda_architecture.cmake +++ b/cpp/examples/set_cuda_architecture.cmake @@ -13,12 +13,7 @@ # ============================================================================= include(${CMAKE_CURRENT_LIST_DIR}/versions.cmake) - -if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/librmm_cpp_examples_RAPIDS.cmake) - file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/${RMM_TAG}/RAPIDS.cmake - ${CMAKE_CURRENT_BINARY_DIR}/librmm_cpp_examples_RAPIDS.cmake) -endif() -include(${CMAKE_CURRENT_BINARY_DIR}/librmm_cpp_examples_RAPIDS.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/../../cmake/rapids_config.cmake) include(rapids-cmake) include(rapids-cpm) diff --git a/examples/versions.cmake b/cpp/examples/versions.cmake similarity index 100% rename from examples/versions.cmake rename to cpp/examples/versions.cmake diff --git a/gcovr.cfg b/cpp/gcovr.cfg similarity index 100% rename from gcovr.cfg rename to cpp/gcovr.cfg diff --git a/include/doxygen_groups.h b/cpp/include/doxygen_groups.h similarity index 100% rename from include/doxygen_groups.h rename to cpp/include/doxygen_groups.h diff --git a/include/rmm/aligned.hpp b/cpp/include/rmm/aligned.hpp similarity index 100% rename from include/rmm/aligned.hpp rename to cpp/include/rmm/aligned.hpp diff --git a/include/rmm/cuda_device.hpp b/cpp/include/rmm/cuda_device.hpp similarity index 100% rename from include/rmm/cuda_device.hpp rename to cpp/include/rmm/cuda_device.hpp diff --git a/include/rmm/cuda_stream.hpp b/cpp/include/rmm/cuda_stream.hpp similarity index 100% rename from include/rmm/cuda_stream.hpp rename to cpp/include/rmm/cuda_stream.hpp diff --git a/include/rmm/cuda_stream_pool.hpp b/cpp/include/rmm/cuda_stream_pool.hpp similarity index 100% rename from include/rmm/cuda_stream_pool.hpp rename to cpp/include/rmm/cuda_stream_pool.hpp diff --git a/include/rmm/cuda_stream_view.hpp b/cpp/include/rmm/cuda_stream_view.hpp similarity index 100% rename from include/rmm/cuda_stream_view.hpp rename to cpp/include/rmm/cuda_stream_view.hpp diff --git a/include/rmm/detail/aligned.hpp b/cpp/include/rmm/detail/aligned.hpp similarity index 100% rename from include/rmm/detail/aligned.hpp rename to cpp/include/rmm/detail/aligned.hpp diff --git a/include/rmm/detail/cuda_memory_resource.hpp b/cpp/include/rmm/detail/cuda_memory_resource.hpp similarity index 100% rename from include/rmm/detail/cuda_memory_resource.hpp rename to cpp/include/rmm/detail/cuda_memory_resource.hpp diff --git a/include/rmm/detail/error.hpp b/cpp/include/rmm/detail/error.hpp similarity index 100% rename from include/rmm/detail/error.hpp rename to cpp/include/rmm/detail/error.hpp diff --git a/include/rmm/detail/exec_check_disable.hpp b/cpp/include/rmm/detail/exec_check_disable.hpp similarity index 100% rename from include/rmm/detail/exec_check_disable.hpp rename to cpp/include/rmm/detail/exec_check_disable.hpp diff --git a/include/rmm/detail/export.hpp b/cpp/include/rmm/detail/export.hpp similarity index 100% rename from include/rmm/detail/export.hpp rename to cpp/include/rmm/detail/export.hpp diff --git a/include/rmm/detail/format.hpp b/cpp/include/rmm/detail/format.hpp similarity index 100% rename from include/rmm/detail/format.hpp rename to cpp/include/rmm/detail/format.hpp diff --git a/include/rmm/detail/logging_assert.hpp b/cpp/include/rmm/detail/logging_assert.hpp similarity index 100% rename from include/rmm/detail/logging_assert.hpp rename to cpp/include/rmm/detail/logging_assert.hpp diff --git a/include/rmm/detail/nvtx/ranges.hpp b/cpp/include/rmm/detail/nvtx/ranges.hpp similarity index 100% rename from include/rmm/detail/nvtx/ranges.hpp rename to cpp/include/rmm/detail/nvtx/ranges.hpp diff --git a/include/rmm/detail/runtime_async_alloc.hpp b/cpp/include/rmm/detail/runtime_async_alloc.hpp similarity index 100% rename from include/rmm/detail/runtime_async_alloc.hpp rename to cpp/include/rmm/detail/runtime_async_alloc.hpp diff --git a/include/rmm/detail/stack_trace.hpp b/cpp/include/rmm/detail/stack_trace.hpp similarity index 100% rename from include/rmm/detail/stack_trace.hpp rename to cpp/include/rmm/detail/stack_trace.hpp diff --git a/include/rmm/detail/thrust_namespace.h b/cpp/include/rmm/detail/thrust_namespace.h similarity index 100% rename from include/rmm/detail/thrust_namespace.h rename to cpp/include/rmm/detail/thrust_namespace.h diff --git a/include/rmm/device_buffer.hpp b/cpp/include/rmm/device_buffer.hpp similarity index 100% rename from include/rmm/device_buffer.hpp rename to cpp/include/rmm/device_buffer.hpp diff --git a/include/rmm/device_scalar.hpp b/cpp/include/rmm/device_scalar.hpp similarity index 100% rename from include/rmm/device_scalar.hpp rename to cpp/include/rmm/device_scalar.hpp diff --git a/include/rmm/device_uvector.hpp b/cpp/include/rmm/device_uvector.hpp similarity index 100% rename from include/rmm/device_uvector.hpp rename to cpp/include/rmm/device_uvector.hpp diff --git a/include/rmm/device_vector.hpp b/cpp/include/rmm/device_vector.hpp similarity index 100% rename from include/rmm/device_vector.hpp rename to cpp/include/rmm/device_vector.hpp diff --git a/include/rmm/error.hpp b/cpp/include/rmm/error.hpp similarity index 100% rename from include/rmm/error.hpp rename to cpp/include/rmm/error.hpp diff --git a/include/rmm/exec_policy.hpp b/cpp/include/rmm/exec_policy.hpp similarity index 100% rename from include/rmm/exec_policy.hpp rename to cpp/include/rmm/exec_policy.hpp diff --git a/include/rmm/logger.hpp b/cpp/include/rmm/logger.hpp similarity index 100% rename from include/rmm/logger.hpp rename to cpp/include/rmm/logger.hpp diff --git a/include/rmm/mr/device/aligned_resource_adaptor.hpp b/cpp/include/rmm/mr/device/aligned_resource_adaptor.hpp similarity index 100% rename from include/rmm/mr/device/aligned_resource_adaptor.hpp rename to cpp/include/rmm/mr/device/aligned_resource_adaptor.hpp diff --git a/include/rmm/mr/device/arena_memory_resource.hpp b/cpp/include/rmm/mr/device/arena_memory_resource.hpp similarity index 100% rename from include/rmm/mr/device/arena_memory_resource.hpp rename to cpp/include/rmm/mr/device/arena_memory_resource.hpp diff --git a/include/rmm/mr/device/binning_memory_resource.hpp b/cpp/include/rmm/mr/device/binning_memory_resource.hpp similarity index 100% rename from include/rmm/mr/device/binning_memory_resource.hpp rename to cpp/include/rmm/mr/device/binning_memory_resource.hpp diff --git a/include/rmm/mr/device/callback_memory_resource.hpp b/cpp/include/rmm/mr/device/callback_memory_resource.hpp similarity index 100% rename from include/rmm/mr/device/callback_memory_resource.hpp rename to cpp/include/rmm/mr/device/callback_memory_resource.hpp diff --git a/include/rmm/mr/device/cuda_async_memory_resource.hpp b/cpp/include/rmm/mr/device/cuda_async_memory_resource.hpp similarity index 100% rename from include/rmm/mr/device/cuda_async_memory_resource.hpp rename to cpp/include/rmm/mr/device/cuda_async_memory_resource.hpp diff --git a/include/rmm/mr/device/cuda_async_view_memory_resource.hpp b/cpp/include/rmm/mr/device/cuda_async_view_memory_resource.hpp similarity index 100% rename from include/rmm/mr/device/cuda_async_view_memory_resource.hpp rename to cpp/include/rmm/mr/device/cuda_async_view_memory_resource.hpp diff --git a/include/rmm/mr/device/cuda_memory_resource.hpp b/cpp/include/rmm/mr/device/cuda_memory_resource.hpp similarity index 100% rename from include/rmm/mr/device/cuda_memory_resource.hpp rename to cpp/include/rmm/mr/device/cuda_memory_resource.hpp diff --git a/include/rmm/mr/device/detail/arena.hpp b/cpp/include/rmm/mr/device/detail/arena.hpp similarity index 100% rename from include/rmm/mr/device/detail/arena.hpp rename to cpp/include/rmm/mr/device/detail/arena.hpp diff --git a/include/rmm/mr/device/detail/coalescing_free_list.hpp b/cpp/include/rmm/mr/device/detail/coalescing_free_list.hpp similarity index 100% rename from include/rmm/mr/device/detail/coalescing_free_list.hpp rename to cpp/include/rmm/mr/device/detail/coalescing_free_list.hpp diff --git a/include/rmm/mr/device/detail/fixed_size_free_list.hpp b/cpp/include/rmm/mr/device/detail/fixed_size_free_list.hpp similarity index 100% rename from include/rmm/mr/device/detail/fixed_size_free_list.hpp rename to cpp/include/rmm/mr/device/detail/fixed_size_free_list.hpp diff --git a/include/rmm/mr/device/detail/free_list.hpp b/cpp/include/rmm/mr/device/detail/free_list.hpp similarity index 100% rename from include/rmm/mr/device/detail/free_list.hpp rename to cpp/include/rmm/mr/device/detail/free_list.hpp diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/cpp/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp similarity index 100% rename from include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp rename to cpp/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp diff --git a/include/rmm/mr/device/device_memory_resource.hpp b/cpp/include/rmm/mr/device/device_memory_resource.hpp similarity index 100% rename from include/rmm/mr/device/device_memory_resource.hpp rename to cpp/include/rmm/mr/device/device_memory_resource.hpp diff --git a/include/rmm/mr/device/failure_callback_resource_adaptor.hpp b/cpp/include/rmm/mr/device/failure_callback_resource_adaptor.hpp similarity index 100% rename from include/rmm/mr/device/failure_callback_resource_adaptor.hpp rename to cpp/include/rmm/mr/device/failure_callback_resource_adaptor.hpp diff --git a/include/rmm/mr/device/fixed_size_memory_resource.hpp b/cpp/include/rmm/mr/device/fixed_size_memory_resource.hpp similarity index 100% rename from include/rmm/mr/device/fixed_size_memory_resource.hpp rename to cpp/include/rmm/mr/device/fixed_size_memory_resource.hpp diff --git a/include/rmm/mr/device/limiting_resource_adaptor.hpp b/cpp/include/rmm/mr/device/limiting_resource_adaptor.hpp similarity index 100% rename from include/rmm/mr/device/limiting_resource_adaptor.hpp rename to cpp/include/rmm/mr/device/limiting_resource_adaptor.hpp diff --git a/include/rmm/mr/device/logging_resource_adaptor.hpp b/cpp/include/rmm/mr/device/logging_resource_adaptor.hpp similarity index 100% rename from include/rmm/mr/device/logging_resource_adaptor.hpp rename to cpp/include/rmm/mr/device/logging_resource_adaptor.hpp diff --git a/include/rmm/mr/device/managed_memory_resource.hpp b/cpp/include/rmm/mr/device/managed_memory_resource.hpp similarity index 100% rename from include/rmm/mr/device/managed_memory_resource.hpp rename to cpp/include/rmm/mr/device/managed_memory_resource.hpp diff --git a/include/rmm/mr/device/owning_wrapper.hpp b/cpp/include/rmm/mr/device/owning_wrapper.hpp similarity index 100% rename from include/rmm/mr/device/owning_wrapper.hpp rename to cpp/include/rmm/mr/device/owning_wrapper.hpp diff --git a/include/rmm/mr/device/per_device_resource.hpp b/cpp/include/rmm/mr/device/per_device_resource.hpp similarity index 100% rename from include/rmm/mr/device/per_device_resource.hpp rename to cpp/include/rmm/mr/device/per_device_resource.hpp diff --git a/include/rmm/mr/device/polymorphic_allocator.hpp b/cpp/include/rmm/mr/device/polymorphic_allocator.hpp similarity index 100% rename from include/rmm/mr/device/polymorphic_allocator.hpp rename to cpp/include/rmm/mr/device/polymorphic_allocator.hpp diff --git a/include/rmm/mr/device/pool_memory_resource.hpp b/cpp/include/rmm/mr/device/pool_memory_resource.hpp similarity index 100% rename from include/rmm/mr/device/pool_memory_resource.hpp rename to cpp/include/rmm/mr/device/pool_memory_resource.hpp diff --git a/include/rmm/mr/device/prefetch_resource_adaptor.hpp b/cpp/include/rmm/mr/device/prefetch_resource_adaptor.hpp similarity index 100% rename from include/rmm/mr/device/prefetch_resource_adaptor.hpp rename to cpp/include/rmm/mr/device/prefetch_resource_adaptor.hpp diff --git a/include/rmm/mr/device/sam_headroom_memory_resource.hpp b/cpp/include/rmm/mr/device/sam_headroom_memory_resource.hpp similarity index 100% rename from include/rmm/mr/device/sam_headroom_memory_resource.hpp rename to cpp/include/rmm/mr/device/sam_headroom_memory_resource.hpp diff --git a/include/rmm/mr/device/statistics_resource_adaptor.hpp b/cpp/include/rmm/mr/device/statistics_resource_adaptor.hpp similarity index 100% rename from include/rmm/mr/device/statistics_resource_adaptor.hpp rename to cpp/include/rmm/mr/device/statistics_resource_adaptor.hpp diff --git a/include/rmm/mr/device/system_memory_resource.hpp b/cpp/include/rmm/mr/device/system_memory_resource.hpp similarity index 100% rename from include/rmm/mr/device/system_memory_resource.hpp rename to cpp/include/rmm/mr/device/system_memory_resource.hpp diff --git a/include/rmm/mr/device/thread_safe_resource_adaptor.hpp b/cpp/include/rmm/mr/device/thread_safe_resource_adaptor.hpp similarity index 100% rename from include/rmm/mr/device/thread_safe_resource_adaptor.hpp rename to cpp/include/rmm/mr/device/thread_safe_resource_adaptor.hpp diff --git a/include/rmm/mr/device/thrust_allocator_adaptor.hpp b/cpp/include/rmm/mr/device/thrust_allocator_adaptor.hpp similarity index 100% rename from include/rmm/mr/device/thrust_allocator_adaptor.hpp rename to cpp/include/rmm/mr/device/thrust_allocator_adaptor.hpp diff --git a/include/rmm/mr/device/tracking_resource_adaptor.hpp b/cpp/include/rmm/mr/device/tracking_resource_adaptor.hpp similarity index 100% rename from include/rmm/mr/device/tracking_resource_adaptor.hpp rename to cpp/include/rmm/mr/device/tracking_resource_adaptor.hpp diff --git a/include/rmm/mr/host/host_memory_resource.hpp b/cpp/include/rmm/mr/host/host_memory_resource.hpp similarity index 100% rename from include/rmm/mr/host/host_memory_resource.hpp rename to cpp/include/rmm/mr/host/host_memory_resource.hpp diff --git a/include/rmm/mr/host/new_delete_resource.hpp b/cpp/include/rmm/mr/host/new_delete_resource.hpp similarity index 100% rename from include/rmm/mr/host/new_delete_resource.hpp rename to cpp/include/rmm/mr/host/new_delete_resource.hpp diff --git a/include/rmm/mr/host/pinned_memory_resource.hpp b/cpp/include/rmm/mr/host/pinned_memory_resource.hpp similarity index 100% rename from include/rmm/mr/host/pinned_memory_resource.hpp rename to cpp/include/rmm/mr/host/pinned_memory_resource.hpp diff --git a/include/rmm/mr/is_resource_adaptor.hpp b/cpp/include/rmm/mr/is_resource_adaptor.hpp similarity index 100% rename from include/rmm/mr/is_resource_adaptor.hpp rename to cpp/include/rmm/mr/is_resource_adaptor.hpp diff --git a/include/rmm/mr/pinned_host_memory_resource.hpp b/cpp/include/rmm/mr/pinned_host_memory_resource.hpp similarity index 100% rename from include/rmm/mr/pinned_host_memory_resource.hpp rename to cpp/include/rmm/mr/pinned_host_memory_resource.hpp diff --git a/include/rmm/prefetch.hpp b/cpp/include/rmm/prefetch.hpp similarity index 100% rename from include/rmm/prefetch.hpp rename to cpp/include/rmm/prefetch.hpp diff --git a/include/rmm/resource_ref.hpp b/cpp/include/rmm/resource_ref.hpp similarity index 100% rename from include/rmm/resource_ref.hpp rename to cpp/include/rmm/resource_ref.hpp diff --git a/scripts/doxygen.sh b/cpp/scripts/doxygen.sh similarity index 85% rename from scripts/doxygen.sh rename to cpp/scripts/doxygen.sh index 372a9f27d..2f6c1a464 100755 --- a/scripts/doxygen.sh +++ b/cpp/scripts/doxygen.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2025, NVIDIA CORPORATION. ############################## # RMM doxygen warnings check # ############################## @@ -27,7 +27,7 @@ export RAPIDS_VERSION_MAJOR_MINOR="$(sed -E -e 's/^([0-9]{2})\.([0-9]{2})\.([0-9 # Run doxygen, ignore missing tag files error TAG_ERROR1="error: Tag file '.*.tag' does not exist or is not a file. Skipping it..." TAG_ERROR2="error: cannot open tag file .*.tag for writing" -DOXYGEN_STDERR=`cd doxygen && { cat Doxyfile ; echo QUIET = YES; echo GENERATE_HTML = NO; } | doxygen - 2>&1 | sed "/\($TAG_ERROR1\|$TAG_ERROR2\)/d"` +DOXYGEN_STDERR=`cd cpp/doxygen && { cat Doxyfile ; echo QUIET = YES; echo GENERATE_HTML = NO; } | doxygen - 2>&1 | sed "/\($TAG_ERROR1\|$TAG_ERROR2\)/d"` RETVAL=$? if [ "$RETVAL" != "0" ] || [ ! -z "$DOXYGEN_STDERR" ]; then diff --git a/scripts/gdb-pretty-printers.py b/cpp/scripts/gdb-pretty-printers.py similarity index 100% rename from scripts/gdb-pretty-printers.py rename to cpp/scripts/gdb-pretty-printers.py diff --git a/scripts/load-pretty-printers.in b/cpp/scripts/load-pretty-printers.in similarity index 100% rename from scripts/load-pretty-printers.in rename to cpp/scripts/load-pretty-printers.in diff --git a/scripts/run-cmake-format.sh b/cpp/scripts/run-cmake-format.sh similarity index 90% rename from scripts/run-cmake-format.sh rename to cpp/scripts/run-cmake-format.sh index df7f22782..fc2a83377 100755 --- a/scripts/run-cmake-format.sh +++ b/cpp/scripts/run-cmake-format.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2024, NVIDIA CORPORATION. +# Copyright (c) 2024-2025, NVIDIA CORPORATION. # This script is a wrapper for cmakelang that may be used with pre-commit. The # wrapping is necessary because RAPIDS libraries split configuration for @@ -26,7 +26,7 @@ status=0 if [ -z ${RMM_ROOT:+PLACEHOLDER} ]; then - RMM_BUILD_DIR=$(git rev-parse --show-toplevel 2>&1)/build + RMM_BUILD_DIR=$(git rev-parse --show-toplevel 2>&1)/cpp/build status=$? else RMM_BUILD_DIR=${RMM_ROOT} @@ -68,7 +68,7 @@ else fi if [[ $1 == "cmake-format" ]]; then - cmake-format -i --config-files cmake/config.json ${RAPIDS_CMAKE_FORMAT_FILE} -- ${@:2} + cmake-format -i --config-files cpp/cmake/config.json ${RAPIDS_CMAKE_FORMAT_FILE} -- ${@:2} elif [[ $1 == "cmake-lint" ]]; then - cmake-lint --config-files cmake/config.json ${RAPIDS_CMAKE_FORMAT_FILE} -- ${@:2} + cmake-lint --config-files cpp/cmake/config.json ${RAPIDS_CMAKE_FORMAT_FILE} -- ${@:2} fi diff --git a/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt similarity index 100% rename from tests/CMakeLists.txt rename to cpp/tests/CMakeLists.txt diff --git a/tests/byte_literals.hpp b/cpp/tests/byte_literals.hpp similarity index 100% rename from tests/byte_literals.hpp rename to cpp/tests/byte_literals.hpp diff --git a/tests/container_multidevice_tests.cu b/cpp/tests/container_multidevice_tests.cu similarity index 100% rename from tests/container_multidevice_tests.cu rename to cpp/tests/container_multidevice_tests.cu diff --git a/tests/cuda_stream_pool_tests.cpp b/cpp/tests/cuda_stream_pool_tests.cpp similarity index 100% rename from tests/cuda_stream_pool_tests.cpp rename to cpp/tests/cuda_stream_pool_tests.cpp diff --git a/tests/cuda_stream_tests.cpp b/cpp/tests/cuda_stream_tests.cpp similarity index 100% rename from tests/cuda_stream_tests.cpp rename to cpp/tests/cuda_stream_tests.cpp diff --git a/tests/device_buffer_tests.cu b/cpp/tests/device_buffer_tests.cu similarity index 100% rename from tests/device_buffer_tests.cu rename to cpp/tests/device_buffer_tests.cu diff --git a/tests/device_check_resource_adaptor.hpp b/cpp/tests/device_check_resource_adaptor.hpp similarity index 100% rename from tests/device_check_resource_adaptor.hpp rename to cpp/tests/device_check_resource_adaptor.hpp diff --git a/tests/device_scalar_tests.cpp b/cpp/tests/device_scalar_tests.cpp similarity index 100% rename from tests/device_scalar_tests.cpp rename to cpp/tests/device_scalar_tests.cpp diff --git a/tests/device_uvector_tests.cpp b/cpp/tests/device_uvector_tests.cpp similarity index 100% rename from tests/device_uvector_tests.cpp rename to cpp/tests/device_uvector_tests.cpp diff --git a/tests/error_macros_tests.cpp b/cpp/tests/error_macros_tests.cpp similarity index 100% rename from tests/error_macros_tests.cpp rename to cpp/tests/error_macros_tests.cpp diff --git a/tests/libcudacxx_flag_test/README.md b/cpp/tests/libcudacxx_flag_test/README.md similarity index 100% rename from tests/libcudacxx_flag_test/README.md rename to cpp/tests/libcudacxx_flag_test/README.md diff --git a/tests/libcudacxx_flag_test/libcudacxx_flag_test.cpp b/cpp/tests/libcudacxx_flag_test/libcudacxx_flag_test.cpp similarity index 100% rename from tests/libcudacxx_flag_test/libcudacxx_flag_test.cpp rename to cpp/tests/libcudacxx_flag_test/libcudacxx_flag_test.cpp diff --git a/tests/libcudacxx_flag_test/libcudacxx_flag_test.sh b/cpp/tests/libcudacxx_flag_test/libcudacxx_flag_test.sh similarity index 100% rename from tests/libcudacxx_flag_test/libcudacxx_flag_test.sh rename to cpp/tests/libcudacxx_flag_test/libcudacxx_flag_test.sh diff --git a/tests/logger_tests.cpp b/cpp/tests/logger_tests.cpp similarity index 100% rename from tests/logger_tests.cpp rename to cpp/tests/logger_tests.cpp diff --git a/tests/mock_resource.hpp b/cpp/tests/mock_resource.hpp similarity index 100% rename from tests/mock_resource.hpp rename to cpp/tests/mock_resource.hpp diff --git a/tests/mr/device/adaptor_tests.cpp b/cpp/tests/mr/device/adaptor_tests.cpp similarity index 100% rename from tests/mr/device/adaptor_tests.cpp rename to cpp/tests/mr/device/adaptor_tests.cpp diff --git a/tests/mr/device/aligned_mr_tests.cpp b/cpp/tests/mr/device/aligned_mr_tests.cpp similarity index 100% rename from tests/mr/device/aligned_mr_tests.cpp rename to cpp/tests/mr/device/aligned_mr_tests.cpp diff --git a/tests/mr/device/arena_mr_tests.cpp b/cpp/tests/mr/device/arena_mr_tests.cpp similarity index 100% rename from tests/mr/device/arena_mr_tests.cpp rename to cpp/tests/mr/device/arena_mr_tests.cpp diff --git a/tests/mr/device/binning_mr_tests.cpp b/cpp/tests/mr/device/binning_mr_tests.cpp similarity index 100% rename from tests/mr/device/binning_mr_tests.cpp rename to cpp/tests/mr/device/binning_mr_tests.cpp diff --git a/tests/mr/device/callback_mr_tests.cpp b/cpp/tests/mr/device/callback_mr_tests.cpp similarity index 100% rename from tests/mr/device/callback_mr_tests.cpp rename to cpp/tests/mr/device/callback_mr_tests.cpp diff --git a/tests/mr/device/cuda_async_mr_tests.cpp b/cpp/tests/mr/device/cuda_async_mr_tests.cpp similarity index 100% rename from tests/mr/device/cuda_async_mr_tests.cpp rename to cpp/tests/mr/device/cuda_async_mr_tests.cpp diff --git a/tests/mr/device/cuda_async_view_mr_tests.cpp b/cpp/tests/mr/device/cuda_async_view_mr_tests.cpp similarity index 100% rename from tests/mr/device/cuda_async_view_mr_tests.cpp rename to cpp/tests/mr/device/cuda_async_view_mr_tests.cpp diff --git a/tests/mr/device/failure_callback_mr_tests.cpp b/cpp/tests/mr/device/failure_callback_mr_tests.cpp similarity index 100% rename from tests/mr/device/failure_callback_mr_tests.cpp rename to cpp/tests/mr/device/failure_callback_mr_tests.cpp diff --git a/tests/mr/device/hwdecompress_tests.cpp b/cpp/tests/mr/device/hwdecompress_tests.cpp similarity index 100% rename from tests/mr/device/hwdecompress_tests.cpp rename to cpp/tests/mr/device/hwdecompress_tests.cpp diff --git a/tests/mr/device/limiting_mr_tests.cpp b/cpp/tests/mr/device/limiting_mr_tests.cpp similarity index 100% rename from tests/mr/device/limiting_mr_tests.cpp rename to cpp/tests/mr/device/limiting_mr_tests.cpp diff --git a/tests/mr/device/mr_ref_multithreaded_tests.cpp b/cpp/tests/mr/device/mr_ref_multithreaded_tests.cpp similarity index 100% rename from tests/mr/device/mr_ref_multithreaded_tests.cpp rename to cpp/tests/mr/device/mr_ref_multithreaded_tests.cpp diff --git a/tests/mr/device/mr_ref_test.hpp b/cpp/tests/mr/device/mr_ref_test.hpp similarity index 100% rename from tests/mr/device/mr_ref_test.hpp rename to cpp/tests/mr/device/mr_ref_test.hpp diff --git a/tests/mr/device/mr_ref_tests.cpp b/cpp/tests/mr/device/mr_ref_tests.cpp similarity index 100% rename from tests/mr/device/mr_ref_tests.cpp rename to cpp/tests/mr/device/mr_ref_tests.cpp diff --git a/tests/mr/device/polymorphic_allocator_tests.cpp b/cpp/tests/mr/device/polymorphic_allocator_tests.cpp similarity index 100% rename from tests/mr/device/polymorphic_allocator_tests.cpp rename to cpp/tests/mr/device/polymorphic_allocator_tests.cpp diff --git a/tests/mr/device/pool_mr_tests.cpp b/cpp/tests/mr/device/pool_mr_tests.cpp similarity index 100% rename from tests/mr/device/pool_mr_tests.cpp rename to cpp/tests/mr/device/pool_mr_tests.cpp diff --git a/tests/mr/device/prefetch_resource_adaptor_tests.cpp b/cpp/tests/mr/device/prefetch_resource_adaptor_tests.cpp similarity index 100% rename from tests/mr/device/prefetch_resource_adaptor_tests.cpp rename to cpp/tests/mr/device/prefetch_resource_adaptor_tests.cpp diff --git a/tests/mr/device/statistics_mr_tests.cpp b/cpp/tests/mr/device/statistics_mr_tests.cpp similarity index 100% rename from tests/mr/device/statistics_mr_tests.cpp rename to cpp/tests/mr/device/statistics_mr_tests.cpp diff --git a/tests/mr/device/stream_allocator_adaptor_tests.cpp b/cpp/tests/mr/device/stream_allocator_adaptor_tests.cpp similarity index 100% rename from tests/mr/device/stream_allocator_adaptor_tests.cpp rename to cpp/tests/mr/device/stream_allocator_adaptor_tests.cpp diff --git a/tests/mr/device/system_mr_tests.cu b/cpp/tests/mr/device/system_mr_tests.cu similarity index 100% rename from tests/mr/device/system_mr_tests.cu rename to cpp/tests/mr/device/system_mr_tests.cu diff --git a/tests/mr/device/test_utils.hpp b/cpp/tests/mr/device/test_utils.hpp similarity index 100% rename from tests/mr/device/test_utils.hpp rename to cpp/tests/mr/device/test_utils.hpp diff --git a/tests/mr/device/thrust_allocator_tests.cu b/cpp/tests/mr/device/thrust_allocator_tests.cu similarity index 100% rename from tests/mr/device/thrust_allocator_tests.cu rename to cpp/tests/mr/device/thrust_allocator_tests.cu diff --git a/tests/mr/device/tracking_mr_tests.cpp b/cpp/tests/mr/device/tracking_mr_tests.cpp similarity index 100% rename from tests/mr/device/tracking_mr_tests.cpp rename to cpp/tests/mr/device/tracking_mr_tests.cpp diff --git a/tests/mr/host/mr_ref_tests.cpp b/cpp/tests/mr/host/mr_ref_tests.cpp similarity index 100% rename from tests/mr/host/mr_ref_tests.cpp rename to cpp/tests/mr/host/mr_ref_tests.cpp diff --git a/tests/mr/host/pinned_pool_mr_tests.cpp b/cpp/tests/mr/host/pinned_pool_mr_tests.cpp similarity index 100% rename from tests/mr/host/pinned_pool_mr_tests.cpp rename to cpp/tests/mr/host/pinned_pool_mr_tests.cpp diff --git a/tests/prefetch_tests.cpp b/cpp/tests/prefetch_tests.cpp similarity index 100% rename from tests/prefetch_tests.cpp rename to cpp/tests/prefetch_tests.cpp diff --git a/pyproject.toml b/pyproject.toml index e6fec0296..1712bb14c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,9 @@ -# Copyright (c) 2024, NVIDIA CORPORATION. +# Copyright (c) 2024-2025, NVIDIA CORPORATION. [tool.codespell] # note: pre-commit passes explicit lists of files here, which this skip file list doesn't override - # this is only to allow you to run codespell interactively -skip = "./.git,./build,./python/_skbuild/,.*egg-info.*,./.mypy_cache,./pyproject.toml,./benchmarks/utilities/cxxopts.hpp" +skip = "./.git,./build,./python/_skbuild/,.*egg-info.*,./.mypy_cache,./pyproject.toml,./cpp/benchmarks/utilities/cxxopts.hpp" # ignore short words, and typename parameters like OffsetT ignore-regex = "\\b(.{1,4}|[A-Z]\\w*T)\\b" ignore-words-list = "thirdparty,couldn" diff --git a/python/librmm/CMakeLists.txt b/python/librmm/CMakeLists.txt index 5d25750a9..87b9ad5f8 100644 --- a/python/librmm/CMakeLists.txt +++ b/python/librmm/CMakeLists.txt @@ -35,4 +35,4 @@ set(BUILD_TESTS OFF) set(BUILD_BENCHMARKS OFF) set(CUDA_STATIC_RUNTIME ON) -add_subdirectory(../.. rmm-cpp) +add_subdirectory(../../cpp rmm-cpp) diff --git a/python/rmm/docs/conf.py b/python/rmm/docs/conf.py index b81f309ce..14aa1c2e7 100644 --- a/python/rmm/docs/conf.py +++ b/python/rmm/docs/conf.py @@ -61,7 +61,7 @@ ] # Breathe Configuration -breathe_projects = {"librmm": "../../../doxygen/xml"} +breathe_projects = {"librmm": "../../../cpp/doxygen/xml"} breathe_default_project = "librmm" copybutton_prompt_text = ">>> " From c7a331432f003bcaa8cc45d7bbcbd21a2876565f Mon Sep 17 00:00:00 2001 From: Mike Sarahan Date: Wed, 16 Apr 2025 13:19:18 -0500 Subject: [PATCH 594/675] remove mkdir and test corresponding shared workflow (#1892) This is a tiny cleanup PR to remove one line of vestigial code for mkdir that was moved into the shared workflow. This PR was used to test that functionality. Authors: - Mike Sarahan (https://github.com/msarahan) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1892 --- .github/workflows/pr.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 4aac91f18..0cf1a17e1 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -153,7 +153,6 @@ jobs: arch: '["amd64"]' cuda: '["12.8"]' build_command: | - mkdir -p telemetry-artifacts; sccache --zero-stats; build-all -DBUILD_BENCHMARKS=ON --verbose 2>&1 | tee telemetry-artifacts/build.log; sccache --show-adv-stats | tee telemetry-artifacts/sccache-stats.txt; From ace3fdba520dd616bef730b48d0c6d247ce82b2d Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 21 Apr 2025 12:39:31 -0500 Subject: [PATCH 595/675] Revert "Auto-sync draft PRs" (#1891) Reverts rapidsai/rmm#1890. We now have a quality-of-life feature that does not require a SHA in `/ok to test` if all commits are from trusted authors. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/rmm/pull/1891 --- .github/copy-pr-bot.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/copy-pr-bot.yaml b/.github/copy-pr-bot.yaml index 7052b1a7c..e0ea775aa 100644 --- a/.github/copy-pr-bot.yaml +++ b/.github/copy-pr-bot.yaml @@ -2,4 +2,4 @@ # https://docs.gha-runners.nvidia.com/apps/copy-pr-bot/ enabled: true -auto_sync_draft: true +auto_sync_draft: false From ab23e71ff912956031d09ddd1bd5e4f5cc9d3be3 Mon Sep 17 00:00:00 2001 From: Jaya Venkatesh Date: Tue, 22 Apr 2025 14:54:56 -0700 Subject: [PATCH 596/675] Download build artifacts from Github for CI (#1895) This work is towards moving build artifacts from `downloads.rapids.ai` to Github Artifact Store (see https://github.com/rapidsai/ops/issues/2982) Updates conda and wheel artifact download source from S3 to GitHub across CI scripts, wherever applicable. Uses dynamic temporary paths for wheel downloads returned by `rapids-download-wheels-from-github` instead of using fixed directories, to streamline wheel downloads in the same way as conda downloads. Removes the usage of the `wheel-dir` variable, to directly use the env-var `RAPIDS_WHEEL_BLD_OUTPUT_DIR` for wheel build location Also updates CI workflows to follow `package-name` convention between wheel build and wheel publish jobs. Authors: - Jaya Venkatesh (https://github.com/VenkateshJaya) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1895 --- .github/workflows/build.yaml | 2 ++ .github/workflows/pr.yaml | 2 ++ ci/build_docs.sh | 4 ++-- ci/build_python.sh | 2 +- ci/build_wheel_cpp.sh | 9 ++++----- ci/build_wheel_python.sh | 12 +++++------- ci/test_cpp.sh | 2 +- ci/test_python.sh | 4 ++-- ci/test_wheel.sh | 9 ++++----- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index df620faae..9410bfb1c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -89,6 +89,7 @@ jobs: sha: ${{ inputs.sha }} date: ${{ inputs.date }} script: ci/build_wheel_cpp.sh + package-name: rmm package-type: cpp wheel-build-python: needs: [telemetry-setup, wheel-build-cpp] @@ -100,6 +101,7 @@ jobs: sha: ${{ inputs.sha }} date: ${{ inputs.date }} script: ci/build_wheel_python.sh + package-name: rmm package-type: python wheel-publish-cpp: needs: wheel-build-cpp diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 0cf1a17e1..1b36de140 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -127,6 +127,7 @@ jobs: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request script: ci/build_wheel_cpp.sh + package-name: rmm package-type: cpp wheel-build-python: needs: wheel-build-cpp @@ -135,6 +136,7 @@ jobs: with: build_type: pull-request script: ci/build_wheel_python.sh + package-name: rmm package-type: python wheel-tests: needs: [wheel-build-python, changed-files] diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 16c6e877d..5a197a08d 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -4,8 +4,8 @@ set -euo pipefail rapids-logger "Downloading artifacts from previous jobs" -CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) -PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) +CPP_CHANNEL=$(rapids-download-conda-from-github cpp) +PYTHON_CHANNEL=$(rapids-download-conda-from-github python) rapids-logger "Create test conda environment" diff --git a/ci/build_python.sh b/ci/build_python.sh index 92413ec67..adbbbea19 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -14,7 +14,7 @@ rapids-generate-version > ./VERSION rapids-logger "Begin py build" -CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) +CPP_CHANNEL=$(rapids-download-conda-from-github cpp) sccache --zero-stats diff --git a/ci/build_wheel_cpp.sh b/ci/build_wheel_cpp.sh index db1989166..e3be71737 100755 --- a/ci/build_wheel_cpp.sh +++ b/ci/build_wheel_cpp.sh @@ -4,7 +4,6 @@ set -euo pipefail package_dir="python/librmm" -wheel_dir=${RAPIDS_WHEEL_BLD_OUTPUT_DIR} source rapids-configure-sccache source rapids-date-string @@ -20,12 +19,12 @@ sccache --zero-stats # Creates artifacts directory for telemetry source rapids-telemetry-setup -rapids-telemetry-record build.log rapids-pip-retry wheel . -w "${wheel_dir}" -v --no-deps --disable-pip-version-check +rapids-telemetry-record build.log rapids-pip-retry wheel . -w "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" -v --no-deps --disable-pip-version-check rapids-telemetry-record sccache-stats.txt sccache --show-adv-stats -python -m wheel tags --platform any "${wheel_dir}"/* --remove +python -m wheel tags --platform any "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}"/* --remove -../../ci/validate_wheel.sh "${wheel_dir}" +../../ci/validate_wheel.sh "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" -RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 cpp "${wheel_dir}" +RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 cpp "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index c1e91e2d4..d63d11a2f 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -6,8 +6,6 @@ set -euo pipefail package_name="rmm" package_dir="python/rmm" -wheel_dir=${RAPIDS_WHEEL_BLD_OUTPUT_DIR} - source rapids-configure-sccache source rapids-date-string @@ -16,7 +14,7 @@ rapids-generate-version > ./VERSION pushd "${package_dir}" RAPIDS_PY_CUDA_SUFFIX=$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}") -CPP_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp /tmp/librmm_dist) +CPP_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-github cpp) # ensure 'rmm' wheel builds always use the 'librmm' just built in the same CI run # @@ -37,13 +35,13 @@ rapids-telemetry-record sccache-stats.txt sccache --show-adv-stats EXCLUDE_ARGS=( --exclude "librapids_logger.so" ) -python -m auditwheel repair "${EXCLUDE_ARGS[@]}" -w "${wheel_dir}" dist/* +python -m auditwheel repair "${EXCLUDE_ARGS[@]}" -w "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" dist/* -../../ci/validate_wheel.sh "${wheel_dir}" +../../ci/validate_wheel.sh "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" -RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 python "${wheel_dir}" +RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 python "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" -absolute_wheel_dir=$(realpath "${wheel_dir}") +absolute_wheel_dir=$(realpath "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}") # switch back to the root of the repo and check symbol visibility popd ci/check_symbols.sh "$(echo ${absolute_wheel_dir}/rmm_*.whl)" diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh index 86b2100e3..bf3ac6eb4 100755 --- a/ci/test_cpp.sh +++ b/ci/test_cpp.sh @@ -8,7 +8,7 @@ cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../ . /opt/conda/etc/profile.d/conda.sh -CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) +CPP_CHANNEL=$(rapids-download-conda-from-github cpp) RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"}/ mkdir -p "${RAPIDS_TESTS_DIR}" diff --git a/ci/test_python.sh b/ci/test_python.sh index b2934f261..8a98450bc 100755 --- a/ci/test_python.sh +++ b/ci/test_python.sh @@ -11,8 +11,8 @@ rapids-logger "Create test conda environment" . /opt/conda/etc/profile.d/conda.sh rapids-logger "Downloading artifacts from previous jobs" -CPP_CHANNEL=$(rapids-download-conda-from-s3 cpp) -PYTHON_CHANNEL=$(rapids-download-conda-from-s3 python) +CPP_CHANNEL=$(rapids-download-conda-from-github cpp) +PYTHON_CHANNEL=$(rapids-download-conda-from-github python) rapids-dependency-file-generator \ --output conda \ diff --git a/ci/test_wheel.sh b/ci/test_wheel.sh index ef53afa12..6a2f0a507 100755 --- a/ci/test_wheel.sh +++ b/ci/test_wheel.sh @@ -4,9 +4,8 @@ set -eou pipefail RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}")" -WHEELHOUSE="${PWD}/dist/" -RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp "${WHEELHOUSE}" -RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 python "${WHEELHOUSE}" +CPP_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-github cpp) +PYTHON_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-github python) # generate constraints (possibly pinning to oldest support versions of dependencies) rapids-generate-pip-constraints test_python ./constraints.txt @@ -15,7 +14,7 @@ rapids-generate-pip-constraints test_python ./constraints.txt rapids-pip-retry install \ -v \ --constraint ./constraints.txt \ - "$(echo "${WHEELHOUSE}"/librmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)" \ - "$(echo "${WHEELHOUSE}"/rmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)[test]" + "$(echo "${CPP_WHEELHOUSE}"/librmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)" \ + "$(echo "${PYTHON_WHEELHOUSE}"/rmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)[test]" python -m pytest ./python/rmm/rmm/tests From 1704990e6ecde53b827755986229977d2afe7c36 Mon Sep 17 00:00:00 2001 From: Jaya Venkatesh Date: Thu, 24 Apr 2025 16:43:18 -0700 Subject: [PATCH 597/675] Publish wheels and conda packages from Github Artifacts (#1897) Testing the new gha-tools scripts (https://github.com/rapidsai/gha-tools/pull/159) to publish wheel and conda artifacts from Github Artifact Store to Anaconda and Pypi. Associated with (https://github.com/rapidsai/ops/issues/2982) Authors: - Jaya Venkatesh (https://github.com/VenkateshJaya) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1897 --- .github/workflows/build.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9410bfb1c..a2753eff8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -58,7 +58,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@publish-from-github with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -106,7 +106,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@publish-from-github with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -117,7 +117,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@publish-from-github with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} From 605feb4502b522f18e304796187b1e327d83da48 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 24 Apr 2025 19:44:32 -0500 Subject: [PATCH 598/675] Revert "Publish wheels and conda packages from Github Artifacts" (#1898) Reverts rapidsai/rmm#1897. This was meant as a test of the branch build workflow. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1898 --- .github/workflows/build.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a2753eff8..9410bfb1c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -58,7 +58,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@publish-from-github + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-25.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -106,7 +106,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@publish-from-github + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -117,7 +117,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@publish-from-github + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} From 7506cf70f53c2163111349136286c75ffc269670 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Wed, 30 Apr 2025 15:08:33 -0400 Subject: [PATCH 599/675] DOC v25.08 Updates [skip ci] --- .../cuda11.8-conda/devcontainer.json | 6 ++--- .devcontainer/cuda11.8-pip/devcontainer.json | 6 ++--- .../cuda12.8-conda/devcontainer.json | 6 ++--- .devcontainer/cuda12.8-pip/devcontainer.json | 6 ++--- .github/workflows/build.yaml | 16 ++++++------- .github/workflows/pr.yaml | 24 +++++++++---------- .github/workflows/test.yaml | 6 ++--- .../trigger-breaking-change-alert.yaml | 2 +- VERSION | 2 +- cpp/examples/versions.cmake | 2 +- dependencies.yaml | 12 +++++----- python/rmm/pyproject.toml | 4 ++-- 12 files changed, 46 insertions(+), 46 deletions(-) diff --git a/.devcontainer/cuda11.8-conda/devcontainer.json b/.devcontainer/cuda11.8-conda/devcontainer.json index 623564437..8deaf6f9f 100644 --- a/.devcontainer/cuda11.8-conda/devcontainer.json +++ b/.devcontainer/cuda11.8-conda/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:25.06-cpp-cuda11.8-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.08-cpp-cuda11.8-mambaforge-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.06-cuda11.8-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.08-cuda11.8-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.6": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.8": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda11.8-pip/devcontainer.json b/.devcontainer/cuda11.8-pip/devcontainer.json index 00e38435d..31a095036 100644 --- a/.devcontainer/cuda11.8-pip/devcontainer.json +++ b/.devcontainer/cuda11.8-pip/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "11.8", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:25.06-cpp-cuda11.8-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.08-cpp-cuda11.8-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.06-cuda11.8-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.08-cuda11.8-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.6": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.8": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.8-conda/devcontainer.json b/.devcontainer/cuda12.8-conda/devcontainer.json index faa81b709..5cd35bc88 100644 --- a/.devcontainer/cuda12.8-conda/devcontainer.json +++ b/.devcontainer/cuda12.8-conda/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "12.8", "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:25.06-cpp-mambaforge-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.08-cpp-mambaforge-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.06-cuda12.8-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.08-cuda12.8-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.6": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.8": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.devcontainer/cuda12.8-pip/devcontainer.json b/.devcontainer/cuda12.8-pip/devcontainer.json index e89ed2218..ad9201d16 100644 --- a/.devcontainer/cuda12.8-pip/devcontainer.json +++ b/.devcontainer/cuda12.8-pip/devcontainer.json @@ -5,17 +5,17 @@ "args": { "CUDA": "12.8", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:25.06-cpp-cuda12.8-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.08-cpp-cuda12.8-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.06-cuda12.8-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.08-cuda12.8-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.6": {} + "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.8": {} }, "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9410bfb1c..b864cf600 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -40,7 +40,7 @@ jobs: cpp-build: needs: [telemetry-setup] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -49,7 +49,7 @@ jobs: python-build: needs: [telemetry-setup, cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -58,7 +58,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-25.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: if: github.ref_type == 'branch' needs: [python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -81,7 +81,7 @@ jobs: wheel-build-cpp: needs: [telemetry-setup] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.08 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -94,7 +94,7 @@ jobs: wheel-build-python: needs: [telemetry-setup, wheel-build-cpp] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -106,7 +106,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -117,7 +117,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.08 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 1b36de140..ad52ac1a3 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -26,7 +26,7 @@ jobs: - devcontainer - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-25.08 if: always() with: needs: ${{ toJSON(needs) }} @@ -57,7 +57,7 @@ jobs: needs: - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-25.08 with: files_yaml: | test_cpp: @@ -79,40 +79,40 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-25.08 with: enable_check_generated_files: false ignored_pr_jobs: "telemetry-summarize" conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.08 with: build_type: pull-request conda-cpp-tests: needs: [conda-cpp-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.08 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.08 with: build_type: pull-request conda-python-tests: needs: [conda-python-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.08 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.08 with: build_type: pull-request node_type: "gpu-l4-latest-1" @@ -122,7 +122,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.08 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -132,7 +132,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.08 with: build_type: pull-request script: ci/build_wheel_python.sh @@ -141,7 +141,7 @@ jobs: wheel-tests: needs: [wheel-build-python, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.08 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request @@ -150,7 +150,7 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-25.08 with: arch: '["amd64"]' cuda: '["12.8"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7744b7263..057dbc931 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,7 +19,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.08 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} @@ -27,7 +27,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.08 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} @@ -35,7 +35,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.08 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/trigger-breaking-change-alert.yaml b/.github/workflows/trigger-breaking-change-alert.yaml index 475380cb6..593fcb108 100644 --- a/.github/workflows/trigger-breaking-change-alert.yaml +++ b/.github/workflows/trigger-breaking-change-alert.yaml @@ -12,7 +12,7 @@ jobs: trigger-notifier: if: contains(github.event.pull_request.labels.*.name, 'breaking') secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@branch-25.08 with: sender_login: ${{ github.event.sender.login }} sender_avatar: ${{ github.event.sender.avatar_url }} diff --git a/VERSION b/VERSION index cc83d7ab4..3af4bda02 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -25.06.00 +25.08.00 diff --git a/cpp/examples/versions.cmake b/cpp/examples/versions.cmake index feac5e0a9..6f8d2ff28 100644 --- a/cpp/examples/versions.cmake +++ b/cpp/examples/versions.cmake @@ -12,4 +12,4 @@ # the License. # ============================================================================= -set(RMM_TAG branch-25.06) +set(RMM_TAG branch-25.08) diff --git a/dependencies.yaml b/dependencies.yaml index 031cc0022..467036c53 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -191,7 +191,7 @@ dependencies: common: - output_types: conda packages: - - &librmm_unsuffixed librmm==25.6.*,>=0.0.0a0 + - &librmm_unsuffixed librmm==25.8.*,>=0.0.0a0 - output_types: requirements packages: # pip recognizes the index as a global option for the requirements.txt file @@ -205,12 +205,12 @@ dependencies: cuda: "12.*" cuda_suffixed: "true" packages: - - librmm-cu12==25.6.*,>=0.0.0a0 + - librmm-cu12==25.8.*,>=0.0.0a0 - matrix: cuda: "11.*" cuda_suffixed: "true" packages: - - librmm-cu11==25.6.*,>=0.0.0a0 + - librmm-cu11==25.8.*,>=0.0.0a0 - matrix: packages: - *librmm_unsuffixed @@ -218,17 +218,17 @@ dependencies: common: - output_types: conda packages: - - rmm==25.6.*,>=0.0.0a0 + - rmm==25.8.*,>=0.0.0a0 depends_on_librmm_tests: common: - output_types: conda packages: - - librmm-tests==25.6.*,>=0.0.0a0 + - librmm-tests==25.8.*,>=0.0.0a0 depends_on_librmm_example: common: - output_types: conda packages: - - librmm-example==25.6.*,>=0.0.0a0 + - librmm-example==25.8.*,>=0.0.0a0 checks: common: - output_types: [conda, requirements] diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 0b23cfc19..668c6f739 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -31,7 +31,7 @@ license = { text = "Apache-2.0" } requires-python = ">=3.10" dependencies = [ "cuda-python>=11.8.5,<12.0a0", - "librmm==25.6.*,>=0.0.0a0", + "librmm==25.8.*,>=0.0.0a0", "numpy>=1.23,<3.0a0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. classifiers = [ @@ -78,7 +78,7 @@ requires = [ "cmake>=3.30.4", "cuda-python>=11.8.5,<12.0a0", "cython>=3.0.0", - "librmm==25.6.*,>=0.0.0a0", + "librmm==25.8.*,>=0.0.0a0", "ninja", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. From 0c9fe21266680973c390721e86454a885b444869 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 2 May 2025 11:37:16 -0500 Subject: [PATCH 600/675] Add support for Python 3.13 (#1851) Contributes to https://github.com/rapidsai/build-planning/issues/120 This PR adds support for Python 3.13. ## Notes for Reviewers This is part of ongoing work to add Python 3.13 support across RAPIDS. It temporarily introduces a build/test matrix including Python 3.13, from https://github.com/rapidsai/shared-workflows/pull/268. A follow-up PR will revert back to pointing at the `branch-25.04` branch of `shared-workflows` once all RAPIDS repos have added Python 3.13 support. ### This will fail until all dependencies have been updated to Python 3.13 CI here is expected to fail until all of this project's upstream dependencies support Python 3.13. This can be merged whenever all CI jobs are passing. Authors: - Bradley Dice (https://github.com/bdice) - Gil Forsyth (https://github.com/gforsyth) Approvers: - Gil Forsyth (https://github.com/gforsyth) URL: https://github.com/rapidsai/rmm/pull/1851 --- .github/workflows/build.yaml | 16 ++++++------- .github/workflows/pr.yaml | 24 +++++++++---------- .github/workflows/test.yaml | 6 ++--- .../trigger-breaking-change-alert.yaml | 2 +- README.md | 2 +- .../all_cuda-118_arch-aarch64.yaml | 4 ++-- .../all_cuda-118_arch-x86_64.yaml | 4 ++-- .../all_cuda-128_arch-aarch64.yaml | 4 ++-- .../all_cuda-128_arch-x86_64.yaml | 4 ++-- dependencies.yaml | 10 +++++--- python/rmm/pyproject.toml | 3 ++- 11 files changed, 42 insertions(+), 37 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9410bfb1c..802081962 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -40,7 +40,7 @@ jobs: cpp-build: needs: [telemetry-setup] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@python-3.13 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -49,7 +49,7 @@ jobs: python-build: needs: [telemetry-setup, cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@python-3.13 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -58,7 +58,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@python-3.13 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: if: github.ref_type == 'branch' needs: [python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@python-3.13 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -81,7 +81,7 @@ jobs: wheel-build-cpp: needs: [telemetry-setup] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@python-3.13 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -94,7 +94,7 @@ jobs: wheel-build-python: needs: [telemetry-setup, wheel-build-cpp] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@python-3.13 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -106,7 +106,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@python-3.13 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -117,7 +117,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@python-3.13 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 1b36de140..485ac5c04 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -26,7 +26,7 @@ jobs: - devcontainer - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@python-3.13 if: always() with: needs: ${{ toJSON(needs) }} @@ -57,7 +57,7 @@ jobs: needs: - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@python-3.13 with: files_yaml: | test_cpp: @@ -79,40 +79,40 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@python-3.13 with: enable_check_generated_files: false ignored_pr_jobs: "telemetry-summarize" conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@python-3.13 with: build_type: pull-request conda-cpp-tests: needs: [conda-cpp-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@python-3.13 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@python-3.13 with: build_type: pull-request conda-python-tests: needs: [conda-python-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@python-3.13 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@python-3.13 with: build_type: pull-request node_type: "gpu-l4-latest-1" @@ -122,7 +122,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@python-3.13 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -132,7 +132,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@python-3.13 with: build_type: pull-request script: ci/build_wheel_python.sh @@ -141,7 +141,7 @@ jobs: wheel-tests: needs: [wheel-build-python, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@python-3.13 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request @@ -150,7 +150,7 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@python-3.13 with: arch: '["amd64"]' cuda: '["12.8"]' diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7744b7263..4f5ea66fd 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,7 +19,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@python-3.13 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} @@ -27,7 +27,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@python-3.13 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} @@ -35,7 +35,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@python-3.13 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/trigger-breaking-change-alert.yaml b/.github/workflows/trigger-breaking-change-alert.yaml index 475380cb6..e9399716e 100644 --- a/.github/workflows/trigger-breaking-change-alert.yaml +++ b/.github/workflows/trigger-breaking-change-alert.yaml @@ -12,7 +12,7 @@ jobs: trigger-notifier: if: contains(github.event.pull_request.labels.*.name, 'breaking') secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@branch-25.06 + uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@python-3.13 with: sender_login: ${{ github.event.sender.login }} sender_avatar: ${{ github.event.sender.avatar_url }} diff --git a/README.md b/README.md index 6e6fdc43a..3c0448113 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ conda install -c rapidsai -c conda-forge -c nvidia rmm cuda-version=12.8 We also provide [nightly conda packages](https://anaconda.org/rapidsai-nightly) built from the HEAD of our latest development branch. -Note: RMM is supported only on Linux, and only tested with Python versions 3.10, 3.11, and 3.12. +Note: RMM is supported only on Linux, and only tested with Python versions 3.10, 3.11, 3.12, and 3.13. Note: The RMM package from conda requires building with GCC 9 or later. Otherwise, your application may fail to build. diff --git a/conda/environments/all_cuda-118_arch-aarch64.yaml b/conda/environments/all_cuda-118_arch-aarch64.yaml index d0a88b0f5..671ddd808 100644 --- a/conda/environments/all_cuda-118_arch-aarch64.yaml +++ b/conda/environments/all_cuda-118_arch-aarch64.yaml @@ -24,14 +24,14 @@ dependencies: - make - nbsphinx - ninja -- numba>=0.59.1,<0.61.0a0 +- numba>=0.59.1,<0.62.0a0 - numpy>=1.23,<3.0a0 - numpydoc - nvcc_linux-aarch64=11.8 - pre-commit - pytest - pytest-cov -- python>=3.10,<3.13 +- python>=3.10,<3.14 - rapids-build-backend>=0.3.0,<0.4.0.dev0 - rapids-logger==0.1.*,>=0.0.0a0 - scikit-build-core >=0.10.0 diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index fd68b4c75..5d90cc60c 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -24,14 +24,14 @@ dependencies: - make - nbsphinx - ninja -- numba>=0.59.1,<0.61.0a0 +- numba>=0.59.1,<0.62.0a0 - numpy>=1.23,<3.0a0 - numpydoc - nvcc_linux-64=11.8 - pre-commit - pytest - pytest-cov -- python>=3.10,<3.13 +- python>=3.10,<3.14 - rapids-build-backend>=0.3.0,<0.4.0.dev0 - rapids-logger==0.1.*,>=0.0.0a0 - scikit-build-core >=0.10.0 diff --git a/conda/environments/all_cuda-128_arch-aarch64.yaml b/conda/environments/all_cuda-128_arch-aarch64.yaml index c8d667d22..16f8e9f02 100644 --- a/conda/environments/all_cuda-128_arch-aarch64.yaml +++ b/conda/environments/all_cuda-128_arch-aarch64.yaml @@ -24,13 +24,13 @@ dependencies: - make - nbsphinx - ninja -- numba>=0.59.1,<0.61.0a0 +- numba>=0.59.1,<0.62.0a0 - numpy>=1.23,<3.0a0 - numpydoc - pre-commit - pytest - pytest-cov -- python>=3.10,<3.13 +- python>=3.10,<3.14 - rapids-build-backend>=0.3.0,<0.4.0.dev0 - rapids-logger==0.1.*,>=0.0.0a0 - scikit-build-core >=0.10.0 diff --git a/conda/environments/all_cuda-128_arch-x86_64.yaml b/conda/environments/all_cuda-128_arch-x86_64.yaml index 0b1f61546..25f4246d5 100644 --- a/conda/environments/all_cuda-128_arch-x86_64.yaml +++ b/conda/environments/all_cuda-128_arch-x86_64.yaml @@ -24,13 +24,13 @@ dependencies: - make - nbsphinx - ninja -- numba>=0.59.1,<0.61.0a0 +- numba>=0.59.1,<0.62.0a0 - numpy>=1.23,<3.0a0 - numpydoc - pre-commit - pytest - pytest-cov -- python>=3.10,<3.13 +- python>=3.10,<3.14 - rapids-build-backend>=0.3.0,<0.4.0.dev0 - rapids-logger==0.1.*,>=0.0.0a0 - scikit-build-core >=0.10.0 diff --git a/dependencies.yaml b/dependencies.yaml index 031cc0022..4b1791cc7 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -308,7 +308,7 @@ dependencies: - ipython - make - nbsphinx - - numba>=0.59.1,<0.61.0a0 + - &numba numba>=0.59.1,<0.62.0a0 - numpydoc # this pin can be reverted when https://github.com/spatialaudio/nbsphinx/issues/825 is resolved - sphinx<8.2.0 @@ -332,8 +332,12 @@ dependencies: packages: - python=3.12 - matrix: + py: "3.13" packages: - - python>=3.10,<3.13 + - python=3.13 + - matrix: + packages: + - python>=3.10,<3.14 run: common: - output_types: [conda, requirements, pyproject] @@ -358,7 +362,7 @@ dependencies: common: - output_types: [conda, requirements, pyproject] packages: - - numba>=0.59.1,<0.61.0a0 + - *numba - pytest - pytest-cov specific: diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index 0b23cfc19..230fffb3f 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -43,11 +43,12 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ] [project.optional-dependencies] test = [ - "numba>=0.59.1,<0.61.0a0", + "numba>=0.59.1,<0.62.0a0", "pytest", "pytest-cov", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. From a66a7ea98362205788ed05675924d54afa312324 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 7 May 2025 11:11:13 -0500 Subject: [PATCH 601/675] Fix cpp wheel name to librmm. (#1903) The C++ wheel should be named `librmm` instead of `rmm`. Other repos already do this (like `libcudf`, `libcuml`, ...). Authors: - Bradley Dice (https://github.com/bdice) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1903 --- .github/workflows/build.yaml | 4 ++-- .github/workflows/pr.yaml | 2 +- ci/build_wheel_cpp.sh | 3 ++- ci/build_wheel_python.sh | 4 ++-- ci/test_wheel.sh | 8 ++++---- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 802081962..76dfcf5cd 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -89,7 +89,7 @@ jobs: sha: ${{ inputs.sha }} date: ${{ inputs.date }} script: ci/build_wheel_cpp.sh - package-name: rmm + package-name: librmm package-type: cpp wheel-build-python: needs: [telemetry-setup, wheel-build-cpp] @@ -112,7 +112,7 @@ jobs: branch: ${{ inputs.branch }} sha: ${{ inputs.sha }} date: ${{ inputs.date }} - package-name: rmm + package-name: librmm package-type: cpp wheel-publish-python: needs: wheel-build-python diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 485ac5c04..f81faa33f 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -127,7 +127,7 @@ jobs: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request script: ci/build_wheel_cpp.sh - package-name: rmm + package-name: librmm package-type: cpp wheel-build-python: needs: wheel-build-cpp diff --git a/ci/build_wheel_cpp.sh b/ci/build_wheel_cpp.sh index e3be71737..26454f0b8 100755 --- a/ci/build_wheel_cpp.sh +++ b/ci/build_wheel_cpp.sh @@ -3,6 +3,7 @@ set -euo pipefail +package_name="librmm" package_dir="python/librmm" source rapids-configure-sccache @@ -27,4 +28,4 @@ python -m wheel tags --platform any "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}"/* --remove ../../ci/validate_wheel.sh "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" -RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 cpp "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" +RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 cpp "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index d63d11a2f..b06eac6a6 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -14,13 +14,13 @@ rapids-generate-version > ./VERSION pushd "${package_dir}" RAPIDS_PY_CUDA_SUFFIX=$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}") -CPP_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-github cpp) +LIBRMM_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="librmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-github cpp) # ensure 'rmm' wheel builds always use the 'librmm' just built in the same CI run # # using env variable PIP_CONSTRAINT is necessary to ensure the constraints # are used when created the isolated build environment -echo "librmm-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo "${CPP_WHEELHOUSE}"/librmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)" > ./build-constraints.txt +echo "librmm-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo "${LIBRMM_WHEELHOUSE}"/librmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)" > ./build-constraints.txt sccache --zero-stats diff --git a/ci/test_wheel.sh b/ci/test_wheel.sh index 6a2f0a507..02ec6cf7c 100755 --- a/ci/test_wheel.sh +++ b/ci/test_wheel.sh @@ -4,8 +4,8 @@ set -eou pipefail RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}")" -CPP_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-github cpp) -PYTHON_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-github python) +LIBRMM_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="librmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-github cpp) +RMM_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-github python) # generate constraints (possibly pinning to oldest support versions of dependencies) rapids-generate-pip-constraints test_python ./constraints.txt @@ -14,7 +14,7 @@ rapids-generate-pip-constraints test_python ./constraints.txt rapids-pip-retry install \ -v \ --constraint ./constraints.txt \ - "$(echo "${CPP_WHEELHOUSE}"/librmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)" \ - "$(echo "${PYTHON_WHEELHOUSE}"/rmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)[test]" + "$(echo "${LIBRMM_WHEELHOUSE}"/librmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)" \ + "$(echo "${RMM_WHEELHOUSE}"/rmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)[test]" python -m pytest ./python/rmm/rmm/tests From dbd8cc7a5f2230a21551670106d4bcd5e507441e Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 8 May 2025 09:37:42 -0500 Subject: [PATCH 602/675] Build and test with CUDA 12.9.0 (#1907) This PR uses CUDA 12.9.0 to build and test. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - https://github.com/jakirkham - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/rmm/pull/1907 --- .../devcontainer.json | 8 +++--- .../devcontainer.json | 10 +++---- .github/workflows/build.yaml | 16 ++++++------ .github/workflows/pr.yaml | 26 +++++++++---------- .github/workflows/test.yaml | 6 ++--- .../trigger-breaking-change-alert.yaml | 2 +- README.md | 4 +-- ...64.yaml => all_cuda-129_arch-aarch64.yaml} | 4 +-- ..._64.yaml => all_cuda-129_arch-x86_64.yaml} | 4 +-- dependencies.yaml | 6 ++++- 10 files changed, 45 insertions(+), 41 deletions(-) rename .devcontainer/{cuda12.8-conda => cuda12.9-conda}/devcontainer.json (91%) rename .devcontainer/{cuda12.8-pip => cuda12.9-pip}/devcontainer.json (87%) rename conda/environments/{all_cuda-128_arch-aarch64.yaml => all_cuda-129_arch-aarch64.yaml} (94%) rename conda/environments/{all_cuda-128_arch-x86_64.yaml => all_cuda-129_arch-x86_64.yaml} (94%) diff --git a/.devcontainer/cuda12.8-conda/devcontainer.json b/.devcontainer/cuda12.9-conda/devcontainer.json similarity index 91% rename from .devcontainer/cuda12.8-conda/devcontainer.json rename to .devcontainer/cuda12.9-conda/devcontainer.json index faa81b709..6836ab3d1 100644 --- a/.devcontainer/cuda12.8-conda/devcontainer.json +++ b/.devcontainer/cuda12.9-conda/devcontainer.json @@ -3,7 +3,7 @@ "context": "${localWorkspaceFolder}/.devcontainer", "dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile", "args": { - "CUDA": "12.8", + "CUDA": "12.9", "PYTHON_PACKAGE_MANAGER": "conda", "BASE": "rapidsai/devcontainers:25.06-cpp-mambaforge-ubuntu22.04" } @@ -11,7 +11,7 @@ "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.06-cuda12.8-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.06-cuda12.9-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { @@ -20,7 +20,7 @@ "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" ], - "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config,conda/pkgs,conda/${localWorkspaceFolderBasename}-cuda12.8-envs}"], + "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config,conda/pkgs,conda/${localWorkspaceFolderBasename}-cuda12.9-envs}"], "postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"], "workspaceFolder": "/home/coder", "workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent", @@ -29,7 +29,7 @@ "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.conda/pkgs,target=/home/coder/.conda/pkgs,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.conda/${localWorkspaceFolderBasename}-cuda12.8-envs,target=/home/coder/.conda/envs,type=bind,consistency=consistent" + "source=${localWorkspaceFolder}/../.conda/${localWorkspaceFolderBasename}-cuda12.9-envs,target=/home/coder/.conda/envs,type=bind,consistency=consistent" ], "customizations": { "vscode": { diff --git a/.devcontainer/cuda12.8-pip/devcontainer.json b/.devcontainer/cuda12.9-pip/devcontainer.json similarity index 87% rename from .devcontainer/cuda12.8-pip/devcontainer.json rename to .devcontainer/cuda12.9-pip/devcontainer.json index e89ed2218..d64a5f6b0 100644 --- a/.devcontainer/cuda12.8-pip/devcontainer.json +++ b/.devcontainer/cuda12.9-pip/devcontainer.json @@ -3,15 +3,15 @@ "context": "${localWorkspaceFolder}/.devcontainer", "dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile", "args": { - "CUDA": "12.8", + "CUDA": "12.9", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:25.06-cpp-cuda12.8-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.06-cpp-cuda12.9-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.06-cuda12.8-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.06-cuda12.9-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { @@ -20,7 +20,7 @@ "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" ], - "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config/pip,local/share/${localWorkspaceFolderBasename}-cuda12.8-venvs}"], + "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config/pip,local/share/${localWorkspaceFolderBasename}-cuda12.9-venvs}"], "postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"], "workspaceFolder": "/home/coder", "workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent", @@ -28,7 +28,7 @@ "source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.local/share/${localWorkspaceFolderBasename}-cuda12.8-venvs,target=/home/coder/.local/share/venvs,type=bind,consistency=consistent" + "source=${localWorkspaceFolder}/../.local/share/${localWorkspaceFolderBasename}-cuda12.9-venvs,target=/home/coder/.local/share/venvs,type=bind,consistency=consistent" ], "customizations": { "vscode": { diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 76dfcf5cd..9c735d505 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -40,7 +40,7 @@ jobs: cpp-build: needs: [telemetry-setup] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@cuda-12.9.0 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -49,7 +49,7 @@ jobs: python-build: needs: [telemetry-setup, cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@cuda-12.9.0 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -58,7 +58,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@cuda-12.9.0 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: if: github.ref_type == 'branch' needs: [python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@cuda-12.9.0 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -81,7 +81,7 @@ jobs: wheel-build-cpp: needs: [telemetry-setup] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.9.0 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -94,7 +94,7 @@ jobs: wheel-build-python: needs: [telemetry-setup, wheel-build-cpp] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.9.0 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -106,7 +106,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@cuda-12.9.0 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -117,7 +117,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@cuda-12.9.0 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index f81faa33f..577eb528b 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -26,7 +26,7 @@ jobs: - devcontainer - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@cuda-12.9.0 if: always() with: needs: ${{ toJSON(needs) }} @@ -57,7 +57,7 @@ jobs: needs: - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@cuda-12.9.0 with: files_yaml: | test_cpp: @@ -79,40 +79,40 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@cuda-12.9.0 with: enable_check_generated_files: false ignored_pr_jobs: "telemetry-summarize" conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@cuda-12.9.0 with: build_type: pull-request conda-cpp-tests: needs: [conda-cpp-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-12.9.0 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@cuda-12.9.0 with: build_type: pull-request conda-python-tests: needs: [conda-python-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@cuda-12.9.0 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@cuda-12.9.0 with: build_type: pull-request node_type: "gpu-l4-latest-1" @@ -122,7 +122,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.9.0 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -132,7 +132,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.9.0 with: build_type: pull-request script: ci/build_wheel_python.sh @@ -141,7 +141,7 @@ jobs: wheel-tests: needs: [wheel-build-python, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@cuda-12.9.0 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request @@ -150,10 +150,10 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@cuda-12.9.0 with: arch: '["amd64"]' - cuda: '["12.8"]' + cuda: '["12.9"]' build_command: | sccache --zero-stats; build-all -DBUILD_BENCHMARKS=ON --verbose 2>&1 | tee telemetry-artifacts/build.log; diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4f5ea66fd..d4ab68db4 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,7 +19,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-12.9.0 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} @@ -27,7 +27,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@cuda-12.9.0 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} @@ -35,7 +35,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@cuda-12.9.0 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/trigger-breaking-change-alert.yaml b/.github/workflows/trigger-breaking-change-alert.yaml index e9399716e..83deb407b 100644 --- a/.github/workflows/trigger-breaking-change-alert.yaml +++ b/.github/workflows/trigger-breaking-change-alert.yaml @@ -12,7 +12,7 @@ jobs: trigger-notifier: if: contains(github.event.pull_request.labels.*.name, 'breaking') secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@python-3.13 + uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@cuda-12.9.0 with: sender_login: ${{ github.event.sender.login }} sender_avatar: ${{ github.event.sender.avatar_url }} diff --git a/README.md b/README.md index 3c0448113..fbedee4be 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ RMM can be installed with conda. You can get a minimal conda installation with [ Install RMM with: ```bash -conda install -c rapidsai -c conda-forge -c nvidia rmm cuda-version=12.8 +conda install -c rapidsai -c conda-forge -c nvidia rmm cuda-version=12.9 ``` We also provide [nightly conda packages](https://anaconda.org/rapidsai-nightly) built from the HEAD @@ -90,7 +90,7 @@ $ cd rmm - Create the conda development environment `rmm_dev` ```bash # create the conda environment (assuming in base `rmm` directory) -$ conda env create --name rmm_dev --file conda/environments/all_cuda-128_arch-x86_64.yaml +$ conda env create --name rmm_dev --file conda/environments/all_cuda-129_arch-x86_64.yaml # activate the environment $ conda activate rmm_dev ``` diff --git a/conda/environments/all_cuda-128_arch-aarch64.yaml b/conda/environments/all_cuda-129_arch-aarch64.yaml similarity index 94% rename from conda/environments/all_cuda-128_arch-aarch64.yaml rename to conda/environments/all_cuda-129_arch-aarch64.yaml index 16f8e9f02..0f92e6497 100644 --- a/conda/environments/all_cuda-128_arch-aarch64.yaml +++ b/conda/environments/all_cuda-129_arch-aarch64.yaml @@ -12,7 +12,7 @@ dependencies: - cmake>=3.30.4 - cuda-nvcc - cuda-python>=12.6.2,<13.0a0 -- cuda-version=12.8 +- cuda-version=12.9 - cxx-compiler - cython>=3.0.0 - doxygen=1.9.1 @@ -39,4 +39,4 @@ dependencies: - sphinx<8.2.0 - sphinx_rtd_theme - sysroot_linux-aarch64==2.28 -name: all_cuda-128_arch-aarch64 +name: all_cuda-129_arch-aarch64 diff --git a/conda/environments/all_cuda-128_arch-x86_64.yaml b/conda/environments/all_cuda-129_arch-x86_64.yaml similarity index 94% rename from conda/environments/all_cuda-128_arch-x86_64.yaml rename to conda/environments/all_cuda-129_arch-x86_64.yaml index 25f4246d5..ceca68767 100644 --- a/conda/environments/all_cuda-128_arch-x86_64.yaml +++ b/conda/environments/all_cuda-129_arch-x86_64.yaml @@ -12,7 +12,7 @@ dependencies: - cmake>=3.30.4 - cuda-nvcc - cuda-python>=12.6.2,<13.0a0 -- cuda-version=12.8 +- cuda-version=12.9 - cxx-compiler - cython>=3.0.0 - doxygen=1.9.1 @@ -39,4 +39,4 @@ dependencies: - sphinx<8.2.0 - sphinx_rtd_theme - sysroot_linux-64==2.28 -name: all_cuda-128_arch-x86_64 +name: all_cuda-129_arch-x86_64 diff --git a/dependencies.yaml b/dependencies.yaml index 4b1791cc7..2804c9ed5 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -3,7 +3,7 @@ files: all: output: conda matrix: - cuda: ["11.8", "12.8"] + cuda: ["11.8", "12.9"] arch: [x86_64, aarch64] includes: - build @@ -280,6 +280,10 @@ dependencies: cuda: "12.8" packages: - cuda-version=12.8 + - matrix: + cuda: "12.9" + packages: + - cuda-version=12.9 cuda: specific: - output_types: conda From 8e19009fbe5567962fb6f4fd27d1e203e9fa3b31 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Sun, 11 May 2025 08:00:02 -0400 Subject: [PATCH 603/675] Convert part of RMM to a precompiled library (#1896) This PR is a starting point for https://github.com/rapidsai/rmm/issues/1779. It converts RMM to a precompiled shared library, and moves some implementations into `src/` files. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Robert Maynard (https://github.com/robertmaynard) - Vyas Ramasubramani (https://github.com/vyasr) - Matthew Murray (https://github.com/Matt711) URL: https://github.com/rapidsai/rmm/pull/1896 --- ci/build_wheel_python.sh | 6 +- conda/recipes/librmm/recipe.yaml | 12 ++++ cpp/CMakeLists.txt | 33 +++++---- cpp/include/rmm/aligned.hpp | 42 +++--------- cpp/include/rmm/cuda_device.hpp | 51 +++----------- cpp/include/rmm/cuda_stream.hpp | 42 +++--------- cpp/include/rmm/cuda_stream_pool.hpp | 24 ++----- cpp/include/rmm/cuda_stream_view.hpp | 83 +++++++---------------- cpp/src/aligned.cpp | 53 +++++++++++++++ cpp/src/cuda_device.cpp | 70 +++++++++++++++++++ cpp/src/cuda_stream.cpp | 59 ++++++++++++++++ cpp/src/cuda_stream_pool.cpp | 42 ++++++++++++ cpp/src/cuda_stream_view.cpp | 73 ++++++++++++++++++++ python/librmm/librmm/load.py | 77 +++++++++++++++++++-- python/rmm/rmm/librmm/memory_resource.pxd | 2 + 15 files changed, 470 insertions(+), 199 deletions(-) create mode 100644 cpp/src/aligned.cpp create mode 100644 cpp/src/cuda_device.cpp create mode 100644 cpp/src/cuda_stream.cpp create mode 100644 cpp/src/cuda_stream_pool.cpp create mode 100644 cpp/src/cuda_stream_view.cpp diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index b06eac6a6..65db43e1a 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -34,8 +34,12 @@ rapids-telemetry-record sccache-stats.txt sccache --show-adv-stats EXCLUDE_ARGS=( --exclude "librapids_logger.so" + --exclude "librmm.so" ) -python -m auditwheel repair "${EXCLUDE_ARGS[@]}" -w "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" dist/* +python -m auditwheel repair \ + "${EXCLUDE_ARGS[@]}" \ + -w "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" \ + dist/* ../../ci/validate_wheel.sh "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" diff --git a/conda/recipes/librmm/recipe.yaml b/conda/recipes/librmm/recipe.yaml index 855f737d3..f4fff92dc 100644 --- a/conda/recipes/librmm/recipe.yaml +++ b/conda/recipes/librmm/recipe.yaml @@ -69,19 +69,31 @@ outputs: - cmake --install cpp/build dynamic_linking: overlinking_behavior: "error" + prefix_detection: + ignore: + # See https://github.com/rapidsai/build-planning/issues/160 + - lib/librmm.so requirements: build: - cmake ${{ cmake_version }} + - ${{ stdlib("c") }} host: - cuda-version =${{ cuda_version }} + - if: cuda_major == "11" + then: cudatoolkit + else: cuda-cudart-dev run: - ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }} - if: cuda_major == "11" then: cudatoolkit + else: cuda-cudart - rapids-logger =0.1 run_exports: - ${{ pin_subpackage("librmm", upper_bound="x.x") }} ignore_run_exports: + from_package: + - if: cuda_major != "11" + then: cuda-cudart-dev by_name: - cuda-version - if: cuda_major == "11" diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index aa00cd279..5f6860b85 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -83,31 +83,40 @@ include(cmake/thirdparty/get_nvtx.cmake) # ################################################################################################## # * library targets -------------------------------------------------------------------------------- -add_library(rmm INTERFACE) +add_library(rmm src/aligned.cpp src/cuda_device.cpp src/cuda_stream_pool.cpp + src/cuda_stream_view.cpp src/cuda_stream.cpp) add_library(rmm::rmm ALIAS rmm) target_include_directories( rmm - INTERFACE "$" - "$" "$") + PUBLIC "$" + "$" + INTERFACE "$") if(CUDA_STATIC_RUNTIME) message(STATUS "RMM: Enabling static linking of cudart") - target_link_libraries(rmm INTERFACE CUDA::cudart_static) + target_link_libraries(rmm PUBLIC CUDA::cudart_static) else() - target_link_libraries(rmm INTERFACE CUDA::cudart) + target_link_libraries(rmm PUBLIC CUDA::cudart) endif() -target_link_libraries(rmm INTERFACE CCCL::CCCL) -target_link_libraries(rmm INTERFACE dl) -target_link_libraries(rmm INTERFACE nvtx3::nvtx3-cpp) -target_link_libraries(rmm INTERFACE rapids_logger::rapids_logger) -target_compile_features(rmm INTERFACE cxx_std_17 $) -target_compile_definitions(rmm INTERFACE LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE) +target_link_libraries(rmm PUBLIC CCCL::CCCL ${CMAKE_DL_LIBS} nvtx3::nvtx3-cpp + rapids_logger::rapids_logger) + +set_target_properties( + rmm + PROPERTIES BUILD_RPATH "\$ORIGIN" + INSTALL_RPATH "\$ORIGIN" + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CXX_VISIBILITY_PRESET hidden + POSITION_INDEPENDENT_CODE ON + INTERFACE_POSITION_INDEPENDENT_CODE ON) +target_compile_definitions(rmm PUBLIC LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE) # Enable NVTX if necessary if(RMM_NVTX) - target_compile_definitions(rmm INTERFACE RMM_NVTX) + target_compile_definitions(rmm PUBLIC RMM_NVTX) endif() # ################################################################################################## diff --git a/cpp/include/rmm/aligned.hpp b/cpp/include/rmm/aligned.hpp index cf032fc94..57e91c217 100644 --- a/cpp/include/rmm/aligned.hpp +++ b/cpp/include/rmm/aligned.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ #include #include -namespace RMM_NAMESPACE { +namespace RMM_EXPORT rmm { /** * @addtogroup utilities @@ -49,10 +49,7 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; * * @return True if the input is a power of two with non-negative integer exponent, false otherwise. */ -[[nodiscard]] constexpr bool is_pow2(std::size_t value) noexcept -{ - return (value != 0U) && ((value & (value - 1)) == 0U); -} +[[nodiscard]] bool is_pow2(std::size_t value) noexcept; /** * @brief Returns whether or not `alignment` is a valid memory alignment. @@ -61,10 +58,7 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; * * @return True if the alignment is valid, false otherwise. */ -[[nodiscard]] constexpr bool is_supported_alignment(std::size_t alignment) noexcept -{ - return is_pow2(alignment); -} +[[nodiscard]] bool is_supported_alignment(std::size_t alignment) noexcept; /** * @brief Align up to nearest multiple of specified power of 2 @@ -74,11 +68,7 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; * * @return the aligned value */ -[[nodiscard]] constexpr std::size_t align_up(std::size_t value, std::size_t alignment) noexcept -{ - assert(is_supported_alignment(alignment)); - return (value + (alignment - 1)) & ~(alignment - 1); -} +[[nodiscard]] std::size_t align_up(std::size_t value, std::size_t alignment) noexcept; /** * @brief Align down to the nearest multiple of specified power of 2 @@ -88,11 +78,7 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; * * @return the aligned value */ -[[nodiscard]] constexpr std::size_t align_down(std::size_t value, std::size_t alignment) noexcept -{ - assert(is_supported_alignment(alignment)); - return value & ~(alignment - 1); -} +[[nodiscard]] std::size_t align_down(std::size_t value, std::size_t alignment) noexcept; /** * @brief Checks whether a value is aligned to a multiple of a specified power of 2 @@ -102,11 +88,7 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; * * @return true if aligned */ -[[nodiscard]] constexpr bool is_aligned(std::size_t value, std::size_t alignment) noexcept -{ - assert(is_supported_alignment(alignment)); - return value == align_down(value, alignment); -} +[[nodiscard]] bool is_aligned(std::size_t value, std::size_t alignment) noexcept; /** * @brief Checks whether the provided pointer is aligned to a specified @p alignment @@ -116,13 +98,9 @@ static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT{256}; * * @return true if the pointer is aligned */ -[[nodiscard]] inline bool is_pointer_aligned( - void* ptr, std::size_t alignment = CUDA_ALLOCATION_ALIGNMENT) noexcept -{ - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) - return is_aligned(reinterpret_cast(ptr), alignment); -} +[[nodiscard]] bool is_pointer_aligned(void* ptr, + std::size_t alignment = CUDA_ALLOCATION_ALIGNMENT) noexcept; /** @} */ // end of group -} // namespace RMM_NAMESPACE +} // namespace RMM_EXPORT rmm diff --git a/cpp/include/rmm/cuda_device.hpp b/cpp/include/rmm/cuda_device.hpp index 2b56d6d0a..a8253d163 100644 --- a/cpp/include/rmm/cuda_device.hpp +++ b/cpp/include/rmm/cuda_device.hpp @@ -16,18 +16,15 @@ #pragma once #include -#include #include -#include - #include #include -namespace RMM_NAMESPACE { +namespace RMM_EXPORT rmm { struct cuda_device_id; -inline cuda_device_id get_current_cuda_device(); +cuda_device_id get_current_cuda_device(); /** * @addtogroup cuda_device_management @@ -96,37 +93,21 @@ struct cuda_device_id { * * @return `cuda_device_id` for the current device */ -inline cuda_device_id get_current_cuda_device() -{ - cuda_device_id::value_type dev_id{-1}; - RMM_ASSERT_CUDA_SUCCESS(cudaGetDevice(&dev_id)); - return cuda_device_id{dev_id}; -} +cuda_device_id get_current_cuda_device(); /** * @brief Returns the number of CUDA devices in the system * * @return Number of CUDA devices in the system */ -inline int get_num_cuda_devices() -{ - cuda_device_id::value_type num_dev{-1}; - RMM_ASSERT_CUDA_SUCCESS(cudaGetDeviceCount(&num_dev)); - return num_dev; -} +int get_num_cuda_devices(); /** * @brief Returns the available and total device memory in bytes for the current device * * @return The available and total device memory in bytes for the current device as a std::pair. */ -inline std::pair available_device_memory() -{ - std::size_t free{}; - std::size_t total{}; - RMM_CUDA_TRY(cudaMemGetInfo(&free, &total)); - return {free, total}; -} +std::pair available_device_memory(); /** * @brief Returns the approximate specified percent of available device memory on the current CUDA @@ -136,13 +117,7 @@ inline std::pair available_device_memory() * * @return The recommended initial device memory pool size in bytes. */ -inline std::size_t percent_of_free_device_memory(int percent) -{ - [[maybe_unused]] auto const [free, total] = rmm::available_device_memory(); - auto fraction = static_cast(percent) / 100.0; - return rmm::align_down(static_cast(static_cast(free) * fraction), - rmm::CUDA_ALLOCATION_ALIGNMENT); -} +std::size_t percent_of_free_device_memory(int percent); /** * @brief RAII class that sets the current CUDA device to the specified device on construction @@ -154,19 +129,11 @@ struct cuda_set_device_raii { * * @param dev_id The device to set as the current CUDA device */ - explicit cuda_set_device_raii(cuda_device_id dev_id) - : old_device_{get_current_cuda_device()}, - needs_reset_{dev_id.value() >= 0 && old_device_ != dev_id} - { - if (needs_reset_) { RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(dev_id.value())); } - } + explicit cuda_set_device_raii(cuda_device_id dev_id); /** * @brief Reactivates the previous CUDA device */ - ~cuda_set_device_raii() noexcept - { - if (needs_reset_) { RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(old_device_.value())); } - } + ~cuda_set_device_raii() noexcept; cuda_set_device_raii(cuda_set_device_raii const&) = delete; cuda_set_device_raii& operator=(cuda_set_device_raii const&) = delete; @@ -179,4 +146,4 @@ struct cuda_set_device_raii { }; /** @} */ // end of group -} // namespace RMM_NAMESPACE +} // namespace RMM_EXPORT rmm diff --git a/cpp/include/rmm/cuda_stream.hpp b/cpp/include/rmm/cuda_stream.hpp index df1dde86b..e82dcfd22 100644 --- a/cpp/include/rmm/cuda_stream.hpp +++ b/cpp/include/rmm/cuda_stream.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,16 +17,14 @@ #pragma once #include -#include #include -#include #include #include #include -namespace RMM_NAMESPACE { +namespace RMM_EXPORT rmm { /** * @addtogroup cuda_streams * @{ @@ -65,18 +63,7 @@ class cuda_stream { * * @throw rmm::cuda_error if stream creation fails */ - cuda_stream() - : stream_{[]() { - auto* stream = new cudaStream_t; // NOLINT(cppcoreguidelines-owning-memory) - RMM_CUDA_TRY(cudaStreamCreate(stream)); - return stream; - }(), - [](cudaStream_t* stream) { - RMM_ASSERT_CUDA_SUCCESS(cudaStreamDestroy(*stream)); - delete stream; // NOLINT(cppcoreguidelines-owning-memory) - }} - { - } + cuda_stream(); /** * @brief Returns true if the owned stream is non-null @@ -84,37 +71,33 @@ class cuda_stream { * @return true If the owned stream has not been explicitly moved and is therefore non-null. * @return false If the owned stream has been explicitly moved and is therefore null. */ - [[nodiscard]] bool is_valid() const { return stream_ != nullptr; } + [[nodiscard]] bool is_valid() const; /** * @brief Get the value of the wrapped CUDA stream. * * @return cudaStream_t The wrapped CUDA stream. */ - [[nodiscard]] cudaStream_t value() const - { - RMM_LOGGING_ASSERT(is_valid()); - return *stream_; - } + [[nodiscard]] cudaStream_t value() const; /** * @brief Explicit conversion to cudaStream_t. */ - explicit operator cudaStream_t() const noexcept { return value(); } + explicit operator cudaStream_t() const noexcept; /** * @brief Creates an immutable, non-owning view of the wrapped CUDA stream. * * @return rmm::cuda_stream_view The view of the CUDA stream */ - [[nodiscard]] cuda_stream_view view() const { return cuda_stream_view{value()}; } + [[nodiscard]] cuda_stream_view view() const; /** * @brief Implicit conversion to cuda_stream_view * * @return A view of the owned stream */ - operator cuda_stream_view() const { return view(); } + operator cuda_stream_view() const; /** * @brief Synchronize the owned CUDA stream. @@ -123,21 +106,18 @@ class cuda_stream { * * @throw rmm::cuda_error if stream synchronization fails */ - void synchronize() const { RMM_CUDA_TRY(cudaStreamSynchronize(value())); } + void synchronize() const; /** * @brief Synchronize the owned CUDA stream. Does not throw if there is an error. * * Calls `cudaStreamSynchronize()` and asserts if there is an error. */ - void synchronize_no_throw() const noexcept - { - RMM_ASSERT_CUDA_SUCCESS(cudaStreamSynchronize(value())); - } + void synchronize_no_throw() const noexcept; private: std::unique_ptr> stream_; }; /** @} */ // end of group -} // namespace RMM_NAMESPACE +} // namespace RMM_EXPORT rmm diff --git a/cpp/include/rmm/cuda_stream_pool.hpp b/cpp/include/rmm/cuda_stream_pool.hpp index 0d84d8798..46962cbce 100644 --- a/cpp/include/rmm/cuda_stream_pool.hpp +++ b/cpp/include/rmm/cuda_stream_pool.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024, NVIDIA CORPORATION. + * Copyright (c) 2020-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,14 +18,13 @@ #include #include -#include #include #include #include #include -namespace RMM_NAMESPACE { +namespace RMM_EXPORT rmm { /** * @addtogroup cuda_streams * @{ @@ -50,10 +49,7 @@ class cuda_stream_pool { * @throws logic_error if `pool_size` is zero * @param pool_size The number of streams in the pool */ - explicit cuda_stream_pool(std::size_t pool_size = default_size) : streams_(pool_size) - { - RMM_EXPECTS(pool_size > 0, "Stream pool size must be greater than zero"); - } + explicit cuda_stream_pool(std::size_t pool_size = default_size); ~cuda_stream_pool() = default; cuda_stream_pool(cuda_stream_pool&&) = delete; @@ -68,10 +64,7 @@ class cuda_stream_pool { * * @return rmm::cuda_stream_view */ - rmm::cuda_stream_view get_stream() const noexcept - { - return streams_[(next_stream++) % streams_.size()].view(); - } + rmm::cuda_stream_view get_stream() const noexcept; /** * @brief Get a `cuda_stream_view` of the stream associated with `stream_id`. @@ -83,10 +76,7 @@ class cuda_stream_pool { * * @return rmm::cuda_stream_view */ - rmm::cuda_stream_view get_stream(std::size_t stream_id) const - { - return streams_[stream_id % streams_.size()].view(); - } + rmm::cuda_stream_view get_stream(std::size_t stream_id) const; /** * @brief Get the number of streams in the pool. @@ -95,7 +85,7 @@ class cuda_stream_pool { * * @return the number of streams in the pool */ - std::size_t get_pool_size() const noexcept { return streams_.size(); } + std::size_t get_pool_size() const noexcept; private: std::vector streams_; @@ -103,4 +93,4 @@ class cuda_stream_pool { }; /** @} */ // end of group -} // namespace RMM_NAMESPACE +} // namespace RMM_EXPORT rmm diff --git a/cpp/include/rmm/cuda_stream_view.hpp b/cpp/include/rmm/cuda_stream_view.hpp index d1b8aff15..54b34bc84 100644 --- a/cpp/include/rmm/cuda_stream_view.hpp +++ b/cpp/include/rmm/cuda_stream_view.hpp @@ -16,15 +16,15 @@ #pragma once -#include #include #include #include #include +#include -namespace RMM_NAMESPACE { +namespace RMM_EXPORT rmm { /** * @addtogroup cuda_streams * @{ @@ -38,63 +38,63 @@ namespace RMM_NAMESPACE { */ class cuda_stream_view { public: - constexpr cuda_stream_view() = default; - ~cuda_stream_view() = default; - constexpr cuda_stream_view(cuda_stream_view const&) = default; ///< @default_copy_constructor - constexpr cuda_stream_view(cuda_stream_view&&) = default; ///< @default_move_constructor - constexpr cuda_stream_view& operator=(cuda_stream_view const&) = + cuda_stream_view() = default; + ~cuda_stream_view() = default; + cuda_stream_view(cuda_stream_view const&) = default; ///< @default_copy_constructor + cuda_stream_view(cuda_stream_view&&) = default; ///< @default_move_constructor + cuda_stream_view& operator=(cuda_stream_view const&) = default; ///< @default_copy_assignment{cuda_stream_view} - constexpr cuda_stream_view& operator=(cuda_stream_view&&) = + cuda_stream_view& operator=(cuda_stream_view&&) = default; ///< @default_move_assignment{cuda_stream_view} // Disable construction from literal 0 - constexpr cuda_stream_view(int) = delete; //< Prevent cast from 0 - constexpr cuda_stream_view(std::nullptr_t) = delete; //< Prevent cast from nullptr + cuda_stream_view(int) = delete; //< Prevent cast from 0 + cuda_stream_view(std::nullptr_t) = delete; //< Prevent cast from nullptr /** * @brief Constructor from a cudaStream_t * * @param stream The underlying stream for this view */ - constexpr cuda_stream_view(cudaStream_t stream) noexcept : stream_{stream} {} + cuda_stream_view(cudaStream_t stream) noexcept; /** * @brief Implicit conversion from stream_ref. * * @param stream The underlying stream for this view */ - constexpr cuda_stream_view(cuda::stream_ref stream) noexcept : stream_{stream.get()} {} + cuda_stream_view(cuda::stream_ref stream) noexcept; /** * @brief Get the wrapped stream. * * @return cudaStream_t The underlying stream referenced by this cuda_stream_view */ - [[nodiscard]] constexpr cudaStream_t value() const noexcept { return stream_; } + [[nodiscard]] cudaStream_t value() const noexcept; /** * @brief Implicit conversion to cudaStream_t. * * @return cudaStream_t The underlying stream referenced by this cuda_stream_view */ - constexpr operator cudaStream_t() const noexcept { return value(); } + operator cudaStream_t() const noexcept; /** * @brief Implicit conversion to stream_ref. * * @return stream_ref The underlying stream referenced by this cuda_stream_view */ - constexpr operator cuda::stream_ref() const noexcept { return value(); } + operator cuda::stream_ref() const noexcept; /** * @briefreturn{true if the wrapped stream is the CUDA per-thread default stream} */ - [[nodiscard]] inline bool is_per_thread_default() const noexcept; + [[nodiscard]] bool is_per_thread_default() const noexcept; /** * @briefreturn{true if the wrapped stream is explicitly the CUDA legacy default stream} */ - [[nodiscard]] inline bool is_default() const noexcept; + [[nodiscard]] bool is_default() const noexcept; /** * @brief Synchronize the viewed CUDA stream. @@ -103,17 +103,14 @@ class cuda_stream_view { * * @throw rmm::cuda_error if stream synchronization fails */ - void synchronize() const { RMM_CUDA_TRY(cudaStreamSynchronize(stream_)); } + void synchronize() const; /** * @brief Synchronize the viewed CUDA stream. Does not throw if there is an error. * * Calls `cudaStreamSynchronize()` and asserts if there is an error. */ - void synchronize_no_throw() const noexcept - { - RMM_ASSERT_CUDA_SUCCESS(cudaStreamSynchronize(stream_)); - } + void synchronize_no_throw() const noexcept; private: cudaStream_t stream_{}; @@ -127,7 +124,6 @@ static constexpr cuda_stream_view cuda_stream_default{}; /** * @brief Static cuda_stream_view of cudaStreamLegacy, for convenience */ - static const cuda_stream_view cuda_stream_legacy{ cudaStreamLegacy // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) }; @@ -139,32 +135,6 @@ static const cuda_stream_view cuda_stream_per_thread{ cudaStreamPerThread // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) }; -// Need to avoid putting is_per_thread_default and is_default into the group twice. -/** @} */ // end of group - -[[nodiscard]] inline bool cuda_stream_view::is_per_thread_default() const noexcept -{ -#ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM - return value() == cuda_stream_per_thread || value() == nullptr; -#else - return value() == cuda_stream_per_thread; -#endif -} - -[[nodiscard]] inline bool cuda_stream_view::is_default() const noexcept -{ -#ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM - return value() == cuda_stream_legacy; -#else - return value() == cuda_stream_legacy || value() == nullptr; -#endif -} - -/** - * @addtogroup cuda_streams - * @{ - */ - /** * @brief Equality comparison operator for streams * @@ -172,10 +142,7 @@ static const cuda_stream_view cuda_stream_per_thread{ * @param rhs The second stream view to compare * @return true if equal, false if unequal */ -inline bool operator==(cuda_stream_view lhs, cuda_stream_view rhs) -{ - return lhs.value() == rhs.value(); -} +bool operator==(cuda_stream_view lhs, cuda_stream_view rhs); /** * @brief Inequality comparison operator for streams @@ -184,7 +151,7 @@ inline bool operator==(cuda_stream_view lhs, cuda_stream_view rhs) * @param rhs The second stream view to compare * @return true if unequal, false if equal */ -inline bool operator!=(cuda_stream_view lhs, cuda_stream_view rhs) { return not(lhs == rhs); } +bool operator!=(cuda_stream_view lhs, cuda_stream_view rhs); /** * @brief Output stream operator for printing / logging streams @@ -193,11 +160,7 @@ inline bool operator!=(cuda_stream_view lhs, cuda_stream_view rhs) { return not( * @param stream The cuda_stream_view to output * @return std::ostream& The output ostream */ -inline std::ostream& operator<<(std::ostream& os, cuda_stream_view stream) -{ - os << stream.value(); - return os; -} +std::ostream& operator<<(std::ostream& os, cuda_stream_view stream); /** @} */ // end of group -} // namespace RMM_NAMESPACE +} // namespace RMM_EXPORT rmm diff --git a/cpp/src/aligned.cpp b/cpp/src/aligned.cpp new file mode 100644 index 000000000..a45a142ed --- /dev/null +++ b/cpp/src/aligned.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2020-2025, 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. + */ + +#include + +#include +#include +#include + +namespace rmm { + +bool is_pow2(std::size_t value) noexcept { return (value != 0U) && ((value & (value - 1)) == 0U); } + +bool is_supported_alignment(std::size_t alignment) noexcept { return is_pow2(alignment); } + +std::size_t align_up(std::size_t value, std::size_t alignment) noexcept +{ + assert(is_supported_alignment(alignment)); + return (value + (alignment - 1)) & ~(alignment - 1); +} + +std::size_t align_down(std::size_t value, std::size_t alignment) noexcept +{ + assert(is_supported_alignment(alignment)); + return value & ~(alignment - 1); +} + +bool is_aligned(std::size_t value, std::size_t alignment) noexcept +{ + assert(is_supported_alignment(alignment)); + return value == align_down(value, alignment); +} + +bool is_pointer_aligned(void* ptr, std::size_t alignment) noexcept +{ + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) + return is_aligned(reinterpret_cast(ptr), alignment); +} + +} // namespace rmm diff --git a/cpp/src/cuda_device.cpp b/cpp/src/cuda_device.cpp new file mode 100644 index 000000000..231afd19a --- /dev/null +++ b/cpp/src/cuda_device.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021-2025, 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. + */ + +#include +#include +#include + +#include + +#include +#include + +namespace rmm { + +cuda_device_id get_current_cuda_device() +{ + cuda_device_id::value_type dev_id{-1}; + RMM_ASSERT_CUDA_SUCCESS(cudaGetDevice(&dev_id)); + return cuda_device_id{dev_id}; +} + +int get_num_cuda_devices() +{ + cuda_device_id::value_type num_dev{-1}; + RMM_ASSERT_CUDA_SUCCESS(cudaGetDeviceCount(&num_dev)); + return num_dev; +} + +std::pair available_device_memory() +{ + std::size_t free{}; + std::size_t total{}; + RMM_CUDA_TRY(cudaMemGetInfo(&free, &total)); + return {free, total}; +} + +std::size_t percent_of_free_device_memory(int percent) +{ + [[maybe_unused]] auto const [free, total] = rmm::available_device_memory(); + auto fraction = static_cast(percent) / 100.0; + return rmm::align_down(static_cast(static_cast(free) * fraction), + rmm::CUDA_ALLOCATION_ALIGNMENT); +} + +cuda_set_device_raii::cuda_set_device_raii(cuda_device_id dev_id) + : old_device_{get_current_cuda_device()}, + needs_reset_{dev_id.value() >= 0 && old_device_ != dev_id} +{ + if (needs_reset_) { RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(dev_id.value())); } +} + +cuda_set_device_raii::~cuda_set_device_raii() noexcept +{ + if (needs_reset_) { RMM_ASSERT_CUDA_SUCCESS(cudaSetDevice(old_device_.value())); } +} + +} // namespace rmm diff --git a/cpp/src/cuda_stream.cpp b/cpp/src/cuda_stream.cpp new file mode 100644 index 000000000..e2aae611c --- /dev/null +++ b/cpp/src/cuda_stream.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2020-2025, 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. + */ + +#include +#include +#include + +#include + +namespace rmm { + +cuda_stream::cuda_stream() + : stream_{[]() { + auto* stream = new cudaStream_t; // NOLINT(cppcoreguidelines-owning-memory) + RMM_CUDA_TRY(cudaStreamCreate(stream)); + return stream; + }(), + [](cudaStream_t* stream) { + RMM_ASSERT_CUDA_SUCCESS(cudaStreamDestroy(*stream)); + delete stream; // NOLINT(cppcoreguidelines-owning-memory) + }} +{ +} + +bool cuda_stream::is_valid() const { return stream_ != nullptr; } + +cudaStream_t cuda_stream::value() const +{ + RMM_LOGGING_ASSERT(is_valid()); + return *stream_; +} + +cuda_stream::operator cudaStream_t() const noexcept { return value(); } + +cuda_stream_view cuda_stream::view() const { return cuda_stream_view{value()}; } + +cuda_stream::operator cuda_stream_view() const { return view(); } + +void cuda_stream::synchronize() const { RMM_CUDA_TRY(cudaStreamSynchronize(value())); } + +void cuda_stream::synchronize_no_throw() const noexcept +{ + RMM_ASSERT_CUDA_SUCCESS(cudaStreamSynchronize(value())); +} + +} // namespace rmm diff --git a/cpp/src/cuda_stream_pool.cpp b/cpp/src/cuda_stream_pool.cpp new file mode 100644 index 000000000..8703d066b --- /dev/null +++ b/cpp/src/cuda_stream_pool.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2020-2025, 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. + */ + +#include +#include +#include + +#include + +namespace rmm { + +cuda_stream_pool::cuda_stream_pool(std::size_t pool_size) : streams_(pool_size) +{ + RMM_EXPECTS(pool_size > 0, "Stream pool size must be greater than zero"); +} + +rmm::cuda_stream_view cuda_stream_pool::get_stream() const noexcept +{ + return streams_[(next_stream++) % streams_.size()].view(); +} + +rmm::cuda_stream_view cuda_stream_pool::get_stream(std::size_t stream_id) const +{ + return streams_[stream_id % streams_.size()].view(); +} + +std::size_t cuda_stream_pool::get_pool_size() const noexcept { return streams_.size(); } + +} // namespace rmm diff --git a/cpp/src/cuda_stream_view.cpp b/cpp/src/cuda_stream_view.cpp new file mode 100644 index 000000000..78234a56b --- /dev/null +++ b/cpp/src/cuda_stream_view.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2020-2025, 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. + */ + +#include +#include +#include + +#include +#include + +#include + +namespace rmm { + +cuda_stream_view::cuda_stream_view(cudaStream_t stream) noexcept : stream_{stream} {} + +cuda_stream_view::cuda_stream_view(cuda::stream_ref stream) noexcept : stream_{stream.get()} {} + +cudaStream_t cuda_stream_view::value() const noexcept { return stream_; } + +cuda_stream_view::operator cudaStream_t() const noexcept { return value(); } + +cuda_stream_view::operator cuda::stream_ref() const noexcept { return value(); } + +bool cuda_stream_view::is_per_thread_default() const noexcept +{ +#ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM + return *this == cuda_stream_per_thread || value() == nullptr; +#else + return *this == cuda_stream_per_thread; +#endif +} + +bool cuda_stream_view::is_default() const noexcept +{ +#ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM + return *this == cuda_stream_legacy; +#else + return *this == cuda_stream_legacy || value() == nullptr; +#endif +} + +void cuda_stream_view::synchronize() const { RMM_CUDA_TRY(cudaStreamSynchronize(stream_)); } + +void cuda_stream_view::synchronize_no_throw() const noexcept +{ + RMM_ASSERT_CUDA_SUCCESS(cudaStreamSynchronize(stream_)); +} + +bool operator==(cuda_stream_view lhs, cuda_stream_view rhs) { return lhs.value() == rhs.value(); } + +bool operator!=(cuda_stream_view lhs, cuda_stream_view rhs) { return not(lhs == rhs); } + +std::ostream& operator<<(std::ostream& os, cuda_stream_view stream) +{ + os << stream.value(); + return os; +} + +} // namespace rmm diff --git a/python/librmm/librmm/load.py b/python/librmm/librmm/load.py index 1d32434f8..f5458a9d6 100644 --- a/python/librmm/librmm/load.py +++ b/python/librmm/librmm/load.py @@ -1,4 +1,4 @@ -# Copyright (c) 2025, NVIDIA CORPORATION. +# Copyright (c) 2024-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,13 +13,82 @@ # limitations under the License. # +import ctypes +import os + +# Loading with RTLD_LOCAL adds the library itself to the loader's +# loaded library cache without loading any symbols into the global +# namespace. This allows libraries that express a dependency on +# this library to be loaded later and successfully satisfy this dependency +# without polluting the global symbol table with symbols from +# librmm that could conflict with symbols from other DSOs. +PREFERRED_LOAD_FLAG = ctypes.RTLD_LOCAL + + +def _load_system_installation(soname: str): + """Try to dlopen() the library indicated by ``soname`` + Raises ``OSError`` if library cannot be loaded. + """ + return ctypes.CDLL(soname, PREFERRED_LOAD_FLAG) + + +def _load_wheel_installation(soname: str): + """Try to dlopen() the library indicated by ``soname`` + + Returns ``None`` if the library cannot be loaded. + """ + if os.path.isfile( + lib := os.path.join(os.path.dirname(__file__), "lib64", soname) + ): + return ctypes.CDLL(lib, PREFERRED_LOAD_FLAG) + return None + def load_library(): - """Librmm is header-only, this function loads its (non-header-only) dependencies""" + """Dynamically load librmm.so and its dependencies""" try: + # rapids-logger must be loaded before librmm because librmm references + # it. import rapids_logger + + rapids_logger.load_library() except ModuleNotFoundError: + # librmm's runtime dependency on rapids-logger may be satisfied by a + # natively installed library or a conda package, in which case the + # import will fail and we assume the library is discoverable on system + # paths. pass + + prefer_system_installation = ( + os.getenv("RAPIDS_LIBRMM_PREFER_SYSTEM_LIBRARY", "false").lower() + != "false" + ) + + soname = "librmm.so" + librmm_lib = None + if prefer_system_installation: + # Prefer a system library if one is present to + # avoid clobbering symbols that other packages might expect, but if no + # other library is present use the one in the wheel. + try: + librmm_lib = _load_system_installation(soname) + except OSError: + librmm_lib = _load_wheel_installation(soname) else: - rapids_logger.load_library() - del rapids_logger + # Prefer the libraries bundled in this package. If they aren't found + # (which might be the case in builds where the library was prebuilt before + # packaging the wheel), look for a system installation. + try: + librmm_lib = _load_wheel_installation(soname) + if librmm_lib is None: + librmm_lib = _load_system_installation(soname) + except OSError: + # If none of the searches above succeed, just silently return None + # and rely on other mechanisms (like RPATHs on other DSOs) to + # help the loader find the library. + pass + + # The caller almost never needs to do anything with this library, but no + # harm in offering the option since this object at least provides a handle + # to inspect where librmm was loaded from. + return librmm_lib diff --git a/python/rmm/rmm/librmm/memory_resource.pxd b/python/rmm/rmm/librmm/memory_resource.pxd index 3ded7a9be..a24aa338e 100644 --- a/python/rmm/rmm/librmm/memory_resource.pxd +++ b/python/rmm/rmm/librmm/memory_resource.pxd @@ -66,6 +66,8 @@ cdef inline CppExcept translate_python_except_to_cpp(err: BaseException) noexcep # exception are translated back into a Python exception. cdef extern from *: """ + #include + #include #include From a087b7c55e3cf4e814f0f3498ba6b2bf3769de63 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 12 May 2025 10:51:53 -0400 Subject: [PATCH 604/675] Use auditwheel to properly retag the wheel (#1913) After #1896 the librmm wheel contains a compiled library, which means it is no longer accurate to tag the wheel as supported on any platform. We must tag it according to the suitable architecture tags to ensure that we do not get arm binaries on x86 and vice versa. We must also add a manylinux tag to indicate glibc compatibility. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Kyle Edwards (https://github.com/KyleFromNVIDIA) URL: https://github.com/rapidsai/rmm/pull/1913 --- ci/build_wheel_cpp.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ci/build_wheel_cpp.sh b/ci/build_wheel_cpp.sh index 26454f0b8..e582fb9f2 100755 --- a/ci/build_wheel_cpp.sh +++ b/ci/build_wheel_cpp.sh @@ -20,11 +20,15 @@ sccache --zero-stats # Creates artifacts directory for telemetry source rapids-telemetry-setup -rapids-telemetry-record build.log rapids-pip-retry wheel . -w "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" -v --no-deps --disable-pip-version-check +dist_dir="$(mktemp -d)" +rapids-telemetry-record build.log rapids-pip-retry wheel . -w "${dist_dir}" -v --no-deps --disable-pip-version-check rapids-telemetry-record sccache-stats.txt sccache --show-adv-stats -python -m wheel tags --platform any "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}"/* --remove +python -m auditwheel repair \ + --exclude librapids_logger.so \ + -w "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" \ + ${dist_dir}/* ../../ci/validate_wheel.sh "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" From 36cd90288891bcb4a23143ac82c5bafb272e4b75 Mon Sep 17 00:00:00 2001 From: Jigao Luo Date: Mon, 12 May 2025 19:24:02 +0200 Subject: [PATCH 605/675] Update Readme for the logging `set_level` (#1911) This change updates the README for RMM logging details. The `set_level` call now depends on rapids_logger instead of the old SPD. It's a doc-only, non-breaking change. Authors: - Jigao Luo (https://github.com/JigaoLuo) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1911 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fbedee4be..2ad0ced5f 100644 --- a/README.md +++ b/README.md @@ -657,7 +657,7 @@ of more detailed logging. The default is `INFO`. Available levels are `TRACE`, ` Note that to see logging below the `INFO` level, the application must also set the logging level at run time. C++ applications must must call `rmm::default_logger().set_level()`, for example to enable all -levels of logging down to `TRACE`, call `rmm::default_logger().set_level(spdlog::level::trace)` (and compile +levels of logging down to `TRACE`, call `rmm::default_logger().set_level(rapids_logger::level_enum::trace)` (and compile librmm with `-DRMM_LOGGING_LEVEL=TRACE`). Python applications must call `rmm.set_logging_level()`, for example to enable all levels of logging down to `TRACE`, call `rmm.set_logging_level("trace")` (and compile the RMM Python module with `-DRMM_LOGGING_LEVEL=TRACE`). From b30828d0c2e7dacb5f6f893de3e63ff4a34605e7 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 13 May 2025 11:10:23 -0500 Subject: [PATCH 606/675] Quote head_rev in conda recipes (#1915) This quotes `head_rev` to ensure that commits with leading zeros in the git SHA include those zeros in the output package name. xref: https://github.com/rapidsai/build-planning/issues/176 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1915 --- conda/recipes/librmm/recipe.yaml | 2 +- conda/recipes/rmm/recipe.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conda/recipes/librmm/recipe.yaml b/conda/recipes/librmm/recipe.yaml index f4fff92dc..0d371641f 100644 --- a/conda/recipes/librmm/recipe.yaml +++ b/conda/recipes/librmm/recipe.yaml @@ -7,7 +7,7 @@ context: cuda_version: ${{ (env.get("RAPIDS_CUDA_VERSION") | split("."))[:2] | join(".") }} cuda_major: '${{ (env.get("RAPIDS_CUDA_VERSION") | split("."))[0] }}' date_string: '${{ env.get("RAPIDS_DATE_STRING") }}' - head_rev: ${{ git.head_rev(".")[:8] }} + head_rev: '${{ git.head_rev(".")[:8] }}' recipe: name: librmm-split diff --git a/conda/recipes/rmm/recipe.yaml b/conda/recipes/rmm/recipe.yaml index 82d77f3d3..deed98e69 100644 --- a/conda/recipes/rmm/recipe.yaml +++ b/conda/recipes/rmm/recipe.yaml @@ -8,7 +8,7 @@ context: date_string: '${{ env.get("RAPIDS_DATE_STRING") }}' py_version: ${{ env.get("RAPIDS_PY_VERSION") }} py_buildstring : ${{ py_version | version_to_buildstring }} - head_rev: ${{ git.head_rev(".")[:8] }} + head_rev: '${{ git.head_rev(".")[:8] }}' package: name: rmm From e9f7d35281bab993edc6a65093512dc3a4974397 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 14 May 2025 13:30:12 -0500 Subject: [PATCH 607/675] Update to clang 20 (#1918) Contributes to https://github.com/rapidsai/build-planning/issues/177 This PR updates the clang version to 20. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1918 --- .pre-commit-config.yaml | 2 +- conda/environments/all_cuda-118_arch-aarch64.yaml | 4 ++-- conda/environments/all_cuda-118_arch-x86_64.yaml | 4 ++-- conda/environments/all_cuda-129_arch-aarch64.yaml | 4 ++-- conda/environments/all_cuda-129_arch-x86_64.yaml | 4 ++-- cpp/tests/mr/device/arena_mr_tests.cpp | 2 +- cpp/tests/mr/device/failure_callback_mr_tests.cpp | 2 +- dependencies.yaml | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fc0b4f89f..4881b9937 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: hooks: - id: cython-lint - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v16.0.6 + rev: v20.1.4 hooks: - id: clang-format types_or: [c, c++, cuda] diff --git a/conda/environments/all_cuda-118_arch-aarch64.yaml b/conda/environments/all_cuda-118_arch-aarch64.yaml index 671ddd808..c24757b76 100644 --- a/conda/environments/all_cuda-118_arch-aarch64.yaml +++ b/conda/environments/all_cuda-118_arch-aarch64.yaml @@ -7,8 +7,8 @@ channels: dependencies: - breathe>=4.35.0 - c-compiler -- clang-tools==16.0.6 -- clang==16.0.6 +- clang-tools==20.1.4 +- clang==20.1.4 - cmake>=3.30.4 - cuda-python>=11.8.5,<12.0a0 - cuda-version=11.8 diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 5d90cc60c..fc14e3678 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -7,8 +7,8 @@ channels: dependencies: - breathe>=4.35.0 - c-compiler -- clang-tools==16.0.6 -- clang==16.0.6 +- clang-tools==20.1.4 +- clang==20.1.4 - cmake>=3.30.4 - cuda-python>=11.8.5,<12.0a0 - cuda-version=11.8 diff --git a/conda/environments/all_cuda-129_arch-aarch64.yaml b/conda/environments/all_cuda-129_arch-aarch64.yaml index 0f92e6497..ca1beb155 100644 --- a/conda/environments/all_cuda-129_arch-aarch64.yaml +++ b/conda/environments/all_cuda-129_arch-aarch64.yaml @@ -7,8 +7,8 @@ channels: dependencies: - breathe>=4.35.0 - c-compiler -- clang-tools==16.0.6 -- clang==16.0.6 +- clang-tools==20.1.4 +- clang==20.1.4 - cmake>=3.30.4 - cuda-nvcc - cuda-python>=12.6.2,<13.0a0 diff --git a/conda/environments/all_cuda-129_arch-x86_64.yaml b/conda/environments/all_cuda-129_arch-x86_64.yaml index ceca68767..01b0b49a4 100644 --- a/conda/environments/all_cuda-129_arch-x86_64.yaml +++ b/conda/environments/all_cuda-129_arch-x86_64.yaml @@ -7,8 +7,8 @@ channels: dependencies: - breathe>=4.35.0 - c-compiler -- clang-tools==16.0.6 -- clang==16.0.6 +- clang-tools==20.1.4 +- clang==20.1.4 - cmake>=3.30.4 - cuda-nvcc - cuda-python>=12.6.2,<13.0a0 diff --git a/cpp/tests/mr/device/arena_mr_tests.cpp b/cpp/tests/mr/device/arena_mr_tests.cpp index 033e135b8..322ca4c6a 100644 --- a/cpp/tests/mr/device/arena_mr_tests.cpp +++ b/cpp/tests/mr/device/arena_mr_tests.cpp @@ -590,7 +590,7 @@ TEST_F(ArenaTest, DumpLogOnFailure) // NOLINT // NOLINTNEXTLINE(cppcoreguidelines-avoid-goto) EXPECT_THROW(mr.allocate(8_MiB), rmm::out_of_memory); - struct stat file_status {}; + struct stat file_status{}; EXPECT_EQ(stat("rmm_arena_memory_dump.log", &file_status), 0); EXPECT_GE(file_status.st_size, 0); } diff --git a/cpp/tests/mr/device/failure_callback_mr_tests.cpp b/cpp/tests/mr/device/failure_callback_mr_tests.cpp index 263e0128c..bbe9c7296 100644 --- a/cpp/tests/mr/device/failure_callback_mr_tests.cpp +++ b/cpp/tests/mr/device/failure_callback_mr_tests.cpp @@ -60,7 +60,7 @@ class always_throw_memory_resource final : public mr::device_memory_resource { { throw ExceptionType{"foo"}; } - void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override{}; + void do_deallocate(void* ptr, std::size_t bytes, cuda_stream_view stream) override {}; }; TEST(FailureCallbackTest, DifferentExceptionTypes) diff --git a/dependencies.yaml b/dependencies.yaml index 2804c9ed5..486a42172 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -299,8 +299,8 @@ dependencies: common: - output_types: conda packages: - - clang==16.0.6 - - clang-tools==16.0.6 + - clang==20.1.4 + - clang-tools==20.1.4 - gcovr>=5.0 docs: common: From ecc6ca719d1e85fcd516cac9a407c289a4a04f42 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 14 May 2025 13:41:38 -0500 Subject: [PATCH 608/675] Move docs to top level. (#1917) This PR moves the docs to a top-level `docs/` folder. This aligns better with other RAPIDS projects, rather than hiding them in the `python/` subfolder. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) - Lawrence Mitchell (https://github.com/wence-) - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/rmm/pull/1917 --- .gitignore | 7 ++----- ci/build_docs.sh | 2 +- {python/rmm/docs => docs}/Makefile | 0 {python/rmm/docs => docs}/conf.py | 5 ++--- {python/rmm/docs => docs}/cpp.rst | 0 {python/rmm/docs => docs}/cpp_api.rst | 0 {python/rmm/docs => docs}/guide.md | 0 {python/rmm/docs => docs}/index.rst | 0 .../docs => docs}/librmm_docs/cuda_device_management.rst | 0 {python/rmm/docs => docs}/librmm_docs/cuda_streams.rst | 0 {python/rmm/docs => docs}/librmm_docs/data_containers.rst | 0 {python/rmm/docs => docs}/librmm_docs/deprecated.rst | 0 {python/rmm/docs => docs}/librmm_docs/errors.rst | 0 {python/rmm/docs => docs}/librmm_docs/index.rst | 0 {python/rmm/docs => docs}/librmm_docs/logging.rst | 0 {python/rmm/docs => docs}/librmm_docs/memory_resources.rst | 0 .../rmm/docs => docs}/librmm_docs/thrust_integrations.rst | 0 {python/rmm/docs => docs}/librmm_docs/utilities.rst | 0 {python/rmm/docs => docs}/python.rst | 0 {python/rmm/docs => docs}/python_api.rst | 0 20 files changed, 5 insertions(+), 9 deletions(-) rename {python/rmm/docs => docs}/Makefile (100%) rename {python/rmm/docs => docs}/conf.py (99%) rename {python/rmm/docs => docs}/cpp.rst (100%) rename {python/rmm/docs => docs}/cpp_api.rst (100%) rename {python/rmm/docs => docs}/guide.md (100%) rename {python/rmm/docs => docs}/index.rst (100%) rename {python/rmm/docs => docs}/librmm_docs/cuda_device_management.rst (100%) rename {python/rmm/docs => docs}/librmm_docs/cuda_streams.rst (100%) rename {python/rmm/docs => docs}/librmm_docs/data_containers.rst (100%) rename {python/rmm/docs => docs}/librmm_docs/deprecated.rst (100%) rename {python/rmm/docs => docs}/librmm_docs/errors.rst (100%) rename {python/rmm/docs => docs}/librmm_docs/index.rst (100%) rename {python/rmm/docs => docs}/librmm_docs/logging.rst (100%) rename {python/rmm/docs => docs}/librmm_docs/memory_resources.rst (100%) rename {python/rmm/docs => docs}/librmm_docs/thrust_integrations.rst (100%) rename {python/rmm/docs => docs}/librmm_docs/utilities.rst (100%) rename {python/rmm/docs => docs}/python.rst (100%) rename {python/rmm/docs => docs}/python_api.rst (100%) diff --git a/.gitignore b/.gitignore index a37264dbf..e8084afe0 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,6 @@ dist/ rmm.egg-info/ python/build python/*/build -python/rmm/docs/_build python/rmm/rmm/librmm/*.cpp !python/rmm/rmm/librmm/_torch_allocator.cpp python/rmm/**/librmm/**/*.h @@ -94,9 +93,10 @@ thirdparty/googletest/ *.ipr *.iws -## Doxygen +## Documentation cpp/doxygen/html cpp/doxygen/xml +docs/_build #Java target @@ -116,9 +116,6 @@ instance/ # Scrapy stuff: .scrapy -# Sphinx documentation -python/docs/_build/ - # PyBuilder target/ diff --git a/ci/build_docs.sh b/ci/build_docs.sh index 5a197a08d..394f0d97c 100755 --- a/ci/build_docs.sh +++ b/ci/build_docs.sh @@ -39,7 +39,7 @@ mv html/* "${RAPIDS_DOCS_DIR}/librmm/html" popd rapids-logger "Build Python docs" -pushd python/rmm/docs +pushd docs make dirhtml mkdir -p "${RAPIDS_DOCS_DIR}/rmm/html" mv _build/dirhtml/* "${RAPIDS_DOCS_DIR}/rmm/html" diff --git a/python/rmm/docs/Makefile b/docs/Makefile similarity index 100% rename from python/rmm/docs/Makefile rename to docs/Makefile diff --git a/python/rmm/docs/conf.py b/docs/conf.py similarity index 99% rename from python/rmm/docs/conf.py rename to docs/conf.py index 14aa1c2e7..5b7823d97 100644 --- a/python/rmm/docs/conf.py +++ b/docs/conf.py @@ -16,9 +16,8 @@ import os import re -from packaging.version import Version - import rmm +from packaging.version import Version # -- Project information ----------------------------------------------------- @@ -61,7 +60,7 @@ ] # Breathe Configuration -breathe_projects = {"librmm": "../../../cpp/doxygen/xml"} +breathe_projects = {"librmm": "../cpp/doxygen/xml"} breathe_default_project = "librmm" copybutton_prompt_text = ">>> " diff --git a/python/rmm/docs/cpp.rst b/docs/cpp.rst similarity index 100% rename from python/rmm/docs/cpp.rst rename to docs/cpp.rst diff --git a/python/rmm/docs/cpp_api.rst b/docs/cpp_api.rst similarity index 100% rename from python/rmm/docs/cpp_api.rst rename to docs/cpp_api.rst diff --git a/python/rmm/docs/guide.md b/docs/guide.md similarity index 100% rename from python/rmm/docs/guide.md rename to docs/guide.md diff --git a/python/rmm/docs/index.rst b/docs/index.rst similarity index 100% rename from python/rmm/docs/index.rst rename to docs/index.rst diff --git a/python/rmm/docs/librmm_docs/cuda_device_management.rst b/docs/librmm_docs/cuda_device_management.rst similarity index 100% rename from python/rmm/docs/librmm_docs/cuda_device_management.rst rename to docs/librmm_docs/cuda_device_management.rst diff --git a/python/rmm/docs/librmm_docs/cuda_streams.rst b/docs/librmm_docs/cuda_streams.rst similarity index 100% rename from python/rmm/docs/librmm_docs/cuda_streams.rst rename to docs/librmm_docs/cuda_streams.rst diff --git a/python/rmm/docs/librmm_docs/data_containers.rst b/docs/librmm_docs/data_containers.rst similarity index 100% rename from python/rmm/docs/librmm_docs/data_containers.rst rename to docs/librmm_docs/data_containers.rst diff --git a/python/rmm/docs/librmm_docs/deprecated.rst b/docs/librmm_docs/deprecated.rst similarity index 100% rename from python/rmm/docs/librmm_docs/deprecated.rst rename to docs/librmm_docs/deprecated.rst diff --git a/python/rmm/docs/librmm_docs/errors.rst b/docs/librmm_docs/errors.rst similarity index 100% rename from python/rmm/docs/librmm_docs/errors.rst rename to docs/librmm_docs/errors.rst diff --git a/python/rmm/docs/librmm_docs/index.rst b/docs/librmm_docs/index.rst similarity index 100% rename from python/rmm/docs/librmm_docs/index.rst rename to docs/librmm_docs/index.rst diff --git a/python/rmm/docs/librmm_docs/logging.rst b/docs/librmm_docs/logging.rst similarity index 100% rename from python/rmm/docs/librmm_docs/logging.rst rename to docs/librmm_docs/logging.rst diff --git a/python/rmm/docs/librmm_docs/memory_resources.rst b/docs/librmm_docs/memory_resources.rst similarity index 100% rename from python/rmm/docs/librmm_docs/memory_resources.rst rename to docs/librmm_docs/memory_resources.rst diff --git a/python/rmm/docs/librmm_docs/thrust_integrations.rst b/docs/librmm_docs/thrust_integrations.rst similarity index 100% rename from python/rmm/docs/librmm_docs/thrust_integrations.rst rename to docs/librmm_docs/thrust_integrations.rst diff --git a/python/rmm/docs/librmm_docs/utilities.rst b/docs/librmm_docs/utilities.rst similarity index 100% rename from python/rmm/docs/librmm_docs/utilities.rst rename to docs/librmm_docs/utilities.rst diff --git a/python/rmm/docs/python.rst b/docs/python.rst similarity index 100% rename from python/rmm/docs/python.rst rename to docs/python.rst diff --git a/python/rmm/docs/python_api.rst b/docs/python_api.rst similarity index 100% rename from python/rmm/docs/python_api.rst rename to docs/python_api.rst From 1226490cf44741e949db65fe5910c13a1e4fb5eb Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 15 May 2025 08:05:32 -0500 Subject: [PATCH 609/675] Finish CUDA 12.9 migration and use branch-25.06 workflows (#1921) This PR reverts shared-workflows branches to `branch-25.06` and ensures builds use CUDA 12.8. CUDA 12.9 will be used in the test matrix but not for builds in RAPIDS 25.06. See https://github.com/rapidsai/build-planning/issues/173#issuecomment-2882179838 for more information. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Gil Forsyth (https://github.com/gforsyth) URL: https://github.com/rapidsai/rmm/pull/1921 --- .../devcontainer.json | 8 +++--- .../devcontainer.json | 10 +++---- .github/workflows/build.yaml | 16 ++++++------ .github/workflows/pr.yaml | 26 +++++++++---------- .github/workflows/test.yaml | 6 ++--- .../trigger-breaking-change-alert.yaml | 2 +- README.md | 4 +-- ...64.yaml => all_cuda-128_arch-aarch64.yaml} | 4 +-- ..._64.yaml => all_cuda-128_arch-x86_64.yaml} | 4 +-- dependencies.yaml | 2 +- 10 files changed, 41 insertions(+), 41 deletions(-) rename .devcontainer/{cuda12.9-conda => cuda12.8-conda}/devcontainer.json (91%) rename .devcontainer/{cuda12.9-pip => cuda12.8-pip}/devcontainer.json (87%) rename conda/environments/{all_cuda-129_arch-aarch64.yaml => all_cuda-128_arch-aarch64.yaml} (94%) rename conda/environments/{all_cuda-129_arch-x86_64.yaml => all_cuda-128_arch-x86_64.yaml} (94%) diff --git a/.devcontainer/cuda12.9-conda/devcontainer.json b/.devcontainer/cuda12.8-conda/devcontainer.json similarity index 91% rename from .devcontainer/cuda12.9-conda/devcontainer.json rename to .devcontainer/cuda12.8-conda/devcontainer.json index 6836ab3d1..faa81b709 100644 --- a/.devcontainer/cuda12.9-conda/devcontainer.json +++ b/.devcontainer/cuda12.8-conda/devcontainer.json @@ -3,7 +3,7 @@ "context": "${localWorkspaceFolder}/.devcontainer", "dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile", "args": { - "CUDA": "12.9", + "CUDA": "12.8", "PYTHON_PACKAGE_MANAGER": "conda", "BASE": "rapidsai/devcontainers:25.06-cpp-mambaforge-ubuntu22.04" } @@ -11,7 +11,7 @@ "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.06-cuda12.9-conda" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.06-cuda12.8-conda" ], "hostRequirements": {"gpu": "optional"}, "features": { @@ -20,7 +20,7 @@ "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" ], - "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config,conda/pkgs,conda/${localWorkspaceFolderBasename}-cuda12.9-envs}"], + "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config,conda/pkgs,conda/${localWorkspaceFolderBasename}-cuda12.8-envs}"], "postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"], "workspaceFolder": "/home/coder", "workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent", @@ -29,7 +29,7 @@ "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.conda/pkgs,target=/home/coder/.conda/pkgs,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.conda/${localWorkspaceFolderBasename}-cuda12.9-envs,target=/home/coder/.conda/envs,type=bind,consistency=consistent" + "source=${localWorkspaceFolder}/../.conda/${localWorkspaceFolderBasename}-cuda12.8-envs,target=/home/coder/.conda/envs,type=bind,consistency=consistent" ], "customizations": { "vscode": { diff --git a/.devcontainer/cuda12.9-pip/devcontainer.json b/.devcontainer/cuda12.8-pip/devcontainer.json similarity index 87% rename from .devcontainer/cuda12.9-pip/devcontainer.json rename to .devcontainer/cuda12.8-pip/devcontainer.json index d64a5f6b0..e89ed2218 100644 --- a/.devcontainer/cuda12.9-pip/devcontainer.json +++ b/.devcontainer/cuda12.8-pip/devcontainer.json @@ -3,15 +3,15 @@ "context": "${localWorkspaceFolder}/.devcontainer", "dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile", "args": { - "CUDA": "12.9", + "CUDA": "12.8", "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:25.06-cpp-cuda12.9-ubuntu22.04" + "BASE": "rapidsai/devcontainers:25.06-cpp-cuda12.8-ubuntu22.04" } }, "runArgs": [ "--rm", "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.06-cuda12.9-pip" + "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.06-cuda12.8-pip" ], "hostRequirements": {"gpu": "optional"}, "features": { @@ -20,7 +20,7 @@ "overrideFeatureInstallOrder": [ "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" ], - "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config/pip,local/share/${localWorkspaceFolderBasename}-cuda12.9-venvs}"], + "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config/pip,local/share/${localWorkspaceFolderBasename}-cuda12.8-venvs}"], "postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"], "workspaceFolder": "/home/coder", "workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent", @@ -28,7 +28,7 @@ "source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.local/share/${localWorkspaceFolderBasename}-cuda12.9-venvs,target=/home/coder/.local/share/venvs,type=bind,consistency=consistent" + "source=${localWorkspaceFolder}/../.local/share/${localWorkspaceFolderBasename}-cuda12.8-venvs,target=/home/coder/.local/share/venvs,type=bind,consistency=consistent" ], "customizations": { "vscode": { diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9c735d505..1e61be110 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -40,7 +40,7 @@ jobs: cpp-build: needs: [telemetry-setup] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -49,7 +49,7 @@ jobs: python-build: needs: [telemetry-setup, cpp-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -58,7 +58,7 @@ jobs: upload-conda: needs: [cpp-build, python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-upload-packages.yaml@branch-25.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -68,7 +68,7 @@ jobs: if: github.ref_type == 'branch' needs: [python-build] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -81,7 +81,7 @@ jobs: wheel-build-cpp: needs: [telemetry-setup] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.06 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: ${{ inputs.build_type || 'branch' }} @@ -94,7 +94,7 @@ jobs: wheel-build-python: needs: [telemetry-setup, wheel-build-cpp] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -106,7 +106,7 @@ jobs: wheel-publish-cpp: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} @@ -117,7 +117,7 @@ jobs: wheel-publish-python: needs: wheel-build-python secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/wheels-publish.yaml@branch-25.06 with: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 577eb528b..a751f77f5 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -26,7 +26,7 @@ jobs: - devcontainer - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/pr-builder.yaml@branch-25.06 if: always() with: needs: ${{ toJSON(needs) }} @@ -57,7 +57,7 @@ jobs: needs: - telemetry-setup secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-25.06 with: files_yaml: | test_cpp: @@ -79,40 +79,40 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/checks.yaml@branch-25.06 with: enable_check_generated_files: false ignored_pr_jobs: "telemetry-summarize" conda-cpp-build: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.06 with: build_type: pull-request conda-cpp-tests: needs: [conda-cpp-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.06 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp with: build_type: pull-request conda-python-build: needs: conda-cpp-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.06 with: build_type: pull-request conda-python-tests: needs: [conda-python-build, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.06 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request docs-build: needs: conda-python-build secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/custom-job.yaml@branch-25.06 with: build_type: pull-request node_type: "gpu-l4-latest-1" @@ -122,7 +122,7 @@ jobs: wheel-build-cpp: needs: checks secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.06 with: matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber))) build_type: pull-request @@ -132,7 +132,7 @@ jobs: wheel-build-python: needs: wheel-build-cpp secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/wheels-build.yaml@branch-25.06 with: build_type: pull-request script: ci/build_wheel_python.sh @@ -141,7 +141,7 @@ jobs: wheel-tests: needs: [wheel-build-python, changed-files] secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.06 if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request @@ -150,10 +150,10 @@ jobs: secrets: inherit needs: - telemetry-setup - uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/build-in-devcontainer.yaml@branch-25.06 with: arch: '["amd64"]' - cuda: '["12.9"]' + cuda: '["12.8"]' build_command: | sccache --zero-stats; build-all -DBUILD_BENCHMARKS=ON --verbose 2>&1 | tee telemetry-artifacts/build.log; diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d4ab68db4..7744b7263 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,7 +19,7 @@ on: jobs: cpp-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-tests.yaml@branch-25.06 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} @@ -27,7 +27,7 @@ jobs: sha: ${{ inputs.sha }} python-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/conda-python-tests.yaml@branch-25.06 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} @@ -35,7 +35,7 @@ jobs: sha: ${{ inputs.sha }} wheel-tests: secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/wheels-test.yaml@branch-25.06 with: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} diff --git a/.github/workflows/trigger-breaking-change-alert.yaml b/.github/workflows/trigger-breaking-change-alert.yaml index 83deb407b..475380cb6 100644 --- a/.github/workflows/trigger-breaking-change-alert.yaml +++ b/.github/workflows/trigger-breaking-change-alert.yaml @@ -12,7 +12,7 @@ jobs: trigger-notifier: if: contains(github.event.pull_request.labels.*.name, 'breaking') secrets: inherit - uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@cuda-12.9.0 + uses: rapidsai/shared-workflows/.github/workflows/breaking-change-alert.yaml@branch-25.06 with: sender_login: ${{ github.event.sender.login }} sender_avatar: ${{ github.event.sender.avatar_url }} diff --git a/README.md b/README.md index 2ad0ced5f..8ffd932be 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ RMM can be installed with conda. You can get a minimal conda installation with [ Install RMM with: ```bash -conda install -c rapidsai -c conda-forge -c nvidia rmm cuda-version=12.9 +conda install -c rapidsai -c conda-forge -c nvidia rmm cuda-version=12.8 ``` We also provide [nightly conda packages](https://anaconda.org/rapidsai-nightly) built from the HEAD @@ -90,7 +90,7 @@ $ cd rmm - Create the conda development environment `rmm_dev` ```bash # create the conda environment (assuming in base `rmm` directory) -$ conda env create --name rmm_dev --file conda/environments/all_cuda-129_arch-x86_64.yaml +$ conda env create --name rmm_dev --file conda/environments/all_cuda-128_arch-x86_64.yaml # activate the environment $ conda activate rmm_dev ``` diff --git a/conda/environments/all_cuda-129_arch-aarch64.yaml b/conda/environments/all_cuda-128_arch-aarch64.yaml similarity index 94% rename from conda/environments/all_cuda-129_arch-aarch64.yaml rename to conda/environments/all_cuda-128_arch-aarch64.yaml index ca1beb155..ebb6c4da1 100644 --- a/conda/environments/all_cuda-129_arch-aarch64.yaml +++ b/conda/environments/all_cuda-128_arch-aarch64.yaml @@ -12,7 +12,7 @@ dependencies: - cmake>=3.30.4 - cuda-nvcc - cuda-python>=12.6.2,<13.0a0 -- cuda-version=12.9 +- cuda-version=12.8 - cxx-compiler - cython>=3.0.0 - doxygen=1.9.1 @@ -39,4 +39,4 @@ dependencies: - sphinx<8.2.0 - sphinx_rtd_theme - sysroot_linux-aarch64==2.28 -name: all_cuda-129_arch-aarch64 +name: all_cuda-128_arch-aarch64 diff --git a/conda/environments/all_cuda-129_arch-x86_64.yaml b/conda/environments/all_cuda-128_arch-x86_64.yaml similarity index 94% rename from conda/environments/all_cuda-129_arch-x86_64.yaml rename to conda/environments/all_cuda-128_arch-x86_64.yaml index 01b0b49a4..8f6dfce78 100644 --- a/conda/environments/all_cuda-129_arch-x86_64.yaml +++ b/conda/environments/all_cuda-128_arch-x86_64.yaml @@ -12,7 +12,7 @@ dependencies: - cmake>=3.30.4 - cuda-nvcc - cuda-python>=12.6.2,<13.0a0 -- cuda-version=12.9 +- cuda-version=12.8 - cxx-compiler - cython>=3.0.0 - doxygen=1.9.1 @@ -39,4 +39,4 @@ dependencies: - sphinx<8.2.0 - sphinx_rtd_theme - sysroot_linux-64==2.28 -name: all_cuda-129_arch-x86_64 +name: all_cuda-128_arch-x86_64 diff --git a/dependencies.yaml b/dependencies.yaml index 486a42172..1b5ad562d 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -3,7 +3,7 @@ files: all: output: conda matrix: - cuda: ["11.8", "12.9"] + cuda: ["11.8", "12.8"] arch: [x86_64, aarch64] includes: - build From ad4754dad0d9f575172426f1b45e12b9608fee2f Mon Sep 17 00:00:00 2001 From: Peter Andreas Entschev Date: Sat, 17 May 2025 15:54:22 +0200 Subject: [PATCH 610/675] Expose option to enable fabric memory handle support to Python (#1787) Follow-up to https://github.com/rapidsai/rmm/pull/1743, exposing a way to enable fabric memory handle to Python. Authors: - Peter Andreas Entschev (https://github.com/pentschev) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Bradley Dice (https://github.com/bdice) - Rong Ou (https://github.com/rongou) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1787 --- .../mr/device/cuda_async_memory_resource.hpp | 3 +- python/rmm/rmm/librmm/memory_resource.pxd | 9 +++--- python/rmm/rmm/pylibrmm/memory_resource.pyx | 31 +++++++++++++------ python/rmm/rmm/tests/test_rmm.py | 27 ++++++++++++++++ 4 files changed, 55 insertions(+), 15 deletions(-) diff --git a/cpp/include/rmm/mr/device/cuda_async_memory_resource.hpp b/cpp/include/rmm/mr/device/cuda_async_memory_resource.hpp index cbccc3490..f425799cb 100644 --- a/cpp/include/rmm/mr/device/cuda_async_memory_resource.hpp +++ b/cpp/include/rmm/mr/device/cuda_async_memory_resource.hpp @@ -28,6 +28,7 @@ #include #include +#include #include namespace RMM_NAMESPACE { @@ -55,7 +56,7 @@ class cuda_async_memory_resource final : public device_memory_resource { * https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html and ensure the enum * values are kept in sync with the CUDA documentation. */ - enum class allocation_handle_type { + enum class allocation_handle_type : std::int32_t { none = 0x0, ///< Does not allow any export mechanism. posix_file_descriptor = 0x1, ///< Allows a file descriptor to be used for exporting. Permitted ///< only on POSIX systems. diff --git a/python/rmm/rmm/librmm/memory_resource.pxd b/python/rmm/rmm/librmm/memory_resource.pxd index a24aa338e..0194e604e 100644 --- a/python/rmm/rmm/librmm/memory_resource.pxd +++ b/python/rmm/rmm/librmm/memory_resource.pxd @@ -17,7 +17,7 @@ from builtins import BaseException from libc.stddef cimport size_t -from libc.stdint cimport int8_t, int64_t +from libc.stdint cimport int8_t, int32_t, int64_t from libcpp cimport bool from libcpp.optional cimport optional from libcpp.pair cimport pair @@ -120,17 +120,16 @@ cdef extern from "rmm/mr/device/cuda_async_view_memory_resource.hpp" \ cudaMemPool_t pool_handle) except + cudaMemPool_t pool_handle() const -# TODO: when we adopt Cython 3.0 use enum class cdef extern from "rmm/mr/device/cuda_async_memory_resource.hpp" \ namespace \ - "rmm::mr::cuda_async_memory_resource::allocation_handle_type" \ + "rmm::mr::cuda_async_memory_resource" \ nogil: - enum allocation_handle_type \ - "rmm::mr::cuda_async_memory_resource::allocation_handle_type": + cpdef enum class allocation_handle_type(int32_t): none posix_file_descriptor win32 win32_kmt + fabric cdef extern from "rmm/mr/device/pool_memory_resource.hpp" \ diff --git a/python/rmm/rmm/pylibrmm/memory_resource.pyx b/python/rmm/rmm/pylibrmm/memory_resource.pyx index 253352e7c..7e02bfa62 100644 --- a/python/rmm/rmm/pylibrmm/memory_resource.pyx +++ b/python/rmm/rmm/pylibrmm/memory_resource.pyx @@ -22,7 +22,7 @@ from collections import defaultdict cimport cython from cython.operator cimport dereference as deref from libc.stddef cimport size_t -from libc.stdint cimport int8_t, uintptr_t +from libc.stdint cimport int8_t, int32_t, uintptr_t from libcpp cimport bool from libcpp.memory cimport make_unique, unique_ptr from libcpp.optional cimport optional @@ -67,7 +67,6 @@ from rmm.librmm.memory_resource cimport ( managed_memory_resource, percent_of_free_device_memory as c_percent_of_free_device_memory, pool_memory_resource, - posix_file_descriptor, prefetch_resource_adaptor, sam_headroom_memory_resource, statistics_resource_adaptor, @@ -167,12 +166,16 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): enable_ipc: bool, optional If True, enables export of POSIX file descriptor handles for the memory allocated by this resource so that it can be used with CUDA IPC. + enable_fabric: bool, optional + If True, enables export of fabric handles for the memory allocated by + this resource. """ def __cinit__( self, initial_pool_size=None, release_threshold=None, - enable_ipc=False + enable_ipc=False, + enable_fabric=False ): cdef optional[size_t] c_initial_pool_size = ( optional[size_t]() @@ -186,13 +189,23 @@ cdef class CudaAsyncMemoryResource(DeviceMemoryResource): else optional[size_t]( release_threshold) ) - # If IPC memory handles are not supported, the constructor below will - # raise an error from C++. - cdef optional[allocation_handle_type] c_export_handle_type = ( - optional[allocation_handle_type]( - posix_file_descriptor + # If IPC or fabric memory handles are enabled but not supported, the + # constructor below will raise an error from C++. + cdef allocation_handle_type descriptor = allocation_handle_type.none + if enable_ipc: + descriptor = ( + descriptor | + allocation_handle_type.posix_file_descriptor + ) + if enable_fabric: + descriptor = ( + descriptor | + allocation_handle_type.fabric ) - if enable_ipc + + cdef optional[allocation_handle_type] c_export_handle_type = ( + optional[allocation_handle_type](descriptor) + if (enable_ipc or enable_fabric) else optional[allocation_handle_type]() ) diff --git a/python/rmm/rmm/tests/test_rmm.py b/python/rmm/rmm/tests/test_rmm.py index 2fc917863..287858487 100644 --- a/python/rmm/rmm/tests/test_rmm.py +++ b/python/rmm/rmm/tests/test_rmm.py @@ -689,6 +689,33 @@ def test_cuda_async_memory_resource_ipc(): assert rmm.mr.get_current_device_resource_type() is type(mr) +def test_cuda_async_memory_resource_fabric(): + # TODO: We don't have a great way to check if fabric is supported in Python, + # without using the C++ function + # rmm::detail::runtime_async_alloc::is_export_handle_type_supported. + # We can't accurately test this via Python because + # cuda-python always has the fabric handle enum defined (which normally + # requires a CUDA 12.3 runtime) and the cuda-compat package in Docker + # containers prevents us from assuming that the driver we see actually + # supports fabric handles even if its reported version is new enough (we may + # see a newer driver than what is present on the host). We can only know + # the expected behavior by checking the C++ function mentioned above, which + # is then a redundant check because the CudaAsyncMemoryResource constructor + # follows the same logic. Therefore, we cannot easily ensure this test + # passes in certain expected configurations -- we can only ensure that if + # it fails, it fails in a predictable way. + try: + mr = rmm.mr.CudaAsyncMemoryResource(enable_fabric=True) + except RuntimeError as e: + # CUDA 12.3 is required for fabric memory handle support + assert str(e).endswith( + "Requested IPC memory handle type not supported" + ) + else: + rmm.mr.set_current_device_resource(mr) + assert rmm.mr.get_current_device_resource_type() is type(mr) + + @pytest.mark.parametrize("nelems", _nelems) def test_cuda_async_memory_resource_stream(nelems): # test that using CudaAsyncMemoryResource From 7d9e347bf9051ee83040a0045e65e64f268201c9 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 21 May 2025 14:43:09 -0400 Subject: [PATCH 611/675] use 'rapids-init-pip' in wheel CI, other CI changes (#1926) Proposes a batch of small, mostly-unrelated changes to building and packaging. These are all part of RAPIDS-wide efforts to make it easier to reproduce CI locally and to use artifacts from one project's CI in another project's CI. Contributes to https://github.com/rapidsai/build-planning/issues/178 * prevents triggering expensive CI jobs based on PRs modifying `ci/release/update-version.sh` Contributes to https://github.com/rapidsai/shared-workflows/issues/356 * explicitly provides an input for `script` to workflows using it, instead of relying on a default value coming from the workflow file Contributes to https://github.com/rapidsai/shared-workflows/issues/337 * switches from input `run_script` to `script` in uses of the `custom-job` workflow Contributes to https://github.com/rapidsai/build-planning/issues/179 * adds a call to `rapids-init-pip` near the beginning of all CI scripts that use `pip` Contributes to https://github.com/rapidsai/gha-tools/issues/145 * confirmed that `rapids-configure-conda-channels` is not used in any builds scripts using `rattler-build` ## Notes for Reviewers # Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1926 --- .github/workflows/build.yaml | 4 +++- .github/workflows/pr.yaml | 8 +++++++- .github/workflows/test.yaml | 2 ++ ci/build_wheel_cpp.sh | 1 + ci/build_wheel_python.sh | 15 ++++++++++----- ci/test_wheel.sh | 10 +++++++++- 6 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1e61be110..17b6a4ca4 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -45,6 +45,7 @@ jobs: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} date: ${{ inputs.date }} + script: ci/build_cpp.sh sha: ${{ inputs.sha }} python-build: needs: [telemetry-setup, cpp-build] @@ -54,6 +55,7 @@ jobs: build_type: ${{ inputs.build_type || 'branch' }} branch: ${{ inputs.branch }} date: ${{ inputs.date }} + script: ci/build_python.sh sha: ${{ inputs.sha }} upload-conda: needs: [cpp-build, python-build] @@ -77,7 +79,7 @@ jobs: node_type: "gpu-l4-latest-1" arch: "amd64" container_image: "rapidsai/ci-conda:latest" - run_script: "ci/build_docs.sh" + script: ci/build_docs.sh wheel-build-cpp: needs: [telemetry-setup] secrets: inherit diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index a751f77f5..d081ff180 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -66,6 +66,7 @@ jobs: - '!.pre-commit-config.yaml' - '!CONTRIBUTING.md' - '!README.md' + - '!ci/release/update-version.sh' - '!img/**' - '!python/**' test_python: @@ -74,6 +75,7 @@ jobs: - '!.pre-commit-config.yaml' - '!CONTRIBUTING.md' - '!README.md' + - '!ci/release/update-version.sh' - '!img/**' checks: secrets: inherit @@ -89,6 +91,7 @@ jobs: uses: rapidsai/shared-workflows/.github/workflows/conda-cpp-build.yaml@branch-25.06 with: build_type: pull-request + script: ci/build_cpp.sh conda-cpp-tests: needs: [conda-cpp-build, changed-files] secrets: inherit @@ -96,12 +99,14 @@ jobs: if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_cpp with: build_type: pull-request + script: ci/test_cpp.sh conda-python-build: needs: conda-cpp-build secrets: inherit uses: rapidsai/shared-workflows/.github/workflows/conda-python-build.yaml@branch-25.06 with: build_type: pull-request + script: ci/build_python.sh conda-python-tests: needs: [conda-python-build, changed-files] secrets: inherit @@ -109,6 +114,7 @@ jobs: if: fromJSON(needs.changed-files.outputs.changed_file_groups).test_python with: build_type: pull-request + script: ci/test_python.sh docs-build: needs: conda-python-build secrets: inherit @@ -118,7 +124,7 @@ jobs: node_type: "gpu-l4-latest-1" arch: "amd64" container_image: "rapidsai/ci-conda:latest" - run_script: "ci/build_docs.sh" + script: "ci/build_docs.sh" wheel-build-cpp: needs: checks secrets: inherit diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7744b7263..fb1ff254b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -24,6 +24,7 @@ jobs: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} date: ${{ inputs.date }} + script: ci/test_cpp.sh sha: ${{ inputs.sha }} python-tests: secrets: inherit @@ -32,6 +33,7 @@ jobs: build_type: ${{ inputs.build_type }} branch: ${{ inputs.branch }} date: ${{ inputs.date }} + script: ci/test_python.sh sha: ${{ inputs.sha }} wheel-tests: secrets: inherit diff --git a/ci/build_wheel_cpp.sh b/ci/build_wheel_cpp.sh index e582fb9f2..9d53f46b0 100755 --- a/ci/build_wheel_cpp.sh +++ b/ci/build_wheel_cpp.sh @@ -8,6 +8,7 @@ package_dir="python/librmm" source rapids-configure-sccache source rapids-date-string +source rapids-init-pip rapids-generate-version > ./VERSION diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index 65db43e1a..02b531ee4 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -8,6 +8,7 @@ package_dir="python/rmm" source rapids-configure-sccache source rapids-date-string +source rapids-init-pip rapids-generate-version > ./VERSION @@ -18,17 +19,21 @@ LIBRMM_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="librmm_${RAPIDS_PY_CUDA_SUFFIX}" rapid # ensure 'rmm' wheel builds always use the 'librmm' just built in the same CI run # -# using env variable PIP_CONSTRAINT is necessary to ensure the constraints -# are used when created the isolated build environment -echo "librmm-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo "${LIBRMM_WHEELHOUSE}"/librmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)" > ./build-constraints.txt +# Using env variable PIP_CONSTRAINT (initialized by 'rapids-init-pip') is necessary to ensure the constraints +# are used when creating the isolated build environment. +echo "librmm-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo "${LIBRMM_WHEELHOUSE}"/librmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)" >> "${PIP_CONSTRAINT}" sccache --zero-stats # Creates artifacts directory for telemetry source rapids-telemetry-setup -PIP_CONSTRAINT="${PWD}/build-constraints.txt" \ - rapids-telemetry-record build.log rapids-pip-retry wheel . -w dist -v --no-deps --disable-pip-version-check +rapids-telemetry-record build.log rapids-pip-retry wheel \ + -v \ + -w dist \ + --no-deps \ + --disable-pip-version-check \ + . rapids-telemetry-record sccache-stats.txt sccache --show-adv-stats diff --git a/ci/test_wheel.sh b/ci/test_wheel.sh index 02ec6cf7c..25480f46c 100755 --- a/ci/test_wheel.sh +++ b/ci/test_wheel.sh @@ -3,6 +3,8 @@ set -eou pipefail +source rapids-init-pip + RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}")" LIBRMM_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="librmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-github cpp) RMM_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-github python) @@ -10,10 +12,16 @@ RMM_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="rmm_${RAPIDS_PY_CUDA_SUFFIX}" rapids-down # generate constraints (possibly pinning to oldest support versions of dependencies) rapids-generate-pip-constraints test_python ./constraints.txt -# echo to expand wildcard before adding '[extra]' requires for pip +# notes: +# +# * echo to expand wildcard before adding `[test]` requires for pip +# * need to provide --constraint="${PIP_CONSTRAINT}" because that environment variable is +# ignored if any other --constraint are passed via the CLI +# rapids-pip-retry install \ -v \ --constraint ./constraints.txt \ + --constraint "${PIP_CONSTRAINT}" \ "$(echo "${LIBRMM_WHEELHOUSE}"/librmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)" \ "$(echo "${RMM_WHEELHOUSE}"/rmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)[test]" From 462d2baaf97ee8bcbe61ff9f302ac55d2349f5c9 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Tue, 27 May 2025 16:42:30 -0500 Subject: [PATCH 612/675] stop uploading packages to downloads.rapids.ai (#1929) Contributes to https://github.com/rapidsai/build-planning/issues/181 * removes all uploads of conda packages and wheels to `downloads.rapids.ai` ## Notes for Reviewers ### How I identified changes Looked for uses of the relevant `gha-tools` tools, as well as documentation about `downloads.rapids.ai`, being on the NVIDIA VPN, using S3, etc. like this: ```shell git grep -i -E 's3|upload|downloads\.rapids|vpn' ``` ### How I tested this See "How I tested this" on https://github.com/rapidsai/shared-workflows/pull/364 # Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/rmm/pull/1929 --- ci/build_cpp.sh | 2 -- ci/build_python.sh | 2 -- ci/build_wheel_cpp.sh | 5 ----- ci/build_wheel_python.sh | 3 --- 4 files changed, 12 deletions(-) diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 47212813b..0662de234 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -41,5 +41,3 @@ rm -rf "$RAPIDS_CONDA_BLD_OUTPUT_DIR"/build_cache # Run the libcudacxx flag test at build time, since compilers are available rapids-logger "Run libcudacxx_flag_test" ./cpp/tests/libcudacxx_flag_test/libcudacxx_flag_test.sh - -rapids-upload-conda-to-s3 cpp diff --git a/ci/build_python.sh b/ci/build_python.sh index adbbbea19..acaac99a1 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -42,5 +42,3 @@ rapids-telemetry-record sccache-stats.txt sccache --show-adv-stats # See https://github.com/prefix-dev/rattler-build/issues/1424 rm -rf "$RAPIDS_CONDA_BLD_OUTPUT_DIR"/build_cache - -rapids-upload-conda-to-s3 python diff --git a/ci/build_wheel_cpp.sh b/ci/build_wheel_cpp.sh index 9d53f46b0..9b30dfd1a 100755 --- a/ci/build_wheel_cpp.sh +++ b/ci/build_wheel_cpp.sh @@ -3,7 +3,6 @@ set -euo pipefail -package_name="librmm" package_dir="python/librmm" source rapids-configure-sccache @@ -12,8 +11,6 @@ source rapids-init-pip rapids-generate-version > ./VERSION -RAPIDS_PY_CUDA_SUFFIX=$(rapids-wheel-ctk-name-gen "${RAPIDS_CUDA_VERSION}") - cd "${package_dir}" sccache --zero-stats @@ -32,5 +29,3 @@ python -m auditwheel repair \ ${dist_dir}/* ../../ci/validate_wheel.sh "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" - -RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 cpp "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index 02b531ee4..f20959aab 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -3,7 +3,6 @@ set -euo pipefail -package_name="rmm" package_dir="python/rmm" source rapids-configure-sccache @@ -48,8 +47,6 @@ python -m auditwheel repair \ ../../ci/validate_wheel.sh "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" -RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 python "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}" - absolute_wheel_dir=$(realpath "${RAPIDS_WHEEL_BLD_OUTPUT_DIR}") # switch back to the root of the repo and check symbol visibility popd From e7356abe85949249d79a1c83fb9352c10f5d4c0a Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Fri, 30 May 2025 11:55:42 -0500 Subject: [PATCH 613/675] Remove CUDA 11 devcontainers and update CI scripts (#1933) This PR removes CUDA 11 devcontainers and updates CI scripts. xref: https://github.com/rapidsai/build-planning/issues/184 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1933 --- .../cuda11.8-conda/devcontainer.json | 42 ------------------- .devcontainer/cuda11.8-pip/devcontainer.json | 41 ------------------ .github/workflows/pr.yaml | 5 +-- 3 files changed, 1 insertion(+), 87 deletions(-) delete mode 100644 .devcontainer/cuda11.8-conda/devcontainer.json delete mode 100644 .devcontainer/cuda11.8-pip/devcontainer.json diff --git a/.devcontainer/cuda11.8-conda/devcontainer.json b/.devcontainer/cuda11.8-conda/devcontainer.json deleted file mode 100644 index 8deaf6f9f..000000000 --- a/.devcontainer/cuda11.8-conda/devcontainer.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "build": { - "context": "${localWorkspaceFolder}/.devcontainer", - "dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile", - "args": { - "CUDA": "11.8", - "PYTHON_PACKAGE_MANAGER": "conda", - "BASE": "rapidsai/devcontainers:25.08-cpp-cuda11.8-mambaforge-ubuntu22.04" - } - }, - "runArgs": [ - "--rm", - "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.08-cuda11.8-conda" - ], - "hostRequirements": {"gpu": "optional"}, - "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.8": {} - }, - "overrideFeatureInstallOrder": [ - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" - ], - "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config,conda/pkgs,conda/${localWorkspaceFolderBasename}-cuda11.8-envs}"], - "postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"], - "workspaceFolder": "/home/coder", - "workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent", - "mounts": [ - "source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.conda/pkgs,target=/home/coder/.conda/pkgs,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.conda/${localWorkspaceFolderBasename}-cuda11.8-envs,target=/home/coder/.conda/envs,type=bind,consistency=consistent" - ], - "customizations": { - "vscode": { - "extensions": [ - "ms-python.flake8", - "nvidia.nsight-vscode-edition" - ] - } - } -} diff --git a/.devcontainer/cuda11.8-pip/devcontainer.json b/.devcontainer/cuda11.8-pip/devcontainer.json deleted file mode 100644 index 31a095036..000000000 --- a/.devcontainer/cuda11.8-pip/devcontainer.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "build": { - "context": "${localWorkspaceFolder}/.devcontainer", - "dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile", - "args": { - "CUDA": "11.8", - "PYTHON_PACKAGE_MANAGER": "pip", - "BASE": "rapidsai/devcontainers:25.08-cpp-cuda11.8-ubuntu22.04" - } - }, - "runArgs": [ - "--rm", - "--name", - "${localEnv:USER:anon}-rapids-${localWorkspaceFolderBasename}-25.08-cuda11.8-pip" - ], - "hostRequirements": {"gpu": "optional"}, - "features": { - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils:25.8": {} - }, - "overrideFeatureInstallOrder": [ - "ghcr.io/rapidsai/devcontainers/features/rapids-build-utils" - ], - "initializeCommand": ["/bin/bash", "-c", "mkdir -m 0755 -p ${localWorkspaceFolder}/../.{aws,cache,config/pip,local/share/${localWorkspaceFolderBasename}-cuda11.8-venvs}"], - "postAttachCommand": ["/bin/bash", "-c", "if [ ${CODESPACES:-false} = 'true' ]; then . devcontainer-utils-post-attach-command; . rapids-post-attach-command; fi"], - "workspaceFolder": "/home/coder", - "workspaceMount": "source=${localWorkspaceFolder},target=/home/coder/rmm,type=bind,consistency=consistent", - "mounts": [ - "source=${localWorkspaceFolder}/../.aws,target=/home/coder/.aws,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.cache,target=/home/coder/.cache,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.config,target=/home/coder/.config,type=bind,consistency=consistent", - "source=${localWorkspaceFolder}/../.local/share/${localWorkspaceFolderBasename}-cuda11.8-venvs,target=/home/coder/.local/share/venvs,type=bind,consistency=consistent" - ], - "customizations": { - "vscode": { - "extensions": [ - "ms-python.flake8", - "nvidia.nsight-vscode-edition" - ] - } - } -} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index c4f9b2230..c7f25cc90 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -42,10 +42,7 @@ jobs: if: ${{ vars.TELEMETRY_ENABLED == 'true' }} uses: rapidsai/shared-actions/telemetry-dispatch-stash-base-env-vars@main check-nightly-ci: - # Switch to ubuntu-latest once it defaults to a version of Ubuntu that - # provides at least Python 3.11 (see - # https://docs.python.org/3/library/datetime.html#datetime.date.fromisoformat) - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest env: RAPIDS_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: From d7b953812cf8ef0fa4e4e53fb21a80d959847a68 Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Wed, 4 Jun 2025 14:19:49 -0400 Subject: [PATCH 614/675] Merge pull request #1942 from gforsyth/hotfix_pytest fix(pytest): disable warning that gets raised to INTERNALERROR in pytest8.4.0 --- python/rmm/.coveragerc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/rmm/.coveragerc b/python/rmm/.coveragerc index 00997a39b..3c20614e3 100644 --- a/python/rmm/.coveragerc +++ b/python/rmm/.coveragerc @@ -2,4 +2,4 @@ [run] include = rmm/* omit = rmm/tests/* -disable_warnings=include-ignored +disable_warnings=include-ignored,no-data-collected From 013e20318592cd4f09fab43e66aa3e4932af2936 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 4 Jun 2025 17:19:07 -0500 Subject: [PATCH 615/675] Run system MR tests in isolation. (#1945) This fixes one of the problems reported in #1935, where system MR tests need to run in isolation (in serial, rather than in parallel with other tests). This test checks the free memory before and after an allocation, so running it with other tests in parallel is flaky. --------- Co-authored-by: Kyle Edwards --- cpp/tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 056253d92..89d76fd53 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -214,7 +214,7 @@ ConfigureTest(BINNING_MR_TEST mr/device/binning_mr_tests.cpp) ConfigureTest(CALLBACK_MR_TEST mr/device/callback_mr_tests.cpp) # system memory resource tests -ConfigureTest(SYSTEM_MR_TEST mr/device/system_mr_tests.cu) +ConfigureTest(SYSTEM_MR_TEST mr/device/system_mr_tests.cu GPUS 1 PERCENT 100) # container multidevice tests ConfigureTest(CONTAINER_MULTIDEVICE_TEST container_multidevice_tests.cu) From 2e4489272cb98df4be298270dc4546095ec8d476 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Thu, 5 Jun 2025 11:13:55 -0400 Subject: [PATCH 616/675] Update Changelog [skip ci] --- CHANGELOG.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c8d9e1e8..cfc4b1298 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,51 @@ +# rmm 25.06.00 (5 Jun 2025) + +## 🚨 Breaking Changes + +- Convert part of RMM to a precompiled library ([#1896](https://github.com/rapidsai/rmm/pull/1896)) [@bdice](https://github.com/bdice) +- Move RMM C++ code into cpp directory. ([#1883](https://github.com/rapidsai/rmm/pull/1883)) [@bdice](https://github.com/bdice) + +## 🐛 Bug Fixes + +- Run system MR tests in isolation. ([#1945](https://github.com/rapidsai/rmm/pull/1945)) [@bdice](https://github.com/bdice) +- Use auditwheel to properly retag the wheel ([#1913](https://github.com/rapidsai/rmm/pull/1913)) [@vyasr](https://github.com/vyasr) +- Fix logger macros ([#1884](https://github.com/rapidsai/rmm/pull/1884)) [@vyasr](https://github.com/vyasr) + +## 📖 Documentation + +- Move docs to top level. ([#1917](https://github.com/rapidsai/rmm/pull/1917)) [@bdice](https://github.com/bdice) +- Update Readme for the logging `set_level` ([#1911](https://github.com/rapidsai/rmm/pull/1911)) [@JigaoLuo](https://github.com/JigaoLuo) +- Fixed documentation example for `DeviceBuffer.to_device` ([#1881](https://github.com/rapidsai/rmm/pull/1881)) [@TomAugspurger](https://github.com/TomAugspurger) + +## 🚀 New Features + +- Convert part of RMM to a precompiled library ([#1896](https://github.com/rapidsai/rmm/pull/1896)) [@bdice](https://github.com/bdice) +- Set mempool hw_decompress flag if driver supports it ([#1875](https://github.com/rapidsai/rmm/pull/1875)) [@bdice](https://github.com/bdice) +- Expose option to enable fabric memory handle support to Python ([#1787](https://github.com/rapidsai/rmm/pull/1787)) [@pentschev](https://github.com/pentschev) + +## 🛠️ Improvements + +- fix(pytest): disable warning that gets raised to INTERNALERROR in pytest8.4.0 ([#1942](https://github.com/rapidsai/rmm/pull/1942)) [@gforsyth](https://github.com/gforsyth) +- use 'rapids-init-pip' in wheel CI, other CI changes ([#1926](https://github.com/rapidsai/rmm/pull/1926)) [@jameslamb](https://github.com/jameslamb) +- Finish CUDA 12.9 migration and use branch-25.06 workflows ([#1921](https://github.com/rapidsai/rmm/pull/1921)) [@bdice](https://github.com/bdice) +- Update to clang 20 ([#1918](https://github.com/rapidsai/rmm/pull/1918)) [@bdice](https://github.com/bdice) +- Quote head_rev in conda recipes ([#1915](https://github.com/rapidsai/rmm/pull/1915)) [@bdice](https://github.com/bdice) +- Build and test with CUDA 12.9.0 ([#1907](https://github.com/rapidsai/rmm/pull/1907)) [@bdice](https://github.com/bdice) +- Fix cpp wheel name to librmm. ([#1903](https://github.com/rapidsai/rmm/pull/1903)) [@bdice](https://github.com/bdice) +- Revert "Publish wheels and conda packages from Github Artifacts" ([#1898](https://github.com/rapidsai/rmm/pull/1898)) [@bdice](https://github.com/bdice) +- Publish wheels and conda packages from Github Artifacts ([#1897](https://github.com/rapidsai/rmm/pull/1897)) [@VenkateshJaya](https://github.com/VenkateshJaya) +- Download build artifacts from Github for CI ([#1895](https://github.com/rapidsai/rmm/pull/1895)) [@VenkateshJaya](https://github.com/VenkateshJaya) +- remove mkdir and test corresponding shared workflow ([#1892](https://github.com/rapidsai/rmm/pull/1892)) [@msarahan](https://github.com/msarahan) +- Revert "Auto-sync draft PRs" ([#1891](https://github.com/rapidsai/rmm/pull/1891)) [@bdice](https://github.com/bdice) +- Auto-sync draft PRs ([#1890](https://github.com/rapidsai/rmm/pull/1890)) [@bdice](https://github.com/bdice) +- Add ARM conda environments ([#1889](https://github.com/rapidsai/rmm/pull/1889)) [@bdice](https://github.com/bdice) +- Vendor RAPIDS.cmake to avoid network call. ([#1886](https://github.com/rapidsai/rmm/pull/1886)) [@bdice](https://github.com/bdice) +- [pre-commit.ci] pre-commit autoupdate ([#1885](https://github.com/rapidsai/rmm/pull/1885)) [@pre-commit-ci[bot]](https://github.com/pre-commit-ci[bot]) +- Move RMM C++ code into cpp directory. ([#1883](https://github.com/rapidsai/rmm/pull/1883)) [@bdice](https://github.com/bdice) +- refactor(rattler): enable strict channel priority for builds ([#1867](https://github.com/rapidsai/rmm/pull/1867)) [@gforsyth](https://github.com/gforsyth) +- Add support for Python 3.13 ([#1851](https://github.com/rapidsai/rmm/pull/1851)) [@bdice](https://github.com/bdice) +- Streamlining wheel builds to use fixed location and uploading build artifacts to Github ([#1810](https://github.com/rapidsai/rmm/pull/1810)) [@VenkateshJaya](https://github.com/VenkateshJaya) + # rmm 25.04.00 (9 Apr 2025) ## 🚨 Breaking Changes From ef5d84c85bffdef5f1e87d610fab0a8d34c41ba4 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 10 Jun 2025 07:56:23 -0700 Subject: [PATCH 617/675] Temporarily disable failing test on HMM systems. (#1950) Temporarily skipping a test to unblock CI. Failures on HMM systems are being diagnosed in #1935 and #1944. --- cpp/tests/mr/device/mr_ref_test.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/tests/mr/device/mr_ref_test.hpp b/cpp/tests/mr/device/mr_ref_test.hpp index ea0a86eab..02eb171be 100644 --- a/cpp/tests/mr/device/mr_ref_test.hpp +++ b/cpp/tests/mr/device/mr_ref_test.hpp @@ -76,7 +76,8 @@ inline void test_get_current_device_resource_ref() void* ptr = rmm::mr::get_current_device_resource_ref().allocate(1_MiB); EXPECT_NE(nullptr, ptr); EXPECT_TRUE(is_properly_aligned(ptr)); - EXPECT_TRUE(is_device_accessible_memory(ptr)); + // Temporarily disabling this test, see #1935. + // EXPECT_TRUE(is_device_accessible_memory(ptr)); rmm::mr::get_current_device_resource_ref().deallocate(ptr, 1_MiB); } From 27b3dc2dec7c1bc26caecc53f38472f5ea888c47 Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Tue, 10 Jun 2025 15:48:34 -0400 Subject: [PATCH 618/675] refactor(rattler): remove cuda11 options and general cleanup (#1932) xref rapidsai/build-planning#184 Authors: - Gil Forsyth (https://github.com/gforsyth) - Bradley Dice (https://github.com/bdice) - https://github.com/jakirkham Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1932 --- conda/recipes/librmm/conda_build_config.yaml | 9 ++-- conda/recipes/librmm/recipe.yaml | 46 +++++--------------- conda/recipes/rmm/conda_build_config.yaml | 9 ++-- conda/recipes/rmm/recipe.yaml | 25 +++-------- 4 files changed, 24 insertions(+), 65 deletions(-) diff --git a/conda/recipes/librmm/conda_build_config.yaml b/conda/recipes/librmm/conda_build_config.yaml index 0a1108eb5..caf5489e1 100644 --- a/conda/recipes/librmm/conda_build_config.yaml +++ b/conda/recipes/librmm/conda_build_config.yaml @@ -1,14 +1,11 @@ c_compiler_version: - - 13 # [not os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] - - 11 # [os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] + - 13 cxx_compiler_version: - - 13 # [not os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] - - 11 # [os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] + - 13 cuda_compiler: - - cuda-nvcc # [not os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] - - nvcc # [os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] + - cuda-nvcc c_stdlib: - sysroot diff --git a/conda/recipes/librmm/recipe.yaml b/conda/recipes/librmm/recipe.yaml index 0d371641f..95f698095 100644 --- a/conda/recipes/librmm/recipe.yaml +++ b/conda/recipes/librmm/recipe.yaml @@ -1,4 +1,3 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/prefix-dev/recipe-format/main/schema.json # Copyright (c) 2018-2025, NVIDIA CORPORATION. schema_version: 1 @@ -56,8 +55,7 @@ cache: - ${{ stdlib("c") }} host: - rapids-logger =0.1 - - if: cuda_major != "11" - then: cuda-driver-dev + - cuda-driver-dev outputs: - package: @@ -79,25 +77,18 @@ outputs: - ${{ stdlib("c") }} host: - cuda-version =${{ cuda_version }} - - if: cuda_major == "11" - then: cudatoolkit - else: cuda-cudart-dev + - cuda-cudart-dev run: - ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }} - - if: cuda_major == "11" - then: cudatoolkit - else: cuda-cudart + - cuda-cudart - rapids-logger =0.1 run_exports: - ${{ pin_subpackage("librmm", upper_bound="x.x") }} ignore_run_exports: from_package: - - if: cuda_major != "11" - then: cuda-cudart-dev + - cuda-cudart-dev by_name: - cuda-version - - if: cuda_major == "11" - then: cudatoolkit tests: - script: - "test -d \"${PREFIX}/include/rmm\"" @@ -122,27 +113,19 @@ outputs: - ${{ stdlib("c") }} # this is here to help with overlinking errors against libm.so.6 and friends host: - ${{ pin_subpackage("librmm", exact=True) }} - - if: cuda_major != "11" - then: cuda-driver-dev + - cuda-driver-dev - cuda-version =${{ cuda_version }} - - if: cuda_major == "11" - then: cudatoolkit - else: cuda-cudart-dev + - cuda-cudart-dev run: - ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }} - ${{ pin_subpackage("librmm", exact=True) }} - rapids-logger =0.1 - - if: cuda_major == "11" - then: cudatoolkit - else: cuda-cudart + - cuda-cudart ignore_run_exports: from_package: - - if: cuda_major != "11" - then: cuda-cudart-dev + - cuda-cudart-dev by_name: - cuda-version - - if: cuda_major == "11" - then: cudatoolkit about: homepage: ${{ load_from_file("python/librmm/pyproject.toml").project.urls.Homepage }} license: ${{ load_from_file("python/librmm/pyproject.toml").project.license.text | replace(" ", "-") }} @@ -178,25 +161,18 @@ outputs: - cuda-version =${{ cuda_version }} host: - cuda-version =${{ cuda_version }} - - if: cuda_major == "11" - then: cudatoolkit - else: cuda-cudart-dev + - cuda-cudart-dev - ${{ pin_subpackage("librmm", exact=True) }} run: - - if: cuda_major == "11" - then: cudatoolkit - else: cuda-cudart + - cuda-cudart - ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }} - ${{ pin_subpackage("librmm", exact=True) }} ignore_run_exports: from_package: - - if: cuda_major != "11" - then: cuda-cudart-dev + - cuda-cudart-dev by_name: - cuda-version - librmm - - if: cuda_major == "11" - then: cudatoolkit about: homepage: ${{ load_from_file("python/librmm/pyproject.toml").project.urls.Homepage }} license: ${{ load_from_file("python/librmm/pyproject.toml").project.license.text | replace(" ", "-") }} diff --git a/conda/recipes/rmm/conda_build_config.yaml b/conda/recipes/rmm/conda_build_config.yaml index 0a1108eb5..caf5489e1 100644 --- a/conda/recipes/rmm/conda_build_config.yaml +++ b/conda/recipes/rmm/conda_build_config.yaml @@ -1,14 +1,11 @@ c_compiler_version: - - 13 # [not os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] - - 11 # [os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] + - 13 cxx_compiler_version: - - 13 # [not os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] - - 11 # [os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] + - 13 cuda_compiler: - - cuda-nvcc # [not os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] - - nvcc # [os.environ.get("RAPIDS_CUDA_VERSION", "").startswith("11")] + - cuda-nvcc c_stdlib: - sysroot diff --git a/conda/recipes/rmm/recipe.yaml b/conda/recipes/rmm/recipe.yaml index deed98e69..8bcf96b12 100644 --- a/conda/recipes/rmm/recipe.yaml +++ b/conda/recipes/rmm/recipe.yaml @@ -1,4 +1,3 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/prefix-dev/recipe-format/main/schema.json # Copyright (c) 2019-2025, NVIDIA CORPORATION. context: @@ -49,13 +48,8 @@ requirements: - ${{ stdlib("c") }} host: - cuda-version =${{ cuda_version }} - - if: cuda_major == "11" - then: - - cudatoolkit - - cuda-python >=11.8.5,<12.0a0 - else: - - cuda-cudart-dev - - cuda-python >=12.6.2,<13.0a0 + - cuda-cudart-dev + - cuda-python >=12.6.2,<13.0a0 - cython >=3.0.0 - rapids-build-backend >=0.3.0,<0.4.0.dev0 - librmm =${{ version }} @@ -63,22 +57,17 @@ requirements: - pip - scikit-build-core >=0.10.0 run: - - if: cuda_major == "11" - then: - - cudatoolkit - - cuda-python >=11.8.5,<12.0a0 - else: - - cuda-cudart - - cuda-python >=12.6.2,<13.0a0 + - cuda-cudart + - cuda-python >=12.6.2,<13.0a0 - ${{ pin_compatible("cuda-version", upper_bound="x", lower_bound="x") }} - numpy >=1.23,<3.0a0 - python ignore_run_exports: from_package: - - ${{ compiler("cuda") }} - cuda-python - - if: not (cuda_major == "11") - then: "cuda-cudart-dev" + - cuda-cudart-dev + by_name: + - cuda-version tests: - python: From 07dec92a22a04c4026f9cfac7455d94ce6286921 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 10 Jun 2025 15:49:41 -0400 Subject: [PATCH 619/675] Remove CUDA 11 from dependencies.yaml (#1934) Issue: https://github.com/rapidsai/build-planning/issues/184 Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) - Bradley Dice (https://github.com/bdice) - https://github.com/jakirkham Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1934 --- .../all_cuda-118_arch-aarch64.yaml | 43 ----------- .../all_cuda-118_arch-x86_64.yaml | 43 ----------- dependencies.yaml | 71 ++----------------- python/rmm/pyproject.toml | 4 +- 4 files changed, 8 insertions(+), 153 deletions(-) delete mode 100644 conda/environments/all_cuda-118_arch-aarch64.yaml delete mode 100644 conda/environments/all_cuda-118_arch-x86_64.yaml diff --git a/conda/environments/all_cuda-118_arch-aarch64.yaml b/conda/environments/all_cuda-118_arch-aarch64.yaml deleted file mode 100644 index c24757b76..000000000 --- a/conda/environments/all_cuda-118_arch-aarch64.yaml +++ /dev/null @@ -1,43 +0,0 @@ -# This file is generated by `rapids-dependency-file-generator`. -# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. -channels: -- rapidsai -- rapidsai-nightly -- conda-forge -dependencies: -- breathe>=4.35.0 -- c-compiler -- clang-tools==20.1.4 -- clang==20.1.4 -- cmake>=3.30.4 -- cuda-python>=11.8.5,<12.0a0 -- cuda-version=11.8 -- cudatoolkit -- cxx-compiler -- cython>=3.0.0 -- doxygen=1.9.1 -- gcc_linux-aarch64=11.* -- gcovr>=5.0 -- graphviz -- identify>=2.5.20 -- ipython -- make -- nbsphinx -- ninja -- numba>=0.59.1,<0.62.0a0 -- numpy>=1.23,<3.0a0 -- numpydoc -- nvcc_linux-aarch64=11.8 -- pre-commit -- pytest -- pytest-cov -- python>=3.10,<3.14 -- rapids-build-backend>=0.3.0,<0.4.0.dev0 -- rapids-logger==0.1.*,>=0.0.0a0 -- scikit-build-core >=0.10.0 -- sphinx-copybutton -- sphinx-markdown-tables -- sphinx<8.2.0 -- sphinx_rtd_theme -- sysroot_linux-aarch64==2.28 -name: all_cuda-118_arch-aarch64 diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml deleted file mode 100644 index fc14e3678..000000000 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ /dev/null @@ -1,43 +0,0 @@ -# This file is generated by `rapids-dependency-file-generator`. -# To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. -channels: -- rapidsai -- rapidsai-nightly -- conda-forge -dependencies: -- breathe>=4.35.0 -- c-compiler -- clang-tools==20.1.4 -- clang==20.1.4 -- cmake>=3.30.4 -- cuda-python>=11.8.5,<12.0a0 -- cuda-version=11.8 -- cudatoolkit -- cxx-compiler -- cython>=3.0.0 -- doxygen=1.9.1 -- gcc_linux-64=11.* -- gcovr>=5.0 -- graphviz -- identify>=2.5.20 -- ipython -- make -- nbsphinx -- ninja -- numba>=0.59.1,<0.62.0a0 -- numpy>=1.23,<3.0a0 -- numpydoc -- nvcc_linux-64=11.8 -- pre-commit -- pytest -- pytest-cov -- python>=3.10,<3.14 -- rapids-build-backend>=0.3.0,<0.4.0.dev0 -- rapids-logger==0.1.*,>=0.0.0a0 -- scikit-build-core >=0.10.0 -- sphinx-copybutton -- sphinx-markdown-tables -- sphinx<8.2.0 -- sphinx_rtd_theme -- sysroot_linux-64==2.28 -name: all_cuda-118_arch-x86_64 diff --git a/dependencies.yaml b/dependencies.yaml index ada445aa9..438bc130d 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -3,7 +3,7 @@ files: all: output: conda matrix: - cuda: ["11.8", "12.8"] + cuda: ["12.8"] arch: [x86_64, aarch64] includes: - build @@ -132,42 +132,20 @@ dependencies: specific: - output_types: conda matrices: - - matrix: - arch: x86_64 - cuda: "11.*" - packages: - - gcc_linux-64=11.* - - &sysroot_x86_64 sysroot_linux-64==2.28 - matrix: arch: x86_64 cuda: "12.*" packages: - gcc_linux-64=13.* - - *sysroot_x86_64 - - matrix: - arch: aarch64 - cuda: "11.*" - packages: - - gcc_linux-aarch64=11.* - - &sysroot_aarch64 sysroot_linux-aarch64==2.28 + - sysroot_linux-64==2.28 - matrix: arch: aarch64 cuda: "12.*" packages: - gcc_linux-aarch64=13.* - - *sysroot_aarch64 + - sysroot_linux-aarch64==2.28 - output_types: conda matrices: - - matrix: - arch: x86_64 - cuda: "11.8" - packages: - - nvcc_linux-64=11.8 - - matrix: - arch: aarch64 - cuda: "11.8" - packages: - - nvcc_linux-aarch64=11.8 - matrix: cuda: "12.*" packages: @@ -180,13 +158,9 @@ dependencies: specific: - output_types: [conda, requirements, pyproject] matrices: - - matrix: - cuda: "12.*" + - matrix: # All CUDA 12 versions packages: - &cuda_python12 cuda-python>=12.6.2,<13.0a0 - - matrix: # All CUDA 11 versions - packages: - - &cuda_python11 cuda-python>=11.8.5,<12.0a0 depends_on_librmm: common: - output_types: conda @@ -195,7 +169,7 @@ dependencies: - output_types: requirements packages: # pip recognizes the index as a global option for the requirements.txt file - # This index is needed for librmm-cu{11,12}. + # This index is needed for librmm-cu12. - --extra-index-url=https://pypi.nvidia.com - --extra-index-url=https://pypi.anaconda.org/rapidsai-wheels-nightly/simple specific: @@ -206,11 +180,6 @@ dependencies: cuda_suffixed: "true" packages: - librmm-cu12==25.8.*,>=0.0.0a0 - - matrix: - cuda: "11.*" - cuda_suffixed: "true" - packages: - - librmm-cu11==25.8.*,>=0.0.0a0 - matrix: packages: - *librmm_unsuffixed @@ -244,26 +213,6 @@ dependencies: specific: - output_types: conda matrices: - - matrix: - cuda: "11.2" - packages: - - cuda-version=11.2 - - matrix: - cuda: "11.4" - packages: - - cuda-version=11.4 - - matrix: - cuda: "11.5" - packages: - - cuda-version=11.5 - - matrix: - cuda: "11.6" - packages: - - cuda-version=11.6 - - matrix: - cuda: "11.8" - packages: - - cuda-version=11.8 - matrix: cuda: "12.0" packages: @@ -288,10 +237,6 @@ dependencies: specific: - output_types: conda matrices: - - matrix: - cuda: "11.*" - packages: - - cudatoolkit - matrix: cuda: "12.*" packages: @@ -350,13 +295,9 @@ dependencies: specific: - output_types: [conda, requirements, pyproject] matrices: - - matrix: - cuda: "12.*" + - matrix: # All CUDA 12 versions packages: - *cuda_python12 - - matrix: # All CUDA 11 versions - packages: - - *cuda_python11 test_cpp: common: - output_types: conda diff --git a/python/rmm/pyproject.toml b/python/rmm/pyproject.toml index e2f533523..be6707866 100644 --- a/python/rmm/pyproject.toml +++ b/python/rmm/pyproject.toml @@ -30,7 +30,7 @@ authors = [ license = { text = "Apache-2.0" } requires-python = ">=3.10" dependencies = [ - "cuda-python>=11.8.5,<12.0a0", + "cuda-python>=12.6.2,<13.0a0", "librmm==25.8.*,>=0.0.0a0", "numpy>=1.23,<3.0a0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. @@ -77,7 +77,7 @@ dependencies-file = "../../dependencies.yaml" matrix-entry = "cuda_suffixed=true" requires = [ "cmake>=3.30.4", - "cuda-python>=11.8.5,<12.0a0", + "cuda-python>=12.6.2,<13.0a0", "cython>=3.0.0", "librmm==25.8.*,>=0.0.0a0", "ninja", From c4f89603afd51d3cc06fe00dc38670b96f831609 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Tue, 10 Jun 2025 20:51:09 +0100 Subject: [PATCH 620/675] Fix race conditions and deadlocks in REPLAY_BENCH (#1940) The `REPLAY_BENCH` benchmark is used for replaying logs of allocation patterns. However, unless one passes `--benchmark_repetitions=1` and `--benchmark_min_time=0s`, the replay hangs forever after the first warmup iteration. The problem is that a shared `event_index` needs to be reset for each benchmark iteration. Additionally, if running a multi-threaded allocation replay, there is a race condition between thread 0 setting up and tearing down the memory resource being used, and any other threads running through their allocation pattern. To fix these, now that we no longer support CUDA 11, require C++20 to compile the benchmarks and use a `std::barrier` to ensure ordering between `SetUp`/`TearDown` on thread 0 and the actual benchmark iteration. To handle the `event_index` problem, we again use barriers for sequencing. Thread 0 resets the `event_index` at the beginning of each benchmark iteration and then everyone waits at a barrier. - Closes #1939 Authors: - Lawrence Mitchell (https://github.com/wence-) - Bradley Dice (https://github.com/bdice) Approvers: - Peter Andreas Entschev (https://github.com/pentschev) - Rong Ou (https://github.com/rongou) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1940 --- cpp/benchmarks/CMakeLists.txt | 2 ++ cpp/benchmarks/replay/replay.cpp | 22 +++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index bfddbc7d2..9f995d56c 100644 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -31,6 +31,8 @@ function(ConfigureBench BENCH_NAME) set_target_properties( ${BENCH_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON + CXX_STANDARD 20 + CXX_STANDARD_REQUIRED ON RUNTIME_OUTPUT_DIRECTORY "$" CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}" INSTALL_RPATH "\$ORIGIN/../../../lib") diff --git a/cpp/benchmarks/replay/replay.cpp b/cpp/benchmarks/replay/replay.cpp index c115d9e42..7002a29dd 100644 --- a/cpp/benchmarks/replay/replay.cpp +++ b/cpp/benchmarks/replay/replay.cpp @@ -35,8 +35,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -116,6 +118,7 @@ struct replay_benchmark { std::condition_variable cv; // to ensure in-order playback std::mutex event_mutex; // to make event_index and allocation_map thread-safe std::size_t event_index{0}; // playback index + std::barrier<> barrier_; // barrier to sequence resetting of event_index /** * @brief Construct a `replay_benchmark` from a list of events and @@ -131,7 +134,8 @@ struct replay_benchmark { : factory_{std::move(factory)}, simulated_size_{simulated_size}, events_{events}, - allocation_map{events.size()} + allocation_map{events.size()}, + barrier_{static_cast(events_.size())} { } @@ -145,7 +149,8 @@ struct replay_benchmark { simulated_size_{other.simulated_size_}, mr_{std::move(other.mr_)}, events_{other.events_}, - allocation_map{std::move(other.allocation_map)} + allocation_map{std::move(other.allocation_map)}, + barrier_{static_cast(events_.size())} { } @@ -176,11 +181,15 @@ struct replay_benchmark { RMM_LOG_INFO("------ Start of Benchmark -----"); mr_ = factory_(simulated_size_); } + // Can't release threads until MR is set up. + barrier_.arrive_and_wait(); } /// Destroy the memory resource and count any unallocated memory void TearDown(const ::benchmark::State& state) { + // Can't tear down the MR until every thread is done. + barrier_.arrive_and_wait(); if (state.thread_index() == 0) { RMM_LOG_INFO("------ End of Benchmark -----"); // clean up any leaked allocations @@ -207,8 +216,12 @@ struct replay_benchmark { SetUp(state); auto const& my_events = events_.at(state.thread_index()); - for (auto _ : state) { // NOLINT(clang-analyzer-deadcode.DeadStores) + // At start of each iteration event_index must be reset. + // Any thread could do this, but this is easy + if (state.thread_index() == 0) { event_index = 0; } + // And everyone waits for the reset. + barrier_.arrive_and_wait(); std::for_each(my_events.begin(), my_events.end(), [this](auto event) { // ensure correct ordering between threads std::unique_lock lock{event_mutex}; @@ -228,6 +241,9 @@ struct replay_benchmark { event_index++; cv.notify_all(); }); + // Everyone waits to be done (so that the reset of the next + // iteration doesn't proceed until we're finished) + barrier_.arrive_and_wait(); } TearDown(state); From f9ff11ae7c5078f215b8fca71deb3bea68101c56 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 10 Jun 2025 12:53:34 -0700 Subject: [PATCH 621/675] Fix Python path in CONTRIBUTING.md (#1936) Minor documentation fix for the Python package path. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1936 --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e24b94f14..4fe31340d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,7 +37,7 @@ are required. To set up a development environment, follow the steps in the [README](https://github.com/rapidsai/rmm/blob/main/README.md) for cloning the repository and creating the conda environment. Once the environment is created, you can build and install RMM using ```bash -$ python -m pip install ./python +$ python -m pip install ./python/rmm ``` This command will build the RMM Python library inside the clone and automatically make it importable when running Python anywhere on your machine. Remember, if you are unsure about anything, don't hesitate to comment on issues From a0dd1b98a58af123d34f8257de2a9b95af6acb03 Mon Sep 17 00:00:00 2001 From: Peter Andreas Entschev Date: Wed, 11 Jun 2025 01:07:41 +0200 Subject: [PATCH 622/675] Add managed memory resource to replay benchmark (#1938) Extend replay benchmark to include managed memory resource. Authors: - Peter Andreas Entschev (https://github.com/pentschev) - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1938 --- cpp/benchmarks/replay/replay.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cpp/benchmarks/replay/replay.cpp b/cpp/benchmarks/replay/replay.cpp index 7002a29dd..32d64fabf 100644 --- a/cpp/benchmarks/replay/replay.cpp +++ b/cpp/benchmarks/replay/replay.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -51,6 +52,11 @@ std::shared_ptr make_cuda(std::size_t = 0) return std::make_shared(); } +std::shared_ptr make_managed(std::size_t = 0) +{ + return std::make_shared(); +} + std::shared_ptr make_simulated(std::size_t simulated_size) { return std::make_shared(simulated_size); @@ -335,6 +341,11 @@ void declare_benchmark(std::string const& name, replay_benchmark(&make_arena, simulated_size, per_thread_events)) ->Unit(benchmark::kMillisecond) ->Threads(static_cast(num_threads)); + } else if (name == "managed") { + benchmark::RegisterBenchmark("Managed Resource", + replay_benchmark(&make_managed, simulated_size, per_thread_events)) + ->Unit(benchmark::kMillisecond) + ->Threads(static_cast(num_threads)); } else { std::cout << "Error: invalid memory_resource name: " << name << "\n"; } @@ -425,7 +436,7 @@ int main(int argc, char** argv) std::string mr_name = args["resource"].as(); declare_benchmark(mr_name, simulated_size, per_thread_events, num_threads); } else { - std::array mrs{"pool", "arena", "binning", "cuda"}; + std::array mrs{"pool", "arena", "binning", "cuda", "managed"}; std::for_each(std::cbegin(mrs), std::cend(mrs), [&simulated_size, &per_thread_events, &num_threads](auto const& mr) { From db325e6cdc786020773180ffb36ec5fc965f9e1c Mon Sep 17 00:00:00 2001 From: Ray Douglass <3107146+raydouglass@users.noreply.github.com> Date: Wed, 11 Jun 2025 12:24:44 -0400 Subject: [PATCH 623/675] Update branches that trigger nightlies (#1954) `rmm` is piloting the new branching strategy (https://docs.rapids.ai/notices/rsn0047/). This PR updates the branches which trigger a nightly/branch build in the new strategy. --- .github/workflows/build.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1e3462a6f..1f4c3495f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -3,7 +3,9 @@ name: build on: push: branches: - - "branch-*" + - "main" + - "release/*" + - "hotfix/*" tags: - v[0-9][0-9].[0-9][0-9].[0-9][0-9] workflow_dispatch: From a4e28c1b6737774518f225d4d01f4e672be8ac0b Mon Sep 17 00:00:00 2001 From: Mike Sarahan Date: Thu, 12 Jun 2025 07:53:31 -0500 Subject: [PATCH 624/675] Adding GH_TOKEN pass-through to summarize job (#1956) This adds an env var to pass the github token through to the telemetry summary shared action. The token is necessary to check if the base artifact exists. See https://github.com/rapidsai/shared-actions/pull/56 for more information. The whitespace changes here were introduced from using yq with rapids-reviser to add this field. If the whitespace changes are undesirable, I will revert them. Authors: - Mike Sarahan (https://github.com/msarahan) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rmm/pull/1956 --- .github/workflows/pr.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index c7f25cc90..d76d4eec9 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -1,14 +1,11 @@ name: pr - on: push: branches: - "pull-request/[0-9]+" - concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - jobs: pr-builder: needs: @@ -161,7 +158,6 @@ jobs: sccache --zero-stats; build-all -DBUILD_BENCHMARKS=ON --verbose 2>&1 | tee telemetry-artifacts/build.log; sccache --show-adv-stats | tee telemetry-artifacts/sccache-stats.txt; - telemetry-summarize: # This job must use a self-hosted runner to record telemetry traces. runs-on: linux-amd64-cpu4 @@ -171,3 +167,5 @@ jobs: steps: - name: Telemetry summarize uses: rapidsai/shared-actions/telemetry-dispatch-summarize@main + env: + GH_TOKEN: ${{ github.token }} From 0016ffb481cdee530ddc515b30c738123c1f52fe Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Tue, 17 Jun 2025 21:28:54 +0100 Subject: [PATCH 625/675] Implemented device_uvector's reverse iterators (#1937) This pull request implements the reverse iterators for the `device_uvector` type. Closes https://github.com/rapidsai/rmm/issues/1326 Authors: - Basit Ayantunde (https://github.com/lamarrr) - Bradley Dice (https://github.com/bdice) Approvers: - Mark Harris (https://github.com/harrism) - Bradley Dice (https://github.com/bdice) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1937 --- cpp/include/rmm/device_uvector.hpp | 70 ++++++++++++++++++++++++++++++ cpp/tests/device_uvector_tests.cpp | 18 ++++++++ 2 files changed, 88 insertions(+) diff --git a/cpp/include/rmm/device_uvector.hpp b/cpp/include/rmm/device_uvector.hpp index b790584db..78709b5d9 100644 --- a/cpp/include/rmm/device_uvector.hpp +++ b/cpp/include/rmm/device_uvector.hpp @@ -24,6 +24,8 @@ #include #include +#include + #include #include #include @@ -87,6 +89,10 @@ class device_uvector { using const_pointer = value_type const*; ///< The type of the pointer returned by data() const using iterator = pointer; ///< The type of the iterator returned by begin() using const_iterator = const_pointer; ///< The type of the const iterator returned by cbegin() + using reverse_iterator = + thrust::reverse_iterator; ///< The type of the iterator returned by rbegin() + using const_reverse_iterator = + thrust::reverse_iterator; ///< The type of the iterator returned by crbegin() RMM_EXEC_CHECK_DISABLE ~device_uvector() = default; @@ -504,6 +510,70 @@ class device_uvector { */ [[nodiscard]] const_iterator end() const noexcept { return cend(); } + /** + * @brief Returns a reverse_iterator to the last element. + * + * If the vector is empty, then `rbegin() == rend()`. + * + * @return Iterator to the last element. + */ + [[nodiscard]] reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } + + /** + * @brief Returns a const_reverse_iterator to the last element. + * + * If the vector is empty, then `crbegin() == crend()`. + * + * @return Immutable iterator to the last element. + */ + [[nodiscard]] const_reverse_iterator crbegin() const noexcept + { + return const_reverse_iterator(cend()); + } + + /** + * @brief Returns a const_reverse_iterator to the last element. + * + * If the vector is empty, then `rbegin() == rend()`. + * + * @return Immutable iterator to the first element. + */ + [[nodiscard]] const_reverse_iterator rbegin() const noexcept { return crbegin(); } + + /** + * @brief Returns reverse_iterator to the element preceding the first element of the vector. + * + * The element referenced by `rend()` is a placeholder and dereferencing it results in undefined + * behavior. + * + * @return Iterator to the element before the first element. + */ + [[nodiscard]] reverse_iterator rend() noexcept { return reverse_iterator(begin()); } + + /** + * @brief Returns a const_reverse_iterator to the element preceding the first element of the + * vector. + * + * The element referenced by `crend()` is a placeholder and dereferencing it results in undefined + * behavior. + * + * @return Immutable iterator to the element before the first element. + */ + [[nodiscard]] const_reverse_iterator crend() const noexcept + { + return const_reverse_iterator(begin()); + } + + /** + * @brief Returns const_reverse_iterator to the element preceding the first element of the vector. + * + * The element referenced by `rend()` is a placeholder and dereferencing it results in undefined + * behavior. + * + * @return Immutable iterator to the element before the first element. + */ + [[nodiscard]] const_reverse_iterator rend() const noexcept { return crend(); } + /** * @briefreturn{The number of elements in the vector} */ diff --git a/cpp/tests/device_uvector_tests.cpp b/cpp/tests/device_uvector_tests.cpp index faa8a9994..aae7e1cfd 100644 --- a/cpp/tests/device_uvector_tests.cpp +++ b/cpp/tests/device_uvector_tests.cpp @@ -291,3 +291,21 @@ TYPED_TEST(TypedUVectorTest, Iterators) auto const* const_end = std::as_const(vec).end(); EXPECT_EQ(const_end, vec.cend()); } + +TYPED_TEST(TypedUVectorTest, ReverseIterators) +{ + auto const size{12345}; + rmm::device_uvector vec(size, this->stream()); + + EXPECT_EQ(vec.rbegin().base(), vec.end()); + EXPECT_EQ(vec.crbegin().base(), vec.cend()); + + EXPECT_EQ(std::distance(vec.rbegin(), vec.rend()), vec.size()); + EXPECT_EQ(std::distance(vec.crbegin(), vec.crend()), vec.size()); + + EXPECT_EQ(std::distance(vec.rend(), vec.rbegin()), -static_cast(vec.size())); + EXPECT_EQ(std::distance(vec.crend(), vec.crbegin()), -static_cast(vec.size())); + + EXPECT_EQ((vec.rbegin() + 1).base(), vec.end() - 1); + EXPECT_EQ((vec.rend() - 1).base(), vec.begin() + 1); +} From 8f10dc7d48e147ead0d86fcbcfe9983db8aec084 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 17 Jun 2025 14:44:13 -0700 Subject: [PATCH 626/675] Update cxxopts to 3.3.1. (#1962) Updates vendored cxxopts.hpp to 3.3.1. xref: https://github.com/rapidsai/rmm/pull/1951#discussion_r2152442707 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Gil Forsyth (https://github.com/gforsyth) - Mark Harris (https://github.com/harrism) - Vyas Ramasubramani (https://github.com/vyasr) URL: https://github.com/rapidsai/rmm/pull/1962 --- .pre-commit-config.yaml | 13 +- cpp/benchmarks/utilities/cxxopts.hpp | 2847 +++++++++++++++++++------- 2 files changed, 2139 insertions(+), 721 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4881b9937..3571a16a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,6 +30,10 @@ repos: - id: clang-format types_or: [c, c++, cuda] args: ["-fallback-style=none", "-style=file", "-i"] + exclude: | + (?x)^( + ^cpp/benchmarks/utilities/cxxopts.hpp + ) - repo: https://github.com/sirosen/texthooks rev: 0.6.8 hooks: @@ -79,8 +83,13 @@ repos: - repo: https://github.com/rapidsai/pre-commit-hooks rev: v0.6.0 hooks: - - id: verify-copyright - - id: verify-alpha-spec + - id: verify-copyright + args: [--fix, --main-branch=main] + exclude: | + (?x)^( + ^cpp/benchmarks/utilities/cxxopts.hpp + ) + - id: verify-alpha-spec - repo: https://github.com/rapidsai/dependency-file-generator rev: v1.18.1 hooks: diff --git a/cpp/benchmarks/utilities/cxxopts.hpp b/cpp/benchmarks/utilities/cxxopts.hpp index e021297bb..32c8f2ce7 100644 --- a/cpp/benchmarks/utilities/cxxopts.hpp +++ b/cpp/benchmarks/utilities/cxxopts.hpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2014, 2015, 2016, 2017 Jarryd Beck +Copyright (c) 2014-2022 Jarryd Beck Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -22,84 +22,210 @@ THE SOFTWARE. */ +// vim: ts=2:sw=2:expandtab + #ifndef CXXOPTS_HPP_INCLUDED #define CXXOPTS_HPP_INCLUDED -#include +#include +#include #include #include -#include #include +#include #include #include -#include #include #include #include #include +#include #include +#include +#include + +#ifdef CXXOPTS_NO_EXCEPTIONS +#include +#endif + +#if defined(__GNUC__) && !defined(__clang__) +# if (__GNUC__ * 10 + __GNUC_MINOR__) < 49 +# define CXXOPTS_NO_REGEX true +# endif +#endif +#if defined(_MSC_VER) && !defined(__clang__) +#define CXXOPTS_LINKONCE_CONST __declspec(selectany) extern +#define CXXOPTS_LINKONCE __declspec(selectany) extern +#else +#define CXXOPTS_LINKONCE_CONST +#define CXXOPTS_LINKONCE +#endif + +#ifndef CXXOPTS_NO_REGEX +# include +#endif // CXXOPTS_NO_REGEX + +// Nonstandard before C++17, which is coincidentally what we also need for +#ifdef __has_include +# if __has_include() +# include +# ifdef __cpp_lib_optional +# define CXXOPTS_HAS_OPTIONAL +# endif +# endif +# if __has_include() +# include +# ifdef __cpp_lib_filesystem +# define CXXOPTS_HAS_FILESYSTEM +# endif +# endif +#endif -#ifdef __cpp_lib_optional -#include -#define CXXOPTS_HAS_OPTIONAL +#define CXXOPTS_FALLTHROUGH +#ifdef __has_cpp_attribute + #if __has_cpp_attribute(fallthrough) + #undef CXXOPTS_FALLTHROUGH + #define CXXOPTS_FALLTHROUGH [[fallthrough]] + #endif +#endif + +#if __cplusplus >= 201603L +#define CXXOPTS_NODISCARD [[nodiscard]] +#else +#define CXXOPTS_NODISCARD #endif #ifndef CXXOPTS_VECTOR_DELIMITER #define CXXOPTS_VECTOR_DELIMITER ',' #endif -#define CXXOPTS__VERSION_MAJOR 2 -#define CXXOPTS__VERSION_MINOR 2 -#define CXXOPTS__VERSION_PATCH 0 +#define CXXOPTS__VERSION_MAJOR 3 +#define CXXOPTS__VERSION_MINOR 3 +#define CXXOPTS__VERSION_PATCH 1 + +#if (__GNUC__ < 10 || (__GNUC__ == 10 && __GNUC_MINOR__ < 1)) && __GNUC__ >= 6 + #define CXXOPTS_NULL_DEREF_IGNORE +#endif + +#if defined(__GNUC__) +#define DO_PRAGMA(x) _Pragma(#x) +#define CXXOPTS_DIAGNOSTIC_PUSH DO_PRAGMA(GCC diagnostic push) +#define CXXOPTS_DIAGNOSTIC_POP DO_PRAGMA(GCC diagnostic pop) +#define CXXOPTS_IGNORE_WARNING(x) DO_PRAGMA(GCC diagnostic ignored x) +#else +// define other compilers here if needed +#define CXXOPTS_DIAGNOSTIC_PUSH +#define CXXOPTS_DIAGNOSTIC_POP +#define CXXOPTS_IGNORE_WARNING(x) +#endif + +#ifdef CXXOPTS_NO_RTTI +#define CXXOPTS_RTTI_CAST static_cast +#else +#define CXXOPTS_RTTI_CAST dynamic_cast +#endif namespace cxxopts { static constexpr struct { uint8_t major, minor, patch; -} version = {CXXOPTS__VERSION_MAJOR, CXXOPTS__VERSION_MINOR, CXXOPTS__VERSION_PATCH}; -} // namespace cxxopts +} version = { + CXXOPTS__VERSION_MAJOR, + CXXOPTS__VERSION_MINOR, + CXXOPTS__VERSION_PATCH +}; +} // namespace cxxopts -// when we ask cxxopts to use Unicode, help strings are processed using ICU, -// which results in the correct lengths being computed for strings when they -// are formatted for the help output -// it is necessary to make sure that can be found by the -// compiler, and that icu-uc is linked in to the binary. +//when we ask cxxopts to use Unicode, help strings are processed using ICU, +//which results in the correct lengths being computed for strings when they +//are formatted for the help output +//it is necessary to make sure that can be found by the +//compiler, and that icu-uc is linked in to the binary. #ifdef CXXOPTS_USE_UNICODE #include namespace cxxopts { -typedef icu::UnicodeString String; -inline String toLocalString(std::string s) { return icu::UnicodeString::fromUTF8(std::move(s)); } +using String = icu::UnicodeString; -class UnicodeStringIterator : public std::iterator { - public: - UnicodeStringIterator(const icu::UnicodeString* string, int32_t pos) : s(string), i(pos) {} +inline +String +toLocalString(std::string s) +{ + return icu::UnicodeString::fromUTF8(std::move(s)); +} - value_type operator*() const { return s->char32At(i); } +// GNU GCC with -Weffc++ will issue a warning regarding the upcoming class, we want to silence it: +// warning: base class 'class std::enable_shared_from_this' has accessible non-virtual destructor +CXXOPTS_DIAGNOSTIC_PUSH +CXXOPTS_IGNORE_WARNING("-Wnon-virtual-dtor") +// This will be ignored under other compilers like LLVM clang. +class UnicodeStringIterator +{ + public: - bool operator==(const UnicodeStringIterator& rhs) const { return s == rhs.s && i == rhs.i; } + using iterator_category = std::forward_iterator_tag; + using value_type = int32_t; + using difference_type = std::ptrdiff_t; + using pointer = value_type*; + using reference = value_type&; - bool operator!=(const UnicodeStringIterator& rhs) const { return !(*this == rhs); } + UnicodeStringIterator(const icu::UnicodeString* string, int32_t pos) + : s(string) + , i(pos) + { + } + + value_type + operator*() const + { + return s->char32At(i); + } - UnicodeStringIterator& operator++() + bool + operator==(const UnicodeStringIterator& rhs) const + { + return s == rhs.s && i == rhs.i; + } + + bool + operator!=(const UnicodeStringIterator& rhs) const + { + return !(*this == rhs); + } + + UnicodeStringIterator& + operator++() { ++i; return *this; } - UnicodeStringIterator operator+(int32_t v) { return UnicodeStringIterator(s, i + v); } + UnicodeStringIterator + operator+(int32_t v) + { + return UnicodeStringIterator(s, i + v); + } - private: + private: const icu::UnicodeString* s; int32_t i; }; +CXXOPTS_DIAGNOSTIC_POP -inline String& stringAppend(String& s, String a) { return s.append(std::move(a)); } +inline +String& +stringAppend(String&s, String a) +{ + return s.append(std::move(a)); +} -inline String& stringAppend(String& s, int n, UChar32 c) +inline +String& +stringAppend(String& s, std::size_t n, UChar32 c) { - for (int i = 0; i != n; ++i) { + for (std::size_t i = 0; i != n; ++i) + { s.append(c); } @@ -107,9 +233,11 @@ inline String& stringAppend(String& s, int n, UChar32 c) } template -String& stringAppend(String& s, Iterator begin, Iterator end) +String& +stringAppend(String& s, Iterator begin, Iterator end) { - while (begin != end) { + while (begin != end) + { s.append(*begin); ++begin; } @@ -117,9 +245,16 @@ String& stringAppend(String& s, Iterator begin, Iterator end) return s; } -inline size_t stringLength(const String& s) { return s.length(); } +inline +size_t +stringLength(const String& s) +{ + return static_cast(s.length()); +} -inline std::string toUTF8String(const String& s) +inline +std::string +toUTF8String(const String& s) { std::string result; s.toUTF8String(result); @@ -127,200 +262,312 @@ inline std::string toUTF8String(const String& s) return result; } -inline bool empty(const String& s) { return s.isEmpty(); } -} // namespace cxxopts +inline +bool +empty(const String& s) +{ + return s.isEmpty(); +} + +} // namespace cxxopts namespace std { -inline cxxopts::UnicodeStringIterator begin(const icu::UnicodeString& s) + +inline +cxxopts::UnicodeStringIterator +begin(const icu::UnicodeString& s) { return cxxopts::UnicodeStringIterator(&s, 0); } -inline cxxopts::UnicodeStringIterator end(const icu::UnicodeString& s) +inline +cxxopts::UnicodeStringIterator +end(const icu::UnicodeString& s) { return cxxopts::UnicodeStringIterator(&s, s.length()); } -} // namespace std -// ifdef CXXOPTS_USE_UNICODE +} // namespace std + +//ifdef CXXOPTS_USE_UNICODE #else namespace cxxopts { -typedef std::string String; + +using String = std::string; template -T toLocalString(T&& t) +T +toLocalString(T&& t) { return std::forward(t); } -inline size_t stringLength(const String& s) { return s.length(); } +inline +std::size_t +stringLength(const String& s) +{ + return s.length(); +} -inline String& stringAppend(String& s, String a) { return s.append(std::move(a)); } +inline +String& +stringAppend(String&s, const String& a) +{ + return s.append(a); +} -inline String& stringAppend(String& s, size_t n, char c) { return s.append(n, c); } +inline +String& +stringAppend(String& s, std::size_t n, char c) +{ + return s.append(n, c); +} template -String& stringAppend(String& s, Iterator begin, Iterator end) +String& +stringAppend(String& s, Iterator begin, Iterator end) { return s.append(begin, end); } template -std::string toUTF8String(T&& t) +std::string +toUTF8String(T&& t) { return std::forward(t); } -inline bool empty(const std::string& s) { return s.empty(); } -} // namespace cxxopts +inline +bool +empty(const std::string& s) +{ + return s.empty(); +} + +} // namespace cxxopts -// ifdef CXXOPTS_USE_UNICODE +//ifdef CXXOPTS_USE_UNICODE #endif namespace cxxopts { + namespace { -#ifdef _WIN32 -const std::string LQUOTE("\'"); -const std::string RQUOTE("\'"); -#else -const std::string LQUOTE("‘"); -const std::string RQUOTE("’"); -#endif -} // namespace +CXXOPTS_LINKONCE_CONST std::string LQUOTE("\'"); +CXXOPTS_LINKONCE_CONST std::string RQUOTE("\'"); +} // namespace + +// GNU GCC with -Weffc++ will issue a warning regarding the upcoming class, we +// want to silence it: warning: base class 'class +// std::enable_shared_from_this' has accessible non-virtual +// destructor This will be ignored under other compilers like LLVM clang. +CXXOPTS_DIAGNOSTIC_PUSH +CXXOPTS_IGNORE_WARNING("-Wnon-virtual-dtor") + +// some older versions of GCC warn under this warning +CXXOPTS_IGNORE_WARNING("-Weffc++") +class Value : public std::enable_shared_from_this +{ + public: -class Value : public std::enable_shared_from_this { - public: virtual ~Value() = default; - virtual std::shared_ptr clone() const = 0; + virtual + std::shared_ptr + clone() const = 0; + + virtual void + add(const std::string& text) const = 0; - virtual void parse(const std::string& text) const = 0; + virtual void + parse(const std::string& text) const = 0; - virtual void parse() const = 0; + virtual void + parse() const = 0; - virtual bool has_default() const = 0; + virtual bool + has_default() const = 0; - virtual bool is_container() const = 0; + virtual bool + is_container() const = 0; - virtual bool has_implicit() const = 0; + virtual bool + has_implicit() const = 0; - virtual std::string get_default_value() const = 0; + virtual std::string + get_default_value() const = 0; - virtual std::string get_implicit_value() const = 0; + virtual std::string + get_implicit_value() const = 0; - virtual std::shared_ptr default_value(const std::string& value) = 0; + virtual std::shared_ptr + default_value(const std::string& value) = 0; - virtual std::shared_ptr implicit_value(const std::string& value) = 0; + virtual std::shared_ptr + implicit_value(const std::string& value) = 0; - virtual std::shared_ptr no_implicit_value() = 0; + virtual std::shared_ptr + no_implicit_value() = 0; - virtual bool is_boolean() const = 0; + virtual bool + is_boolean() const = 0; }; -class OptionException : public std::exception { - public: - OptionException(const std::string& message) : m_message(message) {} +CXXOPTS_DIAGNOSTIC_POP - virtual const char* what() const noexcept { return m_message.c_str(); } +namespace exceptions { - private: +class exception : public std::exception +{ + public: + explicit exception(std::string message) + : m_message(std::move(message)) + { + } + + CXXOPTS_NODISCARD + const char* + what() const noexcept override + { + return m_message.c_str(); + } + + private: std::string m_message; }; -class OptionSpecException : public OptionException { - public: - OptionSpecException(const std::string& message) : OptionException(message) {} +class specification : public exception +{ + public: + + explicit specification(const std::string& message) + : exception(message) + { + } }; -class OptionParseException : public OptionException { - public: - OptionParseException(const std::string& message) : OptionException(message) {} +class parsing : public exception +{ + public: + explicit parsing(const std::string& message) + : exception(message) + { + } }; -class option_exists_error : public OptionSpecException { - public: - option_exists_error(const std::string& option) - : OptionSpecException("Option " + LQUOTE + option + RQUOTE + " already exists") +class option_already_exists : public specification +{ + public: + explicit option_already_exists(const std::string& option) + : specification("Option " + LQUOTE + option + RQUOTE + " already exists") { } }; -class invalid_option_format_error : public OptionSpecException { - public: - invalid_option_format_error(const std::string& format) - : OptionSpecException("Invalid option format " + LQUOTE + format + RQUOTE) +class invalid_option_format : public specification +{ + public: + explicit invalid_option_format(const std::string& format) + : specification("Invalid option format " + LQUOTE + format + RQUOTE) { } }; -class option_syntax_exception : public OptionParseException { - public: - option_syntax_exception(const std::string& text) - : OptionParseException("Argument " + LQUOTE + text + RQUOTE + - " starts with a - but has incorrect syntax") +class invalid_option_syntax : public parsing { + public: + explicit invalid_option_syntax(const std::string& text) + : parsing("Argument " + LQUOTE + text + RQUOTE + + " starts with a - but has incorrect syntax") { } }; -class option_not_exists_exception : public OptionParseException { - public: - option_not_exists_exception(const std::string& option) - : OptionParseException("Option " + LQUOTE + option + RQUOTE + " does not exist") +class no_such_option : public parsing +{ + public: + explicit no_such_option(const std::string& option) + : parsing("Option " + LQUOTE + option + RQUOTE + " does not exist") { } }; -class missing_argument_exception : public OptionParseException { - public: - missing_argument_exception(const std::string& option) - : OptionParseException("Option " + LQUOTE + option + RQUOTE + " is missing an argument") +class missing_argument : public parsing +{ + public: + explicit missing_argument(const std::string& option) + : parsing( + "Option " + LQUOTE + option + RQUOTE + " is missing an argument" + ) { } }; -class option_requires_argument_exception : public OptionParseException { - public: - option_requires_argument_exception(const std::string& option) - : OptionParseException("Option " + LQUOTE + option + RQUOTE + " requires an argument") +class option_requires_argument : public parsing +{ + public: + explicit option_requires_argument(const std::string& option) + : parsing( + "Option " + LQUOTE + option + RQUOTE + " requires an argument" + ) { } }; -class option_not_has_argument_exception : public OptionParseException { - public: - option_not_has_argument_exception(const std::string& option, const std::string& arg) - : OptionParseException("Option " + LQUOTE + option + RQUOTE + - " does not take an argument, but argument " + LQUOTE + arg + RQUOTE + - " given") +class gratuitous_argument_for_option : public parsing +{ + public: + gratuitous_argument_for_option + ( + const std::string& option, + const std::string& arg + ) + : parsing( + "Option " + LQUOTE + option + RQUOTE + + " does not take an argument, but argument " + + LQUOTE + arg + RQUOTE + " given" + ) { } }; -class option_not_present_exception : public OptionParseException { - public: - option_not_present_exception(const std::string& option) - : OptionParseException("Option " + LQUOTE + option + RQUOTE + " not present") +class requested_option_not_present : public parsing +{ + public: + explicit requested_option_not_present(const std::string& option) + : parsing("Option " + LQUOTE + option + RQUOTE + " not present") { } }; -class argument_incorrect_type : public OptionParseException { - public: - argument_incorrect_type(const std::string& arg) - : OptionParseException("Argument " + LQUOTE + arg + RQUOTE + " failed to parse") +class option_has_no_value : public exception +{ + public: + explicit option_has_no_value(const std::string& option) + : exception( + !option.empty() ? + ("Option " + LQUOTE + option + RQUOTE + " has no value") : + "Option has no value") { } }; -class option_required_exception : public OptionParseException { - public: - option_required_exception(const std::string& option) - : OptionParseException("Option " + LQUOTE + option + RQUOTE + " is required but not present") +class incorrect_argument_type : public parsing +{ + public: + explicit incorrect_argument_type + ( + const std::string& arg + ) + : parsing( + "Argument " + LQUOTE + arg + RQUOTE + " failed to parse" + ) { } }; +} // namespace exceptions + + template void throw_or_mimic(const std::string& text) { @@ -333,120 +580,436 @@ void throw_or_mimic(const std::string& text) throw T{text}; #else // Otherwise manually instantiate the exception, print what() to stderr, - // and abort + // and exit T exception{text}; std::cerr << exception.what() << std::endl; - std::cerr << "Aborting (exceptions disabled)..." << std::endl; - std::abort(); + std::exit(EXIT_FAILURE); #endif } +using OptionNames = std::vector; + namespace values { + +namespace parser_tool { + +struct IntegerDesc +{ + std::string negative = ""; + std::string base = ""; + std::string value = ""; +}; +struct ArguDesc { + std::string arg_name = ""; + bool grouping = false; + bool set_value = false; + std::string value = ""; +}; + +#ifdef CXXOPTS_NO_REGEX +inline IntegerDesc SplitInteger(const std::string &text) +{ + if (text.empty()) + { + throw_or_mimic(text); + } + IntegerDesc desc; + const char *pdata = text.c_str(); + if (*pdata == '-') + { + pdata += 1; + desc.negative = "-"; + } + if (strncmp(pdata, "0x", 2) == 0) + { + pdata += 2; + desc.base = "0x"; + } + if (*pdata != '\0') + { + desc.value = std::string(pdata); + } + else + { + throw_or_mimic(text); + } + return desc; +} + +inline bool IsTrueText(const std::string &text) +{ + const char *pdata = text.c_str(); + if (*pdata == 't' || *pdata == 'T') + { + pdata += 1; + if (strncmp(pdata, "rue\0", 4) == 0) + { + return true; + } + } + else if (strncmp(pdata, "1\0", 2) == 0) + { + return true; + } + return false; +} + +inline bool IsFalseText(const std::string &text) +{ + const char *pdata = text.c_str(); + if (*pdata == 'f' || *pdata == 'F') + { + pdata += 1; + if (strncmp(pdata, "alse\0", 5) == 0) + { + return true; + } + } + else if (strncmp(pdata, "0\0", 2) == 0) + { + return true; + } + return false; +} + +inline OptionNames split_option_names(const std::string &text) +{ + OptionNames split_names; + + std::string::size_type token_start_pos = 0; + auto length = text.length(); + + if (length == 0) + { + throw_or_mimic(text); + } + + while (token_start_pos < length) { + const auto &npos = std::string::npos; + auto next_non_space_pos = text.find_first_not_of(' ', token_start_pos); + if (next_non_space_pos == npos) { + throw_or_mimic(text); + } + token_start_pos = next_non_space_pos; + auto next_delimiter_pos = text.find(',', token_start_pos); + if (next_delimiter_pos == token_start_pos) { + throw_or_mimic(text); + } + if (next_delimiter_pos == npos) { + next_delimiter_pos = length; + } + auto token_length = next_delimiter_pos - token_start_pos; + // validate the token itself matches the regex /([:alnum:][-_[:alnum:]]*/ + { + const char* option_name_valid_chars = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789" + "_-.?"; + + if (!std::isalnum(text[token_start_pos], std::locale::classic()) || + text.find_first_not_of(option_name_valid_chars, token_start_pos) < next_delimiter_pos) { + throw_or_mimic(text); + } + } + split_names.emplace_back(text.substr(token_start_pos, token_length)); + token_start_pos = next_delimiter_pos + 1; + } + return split_names; +} + +inline ArguDesc ParseArgument(const char *arg, bool &matched) +{ + ArguDesc argu_desc; + const char *pdata = arg; + matched = false; + if (strncmp(pdata, "--", 2) == 0) + { + pdata += 2; + if (isalnum(*pdata, std::locale::classic())) + { + argu_desc.arg_name.push_back(*pdata); + pdata += 1; + while (isalnum(*pdata, std::locale::classic()) || *pdata == '-' || *pdata == '_') + { + argu_desc.arg_name.push_back(*pdata); + pdata += 1; + } + if (argu_desc.arg_name.length() > 1) + { + if (*pdata == '=') + { + argu_desc.set_value = true; + pdata += 1; + if (*pdata != '\0') + { + argu_desc.value = std::string(pdata); + } + matched = true; + } + else if (*pdata == '\0') + { + matched = true; + } + } + } + } + else if (strncmp(pdata, "-", 1) == 0) + { + pdata += 1; + argu_desc.grouping = true; + while (isalnum(*pdata, std::locale::classic())) + { + argu_desc.arg_name.push_back(*pdata); + pdata += 1; + } + matched = !argu_desc.arg_name.empty() && *pdata == '\0'; + } + return argu_desc; +} + +#else // CXXOPTS_NO_REGEX + namespace { -std::basic_regex integer_pattern("(-)?(0x)?([0-9a-zA-Z]+)|((0x)?0)"); -std::basic_regex truthy_pattern("(t|T)(rue)?|1"); -std::basic_regex falsy_pattern("(f|F)(alse)?|0"); -} // namespace +CXXOPTS_LINKONCE +const char* const integer_pattern = + "(-)?(0x)?([0-9a-zA-Z]+)|((0x)?0)"; +CXXOPTS_LINKONCE +const char* const truthy_pattern = + "(t|T)(rue)?|1"; +CXXOPTS_LINKONCE +const char* const falsy_pattern = + "(f|F)(alse)?|0"; +CXXOPTS_LINKONCE +const char* const option_pattern = + "--([[:alnum:]][-_[:alnum:]\\.]+)(=(.*))?|-([[:alnum:]].*)"; +CXXOPTS_LINKONCE +const char* const option_specifier_pattern = + "([[:alnum:]][-_[:alnum:]\\.]*)(,[ ]*[[:alnum:]][-_[:alnum:]]*)*"; +CXXOPTS_LINKONCE +const char* const option_specifier_separator_pattern = ", *"; + +} // namespace + +inline IntegerDesc SplitInteger(const std::string &text) +{ + static const std::basic_regex integer_matcher(integer_pattern); + + std::smatch match; + std::regex_match(text, match, integer_matcher); + + if (match.length() == 0) + { + throw_or_mimic(text); + } + + IntegerDesc desc; + desc.negative = match[1]; + desc.base = match[2]; + desc.value = match[3]; + + if (match.length(4) > 0) + { + desc.base = match[5]; + desc.value = "0"; + return desc; + } + + return desc; +} + +inline bool IsTrueText(const std::string &text) +{ + static const std::basic_regex truthy_matcher(truthy_pattern); + std::smatch result; + std::regex_match(text, result, truthy_matcher); + return !result.empty(); +} + +inline bool IsFalseText(const std::string &text) +{ + static const std::basic_regex falsy_matcher(falsy_pattern); + std::smatch result; + std::regex_match(text, result, falsy_matcher); + return !result.empty(); +} + +// Gets the option names specified via a single, comma-separated string, +// and returns the separate, space-discarded, non-empty names +// (without considering which or how many are single-character) +inline OptionNames split_option_names(const std::string &text) +{ + static const std::basic_regex option_specifier_matcher(option_specifier_pattern); + if (!std::regex_match(text.c_str(), option_specifier_matcher)) + { + throw_or_mimic(text); + } + + OptionNames split_names; + + static const std::basic_regex option_specifier_separator_matcher(option_specifier_separator_pattern); + constexpr int use_non_matches { -1 }; + auto token_iterator = std::sregex_token_iterator( + text.begin(), text.end(), option_specifier_separator_matcher, use_non_matches); + std::copy(token_iterator, std::sregex_token_iterator(), std::back_inserter(split_names)); + return split_names; +} + +inline ArguDesc ParseArgument(const char *arg, bool &matched) +{ + static const std::basic_regex option_matcher(option_pattern); + std::match_results result; + std::regex_match(arg, result, option_matcher); + matched = !result.empty(); + + ArguDesc argu_desc; + if (matched) { + argu_desc.arg_name = result[1].str(); + argu_desc.set_value = result[2].length() > 0; + argu_desc.value = result[3].str(); + if (result[4].length() > 0) + { + argu_desc.grouping = true; + argu_desc.arg_name = result[4].str(); + } + } + + return argu_desc; +} + +#endif // CXXOPTS_NO_REGEX +#undef CXXOPTS_NO_REGEX +} // namespace parser_tool namespace detail { + template struct SignedCheck; template -struct SignedCheck { +struct SignedCheck +{ template - void operator()(bool negative, U u, const std::string& text) + void + operator()(bool negative, U u, const std::string& text) { - if (negative) { - if (u > static_cast((std::numeric_limits::min)())) { - throw_or_mimic(text); + if (negative) + { + if (u > static_cast((std::numeric_limits::min)())) + { + throw_or_mimic(text); } - } else { - if (u > static_cast((std::numeric_limits::max)())) { - throw_or_mimic(text); + } + else + { + if (u > static_cast((std::numeric_limits::max)())) + { + throw_or_mimic(text); } } } }; template -struct SignedCheck { +struct SignedCheck +{ template - void operator()(bool, U, const std::string&) - { - } + void + operator()(bool, U, const std::string&) const {} }; template -void check_signed_range(bool negative, U value, const std::string& text) +void +check_signed_range(bool negative, U value, const std::string& text) { SignedCheck::is_signed>()(negative, value, text); } -} // namespace detail + +} // namespace detail template -R checked_negate(T&& t, const std::string&, std::true_type) +void +checked_negate(R& r, T&& t, const std::string&, std::true_type) { // if we got to here, then `t` is a positive number that fits into // `R`. So to avoid MSVC C4146, we first cast it to `R`. // See https://github.com/jarro2783/cxxopts/issues/62 for more details. - return static_cast(-static_cast(t - 1) - 1); + r = static_cast(-static_cast(t-1)-1); } template -T checked_negate(T&& t, const std::string& text, std::false_type) +void +checked_negate(R&, T&&, const std::string& text, std::false_type) { - throw_or_mimic(text); - return t; + throw_or_mimic(text); } template -void integer_parser(const std::string& text, T& value) +void +integer_parser(const std::string& text, T& value) { - std::smatch match; - std::regex_match(text, match, integer_pattern); - - if (match.length() == 0) { throw_or_mimic(text); } - - if (match.length(4) > 0) { - value = 0; - return; - } + parser_tool::IntegerDesc int_desc = parser_tool::SplitInteger(text); using US = typename std::make_unsigned::type; - constexpr bool is_signed = std::numeric_limits::is_signed; - const bool negative = match.length(1) > 0; - const uint8_t base = match.length(2) > 0 ? 16 : 10; - auto value_match = match[3]; + const bool negative = int_desc.negative.length() > 0; + const uint8_t base = int_desc.base.length() > 0 ? 16 : 10; + const std::string & value_match = int_desc.value; US result = 0; - for (auto iter = value_match.first; iter != value_match.second; ++iter) { + for (char ch : value_match) + { US digit = 0; - if (*iter >= '0' && *iter <= '9') { - digit = static_cast(*iter - '0'); - } else if (base == 16 && *iter >= 'a' && *iter <= 'f') { - digit = static_cast(*iter - 'a' + 10); - } else if (base == 16 && *iter >= 'A' && *iter <= 'F') { - digit = static_cast(*iter - 'A' + 10); - } else { - throw_or_mimic(text); + if (ch >= '0' && ch <= '9') + { + digit = static_cast(ch - '0'); + } + else if (base == 16 && ch >= 'a' && ch <= 'f') + { + digit = static_cast(ch - 'a' + 10); + } + else if (base == 16 && ch >= 'A' && ch <= 'F') + { + digit = static_cast(ch - 'A' + 10); + } + else + { + throw_or_mimic(text); + } + + US limit = 0; + if (negative) + { + limit = static_cast(std::abs(static_cast((std::numeric_limits::min)()))); + } + else + { + limit = (std::numeric_limits::max)(); } - const US next = static_cast(result * base + digit); - if (result > next) { throw_or_mimic(text); } + if (base != 0 && result > limit / base) + { + throw_or_mimic(text); + } + if (result * base > limit - digit) + { + throw_or_mimic(text); + } - result = next; + result = static_cast(result * base + digit); } detail::check_signed_range(negative, result, text); - if (negative) { - value = checked_negate(result, text, std::integral_constant()); - } else { + if (negative) + { + checked_negate(value, result, text, std::integral_constant()); + } + else + { value = static_cast(result); } } @@ -456,258 +1019,444 @@ void stringstream_parser(const std::string& text, T& value) { std::stringstream in(text); in >> value; - if (!in) { throw_or_mimic(text); } + if (!in) { + throw_or_mimic(text); + } } -inline void parse_value(const std::string& text, uint8_t& value) { integer_parser(text, value); } - -inline void parse_value(const std::string& text, int8_t& value) { integer_parser(text, value); } - -inline void parse_value(const std::string& text, uint16_t& value) { integer_parser(text, value); } - -inline void parse_value(const std::string& text, int16_t& value) { integer_parser(text, value); } - -inline void parse_value(const std::string& text, uint32_t& value) { integer_parser(text, value); } - -inline void parse_value(const std::string& text, int32_t& value) { integer_parser(text, value); } - -inline void parse_value(const std::string& text, uint64_t& value) { integer_parser(text, value); } - -inline void parse_value(const std::string& text, int64_t& value) { integer_parser(text, value); } - -inline void parse_value(const std::string& text, bool& value) +template ::value>::type* = nullptr + > +void parse_value(const std::string& text, T& value) { - std::smatch result; - std::regex_match(text, result, truthy_pattern); + integer_parser(text, value); +} - if (!result.empty()) { +inline +void +parse_value(const std::string& text, bool& value) +{ + if (parser_tool::IsTrueText(text)) + { value = true; return; } - std::regex_match(text, result, falsy_pattern); - if (!result.empty()) { + if (parser_tool::IsFalseText(text)) + { value = false; return; } - throw_or_mimic(text); + throw_or_mimic(text); } -inline void parse_value(const std::string& text, std::string& value) { value = text; } +inline +void +parse_value(const std::string& text, std::string& value) +{ + value = text; +} // The fallback parser. It uses the stringstream parser to parse all types // that have not been overloaded explicitly. It has to be placed in the // source code before all other more specialized templates. +template ::value>::type* = nullptr + > +void +parse_value(const std::string& text, T& value) { + stringstream_parser(text, value); +} + +#ifdef CXXOPTS_HAS_OPTIONAL template -void parse_value(const std::string& text, T& value) +void +parse_value(const std::string& text, std::optional& value) { - stringstream_parser(text, value); + T result; + parse_value(text, result); + value = std::move(result); +} +#endif + +#ifdef CXXOPTS_HAS_FILESYSTEM +inline +void +parse_value(const std::string& text, std::filesystem::path& value) +{ + value.assign(text); +} +#endif + +inline +void parse_value(const std::string& text, char& c) +{ + if (text.length() != 1) + { + throw_or_mimic(text); + } + + c = text[0]; } template -void parse_value(const std::string& text, std::vector& value) +void +parse_value(const std::string& text, std::vector& value) { + if (text.empty()) { + T v; + parse_value(text, v); + value.emplace_back(std::move(v)); + return; + } std::stringstream in(text); std::string token; - while (in.eof() == false && std::getline(in, token, CXXOPTS_VECTOR_DELIMITER)) { + while(!in.eof() && std::getline(in, token, CXXOPTS_VECTOR_DELIMITER)) { T v; parse_value(token, v); value.emplace_back(std::move(v)); } } -#ifdef CXXOPTS_HAS_OPTIONAL template -void parse_value(const std::string& text, std::optional& value) +void +add_value(const std::string& text, T& value) { - T result; - parse_value(text, result); - value = std::move(result); + parse_value(text, value); } -#endif -inline void parse_value(const std::string& text, char& c) +template +void +add_value(const std::string& text, std::vector& value) { - if (text.length() != 1) { throw_or_mimic(text); } - - c = text[0]; + T v; + add_value(text, v); + value.emplace_back(std::move(v)); } template -struct type_is_container { +struct type_is_container +{ static constexpr bool value = false; }; template -struct type_is_container> { +struct type_is_container> +{ static constexpr bool value = true; }; template -class abstract_value : public Value { +class abstract_value : public Value +{ using Self = abstract_value; - public: - abstract_value() : m_result(std::make_shared()), m_store(m_result.get()) {} + public: + abstract_value() + : m_result(std::make_shared()) + , m_store(m_result.get()) + { + } + + explicit abstract_value(T* t) + : m_store(t) + { + } - abstract_value(T* t) : m_store(t) {} + ~abstract_value() override = default; - virtual ~abstract_value() = default; + abstract_value& operator=(const abstract_value&) = default; abstract_value(const abstract_value& rhs) { - if (rhs.m_result) { + if (rhs.m_result) + { m_result = std::make_shared(); - m_store = m_result.get(); - } else { + m_store = m_result.get(); + } + else + { m_store = rhs.m_store; } - m_default = rhs.m_default; - m_implicit = rhs.m_implicit; - m_default_value = rhs.m_default_value; + m_default = rhs.m_default; + m_implicit = rhs.m_implicit; + m_default_value = rhs.m_default_value; m_implicit_value = rhs.m_implicit_value; } - void parse(const std::string& text) const { parse_value(text, *m_store); } + void + add(const std::string& text) const override + { + add_value(text, *m_store); + } - bool is_container() const { return type_is_container::value; } + void + parse(const std::string& text) const override + { + parse_value(text, *m_store); + } - void parse() const { parse_value(m_default_value, *m_store); } + bool + is_container() const override + { + return type_is_container::value; + } - bool has_default() const { return m_default; } + void + parse() const override + { + parse_value(m_default_value, *m_store); + } - bool has_implicit() const { return m_implicit; } + bool + has_default() const override + { + return m_default; + } + + bool + has_implicit() const override + { + return m_implicit; + } - std::shared_ptr default_value(const std::string& value) + std::shared_ptr + default_value(const std::string& value) override { - m_default = true; + m_default = true; m_default_value = value; return shared_from_this(); } - std::shared_ptr implicit_value(const std::string& value) + std::shared_ptr + implicit_value(const std::string& value) override { - m_implicit = true; + m_implicit = true; m_implicit_value = value; return shared_from_this(); } - std::shared_ptr no_implicit_value() + std::shared_ptr + no_implicit_value() override { m_implicit = false; return shared_from_this(); } - std::string get_default_value() const { return m_default_value; } + std::string + get_default_value() const override + { + return m_default_value; + } - std::string get_implicit_value() const { return m_implicit_value; } + std::string + get_implicit_value() const override + { + return m_implicit_value; + } - bool is_boolean() const { return std::is_same::value; } + bool + is_boolean() const override + { + return std::is_same::value; + } - const T& get() const + const T& + get() const { - if (m_store == nullptr) { + if (m_store == nullptr) + { return *m_result; - } else { - return *m_store; } + return *m_store; } - protected: - std::shared_ptr m_result; - T* m_store; + protected: + std::shared_ptr m_result{}; + T* m_store{}; - bool m_default = false; + bool m_default = false; bool m_implicit = false; - std::string m_default_value; - std::string m_implicit_value; + std::string m_default_value{}; + std::string m_implicit_value{}; }; template -class standard_value : public abstract_value { - public: +class standard_value : public abstract_value +{ + public: using abstract_value::abstract_value; - std::shared_ptr clone() const { return std::make_shared>(*this); } + CXXOPTS_NODISCARD + std::shared_ptr + clone() const override + { + return std::make_shared>(*this); + } }; template <> -class standard_value : public abstract_value { - public: - ~standard_value() = default; +class standard_value : public abstract_value +{ + public: + ~standard_value() override = default; - standard_value() { set_default_and_implicit(); } + standard_value() + { + set_default_and_implicit(); + } - standard_value(bool* b) : abstract_value(b) { set_default_and_implicit(); } + explicit standard_value(bool* b) + : abstract_value(b) + { + m_implicit = true; + m_implicit_value = "true"; + } + + std::shared_ptr + clone() const override + { + return std::make_shared>(*this); + } - std::shared_ptr clone() const { return std::make_shared>(*this); } + private: - private: - void set_default_and_implicit() + void + set_default_and_implicit() { - m_default = true; - m_default_value = "false"; - m_implicit = true; + m_default = true; + m_default_value = "false"; + m_implicit = true; m_implicit_value = "true"; } }; -} // namespace values + +} // namespace values template -std::shared_ptr value() +std::shared_ptr +value() { return std::make_shared>(); } template -std::shared_ptr value(T& t) +std::shared_ptr +value(T& t) { return std::make_shared>(&t); } class OptionAdder; -class OptionDetails { - public: - OptionDetails(const std::string& short_, - const std::string& long_, - const String& desc, - std::shared_ptr val) - : m_short(short_), m_long(long_), m_desc(desc), m_value(val), m_count(0) +CXXOPTS_NODISCARD +inline +const std::string& +first_or_empty(const OptionNames& long_names) +{ + static const std::string empty{""}; + return long_names.empty() ? empty : long_names.front(); +} + +class OptionDetails +{ + public: + OptionDetails + ( + std::string short_, + OptionNames long_, + String desc, + std::shared_ptr val + ) + : m_short(std::move(short_)) + , m_long(std::move(long_)) + , m_desc(std::move(desc)) + , m_value(std::move(val)) + , m_count(0) { + m_hash = std::hash{}(first_long_name() + m_short); } - OptionDetails(const OptionDetails& rhs) : m_desc(rhs.m_desc), m_count(rhs.m_count) + OptionDetails(const OptionDetails& rhs) + : m_desc(rhs.m_desc) + , m_value(rhs.m_value->clone()) + , m_count(rhs.m_count) { - m_value = rhs.m_value->clone(); } OptionDetails(OptionDetails&& rhs) = default; - const String& description() const { return m_desc; } + CXXOPTS_NODISCARD + const String& + description() const + { + return m_desc; + } - const Value& value() const { return *m_value; } + CXXOPTS_NODISCARD + const Value& + value() const { + return *m_value; + } - std::shared_ptr make_storage() const { return m_value->clone(); } + CXXOPTS_NODISCARD + std::shared_ptr + make_storage() const + { + return m_value->clone(); + } - const std::string& short_name() const { return m_short; } + CXXOPTS_NODISCARD + const std::string& + short_name() const + { + return m_short; + } - const std::string& long_name() const { return m_long; } + CXXOPTS_NODISCARD + const std::string& + first_long_name() const + { + return first_or_empty(m_long); + } - private: - std::string m_short; - std::string m_long; - String m_desc; - std::shared_ptr m_value; + CXXOPTS_NODISCARD + const std::string& + essential_name() const + { + return m_long.empty() ? m_short : m_long.front(); + } + + CXXOPTS_NODISCARD + const OptionNames & + long_names() const + { + return m_long; + } + + std::size_t + hash() const + { + return m_hash; + } + + private: + std::string m_short{}; + OptionNames m_long{}; + String m_desc{}; + std::shared_ptr m_value{}; int m_count; + + std::size_t m_hash{}; }; -struct HelpOptionDetails { +struct HelpOptionDetails +{ std::string s; - std::string l; + OptionNames l; String desc; bool has_default; std::string default_value; @@ -718,148 +1467,395 @@ struct HelpOptionDetails { bool is_boolean; }; -struct HelpGroupDetails { - std::string name; - std::string description; - std::vector options; +struct HelpGroupDetails +{ + std::string name{}; + std::string description{}; + std::vector options{}; }; -class OptionValue { - public: - void parse(std::shared_ptr details, const std::string& text) +class OptionValue +{ + public: + void + add + ( + const std::shared_ptr& details, + const std::string& text + ) + { + ensure_value(details); + ++m_count; + m_value->add(text); + m_long_names = &details->long_names(); + } + + void + parse + ( + const std::shared_ptr& details, + const std::string& text + ) { ensure_value(details); ++m_count; m_value->parse(text); + m_long_names = &details->long_names(); } - void parse_default(std::shared_ptr details) + void + parse_default(const std::shared_ptr& details) { ensure_value(details); m_default = true; + m_long_names = &details->long_names(); m_value->parse(); } - size_t count() const noexcept { return m_count; } + void + parse_no_value(const std::shared_ptr& details) + { + m_long_names = &details->long_names(); + } + +#if defined(CXXOPTS_NULL_DEREF_IGNORE) +CXXOPTS_DIAGNOSTIC_PUSH +CXXOPTS_IGNORE_WARNING("-Wnull-dereference") +#endif + + CXXOPTS_NODISCARD + std::size_t + count() const noexcept + { + return m_count; + } + +#if defined(CXXOPTS_NULL_DEREF_IGNORE) +CXXOPTS_DIAGNOSTIC_POP +#endif // TODO: maybe default options should count towards the number of arguments - bool has_default() const noexcept { return m_default; } + CXXOPTS_NODISCARD + bool + has_default() const noexcept + { + return m_default; + } template - const T& as() const + const T& + as() const { - if (m_value == nullptr) { throw_or_mimic("No value"); } + if (m_value == nullptr) { + throw_or_mimic( + m_long_names == nullptr ? "" : first_or_empty(*m_long_names)); + } -#ifdef CXXOPTS_NO_RTTI - return static_cast&>(*m_value).get(); -#else - return dynamic_cast&>(*m_value).get(); -#endif + return CXXOPTS_RTTI_CAST&>(*m_value).get(); + } + +#ifdef CXXOPTS_HAS_OPTIONAL + template + std::optional + as_optional() const + { + if (m_value == nullptr) { + return std::nullopt; + } + return as(); } +#endif - private: - void ensure_value(std::shared_ptr details) + private: + void + ensure_value(const std::shared_ptr& details) { - if (m_value == nullptr) { m_value = details->make_storage(); } + if (m_value == nullptr) + { + m_value = details->make_storage(); + } } - std::shared_ptr m_value; - size_t m_count = 0; + + const OptionNames * m_long_names = nullptr; + // Holding this pointer is safe, since OptionValue's only exist in key-value pairs, + // where the key has the string we point to. + std::shared_ptr m_value{}; + std::size_t m_count = 0; bool m_default = false; }; -class KeyValue { - public: - KeyValue(std::string key_, std::string value_) - : m_key(std::move(key_)), m_value(std::move(value_)) +class KeyValue +{ + public: + KeyValue(std::string key_, std::string value_) noexcept + : m_key(std::move(key_)) + , m_value(std::move(value_)) { } - const std::string& key() const { return m_key; } + CXXOPTS_NODISCARD + const std::string& + key() const + { + return m_key; + } - const std::string& value() const { return m_value; } + CXXOPTS_NODISCARD + const std::string& + value() const + { + return m_value; + } template - T as() const + T + as() const { T result; values::parse_value(m_value, result); return result; } - private: + private: std::string m_key; std::string m_value; }; -class ParseResult { - public: - ParseResult( - const std::shared_ptr>>, - std::vector, - bool allow_unrecognised, - int&, - char**&); +using ParsedHashMap = std::unordered_map; +using NameHashMap = std::unordered_map; + +class ParseResult +{ + public: + class Iterator + { + public: + using iterator_category = std::forward_iterator_tag; + using value_type = KeyValue; + using difference_type = void; + using pointer = const KeyValue*; + using reference = const KeyValue&; + + Iterator() = default; + Iterator(const Iterator&) = default; + +// GCC complains about m_iter not being initialised in the member +// initializer list +CXXOPTS_DIAGNOSTIC_PUSH +CXXOPTS_IGNORE_WARNING("-Weffc++") + Iterator(const ParseResult *pr, bool end=false) + : m_pr(pr) + { + if (end) + { + m_sequential = false; + m_iter = m_pr->m_defaults.end(); + } + else + { + m_sequential = true; + m_iter = m_pr->m_sequential.begin(); + + if (m_iter == m_pr->m_sequential.end()) + { + m_sequential = false; + m_iter = m_pr->m_defaults.begin(); + } + } + } +CXXOPTS_DIAGNOSTIC_POP + + Iterator& operator++() + { + ++m_iter; + if(m_sequential && m_iter == m_pr->m_sequential.end()) + { + m_sequential = false; + m_iter = m_pr->m_defaults.begin(); + return *this; + } + return *this; + } + + Iterator operator++(int) + { + Iterator retval = *this; + ++(*this); + return retval; + } + + bool operator==(const Iterator& other) const + { + return (m_sequential == other.m_sequential) && (m_iter == other.m_iter); + } + + bool operator!=(const Iterator& other) const + { + return !(*this == other); + } + + const KeyValue& operator*() + { + return *m_iter; + } + + const KeyValue* operator->() + { + return m_iter.operator->(); + } - size_t count(const std::string& o) const + private: + const ParseResult* m_pr; + std::vector::const_iterator m_iter; + bool m_sequential = true; + }; + + ParseResult() = default; + ParseResult(const ParseResult&) = default; + + ParseResult(NameHashMap&& keys, ParsedHashMap&& values, std::vector sequential, + std::vector default_opts, std::vector&& unmatched_args) + : m_keys(std::move(keys)) + , m_values(std::move(values)) + , m_sequential(std::move(sequential)) + , m_defaults(std::move(default_opts)) + , m_unmatched(std::move(unmatched_args)) { - auto iter = m_options->find(o); - if (iter == m_options->end()) { return 0; } + } - auto riter = m_results.find(iter->second); + ParseResult& operator=(ParseResult&&) = default; + ParseResult& operator=(const ParseResult&) = default; - return riter->second.count(); + Iterator + begin() const + { + return Iterator(this); + } + + Iterator + end() const + { + return Iterator(this, true); } - const OptionValue& operator[](const std::string& option) const + std::size_t + count(const std::string& o) const { - auto iter = m_options->find(option); + auto iter = m_keys.find(o); + if (iter == m_keys.end()) + { + return 0; + } + + auto viter = m_values.find(iter->second); - if (iter == m_options->end()) { throw_or_mimic(option); } + if (viter == m_values.end()) + { + return 0; + } - auto riter = m_results.find(iter->second); + return viter->second.count(); + } - return riter->second; + bool + contains(const std::string& o) const + { + return static_cast(count(o)); } - const std::vector& arguments() const { return m_sequential; } + const OptionValue& + operator[](const std::string& option) const + { + auto iter = m_keys.find(option); + + if (iter == m_keys.end()) + { + throw_or_mimic(option); + } - private: - void parse(int& argc, char**& argv); + auto viter = m_values.find(iter->second); - void add_to_option(const std::string& option, const std::string& arg); + if (viter == m_values.end()) + { + throw_or_mimic(option); + } - bool consume_positional(std::string a); + return viter->second; + } - void parse_option(std::shared_ptr value, - const std::string& name, - const std::string& arg = ""); +#ifdef CXXOPTS_HAS_OPTIONAL + template + std::optional + as_optional(const std::string& option) const + { + auto iter = m_keys.find(option); + if (iter != m_keys.end()) + { + auto viter = m_values.find(iter->second); + if (viter != m_values.end()) + { + return viter->second.as_optional(); + } + } + return std::nullopt; + } +#endif - void parse_default(std::shared_ptr details); + const std::vector& + arguments() const + { + return m_sequential; + } - void checked_parse_arg(int argc, - char* argv[], - int& current, - std::shared_ptr value, - const std::string& name); + const std::vector& + unmatched() const + { + return m_unmatched; + } - const std::shared_ptr>> m_options; - std::vector m_positional; - std::vector::iterator m_next_positional; - std::unordered_set m_positional_set; - std::unordered_map, OptionValue> m_results; + const std::vector& + defaults() const + { + return m_defaults; + } - bool m_allow_unrecognised; + const std::string + arguments_string() const + { + std::string result; + for(const auto& kv: m_sequential) + { + result += kv.key() + " = " + kv.value() + "\n"; + } + for(const auto& kv: m_defaults) + { + result += kv.key() + " = " + kv.value() + " " + "(default)" + "\n"; + } + return result; + } - std::vector m_sequential; + private: + NameHashMap m_keys{}; + ParsedHashMap m_values{}; + std::vector m_sequential{}; + std::vector m_defaults{}; + std::vector m_unmatched{}; }; -struct Option { - Option(const std::string& opts, - const std::string& desc, - const std::shared_ptr& value = ::cxxopts::value(), - const std::string& arg_help = "") - : opts_(opts), desc_(desc), value_(value), arg_help_(arg_help) +struct Option +{ + Option + ( + std::string opts, + std::string desc, + std::shared_ptr value = ::cxxopts::value(), + std::string arg_help = "" + ) + : opts_(std::move(opts)) + , desc_(std::move(desc)) + , value_(std::move(value)) + , arg_help_(std::move(arg_help)) { } @@ -869,150 +1865,311 @@ struct Option { std::string arg_help_; }; -class Options { - typedef std::unordered_map> OptionMap; +using OptionMap = std::unordered_map>; +using PositionalList = std::vector; +using PositionalListIterator = PositionalList::const_iterator; + +class OptionParser +{ + public: + OptionParser(const OptionMap& options, const PositionalList& positional, bool allow_unrecognised) + : m_options(options) + , m_positional(positional) + , m_allow_unrecognised(allow_unrecognised) + { + } + + ParseResult + parse(int argc, const char* const* argv); + + bool + consume_positional(const std::string& a, PositionalListIterator& next); - public: - Options(std::string program, std::string help_string = "") - : m_program(std::move(program)), - m_help_string(toLocalString(std::move(help_string))), - m_custom_help("[OPTION...]"), - m_positional_help("positional parameters"), - m_show_positional(false), - m_allow_unrecognised(false), - m_options(std::make_shared()), - m_next_positional(m_positional.end()) + void + checked_parse_arg + ( + int argc, + const char* const* argv, + int& current, + const std::shared_ptr& value, + const std::string& name + ); + + void + add_to_option(const std::shared_ptr& value, const std::string& arg); + + void + parse_option + ( + const std::shared_ptr& value, + const std::string& name, + const std::string& arg = "" + ); + + void + parse_default(const std::shared_ptr& details); + + void + parse_no_value(const std::shared_ptr& details); + + private: + + void finalise_aliases(); + + const OptionMap& m_options; + const PositionalList& m_positional; + + std::vector m_sequential{}; + std::vector m_defaults{}; + bool m_allow_unrecognised; + + ParsedHashMap m_parsed{}; + NameHashMap m_keys{}; +}; + +class Options +{ + public: + + explicit Options(std::string program_name, std::string help_string = "") + : m_program(std::move(program_name)) + , m_help_string(toLocalString(std::move(help_string))) + , m_custom_help("[OPTION...]") + , m_positional_help("positional parameters") + , m_show_positional(false) + , m_allow_unrecognised(false) + , m_width(76) + , m_tab_expansion(false) + , m_options(std::make_shared()) { } - Options& positional_help(std::string help_text) + Options& + positional_help(std::string help_text) { m_positional_help = std::move(help_text); return *this; } - Options& custom_help(std::string help_text) + Options& + custom_help(std::string help_text) { m_custom_help = std::move(help_text); return *this; } - Options& show_positional_help() + Options& + show_positional_help() { m_show_positional = true; return *this; } - Options& allow_unrecognised_options() + Options& + allow_unrecognised_options() { m_allow_unrecognised = true; return *this; } - ParseResult parse(int& argc, char**& argv); - - OptionAdder add_options(std::string group = ""); - - void add_options(const std::string& group, std::initializer_list