Skip to content

Merge sourceryinstitute/master into sourceryinstitute/teams #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion gcc/fortran/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ gfc_match_array_ref (gfc_array_ref *ar, gfc_array_spec *as, int init,
bool matched_bracket = false;
gfc_expr *tmp;
bool stat_just_seen = false;

bool team_just_seen = false;

memset (ar, '\0', sizeof (*ar));

ar->where = gfc_current_locus;
Expand Down Expand Up @@ -230,7 +231,21 @@ gfc_match_array_ref (gfc_array_ref *ar, gfc_array_spec *as, int init,
if (m == MATCH_ERROR)
return MATCH_ERROR;

team_just_seen = false;
stat_just_seen = false;

if (gfc_match(" , team = %e",&tmp) == MATCH_YES && ar->stat == NULL)
{
ar->team = tmp;
team_just_seen = true;
}

if (ar->team && !team_just_seen)
{
gfc_error ("TEAM= attribute in %C misplaced");
return MATCH_ERROR;
}

if (gfc_match(" , stat = %e",&tmp) == MATCH_YES && ar->stat == NULL)
{
ar->stat = tmp;
Expand Down
14 changes: 14 additions & 0 deletions gcc/fortran/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,20 @@ gfc_check_failed_or_stopped_images (gfc_expr *team, gfc_expr *kind)
return true;
}

bool
gfc_check_get_team (gfc_expr *level)
{
if (level)
{
gfc_error ("%qs argument of %qs intrinsic at %L not yet supported",
gfc_current_intrinsic_arg[0]->name, gfc_current_intrinsic,
&level->where);
return false;
}

return true;
}


bool
gfc_check_atomic_cas (gfc_expr *atom, gfc_expr *old, gfc_expr *compare,
Expand Down
16 changes: 16 additions & 0 deletions gcc/fortran/dump-parse-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,22 @@ show_code_node (int level, gfc_code *c)
fputs ("FAIL IMAGE ", dumpfile);
break;

case EXEC_CHANGE_TEAM:
fputs ("CHANGE TEAM", dumpfile);
break;

case EXEC_END_TEAM:
fputs ("END TEAM", dumpfile);
break;

case EXEC_FORM_TEAM:
fputs ("FORM TEAM", dumpfile);
break;

case EXEC_SYNC_TEAM:
fputs ("SYNC TEAM", dumpfile);
break;

case EXEC_SYNC_ALL:
fputs ("SYNC ALL ", dumpfile);
if (c->expr2 != NULL)
Expand Down
18 changes: 18 additions & 0 deletions gcc/fortran/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -4974,6 +4974,24 @@ gfc_ref_this_image (gfc_ref *ref)
return true;
}

gfc_expr *
gfc_find_team_co(gfc_expr *e)
{
gfc_ref *ref;

for (ref = e->ref; ref; ref = ref->next)
if (ref->type == REF_ARRAY && ref->u.ar.codimen > 0)
return ref->u.ar.team;

if (e->value.function.actual->expr)
for (ref = e->value.function.actual->expr->ref; ref;
ref = ref->next)
if (ref->type == REF_ARRAY && ref->u.ar.codimen > 0)
return ref->u.ar.team;

return NULL;
}

gfc_expr *
gfc_find_stat_co(gfc_expr *e)
{
Expand Down
7 changes: 6 additions & 1 deletion gcc/fortran/gfortran.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ enum gfc_statement
ST_OMP_TASKLOOP_SIMD, ST_OMP_END_TASKLOOP_SIMD, ST_OMP_ORDERED_DEPEND,
ST_PROCEDURE, ST_GENERIC, ST_CRITICAL, ST_END_CRITICAL,
ST_GET_FCN_CHARACTERISTICS, ST_LOCK, ST_UNLOCK, ST_EVENT_POST,
ST_EVENT_WAIT,ST_FAIL_IMAGE,ST_NONE
ST_EVENT_WAIT, ST_FAIL_IMAGE, ST_FORM_TEAM, ST_CHANGE_TEAM,
ST_END_TEAM, ST_SYNC_TEAM, ST_NONE
};

/* Types of interfaces that we can have. Assignment interfaces are
Expand Down Expand Up @@ -456,6 +457,7 @@ enum gfc_isym_id
GFC_ISYM_GETLOG,
GFC_ISYM_GETPID,
GFC_ISYM_GETUID,
GFC_ISYM_GET_TEAM,
GFC_ISYM_GMTIME,
GFC_ISYM_HOSTNM,
GFC_ISYM_HUGE,
Expand Down Expand Up @@ -1913,6 +1915,7 @@ typedef struct gfc_array_ref
int dimen; /* # of components in the reference */
int codimen;
bool in_allocate; /* For coarray checks. */
gfc_expr *team;
gfc_expr *stat;
locus where;
gfc_array_spec *as;
Expand Down Expand Up @@ -2488,6 +2491,7 @@ enum gfc_exec_op
EXEC_OPEN, EXEC_CLOSE, EXEC_WAIT,
EXEC_READ, EXEC_WRITE, EXEC_IOLENGTH, EXEC_TRANSFER, EXEC_DT_END,
EXEC_BACKSPACE, EXEC_ENDFILE, EXEC_INQUIRE, EXEC_REWIND, EXEC_FLUSH,
EXEC_FORM_TEAM, EXEC_CHANGE_TEAM, EXEC_END_TEAM, EXEC_SYNC_TEAM,
EXEC_LOCK, EXEC_UNLOCK, EXEC_EVENT_POST, EXEC_EVENT_WAIT, EXEC_FAIL_IMAGE,
EXEC_OACC_KERNELS_LOOP, EXEC_OACC_PARALLEL_LOOP, EXEC_OACC_ROUTINE,
EXEC_OACC_PARALLEL, EXEC_OACC_KERNELS, EXEC_OACC_DATA, EXEC_OACC_HOST_DATA,
Expand Down Expand Up @@ -3190,6 +3194,7 @@ bool gfc_is_coarray (gfc_expr *);
int gfc_get_corank (gfc_expr *);
bool gfc_has_ultimate_allocatable (gfc_expr *);
bool gfc_has_ultimate_pointer (gfc_expr *);
gfc_expr* gfc_find_team_co (gfc_expr *);
gfc_expr* gfc_find_stat_co (gfc_expr *);
gfc_expr* gfc_build_intrinsic_call (gfc_namespace *, gfc_isym_id, const char*,
locus, unsigned, ...);
Expand Down
7 changes: 7 additions & 0 deletions gcc/fortran/intrinsic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1938,6 +1938,13 @@ add_functions (void)

make_generic ("getpid", GFC_ISYM_GETPID, GFC_STD_GNU);

add_sym_1 ("get_team", GFC_ISYM_GET_TEAM, CLASS_TRANSFORMATIONAL,
ACTUAL_NO, BT_INTEGER, di, GFC_STD_F2008_TS,
gfc_check_get_team,
NULL,
gfc_resolve_get_team,
"level", BT_INTEGER, di, OPTIONAL);

add_sym_0 ("getuid", GFC_ISYM_GETUID, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
di, GFC_STD_GNU, NULL, NULL, gfc_resolve_getuid);

Expand Down
3 changes: 3 additions & 0 deletions gcc/fortran/intrinsic.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ bool gfc_check_fn_r (gfc_expr *);
bool gfc_check_fn_rc (gfc_expr *);
bool gfc_check_fn_rc2008 (gfc_expr *);
bool gfc_check_fnum (gfc_expr *);
bool gfc_check_get_team (gfc_expr *);
bool gfc_check_hostnm (gfc_expr *);
bool gfc_check_huge (gfc_expr *);
bool gfc_check_hypot (gfc_expr *, gfc_expr *);
Expand Down Expand Up @@ -299,6 +300,7 @@ gfc_expr *gfc_simplify_float (gfc_expr *);
gfc_expr *gfc_simplify_floor (gfc_expr *, gfc_expr *);
gfc_expr *gfc_simplify_fraction (gfc_expr *);
gfc_expr *gfc_simplify_gamma (gfc_expr *);
gfc_expr *gfc_simplify_get_team (gfc_expr *);
gfc_expr *gfc_simplify_huge (gfc_expr *);
gfc_expr *gfc_simplify_hypot (gfc_expr *, gfc_expr *);
gfc_expr *gfc_simplify_iachar (gfc_expr *, gfc_expr *);
Expand Down Expand Up @@ -493,6 +495,7 @@ void gfc_resolve_gamma (gfc_expr *, gfc_expr *);
void gfc_resolve_getcwd (gfc_expr *, gfc_expr *);
void gfc_resolve_getgid (gfc_expr *);
void gfc_resolve_getpid (gfc_expr *);
void gfc_resolve_get_team (gfc_expr *, gfc_expr *);
void gfc_resolve_getuid (gfc_expr *);
void gfc_resolve_hostnm (gfc_expr *, gfc_expr *);
void gfc_resolve_hypot (gfc_expr *, gfc_expr *, gfc_expr *);
Expand Down
12 changes: 12 additions & 0 deletions gcc/fortran/iresolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -2859,6 +2859,18 @@ gfc_resolve_image_status (gfc_expr *f, gfc_expr *image ATTRIBUTE_UNUSED,
f->value.function.name = image_status;
}

/* Resolve get_team (). */

void
gfc_resolve_get_team (gfc_expr *f, gfc_expr *level ATTRIBUTE_UNUSED)
{
static char get_team[] = "_gfortran_caf_get_team";
f->rank = 0;
f->ts.type = BT_INTEGER;
f->ts.kind = gfc_default_integer_kind;
f->value.function.name = get_team;
}


/* Resolve image_index (...). */

Expand Down
7 changes: 6 additions & 1 deletion gcc/fortran/iso-fortran-env.def
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ NAMED_DERIVED_TYPE (ISOFORTRAN_LOCK_TYPE, "lock_type", \

NAMED_DERIVED_TYPE (ISOFORTRAN_EVENT_TYPE, "event_type", \
flag_coarray == GFC_FCOARRAY_LIB
? get_int_kind_from_node (ptr_type_node)
? get_int_kind_from_node (ptr_type_node)
: gfc_default_integer_kind, GFC_STD_F2008_TS)

NAMED_DERIVED_TYPE (ISOFORTRAN_TEAM_TYPE, "team_type", \
flag_coarray == GFC_FCOARRAY_LIB
? get_int_kind_from_node (ptr_type_node)
: gfc_default_integer_kind, GFC_STD_F2008_TS)

#undef NAMED_INTCST
Expand Down
135 changes: 134 additions & 1 deletion gcc/fortran/match.c
Original file line number Diff line number Diff line change
Expand Up @@ -1595,16 +1595,19 @@ gfc_match_if (gfc_statement *if_type)
match ("assign", gfc_match_assign, ST_LABEL_ASSIGNMENT)
match ("backspace", gfc_match_backspace, ST_BACKSPACE)
match ("call", gfc_match_call, ST_CALL)
match ("change team", gfc_match_change_team, ST_CHANGE_TEAM)
match ("close", gfc_match_close, ST_CLOSE)
match ("continue", gfc_match_continue, ST_CONTINUE)
match ("cycle", gfc_match_cycle, ST_CYCLE)
match ("deallocate", gfc_match_deallocate, ST_DEALLOCATE)
match ("end file", gfc_match_endfile, ST_END_FILE)
match ("end team", gfc_match_end_team, ST_END_TEAM)
match ("error stop", gfc_match_error_stop, ST_ERROR_STOP)
match ("event post", gfc_match_event_post, ST_EVENT_POST)
match ("event wait", gfc_match_event_wait, ST_EVENT_WAIT)
match ("exit", gfc_match_exit, ST_EXIT)
match ("fail image", gfc_match_fail_image, ST_FAIL_IMAGE)
match ("form team", gfc_match_form_team, ST_FORM_TEAM)
match ("flush", gfc_match_flush, ST_FLUSH)
match ("forall", match_simple_forall, ST_FORALL)
match ("go to", gfc_match_goto, ST_GOTO)
Expand All @@ -1620,6 +1623,7 @@ gfc_match_if (gfc_statement *if_type)
match ("rewind", gfc_match_rewind, ST_REWIND)
match ("stop", gfc_match_stop, ST_STOP)
match ("wait", gfc_match_wait, ST_WAIT)
match ("sync team", gfc_match_sync_team, ST_SYNC_TEAM)
match ("sync all", gfc_match_sync_all, ST_SYNC_CALL);
match ("sync images", gfc_match_sync_images, ST_SYNC_IMAGES);
match ("sync memory", gfc_match_sync_memory, ST_SYNC_MEMORY);
Expand Down Expand Up @@ -1659,7 +1663,6 @@ gfc_match_if (gfc_statement *if_type)
gfc_free_expr (expr);
return MATCH_ERROR;
}

/* At this point, we've matched the single IF and the action clause
is in new_st. Rearrange things so that the IF statement appears
in new_st. */
Expand Down Expand Up @@ -3343,6 +3346,136 @@ gfc_match_fail_image (void)
return MATCH_ERROR;
}

