Skip to content

[sycl-post-link] Split SYCL and ESIMD kernels into separate modules #3044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions llvm/test/tools/sycl-post-link/ir-output-only.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
; RUN: sycl-post-link --ir-output-only -split=auto -S %s -o %t.ll
; RUN: FileCheck %s -input-file=%t.ll

; This test checks that the --ir-output-only option writes a LLVM IR
; file instead of a table. In comparison with other tests, this one
; checks that the option works OK with -split=auto.

target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spir64-unknown-linux-sycldevice"

declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()

define dso_local spir_kernel void @kernel1() #0 {
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

define dso_local spir_kernel void @kernel2() #0 {
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

attributes #0 = { "sycl-module-id"="a.cpp" }

!llvm.module.flags = !{!0}
!opencl.spir.version = !{!1}
!spirv.Source = !{!2}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 1, i32 2}
!2 = !{i32 0, i32 100000}

; CHECK: define dso_local spir_kernel void @kernel1()
; CHECK: define dso_local spir_kernel void @kernel2()
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
; RUN: sycl-post-link -split-esimd -S %s -o %t.table
; RUN: FileCheck %s -input-file=%t.table
; RUN: FileCheck %s -input-file=%t_0.ll --check-prefixes CHECK-SYCL-IR
; RUN: FileCheck %s -input-file=%t_esimd_0.ll --check-prefixes CHECK-ESIMD-IR

; This is basic test of splitting SYCL and ESIMD kernels into separate
; modules.

target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spir64-unknown-linux-sycldevice"

declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()

define dso_local spir_kernel void @ESIMD_kernel() #0 !sycl_explicit_simd !3{
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

define dso_local spir_kernel void @SYCL_kernel() #0 {
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

attributes #0 = { "sycl-module-id"="a.cpp" }

!llvm.module.flags = !{!0}
!opencl.spir.version = !{!1}
!spirv.Source = !{!2}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 1, i32 2}
!2 = !{i32 0, i32 100000}
!3 = !{}

; CHECK: [Code|Properties]
; CHECK: {{.*}}_0.ll|{{.*}}_0.prop
; CHECK: {{.*}}_esimd_0.ll|{{.*}}_esimd_0.prop

; CHECK-SYCL-IR-DAG: define dso_local spir_kernel void @SYCL_kernel()
; CHECK-SYCL-IR-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()

; CHECK-ESIMD-IR-DAG: define dso_local spir_kernel void @ESIMD_kernel()
; CHECK-ESIMD-IR-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
; RUN: sycl-post-link -split=source -S %s -o %t.table
; RUN: FileCheck %s -input-file=%t.table
; RUN: FileCheck %s -input-file=%t_0.ll --check-prefixes CHECK-IR-0
; RUN: FileCheck %s -input-file=%t_1.ll --check-prefixes CHECK-IR-1

; This test checks that if no '-split-esimd' provided, ther is no
; splitting of SYCL and ESIMD kernels into separate modules.
; However, the rest of the splitting still happens according to
; the '-split=' option.

target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spir64-unknown-linux-sycldevice"

declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()

define dso_local spir_kernel void @ESIMD_kernel() #0 !sycl_explicit_simd !3{
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

define dso_local spir_kernel void @SYCL_kernel1() #0 {
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

define dso_local spir_kernel void @SYCL_kernel2() #1 {
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

attributes #0 = { "sycl-module-id"="a.cpp" }
attributes #1 = { "sycl-module-id"="b.cpp" }

!llvm.module.flags = !{!0}
!opencl.spir.version = !{!1}
!spirv.Source = !{!2}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 1, i32 2}
!2 = !{i32 0, i32 100000}
!3 = !{}

; CHECK: [Code|Properties]
; CHECK: {{.*}}_0.ll|{{.*}}_0.prop
; CHECK: {{.*}}_1.ll|{{.*}}_1.prop

