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} 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_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/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/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())) { } }; 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/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/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/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/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"] diff --git a/tests/device_buffer_tests.cu b/tests/device_buffer_tests.cu index f73be0201..c095eecf8 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,6 @@ struct DeviceBufferTest : public ::testing::Test { }; using resources = ::testing::Types; -using async_resource_ref = cuda::mr::async_resource_ref; TYPED_TEST_CASE(DeviceBufferTest, resources); @@ -75,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()); } @@ -86,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()); } @@ -96,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()); } @@ -107,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()); } @@ -119,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 @@ -135,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 @@ -148,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()); } @@ -175,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), @@ -218,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_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()} {} diff --git a/tests/device_uvector_tests.cpp b/tests/device_uvector_tests.cpp index 3c042a437..1c93ef138 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; @@ -30,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 = cuda::mr::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/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; 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 9826c10be..f999e08f4 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 @@ -44,8 +45,7 @@ #include #include -using resource_ref = cuda::mr::resource_ref; -using async_resource_ref = cuda::mr::async_resource_ref; +using resource_ref = cuda::mr::resource_ref; namespace rmm::test { @@ -75,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 = {}) { @@ -105,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}; @@ -146,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 { @@ -199,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 = {}) @@ -272,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 = {}) { @@ -343,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 ed8875cbe..038f4b664 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,6 @@ namespace rmm::test { namespace { struct allocator_test : public mr_test {}; -using async_resource_ref = cuda::mr::async_resource_ref; TEST_P(allocator_test, first) { @@ -46,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,