Skip to content

Commit

Permalink
Merge pull request #1152 from PietroGhg/pietro/barriers
Browse files Browse the repository at this point in the history
[NATIVECPU] Handle oneAPI Construction Kit integration in runtime
  • Loading branch information
kbenzie committed Jan 24, 2024
2 parents 6892412 + 71e7e38 commit eddda12
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/adapters/native_cpu/enqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include <array>
#include <cstdint>

Expand Down Expand Up @@ -77,6 +76,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch(
for (unsigned g2 = 0; g2 < numWG2; g2++) {
for (unsigned g1 = 0; g1 < numWG1; g1++) {
for (unsigned g0 = 0; g0 < numWG0; g0++) {
#ifdef NATIVECPU_USE_OCK
state.update(g0, g1, g2);
hKernel->_subhandler(hKernel->_args.data(), &state);
#else
for (unsigned local2 = 0; local2 < ndr.LocalSize[2]; local2++) {
for (unsigned local1 = 0; local1 < ndr.LocalSize[1]; local1++) {
for (unsigned local0 = 0; local0 < ndr.LocalSize[0]; local0++) {
Expand All @@ -85,6 +88,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch(
}
}
}
#endif
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions source/adapters/native_cpu/nativecpu_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ struct state {
MGlobal_id[2] =
MWorkGroup_size[2] * MWorkGroup_id[2] + MLocal_id[2] + MGlobalOffset[2];
}

void update(size_t group0, size_t group1, size_t group2) {
MWorkGroup_id[0] = group0;
MWorkGroup_id[1] = group1;
MWorkGroup_id[2] = group2;
}
};

} // namespace native_cpu

0 comments on commit eddda12

Please sign in to comment.