File: netpipe.h

package info (click to toggle)
netpipe 3.7.2-8
  • links: PTS
  • area: main
  • in suites: buster, sid
  • size: 1,188 kB
  • sloc: ansic: 7,588; makefile: 279; sh: 63; perl: 45; csh: 25
file content (432 lines) | stat: -rw-r--r-- 14,148 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
#define FINAL
#undef FINAL
/*****************************************************************************/
/* "NetPIPE" -- Network Protocol Independent Performance Evaluator.          */
/* Copyright 1997, 1998 Iowa State University Research Foundation, Inc.      */
/*                                                                           */
/* This program is free software; you can redistribute it and/or modify      */
/* it under the terms of the GNU General Public License as published by      */
/* the Free Software Foundation.  You should have received a copy of the     */
/* GNU General Public License along with this program; if not, write to the  */
/* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   */
/*                                                                           */
/*     * netpipe.h          ---- General include file                        */
/*****************************************************************************/
#include <ctype.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/time.h>       /* struct timeval */
#include <sys/resource.h>   /* getrusage() */
#include <stdlib.h>         /* malloc(3) */
#include <unistd.h>         /* getopt, read, write, ... */

/* Handle the case of building on MacOS X */
#if defined(__APPLE__)
#include <stdint.h>
#endif 

#ifdef INFINIBAND
#include <ib_defs.h> /* ib_mtu_t */
#endif

#ifdef OPENIB
#include <infiniband/verbs.h>	/* enum ibv_mtu */
#endif

#ifdef FINAL
  #define  TRIALS             7
  #define  RUNTM              0.25
#else
  #define  TRIALS             3
  #define  RUNTM              0.10
#endif

#define  MEMSIZE            10000000 
#define  DEFPORT            5002
#define  NSAMP              8000
#define  DEFPERT            3
#define  LONGTIME           1e99
#define  CHARSIZE           8
#define  STOPTM             1.0
#define  MAXINT             10000000
/*#define  MAXINT             1048576*/

#define     ABS(x)     (((x) < 0)?(-(x)):(x))
#define     MIN(x,y)   (((x) < (y))?(x):(y))
#define     MAX(x,y)   (((x) > (y))?(x):(y))

/* Need to include the protocol structure header file.                       */
/* Change this to reflect the protocol                                       */

#if defined(TCP)
  #include <netdb.h>
  #include <sys/socket.h>
  #include <netinet/in.h>
  #include <netinet/tcp.h>
  #include <arpa/inet.h>
  
  typedef struct protocolstruct ProtocolStruct;
  struct protocolstruct
  {
      struct sockaddr_in      sin1,   /* socket structure #1              */
                              sin2;   /* socket structure #2              */
      int                     nodelay;  /* Flag for TCP nodelay           */
      struct hostent          *addr;    /* Address of host                */
      int                     sndbufsz, /* Size of TCP send buffer        */
                              rcvbufsz; /* Size of TCP receive buffer     */
#if defined(INFINIBAND)
      IB_mtu_t                ib_mtu;   /* MTU Size for Infiniband HCA    */
      int                     commtype; /* Communications type            */
      int                     comptype; /* Completion type                */
#endif
#if defined(OPENIB)
      enum ibv_mtu            ib_mtu;   /* MTU Size for Infiniband HCA    */
      int                     commtype; /* Communications type            */
      int                     comptype; /* Completion type                */
      char                    *device_and_port; /* Local port specification */
#endif
#if defined(DAT)
      int                     commtype; /* Communications type            */
      int                     comptype; /* Completion type                */
#endif
  };

#if defined(INFINIBAND) || defined(OPENIB)
enum completion_types {
   NP_COMP_LOCALPOLL,  /* Poll locally on last byte of data     */
   NP_COMP_VAPIPOLL,   /* Poll using vapi function              */
   NP_COMP_EVENT       /* Don't poll, use vapi event completion */
};
enum communication_types {
   NP_COMM_SENDRECV,           /* Communication with send/receive            */
   NP_COMM_SENDRECV_WITH_IMM,  /* Communication with send/receive & imm data */
   NP_COMM_RDMAWRITE,          /* Communication with rdma write              */
   NP_COMM_RDMAWRITE_WITH_IMM, /* Communication with rdma write & imm data   */
};
#endif

#if defined(DAT)
enum completion_types {
   NP_COMP_LOCALPOLL,  /* Poll locally on last byte of data */
   NP_COMP_DQPOLL,     /* Poll using uDAPL dequeue function */
   NP_COMP_EVD,        /* Don't poll, use uDAPL EVD wait    */
   NP_COMP_CNO         /* Don't poll, use uDAPL CNO wait    */
};
enum communication_types {
   NP_COMM_SENDRECV,           /* Communication with send/receive            */
   NP_COMM_RDMAWRITE,          /* Communication with rdma write              */
};
#endif

