Skip to content

Commit

Permalink
don't free mem
Browse files Browse the repository at this point in the history
  • Loading branch information
philsippl committed Dec 27, 2024
1 parent fc0b726 commit e5c8c51
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
19 changes: 15 additions & 4 deletions iris-mpc-gpu/src/dot/share_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ use cudarc::{
nvrtc::compile_ptx,
};
use itertools::{izip, Itertools};
use memmap2::MmapMut;
use rayon::prelude::*;
use std::{
ffi::{c_void, CStr},
mem,
mem::{self, forget},
sync::Arc,
};

Expand Down Expand Up @@ -243,13 +244,23 @@ impl ShareDB {
.devices()
.iter()
.map(|device| unsafe {
let host_mem0 = memmap2::MmapMut::map_anon(max_size * self.code_length).unwrap();
let host_mem1 = memmap2::MmapMut::map_anon(max_size * self.code_length).unwrap();
let host_mem0 = MmapMut::map_anon(max_size * self.code_length).unwrap();
let host_mem1 = MmapMut::map_anon(max_size * self.code_length).unwrap();

let host_mem0_ptr = host_mem0.as_ptr() as u64;
let host_mem1_ptr = host_mem1.as_ptr() as u64;

// Make sure to not drop the memory, even though we only use the pointers
// afterwards. This also has the effect that this memory is never freed, which
// is fine for the db.
forget(host_mem0);
forget(host_mem1);

(
StreamAwareCudaSlice::from(device.alloc(max_size).unwrap()),
(
StreamAwareCudaSlice::from(device.alloc(max_size).unwrap()),
(host_mem0.as_ptr() as u64, host_mem1.as_ptr() as u64),
(host_mem0_ptr, host_mem1_ptr),
),
)
})
Expand Down
4 changes: 4 additions & 0 deletions iris-mpc-gpu/src/server/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,15 @@ impl ServerActor {
comms.clone(),
);

let now = Instant::now();

let left_code_db_slices = codes_engine.alloc_db(max_db_size);
let left_mask_db_slices = masks_engine.alloc_db(max_db_size);
let right_code_db_slices = codes_engine.alloc_db(max_db_size);
let right_mask_db_slices = masks_engine.alloc_db(max_db_size);

tracing::info!("Allocated db in {:?}", now.elapsed());

// Engines for inflight queries
let batch_codes_engine = ShareDB::init(
party_id,
Expand Down

0 comments on commit e5c8c51

Please sign in to comment.