Commit Graph

47 Commits

Author SHA1 Message Date
Janne Blomqvist
dffb1e2279 PR 84519 Handle optional QUIET specifier for STOP and ERROR STOP
Fortran 2018 adds a new QUIET specifier for the STOP and ERROR STOP
statements, in order to suppress the printing of signaling FP
exceptions and the stop code. This patch adds the necessary library
changes, but for now the new specifier is not parsed and the frontend
unconditionally adds a false value for the new argument.

Regtested on x86_64-pc-linux-gnu.

gcc/fortran/ChangeLog:

2018-02-23  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/84519
	* trans-decl.c (gfc_build_builtin_function_decls): Add bool
	argument to stop and error stop decls.
	* trans-stmt.c (gfc_trans_stop): Add false value to argument
	lists.

libgfortran/ChangeLog:

2018-02-23  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/84519
	* caf/libcaf.h (_gfortran_caf_stop_numeric): Add bool argument.
	(_gfortran_caf_stop_str): Likewise.
	(_gfortran_caf_error_stop_str): Likewise.
	(_gfortran_caf_error_stop): Likewise.
	* caf/mpi.c (_gfortran_caf_error_stop_str): Handle new argument.
	(_gfortran_caf_error_stop): Likewise.
	* caf/single.c (_gfortran_caf_stop_numeric): Likewise.
	(_gfortran_caf_stop_str): Likewise.
	(_gfortran_caf_error_stop_str): Likewise.
	(_gfortran_caf_error_stop): Likewise.
	(_gfortran_caf_lock): Likewise.
	(_gfortran_caf_unlock): Likewise.
	* libgfortran.h (stop_string): Add bool argument.
	* runtime/pause.c (do_pause): Add false argument.
	* runtime/stop.c (stop_numeric): Handle new argument.
	(stop_string): Likewise.
	(error_stop_string): Likewise.
	(error_stop_numeric): Likewise.

From-SVN: r257928
2018-02-23 11:07:24 +02:00
Janne Blomqvist
3f5fabc0ea Character length cleanup for Coarray Fortran library
Following the change to use size_t for Fortran character lengths (PR
78534), this patch modifies the Coarray ABI in a similar way. The
single-image implementation that is included in libgfortran is
updated, but this needs corresponding work in the OpenCoarray library
as well for multi-image support. I also fixed the types for the STOP
and ERROR STOP implementation in libgfortran, as the calling of them
is somewhat intertwined with the calling of the corresponding CAF
functions. I'll send the OpenCoarray changes as a separate pull
request to the OpenCoarrays repository.

Regtested on x86_64-pc-linux-gnu.

gcc/fortran/ChangeLog:

2018-02-22  Janne Blomqvist  <jb@gcc.gnu.org>

	* gfortran.texi: Update Coarray API description.
	* trans-decl.c (gfc_build_builtin_function_decls): Use size_t for
	character lengths, int for exit codes.
	(generate_coarray_sym_init): Use size_t for character length.
	* trans-intrinsic.c (conv_co_collective): Likewise.
	* trans-stmt.c (gfc_trans_lock_unlock): Likewise.
	(gfc_trans_event_post_wait): Likewise.
	(gfc_trans_sync): Likewise.
	(gfc_trans_stop): Use size_t for character lengths, int for exit
	codes.

libgfortran/ChangeLog:

2018-02-22  Janne Blomqvist  <jb@gcc.gnu.org>

	* libgfortran.h (stop_string): Use size_t for character length.
	* runtime/stop.c (stop_string): Likewise.
	(error_stop_string): Likewise.
	(stop_numeric): Use int for exit code.
	(error_stop_numeric): Likewise.
	* caf/libcaf.h: Remove stdint.h include.
	(_gfortran_caf_register): Use size_t for character length.
	(_gfortran_caf_deregister): Likewise.
	(_gfortran_caf_sync_all): Likewise.
	(_gfortran_caf_sync_memory): Likewise.
	(_gfortran_caf_sync_images): Likewise.
	(_gfortran_caf_stop_numeric): Use int for exit code.
	(_gfortran_caf_stop_str): Use size_t for character length.
	(_gfortran_caf_error_stop_str): Likewise.
	(_gfortran_caf_error_stop): Use int for exit code.
	(_gfortran_caf_co_broadcast): Use size_t for character length.
	(_gfortran_caf_co_sum): Likewise.
	(_gfortran_caf_co_min): Likewise.
	(_gfortran_caf_co_max): Likewise.
	(_gfortran_caf_co_reduce): Likewise.
	(_gfortran_caf_lock): Likewise.
	(_gfortran_caf_unlock): Likewise.
	(_gfortran_caf_event_post): Likewise.
	(_gfortran_caf_event_wait): Likewise.
	* caf/mpi.c (_gfortran_caf_register): Update implementation to
	match prototype.
	(_gfortran_caf_deregister): Likewise.
	(_gfortran_caf_sync_all): Likewise.
	(_gfortran_caf_sync_images): Likewise.
	(_gfortran_caf_error_stop_str): Likewise.
	(_gfortran_caf_error_stop): Likewise.
	* caf/single.c (caf_internal_error): Likewise.
	(_gfortran_caf_register): Likewise.
	(_gfortran_caf_deregister): Likewise.
	(_gfortran_caf_sync_all): Likewise.
	(_gfortran_caf_sync_memory): Likewise.
	(_gfortran_caf_sync_images): Likewise.
	(_gfortran_caf_stop_numeric): Likewise.
	(_gfortran_caf_stop_str): Likewise.
	(_gfortran_caf_error_stop_str): Likewise.
	(_gfortran_caf_error_stop): Likewise.
	(_gfortran_caf_co_broadcast): Likewise.
	(_gfortran_caf_co_sum): Likewise.
	(_gfortran_caf_co_min): Likewise.
	(_gfortran_caf_co_max): Likewise.
	(_gfortran_caf_co_reduce): Likewise.
	(_gfortran_caf_event_post): Likewise.
	(_gfortran_caf_event_wait): Likewise.
	(_gfortran_caf_lock): Likewise.
	(_gfortran_caf_unlock): Likewise.

From-SVN: r257894
2018-02-22 11:44:31 +02:00
Andre Vehreschild
87e8aa3bd9 gfortran.texi: Document additional src/dst_type.
gcc/fortran/ChangeLog:

2018-02-19  Andre Vehreschild  <vehre@gcc.gnu.org>

	* gfortran.texi: Document additional src/dst_type.  Fix some typos.
	* trans-decl.c (gfc_build_builtin_function_decls): Declare the new
	argument of _caf_*_by_ref () with * e { get, send, sendget }.
	* trans-intrinsic.c (gfc_conv_intrinsic_caf_get): Add the type of the
	data referenced when generating a call to caf_get_by_ref ().
	(conv_caf_send): Same but for caf_send_by_ref () and
	caf_sendget_by_ref ().

gcc/testsuite/ChangeLog:

2018-02-19  Andre Vehreschild  <vehre@gcc.gnu.org>

	* gfortran.dg/coarray_alloc_comp_6.f08: New test.
	* gfortran.dg/coarray_alloc_comp_7.f08: New test.
	* gfortran.dg/coarray_alloc_comp_8.f08: New test.

libgfortran/ChangeLog:

2018-02-19  Andre Vehreschild  <vehre@gcc.gnu.org>

	* caf/libcaf.h: Add type parameters to the caf_*_by_ref prototypes.
	* caf/single.c (get_for_ref): Simplifications and now respecting
	the type argument.
	(_gfortran_caf_get_by_ref): Added source type handing to get_for_ref().
	(send_by_ref): Simplifications and respecting the dst_type now.
	(_gfortran_caf_send_by_ref): Added destination type hand over to
	send_by_ref().
	(_gfortran_caf_sendget_by_ref): Added general support and fixed stack
	corruption.  The function is now really usable.

