Skip to content

Commit

Permalink
Fixed wasm32 non atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
SarthakSingh31 committed Nov 14, 2024
1 parent d1173f3 commit 5412ef0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 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>,
#[allow(unused)]
pub(crate) adapter: Pdrc<wgpu::Adapter>,
encoder: CommandEncoder,
current_pass: Option<ComputePass<'static>>,
Expand Down
8 changes: 7 additions & 1 deletion crates/cubecl-wgpu/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ use crate::{
compute::{WgpuServer, WgpuStorage},
AutoGraphicsApi, GraphicsApi, Pdrc, WgpuDevice,
};
use cubecl_core::{channel::ComputeChannel, server::ComputeServer, Feature, Runtime};
#[cfg(not(all(target_arch = "wasm32", target_feature = "atomics")))]
use cubecl_core::future;
#[cfg(all(target_arch = "wasm32", target_feature = "atomics"))]
use cubecl_core::{channel::ComputeChannel, server::ComputeServer};
use cubecl_core::{Feature, Runtime};
#[cfg(not(all(target_arch = "wasm32", target_feature = "atomics")))]
use cubecl_runtime::channel::MutexComputeChannel;
use cubecl_runtime::{
Expand All @@ -31,6 +35,7 @@ thread_local! {
static LOCAL_DEVICE: RefCell<hashbrown::HashMap<WgpuDevice, Rc<RefCell<Server>>>> = RefCell::new(hashbrown::HashMap::default());
}

#[cfg(all(target_arch = "wasm32", target_feature = "atomics"))]
static RUNTIME: ComputeRuntime<WgpuDevice, Server, ThreadLocalChannel> = ComputeRuntime::new();

/// The compute instance is shared across all [wgpu runtimes](WgpuRuntime).
Expand Down Expand Up @@ -214,6 +219,7 @@ pub(crate) fn create_client_on_setup<C: WgpuCompiler>(
memory_management,
setup.device.clone(),
setup.queue,
setup.adapter.clone(),
options.tasks_max,
);
let channel = MutexComputeChannel::new(server);
Expand Down

0 comments on commit 5412ef0

Please sign in to comment.