[clang] [MLIR] Add SyclRuntimeWrapper (PR #69648)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 19 15:26:34 PDT 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff e353cd8173db939af22a6fd90705e35fbadb01a7 95b9d423a9e4fc0f317e2468696a9dafefd20f46 -- mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp b/mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp
index f3a082922d61..619d88e889f7 100644
--- a/mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp
+++ b/mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp
@@ -65,36 +65,37 @@ auto catchAll(F &&func) {
static sycl::device getDefaultDevice() {
static sycl::device syclDevice;
- static bool isDeviceInitialised = false;
- if(!isDeviceInitialised) {
- auto platformList = sycl::platform::get_platforms();
- for (const auto &platform : platformList) {
- auto platformName = platform.get_info<sycl::info::platform::name>();
- bool isLevelZero = platformName.find("Level-Zero") != std::string::npos;
- if (!isLevelZero)
- continue;
-
- syclDevice = platform.get_devices()[0];
- isDeviceInitialised = true;
- return syclDevice;
- }
+ static bool isDeviceInitialised = false;
+ if (!isDeviceInitialised) {
+ auto platformList = sycl::platform::get_platforms();
+ for (const auto &platform : platformList) {
+ auto platformName = platform.get_info<sycl::info::platform::name>();
+ bool isLevelZero = platformName.find("Level-Zero") != std::string::npos;
+ if (!isLevelZero)
+ continue;
+
+ syclDevice = platform.get_devices()[0];
+ isDeviceInitialised = true;
+ return syclDevice;
+ }
throw std::runtime_error("getDefaultDevice failed");
- }
- else
+ } else
return syclDevice;
}
static sycl::context getDefaultContext() {
- static sycl::context syclContext { getDefaultDevice() };
+ static sycl::context syclContext{getDefaultDevice()};
return syclContext;
}
static void *allocDeviceMemory(sycl::queue *queue, size_t size, bool isShared) {
void *memPtr = nullptr;
if (isShared) {
- memPtr = sycl::aligned_alloc_shared(64, size, getDefaultDevice(), getDefaultContext());
+ memPtr = sycl::aligned_alloc_shared(64, size, getDefaultDevice(),
+ getDefaultContext());
} else {
- memPtr = sycl::aligned_alloc_device(64, size, getDefaultDevice(), getDefaultContext());
+ memPtr = sycl::aligned_alloc_device(64, size, getDefaultDevice(),
+ getDefaultContext());
}
if (memPtr == nullptr) {
throw std::runtime_error("mem allocation failed!");
@@ -116,10 +117,10 @@ static ze_module_handle_t loadModule(const void *data, size_t dataSize) {
(const uint8_t *)data,
nullptr,
nullptr};
- auto zeDevice =
- sycl::get_native<sycl::backend::ext_oneapi_level_zero>(getDefaultDevice());
- auto zeContext =
- sycl::get_native<sycl::backend::ext_oneapi_level_zero>(getDefaultContext());
+ auto zeDevice = sycl::get_native<sycl::backend::ext_oneapi_level_zero>(
+ getDefaultDevice());
+ auto zeContext = sycl::get_native<sycl::backend::ext_oneapi_level_zero>(
+ getDefaultContext());
L0_SAFE_CALL(zeModuleCreate(zeContext, zeDevice, &desc, &zeModule, nullptr));
return zeModule;
}
@@ -134,8 +135,8 @@ static sycl::kernel *getKernel(ze_module_handle_t zeModule, const char *name) {
L0_SAFE_CALL(zeKernelCreate(zeModule, &desc, &zeKernel));
sycl::kernel_bundle<sycl::bundle_state::executable> kernelBundle =
sycl::make_kernel_bundle<sycl::backend::ext_oneapi_level_zero,
- sycl::bundle_state::executable>({zeModule},
- getDefaultContext());
+ sycl::bundle_state::executable>(
+ {zeModule}, getDefaultContext());
auto kernel = sycl::make_kernel<sycl::backend::ext_oneapi_level_zero>(
{kernelBundle, zeKernel}, getDefaultContext());
``````````
</details>
https://github.com/llvm/llvm-project/pull/69648
More information about the cfe-commits
mailing list