summaryrefslogtreecommitdiff
path: root/libgfortran/caf/mpi.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgfortran/caf/mpi.c')
-rw-r--r--libgfortran/caf/mpi.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/libgfortran/caf/mpi.c b/libgfortran/caf/mpi.c
index da7185ed09..cc9740d29d 100644
--- a/libgfortran/caf/mpi.c
+++ b/libgfortran/caf/mpi.c
@@ -1,5 +1,5 @@
/* MPI implementation of GNU Fortran Coarray Library
- Copyright (C) 2011-2014 Free Software Foundation, Inc.
+ Copyright (C) 2011-2015 Free Software Foundation, Inc.
Contributed by Tobias Burnus <burnus@net-b.de>
This file is part of the GNU Fortran Coarray Runtime Library (libcaf).
@@ -34,6 +34,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* Define GFC_CAF_CHECK to enable run-time checking. */
/* #define GFC_CAF_CHECK 1 */
+typedef void ** mpi_token_t;
+#define TOKEN(X) ((mpi_token_t) (X))
static void error_stop (int error) __attribute__ ((noreturn));
@@ -73,7 +75,7 @@ caf_runtime_error (const char *message, ...)
libaray is initialized. */
void
-_gfortran_caf_init (int *argc, char ***argv, int *this_image, int *num_images)
+_gfortran_caf_init (int *argc, char ***argv)
{
if (caf_num_images == 0)
{
@@ -87,11 +89,6 @@ _gfortran_caf_init (int *argc, char ***argv, int *this_image, int *num_images)
MPI_Comm_rank (MPI_COMM_WORLD, &caf_this_image);
caf_this_image++;
}
-
- if (this_image)
- *this_image = caf_this_image;
- if (num_images)
- *num_images = caf_num_images;
}
@@ -104,8 +101,8 @@ _gfortran_caf_finalize (void)
{
caf_static_t *tmp = caf_static_list->prev;
- free (caf_static_list->token[caf_this_image-1]);
- free (caf_static_list->token);
+ free (TOKEN (caf_static_list->token)[caf_this_image-1]);
+ free (TOKEN (caf_static_list->token));
free (caf_static_list);
caf_static_list = tmp;
}
@@ -117,8 +114,23 @@ _gfortran_caf_finalize (void)
}
+int
+_gfortran_caf_this_image (int distance __attribute__ ((unused)))
+{
+ return caf_this_image;
+}
+
+
+int
+_gfortran_caf_num_images (int distance __attribute__ ((unused)),
+ int failed __attribute__ ((unused)))
+{
+ return caf_num_images;
+}
+
+
void *
-_gfortran_caf_register (ptrdiff_t size, caf_register_t type, void ***token,
+_gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token,
int *stat, char *errmsg, int errmsg_len)
{
void *local;
@@ -129,17 +141,17 @@ _gfortran_caf_register (ptrdiff_t size, caf_register_t type, void ***token,
/* Start MPI if not already started. */
if (caf_num_images == 0)
- _gfortran_caf_init (NULL, NULL, NULL, NULL);
+ _gfortran_caf_init (NULL, NULL);
/* Token contains only a list of pointers. */
local = malloc (size);
- *token = malloc (sizeof (void*) * caf_num_images);
+ *token = malloc (sizeof (mpi_token_t) * caf_num_images);
if (unlikely (local == NULL || *token == NULL))
goto error;
/* token[img-1] is the address of the token in image "img". */
- err = MPI_Allgather (&local, sizeof (void*), MPI_BYTE, *token,
+ err = MPI_Allgather (&local, sizeof (void*), MPI_BYTE, TOKEN (*token),
sizeof (void*), MPI_BYTE, MPI_COMM_WORLD);
if (unlikely (err))
@@ -192,7 +204,7 @@ error:
void
-_gfortran_caf_deregister (void ***token, int *stat, char *errmsg, int errmsg_len)
+_gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, int errmsg_len)
{
if (unlikely (caf_is_finalized))
{
@@ -220,7 +232,7 @@ _gfortran_caf_deregister (void ***token, int *stat, char *errmsg, int errmsg_len
if (stat)
*stat = 0;
- free ((*token)[caf_this_image-1]);
+ free (TOKEN (*token)[caf_this_image-1]);
free (*token);
}