Skip to content

Commit 96ce792

Browse files
authored
Merge branch 'teams' into master
2 parents afff591 + 83ff993 commit 96ce792

File tree

7 files changed

+272
-6
lines changed

7 files changed

+272
-6
lines changed

gcc/fortran/array.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,20 @@ gfc_match_array_ref (gfc_array_ref *ar, gfc_array_spec *as, int init,
231231
return MATCH_ERROR;
232232

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

gcc/fortran/expr.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5006,7 +5006,25 @@ gfc_ref_this_image (gfc_ref *ref)
50065006
}
50075007

50085008
gfc_expr *
5009-
gfc_find_stat_co(gfc_expr *e)
5009+
gfc_find_team_co (gfc_expr *e)
5010+
{
5011+
gfc_ref *ref;
5012+
5013+
for (ref = e->ref; ref; ref = ref->next)
5014+
if (ref->type == REF_ARRAY && ref->u.ar.codimen > 0)
5015+
return ref->u.ar.team;
5016+
5017+
if (e->value.function.actual->expr)
5018+
for (ref = e->value.function.actual->expr->ref; ref;
5019+
ref = ref->next)
5020+
if (ref->type == REF_ARRAY && ref->u.ar.codimen > 0)
5021+
return ref->u.ar.team;
5022+
5023+
return NULL;
5024+
}
5025+
5026+
gfc_expr *
5027+
gfc_find_stat_co (gfc_expr *e)
50105028
{
50115029
gfc_ref *ref;
50125030

gcc/fortran/intrinsic.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,11 @@ add_functions (void)
19401940

19411941
make_generic ("getpid", GFC_ISYM_GETPID, GFC_STD_GNU);
19421942

1943+
add_sym_1 ("get_team", GFC_ISYM_GET_TEAM, CLASS_TRANSFORMATIONAL,
1944+
ACTUAL_NO, BT_INTEGER, di, GFC_STD_F2008_TS,
1945+
gfc_check_get_team, NULL, gfc_resolve_get_team,
1946+
"level", BT_INTEGER, di, OPTIONAL);
1947+
19431948
add_sym_0 ("getuid", GFC_ISYM_GETUID, CLASS_IMPURE, ACTUAL_NO, BT_INTEGER,
19441949
di, GFC_STD_GNU, NULL, NULL, gfc_resolve_getuid);
19451950

gcc/fortran/match.c

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3343,6 +3343,131 @@ gfc_match_fail_image (void)
33433343
return MATCH_ERROR;
33443344
}
33453345

3346+
/* Match a FORM TEAM statement. */
3347+
3348+
match
3349+
gfc_match_form_team (void)
3350+
{
3351+
match m;
3352+
gfc_expr *teamid,*team;
3353+
3354+
if (!gfc_notify_std (GFC_STD_F2008_TS, "FORM TEAM statement at %C"))
3355+
return MATCH_ERROR;
3356+
3357+
if (gfc_match_char ('(') == MATCH_NO)
3358+
goto syntax;
3359+
3360+
new_st.op = EXEC_FORM_TEAM;
3361+
3362+
if (gfc_match ("%e", &teamid) != MATCH_YES)
3363+
goto syntax;
3364+
m = gfc_match_char (',');
3365+
if (m == MATCH_ERROR)
3366+
goto syntax;
3367+
if (gfc_match ("%e", &team) != MATCH_YES)
3368+
goto syntax;
3369+
3370+
m = gfc_match_char (')');
3371+
if (m == MATCH_NO)
3372+
goto syntax;
3373+
3374+
new_st.expr1 = teamid;
3375+
new_st.expr2 = team;
3376+
3377+
return MATCH_YES;
3378+
3379+
syntax:
3380+
gfc_syntax_error (ST_FORM_TEAM);
3381+
3382+
return MATCH_ERROR;
3383+
}
3384+
3385+
/* Match a CHANGE TEAM statement. */
3386+
3387+
match
3388+
gfc_match_change_team (void)
3389+
{
3390+
match m;
3391+
gfc_expr *team;
3392+
3393+
if (!gfc_notify_std (GFC_STD_F2008_TS, "CHANGE TEAM statement at %C"))
3394+
return MATCH_ERROR;
3395+
3396+
if (gfc_match_char ('(') == MATCH_NO)
3397+
goto syntax;
3398+
3399+
new_st.op = EXEC_CHANGE_TEAM;
3400+
3401+
if (gfc_match ("%e", &team) != MATCH_YES)
3402+
goto syntax;
3403+
3404+
m = gfc_match_char (')');
3405+
if (m == MATCH_NO)
3406+
goto syntax;
3407+
3408+
new_st.expr1 = team;
3409+
3410+
return MATCH_YES;
3411+
3412+
syntax:
3413+
gfc_syntax_error (ST_CHANGE_TEAM);
3414+
3415+
return MATCH_ERROR;
3416+
}
3417+
3418+
/* Match a END TEAM statement. */
3419+
3420+
match
3421+
gfc_match_end_team (void)
3422+
{
3423+
if (!gfc_notify_std (GFC_STD_F2008_TS, "END TEAM statement at %C"))
3424+
return MATCH_ERROR;
3425+
3426+
if (gfc_match_char ('(') == MATCH_YES)
3427+
goto syntax;
3428+
3429+
new_st.op = EXEC_END_TEAM;
3430+
3431+
return MATCH_YES;
3432+
3433+
syntax:
3434+
gfc_syntax_error (ST_END_TEAM);
3435+
3436+
return MATCH_ERROR;
3437+
}
3438+
3439+
/* Match a SYNC TEAM statement. */
3440+
3441+
match
3442+
gfc_match_sync_team (void)
3443+
{
3444+
match m;
3445+
gfc_expr *team;
3446+
3447+
if (!gfc_notify_std (GFC_STD_F2008_TS, "SYNC TEAM statement at %C"))
3448+
return MATCH_ERROR;
3449+
3450+
if (gfc_match_char ('(') == MATCH_NO)
3451+
goto syntax;
3452+
3453+
new_st.op = EXEC_SYNC_TEAM;
3454+
3455+
if (gfc_match ("%e", &team) != MATCH_YES)
3456+
goto syntax;
3457+
3458+
m = gfc_match_char (')');
3459+
if (m == MATCH_NO)
3460+
goto syntax;
3461+
3462+
new_st.expr1 = team;
3463+
3464+
return MATCH_YES;
3465+
3466+
syntax:
3467+
gfc_syntax_error (ST_SYNC_TEAM);
3468+
3469+
return MATCH_ERROR;
3470+
}
33463471

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

