@@ -493,7 +493,6 @@ submit_test_desc(struct tcfg_cpu *tcpu)
493493 uint32_t i ;
494494 int d ;
495495 struct tcfg * tcfg ;
496- bool inf ;
497496 int nb_desc ;
498497
499498 tcfg = tcpu -> tcfg ;
@@ -534,16 +533,14 @@ submit_test_desc(struct tcfg_cpu *tcpu)
534533 else
535534 INFO_CPU (tcpu , "Running BW test\n" );
536535
537- inf = tcfg -> iter == ~0U ;
538-
539536 if (do_single_iter (tcpu , nb_desc )) {
540537 ERR ("Failed initial descriptor submission\n" );
541538 goto error2 ;
542539 }
543540
544541 tcpu -> curr_stat .iter = 0 ;
545542 tcpu -> tstart = rdtsc ();
546- for (i = 0 ; !tcfg -> stop && (inf || i < tcfg -> iter ) ; i ++ ) {
543+ for (i = 0 ; !tcfg -> stop && (tcfg -> tval_secs || i < tcfg -> iter ) ; i ++ ) {
547544 if (do_single_iter (tcpu , nb_desc )) {
548545 ERR ("Error iteration: %d\n" , i );
549546 goto error2 ;
@@ -553,7 +550,6 @@ submit_test_desc(struct tcfg_cpu *tcpu)
553550 tcpu -> tend = rdtsc ();
554551
555552 tcpu -> cycles = tcpu -> tend - tcpu -> tstart ;
556- tcpu -> cycles /= tcfg -> iter ;
557553
558554 d = 0 ;
559555 while (d < tcpu -> qd ) {
@@ -622,7 +618,6 @@ test_run_fn(void *arg)
622618{
623619 struct tcfg_cpu * tcpu = arg ;
624620 struct tcfg * tcfg = tcpu -> tcfg ;
625- bool do_sub_rate ;
626621
627622 cpu_pin (tcpu -> cpu_num );
628623
@@ -631,49 +626,14 @@ test_run_fn(void *arg)
631626 return 0 ;
632627 }
633628
634- do_sub_rate = tcfg -> misc_flags &
635- (TEST_M64 | TEST_DB | TEST_M64MEM |
636- TEST_ENQ | TEST_ENQMEM );
637-
638- if (tcfg -> op == DSA_OPCODE_NOOP && do_sub_rate )
629+ if (is_work_rate_sub_test (tcfg ))
639630 work_sub_rate_test (tcpu );
640631 else
641632 do_desc_work (tcpu );
642633
643634 return 0 ;
644635}
645636
646- static void
647- iter_count_stat (uint64_t * stat , uint64_t * prev , uint64_t * curr )
648- {
649- * stat += * curr - * prev ;
650- * prev = * curr ;
651- }
652-
653- static void
654- count_stat (struct iter_stat * is , struct tcfg_cpu * tcpu )
655- {
656- int i ;
657-
658- for (i = 0 ; i < ARRAY_SIZE (is -> stat ); i ++ )
659- iter_count_stat (& is -> stat [i ], & tcpu -> prev_stat .stat [i ],
660- & tcpu -> curr_stat .stat [i ]);
661- }
662-
663- static void
664- iter_count (struct tcfg * tcfg , struct iter_stat * iter_stat )
665- {
666- unsigned int i ;
667- struct iter_stat is = {};
668-
669- for (i = 0 ; i < tcfg -> nb_cpus ; i ++ ) {
670- struct tcfg_cpu * tcpu = & tcfg -> tcpu [i ];
671-
672- count_stat (& is , tcpu );
673- }
674-
675- * iter_stat = is ;
676- }
677637
678638static void *
679639test_fn (void * arg )
@@ -702,10 +662,36 @@ test_fn(void *arg)
702662 return NULL ;
703663}
704664
665+ static void
666+ print_results (struct tcfg * tcfg )
667+ {
668+ if (is_work_rate_sub_test (tcfg )) {
669+ printf ("kopsrate = %d" , tcfg -> kops_rate );
670+ if (tcfg -> misc_flags & (TEST_ENQ | TEST_ENQMEM ))
671+ printf (" latency = %d ns" , (1000 * 1000 ) / tcfg -> kops_rate );
672+ printf ("\n" );
673+ return ;
674+ }
675+
676+ printf ("GB per sec = %f" , tcfg -> bw );
677+ if (tcfg -> qd == 1 || tcfg -> nb_bufs == 1 )
678+ printf (" latency(cycles) = %f, %f ns, cycles/sec =%ld" ,
679+ tcfg -> latency , (tcfg -> latency * 1E9 )/tcfg -> cycles_per_sec ,
680+ tcfg -> cycles_per_sec );
681+ printf (" cpu %f kopsrate = %d\n" , tcfg -> cpu_util , tcfg -> kops_rate );
682+
683+ if (tcfg -> drain_desc ) {
684+ double drain_usec = ((1.0 * tcfg -> drain_lat )/tcfg -> cycles_per_sec ) * 1000000 ;
685+
686+ printf ("Drain desc latency = %lu cycles | %f uSec\n" , tcfg -> drain_lat , drain_usec );
687+ }
688+ }
689+
705690static int
706691test_run (struct tcfg * tcfg )
707692{
708693 int i , err = 0 ;
694+ bool inf = tcfg -> iter == -1 ;
709695
710696 for (i = 0 ; i < tcfg -> nb_cpus ; i ++ ) {
711697
@@ -728,19 +714,16 @@ test_run(struct tcfg *tcfg)
728714 }
729715 }
730716
731- if (tcfg -> iter == ~0U ) {
732- uint64_t iter_bytes = data_size_per_iter (tcfg );
717+ if (tcfg -> tval_secs ) {
733718
734719 err = false;
735- while (!err ) {
736- float bw ;
737- struct iter_stat is ;
720+ while (!tcfg -> stop ) {
738721
739- sleep (tcfg -> tval_secs );
740- iter_count ( tcfg , & is );
722+ while (tcfg -> tcpu [ 0 ]. tstart == 0 )
723+ __builtin_ia32_pause ( );
741724
742- bw = ( is . iter * iter_bytes )/( 1E9 * tcfg -> tval_secs );
743- bw = bw / tcfg -> nb_cpus ;
725+ sleep ( tcfg -> tval_secs );
726+ do_results ( tcfg ) ;
744727
745728 for (i = 0 , err = false; i < tcfg -> nb_cpus ; i ++ ) {
746729 struct tcfg_cpu * tcpu = & tcfg -> tcpu [i ];
@@ -757,11 +740,8 @@ test_run(struct tcfg *tcfg)
757740 continue ;
758741 }
759742
760- tcfg -> retry = is .retry / tcfg -> nb_cpus ;
761- tcfg -> mwait_cycles = is .mwait_cycles / tcfg -> nb_cpus ;
762- calc_cpu_for_sec (tcfg , tcfg -> tval_secs );
763-
764- fprintf (stdout , "BW %f GB cpu util %f\n" , bw , tcfg -> cpu_util );
743+ print_results (tcfg );
744+ tcfg -> stop = !inf ;
765745 }
766746 }
767747
@@ -803,7 +783,7 @@ main(int argc, char **argv)
803783 .flags_nth_desc = 1 ,
804784 .flags_cmask = -1 ,
805785 .flags_smask = 0 ,
806- .tval_secs = 4 ,
786+ .tval_secs = 0 ,
807787 .numa_node_default = { -1 , -1 , -1 },
808788 .place_op = { OP_FLUSH , OP_FLUSH , OP_FLUSH },
809789 .access_op = { OP_WRITE , OP_WRITE , OP_WRITE },
@@ -838,20 +818,8 @@ main(int argc, char **argv)
838818
839819 do_results (& tcfg );
840820
841- printf ("GB per sec = %f" , tcfg .bw );
842- if (tcfg .qd == 1 || tcfg .nb_bufs == 1 )
843- printf (" latency(cycles) = %f, %f ns,"
844- " cycles/sec =%ld" ,
845- tcfg .latency , (tcfg .latency * 1E9 )/tcfg .cycles_per_sec ,
846- tcfg .cycles_per_sec );
847- printf (" cpu %f kopsrate = %d\n" , tcfg .cpu_util , tcfg .ops_rate );
848-
849-
850- if (tcfg .drain_desc ) {
851- double drain_usec = ((1.0 * tcfg .drain_lat )/tcfg .cycles_per_sec ) * 1000000 ;
852-
853- printf ("Drain desc latency = %lu cycles | %f uSec\n" , tcfg .drain_lat , drain_usec );
854- }
821+ if (!tcfg .tval_secs )
822+ print_results (& tcfg );
855823
856824err_ret :
857825 test_free (& tcfg );
0 commit comments