From-SVN: r257813
2018-02-19 18:30:57 +01:00
Paul Thomas
7fb43006b2 re PR fortran/37577 ([meta-bug] change internal array descriptor format for better syntax, C interop TR, rank 15)
2018-25-01  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/37577
	* array.c (gfc_match_array_ref): If standard earlier than F2008
	it is an error if the reference dimension is greater than 7.
	libgfortran.h : Increase GFC_MAX_DIMENSIONS to 15. Change the
	dtype masks and shifts accordingly.
	* trans-array.c (gfc_conv_descriptor_dtype): Use the dtype
	type node to check the field.
	(gfc_conv_descriptor_dtype): Access the rank field of dtype.
	(duplicate_allocatable_coarray): Access the rank field of the
	dtype descriptor rather than the dtype itself.
	* trans-expr.c (get_scalar_to_descriptor_type): Store the type
	of 'scalar' on entry and use its TREE_TYPE if it is ARRAY_TYPE
	(ie. a character).
	(gfc_conv_procedure_call): Pass TREE_OPERAND (tmp,0) to
	get_scalar_to_descriptor_type if the actual expression is a
	constant.
	(gfc_trans_structure_assign): Assign the rank directly to the
	dtype rank field.
	* trans-intrinsic.c (gfc_conv_intrinsic_rank): Cast the result
	to default integer kind.
	(gfc_conv_intrinsic_sizeof): Obtain the element size from the
	'elem_len' field of the dtype.
	* trans-io.c (gfc_build_io_library_fndecls): Replace
	gfc_int4_type_node with dtype_type_node where necessary.
	(transfer_namelist_element): Use gfc_get_dtype_rank_type for
	scalars.
	* trans-types.c : Provide 'get_dtype_type_node' to acces the
	dtype_type_node and, if necessary, build it.
	The maximum size of an array element is now determined by the
	maximum value of size_t.
	Update the description of the array descriptor, including the
	type def for the dtype_type.
	(gfc_get_dtype_rank_type): Build a constructor for the dtype.
	Distinguish RECORD_TYPEs that are BT_DERIVED or BT_CLASS.
	(gfc_get_array_descriptor_base): Change the type of the dtype
	field to dtype_type_node.
	(gfc_get_array_descr_info): Get the offset to the rank field of
	the dtype.
	* trans-types.h : Add a prototype for 'get_dtype_type_node ()'.
	* trans.h : Define the indices of the dtype fields.

2018-25-01  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/37577
	* gfortran.dg/coarray_18.f90: Allow dimension 15 for F2008.
	* gfortran.dg/coarray_lib_this_image_2.f90: Change 'array1' to
	'array01' in the tree dump comparison.
	* gfortran.dg/coarray_lib_token_4.f90: Likewise.
	* gfortran.dg/inline_sum_1.f90: Similar - allow two digits.
	* gfortran.dg/rank_1.f90: Allow dimension 15 for F2008.

2018-25-01  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/37577
	* caf/single.c (_gfortran_caf_failed_images): Access the 'type'
	and 'elem_len' fields of the dtype instead of the shifts.
	(_gfortran_caf_stopped_images): Likewise.
	* intrinsics/associated.c (associated): Compare the 'type' and
	'elem_len' fields instead of the dtype.
	* caf/date_and_time.c : Access the dtype fields rather using
	shifts and masks.
	* io/transfer.c (transfer_array ): Comment on item count.
	(set_nml_var,st_set_nml_var): Change dtype type and use fields.
	(st_set_nml_dtio_var): Likewise.
	* libgfortran.h : Change definition of GFC_ARRAY_DESCRIPTOR and
	add a typedef for the dtype_type. Change the GFC_DTYPE_* macros
	to access the dtype fields.

From-SVN: r257065
2018-01-25 19:09:40 +00:00
Jakub Jelinek
85ec4feb11 Update copyright years.
From-SVN: r256169
2018-01-03 11:03:58 +01:00
Andre Vehreschild
ef78bc3c0b check.c (positive_check): Add new function checking constant for being greater then zero.
gcc/fortran/ChangeLog:

2017-03-05  Andre Vehreschild  <vehre@gcc.gnu.org>
            Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>

	* check.c (positive_check): Add new function checking constant for
	being greater then zero.
	(gfc_check_image_status): Add checking of image_status arguments.
	(gfc_check_failed_or_stopped_images): Same but for failed_- and
	stopped_images function.
	* dump-parse-tree.c (show_code_node): Added output of FAIL IMAGE.
	* gfortran.h (enum gfc_statement): Added FAIL_IMAGE_ST.
	(enum gfc_isym_id): Added new intrinsic symbols.
	(enum gfc_exec_op): Added EXEC_FAIL_IMAGE.
	* gfortran.texi: Added description for the new API functions. Updated
	coverage of gfortran of TS18508.
	* intrinsic.c (add_functions): Added symbols to resolve new intrinsic
	functions. 
	* intrinsic.h: Added prototypes.
	* iresolve.c (gfc_resolve_failed_images): Resolve the failed_images
	intrinsic.
	(gfc_resolve_image_status): Same for image_status.
	(gfc_resolve_stopped_images): Same for stopped_images.
	* libgfortran.h: Added prototypes.
	* match.c (gfc_match_if): Added matching of FAIL IMAGE statement.
	(gfc_match_fail_image): Match a FAIL IMAGE statement.
	* match.h: Added prototype.
	* parse.c (decode_statement): Added matching for FAIL IMAGE.
	(next_statement): Same.
	(gfc_ascii_statement): Same.
	* resolve.c: Same.
	* simplify.c (gfc_simplify_failed_or_stopped_images): For COARRAY=
	single a constant result can be returne.d
	(gfc_simplify_image_status): For COARRAY=single the result is constant.
	* st.c (gfc_free_statement): Added FAIL_IMAGE handling.
	* trans-decl.c (gfc_build_builtin_function_decls): Added decls of the
	new intrinsics.
	* trans-expr.c (gfc_conv_procedure_call): This is first time all
	arguments of a function are optional, which is now handled here
	correctly.
	* trans-intrinsic.c (conv_intrinsic_image_status): Translate
	image_status.
	(gfc_conv_intrinsic_function): Add support for image_status.
	(gfc_is_intrinsic_libcall): Add support for the remaining new
	intrinsics.
	* trans-stmt.c (gfc_trans_fail_image): Trans a fail image.
	* trans-stmt.h: Add the prototype for the above.
	* trans.c (trans_code): Dispatch for fail_image.
	* trans.h: Add the trees for the new intrinsics.

libgfortran/ChangeLog:

2017-03-05  Andre Vehreschild  <vehre@gcc.gnu.org>
            Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>

	* caf/libcaf.h: Added prototypes and stat codes for failed and stopped
	images.
	* caf/single.c (void _gfortran_caf_fail_image): Add the routine.
	(int _gfortran_caf_image_status): Same.
	(_gfortran_caf_failed_images): Same.
	(_gfortran_caf_stopped_images): Same.


gcc/testsuite/ChangeLog:

2017-03-05  Andre Vehreschild  <vehre@gcc.gnu.org>
            Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>

	* gfortran.dg/coarray/fail_image_1.f08: New test.
	* gfortran.dg/coarray/fail_image_2.f08: New test.
	* gfortran.dg/coarray/failed_images_1.f08: New test.
	* gfortran.dg/coarray/failed_images_2.f08: New test.
	* gfortran.dg/coarray/image_status_1.f08: New test.
	* gfortran.dg/coarray/image_status_2.f08: New test.
	* gfortran.dg/coarray/stopped_images_1.f08: New test.
	* gfortran.dg/coarray/stopped_images_2.f08: New test.
	* gfortran.dg/coarray_fail_st.f90: New test.
	* gfortran.dg/coarray_failed_images_1.f08: New test.
	* gfortran.dg/coarray_image_status_1.f08: New test.
	* gfortran.dg/coarray_stopped_images_1.f08: New test.

From-SVN: r245900
2017-03-05 12:35:47 +01:00
Andre Vehreschild
4ccff88b71 re PR fortran/70696 ([Coarray] ICE on EVENT POST of host-associated EVENT_TYPE coarray)
gcc/testsuite/ChangeLog:

2017-01-13  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/70696
	* gfortran.dg/coarray/event_3.f08: New test.

gcc/fortran/ChangeLog:

2017-01-13  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/70696
	* trans-expr.c (gfc_get_tree_for_caf_expr): Ensure the backend_decl
	is valid before accessing it.

libgfortran/ChangeLog:

2017-01-13  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/70696
	* caf/single.c (_gfortran_caf_register): Allocate enough memory for
	the event counter.

From-SVN: r244407
2017-01-13 11:22:21 +01:00
Andre Vehreschild
de91486c74 re PR fortran/78781 ([Coarray] ICE in gfc_deallocate_scalar_with_status, at fortran/trans.c:1588)
gcc/fortran/ChangeLog:

2017-01-07  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/78781
	PR fortran/78935
	* expr.c (gfc_check_pointer_assign): Return the same error message for
	rewritten coarray pointer assignments like for plain ones.
	* gfortran.h: Change prototype.
	* primary.c (caf_variable_attr): Set attributes used ones only only
	ones.  Add setting of pointer_comp attribute.
	(gfc_caf_attr): Add setting of pointer_comp attribute.
	* trans-array.c (gfc_array_allocate): Add flag that the component to
	allocate is not an ultimate coarray component.  Add allocation of
	pointer arrays.
	(structure_alloc_comps): Extend nullify to treat pointer components in
	coarrays correctly.  Restructure nullify to remove redundant code.
	(gfc_nullify_alloc_comp): Allow setting caf_mode flags.
	* trans-array.h: Change prototype of gfc_nullify_alloc_comp ().
	* trans-decl.c (generate_coarray_sym_init): Call nullify_alloc_comp for
	derived type coarrays with pointer components.
	* trans-expr.c (gfc_trans_structure_assign): Also treat pointer
	components.
	(trans_caf_token_assign): Handle assignment of token of scalar pointer
	components.
	(gfc_trans_pointer_assignment): Call above routine.
	* trans-intrinsic.c (conv_expr_ref_to_caf_ref): Add treating pointer
	components.
	(gfc_conv_intrinsic_caf_get): Likewise.
	(conv_caf_send): Likewise.
	* trans-stmt.c (gfc_trans_allocate): After allocating a derived type in
	a coarray pre-register the tokens.
	(gfc_trans_deallocate): Simply determining the coarray type (scalar or
	array) and deregistering it correctly.
	* trans-types.c (gfc_typenode_for_spec): Replace in_coarray flag by the
	actual codim to allow lookup of array types in the cache.
	(gfc_build_array_type): Likewise.
	(gfc_get_array_descriptor_base): Likewise.
	(gfc_get_array_type_bounds): Likewise.
	(gfc_get_derived_type): Likewise.
	* trans-types.h: Likewise.
	* trans.c (gfc_deallocate_with_status): Enable deregistering of all kind
	of coarray components.
	(gfc_deallocate_scalar_with_status): Use free() in fcoarray_single mode
	instead of caf_deregister.