/* Match a FORM TEAM statement. */

match
gfc_match_form_team (void)
{
match m;
gfc_expr *teamid,*team;

if (!gfc_notify_std (GFC_STD_F2008_TS, "FORM TEAM statement at %C"))
return MATCH_ERROR;

if (gfc_match_char ('(') == MATCH_NO)
goto syntax;

new_st.op = EXEC_FORM_TEAM;

if (gfc_match ("%e", &teamid) != MATCH_YES)
goto syntax;
m = gfc_match_char (',');
if (m == MATCH_ERROR)
goto syntax;
if (gfc_match ("%e", &team) != MATCH_YES)
goto syntax;

m = gfc_match_char (')');
if (m == MATCH_NO)
goto syntax;

new_st.expr1 = teamid;
new_st.expr2 = team;

return MATCH_YES;

syntax:
gfc_syntax_error (ST_FORM_TEAM);

return MATCH_ERROR;
}

/* Match a CHANGE TEAM statement. */

match
gfc_match_change_team (void)
{
match m;
gfc_expr *team;

if (!gfc_notify_std (GFC_STD_F2008_TS, "CHANGE TEAM statement at %C"))
return MATCH_ERROR;

if (gfc_match_char ('(') == MATCH_NO)
goto syntax;

new_st.op = EXEC_CHANGE_TEAM;

/* if (gfc_match ("%e", &teamid) != MATCH_YES) */
/* goto syntax; */
/* m = gfc_match_char (','); */
/* if (m == MATCH_ERROR) */
/* goto syntax; */
if (gfc_match ("%e", &team) != MATCH_YES)
goto syntax;

m = gfc_match_char (')');
if (m == MATCH_NO)
goto syntax;

new_st.expr1 = team;

return MATCH_YES;

syntax:
gfc_syntax_error (ST_CHANGE_TEAM);

return MATCH_ERROR;
}

