-
Notifications
You must be signed in to change notification settings - Fork 96
[SYCLomatic] Block Store headers core #1819
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
Changes from 23 commits
13d8b67
7517519
6b7fd09
454c453
9e75c62
ffbd181
a0007e1
49147b8
18f826a
7149372
431d4a4
8cc73f1
a677eb2
98d0193
79295f8
c4fe035
76ec684
41b1c8a
b046dcc
f86801d
273d098
3185ceb
cc00403
56c07e1
28ff868
e87c0a6
1802fbe
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -708,10 +708,10 @@ class [[deprecated("Please use group_radix_sort instead")]] radix_sort { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// Load linear segment items into block format across threads | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// Helper for Block Load | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
enum load_algorithm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
enum class load_algorithm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
BLOCK_LOAD_DIRECT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
BLOCK_LOAD_STRIPED, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// loads a linear segment of workgroup items into a blocked arrangement. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
template <size_t ITEMS_PER_WORK_ITEM, typename InputT, typename InputIteratorT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -842,16 +842,119 @@ class workgroup_load { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
__dpct_inline__ void load(const Item &item, InputIteratorT block_itr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
InputT (&items)[ITEMS_PER_WORK_ITEM]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if constexpr (ALGORITHM == BLOCK_LOAD_DIRECT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if constexpr (ALGORITHM == load_algorithm::BLOCK_LOAD_DIRECT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
load_blocked<ITEMS_PER_WORK_ITEM>(item, block_itr, items); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else if constexpr (ALGORITHM == BLOCK_LOAD_STRIPED) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else if constexpr (ALGORITHM == load_algorithm::BLOCK_LOAD_STRIPED) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
load_striped<ITEMS_PER_WORK_ITEM>(item, block_itr, items); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
private: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
uint8_t *_local_memory; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// Store blocked/warped or striped work items into linear segment of items. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
abhilash1910 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// Helper for Block Store | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
enum class store_algorithm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
BLOCK_STORE_DIRECT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
BLOCK_STORE_STRIPED, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// Stores a blocked arrangement of work items linear segment of items. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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. I'd like to have a more detail comments like SYCLomatic/clang/runtime/dpct-rt/include/dpct/sparse_utils.hpp Lines 278 to 306 in b2e5588
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
template <size_t ITEMS_PER_WORK_ITEM, typename InputT, typename OutputIteratorT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
typename Item> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
__dpct_inline__ void store_blocked(const Item &item, OutputIteratorT block_itr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
InputT (&items)[ITEMS_PER_WORK_ITEM]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// This implementation does not take in account range storage across | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// workgroup items To-do: Decide whether range storage is required for group | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// storage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
size_t linear_tid = item.get_local_linear_id(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OutputIteratorT workitem_itr = block_itr + (linear_tid * ITEMS_PER_WORK_ITEM); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#pragma unroll | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
for (uint32_t idx = 0; idx < ITEMS_PER_WORK_ITEM; idx++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
workitem_itr[idx] = items[idx]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// Stores a striped arrangement of work items linear segment of items. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
template <size_t ITEMS_PER_WORK_ITEM, typename InputT, typename OutputIteratorT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
typename Item> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
__dpct_inline__ void store_striped(const Item &item, OutputIteratorT block_itr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
InputT (&items)[ITEMS_PER_WORK_ITEM]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// This implementation does not take in account range storage across | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// workgroup items To-do: Decide whether range storage is required for group | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// storage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
size_t linear_tid = item.get_local_linear_id(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OutputIteratorT workitem_itr = block_itr + linear_tid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
size_t group_work_items = item.get_local_range().size(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#pragma unroll | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
for (uint32_t idx = 0; idx < ITEMS_PER_WORK_ITEM; idx++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
workitem_itr[(idx * group_work_items)] = items[idx]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// Stores a subgroup-striped arrangement of work items linear segment of items. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Created as free function until exchange mechanism is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// implemented. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// To-do: inline this function with BLOCK_STORE_WARP_TRANSPOSE mechanism | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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. I'm not sure what this comment means exactly. But also, lets use our own terminology here. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
template <size_t ITEMS_PER_WORK_ITEM, typename InputT, typename OutputIteratorT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
typename Item> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
__dpct_inline__ void | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
store_subgroup_striped(const Item &item, OutputIteratorT block_itr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
InputT (&items)[ITEMS_PER_WORK_ITEM]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// This implementation does not take in account range storing across | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// workgroup items To-do: Decide whether range storing is required for group | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// loading | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// This implementation loads linear segments into warp striped arrangement. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
abhilash1910 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
auto sub_group = item.get_subgroup(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
abhilash1910 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
uint32_t subgroup_offset = sub_group.get_local_linear_id(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
uint32_t subgroup_size = sub_group.get_local_linear_range(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
uint32_t subgroup_idx = sub_group.get_group_linear_id(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
uint32_t initial_offset = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(subgroup_idx * ITEMS_PER_WORK_ITEM * subgroup_size) + subgroup_offset; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OutputIteratorT workitem_itr = block_itr + initial_offset; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#pragma unroll | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
for (uint32_t idx = 0; idx < ITEMS_PER_WORK_ITEM; idx++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
workitem_itr[(idx * subgroup_size)] = items[idx]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// template parameters : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// ITEMS_PER_WORK_ITEM: size_t variable controlling the number of items per | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// thread/work_item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// ALGORITHM: store_algorithm variable controlling the type of store operation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// InputT: type for input sequence. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// OutputIteratorT: output iterator type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Item : typename parameter resembling sycl::nd_item<3> . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
template <size_t ITEMS_PER_WORK_ITEM, store_algorithm ALGORITHM, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
typename InputT, typename OutputIteratorT, typename Item> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class workgroup_store { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
static size_t get_local_memory_size(size_t group_work_items) { return 0; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
workgroup_store(uint8_t *local_memory) : _local_memory(local_memory) {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
__dpct_inline__ void store(const Item &item, OutputIteratorT block_itr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
InputT (&items)[ITEMS_PER_WORK_ITEM]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if constexpr (ALGORITHM == store_algorithm::BLOCK_STORE_DIRECT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
store_blocked<ITEMS_PER_WORK_ITEM>(item, block_itr, items); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else if constexpr (ALGORITHM == store_algorithm::BLOCK_STORE_STRIPED) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
store_striped<ITEMS_PER_WORK_ITEM>(item, block_itr, items); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
private: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// local_memory is a placeholder ,currently unused, as no operations use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// extra memory but placed here to make migrations easier. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// For future exchange operations might be necessary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
abhilash1910 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
uint8_t *_local_memory; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
danhoeflinger marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} // namespace group | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} // namespace dpct | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.