Skip to content

Commit 2667845

Browse files
committed
[OpenACC] device_type on set should have only 1 architecture
Discussions with the OpenACC Standard folks and the dialect folks showed that the ability to have 'set' have a 'device_type' with more than one architecture was a mistake, and one that will be fixed in future revisions of the standard. Since the dialect requires this anyway, we'll implement this in advance of standardization.
1 parent 5de3118 commit 2667845

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

Diff for: clang/include/clang/Basic/DiagnosticSemaKinds.td

+3
Original file line numberDiff line numberDiff line change
@@ -13063,6 +13063,9 @@ def err_acc_invalid_modifier
1306313063
: Error<"OpenACC '%0' modifier not valid on '%1' clause">;
1306413064
def err_acc_invalid_default_type
1306513065
: Error<"invalid value %0 in '%1' clause; valid values are %2">;
13066+
def err_acc_device_type_multiple_archs
13067+
: Error<"OpenACC 'device_type' clause on a 'set' construct only permits "
13068+
"one architecture">;
1306613069

1306713070
// AMDGCN builtins diagnostics
1306813071
def err_amdgcn_load_lds_size_invalid_value : Error<"invalid size value">;

Diff for: clang/lib/Sema/SemaOpenACCClause.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,16 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitDeviceTypeClause(
13381338
checkAlreadyHasClauseOfKind(SemaRef, ExistingClauses, Clause))
13391339
return nullptr;
13401340

1341+
// Based on discussions, having more than 1 'architecture' on a 'set' is
1342+
// nonsensical, so we're going to fix the standard to reflect this. Implement
1343+
// the limitation, since the Dialect requires this.
1344+
if (Clause.getDirectiveKind() == OpenACCDirectiveKind::Set &&
1345+
Clause.getDeviceTypeArchitectures().size() > 1) {
1346+
SemaRef.Diag(Clause.getDeviceTypeArchitectures()[1].second,
1347+
diag::err_acc_device_type_multiple_archs);
1348+
return nullptr;
1349+
}
1350+
13411351
// The list of valid device_type values. Flang also has these hardcoded in
13421352
// openacc_parsers.cpp, as there does not seem to be a reliable backend
13431353
// source. The list below is sourced from Flang, though NVC++ supports only

Diff for: clang/test/SemaOpenACC/set-construct.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,12 @@ void uses() {
6666
// expected-error@+2{{'if' clause cannot appear more than once on a 'set' directive}}
6767
// expected-note@+1{{previous clause is here}}
6868
#pragma acc set device_type(acc_device_nvidia) if(true) if (true)
69+
70+
// expected-error@+2{{OpenACC 'device_type' clause on a 'set' construct only permits one architecture}}
71+
// expected-error@+1{{OpenACC 'set' construct must have at least one 'default_async', 'device_num', 'device_type' or 'if' clause}}
72+
#pragma acc set device_type(nvidia, radeon)
73+
74+
// expected-error@+2{{OpenACC 'device_type' clause on a 'set' construct only permits one architecture}}
75+
// expected-error@+1{{OpenACC 'set' construct must have at least one 'default_async', 'device_num', 'device_type' or 'if' clause}}
76+
#pragma acc set device_type(nonsense, nvidia, radeon)
6977
}

0 commit comments

Comments
 (0)