diff options
author | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-06-10 10:22:24 +0000 |
---|---|---|
committer | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-06-10 10:22:24 +0000 |
commit | 96b417f084169ab82fd99363b70802c98d94cdb1 (patch) | |
tree | 4d1a49e6b55f66c96e0bf26e86bf290b7017072c /libgfortran/caf | |
parent | b2c2e188e031f6e3ba282af91a2d565f73fe5c43 (diff) | |
download | gcc-96b417f084169ab82fd99363b70802c98d94cdb1.tar.gz |
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".
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@174896 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/caf')
-rw-r--r-- | libgfortran/caf/libcaf.h | 4 | ||||
-rw-r--r-- | libgfortran/caf/mpi.c | 76 | ||||
-rw-r--r-- | libgfortran/caf/single.c | 14 |
3 files changed, 57 insertions, 37 deletions
diff --git a/libgfortran/caf/libcaf.h b/libgfortran/caf/libcaf.h index 7b19f0d2dd0..9c20c4e9d78 100644 --- a/libgfortran/caf/libcaf.h +++ b/libgfortran/caf/libcaf.h @@ -54,8 +54,8 @@ void * _gfortran_caf_register (ptrdiff_t, caf_register_t, void **); int _gfortran_caf_deregister (void **); -int _gfortran_caf_sync_all (char *, int); -int _gfortran_caf_sync_images (int, int[], char *, int); +void _gfortran_caf_sync_all (int *, char *, int); +void _gfortran_caf_sync_images (int, int[], int *, char *, int); /* FIXME: The CRITICAL functions should be removed; the functionality is better represented using Coarray's lock feature. */ diff --git a/libgfortran/caf/mpi.c b/libgfortran/caf/mpi.c index 9b7bb333c22..e64670ea8cb 100644 --- a/libgfortran/caf/mpi.c +++ b/libgfortran/caf/mpi.c @@ -92,41 +92,49 @@ _gfortran_caf_deregister (void **token __attribute__ ((unused))) } -/* SYNC ALL - the return value matches Fortran's STAT argument. */ - -int -_gfortran_caf_sync_all (char *errmsg, int errmsg_len) +void +_gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len) { - int ierr; - ierr = MPI_Barrier (MPI_COMM_WORLD); + /* TODO: Is ierr correct? When should STAT_STOPPED_IMAGE be used? */ + int ierr = MPI_Barrier (MPI_COMM_WORLD); + + if (stat) + *stat = ierr; - if (ierr && errmsg_len > 0) + if (ierr) { const char msg[] = "SYNC ALL failed"; - int len = ((int) sizeof (msg) > errmsg_len) ? errmsg_len - : (int) sizeof (msg); - memcpy (errmsg, msg, len); - if (errmsg_len > len) - memset (&errmsg[len], ' ', errmsg_len-len); + if (errmsg_len > 0) + { + int len = ((int) sizeof (msg) > errmsg_len) ? errmsg_len + : (int) sizeof (msg); + memcpy (errmsg, msg, len); + if (errmsg_len > len) + memset (&errmsg[len], ' ', errmsg_len-len); + } + else + { + fprintf (stderr, "SYNC ALL failed\n"); + error_stop (ierr); + } } - - /* TODO: Is ierr correct? When should STAT_STOPPED_IMAGE be used? */ - return ierr; } /* SYNC IMAGES. Note: SYNC IMAGES(*) is passed as count == -1 while SYNC IMAGES([]) has count == 0. Note further that SYNC IMAGES(*) - is not equivalent to SYNC ALL. The return value matches Fortran's - STAT argument. */ -int -_gfortran_caf_sync_images (int count, int images[], char *errmsg, + is not equivalent to SYNC ALL. */ +void +_gfortran_caf_sync_images (int count, int images[], int *stat, char *errmsg, int errmsg_len) { int ierr; - if (count == 0 || (count == 1 && images[0] == caf_this_image)) - return 0; + { + if (stat) + *stat = 0; + return; + } #ifdef GFC_CAF_CHECK { @@ -151,20 +159,28 @@ _gfortran_caf_sync_images (int count, int images[], char *errmsg, } /* Handle SYNC IMAGES(*). */ + /* TODO: Is ierr correct? When should STAT_STOPPED_IMAGE be used? */ ierr = MPI_Barrier (MPI_COMM_WORLD); + if (stat) + *stat = ierr; - if (ierr && errmsg_len > 0) + if (ierr) { const char msg[] = "SYNC IMAGES failed"; - int len = ((int) sizeof (msg) > errmsg_len) ? errmsg_len - : (int) sizeof (msg); - memcpy (errmsg, msg, len); - if (errmsg_len > len) - memset (&errmsg[len], ' ', errmsg_len-len); + if (errmsg_len > 0) + { + int len = ((int) sizeof (msg) > errmsg_len) ? errmsg_len + : (int) sizeof (msg); + memcpy (errmsg, msg, len); + if (errmsg_len > len) + memset (&errmsg[len], ' ', errmsg_len-len); + } + else + { + fprintf (stderr, "SYNC IMAGES failed\n"); + error_stop (ierr); + } } - - /* TODO: Is ierr correct? When should STAT_STOPPED_IMAGE be used? */ - return ierr; } diff --git a/libgfortran/caf/single.c b/libgfortran/caf/single.c index c5c66b4b955..4c46e47d35c 100644 --- a/libgfortran/caf/single.c +++ b/libgfortran/caf/single.c @@ -69,16 +69,19 @@ _gfortran_caf_deregister (void **token __attribute__ ((unused))) } -int -_gfortran_caf_sync_all (char *errmsg __attribute__ ((unused)), +void +_gfortran_caf_sync_all (int *stat, + char *errmsg __attribute__ ((unused)), int errmsg_len __attribute__ ((unused))) { - return 0; + if (stat) + *stat = 0; } -int +void _gfortran_caf_sync_images (int count __attribute__ ((unused)), int images[] __attribute__ ((unused)), + int *stat, char *errmsg __attribute__ ((unused)), int errmsg_len __attribute__ ((unused))) { @@ -94,7 +97,8 @@ _gfortran_caf_sync_images (int count __attribute__ ((unused)), } #endif - return 0; + if (stat) + *stat = 0; } |