Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
ee86652
generic interface word size
leon-thomm Nov 6, 2023
bc19ed7
context base offset
leon-thomm Nov 6, 2023
90f5a1a
libloading wasm backend
leon-thomm Nov 6, 2023
572d941
fix libloading wasm backend
leon-thomm Nov 7, 2023
6d2a1b7
update driver tests
leon-thomm Nov 7, 2023
1d1ef65
update driver tests
leon-thomm Nov 7, 2023
876b806
add wasm backend binaries
leon-thomm Nov 7, 2023
d9b2d41
rename wasm test files
leon-thomm Nov 9, 2023
f849a42
update matmul binary
leon-thomm Nov 9, 2023
bc27391
wasm memory on heap
leon-thomm Nov 12, 2023
d48fe7a
use Arc<Library>
leon-thomm Nov 13, 2023
e5d2faa
zero-copy wasm memory initialization
leon-thomm Nov 15, 2023
16b05a2
add wasm feature to dispatcher
leon-thomm Nov 15, 2023
278415e
Merge branch 'main' into dev/wasm
leon-thomm Nov 15, 2023
f763605
remove context base offset, use occupation instead
leon-thomm Nov 15, 2023
9d1b104
make wasm context the full wasm memory
leon-thomm Nov 15, 2023
611a8e9
Merge pull request #17 from eth-easl/dev/wasm-heap-only
leon-thomm Nov 16, 2023
41a9af0
Add wasm libloading dependency to cargo
tom-kuchler Nov 17, 2023
371b89a
Undoing premature changes
tom-kuchler Nov 17, 2023
e931f93
remove base offset from cheri memory domain
leon-thomm Nov 17, 2023
e55f14d
update wasm driver tests
leon-thomm Nov 18, 2023
78d7829
merge dev/composition
leon-thomm Nov 20, 2023
b8e57ae
fix MMU interface usage
leon-thomm Nov 20, 2023
832c1fe
fix auto merge
leon-thomm Nov 20, 2023
bdf215d
fix wasm engine re-usage and add wasm dispatcher tests
leon-thomm Nov 20, 2023
909d3a8
Fix issue with compiling main and reenable empty loader test
tom-kuchler Nov 20, 2023
6c2d135
handle wasm out of memory
leon-thomm Nov 20, 2023
6acb4bd
add wasm to domain tests
leon-thomm Nov 20, 2023
42951cb
update wasm test files
leon-thomm Nov 21, 2023
4967cda
merge main
leon-thomm Nov 21, 2023
9cfbbde
update wasm test files (again)
leon-thomm Nov 21, 2023
bae4df9
Merge remote-tracking branch 'origin/main' into dev/wasm
leon-thomm Nov 21, 2023
567e861
add wasm backend to server, fix hyper imports
leon-thomm Nov 21, 2023
173c484
use mmap() for wasm memory
leon-thomm Nov 22, 2023
83693af
temporary request counter
leon-thomm Nov 22, 2023
bde8a36
merge main
leon-thomm Nov 23, 2023
377ad77
use http for unity submodule
leon-thomm Nov 23, 2023
0a78b9d
temp request print
leon-thomm Nov 24, 2023
ddfbd5d
merge main
leon-thomm Nov 24, 2023
8c187b7
remove debug counter
leon-thomm Nov 24, 2023
95b028c
raise number of engine cores
leon-thomm Nov 24, 2023
082f6d8
Merge branch 'dev/wasm' of github.com:eth-easl/dandelion into dev/wasm
leon-thomm Nov 24, 2023
73de0ce
remove print
leon-thomm Nov 24, 2023
8608196
use 63 engine cores
leon-thomm Nov 24, 2023
fe582cb
Complain of engine initialized with invalid coreID
richardlee159 Nov 24, 2023
11c96f9
Dynamically determine number of cores available
richardlee159 Nov 24, 2023
33b57fc
Optimize core allocation for dispatcher & engines
richardlee159 Nov 25, 2023
c1aed39
Add simple test for server
richardlee159 Nov 25, 2023
9161e61
Fix core pinning issue for dispatcher
richardlee159 Nov 25, 2023
1112951
Initialize matrix in a thread-safe way
richardlee159 Nov 25, 2023
d6e155b
merge origin/dev/server_enhance
leon-thomm Nov 26, 2023
9c0e67e
add engines
leon-thomm Nov 27, 2023
1985974
merge origin/main
leon-thomm Nov 28, 2023
2d446bb
update busy binary
leon-thomm Nov 30, 2023
6d18506
Merge remote-tracking branch 'origin/main' into dev/wasm
leon-thomm Dec 2, 2023
dd819e5
use fewer dispatcher cores
Dec 2, 2023
9ca475d
Remove cheri as default on aarch64 machines
tom-kuchler Dec 4, 2023
4a486c5
cherry pick 'Set dispatcher core number via environment variable'
leon-thomm Dec 4, 2023
c16efc9
update busy binary
leon-thomm Dec 4, 2023
83023e8
merge main
leon-thomm Dec 5, 2023
6d1cc15
add pure wasm binaries
leon-thomm Dec 7, 2023
314332b
fix duplicate Cargo.toml section
leon-thomm Dec 7, 2023
cc24d2e
wasmtime backend prototype
leon-thomm Dec 7, 2023
d5ac2fa
fix wasmtime binary path
leon-thomm Dec 7, 2023
cee3aa6
reduce wasmtime dependencies
leon-thomm Dec 7, 2023
1376aec
wasm module pre-compilation
leon-thomm Dec 7, 2023
5cd0f55
fix imports
leon-thomm Dec 8, 2023
9d21625
use one wasmtime engine only
leon-thomm Dec 9, 2023
33fdf09
wasmtime module precompilation
leon-thomm Dec 11, 2023
fb04088
update wasm binaries
leon-thomm Dec 11, 2023
24fbba6
add error messages to wasmtime function parsing
leon-thomm Dec 11, 2023
3215a06
arch specific wasmtime binaries
leon-thomm Dec 12, 2023
e57cdcf
use arch-specific wasmtime binaries
leon-thomm Dec 12, 2023
5951c88
update wasmtime binaries
Dec 12, 2023
a15b9c1
pass sysdata offset to wasm function; fix wasmtime tests
leon-thomm Dec 15, 2023
22992ea
Update lock to read write lock, originally made by Pinghe, cherri pic…
tom-kuchler Dec 18, 2023
3fa4952
Fix main broken from picking
tom-kuchler Dec 18, 2023
92e317a
merge dev/locking
leon-thomm Dec 18, 2023
664cec4
fix wasm after merge
leon-thomm Dec 18, 2023
c034f2b
fix wasmtime after merge
leon-thomm Dec 18, 2023
f8e0b5c
fix Cargo.toml newline
Dec 18, 2023
cce9502
remove print
leon-thomm Dec 18, 2023
9218da8
lower NUM_COLD
Dec 18, 2023
77606d8
Merge branch 'dev/wasmtime' of https://github.com/eth-easl/dandelion …
Dec 18, 2023
c7c8927
fix wasmtime precompiled feature detection
leon-thomm Dec 19, 2023
33e60b0
re-compiled wasm binaries
leon-thomm Jan 25, 2024
a0e4037
merge main
leon-thomm Jan 25, 2024
542c87d
fix merge missing change
leon-thomm Jan 25, 2024
711515c
fix merge again
leon-thomm Jan 25, 2024
f0b1abb
rename wasmtime features
leon-thomm Jan 31, 2024
d418b65
fix missing feature rename
leon-thomm Jan 31, 2024
02db215
fix wasmtime-precompiled driver init
leon-thomm Feb 1, 2024
3504386
fix feature separation wasmtime-precompiled and wasmtime-jit
leon-thomm Feb 1, 2024
4a2b9d9
rename wasmtime-precompiled to wasmtime-precomp
leon-thomm Feb 1, 2024
7e2bfb0
missed files in previous commit
leon-thomm Feb 1, 2024
7a624ee
Adding back cheri build file that was wrongly removed
tom-kuchler Feb 1, 2024
a22e5b1
Add env variable to use different mmu worker locations
tom-kuchler Feb 1, 2024
ae4acf6
fix dandelion build
leon-thomm Feb 2, 2024
aef4816
roll back to read-write lock in function registry
leon-thomm Feb 9, 2024
018fcfa
Merge branch 'dev/wasmtime-debug-registry' into dev/wasmtime
leon-thomm Feb 9, 2024
885877c
Revert "Merge branch 'dev/wasmtime-debug-registry' into dev/wasmtime"
leon-thomm Feb 13, 2024
7ce1c54
recomputed wasm binaries
leon-thomm Feb 25, 2024
b714bed
clean up
leon-thomm Feb 25, 2024
5d2ee5b
Add features to workflow
tom-kuchler Feb 27, 2024
d87abcb
turns out I can't round properly
leon-thomm Mar 19, 2024
4bf2632
improve memory domain tests
leon-thomm Mar 20, 2024
c7983e1
allow function-less context creation
leon-thomm Mar 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cargo-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
# test different available compute engines with different system engines
matrix:
compute_driver: [ mmu, wasm ]
compute_driver: [ mmu, wasm, wasmtime-jit, wasmtime-precomp ]
system_driver: [ hyper_io ]
steps:
# check out the code
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,7 @@ RUSTFLAGS='-C target-feature=+crt-static -C link-arg=-Wl,-fuse-ld=lld,--image-ba
Also make sure that shared memory objects are executable:
```
sudo mount -o remount,exec /dev/shm
```
```

### MMU worker path
To use a `mmu_worker` that is not at the original location it was built in, set the `PROCESS_WORKER_PATH` environment variable to point to the desired binary
2 changes: 2 additions & 0 deletions dandelion_commons/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub enum DandelionError {
ContextMissmatch,
/// domain could not be allocated because there is no space available
OutOfMemory,
/// memory size is not allowed, e.g. Wasm memory must be <= 4GiB
InvalidMemorySize,
/// context can't fit additional memory
ContextFull,
/// read buffer was misaligned for requested data type
Expand Down
5 changes: 4 additions & 1 deletion dispatcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ dandelion_commons = {path = "../dandelion_commons"}
machine_interface = {path = "../machine_interface"}
futures = {version = "0.3.28", default-features = false}
itertools = {version = "0.11", default-features = false, features = ["use_alloc"]}
async-lock = "3.1"

[features]
cheri = ["machine_interface/cheri"]
mmu = ["machine_interface/mmu"]
wasm = ["machine_interface/wasm"]
mmu = ["machine_interface/mmu"]
wasmtime-jit = ["machine_interface/wasmtime-jit"]
wasmtime-precomp = ["machine_interface/wasmtime-precomp"]
1 change: 1 addition & 0 deletions dispatcher/src/function_registry.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use async_lock::RwLock;
use dandelion_commons::{DandelionError, DandelionResult, EngineTypeId, FunctionId};
use machine_interface::{
function_driver::{Driver, Function, FunctionConfig},
Expand Down
11 changes: 10 additions & 1 deletion dispatcher/tests/dispatcher_tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(all(test, any(feature = "cheri", feature = "mmu", feature = "wasm")))]
#[cfg(all(test, any(feature = "cheri", feature = "mmu", feature = "wasm", feature = "wasmtime-jit", feature = "wasmtime-precomp")))]
mod dispatcher_tests {
mod function_tests;
mod registry_tests;
Expand Down Expand Up @@ -190,4 +190,13 @@ mod dispatcher_tests {
#[cfg(target_arch = "aarch64")]
dispatcherTests!(sysld_wasm_aarch64; WasmMemoryDomain; Vec::new(); WasmDriver {}; vec![ComputeResource::CPU(1)]);
}

#[cfg(any(feature = "wasmtime-jit", feature = "wasmtime-precomp"))]
mod wasmtime {
use machine_interface::{
function_driver::{compute_driver::wasmtime::WasmtimeDriver, ComputeResource},
memory_domain::wasmtime::WasmtimeMemoryDomain,
};
dispatcherTests!(wasm; WasmtimeMemoryDomain; Vec::new(); WasmtimeDriver {}; vec![ComputeResource::CPU(1)]);
}
}
3 changes: 3 additions & 0 deletions machine_interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ cheri = ["std"]
mmu = ["std"]
hyper_io = ["std", "dep:hyper"]
wasm = ["std"]
wasmtime-jit = ["std", "dep:wasmtime"]
wasmtime-precomp = ["std", "dep:wasmtime"]

[build-dependencies]
cmake = "0.1"
Expand All @@ -32,6 +34,7 @@ tokio = { version = "1", features = ["full"] }
hyper = { version = "0.14", optional = true, features = ["http1", "http2", "client", "runtime"]}
libloading = { version = "0.8.1" }
log = "0.4.20"
wasmtime = { version = "15.0.1", optional = true, default-features = false, features = ["cranelift", "cache"]}

# disable benchmarks in library, to not run all unit tests on every benchmark
# also needs to be disabled for criterion flags to work that are not available for tests
Expand Down
21 changes: 21 additions & 0 deletions machine_interface/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
fn main() {
// check if cheri is enabled and build library if so
#[cfg(feature = "cheri")]
{
use cmake::Config;
// cmake configure and build all
let _all = Config::new("c_machine_libraries")
.define("FORCE_BUILD_CHERI", "")
.build_target("all")
.build();
// run tests tests
let _test = Config::new("c_machine_libraries")
.build_target("test")
.build();
// install
let install = Config::new("c_machine_libraries").build();
// passing cmake information to c
println!("cargo:rustc-link-search=native={}", install.display());
println!("cargo:rustc-link-lib=static=cheri_lib");
}
}
36 changes: 32 additions & 4 deletions machine_interface/src/function_driver.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
use crate::{
memory_domain::{Context, MemoryDomain},
memory_domain::{Context, ContextType, MemoryDomain},
DataRequirementList, Position,
};
use core::pin::Pin;
use dandelion_commons::{records::Recorder, DandelionResult};
use dandelion_commons::{records::Recorder, DandelionResult, DandelionError};
use std::{future::Future, sync::Arc};

#[cfg(feature = "wasm")]
use libloading::Library;

#[cfg(any(feature = "wasmtime-jit", feature = "wasmtime-precomp"))]
use wasmtime;
#[cfg(any(feature = "wasmtime-jit", feature = "wasmtime-precomp"))]
use crate::function_driver::compute_driver::wasmtime as wasmtime_driver;

pub mod compute_driver;
mod load_utils;
pub mod system_driver;
mod thread_utils;

#[cfg(any(feature = "mmu", feature = "cheri"))]
#[derive(Clone)]
pub struct ElfConfig {
// TODO change to positions
Expand All @@ -28,6 +35,7 @@ pub enum SystemFunction {
HTTP,
}

#[cfg(feature = "wasm")]
#[derive(Clone)]
pub struct WasmConfig {
lib: Arc<Library>,
Expand All @@ -37,11 +45,25 @@ pub struct WasmConfig {
system_data_struct_offset: usize,
}

#[cfg(any(feature = "wasmtime-jit", feature = "wasmtime-precomp"))]
#[derive(Clone)]
pub struct WasmtimeConfig {
precompiled_module: Vec<u8>,
total_mem_size: usize,
sdk_heap_base: usize,
system_data_struct_offset: usize,
wasmtime_engine: wasmtime::Engine, // engine can be shared across threads
}

#[derive(Clone)]
pub enum FunctionConfig {
#[cfg(any(feature = "mmu", feature = "cheri"))]
ElfConfig(ElfConfig),
Comment thread
tom-kuchler marked this conversation as resolved.
SysConfig(SystemFunction),
#[cfg(feature = "wasm")]
WasmConfig(WasmConfig),
#[cfg(any(feature = "wasmtime-jit", feature = "wasmtime-precomp"))]
WasmtimeConfig(WasmtimeConfig),
}

pub struct Function {
Expand All @@ -53,15 +75,21 @@ pub struct Function {
impl Function {
pub fn load(&self, domain: &Box<dyn MemoryDomain>) -> DandelionResult<Context> {
return match &self.config {
#[cfg(any(feature = "mmu", feature = "cheri"))]
FunctionConfig::ElfConfig(_) => {
load_utils::load_static(domain, &self.context, &self.requirements)
}
},
FunctionConfig::SysConfig(_) => domain.acquire_context(self.requirements.size),
#[cfg(feature = "wasm")]
FunctionConfig::WasmConfig(c) => {
let mut context = domain.acquire_context(c.wasm_mem_size)?;
context.occupy_space(0, c.sdk_heap_base)?;
Ok(context)
}
},
#[cfg(any(feature = "wasmtime-jit", feature = "wasmtime-precomp"))]
FunctionConfig::WasmtimeConfig(c) => {
Comment thread
tom-kuchler marked this conversation as resolved.
wasmtime_driver::load_context(c, domain)
},
};
}
}
Expand Down
3 changes: 3 additions & 0 deletions machine_interface/src/function_driver/compute_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ pub mod mmu;
#[cfg(feature = "wasm")]
pub mod wasm;

#[cfg(any(feature = "wasmtime-jit", feature = "wasmtime-precomp"))]
pub mod wasmtime;

#[cfg(test)]
mod compute_driver_tests;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(all(test, any(feature = "cheri", feature = "mmu", feature = "wasm")))]
#[cfg(all(test, any(feature = "cheri", feature = "mmu", feature = "wasm", feature = "wasmtime-jit", feature = "wasmtime-precomp")))]
mod compute_driver_tests {
use crate::{
function_driver::{ComputeResource, Driver, Engine, FunctionConfig},
Expand Down Expand Up @@ -630,4 +630,47 @@ mod compute_driver_tests {
ComputeResource::GPU(0),
]);
}
}

#[cfg(any(feature = "wasmtime-jit", feature = "wasmtime-precomp"))]
mod wasmtime {
use crate::function_driver::compute_driver::wasmtime::WasmtimeDriver;
use crate::function_driver::ComputeResource;
use crate::memory_domain::wasmtime::WasmtimeMemoryDomain;

#[cfg(feature = "wasmtime-jit")]
driverTests!(wasm; WasmtimeMemoryDomain; Vec::new(); WasmtimeDriver {};
vec![
ComputeResource::CPU(1),
ComputeResource::CPU(2),
ComputeResource::CPU(3),
];
vec![
ComputeResource::CPU(255),
ComputeResource::GPU(0),
]);

#[cfg(all(feature = "wasmtime-precomp", target_arch = "x86_64"))]
driverTests!(wasmtime_x86_64; WasmtimeMemoryDomain; Vec::new(); WasmtimeDriver {};
vec![
ComputeResource::CPU(1),
ComputeResource::CPU(2),
ComputeResource::CPU(3),
];
vec![
ComputeResource::CPU(255),
ComputeResource::GPU(0),
]);

#[cfg(all(feature = "wasmtime-precomp", target_arch = "aarch64"))]
driverTests!(wasmtime_aarch64; WasmtimeMemoryDomain; Vec::new(); WasmtimeDriver {};
vec![
ComputeResource::CPU(1),
ComputeResource::CPU(2),
ComputeResource::CPU(3),
];
vec![
ComputeResource::CPU(255),
ComputeResource::GPU(0),
]);
}
}
5 changes: 2 additions & 3 deletions machine_interface/src/function_driver/compute_driver/mmu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ fn mmu_run_static(
// that will not collide with those used by user's function

// this trick gives the desired path of mmu_worker for packages within the workspace
// TODO: replace with a more general solution (e.g. environment variable)
let path = format!(
let path = std::env::var("PROCESS_WORKER_PATH").unwrap_or(format!(
"{}/../target/{}-unknown-linux-gnu/{}/mmu_worker",
env!("CARGO_MANIFEST_DIR"),
std::env::consts::ARCH,
Expand All @@ -175,7 +174,7 @@ fn mmu_run_static(
} else {
"release"
},
);
));

// create a new address space (child process) and pass the shared memory
let mut worker = Command::new(path)
Expand Down
7 changes: 5 additions & 2 deletions machine_interface/src/function_driver/compute_driver/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ use libloading::{Library, Symbol};
use log::error;
use std::sync::{Arc, Mutex};

type WasmEntryPoint = fn(&mut [u8]) -> Option<i32>;
type WasmEntryPoint = fn(&mut [u8], usize) -> Option<i32>;

struct WasmCommand {
lib: Arc<Library>,
context: Arc<Mutex<Option<Context>>>,
sysdata_offset: usize,
}
unsafe impl Send for WasmCommand {}

Expand All @@ -45,7 +46,8 @@ impl ThreadPayload for WasmCommand {
};

// call entry point
let ret = entry_point(&mut wasm_context.mem);
let ret = entry_point(&mut wasm_context.mem, self.sysdata_offset);

// put context back
*guard = Some(ctx);

Expand Down Expand Up @@ -140,6 +142,7 @@ impl Engine for WasmEngine {
WasmCommand {
context: context_.clone(),
lib: wasm_config.lib.clone(),
sysdata_offset: wasm_config.system_data_struct_offset,
},
);

Expand Down
Loading