[Lldb-commits] [libc] [clang] [llvm] [lld] [flang] [clang-tools-extra] [openmp] [lldb] [compiler-rt] [libcxx] [mlir] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-27 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 updated 
https://github.com/llvm/llvm-project/pull/71430

>From c76403cf8629b8f7d8a5b7a3ee5da2881713a7f8 Mon Sep 17 00:00:00 2001
From: "Lee, Sang Ik" 
Date: Mon, 6 Nov 2023 18:47:23 +
Subject: [PATCH 1/5] [MLIR] Enable GPU Dialect to SYCL runtime integration

GPU Dialect lowering to SYCL runtime is driven by spirv.target_env
attached to gpu.module. As a result of this, spirv.target_env remains
as an input to LLVMIR Translation.
A SPIRVToLLVMIRTranslation without any actual translation is added to
avoid an unregistered error in mlir-cpu-runner.
SelectObjectAttr.cpp is updated to
1) Pass binary size argument to getModuleLoadFn
2) Pass parameter count to getKernelLaunchFn
This change does not impact CUDA and ROCM usage since both
mlir_cuda_runtime and mlir_rocm_runtime are already updated to
accept and ignore the extra arguments.
---
 mlir/include/mlir/Target/LLVMIR/Dialect/All.h |  3 ++
 .../Dialect/SPIRV/SPIRVToLLVMIRTranslation.h  | 31 +++
 mlir/lib/Target/LLVMIR/CMakeLists.txt |  1 +
 mlir/lib/Target/LLVMIR/Dialect/CMakeLists.txt |  1 +
 .../LLVMIR/Dialect/GPU/SelectObjectAttr.cpp   | 50 +
 .../LLVMIR/Dialect/SPIRV/CMakeLists.txt   | 13 +
 .../SPIRV/SPIRVToLLVMIRTranslation.cpp| 31 +++
 mlir/test/CMakeLists.txt  |  4 ++
 .../Integration/GPU/SYCL/gpu-to-spirv.mlir| 54 +++
 mlir/test/Integration/GPU/SYCL/lit.local.cfg  |  2 +
 mlir/test/Target/LLVMIR/gpu.mlir  |  9 ++--
 mlir/test/lit.cfg.py  |  3 ++
 mlir/test/lit.site.cfg.py.in  |  1 +
 13 files changed, 188 insertions(+), 15 deletions(-)
 create mode 100644 
mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h
 create mode 100644 mlir/lib/Target/LLVMIR/Dialect/SPIRV/CMakeLists.txt
 create mode 100644 
mlir/lib/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.cpp
 create mode 100644 mlir/test/Integration/GPU/SYCL/gpu-to-spirv.mlir
 create mode 100644 mlir/test/Integration/GPU/SYCL/lit.local.cfg

diff --git a/mlir/include/mlir/Target/LLVMIR/Dialect/All.h 
b/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
index 0563b9bf3d475a4..5dfc15afb75931a 100644
--- a/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
+++ b/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
@@ -26,6 +26,7 @@
 #include "mlir/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/ROCDL/ROCDLToLLVMIRTranslation.h"
