diff options
author | allen <allen@b61c5cb5-eaca-4651-9a7a-d64986f99364> | 2000-02-03 12:04:43 +0000 |
---|---|---|
committer | allen <allen@b61c5cb5-eaca-4651-9a7a-d64986f99364> | 2000-02-03 12:04:43 +0000 |
commit | 83ceaa6b1cb346e28e45db30170234ddf6902fbb (patch) | |
tree | a7249c594f7ee99b3765bc6948459593e16a1722 /src/PostReceiveGA.c | |
parent | 89aecf06c6c5f4576d987727c11ee9923ced5221 (diff) |
New routines for treating arrays ... soon the GFs will be done with
these too.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@157 b61c5cb5-eaca-4651-9a7a-d64986f99364
Diffstat (limited to 'src/PostReceiveGA.c')
-rw-r--r-- | src/PostReceiveGA.c | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/src/PostReceiveGA.c b/src/PostReceiveGA.c new file mode 100644 index 0000000..56d3ac6 --- /dev/null +++ b/src/PostReceiveGA.c @@ -0,0 +1,120 @@ + /*@@ + @file PostReceiveGA.c + @date Wed Feb 2 11:28:06 1997 + @author Gabrielle Allen + @desc + Routines which post all the IRecv commands for a GA. These + allow the asyncronous model proposed in, for example, + @seeroutine SyncGA to go! + @enddesc + @version $Id$ + @@*/ + +#include <stdio.h> + +#include "pugh.h" + +static char *rcsid = "$Id$"; + +/*#define DEBUG_PUGH*/ + + + /*@@ + @routine PostReceiveGA + @date Thu Apr 3 12:10:46 1997 + @author Paul Walker + @desc + This routine posts a recieve (MPI_Irecv) of the buffer + we want to get the send from another processor, which + will be sent by @seeroutine pGA_PostSend and then + finalized by @seeroutoine pGA_FinishRecv. + <p> + Aside from a silly calculation to get a unique tag + based on neigbors and processors, this is a very + straightforward routine. + @enddesc + @history + @hdate Nov 4 1998 @hauthor Gabrielle Allen + @hdesc Allow for forced synchronization of all GAs with storage + @endhistory + @@*/ + +void PostReceiveGA(pGH *GH, pGA *GA, int dir) +{ +#ifdef MPI + int rtag; + int mpi_type; + MPI_Datatype *recv_dt; + + if (!(GA->storage)) + { + CCTK_WARN(2,"Trying to synchronize variable with no storage"); + return; + } + + /* Return if communication not required and no forced synchronisation */ + if (!(GH->forceSync || GA->docomm[dir])) + { + return; + } + + if (GA->connectivity->neighbours[GH->myproc][dir] < 0) + { + return; + } + + switch (GA->vtype) + { + case CCTK_VARIABLE_CHAR: + mpi_type = PUGH_MPI_CHAR; + recv_dt = GH->recv_char_dt [GA->stagger]; + break; + + case CCTK_VARIABLE_INT: + mpi_type = PUGH_MPI_INT; + recv_dt = GH->recv_int_dt [GA->stagger]; + break; + + case CCTK_VARIABLE_REAL: + mpi_type = PUGH_MPI_REAL; + recv_dt = GH->recv_real_dt [GA->stagger]; + break; + + case CCTK_VARIABLE_COMPLEX: + mpi_type = GH->pugh_mpi_complex; + recv_dt = GH->recv_complex_dt [GA->stagger]; + break; + + default: + CCTK_WARN (1, "Unknown variable type in PostReceiveGA"); + return; + } + + rtag = 1000 + dir + 2 * (GH->myproc + GH->nprocs * GA->id); + /* mod the tag to force MPI compliance */ + rtag = rtag % 32768; +#ifdef DEBUG_PUGH + printf ("RECV GA %s Side %d Proc %d rtag %d size %d from proc %d\n", + GA->name, + dir, + GH->myproc, + rtag, + GA->buffer_sz[dir], + GA->connectivity->neighbours[GH->myproc][dir]); +#endif + if (GH->commmodel == PUGH_ALLOCATEDBUFFERS) + { + CACTUS_MPI_ERROR (MPI_Irecv (GA->recv_buffer [dir], + GA->buffer_sz [dir], mpi_type, + GA->connectivity->neighbours [GH->myproc][dir], rtag, + GH->PUGH_COMM_WORLD, &(GA->rreq [dir]))); + } + if (GH->commmodel == PUGH_DERIVEDTYPES) + { + CACTUS_MPI_ERROR (MPI_Irecv (GA->data, + 1, recv_dt [dir], + GA->connectivity->neighbours [GH->myproc][dir], rtag, + GH->PUGH_COMM_WORLD, &(GA->rreq [dir]))); + } +#endif +} |