cogciprocate / ocl

OpenCL for Rust
Other
721 stars 75 forks source link

How do I set global_work_size and local_work_size? #227

Closed winktool closed 8 months ago

winktool commented 8 months ago

The data I input to the kernel is about 1000 bytes. I'm using a nvidia rtx 3090.


    let max_work_group_size = device.max_wg_size().unwrap();

    print!("max_work_group_size: {}", max_work_group_size);

    let kernel = Kernel::builder()
        .queue(queue)
        .global_work_size(max_work_group_size * 128)
        .build()
        .unwrap();
winktool commented 8 months ago

How do I get the compute units? let max_compute_units = device.max_compute_units().unwrap(); doesn't work.

c0gent commented 8 months ago
use ocl::core::DeviceInfo;

...

let max_compute_units = device.info(DeviceInfo::MaxComputeUnits).unwrap();

Here's a list of things you can get using device.info().

Corresponds with what's listed here.

Here's an article discussing work group sizes.

winktool commented 8 months ago

Thank you for your reply, you're very kind.