Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

AdjacentDifferenceCopy not setting temp_storage_bytes. #506

Closed
vince-streamhpc opened this issue Jun 9, 2022 · 1 comment
Closed

AdjacentDifferenceCopy not setting temp_storage_bytes. #506

vince-streamhpc opened this issue Jun 9, 2022 · 1 comment
Assignees
Labels
P1: should have Necessary, but not critical. type: bug: functional Does not work as intended.
Milestone

Comments

@vince-streamhpc
Copy link

Calling AdjacentDifferenceCopy with nullptr to determine the storage size needed, does not set the temp_storage_bytes value.

template <bool ReadLeft,
          typename InputIteratorT,
          typename OutputIteratorT,
          typename DifferenceOpT,
          typename NumItemsT>
void AdjacentDifferenceCopy(InputIteratorT input,
                            OutputIteratorT output,
                            DifferenceOpT difference_op,
                            NumItemsT num_items)
{
  std::size_t temp_storage_bytes; // Will stay uninitialized after calling:

  AdjacentDifferenceCopy<ReadLeft>(nullptr,
                                   temp_storage_bytes,
                                   input,
                                   output,
                                   difference_op,
                                   num_items);

  thrust::device_vector<std::uint8_t> temp_storage(temp_storage_bytes); // Crashes because temp_storage_bytes is uninitialized and thus contains likely a very large random value
  AdjacentDifferenceCopy<ReadLeft>(thrust::raw_pointer_cast(
                                     temp_storage.data()),
                                   temp_storage_bytes,
                                   input,
                                   output,
                                   difference_op,
                                   num_items);
}
@gevtushenko
Copy link
Collaborator

@vince-streamhpc thank you for noticing this! I've created PR with a fix.

@gevtushenko gevtushenko self-assigned this Jun 9, 2022
@alliepiper alliepiper added type: bug: functional Does not work as intended. P1: should have Necessary, but not critical. labels Jun 22, 2022
@alliepiper alliepiper added this to the 2.0.0 milestone Jun 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P1: should have Necessary, but not critical. type: bug: functional Does not work as intended.
Projects
None yet
Development

No branches or pull requests

3 participants