/* Match a END TEAM statement. */

match
gfc_match_end_team (void)
{
if (!gfc_notify_std (GFC_STD_F2008_TS, "END TEAM statement at %C"))
return MATCH_ERROR;

if (gfc_match_char ('(') == MATCH_YES)
goto syntax;

new_st.op = EXEC_END_TEAM;

return MATCH_YES;

syntax:
gfc_syntax_error (ST_END_TEAM);

return MATCH_ERROR;
}

/* Match a SYNC TEAM statement. */

match
gfc_match_sync_team (void)
{
match m;
gfc_expr *team;

if (!gfc_notify_std (GFC_STD_F2008_TS, "SYNC TEAM statement at %C"))
return MATCH_ERROR;

if (gfc_match_char ('(') == MATCH_NO)
goto syntax;

new_st.op = EXEC_SYNC_TEAM;

if (gfc_match ("%e", &team) != MATCH_YES)
goto syntax;

m = gfc_match_char (')');
if (m == MATCH_NO)
goto syntax;

new_st.expr1 = team;

return MATCH_YES;

syntax:
gfc_syntax_error (ST_SYNC_TEAM);

return MATCH_ERROR;
}

/* Match LOCK/UNLOCK statement. Syntax:
LOCK ( lock-variable [ , lock-stat-list ] )
Expand Down
4 changes: 4 additions & 0 deletions gcc/fortran/match.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ match gfc_match_event_post (void);
match gfc_match_event_wait (void);
match gfc_match_critical (void);
match gfc_match_fail_image (void);
match gfc_match_change_team (void);
match gfc_match_end_team (void);
match gfc_match_form_team (void);
match gfc_match_sync_team (void);
match gfc_match_block (void);
match gfc_match_associate (void);
match gfc_match_do (void);
Expand Down
Loading