Skip to content

Commit 2d359df

Browse files
authored
[SYCL][FPGA] Silence unknown attribut warnings on Host compilation (#5619)
The compiler emits "unknown attribute" warnings during host compilation for attributes: 1. [[intel::num_simd_work_items()]] 2. [[intel::kernel_args_restrict()]] 3. [[intel::use_stall_enable_clusters]] 4. [[intel::scheduler_target_fmax_mhz()]] 5. [[intel::max_work_group_size()]] 6. [[intel::max_global_work_dim()]] 7. [[intel::bank_bits()]] This patch marks the attributes in Attr.td with "SilentlyIgnoreSYCLIsHost", so the diagnostic is not being issued on the host at all. Signed-off-by: Soumi Manna <[email protected]>
1 parent 156f39b commit 2d359df

File tree

2 files changed

+45
-8
lines changed

2 files changed

+45
-8
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ def SYCLRequiresDecomposition : InheritableAttr {
13701370
def SYCLIntelKernelArgsRestrict : InheritableAttr {
13711371
let Spellings = [CXX11<"intel", "kernel_args_restrict">];
13721372
let Subjects = SubjectList<[Function], ErrorDiag>;
1373-
let LangOpts = [SYCLIsDevice, SYCLIsHost];
1373+
let LangOpts = [SYCLIsDevice, SilentlyIgnoreSYCLIsHost];
13741374
let Documentation = [SYCLIntelKernelArgsRestrictDocs];
13751375
let SimpleHandler = 1;
13761376
let SupportsNonconformingLambdaSyntax = 1;
@@ -1379,15 +1379,15 @@ def SYCLIntelKernelArgsRestrict : InheritableAttr {
13791379
def SYCLIntelNumSimdWorkItems : InheritableAttr {
13801380
let Spellings = [CXX11<"intel", "num_simd_work_items">];
13811381
let Args = [ExprArgument<"Value">];
1382-
let LangOpts = [SYCLIsDevice, SYCLIsHost];
1382+
let LangOpts = [SYCLIsDevice, SilentlyIgnoreSYCLIsHost];
13831383
let Subjects = SubjectList<[Function], ErrorDiag>;
13841384
let Documentation = [SYCLIntelNumSimdWorkItemsAttrDocs];
13851385
let SupportsNonconformingLambdaSyntax = 1;
13861386
}
13871387

13881388
def SYCLIntelUseStallEnableClusters : InheritableAttr {
13891389
let Spellings = [CXX11<"intel","use_stall_enable_clusters">];
1390-
let LangOpts = [SYCLIsHost, SYCLIsDevice];
1390+
let LangOpts = [SilentlyIgnoreSYCLIsHost, SYCLIsDevice];
13911391
let Subjects = SubjectList<[Function], ErrorDiag>;
13921392
let Documentation = [SYCLIntelUseStallEnableClustersAttrDocs];
13931393
let SupportsNonconformingLambdaSyntax = 1;
@@ -1396,7 +1396,7 @@ def SYCLIntelUseStallEnableClusters : InheritableAttr {
13961396
def SYCLIntelSchedulerTargetFmaxMhz : InheritableAttr {
13971397
let Spellings = [CXX11<"intel", "scheduler_target_fmax_mhz">];
13981398
let Args = [ExprArgument<"Value">];
1399-
let LangOpts = [SYCLIsDevice, SYCLIsHost];
1399+
let LangOpts = [SYCLIsDevice, SilentlyIgnoreSYCLIsHost];
14001400
let Subjects = SubjectList<[Function], ErrorDiag>;
14011401
let Documentation = [SYCLIntelSchedulerTargetFmaxMhzAttrDocs];
14021402
let SupportsNonconformingLambdaSyntax = 1;
@@ -1407,7 +1407,7 @@ def SYCLIntelMaxWorkGroupSize : InheritableAttr {
14071407
let Args = [ExprArgument<"XDim">,
14081408
ExprArgument<"YDim">,
14091409
ExprArgument<"ZDim">];
1410-
let LangOpts = [SYCLIsDevice, SYCLIsHost];
1410+
let LangOpts = [SYCLIsDevice, SilentlyIgnoreSYCLIsHost];
14111411
let Subjects = SubjectList<[Function], ErrorDiag>;
14121412
let AdditionalMembers = [{
14131413
Optional<llvm::APSInt> getXDimVal() const {
@@ -1433,7 +1433,7 @@ def SYCLIntelMaxWorkGroupSize : InheritableAttr {
14331433
def SYCLIntelMaxGlobalWorkDim : InheritableAttr {
14341434
let Spellings = [CXX11<"intel", "max_global_work_dim">];
14351435
let Args = [ExprArgument<"Value">];
1436-
let LangOpts = [SYCLIsDevice, SYCLIsHost];
1436+
let LangOpts = [SYCLIsDevice, SilentlyIgnoreSYCLIsHost];
14371437
let Subjects = SubjectList<[Function], ErrorDiag>;
14381438
let Documentation = [SYCLIntelMaxGlobalWorkDimAttrDocs];
14391439
let SupportsNonconformingLambdaSyntax = 1;
@@ -2269,7 +2269,7 @@ def IntelFPGABankBits : Attr {
22692269
let Args = [VariadicExprArgument<"Args">];
22702270
let Subjects = SubjectList<[IntelFPGAConstVar, IntelFPGALocalStaticAgentMemVar,
22712271
Field], ErrorDiag>;
2272-
let LangOpts = [SYCLIsDevice, SYCLIsHost];
2272+
let LangOpts = [SYCLIsDevice, SilentlyIgnoreSYCLIsHost];
22732273
let Documentation = [IntelFPGABankBitsDocs];
22742274
}
22752275
def : MutualExclusions<[IntelFPGARegister, IntelFPGABankBits]>;

clang/test/SemaSYCL/spurious-host-warning.cpp

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// RUN: %clang_cc1 -fsycl-is-host -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s -DSYCLHOST
22
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s
33

4+
// Test checks the attribute is silently ignored during host compilation
5+
// where -fsycl-is-host is passed on cc1.
6+
47
#ifdef SYCLHOST
58
// expected-no-diagnostics
69
#endif
@@ -56,5 +59,39 @@ void foo()
5659
// expected-warning@+2 {{'simple_dual_port' attribute ignored}}
5760
#endif
5861
[[intel::simple_dual_port]] unsigned int v_ten[64];
59-
}
6062

63+
#ifndef SYCLHOST
64+
// expected-warning@+2 {{'bank_bits' attribute ignored}}
65+
#endif
66+
[[intel::bank_bits(2, 3, 4, 5)]] unsigned int v_eleven[64];
67+
68+
#ifndef SYCLHOST
69+
// expected-warning@+2 {{'use_stall_enable_clusters' attribute ignored}}
70+
#endif
71+
[[intel::use_stall_enable_clusters]] void func();
72+
73+
#ifndef SYCLHOST
74+
// expected-warning@+2 {{'max_global_work_dim' attribute ignored}}
75+
#endif
76+
[[intel::max_global_work_dim(1)]] void func1();
77+
78+
#ifndef SYCLHOST
79+
// expected-warning@+2 {{'scheduler_target_fmax_mhz' attribute ignored}}
80+
#endif
81+
[[intel::scheduler_target_fmax_mhz(3)]] void func2();
82+
83+
#ifndef SYCLHOST
84+
// expected-warning@+2 {{'kernel_args_restrict' attribute ignored}}
85+
#endif
86+
[[intel::kernel_args_restrict]] void func3();
87+
88+
#ifndef SYCLHOST
89+
// expected-warning@+2 {{'num_simd_work_items' attribute ignored}}
90+
#endif
91+
[[intel::num_simd_work_items(12)]] void func4();
92+
93+
#ifndef SYCLHOST
94+
// expected-warning@+2 {{'max_work_group_size' attribute ignored}}
95+
#endif
96+
[[intel::max_work_group_size(32, 32, 32)]] void func5();
97+
}

0 commit comments

Comments
 (0)