File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -1023,6 +1023,47 @@ fn bench(args: Args) {
1023
1023
drop ( streams) ;
1024
1024
}
1025
1025
1026
+ // test
1027
+ #[ cfg( test) ]
1028
+ mod tests {
1029
+ use super :: * ;
1030
+
1031
+ #[ test]
1032
+ fn test_bench ( ) {
1033
+
1034
+ env_logger:: init ( ) ;
1035
+ std:: env:: set_var ( "NCCL_PLUGIN_P2P" , "socket" ) ;
1036
+ nccl_net:: init ( ) ;
1037
+
1038
+ let b = std:: thread:: spawn ( || {
1039
+ let count = format ! ( "{}" , 1024 * 1024 ) ;
1040
+ let args = Args :: parse_from ( vec ! [
1041
+ "--bench" ,
1042
+ "--address" ,
1043
+ "127.0.0.1" ,
1044
+ "--port" ,
1045
+ "8080" ,
1046
+ "--count" ,
1047
+ & count,
1048
+ ] ) ;
1049
+ bench ( args) ;
1050
+ } ) ;
1051
+ let c = std:: thread:: spawn ( || {
1052
+ let count = format ! ( "{}" , 1024 * 1024 ) ;
1053
+ let args = Args :: parse_from ( vec ! [
1054
+ "--client" ,
1055
+ "--address" ,
1056
+ "127.0.0.1:8080" ,
1057
+ "--count" ,
1058
+ & count,
1059
+ ] ) ;
1060
+ client ( args) ;
1061
+ } ) ;
1062
+ b. join ( ) . unwrap ( ) ;
1063
+ c. join ( ) . unwrap ( ) ;
1064
+ }
1065
+ }
1066
+
1026
1067
fn alignment ( size : usize ) -> usize {
1027
1068
let page = unsafe { libc:: sysconf ( libc:: _SC_PAGESIZE) as usize } ;
1028
1069
( size + page - 1 ) & !( page - 1 )
You can’t perform that action at this time.
0 commit comments