Skip to content

Commit 3972e65

Browse files
NaraendaGergely Meszaros
andauthored
StreamHPC 2023-10-30 (#338)
* fix: Restore compatibility with latest rocPRIM rocPRIM changed the API of `lookback_scan_state`, update usage to match. * fix: doxygen warnings --------- Co-authored-by: Gergely Meszaros <gergely@streamhpc.com>
1 parent c24fefa commit 3972e65

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

thrust/mr/new.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright 2018 NVIDIA Corporation
3+
* Modifications Copyright 2023 Advanced Micro Devices, Inc. All rights reserved.
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -39,6 +40,13 @@ namespace mr
3940
class new_delete_resource final : public memory_resource<>
4041
{
4142
public:
43+
/*! Allocates memory of size at least \p bytes and alignment at least \p alignment.
44+
*
45+
* \param bytes size, in bytes, that is requested from this allocation
46+
* \param alignment alignment that is requested from this allocation
47+
* \throws thrust::bad_alloc when no memory with requested size and alignment can be allocated.
48+
* \return A pointer to void to the newly allocated memory.
49+
*/
4250
void * do_allocate(std::size_t bytes, std::size_t alignment = THRUST_MR_DEFAULT_ALIGNMENT) override
4351
{
4452
#if defined(__cpp_aligned_new)
@@ -60,6 +68,14 @@ class new_delete_resource final : public memory_resource<>
6068
#endif
6169
}
6270

71+
/*! Deallocates memory pointed to by \p p.
72+
*
73+
* \param p pointer to be deallocated
74+
* \param bytes the size of the allocation. This must be equivalent to the value of \p bytes that
75+
* was passed to the allocation function that returned \p p.
76+
* \param alignment the size of the allocation. This must be equivalent to the value of \p alignment
77+
* that was passed to the allocation function that returned \p p.
78+
*/
6379
void do_deallocate(void * p, std::size_t bytes, std::size_t alignment = THRUST_MR_DEFAULT_ALIGNMENT) override
6480
{
6581
#if defined(__cpp_aligned_new)

thrust/system/hip/detail/set_operations.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -918,8 +918,12 @@ namespace __set_operations
918918
const unsigned int number_of_blocks = (keys_total + items_per_block - 1) / items_per_block;
919919

920920
// Calculate required temporary storage
921-
size_t scan_state_bytes
922-
= ::rocprim::detail::align_size(block_state_type::get_storage_size(number_of_blocks));
921+
size_t scan_state_bytes;
922+
status = block_state_type::get_storage_size(number_of_blocks, stream, scan_state_bytes);
923+
if (status != hipSuccess) {
924+
return status;
925+
}
926+
scan_state_bytes = ::rocprim::detail::align_size(scan_state_bytes);
923927
size_t ordered_block_id_bytes
924928
= ::rocprim::detail::align_size(ordered_block_id_type::get_storage_size());
925929
size_t partition_storage_bytes = (number_of_blocks + 1) * sizeof(pair<Size, Size>);
@@ -943,7 +947,11 @@ namespace __set_operations
943947

944948
auto ptr = reinterpret_cast<char*>(temporary_storage);
945949
// Create and initialize lookback_scan_state obj
946-
auto blocks_state = block_state_type::create(ptr, number_of_blocks);
950+
block_state_type blocks_state;
951+
status = block_state_type::create(blocks_state, ptr, number_of_blocks, stream);
952+
if (status != hipSuccess) {
953+
return status;
954+
}
947955
ptr += scan_state_bytes;
948956
// Create and initialize ordered_block_id obj
949957
auto ordered_bid

0 commit comments

Comments
 (0)