Skip to content

Commit 3c378a4

Browse files
committed
Change hashmap to vector
1 parent 957c657 commit 3c378a4

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

unified-runtime/source/adapters/level_zero/v2/command_buffer.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ ur_exp_command_buffer_handle_t_::getSyncPoint(ur_event_handle_t event) {
8484
throw UR_RESULT_ERROR_OUT_OF_RESOURCES;
8585
}
8686
syncPoints.push_back(event);
87+
usedSyncPoints.push_back(false);
8788
return static_cast<ur_exp_command_buffer_sync_point_t>(syncPoints.size() - 1);
8889
}
8990

@@ -99,7 +100,7 @@ ur_event_handle_t *ur_exp_command_buffer_handle_t_::getWaitListFromSyncPoints(
99100
UR_LOG(ERR, "Invalid sync point");
100101
throw UR_RESULT_ERROR_INVALID_VALUE;
101102
}
102-
usedSyncPoints.insert(pSyncPointWaitList[i]);
103+
usedSyncPoints[pSyncPointWaitList[i]] = true;
103104
syncPointWaitList[i] = syncPoints[pSyncPointWaitList[i]];
104105
}
105106
return syncPointWaitList.data();
@@ -133,10 +134,13 @@ ur_result_t ur_exp_command_buffer_handle_t_::finalizeCommandBuffer() {
133134
if (!isInOrder) {
134135
ZE2UR_CALL(zeCommandListAppendBarrier,
135136
(commandListLocked->getZeCommandList(), nullptr, 0, nullptr));
136-
for (auto &event : usedSyncPoints) {
137-
ZE2UR_CALL(zeCommandListAppendEventReset,
138-
(commandListLocked->getZeCommandList(),
139-
syncPoints[event]->getZeEvent()));
137+
for (size_t i = 0; i < usedSyncPoints.size(); ++i) {
138+
if (!usedSyncPoints[i]) {
139+
continue;
140+
}
141+
ZE2UR_CALL(
142+
zeCommandListAppendEventReset,
143+
(commandListLocked->getZeCommandList(), syncPoints[i]->getZeEvent()));
140144
}
141145
ZE2UR_CALL(zeCommandListAppendBarrier,
142146
(commandListLocked->getZeCommandList(), nullptr, 0, nullptr));

unified-runtime/source/adapters/level_zero/v2/command_buffer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct ur_exp_command_buffer_handle_t_ : public ur_object {
6767
std::vector<ur_event_handle_t> syncPoints;
6868

6969
// Stores all sync points that should be reset after execution.
70-
std::unordered_set<ur_exp_command_buffer_sync_point_t> usedSyncPoints;
70+
std::vector<bool> usedSyncPoints;
7171

7272
// Temporary storage for sync points that are passed to function that require
7373
// array of events. This is used to avoid allocating a new memory every time.

0 commit comments

Comments
 (0)