@@ -275,7 +275,8 @@ static void usage(char * const argv[])
275275    fprintf (stderr , "%s -k key_name -f format_name [-t] [-v] [-T time] threadcount\n" 
276276        "\t-t  terse output\n" 
277277        "\t-v  verbose output, includes min, max, stddev, and median times\n" 
278-         "\t-T  timeout for each test run in seconds, can be fractional" 
278+         "\t-T  timeout for each test run in seconds, can be fractional\n" 
279+         "\t-b  Set CPU affinity for the threads (in round robin fashion)\n" 
279280        "\twhere key_name is one of these: " , argv [0 ]);
280281    fprintf (stderr , "%s" , * key_name );
281282    do  {
@@ -303,6 +304,7 @@ int main(int argc, char * const argv[])
303304    int  key_id , key_id_min , key_id_max , k ;
304305    int  format_id , format_id_min , format_id_max , f ;
305306    int  verbosity  =  VERBOSITY_DEFAULT ;
307+     int  bind_threads  =  0 ;
306308    char  * key  =  NULL ;
307309    char  * key_format  =  NULL ;
308310    void  (* do_f [2 ])(size_t ) =  {
@@ -313,7 +315,7 @@ int main(int argc, char * const argv[])
313315    key_id  =  SAMPLE_INVALID ;
314316    format_id  =  FORMAT_INVALID ;
315317
316-     while  ((ch  =  getopt (argc , argv , "T:k:f:tv " )) !=  -1 ) {
318+     while  ((ch  =  getopt (argc , argv , "T:k:f:tvb " )) !=  -1 ) {
317319        switch  (ch ) {
318320        case  'T' : {
319321            double  timeout_s ;
@@ -342,6 +344,9 @@ int main(int argc, char * const argv[])
342344        case  'v' :
343345            verbosity  =  VERBOSITY_VERBOSE ;
344346            break ;
347+         case  'b' :
348+             bind_threads  =  1 ;
349+             break ;
345350        }
346351    }
347352
@@ -419,7 +424,9 @@ int main(int argc, char * const argv[])
419424        for  (f  =  format_id_min ; f  <  format_id_max ; f ++ ) {
420425            sample_id  =  k ;
421426            max_time  =  ossl_time_add (ossl_time_now (), ossl_us2time (timeout_us ));
422-             if  (!perflib_run_multi_thread_test (do_f [f ], threadcount , & duration )) {
427+             if  (!perflib_run_multi_thread_test_ex (do_f [f ], threadcount ,
428+                 & duration , bind_threads  ? perflib_roundrobin_affinity  : NULL ,
429+                 NULL )) {
423430                fprintf (stderr , "Failed to run the test %s in %s format\n" ,
424431                        sample_names [k ], format_names [f ]);
425432                OPENSSL_free (counts );
0 commit comments