aboutsummaryrefslogtreecommitdiff
path: root/src/FinishReceiveGA.c
diff options
context:
space:
mode:
authorallen <allen@b61c5cb5-eaca-4651-9a7a-d64986f99364>2000-02-03 12:04:43 +0000
committerallen <allen@b61c5cb5-eaca-4651-9a7a-d64986f99364>2000-02-03 12:04:43 +0000
commit83ceaa6b1cb346e28e45db30170234ddf6902fbb (patch)
treea7249c594f7ee99b3765bc6948459593e16a1722 /src/FinishReceiveGA.c
parent89aecf06c6c5f4576d987727c11ee9923ced5221 (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/FinishReceiveGA.c')
-rw-r--r--src/FinishReceiveGA.c211
1 files changed, 211 insertions, 0 deletions
diff --git a/src/FinishReceiveGA.c b/src/FinishReceiveGA.c
new file mode 100644
index 0000000..5648b4b
--- /dev/null
+++ b/src/FinishReceiveGA.c
@@ -0,0 +1,211 @@
+ /*@@
+ @file FinishReceiveGA.c
+ @date Wed Feb 2 11:37:28 1997
+ @author Gabrielle Allen
+ @desc
+ The routine which finalize the MPI recieves for a grid
+ function. Critically linked with @seefile pGA_PostRecv.c
+ and @seefile pGA_PostSend.c
+ @enddesc
+ @version $Id$
+ @@*/
+
+/*#define DEBUG_PUGH*/
+
+#include <stdio.h>
+
+#include "cctk.h"
+#include "pugh.h"
+
+void FinishReceiveGA3(pGH *GH, pGA *GA, int dir);
+void FinishReceiveGA1(pGH *GH, pGA *GA, int dir);
+
+static char *rcsid = "$Id$";
+
+ /*@@
+ @routine FinishReceiveGA
+ @date Thu Apr 3 11:38:07 1997
+ @author Paul Walker
+ @desc
+ This routine finalizes the MPI communication through a face.
+ It is crucially linked with @seeroutine pGA_PostRecv and
+ @seeroutine pGA_PostSend.
+ <p>
+ <b>Important!</b>
+ This routine does <b>not</b> wait on the recieves.
+ Before it is called, you must do the MPI_Wait or
+ else you will not get the right answer. for an
+ example of this, see @seeroutine SyncGroupGA or
+ @seeroutine SyncGroupGA
+ @enddesc
+ @calledby SyncGroupGA
+ @history
+ @hdate Nov 4 1998 @hauthor Gabrielle Allen
+ @hdesc Allow for forced synchronization of all GAs with storage
+ @endhistory
+@@*/
+
+void FinishReceiveGA(pGH *GH, pGA *GA, int dir)
+{
+#ifdef MPI
+
+ /* Return if GA has no storage */
+ if (!(GA->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)
+ {
+
+ /* Here wait one at a time, so the others can arrive while
+ we copy the data back in... */
+
+#ifdef DEBUG_PUGH
+ printf ("FINISHRECV: GA %s Side %d Proc %d request %d\n",
+ GA->name,dir,GH->myproc,GA->rreq[dir]);
+#endif
+
+ if (GA->extras->dim == 3)
+ {
+ FinishReceiveGA3(GH,GA,dir);
+ }
+ else if (GA->extras->dim == 1)
+ {
+ FinishReceiveGA1(GH,GA,dir);
+ }
+ else
+ {
+ CCTK_WARN(0,"PUGH does not support this dimension grid");
+ }
+
+ }
+
+#endif
+}
+
+void FinishReceiveGA3(pGH *GH,pGA *GA,int dir)
+{
+ int istart,iend,jstart,jend,kstart,kend;
+ int ii,jj,kk,xx;
+ CCTK_CHAR *char_data;
+ CCTK_INT *int_data;
+ CCTK_REAL *real_data;
+ CCTK_COMPLEX *complex_data;
+
+ /* Copy buffer onto GA Storage */
+ istart = GA->extras->ghosts[GA->stagger][0][dir][0];
+ iend = GA->extras->ghosts[GA->stagger][1][dir][0];
+ jstart = GA->extras->ghosts[GA->stagger][0][dir][1];
+ jend = GA->extras->ghosts[GA->stagger][1][dir][1];
+ kstart = GA->extras->ghosts[GA->stagger][0][dir][2];
+ kend = GA->extras->ghosts[GA->stagger][1][dir][2];
+
+ /* Great now copy. Note ordering is just link in PostSend */
+ xx=0;
+ switch (GA->vtype)
+ {
+ case CCTK_VARIABLE_CHAR:
+ char_data = (CCTK_CHAR *) GA->data;
+ for (kk=kstart; kk<kend; kk++)
+ for (jj=jstart; jj<jend; jj++)
+ for (ii=istart; ii<iend; ii++)
+ char_data [DATINDEX (GA->extras,ii,jj,kk)] =
+ ((CCTK_CHAR *) GA->recv_buffer[dir]) [xx++];
+ break;
+
+ case CCTK_VARIABLE_INT:
+ int_data = (CCTK_INT *) GA->data;
+ for (kk=kstart; kk<kend; kk++)
+ for (jj=jstart; jj<jend; jj++)
+ for (ii=istart; ii<iend; ii++)
+ int_data [DATINDEX (GA->extras,ii,jj,kk)] =
+ ((CCTK_INT *) GA->recv_buffer[dir]) [xx++];
+ break;
+
+ case CCTK_VARIABLE_REAL:
+ real_data = (CCTK_REAL *) GA->data;
+ for (kk=kstart; kk<kend; kk++)
+ for (jj=jstart; jj<jend; jj++)
+ for (ii=istart; ii<iend; ii++)
+ real_data [DATINDEX (GA->extras,ii,jj,kk)] =
+ ((CCTK_REAL *) GA->recv_buffer[dir]) [xx++];
+ break;
+
+ case CCTK_VARIABLE_COMPLEX:
+ complex_data = (CCTK_COMPLEX *) GA->data;
+ for (kk=kstart; kk<kend; kk++)
+ for (jj=jstart; jj<jend; jj++)
+ for (ii=istart; ii<iend; ii++)
+ complex_data [DATINDEX (GA->extras,ii,jj,kk)] =
+ ((CCTK_COMPLEX *) GA->recv_buffer[dir]) [xx++];
+ break;
+
+ default:
+ CCTK_WARN (1, "Unsupported variable type in FinishReceiveGA3");
+ return;
+ }
+}
+
+
+
+void FinishReceiveGA1(pGH *GH,pGA *GA,int dir)
+{
+ int istart,iend;
+ int ii,xx;
+ CCTK_CHAR *char_data;
+ CCTK_INT *int_data;
+ CCTK_REAL *real_data;
+ CCTK_COMPLEX *complex_data;
+
+ /* Copy buffer onto GA Storage */
+ istart = GA->extras->ghosts[GA->stagger][0][dir][0];
+ iend = GA->extras->ghosts[GA->stagger][1][dir][0];
+
+ /* Great now copy. Note ordering is just link in PostSend */
+ xx=0;
+ switch (GA->vtype)
+ {
+ case CCTK_VARIABLE_CHAR:
+ char_data = (CCTK_CHAR *) GA->data;
+ for (ii=istart; ii<iend; ii++)
+ {
+ char_data [ii] = ((CCTK_CHAR *)GA->recv_buffer[dir])[xx++];
+ }
+ break;
+
+ case CCTK_VARIABLE_INT:
+ int_data = (CCTK_INT *) GA->data;
+ for (ii=istart; ii<iend; ii++)
+ {
+ int_data [ii] = ((CCTK_INT *)GA->recv_buffer[dir])[xx++];
+ }
+ break;
+
+ case CCTK_VARIABLE_REAL:
+ real_data = (CCTK_REAL *) GA->data;
+ for (ii=istart; ii<iend; ii++)
+ {
+ real_data [ii] = ((CCTK_REAL *)GA->recv_buffer[dir])[xx++];
+ }
+ break;
+
+ case CCTK_VARIABLE_COMPLEX:
+ complex_data = (CCTK_COMPLEX *) GA->data;
+ for (ii=istart; ii<iend; ii++)
+ {
+ complex_data [ii] = ((CCTK_COMPLEX *)GA->recv_buffer[dir])[xx++];
+ }
+ break;
+
+ default:
+ CCTK_WARN (1, "Unsupported variable type in FinishReceiveGA3");
+ return;
+ }
+}