-
Notifications
You must be signed in to change notification settings - Fork 32
Fix large-message initialization in communication benchmark #1016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,9 @@ | |
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include <cstdint> | ||
| #include <limits> | ||
|
|
||
| #include <thrust/random.h> | ||
| #include <thrust/transform.h> | ||
|
|
||
|
|
@@ -17,21 +20,30 @@ | |
| #include "random_data.hpp" | ||
|
|
||
| rmm::device_uvector<std::int32_t> random_device_vector( | ||
| cudf::size_type nelem, | ||
| std::size_t nelem, | ||
| std::int32_t min_val, | ||
| std::int32_t max_val, | ||
| rmm::cuda_stream_view stream, | ||
| rmm::device_async_resource_ref mr | ||
| ) { | ||
| // Fill vector with random data. | ||
| rmm::device_uvector<std::int32_t> vec(static_cast<std::size_t>(nelem), stream, mr); | ||
| using index_t = std::int64_t; | ||
| RAPIDSMPF_EXPECTS( | ||
| nelem <= static_cast<std::size_t>(std::numeric_limits<index_t>::max()), | ||
| "random_device_vector size exceeds signed iterator range" | ||
| ); | ||
| rmm::device_uvector<std::int32_t> vec(nelem, stream, mr); | ||
| thrust::counting_iterator<index_t> const begin(0); | ||
| thrust::counting_iterator<index_t> const end(static_cast<index_t>(nelem)); | ||
| thrust::transform( | ||
| rmm::exec_policy(stream), | ||
| thrust::make_counting_iterator(0), | ||
| thrust::make_counting_iterator(nelem), | ||
| begin, | ||
| end, | ||
| vec.begin(), | ||
| [min_val, max_val] __device__(cudf::size_type index) { | ||
| thrust::default_random_engine engine(index); // HACK: use the seed as index | ||
| [min_val, max_val] __device__(index_t index) { | ||
| thrust::default_random_engine engine( | ||
| static_cast<thrust::default_random_engine::result_type>(index) | ||
| ); | ||
| thrust::uniform_int_distribution<std::int32_t> dist(min_val, max_val); | ||
| return dist(engine); | ||
| } | ||
|
|
@@ -46,7 +58,10 @@ std::unique_ptr<cudf::column> random_column( | |
| rmm::cuda_stream_view stream, | ||
| rmm::device_async_resource_ref mr | ||
| ) { | ||
| auto vec = random_device_vector(nrows, min_val, max_val, stream, mr); | ||
| RAPIDSMPF_EXPECTS(nrows >= 0, "nrows must be non-negative"); | ||
| auto vec = random_device_vector( | ||
| static_cast<std::size_t>(nrows), min_val, max_val, stream, mr | ||
| ); | ||
| return std::make_unique<cudf::column>( | ||
| std::move(vec), rmm::device_buffer{0, stream, mr}, 0 | ||
| ); | ||
|
|
@@ -72,7 +87,7 @@ void random_fill(rapidsmpf::Buffer& buffer, rmm::device_async_resource_ref mr) { | |
| case rapidsmpf::MemoryType::DEVICE: | ||
| { | ||
| auto vec = random_device_vector( | ||
| buffer.size / sizeof(std::int32_t) + sizeof(std::int32_t), | ||
| (buffer.size + sizeof(std::int32_t) - 1) / sizeof(std::int32_t), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be fixed now. |
||
| std::numeric_limits<std::int32_t>::min(), | ||
| std::numeric_limits<std::int32_t>::max(), | ||
| buffer.stream(), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. Do we consider 32-bit systems? For 64 bit nelem > INT64_MAX seems unlikely isnt it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always use
safe_cast()There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No: https://forums.developer.nvidia.com/t/whats-the-last-version-of-the-cuda-toolkit-to-support-32-bit-applications/323106/4
Removed that.
Done.