pub fn bench_frwr() {
    let ctx: &mut RContext = &mut ALLRCONTEXTS.get_mut()[0];
    let sa_client = &mut SA_CLIENT.get_mut();

    let mut explorer = IBExplorer::new();
    let remote_service_id = 50;
    let qd_hint = 73;
    let gid_addr = ctx.get_gid_as_string();
    let _ = explorer.resolve(1, ctx, &gid_addr, sa_client.get_inner_sa_client());
    // get path
    // thus the path resolver could be split out of other module
    let path_res = explorer.get_path_result().unwrap();
    // create Ctrl. serve for cm handshakes
    let _ctrl = RCtrl::create(remote_service_id, &mut ALLRCONTEXTS.get_mut()[0]).unwrap();

    // create RC at one side
    let rc = RC::new(&mut ALLRCONTEXTS.get_mut()[0], core::ptr::null_mut(), core::ptr::null_mut());

    let mut rc = rc.unwrap();
    let mrc = unsafe { Arc::get_mut_unchecked(&mut rc) };
    // connect to the server (Ctrl)
    let _ = mrc.connect(qd_hint + 1, path_res, remote_service_id as u64);


    let sz_list = vec![4 * K, 16 * K, 256 * K, 512 * K,
                       1 * M, 4 * M, 16 * M, 64 * M, 128 * M, 512 * M];

    fn normal_req(rc: &Arc<RC>, ctx: &RContext, l_pblock: &RMemVirt, val: usize) {
        let sz: u64 = 64;
        let lmr = l_pblock.get_inner_mr();
        let local_pa = l_pblock.get_dma_buf();
        let local_va = l_pblock.get_va_buf();
        let remote_pa = local_pa + sz;
        let remote_va = local_va + sz;
        let rkey = unsafe { (*lmr).rkey } as u32;
        let k_key = unsafe { ctx.get_lkey() };

        let mut op = RCOp::new(rc);
        println!("[before] value = {}", unsafe { *(local_va as *mut i8) });
        let ptr = remote_va as *mut usize;
        unsafe { (*ptr) = val as usize };
        let _ = op.read(local_pa, k_key,
                        64 as usize, remote_pa, rkey);

        println!("[after] value = {}", unsafe { *(local_va as *mut usize) });
    }

    fn run_single_test(rc: &Arc<RC>, sz: usize) {
        let qp = rc.get_qp();
        let mut profile = Profile::new();
        let en_len = 1 + (sz / PG_SZ);
        let ctx: &mut RContext = &mut ALLRCONTEXTS.get_mut()[0];
        let alloc_sz = sz;
        let running_cnt = 10;
        let flag = ib_access_flags::IB_ACCESS_LOCAL_WRITE |
            ib_access_flags::IB_ACCESS_REMOTE_READ |
            ib_access_flags::IB_ACCESS_REMOTE_WRITE;
        let mut ptr: Box<[core::mem::MaybeUninit<i8>], VmallocAllocator> =
            Box::new_zeroed_slice_in(alloc_sz as usize, VmallocAllocator);
        for _ in 0..running_cnt {
            profile.reset_timer();
            let mr = unsafe {
                ib_alloc_mr(ctx.get_pd(),
                            ib_mr_type::IB_MR_TYPE_MEM_REG, en_len as u32)
            };
            profile.tick_record(0);
            let l_pblock = RMemVirt::create_from_mr(ctx, mr, ptr[0].as_mut_ptr(), alloc_sz as u64);
            send_reg_mr(qp, l_pblock.get_inner_mr(), flag, true);
            wait_one_cq(rc.get_cq());
            profile.tick_record(1);
            // normal_req(&rc, ctx, &l_pblock, sz);
        }
        profile.increase_op(running_cnt);
        println!("RegMR sz: [ {} ]", sz);
        profile.report(2);
    }
    for sz in sz_list {
        run_single_test(&rc, sz);
    }
}
/// Basic payload-latency benchmark upon FRWR
Basic payload-latency benchmark upon FRWR
Basic payload - latency benchmark upon FRWR
pub fn bench_frwr() {
    let ctx: &mut RContext = &mut ALLRCONTEXTS.get_mut()[0];
    let sa_client = &mut SA_CLIENT.get_mut();
    let mut explorer = IBExplorer::new();
    let remote_service_id = 50;
    let qd_hint = 73;
    let gid_addr = ctx.get_gid_as_string();
    let _ = explorer.resolve(1, ctx, &gid_addr, sa_client.get_inner_sa_client());
    // get path
    // thus the path resolver could be split out of other module
    let path_res = explorer.get_path_result().unwrap();
    // create Ctrl. serve for cm handshakes
    let _ctrl = RCtrl::create(remote_service_id, &mut ALLRCONTEXTS.get_mut()[0]).unwrap();
    // create RC at one side
    let rc = RC::new(&mut ALLRCONTEXTS.get_mut()[0], core::ptr::null_mut(), core::ptr::null_mut());
    let mut rc = rc.unwrap();
    let mrc = unsafe { Arc::get_mut_unchecked(&mut rc) };
    // connect to the server (Ctrl)
    let _ = mrc.connect(qd_hint + 1, path_res, remote_service_id as u64);
    let sz_list = vec![4 * K, 16 * K, 256 * K, 512 * K,
                       1 * M, 4 * M, 16 * M, 64 * M, 128 * M, 512 * M];
    fn normal_req(rc: &Arc<RC>, ctx: &RContext, l_pblock: &RMemVirt, val: usize) {
        let sz: u64 = 64;
        let lmr = l_pblock.get_inner_mr();
        let local_pa = l_pblock.get_dma_buf();
        let local_va = l_pblock.get_va_buf();
        let remote_pa = local_pa + sz;
        let remote_va = local_va + sz;
        let rkey = unsafe { (*lmr).rkey } as u32;
        let k_key = unsafe { ctx.get_lkey() };
        let mut op = RCOp::new(rc);
        println!("[before] value = {}", unsafe { *(local_va as *mut i8) });
        let ptr = remote_va as *mut usize;
        unsafe { (*ptr) = val as usize };
        let _ = op.read(local_pa, k_key,
                        64 as usize, remote_pa, rkey);
        println!("[after] value = {}", unsafe { *(local_va as *mut usize) });
    }
    fn run_single_test(rc: &Arc<RC>, sz: usize) {
        let qp = rc.get_qp();
        let mut profile = Profile::new();
        let en_len = 1 + (sz / PG_SZ);
        let ctx: &mut RContext = &mut ALLRCONTEXTS.get_mut()[0];
        let alloc_sz = sz;
        let running_cnt = 10;
        let flag = ib_access_flags::IB_ACCESS_LOCAL_WRITE |
            ib_access_flags::IB_ACCESS_REMOTE_READ |
            ib_access_flags::IB_ACCESS_REMOTE_WRITE;
        let mut ptr: Box<[core::mem::MaybeUninit<i8>], VmallocAllocator> =
            Box::new_zeroed_slice_in(alloc_sz as usize, VmallocAllocator);
        for _ in 0..running_cnt {
            profile.reset_timer();
            let mr = unsafe {
                ib_alloc_mr(ctx.get_pd(),
                            ib_mr_type::IB_MR_TYPE_MEM_REG, en_len as u32)
            };
            profile.tick_record(0);
            let l_pblock = RMemVirt::create_from_mr(ctx, mr, ptr[0].as_mut_ptr(), alloc_sz as u64);
            send_reg_mr(qp, l_pblock.get_inner_mr(), flag, true);
            wait_one_cq(rc.get_cq());
            profile.tick_record(1);
            // normal_req(&rc, ctx, &l_pblock, sz);
        }
        profile.increase_op(running_cnt);
        println!("RegMR sz: [ {} ]", sz);
        profile.report(2);
    }
    for sz in sz_list {
        run_single_test(&rc, sz);
    }
}
pub fn bench_frwr ( ) { let ctx : & mut RContext = & mut ALLRCONTEXTS . get_mut ( ) [ 0 ] ; let sa_client = & mut SA_CLIENT . get_mut ( ) ; let mut explorer = IBExplorer :: new ( ) ; let remote_service_id = 50 ; let qd_hint = 73 ; let gid_addr = ctx . get_gid_as_string ( ) ; let _ = explorer . resolve ( 1 , ctx , & gid_addr , sa_client . get_inner_sa_client ( ) ) ; // get path // thus the path resolver could be split out of other module let path_res = explorer . get_path_result ( ) . unwrap ( ) ; // create Ctrl. serve for cm handshakes let _ctrl = RCtrl :: create ( remote_service_id , & mut ALLRCONTEXTS . get_mut ( ) [ 0 ] ) . unwrap ( ) ; // create RC at one side let rc = RC :: new ( & mut ALLRCONTEXTS . get_mut ( ) [ 0 ] , core :: ptr :: null_mut ( ) , core :: ptr :: null_mut ( ) ) ; let mut rc = rc . unwrap ( ) ; let mrc = unsafe { Arc :: get_mut_unchecked ( & mut rc ) } ; // connect to the server (Ctrl) let _ = mrc . connect ( qd_hint + 1 , path_res , remote_service_id as u64 ) ; let sz_list = vec ! [ 4 K 16 K 256 K 512 K 1 M 4 M 16 M 64 M 128 M 512 M ] ; fn normal_req ( rc : & Arc < RC > , ctx : & RContext , l_pblock : & RMemVirt , val : usize ) { let sz : u64 = 64 ; let lmr = l_pblock . get_inner_mr ( ) ; let local_pa = l_pblock . get_dma_buf ( ) ; let local_va = l_pblock . get_va_buf ( ) ; let remote_pa = local_pa + sz ; let remote_va = local_va + sz ; let rkey = unsafe { ( * lmr ) . rkey } as u32 ; let k_key = unsafe { ctx . get_lkey ( ) } ; let mut op = RCOp :: new ( rc ) ; println ! ( " " unsafe { ( local_va as mut i8 ) } ) ; let ptr = remote_va as * mut usize ; unsafe { ( * ptr ) = val as usize } ; let _ = op . read ( local_pa , k_key , 64 as usize , remote_pa , rkey ) ; println ! ( " " unsafe { ( local_va as mut usize ) } ) ; } fn run_single_test ( rc : & Arc < RC > , sz : usize ) { let qp = rc . get_qp ( ) ; let mut profile = Profile :: new ( ) ; let en_len = 1 + ( sz / PG_SZ ) ; let ctx : & mut RContext = & mut ALLRCONTEXTS . get_mut ( ) [ 0 ] ; let alloc_sz = sz ; let running_cnt = 10 ; let flag = ib_access_flags :: IB_ACCESS_LOCAL_WRITE | ib_access_flags :: IB_ACCESS_REMOTE_READ | ib_access_flags :: IB_ACCESS_REMOTE_WRITE ; let mut ptr : Box < [ core :: mem :: MaybeUninit < i8 > ] , VmallocAllocator > = Box :: new_zeroed_slice_in ( alloc_sz as usize , VmallocAllocator ) ; for _ in 0 .. running_cnt { profile . reset_timer ( ) ; let mr = unsafe { ib_alloc_mr ( ctx . get_pd ( ) , ib_mr_type :: IB_MR_TYPE_MEM_REG , en_len as u32 ) } ; profile . tick_record ( 0 ) ; let l_pblock = RMemVirt :: create_from_mr ( ctx , mr , ptr [ 0 ] . as_mut_ptr ( ) , alloc_sz as u64 ) ; send_reg_mr ( qp , l_pblock . get_inner_mr ( ) , flag , true ) ; wait_one_cq ( rc . get_cq ( ) ) ; profile . tick_record ( 1 ) ; // normal_req(&rc, ctx, &l_pblock, sz); } profile . increase_op ( running_cnt ) ; println ! ( " " sz ) ; profile . report ( 2 ) ; } for sz in sz_list { run_single_test ( & rc , sz ) ; } }
Basic payload-latency benchmark upon FRWR
Basic payload - latency benchmark upon FRWR