Skip to content

Commit 9e47912

Browse files
author
Alessandro Fanfarillo
committed
Team patch applied
1 parent c112272 commit 9e47912

22 files changed

+487
-14
lines changed

gcc/fortran/array.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ gfc_match_array_ref (gfc_array_ref *ar, gfc_array_spec *as, int init,
158158
bool matched_bracket = false;
159159
gfc_expr *tmp;
160160
bool stat_just_seen = false;
161-
161+
bool team_just_seen = false;
162+
162163
memset (ar, '\0', sizeof (*ar));
163164

164165
ar->where = gfc_current_locus;
@@ -230,7 +231,21 @@ gfc_match_array_ref (gfc_array_ref *ar, gfc_array_spec *as, int init,
230231
if (m == MATCH_ERROR)
231232
return MATCH_ERROR;
232233

234+
team_just_seen = false;
233235
stat_just_seen = false;
236+
237+
if (gfc_match(" , team = %e",&tmp) == MATCH_YES && ar->stat == NULL)
238+
{
239+
ar->team = tmp;
240+
team_just_seen = true;
241+
}
242+
243+
if (ar->team && !team_just_seen)
244+
{
245+
gfc_error ("TEAM= attribute in %C misplaced");
246+
return MATCH_ERROR;
247+
}
248+
234249
if (gfc_match(" , stat = %e",&tmp) == MATCH_YES && ar->stat == NULL)
235250
{
236251
ar->stat = tmp;

gcc/fortran/check.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,20 @@ gfc_check_failed_or_stopped_images (gfc_expr *team, gfc_expr *kind)
12131213
return true;
12141214
}
12151215

1216+
bool
1217+
gfc_check_get_team (gfc_expr *level)
1218+
{
1219+
if (level)
1220+
{
1221+
gfc_error ("%qs argument of %qs intrinsic at %L not yet supported",
1222+
gfc_current_intrinsic_arg[0]->name, gfc_current_intrinsic,
1223+
&level->where);
1224+
return false;
1225+
}
1226+
1227+
return true;
1228+
}
1229+
12161230

12171231
bool
12181232
gfc_check_atomic_cas (gfc_expr *atom, gfc_expr *old, gfc_expr *compare,

gcc/fortran/dump-parse-tree.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,22 @@ show_code_node (int level, gfc_code *c)
18261826
fputs ("FAIL IMAGE ", dumpfile);
18271827
break;
18281828

1829+
case EXEC_CHANGE_TEAM:
1830+
fputs ("CHANGE TEAM", dumpfile);
1831+
break;
1832+
1833+
case EXEC_END_TEAM:
1834+
fputs ("END TEAM", dumpfile);
1835+
break;
1836+
1837+
case EXEC_FORM_TEAM:
1838+
fputs ("FORM TEAM", dumpfile);
1839+
break;
1840+
1841+
case EXEC_SYNC_TEAM:
1842+
fputs ("SYNC TEAM", dumpfile);
1843+
break;
1844+
18291845
case EXEC_SYNC_ALL:
18301846
fputs ("SYNC ALL ", dumpfile);
18311847
if (c->expr2 != NULL)

gcc/fortran/expr.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4850,6 +4850,24 @@ gfc_ref_this_image (gfc_ref *ref)
48504850
return true;
48514851
}
48524852

4853+
gfc_expr *
4854+
gfc_find_team_co(gfc_expr *e)
4855+
{
4856+
gfc_ref *ref;
4857+
4858+
for (ref = e->ref; ref; ref = ref->next)
4859+
if (ref->type == REF_ARRAY && ref->u.ar.codimen > 0)
4860+
return ref->u.ar.team;
4861+
4862+
if (e->value.function.actual->expr)
4863+
for (ref = e->value.function.actual->expr->ref; ref;
4864+
ref = ref->next)
4865+
if (ref->type == REF_ARRAY && ref->u.ar.codimen > 0)
4866+
return ref->u.ar.team;
4867+
4868+
return NULL;
4869+
}
4870+
48534871
gfc_expr *
48544872
gfc_find_stat_co(gfc_expr *e)
48554873
{

gcc/fortran/gfortran.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ enum gfc_statement
263263
ST_OMP_TASKLOOP_SIMD, ST_OMP_END_TASKLOOP_SIMD, ST_OMP_ORDERED_DEPEND,
264264
ST_PROCEDURE, ST_GENERIC, ST_CRITICAL, ST_END_CRITICAL,
265265
ST_GET_FCN_CHARACTERISTICS, ST_LOCK, ST_UNLOCK, ST_EVENT_POST,
266-
ST_EVENT_WAIT,ST_FAIL_IMAGE,ST_NONE
266+
ST_EVENT_WAIT, ST_FAIL_IMAGE, ST_FORM_TEAM, ST_CHANGE_TEAM,
267+
ST_END_TEAM, ST_SYNC_TEAM, ST_NONE
267268
};
268269

269270
/* Types of interfaces that we can have. Assignment interfaces are
@@ -456,6 +457,7 @@ enum gfc_isym_id
456457
GFC_ISYM_GETLOG,
457458
GFC_ISYM_GETPID,
458459
GFC_ISYM_GETUID,
460+
GFC_ISYM_GET_TEAM,
459461
GFC_ISYM_GMTIME,
460462
GFC_ISYM_HOSTNM,
461463
GFC_ISYM_HUGE,
@@ -1889,6 +1891,7 @@ typedef struct gfc_array_ref
18891891
int dimen; /* # of components in the reference */
18901892
int codimen;
18911893
bool in_allocate; /* For coarray checks. */
1894+
gfc_expr *team;
18921895
gfc_expr *stat;
18931896
locus where;
18941897
gfc_array_spec *as;
@@ -2461,6 +2464,7 @@ enum gfc_exec_op
24612464
EXEC_OPEN, EXEC_CLOSE, EXEC_WAIT,
24622465
EXEC_READ, EXEC_WRITE, EXEC_IOLENGTH, EXEC_TRANSFER, EXEC_DT_END,
24632466
EXEC_BACKSPACE, EXEC_ENDFILE, EXEC_INQUIRE, EXEC_REWIND, EXEC_FLUSH,
2467+
EXEC_FORM_TEAM, EXEC_CHANGE_TEAM, EXEC_END_TEAM, EXEC_SYNC_TEAM,
24642468
EXEC_LOCK, EXEC_UNLOCK, EXEC_EVENT_POST, EXEC_EVENT_WAIT, EXEC_FAIL_IMAGE,
24652469
EXEC_OACC_KERNELS_LOOP, EXEC_OACC_PARALLEL_LOOP, EXEC_OACC_ROUTINE,
24662470
EXEC_OACC_PARALLEL, EXEC_OACC_KERNELS, EXEC_OACC_DATA, EXEC_OACC_HOST_DATA,
@@ -3154,6 +3158,7 @@ bool gfc_is_coarray (gfc_expr *);
31543158
int gfc_get_corank (gfc_expr *);
31553159
bool gfc_has_ultimate_allocatable (gfc_expr *);
31563160
bool gfc_has_ultimate_pointer (gfc_expr *);
3161+
gfc_expr* gfc_find_team_co (gfc_expr *);
31573162
gfc_expr* gfc_find_stat_co (gfc_expr *);
31583163
gfc_expr* gfc_build_intrinsic_call (gfc_namespace *, gfc_isym_id, const char*,
31593164
locus, unsigned, ...);

gcc/fortran/intrinsic.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,6 +1938,13 @@ add_functions (void)
19381938

19391939
make_generic ("getpid", GFC_ISYM_GETPID, GFC_STD_GNU);
19401940

1941+
add_sym_1 ("get_team", GFC_ISYM_GET_TEAM, CLASS_TRANSFORMATIONAL,
1942+
ACTUAL_NO, BT_INTEGER, di, GFC_STD_F2008_TS,
1943+
gfc_check_get_team,
1944+
NULL,
1945+
gfc_resolve_get_team,
1946+
"level", BT_INTEGER, di, OPTIONAL);
1947+
19411948
add_sym_0 ("getuid", GFC_ISYM_GETUID, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
19421949
di, GFC_STD_GNU, NULL, NULL, gfc_resolve_getuid);
19431950

gcc/fortran/intrinsic.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ bool gfc_check_fn_r (gfc_expr *);
8383
bool gfc_check_fn_rc (gfc_expr *);
8484
bool gfc_check_fn_rc2008 (gfc_expr *);
8585
bool gfc_check_fnum (gfc_expr *);
86+
bool gfc_check_get_team (gfc_expr *);
8687
bool gfc_check_hostnm (gfc_expr *);
8788
bool gfc_check_huge (gfc_expr *);
8889
bool gfc_check_hypot (gfc_expr *, gfc_expr *);
@@ -299,6 +300,7 @@ gfc_expr *gfc_simplify_float (gfc_expr *);
299300
gfc_expr *gfc_simplify_floor (gfc_expr *, gfc_expr *);
300301
gfc_expr *gfc_simplify_fraction (gfc_expr *);
301302
gfc_expr *gfc_simplify_gamma (gfc_expr *);
303+
gfc_expr *gfc_simplify_get_team (gfc_expr *);
302304
gfc_expr *gfc_simplify_huge (gfc_expr *);
303305
gfc_expr *gfc_simplify_hypot (gfc_expr *, gfc_expr *);
304306
gfc_expr *gfc_simplify_iachar (gfc_expr *, gfc_expr *);
@@ -493,6 +495,7 @@ void gfc_resolve_gamma (gfc_expr *, gfc_expr *);
493495
void gfc_resolve_getcwd (gfc_expr *, gfc_expr *);
494496
void gfc_resolve_getgid (gfc_expr *);
495497
void gfc_resolve_getpid (gfc_expr *);
498+
void gfc_resolve_get_team (gfc_expr *, gfc_expr *);
496499
void gfc_resolve_getuid (gfc_expr *);
497500
void gfc_resolve_hostnm (gfc_expr *, gfc_expr *);
498501
void gfc_resolve_hypot (gfc_expr *, gfc_expr *, gfc_expr *);

gcc/fortran/iresolve.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2859,6 +2859,18 @@ gfc_resolve_image_status (gfc_expr *f, gfc_expr *image ATTRIBUTE_UNUSED,
28592859
f->value.function.name = image_status;
28602860
}
28612861

2862+
/* Resolve get_team (). */
2863+
2864+
void
2865+
gfc_resolve_get_team (gfc_expr *f, gfc_expr *level ATTRIBUTE_UNUSED)
2866+
{
2867+
static char get_team[] = "_gfortran_caf_get_team";
2868+
f->rank = 0;
2869+
f->ts.type = BT_INTEGER;
2870+
f->ts.kind = gfc_default_integer_kind;
2871+
f->value.function.name = get_team;
2872+
}
2873+
28622874

28632875
/* Resolve image_index (...). */
28642876

gcc/fortran/iso-fortran-env.def

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,12 @@ NAMED_DERIVED_TYPE (ISOFORTRAN_LOCK_TYPE, "lock_type", \
125125

126126
NAMED_DERIVED_TYPE (ISOFORTRAN_EVENT_TYPE, "event_type", \
127127
flag_coarray == GFC_FCOARRAY_LIB
128-
? get_int_kind_from_node (ptr_type_node)
128+
? get_int_kind_from_node (ptr_type_node)
129+
: gfc_default_integer_kind, GFC_STD_F2008_TS)
130+
131+
NAMED_DERIVED_TYPE (ISOFORTRAN_TEAM_TYPE, "team_type", \
132+
flag_coarray == GFC_FCOARRAY_LIB
133+
? get_int_kind_from_node (ptr_type_node)
129134
: gfc_default_integer_kind, GFC_STD_F2008_TS)
130135

131136
#undef NAMED_INTCST

gcc/fortran/match.c

Lines changed: 134 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1592,16 +1592,19 @@ gfc_match_if (gfc_statement *if_type)
15921592
match ("assign", gfc_match_assign, ST_LABEL_ASSIGNMENT)
15931593
match ("backspace", gfc_match_backspace, ST_BACKSPACE)
15941594
match ("call", gfc_match_call, ST_CALL)
1595+
match ("change team", gfc_match_change_team, ST_CHANGE_TEAM)
15951596
match ("close", gfc_match_close, ST_CLOSE)
15961597
match ("continue", gfc_match_continue, ST_CONTINUE)
15971598
match ("cycle", gfc_match_cycle, ST_CYCLE)
15981599
match ("deallocate", gfc_match_deallocate, ST_DEALLOCATE)
15991600
match ("end file", gfc_match_endfile, ST_END_FILE)
1601+
match ("end team", gfc_match_end_team, ST_END_TEAM)
16001602
match ("error stop", gfc_match_error_stop, ST_ERROR_STOP)
16011603
match ("event post", gfc_match_event_post, ST_EVENT_POST)
16021604
match ("event wait", gfc_match_event_wait, ST_EVENT_WAIT)
16031605
match ("exit", gfc_match_exit, ST_EXIT)
16041606
match ("fail image", gfc_match_fail_image, ST_FAIL_IMAGE)
1607+
match ("form team", gfc_match_form_team, ST_FORM_TEAM)
16051608
match ("flush", gfc_match_flush, ST_FLUSH)
16061609
match ("forall", match_simple_forall, ST_FORALL)
16071610
match ("go to", gfc_match_goto, ST_GOTO)
@@ -1617,6 +1620,7 @@ gfc_match_if (gfc_statement *if_type)
16171620
match ("rewind", gfc_match_rewind, ST_REWIND)
16181621
match ("stop", gfc_match_stop, ST_STOP)
16191622
match ("wait", gfc_match_wait, ST_WAIT)
1623+
match ("sync team", gfc_match_sync_team, ST_SYNC_TEAM)
16201624
match ("sync all", gfc_match_sync_all, ST_SYNC_CALL);
16211625
match ("sync images", gfc_match_sync_images, ST_SYNC_IMAGES);
16221626
match ("sync memory", gfc_match_sync_memory, ST_SYNC_MEMORY);
@@ -1656,7 +1660,6 @@ gfc_match_if (gfc_statement *if_type)
16561660
gfc_free_expr (expr);
16571661
return MATCH_ERROR;
16581662
}
1659-
16601663
/* At this point, we've matched the single IF and the action clause
16611664
is in new_st. Rearrange things so that the IF statement appears
16621665
in new_st. */
@@ -3287,6 +3290,136 @@ gfc_match_fail_image (void)
32873290
return MATCH_ERROR;
32883291
}
32893292

3293+
/* Match a FORM TEAM statement. */
3294+
3295+
match
3296+
gfc_match_form_team (void)
3297+
{
3298+
match m;
3299+
gfc_expr *teamid,*team;
3300+
3301+
if (!gfc_notify_std (GFC_STD_F2008_TS, "FORM TEAM statement at %C"))
3302+
return MATCH_ERROR;
3303+
3304+
if (gfc_match_char ('(') == MATCH_NO)
3305+
goto syntax;
3306+
3307+
new_st.op = EXEC_FORM_TEAM;
3308+
3309+
if (gfc_match ("%e", &teamid) != MATCH_YES)
3310+
goto syntax;
3311+
m = gfc_match_char (',');
3312+
if (m == MATCH_ERROR)
3313+
goto syntax;
3314+
if (gfc_match ("%e", &team) != MATCH_YES)
3315+
goto syntax;
3316+
3317+
m = gfc_match_char (')');
3318+
if (m == MATCH_NO)
3319+
goto syntax;
3320+
3321+
new_st.expr1 = teamid;
3322+
new_st.expr2 = team;
3323+
3324+
return MATCH_YES;
3325+
3326+
syntax:
3327+
gfc_syntax_error (ST_FORM_TEAM);
3328+
3329+
return MATCH_ERROR;
3330+
}
3331+
3332+
/* Match a CHANGE TEAM statement. */
3333+
3334+
match
3335+
gfc_match_change_team (void)
3336+
{
3337+
match m;
3338+
gfc_expr *team;
3339+
3340+
if (!gfc_notify_std (GFC_STD_F2008_TS, "CHANGE TEAM statement at %C"))
3341+
return MATCH_ERROR;
3342+
3343+
if (gfc_match_char ('(') == MATCH_NO)
3344+
goto syntax;
3345+
3346+
new_st.op = EXEC_CHANGE_TEAM;
3347+
3348+
/* if (gfc_match ("%e", &teamid) != MATCH_YES) */
3349+
/* goto syntax; */
3350+
/* m = gfc_match_char (','); */
3351+
/* if (m == MATCH_ERROR) */
3352+
/* goto syntax; */
3353+
if (gfc_match ("%e", &team) != MATCH_YES)
3354+
goto syntax;
3355+
3356+
m = gfc_match_char (')');
3357+
if (m == MATCH_NO)
3358+
goto syntax;
3359+
3360+
new_st.expr1 = team;
3361+
3362+
return MATCH_YES;
3363+
3364+
syntax:
3365+
gfc_syntax_error (ST_CHANGE_TEAM);
3366+
3367+
return MATCH_ERROR;
3368+
}
3369+
3370+
/* Match a END TEAM statement. */
3371+
3372+
match
3373+
gfc_match_end_team (void)
3374+
{
3375+
if (!gfc_notify_std (GFC_STD_F2008_TS, "END TEAM statement at %C"))
3376+
return MATCH_ERROR;
3377+
3378+
if (gfc_match_char ('(') == MATCH_YES)
3379+
goto syntax;
3380+
3381+
new_st.op = EXEC_END_TEAM;
3382+
3383+
return MATCH_YES;
3384+
3385+
syntax:
3386+
gfc_syntax_error (ST_END_TEAM);
3387+
3388+
return MATCH_ERROR;
3389+
}
3390+
3391+
/* Match a SYNC TEAM statement. */
3392+
3393+
match
3394+
gfc_match_sync_team (void)
3395+
{
3396+
match m;
3397+
gfc_expr *team;
3398+
3399+
if (!gfc_notify_std (GFC_STD_F2008_TS, "SYNC TEAM statement at %C"))
3400+
return MATCH_ERROR;
3401+
3402+
if (gfc_match_char ('(') == MATCH_NO)
3403+
goto syntax;
3404+
3405+
new_st.op = EXEC_SYNC_TEAM;
3406+
3407+
if (gfc_match ("%e", &team) != MATCH_YES)
3408+
goto syntax;
3409+
3410+
m = gfc_match_char (')');
3411+
if (m == MATCH_NO)
3412+
goto syntax;
3413+
3414+
new_st.expr1 = team;
3415+
3416+
return MATCH_YES;
3417+
3418+
syntax:
3419+
gfc_syntax_error (ST_SYNC_TEAM);
3420+
3421+
return MATCH_ERROR;
3422+
}
32903423

32913424
/* Match LOCK/UNLOCK statement. Syntax:
32923425
LOCK ( lock-variable [ , lock-stat-list ] )

0 commit comments

Comments
 (0)