Skip to content

Commit

Permalink
Switched to futures_lite for blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
SarthakSingh31 committed Nov 14, 2024
1 parent 33484db commit d1173f3
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 130 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ serde_json = { version = "1.0.119", default-features = false }
dashmap = "5.5.3"
hashbrown = "0.14.5"
spin = { version = "0.9.8", features = ["mutex", "spin_mutex"] }
rayon = "1"

getrandom = { version = "0.2.15", default-features = false }
rand = { version = "0.8.5", default-features = false, features = [
Expand All @@ -38,6 +37,7 @@ async-channel = "2.3"
dirs = "5.0.1"
md5 = "0.7.0"
sanitize-filename = "0.5"
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4.45"
weak-table = "0.3"
web-time = "1.1.0"
Expand Down Expand Up @@ -74,7 +74,6 @@ pretty_assertions = "1.4"
# Async
embassy-futures = { version = "0.1.1" } # for no-std
futures-lite = { version = "2.3.0", default-features = false }
futures = "0.3.31"

[profile.dev]
opt-level = 2
4 changes: 2 additions & 2 deletions crates/cubecl-wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ wgpu = { version = "22.0.0", features = ["fragile-send-sync-non-atomic-wasm"] }

async-channel = { workspace = true }
derive-new = { workspace = true }
futures-lite = { workspace = true }
hashbrown = { workspace = true }
log = { workspace = true }
web-time = { workspace = true }

cfg-if = { workspace = true }

[target.'cfg(all(target_arch = "wasm32", target_feature = "atomics"))'.dependencies]
futures = { workspace = true }
rayon = { workspace = true }
wasm-bindgen = { workspace = true }

[dev-dependencies]
cubecl-core = { path = "../cubecl-core", version = "0.4.0", features = [
Expand Down
14 changes: 10 additions & 4 deletions crates/cubecl-wgpu/src/compute/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct WgpuServer<C: WgpuCompiler> {
memory_management: MemoryManagement<WgpuStorage>,
pub(crate) device: Pdrc<wgpu::Device>,
queue: Pdrc<wgpu::Queue>,
pub(crate) adapter: Pdrc<wgpu::Adapter>,
encoder: CommandEncoder,
current_pass: Option<ComputePass<'static>>,
tasks_count: usize,
Expand Down Expand Up @@ -90,6 +91,7 @@ impl<C: WgpuCompiler> WgpuServer<C> {
memory_management: MemoryManagement<WgpuStorage>,
device: Pdrc<wgpu::Device>,
queue: Pdrc<wgpu::Queue>,
adapter: Pdrc<wgpu::Adapter>,
tasks_max: usize,
) -> Self {
let logger = DebugLogger::default();
Expand All @@ -99,18 +101,22 @@ impl<C: WgpuCompiler> WgpuServer<C> {
timestamps.enable(&device);
}

let encoder = create_encoder(&device);
let poll = WgpuPoll::new(device.clone());

Self {
memory_management,
device: device.clone(),
queue: queue.clone(),
encoder: create_encoder(&device),
device,
queue,
adapter,
encoder,
current_pass: None,
tasks_count: 0,
storage_locked: MemoryLock::default(),
pipelines: HashMap::new(),
tasks_max,
logger,
poll: WgpuPoll::new(device.clone()),
poll,
duration_profiled: None,
timestamps,
_compiler: PhantomData,
Expand Down
Loading

0 comments on commit d1173f3

Please sign in to comment.