#elif defined(SCTP6)
  #include <netdb.h>
  #include <sys/socket.h>
  #include <netinet/in.h>
  #include <netinet/sctp.h>
  #include <arpa/inet.h>
  
  typedef struct protocolstruct ProtocolStruct;
  struct protocolstruct
  {
      struct sockaddr_in6     sin1;   /* socket structure #1              */
      struct sockaddr_in6     sin2;   /* socket structure #2              */
      int                     nodelay;  /* Flag for TCP nodelay           */
      struct hostent          *addr;    /* Address of host                */
      int                     sndbufsz; /* Size of TCP send buffer        */
      int                     rcvbufsz; /* Size of TCP receive buffer     */
  };

#elif defined(SCTP)
  #include <netdb.h>
  #include <sys/socket.h>
  #include <netinet/in.h>
  #include <netinet/sctp.h>
  #include <arpa/inet.h>
  
  typedef struct protocolstruct ProtocolStruct;
  struct protocolstruct
  {
      struct sockaddr_in      sin1,   /* socket structure #1              */
                              sin2;   /* socket structure #2              */
      int                     nodelay;  /* Flag for TCP nodelay           */
      struct hostent          *addr;    /* Address of host                */
      int                     sndbufsz, /* Size of TCP send buffer        */
                              rcvbufsz; /* Size of TCP receive buffer     */
  };

#elif defined(TCP6)
  #include <netdb.h>
  #include <sys/socket.h>
  #include <netinet/in.h>
  #include <netinet/tcp.h>
  #include <arpa/inet.h>
  
  typedef struct protocolstruct ProtocolStruct;
  struct protocolstruct
  {
      struct sockaddr_in6     sin1;   /* socket structure #1              */
      struct sockaddr_in6     sin2;   /* socket structure #2              */
      int                     nodelay;  /* Flag for TCP nodelay           */
      struct hostent          *addr;    /* Address of host                */
      int                     sndbufsz; /* Size of TCP send buffer        */
      int                     rcvbufsz; /* Size of TCP receive buffer     */
  };

#elif defined(IPX)
  #include <netdb.h>
  #include <sys/socket.h>
  #include <netipx/ipx.h>
  
  typedef struct protocolstruct ProtocolStruct;
  struct protocolstruct
  {
      struct sockaddr_ipx     sipx1;   /* socket structure #1              */
      struct sockaddr_ipx     sipx2;   /* socket structure #2              */
      int                     sndbufsz; /* Size of send buffer        */
      int                     rcvbufsz; /* Size of receive buffer     */
  };

#elif defined(MPI)
  typedef struct protocolstruct ProtocolStruct;
  struct protocolstruct 
  { 
    int nbor, iproc;
    int use_get;
    int no_fence;
  };

#elif defined(PVM)
  typedef struct protocolstruct ProtocolStruct;

  struct protocolstruct
  {
    int     mytid; /* Keep track of our task id */
    int     othertid; /* Keep track of the other's task id */
  };

/*
  Choose one of the following to determine the type of data
  encoding for the PVM message passing.
  
  DataDefault means that PVM uses XDR encoding which ensures that
  the data can be packed / unpacked across non-homogeneous machines.
  
  If you know that the machines are the same, then you can use DataRaw
  and save some time (DDT - does not seem to help).
  
  DataInPlace means that the data is not copied at pack time, but is
  copied directly from memory at send time (DDT - this helps a lot).

#define PVMDATA     PvmDataDefault
#define PVMDATA     PvmDataRaw
#define PVMDATA     PvmDataInPlace
*/
#define PVMDATA     PvmDataInPlace


#elif defined(TCGMSG)
  typedef struct protocolstruct ProtocolStruct;
  struct protocolstruct { long nbor, nid; };

#elif defined(LAPI)
  typedef struct protocolstruct ProtocolStruct;   
  struct protocolstruct { int nbor; };

#elif defined(SHMEM)
  #if defined(GPSHMEM)
    #include "gpshmem.h"
  #else
    #include <mpp/shmem.h>
  #endif
  typedef struct protocolstruct ProtocolStruct;
  struct protocolstruct
  {
          int nbor,ipe;
          volatile int *flag;
  };

#elif defined(ARMCI)
    /* basically same as for GPSHMEM */
  double   *pTime;
  int      *pNrepeat;
  typedef struct protocolstruct ProtocolStruct;
  struct protocolstruct
  {
          int nbor,ipe;
          volatile int *flag;
  };


#elif defined(MX)
  #include "myriexpress.h"
  typedef struct protocolstruct ProtocolStruct;
  struct protocolstruct
  {
      mx_endpoint_t ep;
      mx_endpoint_addr_t addr;
      mx_request_t rreq;
  };

