[TOOLS] fix send_bw test for UD.
[mirror/winof/.git] / tools / perftests / user / send_bw / send_bw.c
index 48f23b6..5689861 100644 (file)
 #define MAX_INLINE 400
 
 struct user_parameters {
-       const char              *servername;
-       int connection_type;
-       int mtu;
-       int all; /* run all msg size */
-       int signal_comp;
-       int iters;
-       int tx_depth;
-       int duplex;
+       const char      *servername;
+       int                     connection_type;
+       int                     mtu;
+       int                     all; /* run all msg size */
+       int                     signal_comp;
+       int                     iters;
+       int                     tx_depth;
+       int                     duplex;
     int use_event;
 };
 
@@ -429,6 +429,7 @@ static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn,
                                fprintf(stderr, "Couldn't post recv: counter=%d\n", i);
                                return 14;
                        }
+                       PERF_DEBUG("rcnt = %d \n",i);
                }   
        }
        post_recv = user_parm->tx_depth;
@@ -437,7 +438,8 @@ static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn,
 }
 
 static SOCKET pp_open_port(struct pingpong_context *ctx, const char * servername,
-                       int ib_port, int port, struct pingpong_dest **p_rem_dest,struct user_parameters *user_parm)
+                       int ib_port, int port, struct pingpong_dest **p_my_dest,
+                       struct pingpong_dest **p_rem_dest,struct user_parameters *user_parm)
 {
        struct pingpong_dest    *my_dest;
        struct pingpong_dest    *rem_dest;
@@ -488,7 +490,7 @@ static SOCKET pp_open_port(struct pingpong_context *ctx, const char * servername
                my_dest[i].rkey = ctx->rkey;
                my_dest[i].vaddr = (uintptr_t)ctx->buf + ctx->size;
 
-               printf("  local address:  LID %#04x, QPN %#06x, PSN %#06x "
+               printf("  local address:  LID %#04x, QPN %#06x, PSN %#06x, "
                "RKey %#08x VAddr %#016Lx\n",
                my_dest[i].lid, my_dest[i].qpn, my_dest[i].psn,
                my_dest[i].rkey, my_dest[i].vaddr);
@@ -512,6 +514,7 @@ static SOCKET pp_open_port(struct pingpong_context *ctx, const char * servername
                        return INVALID_SOCKET;
        }
        *p_rem_dest = rem_dest;
+       *p_my_dest = my_dest;
        return sockfd;
 }
 
@@ -638,7 +641,7 @@ int run_iter_bi(struct pingpong_context *ctx, struct user_parameters *user_param
                                return 1;
                        }
                        ++scnt;
-//printf("scnt = %d \n",scnt);
+                       PERF_DEBUG("scnt = %d \n",scnt);
                }
 
                {
@@ -707,6 +710,8 @@ int run_iter_bi(struct pingpong_context *ctx, struct user_parameters *user_param
                                        p_wc_free = p_wc_done;
                                        p_wc_free->p_next = NULL;
                                        p_wc_done = NULL;
+                                       PERF_DEBUG("ccnt = %d \n",ccnt);
+                                       PERF_DEBUG("rcnt = %d \n",rcnt);
                                }
                        } while (ib_status == IB_SUCCESS );
 
@@ -714,7 +719,7 @@ int run_iter_bi(struct pingpong_context *ctx, struct user_parameters *user_param
                                fprintf(stderr, "poll CQ failed %d\n", ib_status);
                                return 1;
                        }
-//printf("ccnt = %d \n",ccnt);
+
                }
        }
        return(0);
