2011-03-27 11:01:34 +02:00
|
|
|
/* MPI implementation of GNU Fortran Coarray Library
|
2014-01-02 23:25:45 +01:00
|
|
|
Copyright (C) 2011-2014 Free Software Foundation, Inc.
|
2011-03-27 11:01:34 +02:00
|
|
|
Contributed by Tobias Burnus <burnus@net-b.de>
|
|
|
|
|
|
|
|
This file is part of the GNU Fortran Coarray Runtime Library (libcaf).
|
|
|
|
|
|
|
|
Libcaf is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
Libcaf is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
permissions described in the GCC Runtime Library Exception, version
|
|
|
|
3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License and
|
|
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#include "libcaf.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2011-05-06 20:35:00 +02:00
|
|
|
#include <string.h> /* For memcpy. */
|
2011-07-09 16:29:50 +02:00
|
|
|
#include <stdarg.h> /* For variadic arguments. */
|
2011-03-27 11:01:34 +02:00
|
|
|
#include <mpi.h>
|
|
|
|
|
2011-05-06 20:35:00 +02:00
|
|
|
|
2011-03-27 11:01:34 +02:00
|
|
|
/* Define GFC_CAF_CHECK to enable run-time checking. */
|
|
|
|
/* #define GFC_CAF_CHECK 1 */
|
|
|
|
|
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
|
|
|
typedef void ** mpi_token_t;
|
|
|
|
#define TOKEN(X) ((mpi_token_t) (X))
|
2011-03-27 11:01:34 +02:00
|
|
|
|
|
|
|
static void error_stop (int error) __attribute__ ((noreturn));
|
|
|
|
|
|
|
|
/* Global variables. */
|
2011-04-06 20:29:55 +02:00
|
|
|
static int caf_mpi_initialized;
|
2011-03-27 11:01:34 +02:00
|
|
|
static int caf_this_image;
|
|
|
|
static int caf_num_images;
|
2011-07-07 14:46:18 +02:00
|
|
|
static int caf_is_finalized;
|
2011-03-27 11:01:34 +02:00
|
|
|
|
2011-06-17 01:09:36 +02:00
|
|
|
caf_static_t *caf_static_list = NULL;
|
|
|
|
|
2011-03-27 11:01:34 +02:00
|
|
|
|
2011-07-14 17:49:00 +02:00
|
|
|
/* Keep in sync with single.c. */
|
2011-07-09 16:29:50 +02:00
|
|
|
static void
|
2011-07-14 17:49:00 +02:00
|
|
|
caf_runtime_error (const char *message, ...)
|
2011-07-09 16:29:50 +02:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
fprintf (stderr, "Fortran runtime error on image %d: ", caf_this_image);
|
|
|
|
va_start (ap, message);
|
2011-07-16 00:39:03 +02:00
|
|
|
vfprintf (stderr, message, ap);
|
2011-07-09 16:29:50 +02:00
|
|
|
va_end (ap);
|
|
|
|
fprintf (stderr, "\n");
|
|
|
|
|
|
|
|
/* FIXME: Shutdown the Fortran RTL to flush the buffer. PR 43849. */
|
|
|
|
/* FIXME: Do some more effort than just MPI_ABORT. */
|
2011-07-14 17:49:00 +02:00
|
|
|
MPI_Abort (MPI_COMM_WORLD, EXIT_FAILURE);
|
2011-07-09 16:29:50 +02:00
|
|
|
|
|
|
|
/* Should be unreachable, but to make sure also call exit. */
|
2011-07-14 17:49:00 +02:00
|
|
|
exit (EXIT_FAILURE);
|
2011-07-09 16:29:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-27 11:01:34 +02:00
|
|
|
/* Initialize coarray program. This routine assumes that no other
|
|
|
|
MPI initialization happened before; otherwise MPI_Initialized
|
|
|
|
had to be used. As the MPI library might modify the command-line
|
|
|
|
arguments, the routine should be called before the run-time
|
|
|
|
libaray is initialized. */
|
|
|
|
|
|
|
|
void
|
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
|
|
|
_gfortran_caf_init (int *argc, char ***argv)
|
2011-03-27 11:01:34 +02:00
|
|
|
{
|
2011-06-17 01:09:36 +02:00
|
|
|
if (caf_num_images == 0)
|
|
|
|
{
|
|
|
|
/* caf_mpi_initialized is only true if the main program is
|
|
|
|
not written in Fortran. */
|
|
|
|
MPI_Initialized (&caf_mpi_initialized);
|
|
|
|
if (!caf_mpi_initialized)
|
|
|
|
MPI_Init (argc, argv);
|
|
|
|
|
|
|
|
MPI_Comm_size (MPI_COMM_WORLD, &caf_num_images);
|
|
|
|
MPI_Comm_rank (MPI_COMM_WORLD, &caf_this_image);
|
|
|
|
caf_this_image++;
|
|
|
|
}
|
2011-03-27 11:01:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-06 20:29:55 +02:00
|
|
|
/* Finalize coarray program. */
|
2011-03-27 11:01:34 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
_gfortran_caf_finalize (void)
|
|
|
|
{
|
2011-06-17 01:09:36 +02:00
|
|
|
while (caf_static_list != NULL)
|
|
|
|
{
|
2011-08-29 12:33:09 +02:00
|
|
|
caf_static_t *tmp = caf_static_list->prev;
|
|
|
|
|
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
|
|
|
free (TOKEN (caf_static_list->token)[caf_this_image-1]);
|
|
|
|
free (TOKEN (caf_static_list->token));
|
2011-08-29 12:33:09 +02:00
|
|
|
free (caf_static_list);
|
|
|
|
caf_static_list = tmp;
|
2011-06-17 01:09:36 +02:00
|
|
|
}
|
|
|
|
|
2011-04-06 20:29:55 +02:00
|
|
|
if (!caf_mpi_initialized)
|
|
|
|
MPI_Finalize ();
|
2011-07-07 14:46:18 +02:00
|
|
|
|
|
|
|
caf_is_finalized = 1;
|
2011-03-27 11:01:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
int
|
|
|
|
_gfortran_caf_this_image (int distance __attribute__ ((unused)))
|
|
|
|
{
|
|
|
|
return caf_this_image;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
_gfortran_caf_num_images (int distance __attribute__ ((unused)),
|
2014-05-11 20:25:55 +02:00
|
|
|
int failed __attribute__ ((unused)))
|
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
|
|
|
{
|
|
|
|
return caf_num_images;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-06 20:35:00 +02:00
|
|
|
void *
|
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
|
|
|
_gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token,
|
2011-07-07 14:46:18 +02:00
|
|
|
int *stat, char *errmsg, int errmsg_len)
|
2011-05-06 20:35:00 +02:00
|
|
|
{
|
2011-06-17 01:09:36 +02:00
|
|
|
void *local;
|
2011-07-07 14:46:18 +02:00
|
|
|
int err;
|
|
|
|
|
|
|
|
if (unlikely (caf_is_finalized))
|
|
|
|
goto error;
|
2011-06-17 01:09:36 +02:00
|
|
|
|
|
|
|
/* Start MPI if not already started. */
|
|
|
|
if (caf_num_images == 0)
|
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
|
|
|
_gfortran_caf_init (NULL, NULL);
|
2011-06-17 01:09:36 +02:00
|
|
|
|
|
|
|
/* Token contains only a list of pointers. */
|
|
|
|
local = malloc (size);
|
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
|
|
|
*token = malloc (sizeof (mpi_token_t) * caf_num_images);
|
2011-06-17 01:09:36 +02:00
|
|
|
|
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
|
|
|
if (unlikely (local == NULL || *token == NULL))
|
2011-07-07 14:46:18 +02:00
|
|
|
goto error;
|
|
|
|
|
2011-06-17 01:09:36 +02:00
|
|
|
/* token[img-1] is the address of the token in image "img". */
|
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
|
|
|
err = MPI_Allgather (&local, sizeof (void*), MPI_BYTE, TOKEN (*token),
|
2011-07-07 14:46:18 +02:00
|
|
|
sizeof (void*), MPI_BYTE, MPI_COMM_WORLD);
|
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
|
|
|
|
2011-07-07 14:46:18 +02:00
|
|
|
if (unlikely (err))
|
|
|
|
{
|
|
|
|
free (local);
|
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
|
|
|
free (*token);
|
2011-07-07 14:46:18 +02:00
|
|
|
goto error;
|
|
|
|
}
|
2011-06-17 01:09:36 +02:00
|
|
|
|
|
|
|
if (type == CAF_REGTYPE_COARRAY_STATIC)
|
|
|
|
{
|
|
|
|
caf_static_t *tmp = malloc (sizeof (caf_static_t));
|
|
|
|
tmp->prev = caf_static_list;
|
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
|
|
|
tmp->token = *token;
|
2011-06-17 01:09:36 +02:00
|
|
|
caf_static_list = tmp;
|
|
|
|
}
|
2011-07-07 14:46:18 +02:00
|
|
|
|
|
|
|
if (stat)
|
|
|
|
*stat = 0;
|
|
|
|
|
2011-06-17 01:09:36 +02:00
|
|
|
return local;
|
2011-07-07 14:46:18 +02:00
|
|
|
|
|
|
|
error:
|
2011-07-09 16:29:50 +02:00
|
|
|
{
|
|
|
|
char *msg;
|
|
|
|
|
|
|
|
if (caf_is_finalized)
|
|
|
|
msg = "Failed to allocate coarray - there are stopped images";
|
|
|
|
else
|
|
|
|
msg = "Failed to allocate coarray";
|
|
|
|
|
|
|
|
if (stat)
|
|
|
|
{
|
|
|
|
*stat = caf_is_finalized ? STAT_STOPPED_IMAGE : 1;
|
|
|
|
if (errmsg_len > 0)
|
|
|
|
{
|
|
|
|
int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len
|
|
|
|
: (int) strlen (msg);
|
|
|
|
memcpy (errmsg, msg, len);
|
|
|
|
if (errmsg_len > len)
|
|
|
|
memset (&errmsg[len], ' ', errmsg_len-len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-07-14 17:49:00 +02:00
|
|
|
caf_runtime_error (msg);
|
2011-07-09 16:29:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2011-05-06 20:35:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-29 12:33:09 +02:00
|
|
|
void
|
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
|
|
|
_gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, int errmsg_len)
|
2011-05-06 20:35:00 +02:00
|
|
|
{
|
2011-08-29 12:33:09 +02:00
|
|
|
if (unlikely (caf_is_finalized))
|
|
|
|
{
|
|
|
|
const char msg[] = "Failed to deallocate coarray - "
|
|
|
|
"there are stopped images";
|
|
|
|
if (stat)
|
|
|
|
{
|
|
|
|
*stat = STAT_STOPPED_IMAGE;
|
|
|
|
|
|
|
|
if (errmsg_len > 0)
|
|
|
|
{
|
|
|
|
int len = ((int) sizeof (msg) - 1 > errmsg_len)
|
|
|
|
? errmsg_len : (int) sizeof (msg) - 1;
|
|
|
|
memcpy (errmsg, msg, len);
|
|
|
|
if (errmsg_len > len)
|
|
|
|
memset (&errmsg[len], ' ', errmsg_len-len);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
caf_runtime_error (msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
_gfortran_caf_sync_all (NULL, NULL, 0);
|
|
|
|
|
|
|
|
if (stat)
|
|
|
|
*stat = 0;
|
|
|
|
|
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
|
|
|
free (TOKEN (*token)[caf_this_image-1]);
|
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
|
|
|
free (*token);
|
2011-05-06 20:35:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-10 12:22:24 +02:00
|
|
|
void
|
|
|
|
_gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len)
|
2011-03-27 11:01:34 +02:00
|
|
|
{
|
2011-07-09 16:29:50 +02:00
|
|
|
int ierr;
|
2011-06-10 12:22:24 +02:00
|
|
|
|
2011-07-09 16:29:50 +02:00
|
|
|
if (unlikely (caf_is_finalized))
|
|
|
|
ierr = STAT_STOPPED_IMAGE;
|
|
|
|
else
|
|
|
|
ierr = MPI_Barrier (MPI_COMM_WORLD);
|
|
|
|
|
2011-06-10 12:22:24 +02:00
|
|
|
if (stat)
|
|
|
|
*stat = ierr;
|
2011-03-27 11:01:34 +02:00
|
|
|
|
2011-06-10 12:22:24 +02:00
|
|
|
if (ierr)
|
2011-03-27 11:01:34 +02:00
|
|
|
{
|
2011-07-09 16:29:50 +02:00
|
|
|
char *msg;
|
|
|
|
if (caf_is_finalized)
|
|
|
|
msg = "SYNC ALL failed - there are stopped images";
|
|
|
|
else
|
|
|
|
msg = "SYNC ALL failed";
|
|
|
|
|
2011-06-10 12:22:24 +02:00
|
|
|
if (errmsg_len > 0)
|
|
|
|
{
|
2011-07-09 16:29:50 +02:00
|
|
|
int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len
|
|
|
|
: (int) strlen (msg);
|
2011-06-10 12:22:24 +02:00
|
|
|
memcpy (errmsg, msg, len);
|
|
|
|
if (errmsg_len > len)
|
|
|
|
memset (&errmsg[len], ' ', errmsg_len-len);
|
|
|
|
}
|
|
|
|
else
|
2011-07-14 17:49:00 +02:00
|
|
|
caf_runtime_error (msg);
|
2011-03-27 11:01:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* SYNC IMAGES. Note: SYNC IMAGES(*) is passed as count == -1 while
|
|
|
|
SYNC IMAGES([]) has count == 0. Note further that SYNC IMAGES(*)
|
2011-06-10 12:22:24 +02:00
|
|
|
is not equivalent to SYNC ALL. */
|
|
|
|
void
|
|
|
|
_gfortran_caf_sync_images (int count, int images[], int *stat, char *errmsg,
|
2011-03-27 11:01:34 +02:00
|
|
|
int errmsg_len)
|
|
|
|
{
|
|
|
|
int ierr;
|
|
|
|
if (count == 0 || (count == 1 && images[0] == caf_this_image))
|
2011-06-10 12:22:24 +02:00
|
|
|
{
|
|
|
|
if (stat)
|
|
|
|
*stat = 0;
|
|
|
|
return;
|
|
|
|
}
|
2011-03-27 11:01:34 +02:00
|
|
|
|
|
|
|
#ifdef GFC_CAF_CHECK
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
if (images[i] < 1 || images[i] > caf_num_images)
|
|
|
|
{
|
|
|
|
fprintf (stderr, "COARRAY ERROR: Invalid image index %d to SYNC "
|
|
|
|
"IMAGES", images[i]);
|
|
|
|
error_stop (1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* FIXME: SYNC IMAGES with a nontrivial argument cannot easily be
|
|
|
|
mapped to MPI communicators. Thus, exist early with an error message. */
|
|
|
|
if (count > 0)
|
|
|
|
{
|
|
|
|
fprintf (stderr, "COARRAY ERROR: SYNC IMAGES not yet implemented");
|
|
|
|
error_stop (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle SYNC IMAGES(*). */
|
2011-08-29 12:33:09 +02:00
|
|
|
if (unlikely (caf_is_finalized))
|
2011-07-09 16:29:50 +02:00
|
|
|
ierr = STAT_STOPPED_IMAGE;
|
|
|
|
else
|
|
|
|
ierr = MPI_Barrier (MPI_COMM_WORLD);
|
|
|
|
|
2011-06-10 12:22:24 +02:00
|
|
|
if (stat)
|
|
|
|
*stat = ierr;
|
2011-03-27 11:01:34 +02:00
|
|
|
|
2011-06-10 12:22:24 +02:00
|
|
|
if (ierr)
|
2011-03-27 11:01:34 +02:00
|
|
|
{
|
2011-07-09 16:29:50 +02:00
|
|
|
char *msg;
|
|
|
|
if (caf_is_finalized)
|
|
|
|
msg = "SYNC IMAGES failed - there are stopped images";
|
|
|
|
else
|
|
|
|
msg = "SYNC IMAGES failed";
|
|
|
|
|
2011-06-10 12:22:24 +02:00
|
|
|
if (errmsg_len > 0)
|
|
|
|
{
|
2011-07-09 16:29:50 +02:00
|
|
|
int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len
|
|
|
|
: (int) strlen (msg);
|
2011-06-10 12:22:24 +02:00
|
|
|
memcpy (errmsg, msg, len);
|
|
|
|
if (errmsg_len > len)
|
|
|
|
memset (&errmsg[len], ' ', errmsg_len-len);
|
|
|
|
}
|
|
|
|
else
|
2011-07-14 17:49:00 +02:00
|
|
|
caf_runtime_error (msg);
|
2011-03-27 11:01:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ERROR STOP the other images. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
error_stop (int error)
|
|
|
|
{
|
|
|
|
/* FIXME: Shutdown the Fortran RTL to flush the buffer. PR 43849. */
|
|
|
|
/* FIXME: Do some more effort than just MPI_ABORT. */
|
|
|
|
MPI_Abort (MPI_COMM_WORLD, error);
|
|
|
|
|
|
|
|
/* Should be unreachable, but to make sure also call exit. */
|
|
|
|
exit (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ERROR STOP function for string arguments. */
|
|
|
|
|
|
|
|
void
|
|
|
|
_gfortran_caf_error_stop_str (const char *string, int32_t len)
|
|
|
|
{
|
|
|
|
fputs ("ERROR STOP ", stderr);
|
|
|
|
while (len--)
|
|
|
|
fputc (*(string++), stderr);
|
|
|
|
fputs ("\n", stderr);
|
|
|
|
|
|
|
|
error_stop (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ERROR STOP function for numerical arguments. */
|
|
|
|
|
|
|
|
void
|
|
|
|
_gfortran_caf_error_stop (int32_t error)
|
|
|
|
{
|
|
|
|
fprintf (stderr, "ERROR STOP %d\n", error);
|
|
|
|
error_stop (error);
|
|
|
|
}
|