; CHECK-IR-0-DAG: define dso_local spir_kernel void @SYCL_kernel1()
; CHECK-IR-0-DAG: define dso_local spir_kernel void @ESIMD_kernel()
; CHECK-IR-0-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()

; CHECK-IR-1-DAG: define dso_local spir_kernel void @SYCL_kernel2()
; CHECK-IR-1-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
; RUN: sycl-post-link -split-esimd -split=kernel -S %s -o %t.table
; RUN: FileCheck %s -input-file=%t.table
; RUN: FileCheck %s -input-file=%t_0.ll --check-prefixes CHECK-SYCL-IR-0
; RUN: FileCheck %s -input-file=%t_1.ll --check-prefixes CHECK-SYCL-IR-1
; RUN: FileCheck %s -input-file=%t_esimd_0.ll --check-prefixes CHECK-ESIMD-IR-0
; RUN: FileCheck %s -input-file=%t_esimd_1.ll --check-prefixes CHECK-ESIMD-IR-1

; This test checks that after we split SYCL and ESIMD kernels into
; separate modules, we split those two modules further according to
; -split option. In this case we have 2 SYCL and 2 ESIMD kernels, which
; are split into a total of 4 separate modules.

target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spir64-unknown-linux-sycldevice"

declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()

define dso_local spir_kernel void @ESIMD_kernel1() #0 !sycl_explicit_simd !3{
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

define dso_local spir_kernel void @ESIMD_kernel2() #0 !sycl_explicit_simd !3{
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

define dso_local spir_kernel void @SYCL_kernel1() #1 {
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

define dso_local spir_kernel void @SYCL_kernel2() #1 {
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

attributes #0 = { "sycl-module-id"="a.cpp" }
attributes #1 = { "sycl-module-id"="a.cpp" }

!llvm.module.flags = !{!0}
!opencl.spir.version = !{!1}
!spirv.Source = !{!2}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 1, i32 2}
!2 = !{i32 0, i32 100000}
!3 = !{}

; CHECK: [Code|Properties]
; CHECK: {{.*}}_0.ll|{{.*}}_0.prop
; CHECK: {{.*}}_1.ll|{{.*}}_1.prop
; CHECK: {{.*}}_esimd_0.ll|{{.*}}_esimd_0.prop
; CHECK: {{.*}}_esimd_1.ll|{{.*}}_esimd_1.prop

; CHECK-SYCL-IR-0-DAG: define dso_local spir_kernel void @SYCL_kernel1()
; CHECK-SYCL-IR-0-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()

; CHECK-SYCL-IR-1-DAG: define dso_local spir_kernel void @SYCL_kernel2()
; CHECK-SYCL-IR-1-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()

; CHECK-ESIMD-IR-0-DAG: define dso_local spir_kernel void @ESIMD_kernel1()
; CHECK-ESIMD-IR-0-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()

; CHECK-ESIMD-IR-1-DAG: define dso_local spir_kernel void @ESIMD_kernel2()
; CHECK-ESIMD-IR-1-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
; RUN: sycl-post-link -split-esimd -split=source -S %s -o %t.table
; RUN: FileCheck %s -input-file=%t.table
; RUN: FileCheck %s -input-file=%t_0.ll --check-prefixes CHECK-SYCL-IR-0
; RUN: FileCheck %s -input-file=%t_1.ll --check-prefixes CHECK-SYCL-IR-1
; RUN: FileCheck %s -input-file=%t_esimd_0.ll --check-prefixes CHECK-ESIMD-IR-0
; RUN: FileCheck %s -input-file=%t_esimd_1.ll --check-prefixes CHECK-ESIMD-IR-1

; This test checks that after we split SYCL and ESIMD kernels into
; separate modules, we split those two modules further according to
; -split option. In this case we have:
; - 3 SYCL kernels: 2 in a.cpp, 1 in b.cpp
; - 3 ESIMD kernels: 2 in a.cpp, 1 in b.cpp
; The module will be split into a total of 4 separate modules.

target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spir64-unknown-linux-sycldevice"

declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()

