diff options
author | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-29 10:33:09 +0000 |
---|---|---|
committer | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-29 10:33:09 +0000 |
commit | 4f5fe47575bafb2cc08d3cbfc42d1bfb3887217c (patch) | |
tree | 53945bc4072488d8d24857a6fbc9d9459dfb6c2e /libgfortran/caf/mpi.c | |
parent | 8df4f2a580d2475189691fd7d6744cde67c025de (diff) |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178193 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/caf/mpi.c')
-rw-r--r-- | libgfortran/caf/mpi.c | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/libgfortran/caf/mpi.c b/libgfortran/caf/mpi.c index ea4c0f05c273..c69c5b9574ff 100644 --- a/libgfortran/caf/mpi.c +++ b/libgfortran/caf/mpi.c @@ -103,8 +103,12 @@ _gfortran_caf_finalize (void) { while (caf_static_list != NULL) { - free(caf_static_list->token[caf_this_image-1]); - caf_static_list = caf_static_list->prev; + caf_static_t *tmp = caf_static_list->prev; + + free (caf_static_list->token[caf_this_image-1]); + free (caf_static_list->token); + free (caf_static_list); + caf_static_list = tmp; } if (!caf_mpi_initialized) @@ -187,10 +191,37 @@ error: } -int -_gfortran_caf_deregister (void **token __attribute__ ((unused))) +void +_gfortran_caf_deregister (void **token, int *stat, char *errmsg, int errmsg_len) { - return 0; + 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; + + free (token[caf_this_image-1]); + free (token); } @@ -267,7 +298,7 @@ _gfortran_caf_sync_images (int count, int images[], int *stat, char *errmsg, } /* Handle SYNC IMAGES(*). */ - if (unlikely(caf_is_finalized)) + if (unlikely (caf_is_finalized)) ierr = STAT_STOPPED_IMAGE; else ierr = MPI_Barrier (MPI_COMM_WORLD); |