{
/* First the clauses that are unique to some constructs. */
case OMP_CLAUSE_DEVICE:
+ case OMP_CLAUSE_DEVICE_TYPE:
case OMP_CLAUSE_DEFAULTMAP:
case OMP_CLAUSE_DEPEND:
case OMP_CLAUSE_DYN_GROUPPRIVATE:
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEFAULTMAP) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE_TYPE) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DYN_GROUPPRIVATE) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEFAULTMAP) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEVICE_TYPE) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DYN_GROUPPRIVATE) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR) \
fputs (" NOWAIT", dumpfile);
if (omp_clauses->collapse)
fprintf (dumpfile, " COLLAPSE(%d)", omp_clauses->collapse);
+ if (omp_clauses->device_type != OMP_DEVICE_TYPE_UNSET)
+ {
+ const char *s;
+ switch (omp_clauses->device_type)
+ {
+ case OMP_DEVICE_TYPE_HOST: s = "host"; break;
+ case OMP_DEVICE_TYPE_NOHOST: s = "nohost"; break;
+ case OMP_DEVICE_TYPE_ANY: s = "any"; break;
+ case OMP_DEVICE_TYPE_UNSET: gcc_unreachable ();
+ }
+ fputs (" DEVICE_TYPE(", dumpfile);
+ fputs (s, dumpfile);
+ fputc (')', dumpfile);
+ }
for (list_type = 0; list_type < OMP_LIST_NUM; list_type++)
if (omp_clauses->lists[list_type] != NULL)
{
OMP_MAP_DETACH, false,
allow_derived))
continue;
+ if ((mask & OMP_CLAUSE_DEVICEPTR)
+ && gfc_match ("deviceptr ( ") == MATCH_YES
+ && gfc_match_omp_map_clause (&c->lists[OMP_LIST_MAP],
+ OMP_MAP_FORCE_DEVICEPTR, false,
+ allow_derived))
+ continue;
+ if ((mask & OMP_CLAUSE_DEVICE_TYPE)
+ && gfc_match_dupl_check (c->device_type == OMP_DEVICE_TYPE_UNSET,
+ "device_type", true) == MATCH_YES)
+ {
+ if (gfc_match ("host") == MATCH_YES)
+ c->device_type = OMP_DEVICE_TYPE_HOST;
+ else if (gfc_match ("nohost") == MATCH_YES)
+ c->device_type = OMP_DEVICE_TYPE_NOHOST;
+ else if (gfc_match ("any") == MATCH_YES)
+ c->device_type = OMP_DEVICE_TYPE_ANY;
+ else
+ {
+ gfc_error ("Expected HOST, NOHOST or ANY at %C");
+ break;
+ }
+ if (gfc_match (" )") != MATCH_YES)
+ break;
+ continue;
+ }
+ if ((mask & OMP_CLAUSE_DEVICE_RESIDENT)
+ && gfc_match_omp_variable_list
+ ("device_resident (",
+ &c->lists[OMP_LIST_DEVICE_RESIDENT], true) == MATCH_YES)
+ continue;
+ if ((mask & OMP_CLAUSE_DEVICE)
+ && openacc
+ && gfc_match ("device ( ") == MATCH_YES
+ && gfc_match_omp_map_clause (&c->lists[OMP_LIST_MAP],
+ OMP_MAP_FORCE_TO, true,
+ /* allow_derived = */ true))
+ continue;
if ((mask & OMP_CLAUSE_DEVICE)
&& !openacc
&& ((m = gfc_match_dupl_check (!c->device, "device", true))
}
continue;
}
- if ((mask & OMP_CLAUSE_DEVICE)
- && openacc
- && gfc_match ("device ( ") == MATCH_YES
- && gfc_match_omp_map_clause (&c->lists[OMP_LIST_MAP],
- OMP_MAP_FORCE_TO, true,
- /* allow_derived = */ true))
- continue;
- if ((mask & OMP_CLAUSE_DEVICEPTR)
- && gfc_match ("deviceptr ( ") == MATCH_YES
- && gfc_match_omp_map_clause (&c->lists[OMP_LIST_MAP],
- OMP_MAP_FORCE_DEVICEPTR, false,
- allow_derived))
- continue;
- if ((mask & OMP_CLAUSE_DEVICE_TYPE)
- && gfc_match ("device_type ( ") == MATCH_YES)
- {
- if (gfc_match ("host") == MATCH_YES)
- c->device_type = OMP_DEVICE_TYPE_HOST;
- else if (gfc_match ("nohost") == MATCH_YES)
- c->device_type = OMP_DEVICE_TYPE_NOHOST;
- else if (gfc_match ("any") == MATCH_YES)
- c->device_type = OMP_DEVICE_TYPE_ANY;
- else
- {
- gfc_error ("Expected HOST, NOHOST or ANY at %C");
- break;
- }
- if (gfc_match (" )") != MATCH_YES)
- break;
- continue;
- }
- if ((mask & OMP_CLAUSE_DEVICE_RESIDENT)
- && gfc_match_omp_variable_list
- ("device_resident (",
- &c->lists[OMP_LIST_DEVICE_RESIDENT], true) == MATCH_YES)
- continue;
if ((mask & OMP_CLAUSE_DIST_SCHEDULE)
&& c->dist_sched_kind == OMP_SCHED_NONE
&& gfc_match ("dist_schedule ( static") == MATCH_YES)
| OMP_CLAUSE_IS_DEVICE_PTR | OMP_CLAUSE_IN_REDUCTION \
| OMP_CLAUSE_THREAD_LIMIT | OMP_CLAUSE_ALLOCATE \
| OMP_CLAUSE_HAS_DEVICE_ADDR | OMP_CLAUSE_USES_ALLOCATORS \
- | OMP_CLAUSE_DYN_GROUPPRIVATE)
+ | OMP_CLAUSE_DYN_GROUPPRIVATE | OMP_CLAUSE_DEVICE_TYPE)
#define OMP_TARGET_DATA_CLAUSES \
(omp_mask (OMP_CLAUSE_DEVICE) | OMP_CLAUSE_MAP | OMP_CLAUSE_IF \
| OMP_CLAUSE_USE_DEVICE_PTR | OMP_CLAUSE_USE_DEVICE_ADDR)
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
+ if (clauses->device_type != OMP_DEVICE_TYPE_UNSET)
+ {
+ enum omp_clause_device_type_kind type;
+ switch (clauses->device_type)
+ {
+ case OMP_DEVICE_TYPE_HOST:
+ type = OMP_CLAUSE_DEVICE_TYPE_HOST;
+ break;
+ case OMP_DEVICE_TYPE_NOHOST:
+ type = OMP_CLAUSE_DEVICE_TYPE_NOHOST;
+ break;
+ case OMP_DEVICE_TYPE_ANY:
+ type = OMP_CLAUSE_DEVICE_TYPE_ANY;
+ break;
+ case OMP_DEVICE_TYPE_UNSET:
+ gcc_unreachable ();
+ }
+ c = build_omp_clause (gfc_get_location (&where), OMP_CLAUSE_DEVICE_TYPE);
+ OMP_CLAUSE_DEVICE_TYPE_KIND (c) = type;
+ omp_clauses = gfc_trans_add_clause (c, omp_clauses);
+ }
+
if (clauses->dyn_groupprivate)
{
gfc_init_se (&se, NULL);
= code->ext.omp_clauses->if_expr;
clausesa[GFC_OMP_SPLIT_TARGET].nowait
= code->ext.omp_clauses->nowait;
+ clausesa[GFC_OMP_SPLIT_TARGET].device_type
+ = code->ext.omp_clauses->device_type;
}
if (mask & GFC_OMP_MASK_TEAMS)
{
case OMP_CLAUSE_INIT:
case OMP_CLAUSE_USE:
case OMP_CLAUSE_DESTROY:
+ case OMP_CLAUSE_DEVICE_TYPE:
break;
case OMP_CLAUSE_DYN_GROUPPRIVATE:
case OMP_CLAUSE_INCLUSIVE:
case OMP_CLAUSE_EXCLUSIVE:
case OMP_CLAUSE_USES_ALLOCATORS:
+ case OMP_CLAUSE_DEVICE_TYPE:
break;
case OMP_CLAUSE_NOHOST:
case OMP_CLAUSE_FINALIZE:
case OMP_CLAUSE_TASK_REDUCTION:
case OMP_CLAUSE_ALLOCATE:
+ case OMP_CLAUSE_DEVICE_TYPE:
break;
case OMP_CLAUSE_ALIGNED:
case OMP_CLAUSE_INIT:
case OMP_CLAUSE_USE:
case OMP_CLAUSE_DESTROY:
+ case OMP_CLAUSE_DEVICE_TYPE:
break;
case OMP_CLAUSE__CACHE_:
DECL_HAS_VALUE_EXPR_P (new_var) = 1;
}
break;
+ case OMP_CLAUSE_DEVICE_TYPE:
+ /* FIXME: Ensure that 'nohost' also has not implied before that
+ 'g->have_offload = true' or an implicit declare target. */
+ if (OMP_CLAUSE_DEVICE_TYPE_KIND (c) != OMP_CLAUSE_DEVICE_TYPE_ANY)
+ sorry_at (OMP_CLAUSE_LOCATION (c),
+ "only the %<device_type(any)%> is supported");
+ break;
}
if (offloaded)
--- /dev/null
+// { dg-do compile }
+// { dg-additional-options "-fdump-tree-gimple" }
+
+void f ()
+{
+
+#pragma omp target
+ ;
+
+#pragma omp target device_type ( any )
+ ;
+
+#pragma omp target device_type ( nohost ) // { dg-message "sorry, unimplemented: only the 'device_type\\(any\\)' is supported" }
+ ;
+
+#pragma omp target device_type ( host )
+ ;
+
+}
+
+// { dg-final { scan-tree-dump-times "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\)\[\\r\\n\]" 1 "gimple" } }
+// { dg-final { scan-tree-dump-times "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\) device_type\\(any\\)" 1 "gimple" } }
+// { dg-final { scan-tree-dump-times "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\) device_type\\(nohost\\)" 1 "gimple" } }
+// { dg-final { scan-tree-dump-times "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\) device_type\\(host\\)" 1 "gimple" } }
--- /dev/null
+! { dg-do compile }
+! { dg-additional-options "-fdump-tree-gimple" }
+
+!$omp target
+!$omp end target
+
+!$omp target device_type ( any )
+!$omp end target
+
+!$omp target device_type ( nohost ) ! { dg-message "sorry, unimplemented: only the 'device_type\\(any\\)' is supported" }
+!$omp end target
+
+!$omp target device_type ( host )
+!$omp end target
+
+end
+
+! { dg-final { scan-tree-dump-times "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\)\[\\r\\n\]" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\) device_type\\(any\\)" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\) device_type\\(nohost\\)" 1 "gimple" } }
+! { dg-final { scan-tree-dump-times "#pragma omp target num_teams\\(-2\\) thread_limit\\(0\\) device_type\\(host\\)" 1 "gimple" } }