define dso_local spir_kernel void @ESIMD_kernel1() #0 !sycl_explicit_simd !3{
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

define dso_local spir_kernel void @ESIMD_kernel2() #0 !sycl_explicit_simd !3{
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

define dso_local spir_kernel void @ESIMD_kernel3() #1 !sycl_explicit_simd !3{
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

define dso_local spir_kernel void @SYCL_kernel1() #0 {
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

define dso_local spir_kernel void @SYCL_kernel2() #0 {
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

define dso_local spir_kernel void @SYCL_kernel3() #1 {
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

attributes #0 = { "sycl-module-id"="a.cpp" }
attributes #1 = { "sycl-module-id"="b.cpp" }

!llvm.module.flags = !{!0}
!opencl.spir.version = !{!1}
!spirv.Source = !{!2}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 1, i32 2}
!2 = !{i32 0, i32 100000}
!3 = !{}

; CHECK: [Code|Properties]
; CHECK: {{.*}}_0.ll|{{.*}}_0.prop
; CHECK: {{.*}}_1.ll|{{.*}}_1.prop
; CHECK: {{.*}}_esimd_0.ll|{{.*}}_esimd_0.prop
; CHECK: {{.*}}_esimd_1.ll|{{.*}}_esimd_1.prop

; CHECK-SYCL-IR-0-DAG: define dso_local spir_kernel void @SYCL_kernel1()
; CHECK-SYCL-IR-0-DAG: define dso_local spir_kernel void @SYCL_kernel2()
; CHECK-SYCL-IR-0-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()

; CHECK-SYCL-IR-1-DAG: define dso_local spir_kernel void @SYCL_kernel3()
; CHECK-SYCL-IR-1-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()

; CHECK-ESIMD-IR-0-DAG: define dso_local spir_kernel void @ESIMD_kernel1()
; CHECK-ESIMD-IR-0-DAG: define dso_local spir_kernel void @ESIMD_kernel2()
; CHECK-ESIMD-IR-0-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()

; CHECK-ESIMD-IR-1-DAG: define dso_local spir_kernel void @ESIMD_kernel3()
; CHECK-ESIMD-IR-1-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
; RUN: sycl-post-link -split-esimd -symbols -S %s -o %t.table
; RUN: FileCheck %s -input-file=%t.table
; RUN: FileCheck %s -input-file=%t_0.sym --check-prefixes CHECK-SYCL-SYM
; RUN: FileCheck %s -input-file=%t_esimd_0.sym --check-prefixes CHECK-ESIMD-SYM

; This test checks symbols generation when we split SYCL and ESIMD kernels into
; separate modules.

target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spir64-unknown-linux-sycldevice"

declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()

define dso_local spir_kernel void @ESIMD_kernel1() #0 !sycl_explicit_simd !3{
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

define dso_local spir_kernel void @ESIMD_kernel2() #0 !sycl_explicit_simd !3{
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

define dso_local spir_kernel void @SYCL_kernel1() #0 {
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

define dso_local spir_kernel void @SYCL_kernel2() #0 {
entry:
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
ret void
}

attributes #0 = { "sycl-module-id"="a.cpp" }
attributes #1 = { "sycl-module-id"="b.cpp" }

!llvm.module.flags = !{!0}
!opencl.spir.version = !{!1}
!spirv.Source = !{!2}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 1, i32 2}
!2 = !{i32 0, i32 100000}
!3 = !{}

; CHECK: [Code|Properties|Symbols]
; CHECK: {{.*}}_0.ll|{{.*}}_0.prop|{{.*}}_0.sym
; CHECK: {{.*}}_esimd_0.ll|{{.*}}_esimd_0.prop|{{.*}}_esimd_0.sym

; CHECK-SYCL-SYM: SYCL_kernel1
; CHECK-SYCL-SYM: SYCL_kernel2

; CHECK-ESIMD-SYM: ESIMD_kernel1
; CHECK-ESIMD-SYM: ESIMD_kernel2
Loading