libgfortran/ChangeLog:

2017-01-07  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/78781
	PR fortran/78935
	* caf/single.c (send_by_ref): Fix addressing of non-allocatable scalar
	destination components.

gcc/testsuite/ChangeLog:

2017-01-07  Andre Vehreschild  <vehre@gcc.gnu.org>

	* gfortran.dg/coarray/ptr_comp_1.f08: New test.
	* gfortran.dg/coarray/ptr_comp_2.f08: New test.
	* gfortran.dg/coarray/ptr_comp_3.f08: New test.
	* gfortran.dg/coarray/ptr_comp_4.f08: New test.
	* gfortran.dg/coarray_ptr_comp_1.f08: New test.
	* gfortran.dg/coarray_ptr_comp_2.f08: New test.
	* gfortran.dg/coarray_ptr_comp_3.f08: New test.

From-SVN: r244196
2017-01-07 18:26:58 +01:00
Jakub Jelinek
cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Andre Vehreschild
8fb75185a2 single.c (_gfortran_caf_get_by_ref): Prevent compile time warning.
libgfortran/ChangeLog:

2016-11-30  Andre Vehreschild  <vehre@gcc.gnu.org>

        * caf/single.c (_gfortran_caf_get_by_ref): Prevent compile time
        warning.
        (_gfortran_caf_send_by_ref): Same.
        (_gfortran_caf_is_present): Prevent fallthrough warnings.

gcc/testsuite/ChangeLog:

2016-11-30  Andre Vehreschild  <vehre@gcc.gnu.org>

	* ChangeLog: Removed wrongly placed entry.
	* gfortran.dg/coarray_lib_alloc_4.f90: New test.

From-SVN: r243034
2016-11-30 16:59:07 +01:00
Andre Vehreschild
9a0f271862 single.c (_gfortran_caf_is_present): Prevent fallthrough warnings.
libgfortran/ChangeLog:

2016-11-30  Andre Vehreschild  <vehre@gcc.gnu.org>

	* caf/single.c (_gfortran_caf_is_present): Prevent fallthrough
	warnings.

From-SVN: r243024
2016-11-30 15:34:13 +01:00
Andre Vehreschild
ba85c8c3fc libcaf.h: Add new action types for (de-)registration of allocatable components in derived...
libgfortran/ChangeLog:

2016-11-30  Andre Vehreschild  <vehre@gcc.gnu.org>

	* caf/libcaf.h: Add new action types for (de-)registration of
	allocatable components in derived type coarrays.  Add _caf_is_present
	prototype.
	* caf/single.c (_gfortran_caf_register): Add support for registration
	only and allocation of already registered allocatable components in
	derived type coarrays.
	(_gfortran_caf_deregister): Add mode to deallocate but not deregister
	an allocatable component in a derived type coarray.
	(_gfortran_caf_is_present): New function.  Query whether an
	allocatable component in a derived type coarray on a remote image is
	allocated.


gcc/testsuite/ChangeLog:

2016-11-30  Andre Vehreschild  <vehre@gcc.gnu.org>

	* gfortran.dg/coarray/alloc_comp_1.f90: Fix tree-dump scans to adhere
	to the changed interfaces.
	* gfortran.dg/coarray_alloc_comp_1.f08: Likewise.
	* gfortran.dg/coarray_allocate_7.f08: Likewise.
	* gfortran.dg/coarray_lib_alloc_1.f90: Likewise.
	* gfortran.dg/coarray_lib_alloc_2.f90: Likewise.
	* gfortran.dg/coarray_lib_alloc_3.f90: Likewise.
	* gfortran.dg/coarray_lib_comm_1.f90: Likewise.
	* gfortran.dg/coarray_lib_alloc_4.f90: New test.

gcc/fortran/ChangeLog:

2016-11-30  Andre Vehreschild  <vehre@gcc.gnu.org>

	* check.c (gfc_check_allocated): By pass the caf_get call and check on
	the array.
	* gfortran.h: Add optional flag to gfc_caf_attr.
	* gfortran.texi: Document new enum values and _caf_is_present function.
	* primary.c (caf_variable_attr): Add optional flag to indicate that the
	expression is reffing a component.
	(gfc_caf_attr): Likewise.
	* trans-array.c (gfc_array_deallocate): Handle deallocation mode for
	coarray deregistration.
	(gfc_trans_dealloc_allocated): Likewise.
	(duplicate_allocatable): Use constants instead of
        creating custom constant tree node of zero or one.  Use gfc_add_modify
        convenience function.
	(duplicate_allocatable_coarray): This function is similar to
	duplicate_allocatable but tailored to handle coarrays.
	(caf_enabled): Check whether in-derived-type coarray processing is
	enabled.
	(caf_in_coarray): Check that in-derived-type coarray processing is
	enabled and currently in a derived-typed coarray.
	(gfc_caf_is_dealloc_only): Return true, when deallocate only is
	desired for components in derived typed coarrays.
	(structure_alloc_comps): A mode for handling coarrays, that is no
	longer encode in the purpose.  This makes the use cases of the
	routine more flexible without repeating.  Allocatable components in
	derived type coarrays are now registered only when nullifying an
	object and allocated before copying data into them.
	(gfc_nullify_alloc_comp): Use the caf_mode of structure_alloc_comps
	now.
	(gfc_deallocate_alloc_comp): Likewise.
	(gfc_deallocate_alloc_comp_no_caf): Likewise.
	(gfc_reassign_alloc_comp_caf): Likewise.
	(gfc_copy_alloc_comp): Likewise.
	(gfc_copy_only_alloc_comp): Likewise.
	(gfc_alloc_allocatable_for_assignment): Make use to the cheaper way of
	reallocating a coarray without deregistering and reregistering it.
	(gfc_trans_deferred_array): Initialize the coarray token correctly for
	deferred variables and tear them down on exit.
	* trans-array.h: Change some prototypes to add the coarray (de-)
	registration modes.  Add prototype for checking if deallocate only is
	selected for components in derived typed coarrays.
	* trans-decl.c (gfc_build_builtin_function_decls): Generate the
	declarations for the changed/new caf-lib routines.
	(gfc_trans_deferred_vars): Ensure deferred variables are (de-)
	registered correctly on procedure entry/exit.
	(generate_coarray_sym_init): Use constants.
	* trans-expr.c (gfc_conv_procedure_call): Propagate coarray allocation
	modes accordingly.
	(gfc_trans_alloc_subarray_assign): Likewise.
	(gfc_trans_subcomponent_assign): Likewise.
	(gfc_trans_structure_assign): Generate code to register the components
	of a derived type coarray prior to initialization.
	(gfc_conv_structure): Set flag that the structure is in a coarray.
	(gfc_trans_scalar_assign): Add flag to indicate being in a coarray and
	set the structure_alloc_comps modes correctly.
	(gfc_trans_assignment_1): Figure being in a coarray expression.
	* trans-intrinsic.c (gfc_conv_intrinsic_caf_get): Adapt to new
	structure_alloc_comps interface.
	(conv_caf_send): Use the old API as long as possible.
	(trans_caf_is_present): Generate code to check whether an allocatable
	component in a derived typed coarray is allocated on a remote image.
	(caf_this_image_ref): Return true, when only reffing this image.
	(gfc_conv_allocated): Convert allocated queries on allocatable
	components to the library API.
	(conv_intrinsic_move_alloc): Adapt to new interface of
	structure_alloc_comps.
	* trans-openmp.c (gfc_walk_alloc_comps): Likewise.
	(gfc_omp_clause_assign_op): Likewise.
	(gfc_omp_clause_dtor): Likewise.
	* trans-stmt.c (gfc_trans_deallocate): Figure which mode to use when
	deallocating allocatable components in derived type coarras.
	* trans.c (gfc_allocate_using_lib): Renamed to
	gfc_allcate_using_caf_lib.
	(gfc_allocate_allocatable): Set the registration mode/type of caf-
	register calls adapting to all the possible allocatable objects.
	(gfc_deallocate_with_status): Add deregistration mode for allocatable
	components in derived type coarrays.
	(gfc_deallocate_scalar_with_status): Likewise.
	* trans.h (enum gfc_coarray_type): Renamed to gfc_coarray_regtype to
	avoid collision with gfc_coarray_deregtype.