gcc/fortran/trans-decl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3360,7 +3360,7 @@ gfc_build_intrinsic_function_decls (void)
33603360
jtype = gfc_get_int_type (ikinds[jkind]);
33613361
if (itype && jtype)
33623362
{
3363-
sprintf(name, PREFIX("pow_i%d_i%d"), ikinds[ikind],
3363+
sprintf (name, PREFIX("pow_i%d_i%d"), ikinds[ikind],
33643364
ikinds[jkind]);
33653365
gfor_fndecl_math_powi[jkind][ikind].integer =
33663366
gfc_build_library_function_decl (get_identifier (name),
@@ -3375,7 +3375,7 @@ gfc_build_intrinsic_function_decls (void)
33753375
rtype = gfc_get_real_type (rkinds[rkind]);
33763376
if (rtype && itype)
33773377
{
3378-
sprintf(name, PREFIX("pow_r%d_i%d"), rkinds[rkind],
3378+
sprintf (name, PREFIX("pow_r%d_i%d"), rkinds[rkind],
33793379
ikinds[ikind]);
33803380
gfor_fndecl_math_powi[rkind][ikind].real =
33813381
gfc_build_library_function_decl (get_identifier (name),
@@ -3387,7 +3387,7 @@ gfc_build_intrinsic_function_decls (void)
33873387
ctype = gfc_get_complex_type (rkinds[rkind]);
33883388
if (ctype && itype)
33893389
{
3390-
sprintf(name, PREFIX("pow_c%d_i%d"), rkinds[rkind],
3390+
sprintf (name, PREFIX("pow_c%d_i%d"), rkinds[rkind],
33913391
ikinds[ikind]);
33923392
gfor_fndecl_math_powi[rkind][ikind].cmplx =
33933393
gfc_build_library_function_decl (get_identifier (name),

gcc/fortran/trans-intrinsic.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1850,7 +1850,7 @@ conv_caf_send (gfc_code *code) {
18501850
gfc_se lhs_se, rhs_se;
18511851
stmtblock_t block;
18521852
tree caf_decl, token, offset, image_index, tmp, lhs_kind, rhs_kind;
1853-
tree may_require_tmp, src_stat, dst_stat;
1853+
tree may_require_tmp, src_stat, dst_stat, dst_team;
18541854
tree lhs_type = NULL_TREE;
18551855
tree vec = null_pointer_node, rhs_vec = null_pointer_node;
18561856
symbol_attribute lhs_caf_attr, rhs_caf_attr;
@@ -1866,6 +1866,7 @@ conv_caf_send (gfc_code *code) {
18661866
lhs_caf_attr = gfc_caf_attr (lhs_expr);
18671867
rhs_caf_attr = gfc_caf_attr (rhs_expr);
18681868
src_stat = dst_stat = null_pointer_node;
1869+
dst_team = null_pointer_node;
18691870

18701871
/* LHS. */
18711872
gfc_init_se (&lhs_se, NULL);

gcc/fortran/trans-stmt.c

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,110 @@ gfc_trans_fail_image (gfc_code *code ATTRIBUTE_UNUSED)
696696
}
697697
}
698698

699+
/* Translate the FORM TEAM statement. */
700+
701+
tree
702+
gfc_trans_form_team (gfc_code *code)
703+
{
704+
if (flag_coarray == GFC_FCOARRAY_LIB)
705+
{
706+
gfc_se argse;
707+
tree team_id,team_type;
708+
gfc_init_se (&argse, NULL);
709+
gfc_conv_expr_val (&argse, code->expr1);
710+
team_id = fold_convert (integer_type_node, argse.expr);
711+
gfc_init_se (&argse, NULL);
712+
gfc_conv_expr_val (&argse, code->expr2);
713+
team_type = gfc_build_addr_expr (ppvoid_type_node, argse.expr);
714+
715+
return build_call_expr_loc (input_location,
716+
gfor_fndecl_caf_form_team, 3,
717+
team_id, team_type,
718+
build_int_cst (integer_type_node, 0));
719+
}
720+
else
721+
{
722+
const char *name = gfc_get_string (PREFIX ("exit_i%d"), 4);
723+
gfc_symbol *exsym = gfc_get_intrinsic_sub_symbol (name);
724+
tree tmp = gfc_get_symbol_decl (exsym);
725+
return build_call_expr_loc (input_location, tmp, 1, integer_zero_node);
726+
}
727+
}
728+
729+
/* Translate the CHANGE TEAM statement. */
730+
731+
tree
732+
gfc_trans_change_team (gfc_code *code)
733+
{
734+
if (flag_coarray == GFC_FCOARRAY_LIB)
735+
{
736+
gfc_se argse;
737+
tree team_type;
738+
739+
gfc_init_se (&argse, NULL);
740+
gfc_conv_expr_val (&argse, code->expr1);
741+
team_type = gfc_build_addr_expr (ppvoid_type_node, argse.expr);
742+
743+
return build_call_expr_loc (input_location,
744+
gfor_fndecl_caf_change_team, 2, team_type,
745+
build_int_cst (integer_type_node, 0));
746+
}
747+
else
748+
{
749+
const char *name = gfc_get_string (PREFIX ("exit_i%d"), 4);
750+
gfc_symbol *exsym = gfc_get_intrinsic_sub_symbol (name);
751+
tree tmp = gfc_get_symbol_decl (exsym);
752+
return build_call_expr_loc (input_location, tmp, 1, integer_zero_node);
753+
}
754+
}
755+
756+
/* Translate the END TEAM statement. */
757+
758+
tree
759+
gfc_trans_end_team (gfc_code *code ATTRIBUTE_UNUSED)
760+
{
761+
if (flag_coarray == GFC_FCOARRAY_LIB)
762+
{
763+
return build_call_expr_loc (input_location,
764+
gfor_fndecl_caf_end_team, 1,
765+
build_int_cst (pchar_type_node, 0));
766+
}
767+
else
768+
{
769+
const char *name = gfc_get_string (PREFIX ("exit_i%d"), 4);
770+
gfc_symbol *exsym = gfc_get_intrinsic_sub_symbol (name);
771+
tree tmp = gfc_get_symbol_decl (exsym);
772+
return build_call_expr_loc (input_location, tmp, 1, integer_zero_node);
773+
}
774+
}
775+
776+
/* Translate the SYNC TEAM statement. */
777+
778+
tree
779+
gfc_trans_sync_team (gfc_code *code)
780+
{
781+
if (flag_coarray == GFC_FCOARRAY_LIB)
782+
{
783+
gfc_se argse;
784+
tree team_type;
785+
786+
gfc_init_se (&argse, NULL);
787+
gfc_conv_expr_val (&argse, code->expr1);
788+
team_type = gfc_build_addr_expr (ppvoid_type_node, argse.expr);
789+
790+
return build_call_expr_loc (input_location,
791+
gfor_fndecl_caf_sync_team, 2,
792+
team_type,
793+
build_int_cst (integer_type_node, 0));
794+
}
795+
else
796+
{
797+
const char *name = gfc_get_string (PREFIX ("exit_i%d"), 4);
798+
gfc_symbol *exsym = gfc_get_intrinsic_sub_symbol (name);
799+
tree tmp = gfc_get_symbol_decl (exsym);
800+
return build_call_expr_loc (input_location, tmp, 1, integer_zero_node);
801+
}
802+
}
699803

700804
tree
701805
gfc_trans_lock_unlock (gfc_code *code, gfc_exec_op op)

0 commit comments

Comments
 (0)