Skip to content

Commit

Permalink
Fix hardware properties (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurBrussee authored Nov 23, 2024
1 parent 71c0517 commit 2c09d4d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions crates/cubecl-wgpu/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,18 @@ pub(crate) fn create_client_on_setup<C: WgpuCompiler>(
options: RuntimeOptions,
) -> ComputeClient<WgpuServer<C>, MutexComputeChannel<WgpuServer<C>>> {
let limits = setup.device.limits();
let adapter_limits = setup.adapter.limits();

let mem_props = MemoryDeviceProperties {
max_page_size: limits.max_storage_buffer_binding_size as u64,
alignment: WgpuStorage::ALIGNMENT.max(limits.min_storage_buffer_offset_alignment as u64),
};
let hardware_props = HardwareProperties {
plane_size_min: setup.adapter.limits().min_subgroup_size,
plane_size_max: setup.adapter.limits().max_subgroup_size,
max_bindings: limits.max_bind_groups,
plane_size_min: adapter_limits.min_subgroup_size,
plane_size_max: adapter_limits.max_subgroup_size,
max_bindings: limits.max_storage_buffers_per_shader_stage,
};

let memory_management = {
let device = setup.device.clone();
let mem_props = mem_props.clone();
Expand All @@ -172,8 +175,15 @@ pub(crate) fn create_client_on_setup<C: WgpuCompiler>(
let features = setup.adapter.features();
let mut device_props = DeviceProperties::new(&[], mem_props, hardware_props);

// Workaround: WebGPU does support subgroups and correctly reports this, but wgpu
// doesn't plumb through this info. Instead min/max are just reported as 0, which can cause issues.
// For now just disable subgroups on WebGPU, until this information is added.
let fake_plane_info =
adapter_limits.min_subgroup_size == 0 && adapter_limits.max_subgroup_size == 0;

if features.contains(wgpu::Features::SUBGROUP)
&& setup.adapter.get_info().device_type != wgpu::DeviceType::Cpu
&& !fake_plane_info
{
device_props.register_feature(Feature::Plane);
}
Expand Down

0 comments on commit 2c09d4d

Please sign in to comment.