@@ -730,11 +735,6 @@ int run_iter_uni(struct pingpong_context *ctx, struct user_parameters *user_para
        ib_recv_wr_t            *bad_wr_recv;
        ib_api_status_t ib_status;
 
-       if (user_param->connection_type==UD) {
-               if (size > 2048) {
-                       size = 2048;
-               }
-       }
 
        /* send */
        if (user_param->connection_type==UD) {
@@ -805,7 +805,7 @@ int run_iter_uni(struct pingpong_context *ctx, struct user_parameters *user_para
                                                scnt, ccnt);
                                                return 1;
                                        }
-                                       ++rcnt;
+                                       
                                        ib_status = ib_post_recv(ctx->qp[0], &ctx->rwr, &bad_wr_recv);
                                        if (ib_status != IB_SUCCESS)
                                        {
@@ -813,7 +813,11 @@ int run_iter_uni(struct pingpong_context *ctx, struct user_parameters *user_para
                                                rcnt);
                                                return 15;
                                        }
-//printf("rcnt = %d \n",rcnt);
+                                       ++rcnt;
+                                       ++ccnt;
+                                       PERF_DEBUG("ccnt = %d \n",ccnt);
+                                       PERF_DEBUG("rcnt = %d \n",rcnt);
+
                                        p_wc_free = p_wc_done;
                                        p_wc_free->p_next = NULL;
                                        p_wc_done = NULL;
@@ -840,7 +844,7 @@ int run_iter_uni(struct pingpong_context *ctx, struct user_parameters *user_para
                                        return 1;
                                }
                                ++scnt;
-//printf("scnt = %d \n",scnt);
+                               PERF_DEBUG("scnt = %d \n",scnt);
                        }
                        if (ccnt < user_param->iters) {
                                ib_wc_t wc;
@@ -887,12 +891,14 @@ int run_iter_uni(struct pingpong_context *ctx, struct user_parameters *user_para
                                                p_wc_free->p_next = NULL;
                                                p_wc_done = NULL;
                                        }
+
                                } while (ib_status == IB_SUCCESS );
                                if (ib_status != IB_NOT_FOUND) {
                                        fprintf(stderr, "poll CQ failed %d\n", ib_status);
                                        return 1;
                                }
-//printf("ccnt = %d \n",ccnt);
+
+                               PERF_DEBUG("ccnt = %d \n",ccnt);
                        }
                }
        }
@@ -903,7 +909,7 @@ int run_iter_uni(struct pingpong_context *ctx, struct user_parameters *user_para
 int __cdecl main(int argc, char *argv[])
 {
        struct pingpong_context *ctx;
-       struct pingpong_dest     my_dest;
+       struct pingpong_dest     *my_dest;
        struct pingpong_dest    *rem_dest;
        struct user_parameters  user_param;
        char                            *ib_devname = NULL;
@@ -1015,7 +1021,7 @@ int __cdecl main(int argc, char *argv[])
                case 'b':
                        user_param.duplex = 1;
                        break;
-
+               case 'h':
                default:
                        usage(argv[0]);
                        return 1;
@@ -1052,18 +1058,16 @@ int __cdecl main(int argc, char *argv[])
                return 1;
        }
        
-       if (user_param.all == ALL) {
+       if (user_param.all == ALL && user_param.connection_type!=UD) {
                /*since we run all sizes */
+               printf("test\n");
                size = 8388608; /*2^23 */
-       } else {
-               if (user_param.connection_type==UD) {
-                       if (size > 2048) {
-                               printf("Max msg size in UD is 2048 changing to 2048\n");
-                               size = 2048;
-                       }
-               }
+       } else if (user_param.connection_type==UD ) {
+               printf("Max msg size in UD is 2048 changing to 2048\n");
+               size = 2048;
        }
        
+       
        srand(GetCurrentProcessId() * GetTickCount());
 
        //TODO: get pagesize from sysinfo
@@ -1077,7 +1081,7 @@ int __cdecl main(int argc, char *argv[])
        if (!ctx)
                return 1;
        
-       sockfd = pp_open_port(ctx, user_param.servername, ib_port, port,&rem_dest,&user_param);
+       sockfd = pp_open_port(ctx, user_param.servername, ib_port, port,&my_dest,&rem_dest,&user_param);
        if (sockfd == INVALID_SOCKET)
                return 9;
        
@@ -1124,9 +1128,13 @@ int __cdecl main(int argc, char *argv[])
                        if (user_param.servername) {
                                print_report(user_param.iters, size, user_param.duplex, tposted, tcompleted);
                                /* sync again for the sake of UC/UC */
-                               pp_client_exch_dest(sockfd, &my_dest,rem_dest);
+                               if(pp_client_exch_dest(sockfd, my_dest,rem_dest))
+                                       return 19;
+                                       
                        } else {
-                               pp_server_exch_dest(sockfd, &my_dest,rem_dest);
+                               if(pp_server_exch_dest(sockfd,my_dest,rem_dest))
+                                       return 19;
+                                       
                        }
 
                }
@@ -1145,9 +1153,9 @@ int __cdecl main(int argc, char *argv[])
 
        /* close sockets */
        if (user_param.servername) {
-               pp_client_exch_dest(sockfd, &my_dest,&rem_dest[0]);
+               pp_client_exch_dest(sockfd, my_dest,rem_dest);
        } else {
-               pp_server_exch_dest(sockfd, &my_dest,&rem_dest[0]);
+               pp_server_exch_dest(sockfd, my_dest,rem_dest);
        }
 
        send(sockfd, "done", sizeof "done",0);