~ubuntu-branches/ubuntu/trusty/netpipe/trusty

« back to all changes in this revision

Viewing changes to src/netpipe.c

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2010-01-06 19:07:32 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100106190732-fg9urgk31weolrcs
Tags: 3.7.1-1
* New upstream release
* Bug fix: "debian/watch fails to report upstream's version", thanks
  to Raphael Geissert (Closes: #450010).

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
                start= 1,       /* Starting value for signature curve        */
55
55
                end=MAXINT,     /* Ending value for signature curve          */
56
56
                streamopt=0,    /* Streaming mode flag                       */
57
 
                reset_connection;/* Reset the connection between trials      */
 
57
                reset_connection,/* Reset the connection between trials      */
 
58
                debug_wait=0;   /* spin and wait for a debugger              */
58
59
   
59
60
    ArgStruct   args;           /* Arguments for all the calls               */
60
61
 
84
85
    args.soffset=0; /* default to no offsets */
85
86
    args.roffset=0; 
86
87
    args.syncflag=0; /* use normal mpi_send */
 
88
    args.use_sdp=0; /* default to no SDP */
 
89
    args.port = DEFPORT; /* just in case the user doesn't set this. */
87
90
 
88
91
 
89
92
    /* TCGMSG launches NPtcgmsg with a -master master_hostname
94
97
#if ! defined(TCGMSG)
95
98
 
96
99
    /* Parse the arguments. See Usage for description */
97
 
    while ((c = getopt(argc, argv, "SO:rIiPszgfaB2h:p:o:l:u:b:m:n:t:c:d:D:")) != -1)
 
100
    while ((c = getopt(argc, argv, "AXSO:rIiPszgfaB2h:p:o:l:u:b:m:n:t:c:d:D:P:")) != -1)
98
101
    {
99
102
        switch(c)
100
103
        {
 
104
            case 'A':
 
105
                      args.use_sdp=1;
 
106
                      break;
101
107
            case 'O':
102
108
                      strcpy(s2,optarg);
103
109
                      strcpy(delim,",");
142
148
 
143
149
            case 's': streamopt = 1;
144
150
                      printf("Streaming in one direction only.\n\n");
145
 
#if defined(TCP) && ! defined(INFINIBAND) 
 
151
#if defined(TCP) && ! defined(INFINIBAND) && !defined(OPENIB)
146
152
                      printf("Sockets are reset between trials to avoid\n");
147
153
                      printf("degradation from a collapsing window size.\n\n");
148
154
#endif
168
174
            case 'u': end = atoi(optarg);
169
175
                      break;
170
176
 
171
 
#if defined(TCP) && ! defined(INFINIBAND)
 
177
#if defined(TCP) && ! defined(INFINIBAND) && !defined(OPENIB)
172
178
            case 'b': /* -b # resets the buffer size, -b 0 keeps system defs */
173
179
                      args.prot.sndbufsz = args.prot.rcvbufsz = atoi(optarg);
174
180
                      break;
178
184
                         /* end will be maxed at sndbufsz+rcvbufsz */
179
185
                      printf("Passing data in both directions simultaneously.\n");
180
186
                      printf("Output is for the combined bandwidth.\n");
181
 
#if defined(TCP) && ! defined(INFINIBAND)
 
187
#if defined(TCP) && ! defined(INFINIBAND) && !defined(OPENIB)
182
188
                      printf("The socket buffer size limits the maximum test size.\n\n");
183
189
#endif
184
190
                      if( streamopt ) {
270
276
                          exit(-1);
271
277
                      }
272
278
                      break;
273
 
 
 
279
#endif
 
280
 
 
281
#if defined(OPENIB)
 
282
            case 'm': switch(atoi(optarg)) {
 
283
                        case 256: args.prot.ib_mtu = IBV_MTU_256;
 
284
                          break;
 
285
                        case 512: args.prot.ib_mtu = IBV_MTU_512;
 
286
                          break;
 
287
                        case 1024: args.prot.ib_mtu = IBV_MTU_1024;
 
288
                          break;
 
289
                        case 2048: args.prot.ib_mtu = IBV_MTU_2048;
 
290
                          break;
 
291
                        case 4096: args.prot.ib_mtu = IBV_MTU_4096;
 
292
                          break;
 
293
                        default: 
 
294
                          fprintf(stderr, "Invalid MTU size, must be one of "
 
295
                                          "256, 512, 1024, 2048, 4096\n");
 
296
                          exit(-1);
 
297
                      }
 
298
                      break;
 
299
#endif
 
300
 
 
301
#if defined(OPENIB)
 
302
            case 'D': args.prot.device_and_port = strdup(optarg);
 
303
                      break;
 
304
#endif
 
305
 
 
306
#if defined(OPENIB) || defined(INFINIBAND)
274
307
            case 't': if( !strcmp(optarg, "send_recv") ) {
275
308
                         printf("Using Send/Receive communications\n");
276
309
                         args.prot.commtype = NP_COMM_SENDRECV;
313
346
                      }
314
347
                      break;
315
348
#endif
 
349
            case 'P': 
 
350
                      args.port = atoi(optarg);
 
351
                      break;
316
352
 
317
353
            case 'n': nrepeat_const = atoi(optarg);
318
354
                      break;
319
355
 
320
 
#if defined(TCP) && ! defined(INFINIBAND)
 
356
#if defined(TCP) && ! defined(INFINIBAND) && !defined(OPENIB)
321
357
            case 'r': args.reset_conn = 1;
322
358
                      printf("Resetting connection after every trial\n");
323
359
                      break;
324
360
#endif
 
361
            case 'X': debug_wait = 1;
 
362
                      printf("Enableing debug wait!\n");
 
363
                      printf("Attach to pid %d and set debug_wait to 0 to conttinue\n", getpid());
 
364
                      break;
325
365
 
326
366
            default: 
327
367
                     PrintUsage(); 
329
369
       }
330
370
   }
331
371
 
 
372
   while(debug_wait){
 
373
           for(i=0;i<10000;i++){};
 
374
        };
332
375
#endif /* ! defined TCGMSG */
333
376
 
334
 
#if defined(INFINIBAND)
 
377
#if defined(OPENIB) || defined(INFINIBAND)
335
378
   asyncReceive = 1;
336
379
   fprintf(stderr, "Preposting asynchronous receives (required for Infiniband)\n");
337
380
   if(args.bidir && (
369
412
       exit(420132);
370
413
   }
371
414
   args.nbuff = TRIALS;
372
 
   args.port = DEFPORT;
373
415
 
374
416
   Setup(&args);
375
417
 
377
419
      end = args.upper;
378
420
      if( args.tr ) {
379
421
         printf("The upper limit is being set to %d Bytes\n", end);
380
 
#if defined(TCP) && ! defined(INFINIBAND)
 
422
#if defined(TCP) && ! defined(INFINIBAND) && !defined(OPENIB)
381
423
         printf("due to socket buffer size limitations\n\n");
382
424
#endif
383
425
   }  }
990
1032
void PrintUsage()
991
1033
{
992
1034
    printf("\n NETPIPE USAGE \n\n");
993
 
#if ! defined(INFINIBAND)
 
1035
#if ! defined(INFINIBAND) && !defined(OPENIB)
994
1036
    printf("a: asynchronous receive (a.k.a. preposted receive)\n");
995
1037
#endif
996
1038
    printf("B: burst all preposts before measuring performance\n");
997
 
#if defined(TCP) && ! defined(INFINIBAND)
 
1039
#if (defined(TCP) || defined(TCP6)) && ! defined(INFINIBAND)
998
1040
    printf("b: specify TCP send/receive socket buffer sizes\n");
999
1041
#endif
1000
1042
 
1001
 
#if defined(INFINIBAND)
 
1043
#if defined(INFINIBAND) || defined(OPENIB)
1002
1044
    printf("c: specify type of completion <-c type>\n"
1003
1045
           "   valid types: local_poll, vapi_poll, event\n"
1004
1046
           "   default: local_poll\n");
1010
1052
    printf("   all MPI-2 implementations\n");
1011
1053
#endif
1012
1054
 
1013
 
#if defined(TCP) || defined(INFINIBAND)
 
1055
#if defined(TCP) || defined(TCP6) || defined(SCTP) || defined(SCTP6) || defined(INFINIBAND) || defined(OPENIB)
1014
1056
    printf("h: specify hostname of the receiver <-h host>\n");
1015
1057
#endif
1016
1058
 
1019
1061
    printf("i: Do an integrity check instead of measuring performance\n");
1020
1062
    printf("l: lower bound start value e.g. <-l 1>\n");
1021
1063
 
1022
 
#if defined(INFINIBAND)
 
1064
#if defined(INFINIBAND) || defined(OPENIB)
1023
1065
    printf("m: set MTU for Infiniband adapter <-m mtu_size>\n");
1024
1066
    printf("   valid sizes: 256, 512, 1024, 2048, 4096 (default 1024)\n");
1025
1067
#endif
1030
1072
    printf("p: set the perturbation number <-p 1>\n"
1031
1073
           "   (default = 3 Bytes, set to 0 for no perturbations)\n");
1032
1074
 
1033
 
#if defined(TCP) && ! defined(INFINIBAND)
 
1075
#if (defined(TCP) || defined(TCP6) || defined(SCTP) || defined(SCTP6)) && ! defined(INFINIBAND) && !defined(OPENIB)
1034
1076
    printf("r: reset sockets for every trial\n");
1035
1077
#endif
1036
1078
 
1039
1081
    printf("S: Use synchronous sends.\n");
1040
1082
#endif
1041
1083
 
1042
 
#if defined(INFINIBAND)
 
1084
#if defined(INFINIBAND) || defined(OPENIB)
1043
1085
    printf("t: specify type of communications <-t type>\n"
1044
1086
           "   valid types: send_recv, send_recv_with_imm,\n"
1045
1087
           "                rdma_write, rdma_write_with_imm\n"
1046
1088
           "   defaul: send_recv\n");
1047
1089
#endif
 
1090
#if defined(OPENIB)
 
1091
    printf("D: specify an OpenFabrics device/port combination\n"
 
1092
           "   to use on the local host.  For example:\n"
 
1093
           "      -D mthca0:1\n"
 
1094
           "   Uses the first port on the \"mthca0\" device\n"
 
1095
           "   (NOTE: ports are indexed from 1, not 0)\n"
 
1096
           "      -D mthca1\n"
 
1097
           "   Uses the first active port on the mtcha1 device\n"
 
1098
           "   No specification will result in using the first\n"
 
1099
           "   active port on any valid device.\n");
 
1100
#endif
1048
1101
    
1049
1102
    printf("u: upper bound stop value e.g. <-u 1048576>\n");
1050
1103
 
1053
1106
#endif
1054
1107
 
1055
1108
    printf("2: Send data in both directions at the same time.\n");
 
1109
    printf("P: Set the port number to one other than the default.\n");
1056
1110
#if defined(MPI)
1057
1111
    printf("   May need to use -a to choose asynchronous communications for MPI/n");
1058
1112
#endif
1059
 
#if defined(TCP) && !defined(INFINIBAND)
1060
 
    printf("   The maximum test size is limited by the TCP buffer size/n");
 
1113
#if (defined(TCP) || defined(TCP6) || defined(SCTP) || defined (SCTP6)) && !defined(INFINIBAND) && !defined(OPENIB)
 
1114
    printf("   The maximum test size is limited by the TCP buffer size\n");
 
1115
#endif
 
1116
#if defined(TCP)
 
1117
    printf("A: Use SDP Address familty (AF_INET_SDP)\n");
1061
1118
#endif
1062
1119
    printf("\n");
1063
1120
}
1131
1188
 
1132
1189
    memset(p->s_buff, 'b', nbytes+soffset);
1133
1190
}
1134
 
#if !defined(INFINIBAND) && !defined(ARMCI) && !defined(LAPI) && !defined(GPSHMEM) && !defined(SHMEM) && !defined(GM)
 
1191
#if !defined(OPENIB) && !defined(INFINIBAND) && !defined(ARMCI) && !defined(LAPI) && !defined(GPSHMEM) && !defined(SHMEM) && !defined(GM) 
1135
1192
 
1136
1193
void MyMalloc(ArgStruct *p, int bufflen, int soffset, int roffset)
1137
1194
{