11use super :: * ;
22
3+ /// A memory region allocated through UCP library,
4+ /// which is optimized for remote memory access operations.
35#[ derive( Debug ) ]
46pub struct MemoryHandle {
57 handle : ucp_mem_h ,
68 context : Arc < Context > ,
79}
810
911impl MemoryHandle {
12+ /// Register memory region.
1013 pub fn register ( context : & Arc < Context > , region : & mut [ u8 ] ) -> Self {
1114 #[ allow( invalid_value) ]
1215 #[ allow( clippy:: uninit_assumed_init) ]
@@ -53,6 +56,7 @@ impl Drop for MemoryHandle {
5356 }
5457}
5558
59+ /// An owned buffer containing remote access key.
5660#[ derive( Debug ) ]
5761pub struct RKeyBuffer {
5862 buf : * mut c_void ,
@@ -71,6 +75,7 @@ impl Drop for RKeyBuffer {
7175 }
7276}
7377
78+ /// Remote access key.
7479#[ derive( Debug ) ]
7580pub struct RKey {
7681 handle : ucp_rkey_h ,
@@ -80,6 +85,7 @@ unsafe impl Send for RKey {}
8085unsafe impl Sync for RKey { }
8186
8287impl RKey {
88+ /// Create remote access key from packed buffer.
8389 pub fn unpack ( endpoint : & Endpoint , rkey_buffer : & [ u8 ] ) -> Self {
8490 let mut handle = MaybeUninit :: uninit ( ) ;
8591 let status = unsafe {
@@ -103,6 +109,7 @@ impl Drop for RKey {
103109}
104110
105111impl Endpoint {
112+ /// Stores a contiguous block of data into remote memory.
106113 pub async fn put ( & self , buf : & [ u8 ] , remote_addr : u64 , rkey : & RKey ) -> Result < ( ) , Error > {
107114 trace ! ( "put: endpoint={:?} len={}" , self . handle, buf. len( ) ) ;
108115 unsafe extern "C" fn callback ( request : * mut c_void , status : ucs_status_t ) {
@@ -134,6 +141,7 @@ impl Endpoint {
134141 }
135142 }
136143
144+ /// Loads a contiguous block of data from remote memory.
137145 pub async fn get ( & self , buf : & mut [ u8 ] , remote_addr : u64 , rkey : & RKey ) -> Result < ( ) , Error > {
138146 trace ! ( "get: endpoint={:?} len={}" , self . handle, buf. len( ) ) ;
139147 unsafe extern "C" fn callback ( request : * mut c_void , status : ucs_status_t ) {
0 commit comments