diff options
author | Andre Vehreschild <vehre@gcc.gnu.org> | 2016-11-22 18:13:27 +0100 |
---|---|---|
committer | Andre Vehreschild <vehre@gcc.gnu.org> | 2016-11-22 18:13:27 +0100 |
commit | 3a7ec30f89305ef4d3ed07bf8126a26b19f3fe6b (patch) | |
tree | 54b31f358fd3846952b3916172d86c859dc42fcd | |
parent | 8e9fe41dfe28aed4147c9c71279f05c21b9b0b01 (diff) | |
download | gcc-vehre/coarray.tar.gz |
Style fixes.vehre/coarray
-rw-r--r-- | gcc/fortran/gfortran.texi | 66 | ||||
-rw-r--r-- | gcc/fortran/trans-array.c | 18 | ||||
-rw-r--r-- | gcc/fortran/trans-stmt.c | 12 | ||||
-rw-r--r-- | gcc/fortran/trans.c | 11 | ||||
-rw-r--r-- | gcc/fortran/trans.h | 8 | ||||
-rw-r--r-- | libgfortran/caf/libcaf.h | 4 |
6 files changed, 90 insertions, 29 deletions
diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index 6d8805cfc98..5e2a750f98d 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -3871,6 +3871,7 @@ of such a type @menu * caf_token_t:: * caf_register_t:: +* caf_deregister_t:: * caf_reference_t:: @end menu @@ -3893,11 +3894,39 @@ typedef enum caf_register_t { CAF_REGTYPE_LOCK_ALLOC, CAF_REGTYPE_CRITICAL, CAF_REGTYPE_EVENT_STATIC, - CAF_REGTYPE_EVENT_ALLOC + CAF_REGTYPE_EVENT_ALLOC, + CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY, + CAF_REGTYPE_COARRAY_ALLOC_ALLOCATE_ONLY } caf_register_t; @end verbatim +The values @code{CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY} and +@code{CAF_REGTYPE_COARRAY_ALLOC_ALLOCATE_ONLY} are for allocatable components +in derived type coarrays only. The first one sets up the token without +allocating memory for allocatable component. The latter one only allocates the +memory for an allocatable component in a derived type coarray. The token +needs to be setup previously by the REGISTER_ONLY. This allows to have +allocatable components un-allocated on some images. The status whether an +allocatable component is allocated on a remote image can be queried by +@code{_caf_is_present} which used internally by the @code{ALLOCATED} +intrinsic. + +@node caf_deregister_t +@subsection @code{caf_deregister_t} + +@verbatim +typedef enum caf_deregister_t { + CAF_DEREGTYPE_COARRAY_DEREGISTER, + CAF_DEREGTYPE_COARRAY_DEALLOCATE_ONLY +} +caf_deregister_t; +@end verbatim + +Allows to specifiy the type of deregistration of a coarray object. The +@code{CAF_DEREGTYPE_COARRAY_DEALLOCATE_ONLY} flag is only allowed for +allocatable components in derived type coarrays. + @node caf_reference_t @subsection @code{caf_reference_t} @@ -4017,6 +4046,7 @@ descriptor-less arrays. The library caf_single has untested support for it. * _gfortran_caf_num_images:: Querying the maximal number of images * _gfortran_caf_register:: Registering coarrays * _gfortran_caf_deregister:: Deregistering coarrays +* _gfortran_caf_is_present:: Query whether an allocatable component in a derived type coarray is allocated * _gfortran_caf_send:: Sending data from a local image to a remote image * _gfortran_caf_get:: Getting data from a remote image * _gfortran_caf_sendget:: Sending data between remote images @@ -4218,6 +4248,7 @@ section) such as the value false; for event types, the initial state should be no event, e.g. zero. @end table + @node _gfortran_caf_deregister @subsection @code{_gfortran_caf_deregister} --- Deregistering coarrays @cindex Coarray, _gfortran_caf_deregister @@ -4231,12 +4262,16 @@ library is only expected to free memory it allocated itself during a call to @code{_gfortran_caf_register}. @item @emph{Syntax}: -@code{void caf_deregister (caf_token_t *token, int *stat, char *errmsg, -int errmsg_len)} +@code{void caf_deregister (caf_token_t *token, caf_deregister_t type, +int *stat, char *errmsg, int errmsg_len)} @item @emph{Arguments}: @multitable @columnfractions .15 .70 @item @var{token} @tab the token to free. +@item @var{type} @tab the type of action to take for the coarray. A +@code{CAF_DEREGTYPE_COARRAY_DEALLOCATE_ONLY} is allowed only for allocatable +components of derived type coarrays. The action only deallocates the local +memory without deleting the token. @item @var{stat} @tab intent(out) Stores the STAT=; may be NULL @item @var{errmsg} @tab intent(out) When an error occurs, this will be set to an error message; may be NULL @@ -4250,6 +4285,31 @@ and via destructors. @end table +@node _gfortran_caf_is_present +@subsection @code{_gfortran_caf_is_present} --- Query whether an allocatable component in a derived type coarray is allocated +@cindex Coarray, _gfortran_caf_is_present + +@table @asis +@item @emph{Description}: +Used to query the coarray library whether an allocatable component in a derived +type coarray is allocated on a remote image. + +@item @emph{Syntax}: +@code{void _gfortran_caf_is_present (caf_token_t token, int image_index, +gfc_reference_t *ref)} + +@item @emph{Arguments}: +@multitable @columnfractions .15 .70 +@item @var{token} @tab An opaque pointer identifying the coarray. +@item @var{image_index} @tab The ID of the remote image; must be a positive +number. +@item @var{ref} @tab A chain of references to address the allocatable component +in the derived type coarray. The object reffed needs to be a scalar or a full +array ref, respectively. +@end multitable + +@end table + @node _gfortran_caf_send @subsection @code{_gfortran_caf_send} --- Sending data from a local image to a remote image @cindex Coarray, _gfortran_caf_send diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 8051047526e..45e1369204e 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -8160,7 +8160,7 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, if ((purpose == COPY_ALLOC_COMP || purpose == COPY_ONLY_ALLOC_COMP) && (caf_mode & GFC_STRUCTURE_CAF_MODE_ENABLE_COARRAY) == 0) - { + { tmp = build_fold_indirect_ref_loc (input_location, gfc_conv_array_data (dest)); dref = gfc_build_array_ref (tmp, index, NULL); @@ -8168,7 +8168,7 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, COPY_ALLOC_COMP, 0); } else - tmp = structure_alloc_comps (der_type, vref, NULL_TREE, rank, purpose, + tmp = structure_alloc_comps (der_type, vref, NULL_TREE, rank, purpose, caf_mode); gfc_add_expr_to_block (&loopbody, tmp); @@ -8245,12 +8245,12 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, { /* Allocatable arrays or coarray'ed components (scalar or array). */ - int caf_dereg_mode = - ((caf_mode & GFC_STRUCTURE_CAF_MODE_IN_COARRAY) != 0 - || c->attr.codimension) + int caf_dereg_mode + = ((caf_mode & GFC_STRUCTURE_CAF_MODE_IN_COARRAY) != 0 + || c->attr.codimension) ? ((caf_mode & GFC_STRUCTURE_CAF_MODE_DEALLOC_ONLY) != 0 - ? GFC_CAF_COARRAY_DEALLOCATE_ONLY - : GFC_CAF_COARRAY_DEREGISTER) + ? GFC_CAF_COARRAY_DEALLOCATE_ONLY + : GFC_CAF_COARRAY_DEREGISTER) : GFC_CAF_COARRAY_NOCOARRAY; if (comp == NULL_TREE) comp = fold_build3_loc (input_location, COMPONENT_REF, ctype, @@ -8399,7 +8399,7 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, TREE_TYPE (tmp), comp, tmp, NULL_TREE); if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (comp))) - tmp = gfc_trans_dealloc_allocated (comp, NULL, + tmp = gfc_trans_dealloc_allocated (comp, NULL, CLASS_DATA (c)->attr.codimension ? GFC_CAF_COARRAY_DEREGISTER : GFC_CAF_COARRAY_NOCOARRAY); @@ -8570,7 +8570,7 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, GFC_CAF_COARRAY_ALLOC_REGISTER_ONLY); } - if (cmp_has_alloc_comps) + if (cmp_has_alloc_comps) { comp = fold_build3_loc (input_location, COMPONENT_REF, ctype, decl, cdecl, NULL_TREE); diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 147872fe0ba..b35075ed460 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -6433,9 +6433,9 @@ gfc_trans_deallocate (gfc_code *code) /* When the expression to deallocate is referencing a component, then only deallocate it, but do not deregister. */ - caf_mode = GFC_STRUCTURE_CAF_MODE_IN_COARRAY | - (comp_ref && !caf_attr.coarray_comp - ? GFC_STRUCTURE_CAF_MODE_DEALLOC_ONLY : 0); + caf_mode = GFC_STRUCTURE_CAF_MODE_IN_COARRAY + | (comp_ref && !caf_attr.coarray_comp + ? GFC_STRUCTURE_CAF_MODE_DEALLOC_ONLY : 0); } } else if (flag_coarray == GFC_FCOARRAY_SINGLE) @@ -6481,14 +6481,14 @@ gfc_trans_deallocate (gfc_code *code) gfc_coarray_deregtype caf_dtype; if (is_coarray) - caf_dtype = (caf_mode & GFC_STRUCTURE_CAF_MODE_DEALLOC_ONLY) == 0 + caf_dtype + = (caf_mode & GFC_STRUCTURE_CAF_MODE_DEALLOC_ONLY) == 0 ? GFC_CAF_COARRAY_DEREGISTER : GFC_CAF_COARRAY_DEALLOCATE_ONLY; else caf_dtype = GFC_CAF_COARRAY_NOCOARRAY; tmp = gfc_array_deallocate (se.expr, pstat, errmsg, errlen, - label_finish, expr, - caf_dtype); + label_finish, expr, caf_dtype); gfc_add_expr_to_block (&se.pre, tmp); } else if (TREE_CODE (se.expr) == COMPONENT_REF diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c index b441e1a2b64..6a1d4819ca6 100644 --- a/gcc/fortran/trans.c +++ b/gcc/fortran/trans.c @@ -1298,7 +1298,7 @@ gfc_deallocate_with_status (tree pointer, tree status, tree errmsg, if (coarray_dealloc_mode == GFC_CAF_COARRAY_ANALYZE) { bool comp_ref; - if (expr && !gfc_caf_attr(expr, false, &comp_ref).coarray_comp + if (expr && !gfc_caf_attr (expr, false, &comp_ref).coarray_comp && comp_ref) caf_dereg_type = GFC_CAF_COARRAY_DEALLOCATE_ONLY; // else do a deregister as set by default. @@ -1538,13 +1538,14 @@ gfc_deallocate_scalar_with_status (tree pointer, tree status, tree label_finish, tree cond2; cond2 = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, - status, build_int_cst (TREE_TYPE (status), 0)); + status, + build_int_cst (TREE_TYPE (status), 0)); tmp = fold_build2_loc (input_location, MODIFY_EXPR, status_type, fold_build1_loc (input_location, INDIRECT_REF, status_type, status), build_int_cst (status_type, 0)); - tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, cond2, - tmp, build_empty_stmt (input_location)); + tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, + cond2, tmp, build_empty_stmt (input_location)); gfc_add_expr_to_block (&non_null, tmp); } } @@ -1571,7 +1572,7 @@ gfc_deallocate_scalar_with_status (tree pointer, tree status, tree label_finish, pstat, null_pointer_node, integer_zero_node); gfc_add_expr_to_block (&non_null, tmp); - /* It guarantees memory consistency within the same segment */ + /* It guarantees memory consistency within the same segment. */ tmp = gfc_build_string_const (strlen ("memory")+1, "memory"), tmp = build5_loc (input_location, ASM_EXPR, void_type_node, gfc_build_string_const (1, ""), NULL_TREE, NULL_TREE, diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h index aeaa7c986af..ae1f15651ef 100644 --- a/gcc/fortran/trans.h +++ b/gcc/fortran/trans.h @@ -121,13 +121,13 @@ enum gfc_coarray_regtype }; -/* Describes the action to take on _caf_deregister. Keep in sync with +/* Describes the action to take on _caf_deregister. Keep in sync with gcc/fortran/trans.h. The negative values are not valid for the library and are used by the drivers for building the correct call. */ enum gfc_coarray_deregtype { - /* This is no coarray, i.e. build a call to a free(). */ + /* This is no coarray, i.e. build a call to a free (). */ GFC_CAF_COARRAY_NOCOARRAY = -2, - /* The driver is to analyze which _caf_deregister()-call to generate. */ + /* The driver is to analyze which _caf_deregister ()-call to generate. */ GFC_CAF_COARRAY_ANALYZE = -1, GFC_CAF_COARRAY_DEREGISTER = 0, GFC_CAF_COARRAY_DEALLOCATE_ONLY @@ -156,7 +156,7 @@ enum gfc_caf_array_ref_t { }; -/* trans-array(structure_alloc_comps) caf_mode bits. */ +/* trans-array (structure_alloc_comps) caf_mode bits. */ enum gfc_structure_caf_mode_t { GFC_STRUCTURE_CAF_MODE_ENABLE_COARRAY = 1 << 0, GFC_STRUCTURE_CAF_MODE_IN_COARRAY = 1 << 1, diff --git a/libgfortran/caf/libcaf.h b/libgfortran/caf/libcaf.h index c81eebef2a4..1bb5176a6c1 100644 --- a/libgfortran/caf/libcaf.h +++ b/libgfortran/caf/libcaf.h @@ -50,7 +50,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define STAT_STOPPED_IMAGE 6000 #endif -/* Describes what type of array we are registerring. Keep in sync with +/* Describes what type of array we are registerring. Keep in sync with gcc/fortran/trans.h. */ typedef enum caf_register_t { CAF_REGTYPE_COARRAY_STATIC, @@ -65,7 +65,7 @@ typedef enum caf_register_t { } caf_register_t; -/* Describes the action to take on _caf_deregister. Keep in sync with +/* Describes the action to take on _caf_deregister. Keep in sync with gcc/fortran/trans.h. */ typedef enum caf_deregister_t { CAF_DEREGTYPE_COARRAY_DEREGISTER, |