"Fossies" - the Fresh Open Source Software Archive

Member "NetPIPE-3.7.2/src/tcgmsg.c" (19 Aug 2010, 3505 Bytes) of package /linux/privat/old/NetPIPE-3.7.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "tcgmsg.c" see the Fossies "Dox" file reference documentation.

    1 /*****************************************************************************/
    2 /* "NetPIPE" -- Network Protocol Independent Performance Evaluator.          */
    3 /* Copyright 1997, 1998 Iowa State University Research Foundation, Inc.      */
    4 /*                                                                           */
    5 /* This program is free software; you can redistribute it and/or modify      */
    6 /* it under the terms of the GNU General Public License as published by      */
    7 /* the Free Software Foundation.  You should have received a copy of the     */
    8 /* GNU General Public License along with this program; if not, write to the  */
    9 /* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   */
   10 /*                                                                           */
   11 /*     * mpi.c              ---- MPI calls source                            */
   12 /*****************************************************************************/
   13 #include    "netpipe.h"
   14 #include    <sndrcv.h>
   15 
   16 void RCV_(long *type, void *buf, long *lenbuf, long *lenmes, long *nodesel, long *nodefrom, long *sync);
   17 void SND_(long *type, void *buf, long *lenbuf, long *node, long *sync);
   18 
   19 void Init(ArgStruct *p, int* pargc, char*** pargv)
   20 {
   21     PBEGIN_(*pargc, *pargv);
   22 }
   23 
   24 void Setup(ArgStruct *p)
   25 {
   26     long nprocs;
   27 
   28     nprocs      = NNODES_();
   29     p->prot.nid = NODEID_();
   30     {
   31         char s[255];
   32         gethostname(s,253);
   33         printf("%d: %s\n",p->prot.nid,s); fflush(stdout);
   34     }
   35 
   36     if (nprocs < 2)
   37     {
   38         printf("Need at least two processes, we have %d\n", nprocs); fflush(stdout);
   39         exit(-2);
   40     }
   41 
   42     p->tr = p->rcv = 0;
   43     if (p->prot.nid == 0) {
   44         p->tr = 1;
   45         p->prot.nbor = nprocs-1;
   46     } else if( p->prot.nid == nprocs-1 ) {
   47         p->rcv = 1;
   48         p->prot.nbor = 0;
   49     }
   50 }
   51 
   52 void Sync(ArgStruct *p)
   53 {
   54     long type = MSGCHR;
   55 
   56     SYNCH_(&type);
   57 }
   58 
   59 void PrepareToReceive(ArgStruct *p)
   60 {
   61         /*
   62           The TCGMSG interface doesn't have a method to pre-post
   63           a buffer for reception of data.
   64         */
   65 }
   66 
   67 void SendData(ArgStruct *p)
   68 {
   69   long type = MSGCHR;
   70   long sync_snd = 0;
   71   long lbufflen = p->bufflen;
   72   
   73     SND_( &type, p->s_ptr, &lbufflen, &p->prot.nbor, &sync_snd);
   74 }
   75 
   76 void RecvData(ArgStruct *p)
   77 {
   78   long lenmes;
   79   long nodefrom;
   80   long type = MSGCHR;
   81   long sync_rcv = 1;
   82   long lbufflen = p->bufflen;
   83 
   84     RCV_ ( &type, p->r_ptr, &lbufflen, &lenmes, &p->prot.nbor, &nodefrom, &sync_rcv) ;
   85 }
   86 
   87 
   88 void SendTime(ArgStruct *p, double *t)
   89 {
   90    long ttype;
   91    long lenbuf;
   92    long sync_snd = 1;
   93 
   94    ttype = MSGDBL;
   95    lenbuf = sizeof(double);
   96    SND_( &ttype, t, &lenbuf, &p->prot.nbor, &sync_snd);
   97 }
   98 
   99 void RecvTime(ArgStruct *p, double *t)
  100 {
  101    long lenmes;
  102    long nodefrom;
  103    long ttype;
  104    long lenbuf;
  105    long sync_rcv = 1;
  106 
  107    ttype = MSGDBL;
  108    lenbuf = sizeof(double);
  109    RCV_( &ttype, t, &lenbuf, &lenmes, &p->prot.nbor, &nodefrom, &sync_rcv);
  110 }
  111 
  112 void SendRepeat(ArgStruct *p, int n)
  113 {
  114    long ttype;
  115    long lenbuf;
  116    long sync_snd = 1;
  117 
  118    ttype = MSGINT;
  119    lenbuf = sizeof(int);
  120    SND_( &ttype, &n, &lenbuf, &p->prot.nbor, &sync_snd);
  121 }
  122 
  123 void RecvRepeat(ArgStruct *p, int *n)
  124 {
  125    long lenmes;
  126    long nodefrom;
  127    long ttype;
  128    long lenbuf;
  129    long sync_rcv = 1;
  130 
  131    ttype = MSGINT;
  132    lenbuf = sizeof(int);
  133    RCV_( &ttype, n, &lenbuf, &lenmes, &p->prot.nbor, &nodefrom, &sync_rcv);
  134 }
  135 
  136 void CleanUp(ArgStruct *p)
  137 {
  138         PEND_();
  139 }
  140 
  141 
  142 void Reset(ArgStruct *p)
  143 {
  144 
  145 }
  146 
  147 
  148 void AfterAlignmentInit(ArgStruct *p)
  149 {
  150 
  151 }