From-SVN: r243021
2016-11-30 14:27:49 +01:00
Andre Vehreschild
0f0565b143 re PR libfortran/77663 (libgfortran/caf/single.c: three minor problems and a lost token)
gcc/testsuite/ChangeLog:

2016-10-01  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/77663
	* gfortran.dg/coarray_send_by_ref_1.f08: New test.

libgfortran/ChangeLog:

2016-10-01  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/77663
	* caf/single.c (caf_internal_error): Fix not terminating va-list.
	(_gfortran_caf_register): Free memory also when other allocs failed.
	(_gfortran_caf_get_by_ref): Fixed style.
	(send_by_ref): Token is now stored at the correct position preventing
	inaccessible tokens, memory loss and possibly crashes.

From-SVN: r240695
2016-10-01 16:00:57 +02:00
Andre Vehreschild
3c9f5092c6 libcaf.h: Add caf_reference_type.
libgfortran/ChangeLog:

2016-09-19  Andre Vehreschild  <vehre@gcc.gnu.org>

	* caf/libcaf.h: Add caf_reference_type.
	* caf/mpi.c: Adapted signature of caf_register().
	* caf/single.c (struct caf_single_token): Added to keep the pointer
	to the memory registered and array descriptor.
	(caf_internal_error): Added convenience interface.
	(_gfortran_caf_register): Adapted to work with caf_single_token and
	return memory in the array descriptor.
	(_gfortran_caf_deregister): Same.
	(assign_char1_from_char4): Fixed style.
	(convert_type): Fixed incorrect conversion.
	(_gfortran_caf_get): Adapted to work with caf_single_token.
	(_gfortran_caf_send): Same.
	(_gfortran_caf_sendget): Same.
	(copy_data): Added to stop repeating it in all _by_ref functions.
	(get_for_ref): Recursive getting of coarray data using a chain of
	references.
	(_gfortran_caf_get_by_ref): Driver for computing the memory needed for
	the get and checking properties of the operation.
	(send_by_ref): Same as get_for_ref but for sending data.
	(_gfortran_caf_send_by_ref): Same like caf_get_by_ref but for sending.
	(_gfortran_caf_sendget_by_ref): Uses get_by_ref and send_by_ref to
	implement sendget for reference chains.
	(_gfortran_caf_atomic_define): Adapted to work with caf_single_token.
	(_gfortran_caf_atomic_ref): Likewise.
	(_gfortran_caf_atomic_cas): Likewise.
	(_gfortran_caf_atomic_op): Likewise.
	(_gfortran_caf_event_post): Likewise.
	(_gfortran_caf_event_wait): Likewise.
	(_gfortran_caf_event_query): Likewise.
	(_gfortran_caf_lock): Likewise.
	(_gfortran_caf_unlock): Likewise.


gcc/testsuite/ChangeLog:

2016-09-19  Andre Vehreschild  <vehre@gcc.gnu.org>

	* gfortran.dg/coarray/alloc_comp_4.f90: New test.
	* gfortran.dg/coarray_38.f90:
	* gfortran.dg/coarray_alloc_comp_1.f08: New test.
	* gfortran.dg/coarray_alloc_comp_2.f08: New test.
	* gfortran.dg/coarray_allocate_7.f08: New test.
	* gfortran.dg/coarray_allocate_8.f08: New test.
	* gfortran.dg/coarray_allocate_9.f08: New test.
	* gfortran.dg/coarray_lib_alloc_1.f90: Adapted scan-tree-dumps to expect
	new caf_register.
	* gfortran.dg/coarray_lib_alloc_2.f90: Same.
	* gfortran.dg/coarray_lib_alloc_3.f90: Same.
	* gfortran.dg/coarray_lib_comm_1.f90: Adapted scan-tree-dumps to expect
	get_by_refs.
	* gfortran.dg/coarray_lib_token_3.f90: Same as for coarray_lib_alloc2.
	* gfortran.dg/coarray_lock_7.f90: Same.
	* gfortran.dg/coarray_poly_5.f90: Same.
	* gfortran.dg/coarray_poly_6.f90: Same.
	* gfortran.dg/coarray_poly_7.f90: Same.
	* gfortran.dg/coarray_poly_8.f90: Same.
	* gfortran.dg/coindexed_1.f90: Changed errors expected.

gcc/fortran/ChangeLog:

2016-09-19  Andre Vehreschild  <vehre@gcc.gnu.org>

	* expr.c (gfc_check_assign): Added flag to control whether datatype
	conversion is allowed.
	* gfortran.h: Added caf-token-tree to gfc_component.  Changed
	prototypes mostly to add whether datatype conversion is allowed.
	* gfortran.texi: Added documentation for the caf_reference_t and the
	caf_*_by_ref function.
	* primary.c (caf_variable_attr): Similar to gfc_variable_attr but
	focused on the needs of coarrays.
	(gfc_caf_attr): Same.
	* resolve.c (resolve_ordinary_assign): Set the conversion allowed
	flag when not in a coarray.
	* trans-array.c (gfc_array_init_size): Moved setting of array
	descriptor's datatype before the alloc, because caf_register needs it.
	(gfc_array_allocate): Changed notion of whether an array is a coarray.
	(gfc_array_deallocate): Same.
	(gfc_alloc_allocatable_for_assignment): Added setting of coarray's
	array descriptor datatype before the register.  And using deregister/
	register to mimmick a realloc for coarrays.
	* trans-decl.c (gfc_build_builtin_function_decls): Corrected signatures
	of old caf-functions and added signature definitions of the _by_ref
	ones.
	(generate_coarray_sym_init): Adapted to new caf_register signature.
	* trans-expr.c (gfc_conv_scalar_to_descriptor): Make sure a constant
	is translated to an lvalue expression before use in an array
	descriptor.
	(gfc_get_ultimate_alloc_ptr_comps_caf_token): New function.  Get the
	last allocatable component's coarray token.
	(gfc_get_tree_for_caf_expr): For top-level object get the coarray
	token and check for unsupported features.
	(gfc_get_caf_token_offset): Getting the offset might procude new
	statements, which now are stored in the pre and post of the current se.
	(gfc_caf_get_image_index): For this image return a call to
	caf_this_image.
	(expr_may_alias_variables): Check that the result is set for testing
	its properties.
	(alloc_scalar_allocatable_for_assignment): Added auto allocation of
	coarray components.
	(gfc_trans_assignment_1): Rewrite an assign to a coarray object to
	be a sendget.
	* trans-intrinsic.c (conv_caf_vector_subscript_elem): Corrected
	wrong comment.
	(compute_component_offset): Compute the correct offset a structure
	member.
	(conv_expr_ref_to_caf_ref): Convert to a chain of refs into
	caf_references.
	(gfc_conv_intrinsic_caf_get): Call caf_get_by_ref instead of caf_get.
	(conv_caf_send): Call caf_*_by_ref for coarrays that need
	reallocation.
	(gfc_conv_intrinsic_function): Adapted to new signuature of the caf
	drivers.
	(conv_intrinsic_atomic_op): Add pre and post statements correctly.
	(conv_intrinsic_atomic_ref): Same.
	(conv_intrinsic_atomic_cas): Same.
	(conv_intrinsic_event_query): Same.
	* trans-stmt.c (gfc_trans_lock_unlock): Same.
	(gfc_trans_event_post_wait): Same.
	(gfc_trans_allocate): Support allocation of allocatable coarrays.
	(gfc_trans_deallocate): And there deallocation.
	* trans-types.c (gfc_typenode_for_spec): Added flag to control whether
	a component is part of coarray.  When so, then add space to store a
	coarray token.
	(gfc_build_array_type): Same.
	(gfc_get_array_descriptor_base): Same.
	(gfc_get_array_type_bounds): Same.
	(gfc_sym_type): Same.
	(gfc_get_derived_type): Same.
	(gfc_get_caf_reference_type): Declare the caf_reference_type.
	* trans-types.h: Prototype changes only.
	* trans.c (gfc_allocate_using_lib): Use the updated caf_register
	signature.
	(gfc_allocate_allocatable): Same.
	(gfc_deallocate_with_status): Same.
	* trans.h: Defined the runtime types for caf_reference_t and the enums.

From-SVN: r240231
2016-09-19 15:45:40 +02:00
Andre Vehreschild
9fe9a3a780 libcaf.h: Add parameter stat to caf_get() and caf_send()'s function prototypes.
libgfortran/ChangeLog:

2016-07-22  Andre Vehreschild  <vehre@gcc.gnu.org>

	* caf/libcaf.h: Add parameter stat to caf_get() and
	caf_send()'s function prototypes.
	* caf/single.c (_gfortran_caf_get): Implement reporting
	error using stat instead of abort().
	(_gfortran_caf_send): Same.
	(_gfortran_caf_sendget): Use NULL for stat when calling
	caf_send().


gcc/testsuite/ChangeLog:

2016-07-22  Andre Vehreschild  <vehre@gcc.gnu.org>

	* gfortran.dg/coarray_stat_2.f90: New test.

From-SVN: r238636
2016-07-22 11:58:50 +02:00
Alessandro Fanfarillo
0daa7ed944 STOP managed by external library when coarrays are used
From-SVN: r234502
2016-03-28 03:05:01 -06:00
Jakub Jelinek
818ab71a41 Update copyright years.
From-SVN: r232055
2016-01-04 15:30:50 +01:00
Tobias Burnus
5df445a2a5 check.c (gfc_check_event_query): New function.
2015-12-02  Tobias Burnus  <burnus@net-b.de>
	    Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>

	* check.c (gfc_check_event_query): New function.
	* dump-parse-tree.c (show_code_node): Handle EXEC_EVENT_POST,
	EXEC_EVENT_WAIT.
	* expr.c (gfc_check_vardef_context): New check for event variables
	definition.
	* gfortran.h (gfc_statement): Add ST_EVENT_POST, ST_EVENT_WAIT.
	(gfc_isym_id): GFC_ISYM_EVENT_QUERY.
	(struct symbol_attribute): New field.
	(gfc_exec_op): Add EXEC_EVENT_POST and EXEC_EVENT_WAIT.
	* gfortran.texi: Document about new events functions and minor
	changes.
	* interface.c (compare_parameter): New check.
	(gfc_procedure_use): New check for explicit procedure interface.
	(add_subroutines): Add event_query.
	* intrinsic.h (gfc_check_event_query,gfc_resolve_event_query):
	New prototypes.
	* iresolve.c (gfc_resolve_event_query): New function.
	* iso-fortran-env.def (event_type): New type.
	* match.c (event_statement,gfc_match_event_post,gfc_match_event_wait):
	New functions.
	(gfc_match_name): New event post and event wait.
	* match.h (gfc_match_event_post,gfc_match_event_wait):
	New prototypes.
	* module.c (ab_attribute): Add AB_EVENT_COMP.
	(attr_bits): Likewise.
	(mio_symbol_attribute): Handle event_comp attribute.
	* parse.c (decode_statement): Add ST_EVENT_POST, ST_EVENT_WAIT.
	(next_statement): Add ST_EVENT_POST, ST_EVENT_WAIT.
	(gfc_ascii_statement): Add ST_EVENT_POST, ST_EVENT_WAIT.
	(parse_derived): Check for event_type components.
	* resolve.c (resolve_allocate_expr): Check for event variable def.
	(resolve_lock_unlock): Renamed to resolve_lock_unlock_event. It
	includes logic for locks and events.
	(gfc_resolve_code): Call it.
	(gfc_resolve_symbol): New check for event variable to be a corray.
	* st.c (gfc_free_statement): Handle new EXEC_EVENT_POST and
	EXEC_EVENT_WAIT.
	* trans-decl.c (gfor_fndecl_caf_event_post,gfor_fndecl_caf_event_wait,
	gfor_fndecl_caf_event_query): New global variables.
	(generate_coarray_sym_init): Checking for event_type.
	(gfc_conv_procedure_call): Check for C bind attribute.
	* trans-intrinsic.c (conv_intrinsic_event_query): New function.
	(conv_intrinsic_move_alloc): Call it.
	* trans-stmt.c (gfc_trans_lock_unlock): Passing address
	of actual argument.
	(gfc_trans_sync): Likewise.
	(gfc_trans_event_post_wait): New function.
	* trans-stmt.h (gfc_trans_event_post_wait): New prototype.
	* trans-types.c (gfc_get_derived_type): Integer_kind as event_type.
	* trans.c (gfc_allocate_using_lib): New argument and logic for events.
	(gfc_allocate_allocatable): Passing new argument.
	(trans_code): Handle EXEC_EVENT_POST, EXEC_EVENT_WAIT.
	* trans.h (gfc_coarray_type): New elements.
	(gfor_fndecl_caf_event_post,gfor_fndecl_caf_event_wait,
	gfor_fndecl_caf_event_query): Declare them.

2015-12-02  Tobias Burnus  <burnus@net-b.de>
	    Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>

	* gfortran.dg/coarray/event_1.f90: New.
	* gfortran.dg/coarray/event_2.f90: New.

Co-Authored-By: Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>

From-SVN: r231208
2015-12-02 21:59:05 +00:00
Thomas Schwinge
17abb5ac38 libgfortran LIBGFOR_MINIMAL enhancements.
Based on GCC trunk r220892, for nvptx-none:

                    === gfortran Summary ===

    # of expected passes            [-31320-]{+32117+}
    # of unexpected failures        [-7222-]{+6821+}
    # of expected failures          78
    # of unresolved testcases       [-6441-]{+6158+}
    # of untested testcases         [-432-]{+391+}
    # of unsupported tests          639

	libgfortran/
	* caf/single.c (caf_runtime_error): Revert 2014-11-28 changes.
	* runtime/minimal.c (STRERR_MAXSZ): Don't define.
	(runtime_error_at, sys_abort): Bring more in line with the
	non-LIBGFOR_MINIMAL code.
	(runtime_warning_at, internal_error): New functions.

From-SVN: r221363
2015-03-11 22:42:56 +01:00
Alessandro Fanfarillo
9315dff064 trans.h (caf_sync_memory): New function decl tree.
2015-03-10  Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>
            Tobias Burnus  <burnus@net-b.de>

        * trans.h (caf_sync_memory): New function decl tree.
        * trans-decl.c (gfc_build_builtin_function_decls): Define it.
        (create_main_function): Don't call sync_synchronize and leave
        it to the CAF library.
        * trans-stmt.c (gfc_trans_stop): Ditto.
        (gfc_trans_sync): Ditto; add call library call for sync memory.

        * gfortran.dg/coarray_sync_memory.f90: New.

        * caf/libcaf.h (_gfortran_caf_sync_memory): New prototype.
        * caf/single.c (_gfortran_caf_sync_memory): Implement.
        (_gfortran_caf_sync_all, _gfortran_caf_sync_image): Add
        __asm__ __volatile___ ("":::"memory").


Co-Authored-By: Tobias Burnus <burnus@net-b.de>

From-SVN: r221329
2015-03-10 18:58:01 +01:00
Jakub Jelinek
5624e564d2 Update copyright years.
From-SVN: r219188
2015-01-05 13:33:28 +01:00
Tobias Burnus
09de7c2578 single.c (_gfortran_caf_co_reduce): New function.
2015-01-02  Tobias Burnus  <burnus@net-b.de>

        * caf/single.c (_gfortran_caf_co_reduce): New function.
        * caf/libcaf.h (_gfortran_caf_co_reduce): New prototype.

2015-01-02  Tobias Burnus  <burnus@net-b.de>

        * gfortran.dg/coarray/collectives_4.f90: New.

From-SVN: r219148
2015-01-02 18:42:52 +01:00
Bernd Schmidt
ee95f9288a Add support for a minimal version of libgfortran for accelerator targets.
* Makefile.am (AM_CFLAGS): Add -DLIBGFOR_MINIMAL if LIBGFOR_MINIMAL.
        (gfor_io_src, gfor_heper_src, gfor_src): Split into minimal and
        always included sources.
        * Makefile.in: Regenerate.
        * configure.ac (LIBGFOR_MINIMAL): New AM_CONDITIONAL.
        * configure: Regenerate.
        * caf/single.c (caf_runtime_error): Don't print messages if
        LIBGFOR_MINIMAL.
        * runtime/compile_options.c (fatal_error_in_progress,
        show_signal, backtrace_handler, maybe_find_addr2line): Guard with
        !defined LIBGFOR_MINIMAL.
        (set_options): Likewise for the backtrace code.
        * runtime/minimal.c: New file.

From-SVN: r218170
2014-11-28 17:39:15 +00:00
Tobias Burnus
a16ee37946 check.c (check_co_collective): Renamed from
2014-09-25  Tobias Burnus  <burnus@net-b.de>

gcc/fortran
        * check.c (check_co_collective): Renamed from
        * check_co_minmaxsum,
        handle co_reduce.
        (gfc_check_co_minmax, gfc_check_co_sum): Update call.
        (gfc_check_co_broadcast, gfc_check_co_reduce): New.
        * gfortran.h (gfc_isym_id): Add GFC_ISYM_CO_BROADCAST and
        GFC_ISYM_CO_REDUCE.
        * intrinsic.c (add_subroutines): Add co_reduce and co_broadcast.
        * intrinsic.h (gfc_check_co_broadcast, gfc_check_co_reduce): Add
        proto types.
        * intrinsic.texi (CO_BROADCAST): Add.
        * trans.h (gfor_fndecl_co_broadcast): New.
        * trans-decl.c (gfor_fndecl_co_broadcast): Ditto.
        (gfc_build_builtin_function_decls): Add decl for it,
        * trans-intrinsic.c (conv_co_collective): Renamed from
        conv_co_minmaxsum. Handle co_reduce.
        (gfc_conv_intrinsic_subroutine): Handle co_reduce.

