diff options
author | goodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164> | 2000-11-13 16:56:26 +0000 |
---|---|---|
committer | goodale <goodale@1faa4e14-9dd3-4be0-9f0e-ffe519881164> | 2000-11-13 16:56:26 +0000 |
commit | 97d378b1e5c9927600cd3e175b1667430d7b4f34 (patch) | |
tree | 79d20caefc4b38d7141997d5c1391d9973deff04 /src | |
parent | f8998309ba282495ca87af18a79038cc3e0ce072 (diff) |
Send size of buffer bigendian buffer of eight bytes rather than an int so
avoid problems with MPI maybe/maybenot doing typeconversion when running
between machines with different MPI_INT types.
Tom
git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@103 1faa4e14-9dd3-4be0-9f0e-ffe519881164
Diffstat (limited to 'src')
-rw-r--r-- | src/Steer.c | 71 |
1 files changed, 69 insertions, 2 deletions
diff --git a/src/Steer.c b/src/Steer.c index 2f89e9b..f54bd26 100644 --- a/src/Steer.c +++ b/src/Steer.c @@ -47,6 +47,7 @@ CCTK_FILEVERSION(DevThorns_httpd_Steer_c) static int CommunicateBuffer(void); static int SteerParameters(void); +static void ByteSwap(void *buf,int nelements,int elementsize); /******************************************************************** ********************* Other Routine Prototypes ********************* @@ -184,6 +185,7 @@ static int CommunicateBuffer(void) int rank; int nprocs; int buffer_size; + CCTK_INT8 transmit_buffer_size; /* Work out how many processes there are. */ MPI_Comm_size(MPI_COMM_WORLD, &nprocs); @@ -206,8 +208,12 @@ static int CommunicateBuffer(void) buffer_size++; } + transmit_buffer_size = buffer_size; + + ByteSwap(&transmit_buffer_size, 1, 8); + /* Tell other procs how much data to receive. */ - MPI_Bcast(&buffer_size, 1, MPI_INT, 0, MPI_COMM_WORLD); + MPI_Bcast(&transmit_buffer_size, 8, MPI_BYTE, 0, MPI_COMM_WORLD); if(buffer_size > 0) { @@ -220,8 +226,12 @@ static int CommunicateBuffer(void) /* Receiving process */ /* Find out how much data to receive. */ - MPI_Bcast(&buffer_size, 1, MPI_INT, 0, MPI_COMM_WORLD); + MPI_Bcast(&transmit_buffer_size, 8, MPI_BYTE, 0, MPI_COMM_WORLD); + ByteSwap(&transmit_buffer_size, 1, 8); + + buffer_size = transmit_buffer_size; + #ifdef TEST_HTTP_STEER fprintf(stderr, "%d - buffer size %d queuebuffer size %d\n", rank, buffer_size, queuebuffer_size); #endif @@ -330,6 +340,63 @@ static int SteerParameters(void) return retval; } + /*@@ + @routine ByteSwap + @date Mon Oct 09 2000 + @author John Shalf + @desc + + @enddesc + @calls + @calledby + @history + + @endhistory + @var buf + @vdesc buffer to byteswap + @vtype void * + @vio inout + @vcomment + + @endvar + @var nelements + @vdesc number of data elements in array + @vtype int + @vio in + @vcomment + + @endvar + @var elementsize + @vdesc size of each element in buffer + @vtype int + @vio in + @vcomment + + @endvar + +@@*/ +static void ByteSwap(void *buf,int nelements,int elementsize) +{ +#ifndef WORDS_BIGENDIAN + char *buffer; + int i; + int s,d; + + buffer=(char *)buf; + + for(i=0;i<nelements;i++,buffer+=elementsize) + { + /* do the swap thing on each element */ + for(s=0,d=elementsize-1;s<d;s++,d--) + { + char c=buffer[s]; + buffer[s]=buffer[d]; + buffer[d]=c; + } + } +#endif +} + #ifdef TEST_HTTP_STEER int CCTK_ParameterSet(char *parameter, char *thorn, char *value) |