+#include "mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/X86Vector/X86VectorToLLVMIRTranslation.h"
 
 namespace mlir {
@@ -45,6 +46,7 @@ static inline void 
registerAllToLLVMIRTranslations(DialectRegistry ®istry) {
   registerOpenACCDialectTranslation(registry);
   registerOpenMPDialectTranslation(registry);
   registerROCDLDialectTranslation(registry);
+  registerSPIRVDialectTranslation(registry);
   registerX86VectorDialectTranslation(registry);
 
   // Extension required for translating GPU offloading Ops.
@@ -61,6 +63,7 @@ registerAllGPUToLLVMIRTranslations(DialectRegistry ®istry) 
{
   registerLLVMDialectTranslation(registry);
   registerNVVMDialectTranslation(registry);
   registerROCDLDialectTranslation(registry);
+  registerSPIRVDialectTranslation(registry);
 
   // Extension required for translating GPU offloading Ops.
   gpu::registerOffloadingLLVMTranslationInterfaceExternalModels(registry);
diff --git 
a/mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h 
b/mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h
new file mode 100644
index 000..e9580a10b4ca780
--- /dev/null
+++ b/mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h
@@ -0,0 +1,31 @@
+//===- SPIRVToLLVMIRTranslation.h - SPIRV to LLVM IR *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This provides registration calls for SPIRV dialect to LLVM IR translation.
+//
+//===--===//
+
+#ifndef MLIR_TARGET_LLVMIR_DIALECT_SPIRV_SPIRVTOLLVMIRTRANSLATION_H
+#define MLIR_TARGET_LLVMIR_DIALECT_SPIRV_SPIRVTOLLVMIRTRANSLATION_H
+
+namespace mlir {
+
+class DialectRegistry;
+class MLIRContext;
+
+/// Register the SPIRV dialect and the translation from it to the LLVM IR in 
the
+/// given registry;
+void registerSPIRVDialectTranslation(DialectRegistry ®istry);
+
+/// Register the SPIRV dialect and the translation from it in the registry
+/// associated with the given context.
+void registerSPIRVDialectTranslation(MLIRContext &context);
+
+} // namespa

[Lldb-commits] [lld] [lldb] [openmp] [libcxx] [mlir] [compiler-rt] [flang] [llvm] [clang-tools-extra] [libc] [clang] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-28 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 updated 
https://github.com/llvm/llvm-project/pull/71430

>From c76403cf8629b8f7d8a5b7a3ee5da2881713a7f8 Mon Sep 17 00:00:00 2001
From: "Lee, Sang Ik" 
Date: Mon, 6 Nov 2023 18:47:23 +
Subject: [PATCH 1/5] [MLIR] Enable GPU Dialect to SYCL runtime integration

GPU Dialect lowering to SYCL runtime is driven by spirv.target_env
attached to gpu.module. As a result of this, spirv.target_env remains
as an input to LLVMIR Translation.
A SPIRVToLLVMIRTranslation without any actual translation is added to
avoid an unregistered error in mlir-cpu-runner.
SelectObjectAttr.cpp is updated to
1) Pass binary size argument to getModuleLoadFn
2) Pass parameter count to getKernelLaunchFn
This change does not impact CUDA and ROCM usage since both
mlir_cuda_runtime and mlir_rocm_runtime are already updated to
accept and ignore the extra arguments.
---
 mlir/include/mlir/Target/LLVMIR/Dialect/All.h |  3 ++
 .../Dialect/SPIRV/SPIRVToLLVMIRTranslation.h  | 31 +++
 mlir/lib/Target/LLVMIR/CMakeLists.txt |  1 +
 mlir/lib/Target/LLVMIR/Dialect/CMakeLists.txt |  1 +
 .../LLVMIR/Dialect/GPU/SelectObjectAttr.cpp   | 50 +
 .../LLVMIR/Dialect/SPIRV/CMakeLists.txt   | 13 +
 .../SPIRV/SPIRVToLLVMIRTranslation.cpp| 31 +++
 mlir/test/CMakeLists.txt  |  4 ++
 .../Integration/GPU/SYCL/gpu-to-spirv.mlir| 54 +++
 mlir/test/Integration/GPU/SYCL/lit.local.cfg  |  2 +
 mlir/test/Target/LLVMIR/gpu.mlir  |  9 ++--
 mlir/test/lit.cfg.py  |  3 ++
 mlir/test/lit.site.cfg.py.in  |  1 +
 13 files changed, 188 insertions(+), 15 deletions(-)
 create mode 100644 
mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h
 create mode 100644 mlir/lib/Target/LLVMIR/Dialect/SPIRV/CMakeLists.txt
 create mode 100644 
mlir/lib/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.cpp
 create mode 100644 mlir/test/Integration/GPU/SYCL/gpu-to-spirv.mlir
 create mode 100644 mlir/test/Integration/GPU/SYCL/lit.local.cfg

diff --git a/mlir/include/mlir/Target/LLVMIR/Dialect/All.h 
b/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
index 0563b9bf3d475a4..5dfc15afb75931a 100644
--- a/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
+++ b/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
@@ -26,6 +26,7 @@
 #include "mlir/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/ROCDL/ROCDLToLLVMIRTranslation.h"
+#include "mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/X86Vector/X86VectorToLLVMIRTranslation.h"
 
 namespace mlir {
@@ -45,6 +46,7 @@ static inline void 
registerAllToLLVMIRTranslations(DialectRegistry ®istry) {
   registerOpenACCDialectTranslation(registry);
   registerOpenMPDialectTranslation(registry);
   registerROCDLDialectTranslation(registry);
+  registerSPIRVDialectTranslation(registry);
   registerX86VectorDialectTranslation(registry);
 
   // Extension required for translating GPU offloading Ops.
@@ -61,6 +63,7 @@ registerAllGPUToLLVMIRTranslations(DialectRegistry ®istry) 
{
   registerLLVMDialectTranslation(registry);
   registerNVVMDialectTranslation(registry);
   registerROCDLDialectTranslation(registry);
+  registerSPIRVDialectTranslation(registry);
 
   // Extension required for translating GPU offloading Ops.
   gpu::registerOffloadingLLVMTranslationInterfaceExternalModels(registry);
diff --git 
a/mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h 
b/mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h
new file mode 100644
index 000..e9580a10b4ca780
--- /dev/null
+++ b/mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h
@@ -0,0 +1,31 @@
+//===- SPIRVToLLVMIRTranslation.h - SPIRV to LLVM IR *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This provides registration calls for SPIRV dialect to LLVM IR translation.
+//
+//===--===//
+
+#ifndef MLIR_TARGET_LLVMIR_DIALECT_SPIRV_SPIRVTOLLVMIRTRANSLATION_H
+#define MLIR_TARGET_LLVMIR_DIALECT_SPIRV_SPIRVTOLLVMIRTRANSLATION_H
+
+namespace mlir {
+
+class DialectRegistry;
+class MLIRContext;
+
+/// Register the SPIRV dialect and the translation from it to the LLVM IR in 
the
+/// given registry;
+void registerSPIRVDialectTranslation(DialectRegistry ®istry);
+
+/// Register the SPIRV dialect and the translation from it in the registry
+/// associated with the given context.
+void registerSPIRVDialectTranslation(MLIRContext &context);
+
+} // namespa

[Lldb-commits] [lld] [lldb] [openmp] [libcxx] [mlir] [compiler-rt] [flang] [llvm] [clang-tools-extra] [libc] [clang] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-28 Thread Sang Ik Lee via lldb-commits


@@ -0,0 +1,31 @@
+//===- SPIRVToLLVMIRTranslation.cpp - Translate SPIRV to LLVM IR 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements a translation between the MLIR SPIRV dialect and
+// LLVM IR.
+//
+//===--===//
+
+#include "mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/IR/BuiltinAttributes.h"
+#include "mlir/IR/Operation.h"
+#include "mlir/Target/LLVMIR/ModuleTranslation.h"
+
+using namespace mlir;
+using namespace mlir::LLVM;
+
+void mlir::registerSPIRVDialectTranslation(DialectRegistry ®istry) {
+  registry.insert();

silee2 wrote:

@joker-eph 

https://github.com/llvm/llvm-project/pull/71430
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [libcxx] [lld] [clang] [flang] [clang-tools-extra] [llvm] [libc] [compiler-rt] [mlir] [openmp] [lldb] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-12-05 Thread Sang Ik Lee via lldb-commits

silee2 wrote:

@fabianmcg Can you approve and merge? @joker-eph is not responding and this PR 
has been open for a long time.
It is blocking other future PRs that depend on this one.
If SPIR-V dialect registration needs to change that can be done in another PR.

https://github.com/llvm/llvm-project/pull/71430
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lld] [llvm] [lldb] [libc] [clang] [openmp] [clang-tools-extra] [flang] [compiler-rt] [libcxx] [mlir] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-12-05 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 updated 
https://github.com/llvm/llvm-project/pull/71430

>From c76403cf8629b8f7d8a5b7a3ee5da2881713a7f8 Mon Sep 17 00:00:00 2001
From: "Lee, Sang Ik" 
Date: Mon, 6 Nov 2023 18:47:23 +
Subject: [PATCH 1/6] [MLIR] Enable GPU Dialect to SYCL runtime integration

GPU Dialect lowering to SYCL runtime is driven by spirv.target_env
attached to gpu.module. As a result of this, spirv.target_env remains
as an input to LLVMIR Translation.
A SPIRVToLLVMIRTranslation without any actual translation is added to
avoid an unregistered error in mlir-cpu-runner.
SelectObjectAttr.cpp is updated to
1) Pass binary size argument to getModuleLoadFn
2) Pass parameter count to getKernelLaunchFn
This change does not impact CUDA and ROCM usage since both
mlir_cuda_runtime and mlir_rocm_runtime are already updated to
accept and ignore the extra arguments.
---
 mlir/include/mlir/Target/LLVMIR/Dialect/All.h |  3 ++
 .../Dialect/SPIRV/SPIRVToLLVMIRTranslation.h  | 31 +++
 mlir/lib/Target/LLVMIR/CMakeLists.txt |  1 +
 mlir/lib/Target/LLVMIR/Dialect/CMakeLists.txt |  1 +
 .../LLVMIR/Dialect/GPU/SelectObjectAttr.cpp   | 50 +
 .../LLVMIR/Dialect/SPIRV/CMakeLists.txt   | 13 +
 .../SPIRV/SPIRVToLLVMIRTranslation.cpp| 31 +++
 mlir/test/CMakeLists.txt  |  4 ++
 .../Integration/GPU/SYCL/gpu-to-spirv.mlir| 54 +++
 mlir/test/Integration/GPU/SYCL/lit.local.cfg  |  2 +
 mlir/test/Target/LLVMIR/gpu.mlir  |  9 ++--
 mlir/test/lit.cfg.py  |  3 ++
 mlir/test/lit.site.cfg.py.in  |  1 +
 13 files changed, 188 insertions(+), 15 deletions(-)
 create mode 100644 
mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h
 create mode 100644 mlir/lib/Target/LLVMIR/Dialect/SPIRV/CMakeLists.txt
 create mode 100644 
mlir/lib/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.cpp
 create mode 100644 mlir/test/Integration/GPU/SYCL/gpu-to-spirv.mlir
 create mode 100644 mlir/test/Integration/GPU/SYCL/lit.local.cfg

diff --git a/mlir/include/mlir/Target/LLVMIR/Dialect/All.h 
b/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
index 0563b9bf3d475..5dfc15afb7593 100644
--- a/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
+++ b/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
@@ -26,6 +26,7 @@
 #include "mlir/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/ROCDL/ROCDLToLLVMIRTranslation.h"
+#include "mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/X86Vector/X86VectorToLLVMIRTranslation.h"
 
 namespace mlir {
@@ -45,6 +46,7 @@ static inline void 
registerAllToLLVMIRTranslations(DialectRegistry ®istry) {
   registerOpenACCDialectTranslation(registry);
   registerOpenMPDialectTranslation(registry);
   registerROCDLDialectTranslation(registry);
+  registerSPIRVDialectTranslation(registry);
   registerX86VectorDialectTranslation(registry);
 
   // Extension required for translating GPU offloading Ops.
@@ -61,6 +63,7 @@ registerAllGPUToLLVMIRTranslations(DialectRegistry ®istry) 
{
   registerLLVMDialectTranslation(registry);
   registerNVVMDialectTranslation(registry);
   registerROCDLDialectTranslation(registry);
+  registerSPIRVDialectTranslation(registry);
 
   // Extension required for translating GPU offloading Ops.
   gpu::registerOffloadingLLVMTranslationInterfaceExternalModels(registry);
diff --git 
a/mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h 
b/mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h
new file mode 100644
index 0..e9580a10b4ca7
--- /dev/null
+++ b/mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h
@@ -0,0 +1,31 @@
+//===- SPIRVToLLVMIRTranslation.h - SPIRV to LLVM IR *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This provides registration calls for SPIRV dialect to LLVM IR translation.
+//
+//===--===//
+
+#ifndef MLIR_TARGET_LLVMIR_DIALECT_SPIRV_SPIRVTOLLVMIRTRANSLATION_H
+#define MLIR_TARGET_LLVMIR_DIALECT_SPIRV_SPIRVTOLLVMIRTRANSLATION_H
+
+namespace mlir {
+
+class DialectRegistry;
+class MLIRContext;
+
+/// Register the SPIRV dialect and the translation from it to the LLVM IR in 
the
+/// given registry;
+void registerSPIRVDialectTranslation(DialectRegistry ®istry);
+
+/// Register the SPIRV dialect and the translation from it in the registry
+/// associated with the given context.
+void registerSPIRVDialectTranslation(MLIRContext &context);
+
+} // namespace mlir

[Lldb-commits] [clang-tools-extra] [llvm] [lldb] [openmp] [lld] [libc] [flang] [mlir] [libcxx] [clang] [compiler-rt] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-12-05 Thread Sang Ik Lee via lldb-commits


@@ -61,6 +63,7 @@ registerAllGPUToLLVMIRTranslations(DialectRegistry ®istry) 
{
   registerLLVMDialectTranslation(registry);
   registerNVVMDialectTranslation(registry);
   registerROCDLDialectTranslation(registry);
+  registerSPIRVDialectTranslation(registry);

silee2 wrote:

@fabianmcg Added test.
Any other request? The PR has been open for a while and blocking other work 
that depends on it. Would be great if you can approve soon.

https://github.com/llvm/llvm-project/pull/71430
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [llvm] [libcxx] [flang] [clang] [lldb] [clang-tools-extra] [mlir] [lld] [openmp] [compiler-rt] [libc] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-12-15 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 closed https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [compiler-rt] [lldb] [libcxx] [llvm] [clang-tools-extra] [lld] [libc] [mlir] [openmp] [flang] [clang] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-12-15 Thread Sang Ik Lee via lldb-commits

silee2 wrote:

Closing as all sub-components has been merged.

https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 created 
https://github.com/llvm/llvm-project/pull/65539:

None

>From 863a72b4e099f4aa24e43fdaaeb2ab0e171a0381 Mon Sep 17 00:00:00 2001
From: "Lee, Sang Ik" 
Date: Wed, 30 Aug 2023 13:44:02 -0700
Subject: [PATCH 01/13] Add SyclRuntimeWrappers and Add CMake option
 MLIR_ENABLE_SYCL_RUNNER

---
 mlir/CMakeLists.txt   |   1 +
 mlir/cmake/modules/FindLevelZero.cmake| 221 ++
 mlir/cmake/modules/FindSyclRuntime.cmake  |  68 +++
 mlir/lib/ExecutionEngine/CMakeLists.txt   |  35 ++
 .../ExecutionEngine/SyclRuntimeWrappers.cpp   | 386 ++
 5 files changed, 711 insertions(+)
 create mode 100644 mlir/cmake/modules/FindLevelZero.cmake
 create mode 100644 mlir/cmake/modules/FindSyclRuntime.cmake
 create mode 100644 mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp

diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index fa4f6e76f985fb5..4a67e018273819f 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -116,6 +116,7 @@ 
add_definitions(-DMLIR_ROCM_CONVERSIONS_ENABLED=${MLIR_ENABLE_ROCM_CONVERSIONS})
 
 set(MLIR_ENABLE_CUDA_RUNNER 0 CACHE BOOL "Enable building the mlir CUDA 
runner")
 set(MLIR_ENABLE_ROCM_RUNNER 0 CACHE BOOL "Enable building the mlir ROCm 
runner")
+set(MLIR_ENABLE_SYCL_RUNNER 0 CACHE BOOL "Enable building the mlir Sycl 
runner")
 set(MLIR_ENABLE_SPIRV_CPU_RUNNER 0 CACHE BOOL "Enable building the mlir SPIR-V 
cpu runner")
 set(MLIR_ENABLE_VULKAN_RUNNER 0 CACHE BOOL "Enable building the mlir Vulkan 
runner")
 set(MLIR_ENABLE_NVPTXCOMPILER 0 CACHE BOOL
diff --git a/mlir/cmake/modules/FindLevelZero.cmake 
b/mlir/cmake/modules/FindLevelZero.cmake
new file mode 100644
index 000..012187f0afc0b07
--- /dev/null
+++ b/mlir/cmake/modules/FindLevelZero.cmake
@@ -0,0 +1,221 @@
+# CMake find_package() module for level-zero
+#
+# Example usage:
+#
+# find_package(LevelZero)
+#
+# If successful, the following variables will be defined:
+# LevelZero_FOUND
+# LevelZero_INCLUDE_DIRS
+# LevelZero_LIBRARY
+# LevelZero_LIBRARIES_DIR
+#
+# By default, the module searches the standard paths to locate the "ze_api.h"
+# and the ze_loader shared library. When using a custom level-zero 
installation,
+# the environment variable "LEVEL_ZERO_DIR" should be specified telling the
+# module to get the level-zero library and headers from that location.
+
+include(FindPackageHandleStandardArgs)
+
+# Search path priority
+# 1. CMake Variable LEVEL_ZERO_DIR
+# 2. Environment Variable LEVEL_ZERO_DIR
+
+if(NOT LEVEL_ZERO_DIR)
+if(DEFINED ENV{LEVEL_ZERO_DIR})
+set(LEVEL_ZERO_DIR "$ENV{LEVEL_ZERO_DIR}")
+endif()
+endif()
+
+if(LEVEL_ZERO_DIR)
+find_path(LevelZero_INCLUDE_DIR
+NAMES level_zero/ze_api.h
+PATHS ${LEVEL_ZERO_DIR}/include
+NO_DEFAULT_PATH
+)
+
+if(LINUX)
+find_library(LevelZero_LIBRARY
+NAMES ze_loader
+PATHS ${LEVEL_ZERO_DIR}/lib
+  ${LEVEL_ZERO_DIR}/lib/x86_64-linux-gnu
+NO_DEFAULT_PATH
+)
+else()
+find_library(LevelZero_LIBRARY
+NAMES ze_loader
+PATHS ${LEVEL_ZERO_DIR}/lib
+NO_DEFAULT_PATH
+)
+endif()
+else()
+find_path(LevelZero_INCLUDE_DIR
+NAMES level_zero/ze_api.h
+)
+
+find_library(LevelZero_LIBRARY
+NAMES ze_loader
+)
+endif()
+
+# Compares the two version string that are supposed to be in x.y.z format
+# and reports if the argument VERSION_STR1 is greater than or equal than
+# version_str2. The strings are compared lexicographically after conversion to
+# lists of equal lengths, with the shorter string getting zero-padded.
+function(compare_versions VERSION_STR1 VERSION_STR2 OUTPUT)
+# Convert the strings to list
+string(REPLACE  "." ";" VL1 ${VERSION_STR1})
+string(REPLACE  "." ";" VL2 ${VERSION_STR2})
+# get lengths of both lists
+list(LENGTH VL1 VL1_LEN)
+list(LENGTH VL2 VL2_LEN)
+set(LEN ${VL1_LEN})
+# If they differ in size pad the shorter list with 0s
+if(VL1_LEN GREATER VL2_LEN)
+math(EXPR DIFF "${VL1_LEN} - ${VL2_LEN}" OUTPUT_FORMAT DECIMAL)
+foreach(IDX RANGE 1 ${DIFF} 1)
+list(APPEND VL2 "0")
+endforeach()
+elseif(VL2_LEN GREATER VL2_LEN)
+math(EXPR DIFF "${VL1_LEN} - ${VL2_LEN}" OUTPUT_FORMAT DECIMAL)
+foreach(IDX RANGE 1 ${DIFF} 1)
+list(APPEND VL2 "0")
+endforeach()
+set(LEN ${VL2_LEN})
+endif()
+math(EXPR LEN_SUB_ONE "${LEN}-1")
+foreach(IDX RANGE 0 ${LEN_SUB_ONE} 1)
+list(GET VL1 ${IDX} VAL1)
+list(GET VL2 ${IDX} VAL2)
+
+if(${VAL1} GREATER ${VAL2})
+set(${OUTPUT} TRUE PARENT_SCOPE)
+break()
+elseif(${VAL1} LESS ${VAL2})
+set(${OUTPUT} FALSE PARENT_SCOPE)
+break()
+else()
+set(${OUTPUT} TRUE PARENT_SCOPE)
+endif()
+endforeach()
+
+endfuncti

[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 edited https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 edited https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 edited https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

silee2 wrote:

> I suggest to extract `mgpu` interface changes and `serializetoSpirv` pass to 
> 2 separate PRs.

Agree. And the changes are originally from different authors so should be 
splitted.

https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 edited https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 edited https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 edited https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 edited https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 edited https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 edited https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 edited https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 edited https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 edited https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 edited https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-14 Thread Sang Ik Lee via lldb-commits


@@ -71,7 +71,8 @@ void GPUToSPIRVPass::runOnOperation() {
   std::unique_ptr target =
   spirv::getMemorySpaceToStorageClassTarget(*context);
   spirv::MemorySpaceToStorageClassMap memorySpaceMap =
-  spirv::mapMemorySpaceToVulkanStorageClass;
+  this->useOpenCL ? spirv::mapMemorySpaceToOpenCLStorageClass :
+  spirv::mapMemorySpaceToVulkanStorageClass;

silee2 wrote:

Created #66445 which includes the code change and unit-test for covering.

https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [MLIR] Update convert-gpu-to-spirv pass to prepare using GPU compilat… (PR #69941)

2023-10-30 Thread Sang Ik Lee via lldb-commits


@@ -54,22 +55,52 @@ void GPUToSPIRVPass::runOnOperation() {
 
   SmallVector gpuModules;
   OpBuilder builder(context);
+
+  auto targetEnvSupportsKernelCapability = [](gpu::GPUModuleOp moduleOp) {
+Operation *gpuModule = moduleOp.getOperation();
+auto targetAttr = spirv::lookupTargetEnvOrDefault(gpuModule);
+spirv::TargetEnv targetEnv(targetAttr);
+return targetEnv.allows(spirv::Capability::Kernel);
+  };
+
   module.walk([&](gpu::GPUModuleOp moduleOp) {
 // Clone each GPU kernel module for conversion, given that the GPU
 // launch op still needs the original GPU kernel module.
-builder.setInsertionPoint(moduleOp.getOperation());
+// For Vulkan Shader capabilities, we insert the newly converted SPIR-V
+// module right after the original GPU module, as that's the expectation of
+// the in-tree Vulkan runner.
+// For OpenCL Kernel capabilities, we insert the newly converted SPIR-V
+// module inside the original GPU module, as that's the expectaion of the
+// normal GPU compilation pipeline.
+if (targetEnvSupportsKernelCapability(moduleOp)) {
+  builder.setInsertionPoint(moduleOp.getBody(),
+moduleOp.getBody()->begin());
+} else {
+  builder.setInsertionPoint(moduleOp.getOperation());
+}
 gpuModules.push_back(builder.clone(*moduleOp.getOperation()));
   });
 
   // Run conversion for each module independently as they can have different
   // TargetEnv attributes.
   for (Operation *gpuModule : gpuModules) {
+spirv::TargetEnvAttr targetAttr =
+spirv::lookupTargetEnvOrDefault(gpuModule);
+
 // Map MemRef memory space to SPIR-V storage class first if requested.
 if (mapMemorySpace) {
+  spirv::TargetEnv targetEnv(targetAttr);
+  FailureOr memoryModel =
+  spirv::getMemoryModel(targetEnv);
+  if (failed(memoryModel))
+return signalPassFailure();
+
   std::unique_ptr target =
   spirv::getMemorySpaceToStorageClassTarget(*context);
   spirv::MemorySpaceToStorageClassMap memorySpaceMap =
-  spirv::mapMemorySpaceToVulkanStorageClass;
+  (memoryModel == spirv::MemoryModel::OpenCL)

silee2 wrote:

Done.

https://github.com/llvm/llvm-project/pull/69941
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [MLIR] Update convert-gpu-to-spirv pass to prepare using GPU compilat… (PR #69941)

2023-10-30 Thread Sang Ik Lee via lldb-commits


@@ -108,6 +138,25 @@ void GPUToSPIRVPass::runOnOperation() {
 if (failed(applyFullConversion(gpuModule, *target, std::move(patterns
   return signalPassFailure();
   }
+
+  // For OpenCL, the gpu.func op in the original gpu.module op needs to be

silee2 wrote:

Keeping the original gpu.func causes legality check error later in the gpu 
compile pipeline. 
If target attr is set for a gpu.module, gpu-to-llvm pass doesn't lower 
gpu.launch_func 
Instead, it is replaced with another gpu.launch_func that has lowered argument 
types (llvm ptrs).
If a gpu.func remains as an input to gpu-to-llvm pass, there is an argument 
mismatch between the new gpu.launch_func and the gpu.func. And a error is fired.
The reason for putting a dummy func.func here is to work around that check.
For func types other than gpu.func, argument types are not checked against 
gpu.launch_func.
But a func.func is still need as there will be a symbol check.


https://github.com/llvm/llvm-project/pull/69941
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [MLIR] Update convert-gpu-to-spirv pass to prepare using GPU compilat… (PR #69941)

2023-10-30 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 edited https://github.com/llvm/llvm-project/pull/69941
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [clang-tools-extra] [llvm] [flang] [mlir] [lldb] [compiler-rt] [libcxx] [mlir] Prepare convert-gpu-to-spirv for OpenCL support (PR #69941)

2023-11-05 Thread Sang Ik Lee via lldb-commits

silee2 wrote:

@antiagainst @joker-eph Can someone merge this PR?

https://github.com/llvm/llvm-project/pull/69941
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [mlir] [lldb] [llvm] [clang] [flang] [libc] [compiler-rt] [libcxx] [clang-tools-extra] [lld] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-14 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 updated 
https://github.com/llvm/llvm-project/pull/71430

>From c76403cf8629b8f7d8a5b7a3ee5da2881713a7f8 Mon Sep 17 00:00:00 2001
From: "Lee, Sang Ik" 
Date: Mon, 6 Nov 2023 18:47:23 +
Subject: [PATCH 1/5] [MLIR] Enable GPU Dialect to SYCL runtime integration

GPU Dialect lowering to SYCL runtime is driven by spirv.target_env
attached to gpu.module. As a result of this, spirv.target_env remains
as an input to LLVMIR Translation.
A SPIRVToLLVMIRTranslation without any actual translation is added to
avoid an unregistered error in mlir-cpu-runner.
SelectObjectAttr.cpp is updated to
1) Pass binary size argument to getModuleLoadFn
2) Pass parameter count to getKernelLaunchFn
This change does not impact CUDA and ROCM usage since both
mlir_cuda_runtime and mlir_rocm_runtime are already updated to
accept and ignore the extra arguments.
---
 mlir/include/mlir/Target/LLVMIR/Dialect/All.h |  3 ++
 .../Dialect/SPIRV/SPIRVToLLVMIRTranslation.h  | 31 +++
 mlir/lib/Target/LLVMIR/CMakeLists.txt |  1 +
 mlir/lib/Target/LLVMIR/Dialect/CMakeLists.txt |  1 +
 .../LLVMIR/Dialect/GPU/SelectObjectAttr.cpp   | 50 +
 .../LLVMIR/Dialect/SPIRV/CMakeLists.txt   | 13 +
 .../SPIRV/SPIRVToLLVMIRTranslation.cpp| 31 +++
 mlir/test/CMakeLists.txt  |  4 ++
 .../Integration/GPU/SYCL/gpu-to-spirv.mlir| 54 +++
 mlir/test/Integration/GPU/SYCL/lit.local.cfg  |  2 +
 mlir/test/Target/LLVMIR/gpu.mlir  |  9 ++--
 mlir/test/lit.cfg.py  |  3 ++
 mlir/test/lit.site.cfg.py.in  |  1 +
 13 files changed, 188 insertions(+), 15 deletions(-)
 create mode 100644 
mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h
 create mode 100644 mlir/lib/Target/LLVMIR/Dialect/SPIRV/CMakeLists.txt
 create mode 100644 
mlir/lib/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.cpp
 create mode 100644 mlir/test/Integration/GPU/SYCL/gpu-to-spirv.mlir
 create mode 100644 mlir/test/Integration/GPU/SYCL/lit.local.cfg

diff --git a/mlir/include/mlir/Target/LLVMIR/Dialect/All.h 
b/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
index 0563b9bf3d475a4..5dfc15afb75931a 100644
--- a/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
+++ b/mlir/include/mlir/Target/LLVMIR/Dialect/All.h
@@ -26,6 +26,7 @@
 #include "mlir/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/ROCDL/ROCDLToLLVMIRTranslation.h"
+#include "mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Dialect/X86Vector/X86VectorToLLVMIRTranslation.h"
 
 namespace mlir {
@@ -45,6 +46,7 @@ static inline void 
registerAllToLLVMIRTranslations(DialectRegistry ®istry) {
   registerOpenACCDialectTranslation(registry);
   registerOpenMPDialectTranslation(registry);
   registerROCDLDialectTranslation(registry);
+  registerSPIRVDialectTranslation(registry);
   registerX86VectorDialectTranslation(registry);
 
   // Extension required for translating GPU offloading Ops.
@@ -61,6 +63,7 @@ registerAllGPUToLLVMIRTranslations(DialectRegistry ®istry) 
{
   registerLLVMDialectTranslation(registry);
   registerNVVMDialectTranslation(registry);
   registerROCDLDialectTranslation(registry);
+  registerSPIRVDialectTranslation(registry);
 
   // Extension required for translating GPU offloading Ops.
   gpu::registerOffloadingLLVMTranslationInterfaceExternalModels(registry);
diff --git 
a/mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h 
b/mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h
new file mode 100644
index 000..e9580a10b4ca780
--- /dev/null
+++ b/mlir/include/mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h
@@ -0,0 +1,31 @@
+//===- SPIRVToLLVMIRTranslation.h - SPIRV to LLVM IR *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This provides registration calls for SPIRV dialect to LLVM IR translation.
+//
+//===--===//
+
+#ifndef MLIR_TARGET_LLVMIR_DIALECT_SPIRV_SPIRVTOLLVMIRTRANSLATION_H
+#define MLIR_TARGET_LLVMIR_DIALECT_SPIRV_SPIRVTOLLVMIRTRANSLATION_H
+
+namespace mlir {
+
+class DialectRegistry;
+class MLIRContext;
+
+/// Register the SPIRV dialect and the translation from it to the LLVM IR in 
the
+/// given registry;
+void registerSPIRVDialectTranslation(DialectRegistry ®istry);
+
+/// Register the SPIRV dialect and the translation from it in the registry
+/// associated with the given context.
+void registerSPIRVDialectTranslation(MLIRContext &context);
+
+} // namespa

[Lldb-commits] [mlir] [compiler-rt] [flang] [clang] [clang-tools-extra] [lld] [libc] [libcxx] [llvm] [lldb] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-14 Thread Sang Ik Lee via lldb-commits


@@ -4,6 +4,7 @@
 module attributes {gpu.container_module} {
   // CHECK: [[ARGS_TY:%.*]] = type { i32, i32 }
   // CHECK: @kernel_module_bin_cst = internal constant [4 x i8] c"BLOB", align 
8
+  // CHECK:  @kernel_module_bin_size_cst = internal constant i64 4, align 8

silee2 wrote:

Done.

https://github.com/llvm/llvm-project/pull/71430
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [mlir] [compiler-rt] [flang] [clang] [clang-tools-extra] [lld] [libc] [libcxx] [llvm] [lldb] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-14 Thread Sang Ik Lee via lldb-commits


@@ -377,10 +379,17 @@ 
llvm::LaunchKernel::createKernelLaunch(mlir::gpu::LaunchFuncOp op,
   if (!binary)
 return op.emitError() << "Couldn't find the binary: " << binaryIdentifier;
 
+  auto binaryVar = dyn_cast(binary);
+  llvm::Constant *binaryInit = binaryVar->getInitializer();
+  auto binaryDataSeq = dyn_cast(binaryInit);

silee2 wrote:

Added pointer checks.

https://github.com/llvm/llvm-project/pull/71430
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [mlir] [lldb] [llvm] [clang] [flang] [libc] [compiler-rt] [libcxx] [clang-tools-extra] [lld] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-14 Thread Sang Ik Lee via lldb-commits


@@ -0,0 +1,56 @@
+// RUN: mlir-opt %s 
-pass-pipeline='builtin.module(spirv-attach-target{ver=v1.0 
caps=Addresses,Int64,Kernel},convert-gpu-to-spirv{use-64bit-index=true},gpu.module(spirv.module(spirv-lower-abi-attrs,spirv-update-vce)),func.func(llvm-request-c-wrappers),convert-scf-to-cf,convert-cf-to-llvm,convert-arith-to-llvm,convert-math-to-llvm,convert-func-to-llvm,gpu-to-llvm{use-bare-pointers-for-kernels=true},gpu-module-to-binary,expand-strided-metadata,lower-affine,finalize-memref-to-llvm,reconcile-unrealized-casts)'
 \
+// RUN: | mlir-cpu-runner \
+// RUN:   --shared-libs=%mlir_sycl_runtime \
+// RUN:   --shared-libs=%mlir_runner_utils \
+// RUN:   --entry-point-result=void \
+// RUN: | FileCheck %s
+
+module @add attributes {gpu.container_module} {
+  memref.global "private" constant @__constant_2x2x2xf32_0 : memref<2x2x2xf32> 
= dense<[[[1.1, 2.2], [3.3, 4.4]], [[5.5, 6.6], [7.7, 8.8 ]]]>
+  memref.global "private" constant @__constant_2x2x2xf32 : memref<2x2x2xf32> = 
dense<[[[1.2, 2.3], [4.5, 5.8]], [[7.2, 8.3], [10.5, 11.8]]]>
+  func.func @main() {
+%0 = memref.get_global @__constant_2x2x2xf32 : memref<2x2x2xf32>
+%1 = memref.get_global @__constant_2x2x2xf32_0 : memref<2x2x2xf32>
+%2 = call @test(%0, %1) : (memref<2x2x2xf32>, memref<2x2x2xf32>) -> 
memref<2x2x2xf32>
+%cast = memref.cast %2 : memref<2x2x2xf32> to memref<*xf32>
+call @printMemrefF32(%cast) : (memref<*xf32>) -> ()
+return
+  }
+  func.func private @printMemrefF32(memref<*xf32>)
+  func.func @test(%arg0: memref<2x2x2xf32>, %arg1: memref<2x2x2xf32>) -> 
memref<2x2x2xf32> {

silee2 wrote:

Done.

https://github.com/llvm/llvm-project/pull/71430
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [clang-tools-extra] [libcxx] [clang] [mlir] [compiler-rt] [lld] [libc] [flang] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-15 Thread Sang Ik Lee via lldb-commits


@@ -61,6 +63,7 @@ registerAllGPUToLLVMIRTranslations(DialectRegistry ®istry) 
{
   registerLLVMDialectTranslation(registry);
   registerNVVMDialectTranslation(registry);
   registerROCDLDialectTranslation(registry);
+  registerSPIRVDialectTranslation(registry);

silee2 wrote:

@joker-eph Any thoughts on library vs inlining the call?

https://github.com/llvm/llvm-project/pull/71430
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [clang] [mlir] [compiler-rt] [libc] [flang] [llvm] [lld] [libcxx] [clang-tools-extra] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-16 Thread Sang Ik Lee via lldb-commits

silee2 wrote:

@antiagainst @kuhar Any comments?

https://github.com/llvm/llvm-project/pull/71430
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [compiler-rt] [mlir] [clang-tools-extra] [flang] [clang] [libc] [llvm] [libcxx] [lldb] [lld] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-11-17 Thread Sang Ik Lee via lldb-commits


@@ -0,0 +1,31 @@
+//===- SPIRVToLLVMIRTranslation.cpp - Translate SPIRV to LLVM IR 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements a translation between the MLIR SPIRV dialect and
+// LLVM IR.
+//
+//===--===//
+
+#include "mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/IR/BuiltinAttributes.h"
+#include "mlir/IR/Operation.h"
+#include "mlir/Target/LLVMIR/ModuleTranslation.h"
+
+using namespace mlir;
+using namespace mlir::LLVM;
+
+void mlir::registerSPIRVDialectTranslation(DialectRegistry ®istry) {
+  registry.insert();

silee2 wrote:

There is no translation but dialect registration is still required as 
spirv.target_env is attached and appears in input.
Other option is to register SPIR-V dialect directly here: 
mlir/include/mlir/Target/LLVMIR/Dialect/All.h
@joker-eph Any thoughts? Or better option?





https://github.com/llvm/llvm-project/pull/71430
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits