Skip to content

Commit eddda12

Browse files
authored
Merge pull request #1152 from PietroGhg/pietro/barriers
[NATIVECPU] Handle oneAPI Construction Kit integration in runtime
2 parents 6892412 + 71e7e38 commit eddda12

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

source/adapters/native_cpu/enqueue.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
88
//
99
//===----------------------------------------------------------------------===//
10-
1110
#include <array>
1211
#include <cstdint>
1312

@@ -77,6 +76,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch(
7776
for (unsigned g2 = 0; g2 < numWG2; g2++) {
7877
for (unsigned g1 = 0; g1 < numWG1; g1++) {
7978
for (unsigned g0 = 0; g0 < numWG0; g0++) {
79+
#ifdef NATIVECPU_USE_OCK
80+
state.update(g0, g1, g2);
81+
hKernel->_subhandler(hKernel->_args.data(), &state);
82+
#else
8083
for (unsigned local2 = 0; local2 < ndr.LocalSize[2]; local2++) {
8184
for (unsigned local1 = 0; local1 < ndr.LocalSize[1]; local1++) {
8285
for (unsigned local0 = 0; local0 < ndr.LocalSize[0]; local0++) {
@@ -85,6 +88,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch(
8588
}
8689
}
8790
}
91+
#endif
8892
}
8993
}
9094
}

source/adapters/native_cpu/nativecpu_state.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ struct state {
5353
MGlobal_id[2] =
5454
MWorkGroup_size[2] * MWorkGroup_id[2] + MLocal_id[2] + MGlobalOffset[2];
5555
}
56+
57+
void update(size_t group0, size_t group1, size_t group2) {
58+
MWorkGroup_id[0] = group0;
59+
MWorkGroup_id[1] = group1;
60+
MWorkGroup_id[2] = group2;
61+
}
5662
};
5763

5864
} // namespace native_cpu

0 commit comments

Comments
 (0)