Skip to content

Commit 18f7cae

Browse files
[ESIMD] Remove propagation of sycl_explicit_simd to the callees (#3152)
We don't need to mark the ESIMD CFG since all ESIMD-specific passes will work exclusively on the ESIMD code. So, in ESIMD passes we don't have to worry about breaking other SYCL code. Another important reason why we no longer need sycl_explicit_simd at every function in the call graph is that we decided that callgraph traversal and SYCL-ESIMD split will now be done in sycl-post-link rather than FE.
1 parent 1113d0a commit 18f7cae

File tree

5 files changed

+3
-43
lines changed

5 files changed

+3
-43
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12996,7 +12996,6 @@ class Sema final {
1299612996
void checkSYCLDeviceVarDecl(VarDecl *Var);
1299712997
void ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc, MangleContext &MC);
1299812998
void MarkDevice();
12999-
void MarkSyclSimd();
1300012999

1300113000
/// Emit a diagnostic about the given attribute having a deprecated name, and
1300213001
/// also emit a fixit hint to generate the new attribute name.

clang/lib/Sema/Sema.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,8 +1014,6 @@ void Sema::ActOnEndOfTranslationUnitFragment(TUFragmentKind Kind) {
10141014
SyclIntHeader->emit(getLangOpts().SYCLIntHeader);
10151015
MarkDevice();
10161016
}
1017-
if (getLangOpts().SYCLExplicitSIMD)
1018-
MarkSyclSimd();
10191017

10201018
emitDeferredDiags();
10211019

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -552,12 +552,6 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> {
552552
}
553553
}
554554

555-
// Propagate the explicit SIMD attribute through call graph - it is used
556-
// to distinguish ESIMD code in ESIMD LLVM passes.
557-
if (KernelBody && KernelBody->hasAttr<SYCLSimdAttr>() &&
558-
(KernelBody != FD) && !FD->hasAttr<SYCLSimdAttr>())
559-
FD->addAttr(SYCLSimdAttr::CreateImplicit(SemaRef.getASTContext()));
560-
561555
// Attribute "loop_fuse" can be applied explicitly on kernel function.
562556
// Attribute should not be propagated from device functions to kernel.
563557
if (auto *A = FD->getAttr<SYCLIntelLoopFuseAttr>()) {
@@ -3210,27 +3204,6 @@ void Sema::ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc,
32103204
Visitor.VisitRecordFields(KernelObj, kernel_decl, kernel_body, int_header);
32113205
}
32123206

3213-
// This function marks all the callees of explicit SIMD kernel
3214-
// with !sycl_explicit_simd. We want to have different semantics
3215-
// for functions that are called from SYCL and E-SIMD contexts.
3216-
// Later, functions marked with !sycl_explicit_simd will be cloned
3217-
// to maintain two different semantics.
3218-
void Sema::MarkSyclSimd() {
3219-
for (Decl *D : syclDeviceDecls())
3220-
if (auto SYCLKernel = dyn_cast<FunctionDecl>(D))
3221-
if (SYCLKernel->hasAttr<SYCLSimdAttr>()) {
3222-
MarkDeviceFunction Marker(*this);
3223-
Marker.SYCLCG.addToCallGraph(getASTContext().getTranslationUnitDecl());
3224-
llvm::SmallPtrSet<FunctionDecl *, 10> VisitedSet;
3225-
Marker.CollectKernelSet(SYCLKernel, SYCLKernel, VisitedSet);
3226-
for (const auto &elt : Marker.KernelSet) {
3227-
if (FunctionDecl *Def = elt->getDefinition())
3228-
if (!Def->hasAttr<SYCLSimdAttr>())
3229-
Def->addAttr(SYCLSimdAttr::CreateImplicit(getASTContext()));
3230-
}
3231-
}
3232-
}
3233-
32343207
void Sema::MarkDevice(void) {
32353208
// Create the call graph so we can detect recursion and check the validity
32363209
// of new operator overrides. Add the kernel function itself in case

clang/test/CodeGenSYCL/esimd_metadata2.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// RUN: %clang_cc1 -disable-llvm-passes -triple spir64-unknown-unknown-sycldevice -fsycl -fsycl-is-device -fsycl-explicit-simd -S -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-ESIMD
22

3-
// In ESIMD mode:
4-
// 1. Attribute !intel_reqd_sub_group_size !1 is added
5-
// for kernels with !sycl_explicit_simd
6-
// 2. Attribute !sycl_explicit_simd is propagated to all the
7-
// callees of ESIMD kernel.
3+
// This test checks that attribute !intel_reqd_sub_group_size !1
4+
// is added for kernels with !sycl_explicit_simd
85

96
__attribute__((sycl_device)) void shared_func_decl();
107
__attribute__((sycl_device)) void shared_func() { shared_func_decl(); }
@@ -13,7 +10,7 @@ __attribute__((sycl_device)) __attribute__((sycl_explicit_simd)) void esimd_func
1310

1411
// CHECK-ESIMD-DAG: define {{.*}}spir_kernel void @{{.*}}kernel_cm() #{{[0-9]+}} !sycl_explicit_simd !{{[0-9]+}} {{.*}} !intel_reqd_sub_group_size ![[SGSIZE1:[0-9]+]] {{.*}}{
1512
// CHECK-ESIMD-DAG: define {{.*}}spir_func void @{{.*}}esimd_funcv() #{{[0-9]+}} !sycl_explicit_simd !{{[0-9]+}} {
16-
// CHECK-ESIMD-DAG: define {{.*}}spir_func void @{{.*}}shared_funcv() #{{[0-9]+}} !sycl_explicit_simd !{{[0-9]+}} {
13+
// CHECK-ESIMD-DAG: define {{.*}}spir_func void @{{.*}}shared_funcv() #{{[0-9]+}} {
1714
// CHECK-ESIMD-DAG: define linkonce_odr spir_func void @_ZN12ESIMDFunctorclEv({{.*}}) #{{[0-9]+}} {{.*}} !sycl_explicit_simd !{{[0-9]+}} {
1815
// CHECK-ESIMD-DAG: declare spir_func void @{{.*}}shared_func_declv() #{{[0-9]+}}
1916

clang/test/CodeGenSYCL/esimd_metadata3.cpp

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)