gcc/testsuite/
        * gfortran.dg/coarray/collectives_3.f90: New.
        * gfortran.dg/coarray_collectives_9.f90: New.
        * gfortran.dg/coarray_collectives_10.f90: New.
        * gfortran.dg/coarray_collectives_11.f90: New.
        * gfortran.dg/coarray_collectives_12.f90: New.

libgfortran/
        * caf/libcaf.h (_gfortran_caf_co_broadcast): New prototype.
        * caf/single.c (_gfortran_caf_co_broadcast): New.

From-SVN: r215579
2014-09-25 08:07:15 +02:00
Tobias Burnus
93e2e0465e trans-decl.c (gfc_build_builtin_function_decls): Add may_require_tmp dummy argument.
2014-08-31  Tobias Burnus  <burnus@net-b.de>

gcc/fortran/
        * trans-decl.c (gfc_build_builtin_function_decls): Add
        may_require_tmp dummy argument.
        * trans-intrinsic.c (gfc_conv_intrinsic_caf_get,
        conv_caf_send): Handle may_require_tmp argument.
        (gfc_conv_intrinsic_function): Update call.
        * gfortran.texi (_gfortran_caf_send, _gfortran_caf_get,
        _gfortran_caf_sendget): Update interface description.

gcc/testsuite/
        * gfortran.dg/coarray_lib_comm_1.f90: New.

libgfortran/
        * caf/libcaf.h (_gfortran_caf_send, _gfortran_caf_get,
        _gfortran_caf_sendget): Update prototype.
        * caf/single.c (_gfortran_caf_send, _gfortran_caf_get,
        _gfortran_caf_sendget): Handle may_require_tmp.

From-SVN: r214764
2014-08-31 08:32:06 +02:00
Tobias Burnus
bc0229f9f6 gfortran.texi (caf_register_t): Add CAF_REGTYPE_CRITICAL.
gcc/fortran/
2014-08-14  Tobias Burnus  <burnus@net-b.de>

        * gfortran.texi (caf_register_t): Add CAF_REGTYPE_CRITICAL.
        (_gfortran_caf_register): Update for locking/critical.
        (_gfortran_caf_lock, _gfortran_caf_unlock): Add.
        * resolve.c (resolve_critical): New.
        (gfc_resolve_code): Call it.
        * trans-decl.c (gfor_fndecl_caf_critical,
        gfor_fndecl_caf_end_critical): Remove.
        (gfor_fndecl_caf_lock, gfor_fndecl_caf_unlock): Add.
        (gfc_build_builtin_function_decls): Remove critical,
        assign locking declarations.
        (generate_coarray_sym_init): Handle locking and
        critical variables.
        * trans-stmt.c (gfc_trans_critical): Add calls to
        lock/unlock libcaf functions.
        * trans.h (gfc_coarray_type): Update locking, add
        critical enum values.
        (gfor_fndecl_caf_critical, gfor_fndecl_caf_end_critical): Remove.
        (gfor_fndecl_caf_lock, gfor_fndecl_caf_unlock): Add.

libgfortran/
2014-08-14  Tobias Burnus  <burnus@net-b.de>

        * caf/libcaf.h (caf_register_t): Update for critical.
        (_gfortran_caf_critical, _gfortran_caf_end_critical): Remove.
        (_gfortran_caf_lock, _gfortran_caf_unlock): Add.
        * caf/single.c (_gfortran_caf_register): Handle locking
        variables.
        (_gfortran_caf_sendget): Re-name args for consistency.
        (_gfortran_caf_lock, _gfortran_caf_unlock): Add.

From-SVN: r213979
2014-08-14 20:39:15 +02:00
Tobias Burnus
42a8246dbd libgfortran.h (libcaf_atomic_codes): Add.
2014-07-12  Tobias Burnus  <burnus@net-b.de>

gcc/fortran/
        * libgfortran.h (libcaf_atomic_codes): Add.
        * trans-decl.c (gfor_fndecl_caf_atomic_def,
        gfor_fndecl_caf_atomic_ref, gfor_fndecl_caf_atomic_cas,
        gfor_fndecl_caf_atomic_op): New variables.
        (gfc_build_builtin_function_decls): Initialize them.
        * trans.h (gfor_fndecl_caf_atomic_def,
        gfor_fndecl_caf_atomic_ref, gfor_fndecl_caf_atomic_cas,
        gfor_fndecl_caf_atomic_op): New variables.
        * trans-intrinsic.c (conv_intrinsic_atomic_op,
        conv_intrinsic_atomic_ref, conv_intrinsic_atomic_cas):
        Add library calls with -fcoarray=lib.

libgfortran/
        * caf/libcaf.h (_gfortran_caf_atomic_define,
        _gfortran_caf_atomic_ref, _gfortran_caf_atomic_op,
        _gfortran_caf_atomic_cas): New prototypes.
        * caf/single.c (_gfortran_caf_atomic_define,
        _gfortran_caf_atomic_ref, _gfortran_caf_atomic_op,
        _gfortran_caf_atomic_cas): New functions.

From-SVN: r212484
2014-07-12 21:02:57 +02:00
Tobias Burnus
5c75088c80 resolve.c (resolve_ordinary_assign): Don't invoke caf_send when assigning a coindexed RHS scalar to a noncoindexed...
2014-06-25  Tobias Burnus  <burnus@net-b.de>

fortran/
        * resolve.c (resolve_ordinary_assign): Don't invoke caf_send
        when assigning a coindexed RHS scalar to a noncoindexed LHS
        array.
        * trans-intrinsic.c (conv_caf_send): Do numeric type conversion
        for a noncoindexed scalar RHS.

gcc/testsuite/
        * gfortran.dg/coarray/coindexed_1.f90: New.

libgfortran/
        * caf/single.c (assign_char4_from_char1,
        * assign_char1_from_char4,
        convert_type): New static functions.
        (_gfortran_caf_get, _gfortran_caf_send): Use them.

From-SVN: r211993
2014-06-25 22:31:32 +02:00
Tobias Burnus
7f6c4159bf trans-intrinsic.c (conv_co_minmaxsum): Fix argument passing.
gcc/fortran/
2014-06-19  Tobias Burnus  <burnus@net-b.de>

        * trans-intrinsic.c (conv_co_minmaxsum): Fix argument
        passing.

gcc/testsuite/
2014-06-19  Tobias Burnus  <burnus@net-b.de>

        * gfortran.dg/coarray/collectives_2.f90: Extend
        and make valid.

libgfortran/
2014-06-19  Tobias Burnus  <burnus@net-b.de>

        * caf/single.c (_gfortran_caf_co_sum, _gfortran_caf_co_max,
        _gfortran_caf_co_min): Fix stat setting.

From-SVN: r211816
2014-06-19 09:16:34 +02:00
Tobias Burnus
b511626828 check.c (gfc_check_atomic, [...]): Use argument for GFC_ISYM_CAF_GET.
gcc/fortran/
2014-06-17  Tobias Burnus  <burnus@net-b.de>

        * check.c (gfc_check_atomic, gfc_check_atomic_def):
        Use argument for GFC_ISYM_CAF_GET.
        * resolve.c (resolve_variable): Enable CAF_GET insertion.
        (resolve_lock_unlock): Remove GFC_ISYM_CAF_GET.
        (resolve_ordinary_assign): Enable CAF_SEND insertion.
        * trans-const.c (gfc_build_string_const,
        gfc_build_wide_string_const): Set TYPE_STRING_FLAG.
        * trans-decl.c (gfor_fndecl_caf_get, gfor_fndecl_caf_send,
        gfor_fndecl_caf_sendget): New global variables.
        (gfc_build_builtin_function_decls): Initialize them;
        update co_min/max/sum initialization.
        * trans-expr.c (gfc_get_tree_for_caf_expr): Renamed from
        get_tree_for_caf_expr and removed static.
        (gfc_conv_procedure_call): Update call.
        * trans-intrinsic.c (caf_get_image_index,
        conv_caf_vector_subscript_elem, conv_caf_vector_subscript,
        get_caf_token_offset, gfc_conv_intrinsic_caf_get,
        conv_caf_send): New.
        (gfc_conv_intrinsic_function, gfc_conv_intrinsic_subroutine,
        gfc_walk_intrinsic_function): Handle CAF_GET and CAF_SEND.
        (conv_co_minmaxsum): Update call for remove unused vector
        subscript.
        (conv_intrinsic_atomic_def, conv_intrinsic_atomic_ref):
        Skip a CAF_GET of the argument.
        * trans-types.c (gfc_get_caf_vector_type): New.
        * trans-types.h (gfc_get_caf_vector_type): New.
        * trans.h (gfor_fndecl_caf_get, gfor_fndecl_caf_send,
        gfor_fndecl_caf_sendget): New global variables.
        (gfc_get_tree_for_caf_expr): New prototypes.