#elif defined(GM)
  #include "gm.h"
  typedef struct protocolstruct ProtocolStruct;
  struct protocolstruct
  { 
     int nbor, iproc, num_stokens; 
     unsigned short host_id; /* Host id in routing info of myrinet card */
  };

  struct gm_port *gm_p;
  unsigned long *ltime, *lrpt;
  char *sync, *sync1;

#elif defined(ATOLL)

  #include <atoll.h>
  
  typedef struct protocolstruct ProtocolStruct;
  struct protocolstruct
  {
      port_id id_self,       /* My port id */
              id_nbor;       /* My neighbor's port id */
  }

#elif defined(MEMCPY) || defined(VMSPLICE)
  typedef struct protocolstruct ProtocolStruct;
  struct protocolstruct { int nothing; };

#elif defined(KNEM)
#include "knem_io.h"

  typedef struct protocolstruct ProtocolStruct;
  struct protocolstruct { 
      int flags; 
      char *shared_filename;
  };

#elif defined(DISK)
  typedef struct protocolstruct ProtocolStruct;
  struct protocolstruct {
     char *dfile_name;
     int read;
     char read_type;   /* c-char  d-double  s-stream */
  };

#else
  #error "One of TCP, TCP6, SCTP, SCTP6, IPX, MPI, PVM, TCGMSG, LAPI, SHMEM, MX, GM, ATOLL, MEMCPY, DISK, VMSPLICE, or KNEM must be defined during compilation"

#endif


typedef struct argstruct ArgStruct;
struct argstruct 
{
    /* This is the common information that is needed for all tests           */
    int      cache;         /* Cache flag, 0 => limit cache, 1=> use cache   */
    char     *host;         /* Name of receiving host                        */

    int      servicefd,     /* File descriptor of the network socket         */
             commfd;        /* Communication file descriptor                 */
    short    port;          /* Port used for connection                      */
    char     *r_buff;       /* Aligned receive buffer                        */
    char     *r_buff_orig;  /* Original unaligned receive buffer             */
#if defined(USE_VOLATILE_RPTR)
    volatile                /* use volatile if polling on buffer in module   */
#endif
    char     *r_ptr;        /* Pointer to current location in send buffer    */
    char     *r_ptr_saved;  /* Pointer for saving value of r_ptr             */
    char     *s_buff;       /* Aligned send buffer                           */
    char     *s_buff_orig;  /* Original unaligned send buffer                */
    char     *s_ptr;        /* Pointer to current location in send buffer    */

    int      bufflen,       /* Length of transmitted buffer                  */
             upper,         /* Upper limit to bufflen                        */
             tr,rcv,        /* Transmit and Recv flags, or maybe neither     */
             bidir,         /* Bi-directional flag                           */
             nbuff;         /* Number of buffers to transmit                 */

    int      source_node;   /* Set to -1 (MPI_ANY_SOURCE) if -z specified    */
    int      preburst;      /* Burst preposted receives before timed runs    */
    int      reset_conn;    /* Reset connection flag                         */
    int      soffset,roffset;
    int      syncflag; /* flag for using sync sends vs. normal sends in MPI mod*/
    int	     use_sdp;       /* Use AF_INET_SDP instead of AF_INET */
    /* Now we work with a union of information for protocol dependent stuff  */
    ProtocolStruct prot;
};

typedef struct data Data;
struct data
{
    double t;
    double bps;
    double variance;
    int    bits;
    int    repeat;
};

double When();

void Init(ArgStruct *p, int* argc, char*** argv);

void Setup(ArgStruct *p);

void establish(ArgStruct *p);

void Sync(ArgStruct *p);

void PrepareToReceive(ArgStruct *p);

void SendData(ArgStruct *p);

void RecvData(ArgStruct *p);

void SendTime(ArgStruct *p, double *t);

void RecvTime(ArgStruct *p, double *t);

void SendRepeat(ArgStruct *p, int rpt);

void RecvRepeat(ArgStruct *p, int *rpt);

void FreeBuff(char *buff1, char *buff2);

void CleanUp(ArgStruct *p);

void InitBufferData(ArgStruct *p, int nbytes, int soffset, int roffset);

void MyMalloc(ArgStruct *p, int bufflen, int soffset, int roffset);

void Reset(ArgStruct *p);

void mymemset(int *ptr, int c, int n);

void flushcache(int *ptr, int n);

void SetIntegrityData(ArgStruct *p);

void VerifyIntegrity(ArgStruct *p);

void* AlignBuffer(void* buff, int boundary);

void AdvanceSendPtr(ArgStruct* p, int blocksize);

void AdvanceRecvPtr(ArgStruct* p, int blocksize);

void SaveRecvPtr(ArgStruct* p);

void ResetRecvPtr(ArgStruct* p);

void AfterAlignmentInit(ArgStruct* p);

/* void InitBufferData(ArgStruct *p, int nbytes); */

void PrintUsage();

int getopt( int argc, char * const argv[], const char *optstring);

void AfterAlignmentInit( ArgStruct *p );