bhelfer / RustBCL

BCL in Rust
BSD 3-Clause "New" or "Revised" License
7 stars 0 forks source link

Fix a fatal bug of multiplying size_of::<T> twice in putmem, getmem #5

Closed SKYSCRAPERS1999 closed 5 years ago

SKYSCRAPERS1999 commented 5 years ago

Fix a fatal bug of multiplying size_of::<T>() twice in putmem, getmem

unsafe fn putmem(&self, target: *mut u8, source: *const u8, len: usize, pe: usize) {
    if shmemx::my_pe() == self.rank {
          libc::memcpy(target as *mut c_void, source as *const T as *const c_void, len);// * size_of::<T>());
    } else {
      shmemx::shmem_putmem(target, source, len as size_t, self.rank as c_int);
    }
}

unsafe fn getmem(&self, target: *mut u8, source: *const u8, len: usize, pe: usize) {
   if shmemx::my_pe() == self.rank {
        libc::memcpy(target as *mut c_void, source as *const T as *const c_void, len);//  * size_of::<T>());
   } else {
        shmemx::shmem_getmem(target, source, len as size_t, self.rank as c_int);
   }
}