libgfortran/
2014-06-17  Tobias Burnus  <burnus@net-b.de>

        * caf/libcaf.h (gfc_descriptor_t): New typedef.
        (caf_vector_t): Update.
        (_gfortran_caf_co_sum, _gfortran_caf_co_max, _gfortran_caf_co_min):
        Remove vector-subscript argument.
        (_gfortran_caf_co_send, _gfortran_caf_co_get,
        _gfortran_caf_co_sendget): New.
        * caf/single.c (_gfortran_caf_co_sum, _gfortran_caf_co_max,
        _gfortran_caf_co_min): Remove vector-subscript argument.
        (_gfortran_caf_co_send, _gfortran_caf_co_get,
        _gfortran_caf_co_sendget): New.

gcc/testsuite/
2014-06-17  Tobias Burnus  <burnus@net-b.de>
            Alessandro Fanfarillo <alessandro.fanfarillo@gmail.com>

        * gfortran.dg/coarray/send_array.f90: New.
        * gfortran.dg/coarray/get_array.f90: New.
        * gfortran.dg/coarray/sendget_array.f90: New.
        * gfortran.dg/coarray/collectives_1.f90: Correct subroutine
        names.
        * gfortran.dg/coarray/collectives_2.f90: New.



Co-Authored-By: Alessandro Fanfarillo <alessandro.fanfarillo@gmail.com>

From-SVN: r211748
2014-06-17 22:54:14 +02:00
Tobias Burnus
a9fe68774e trans-intrinsic.c (gfc_build_builtin_function_decls): Change type of second argument to int.
2014-05-11  Tobias Burnus  <burnus@net-b.de>

       * trans-intrinsic.c (gfc_build_builtin_function_decls):
       Change type of second argument to int.

2014-05-11  Tobias Burnus  <burnus@net-b.de>

       * caf/libcaf.h (_gfortran_caf_num_images): Change type of
       second argument to int.
       * caf/mpi.c (_gfortran_caf_num_images): Ditto.
       * caf/single.c (_gfortran_caf_num_images): Ditto.

From-SVN: r210311
2014-05-11 20:25:55 +02:00
Tobias Burnus
d62cf3dfbe check.c (check_co_minmaxsum, [...]): New.
gcc/fortran/
2014-05-08  Tobias Burnus  <burnus@net-b.de>

        * check.c (check_co_minmaxsum, gfc_check_co_minmax,
        gfc_check_co_sum): New.
        * error.c (gfc_notify_std): Update -std=f2008ts.
        * gfortran.h (gfc_isym_id): Add GFC_ISYM_CO_MAX,
        GFC_ISYM_CO_MIN, GFC_ISYM_CO_SUM.
        * intrinsic.h (gfc_check_co_minmax,
        gfc_check_co_sum): Declare.
        * intrinsic.c (add_subroutines): Add co_min, co_max
        and co_sum.
        (gfc_check_intrinsic_standard): Update text for
        -std=f2008ts.
        * intrinsic.texi (CO_MIN, CO_MAX, CO_SUM): Document
        them.
        * invoke.texi (-std=f2008ts): Update wording.
        * trans.h (gfor_fndecl_co_max,
        gfor_fndecl_co_min, gfor_fndecl_co_sum): Define.
        * trans-decl.c (gfor_fndecl_co_max,
        gfor_fndecl_co_min, gfor_fndecl_co_sum): Define.
        (gfc_build_builtin_function_decls): Assign to it.
        * trans-intrinsic.c (conv_co_minmaxsum): New.
        (gfc_conv_intrinsic_subroutine): Call it.

libgfortran/
2014-05-08  Tobias Burnus  <burnus@net-b.de>

        * caf/libcaf.h (caf_vector_t, _gfortran_caf_co_sum,
        _gfortran_caf_co_min, _gfortran_caf_co_max): Declare
        * caf/single.c

gcc/testsuite/
2014-05-08  Tobias Burnus  <burnus@net-b.de>

        * gfortran.dg/coarray_collectives_1.f90: New.
        * gfortran.dg/coarray_collectives_2.f90: New.
        * gfortran.dg/coarray_collectives_3.f90: New.
        * gfortran.dg/coarray_collectives_4.f90: New.
        * gfortran.dg/coarray_collectives_5.f90: New.
        * gfortran.dg/coarray_collectives_6.f90: New.
        * gfortran.dg/coarray/collectives_1.f90: New.
        * gfortran.dg/assumed_rank_5.f90: Update dg-error.
        * gfortran.dg/assumed_type_4.f90: Update dg-error.
        * gfortran.dg/bind_c_array_params.f03: Update dg-error.
        * gfortran.dg/bind_c_usage_28.f90: Update dg-error.
        * gfortran.dg/c_funloc_tests_5.f03: Update dg-error.
        * gfortran.dg/c_funloc_tests_6.f90: Update dg-error.
        * gfortran.dg/c_loc_tests_11.f03: Update dg-error.

From-SVN: r210223
2014-05-08 18:55:23 +02:00
Tobias Burnus
a8a5f4a972 gfortran.h (gfc_init_coarray_decl): Remove.
2014-04-30  Tobias Burnus  <burnus@net-b.de>

        * gfortran.h (gfc_init_coarray_decl): Remove.
        * parse.c (translate_all_program_units): Remove call to it.
        (gfc_parse_file): Update call.
        * trans.h (gfor_fndecl_caf_this_image,
        gfor_fndecl_caf_num_images): Add.
        (gfort_gvar_caf_num_images,
        gfort_gvar_caf_this_image): Remove.
        * trans-decl.c (gfor_fndecl_caf_this_image,
        gfor_fndecl_caf_num_images): Add.
        (gfort_gvar_caf_num_images,
        gfort_gvar_caf_this_image): Remove.
        (gfc_build_builtin_function_decls): Init new decl.
        (gfc_init_coarray_dec): Remove.
        (create_main_function): Change calls.
        * trans-intrinsic.c (trans_this_image, trans_image_index,
        conv_intrinsic_cobound): Generate call to new library function
        instead of to a static variable.
        * trans-stmt.c (gfc_trans_sync): Ditto.

2014-04-30  Tobias Burnus  <burnus@net-b.de>

        * gfortran.dg/coarray_lib_this_image_1.f90: New.
        * gfortran.dg/coarray_lib_this_image_2.f90: New.

2014-04-30  Tobias Burnus  <burnus@net-b.de>

        * caf/libcaf.h (_gfortran_caf_this_image,
        * _gfortran_caf_num_images):
        New prototypes.
        (_gfortran_caf_init): Change prototype.
        (mpi_token_t): New typedef.
        (TOKEN): New define.
        * caf/mpi.c (_gfortran_caf_this_image,
        * _gfortran_caf_num_images):
        New functions.
        (_gfortran_caf_init): Update.
        (_gfortran_caf_finalize, _gfortran_caf_register,
        _gfortran_caf_deregister): Use mpi_token_t.
        * caf/single.c (_gfortran_caf_this_image,
        * _gfortran_caf_num_images):
        New functions.
        (_gfortran_caf_init): Update.
        (_gfortran_caf_finalize, _gfortran_caf_register,
        _gfortran_caf_deregister): Use mpi_token_t, simplify.

From-SVN: r209951
2014-04-30 21:02:23 +02:00
Richard Sandiford
f0bcf62899 Update copyright years in libgfortran/
From-SVN: r206296
2014-01-02 22:25:45 +00:00
David Edelsohn
13c4975c2d libcaf.h (_gfortran_caf_critical): Add a prototype.
* caf/libcaf.h (_gfortran_caf_critical): Add a prototype.
        (_gfortran_caf_end_critical): Same.

From-SVN: r198613
2013-05-05 19:47:22 -04:00
Richard Sandiford
e3c063ceda Update copyright years in libgfortran.
From-SVN: r195167
2013-01-14 18:20:58 +00:00
Tobias Burnus
5d81ddd07f 2012-01-06 Tobias Burnus <burnus@net-b.de>
* trans-openmp.c (gfc_omp_clause_dtor,
        * gfc_trans_omp_array_reduction):
        Update call to gfc_trans_dealloc_allocated.
        * trans.c (gfc_allocate_using_malloc): Fix spacing.
        (gfc_allocate_allocatable): For gfc_allocate_using_lib, jump to
        label_finish when an error occurs.
        (gfc_deallocate_with_status): Call caf_deregister for -fcoarray=lib.
        * trans.h (gfc_allocate_allocatable,
        * gfc_deallocate_with_status):
        Update prototype.
        (gfor_fndecl_caf_deregister): New tree symbol.
        * trans-expr.c (gfc_conv_procedure_call): Update
        gfc_deallocate_with_status and gfc_trans_dealloc_allocated calls.
        * trans-array.c (gfc_array_allocate,
        * gfc_trans_dealloc_allocated,
        structure_alloc_comps, gfc_trans_deferred_array): Ditto.
        (gfc_array_deallocate): Handle coarrays with -fcoarray=lib.
        * trans-array.h (gfc_array_deallocate, gfc_array_allocate,
        gfc_trans_dealloc_allocated): Update prototypes.
        * trans-stmt.c (gfc_trans_sync): Fix indentation.
        (gfc_trans_allocate): Fix errmsg padding and label handling.
        (gfc_trans_deallocate): Ditto and handle -fcoarray=lib.
        * expr.c (gfc_is_coarray): Fix algorithm for BT_CLASS.
        * libgfortran.h (GFC_STAT_STOPPED_IMAGE): Use large value
        to avoid other stats accidentally matching this one.
        * trans-decl.c (gfor_fndecl_caf_deregister): New global var.
        (gfc_build_builtin_function_decls): Fix prototype decl of caf_register
        and add decl for caf_deregister.
        (gfc_trans_deferred_vars): Handle CAF vars with -fcoarrays=lib.
        * trans-intrinsic.c (conv_intrinsic_move_alloc): Update call to
        gfc_deallocate_with_status.

2012-01-06  Tobias Burnus <burnus@net-b.de>

        * caf/single.c (_gfortran_caf_register,
        * _gfortran_caf_deregister):
        Fix token handling.
        * caf/mpi.c  (_gfortran_caf_register, _gfortran_caf_deregister):
        * Ditto.
        * caf/libcaf.h (STAT_STOPPED_IMAGE): Sync with libgfortran.h.
        (_gfortran_caf_register, _gfortran_caf_deregister): Update prototype.

2012-01-06  Tobias Burnus <burnus@net-b.de>

        * gfortran.dg/deallocate_stat_2.f90: New.
        * coarray/allocate_errgmsg.f90: New.
        * gfortran.dg/coarray_lib_alloc_1.f90: New.
        * gfortran.dg/coarray_lib_alloc_2.f90: New.
        * coarray/subobject_1.f90: Fix for num_images > 1.
        * gfortran.dg/deallocate_stat.f90: Update due to changed
        stat= handling.

From-SVN: r182951
2012-01-06 14:38:49 +01:00
Tobias Burnus
86187d0fe0 trans-decl.c (generate_coarray_sym_init): Use GFC_CAF_COARRAY_STATIC for static coarrays.
gcc/fortran/
2011-08-29  Tobias Burnus  <burnus@net-b.de>

        * trans-decl.c (generate_coarray_sym_init): Use
        GFC_CAF_COARRAY_STATIC for static coarrays.

libgfortan/
2011-08-29  Tobias Burnus  <burnus@net-b.de>

        * caf/libcaf.h (_gfortran_caf_deregister): Update prototype.
        * caf/mpi.c (_gfortran_caf_deregister): Modify prototype,
        actually free memory and add error diagnostic.
        (_gfortran_caf_finalize): Add additional free calls.
        * caf/single.c (_gfortran_caf_deregister): Modify prototype,
        actually free memory and add error diagnostic.
        (_gfortran_caf_finalize): Add additional free calls.

From-SVN: r178193
2011-08-29 12:33:09 +02:00
Daniel Carrera
c0f1579204 mpi.c (caf_runtime_error): Change fprintf to vfprintf.
2011-07-15  Daniel Carrera  <dcarrera@gmail.com>

	* caf/mpi.c (caf_runtime_error): Change fprintf to vfprintf.
	* caf/single.c (caf_runtime_error): Ditto.

From-SVN: r176340
2011-07-15 22:39:03 +00:00
Daniel Carrera
8019694098 Remove error parameter from caf_runtime_error. Add caf_runtime_error to single.c.
From-SVN: r176278
2011-07-14 15:49:00 +00:00
Tobias Burnus
41de45c6a0 mpi.c (runtime_error): New function.
2011-07-09  Tobias Burnus  <burnus@net-b.de>
            Daniel Carrera  <dcarrera@gmail.com>

        * caf/mpi.c (runtime_error): New function.
        (_gfortran_caf_register): Use it.
        (_gfortran_caf_sync_all): Use it, add STAT_STOPPED_IMAGE
        as possible status value.
        (_gfortran_caf_sync_images): Ditto.


Co-Authored-By: Daniel Carrera <dcarrera@gmail.com>

From-SVN: r176080
2011-07-09 16:29:50 +02:00
Tobias Burnus
4054bc52d6 trans.c (gfc_allocate_with_status): Call _gfortran_caf_register with NULL arguments for (new) stat=/errmsg= arguments.
2011-07-07  Tobias Burnus  <burnus@net-b.de>

        * trans.c (gfc_allocate_with_status): Call _gfortran_caf_register
        with NULL arguments for (new) stat=/errmsg= arguments.

2011-07-07  Tobias Burnus  <burnus@net-b.de>

        * libcaf.h (__attribute__, unlikely, likely): New macros.
        (caf_register_t): Update comment.
        (_gfortran_caf_register): Add stat, errmsg, errmsg_len arguments.
        * single.c (_gfortran_caf_register): Ditto; add error diagnostics.
        * mpi.c (_gfortran_caf_register): Ditto.
        (caf_is_finalized): New global variable.
        (_gfortran_caf_finalize): Use it.

From-SVN: r175966
2011-07-07 14:46:18 +02:00
Daniel Carrera
0a1138af63 single.c (_gfortran_caf_register): Store the address of all static coarrays in a linked list.
2011-06-17  Daniel Carrera  <dcarrera@gmail.com>

        * caf/single.c (_gfortran_caf_register): Store the address
        of all static coarrays in a linked list.
        (_gfortran_caf_finalize): Free memory of staic coarrays.
        * caf/mpi.c (_gfortran_caf_register): Store the address
        of all static coarrays in a linked list. Initialize MPI
        if necessary.
        (_gfortran_caf_finalize): Free memory of staic coarrays.
        (_gfortran_caf_init): Check if MPI is already initialized
        before initializing again.
        * caf/libcaf.h: Add a type to caf_register_t to distinguish
        static coarrays and add the type caf_static_t to make the
        linked list of static coarrays.

From-SVN: r175124
2011-06-17 01:09:36 +02:00
Daniel Carrera
f5c01f5bde trans-decl.c (gfc_build_builtin_function_decls): Updated declaration of caf_sync_all and caf_sync_images.
gcc/fortran/
2011-06-10  Daniel Carrera  <dcarrera@gmail.com>

        * trans-decl.c (gfc_build_builtin_function_decls):
        Updated declaration of caf_sync_all and caf_sync_images.
        * trans-stmt.c (gfc_trans_sync): Function
        can now handle a "stat" variable that has an integer type
        different from integer_type_node.

libgfortran/
2011-06-10  Daniel Carrera  <dcarrera@gmail.com>

        * caf/mpi.c (_gfortran_caf_sync_all,
        _gfortran_caf_sync_images): Functions have void return type
        and move status into parameter list.
        * caf/single.c (_gfortran_caf_sync_all,
        _gfortran_caf_sync_images): Functions have void return type
        and move status into parameter list.
        * caf/libcaf.h (_gfortran_caf_sync_all,
        _gfortran_caf_sync_images): Functions have void return type
        and move status into parameter list.

gcc/testsuite/
2011-06-10  Daniel Carrera  <dcarrera@gmail.com>

        * gfortran.dg/coarray/sync_1.f90: New test for
        "SYNC ALL", "SYNC MEMORY" and "SYNC IMAGES".

From-SVN: r174896
2011-06-10 12:22:24 +02:00
Tobias Burnus
cc9ae24cbe re PR fortran/18918 (Eventually support Fortran 2008's coarrays [co-arrays])
2011-05-06  Tobias Burnus  <burnus@net-b.de>

        PR fortran/18918
        * caf/libcaf.h: Cleanup headers.
        (_gfortran_caf_critical, _gfortran_caf_end_critical): Make stub.
        (caf_register_t): New enum.
        (_gfortran_caf_register, _gfortran_caf_deregister): New prototype.
        * caf/single.c (_gfortran_caf_critical,
        _gfortran_caf_end_critical): Remove.
        (_gfortran_caf_register, _gfortran_caf_deregister): New functions.
        * caf/mpi.c (_gfortran_caf_critical,
        _gfortran_caf_end_critical): Remove.
        (_gfortran_caf_register, _gfortran_caf_deregister): New functions.
        (caf_world_window): Remove global variable.
        (_gfortran_caf_init): Fix off-by-one error of this_image.

From-SVN: r173505
2011-05-06 20:35:00 +02:00
Tobias Burnus
6eb87b330f re PR fortran/18918 (Eventually support Fortran 2008's coarrays [co-arrays])
2011-04-06  Tobias Burnus  <burnus@net-b.de>

        PR fortran/18918
        * caf/mpi.c (_gfortran_caf_init, _gfortran_caf_finalize):
        Add global variable caf_mpi_initialized and use it for when
        finalizing.

From-SVN: r172059
2011-04-06 20:29:55 +02:00
Tobias Burnus
5092eb960c re PR fortran/18918 (Eventually support Fortran 2008's coarrays [co-arrays])
2011-03-27  Tobias Burnus  <burnus@net-b.de>

        PR fortran/18918
        * caf/libcaf.h: New - coarray communication library.
        * caf/mpi.c: New.
        * caf/single.c: New.

From-SVN: r171570
2011-03-27 11:01:34 +02:00