macro_rules! offload {
(
@ munch[kernel = $val:expr $(, $($rest:tt)*)?]; kernel = NONE;
workgroup_dim = $w:tt; thread_dim = $t:tt; dyn_cache = $d:tt; device =
$device:tt; args = $a:tt
) => { ... };
(
@ munch[kernel = $val:expr $(, $($rest:tt)*)?]; kernel = (SOME
$old:expr); workgroup_dim = $w:tt; thread_dim = $t:tt; dyn_cache =
$d:tt; device = $device:tt; args = $a:tt
) => { ... };
(
@ munch[workgroup_dim = $val:expr $(, $($rest:tt)*)?]; kernel = $k:tt;
workgroup_dim = ([1, 1, 1]); thread_dim = $t:tt; dyn_cache = $d:tt;
device = $device:tt; args = $a:tt
) => { ... };
(
@ munch[workgroup_dim = $val:expr $(, $($rest:tt)*)?]; kernel = $k:tt;
workgroup_dim = (SOME $old:expr); thread_dim = $t:tt; dyn_cache =
$d:tt; device = $device:tt; args = $a:tt
) => { ... };
(
@ munch[thread_dim = $val:expr $(, $($rest:tt)*)?]; kernel = $k:tt;
workgroup_dim = $w:tt; thread_dim = ([1, 1, 1]); dyn_cache = $d:tt;
device = $device:tt; args = $a:tt
) => { ... };
(
@ munch[thread_dim = $val:expr $(, $($rest:tt)*)?]; kernel = $k:tt;
workgroup_dim = $w:tt; thread_dim = (SOME $old:expr); dyn_cache =
$d:tt; device = $device:tt; args = $a:tt
) => { ... };
(
@ munch[dyn_cache = $val:expr $(, $($rest:tt)*)?]; kernel = $k:tt;
workgroup_dim = $w:tt; thread_dim = $t:tt; dyn_cache = (0); device =
$device:tt; args = $a:tt
) => { ... };
(
@ munch[dyn_cache = $val:expr $(, $($rest:tt)*)?]; kernel = $k:tt;
workgroup_dim = $w:tt; thread_dim = $t:tt; dyn_cache = (SOME
$old:expr); device = $device:tt; args = $a:tt
) => { ... };
(
@ munch[device = $val:expr $(, $($rest:tt)*)?]; kernel = $k:tt;
workgroup_dim = $w:tt; thread_dim = $t:tt; dyn_cache = $d:tt; device =
NONE; args = $a:tt
) => { ... };
(
@ munch[device = $val:expr $(, $($rest:tt)*)?]; kernel = $k:tt;
workgroup_dim = $w:tt; thread_dim = $t:tt; dyn_cache = $d:tt; device =
(SOME $old:expr); args = $a:tt
) => { ... };
(
@ munch[args = ($($arg:expr),* $(,)?) $(, $($rest:tt)*)?]; kernel =
$k:tt; workgroup_dim = $w:tt; thread_dim = $t:tt; dyn_cache = $d:tt;
device = $device:tt; args = NONE
) => { ... };
(
@ munch[args = $val:expr $(, $($rest:tt)*)?]; kernel = $k:tt;
workgroup_dim = $w:tt; thread_dim = $t:tt; dyn_cache = $d:tt; device =
$device:tt; args = NONE
) => { ... };
(
@ munch[args = $val:expr $(, $($rest:tt)*)?]; kernel = $k:tt;
workgroup_dim = $w:tt; thread_dim = $t:tt; dyn_cache = $d:tt; device =
$device:tt; args = (SOME $old:expr)
) => { ... };
(
@ munch[args = $val:expr $(, $($rest:tt)*)?]; kernel = $k:tt;
workgroup_dim = $w:tt; thread_dim = $t:tt; dyn_cache = $d:tt; device =
$device:tt; args = (SOME_TUPLE $old:tt)
) => { ... };
(
@ munch[$invalid:ident = $val:expr $(, $($rest:tt)*)?]; kernel =
$k:tt; workgroup_dim = $w:tt; thread_dim = $t:tt; dyn_cache = $d:tt;
device = $device:tt; args = $a:tt
) => { ... };
(
@ munch[]; kernel = NONE; workgroup_dim = $w:tt; thread_dim = $t:tt;
dyn_cache = $d:tt; device = $device:tt; args = $a:tt
) => { ... };
(
@ munch[]; kernel = $k:tt; workgroup_dim = $w:tt; thread_dim = $t:tt;
dyn_cache = $d:tt; device = $device:tt; args = NONE
) => { ... };
(
@ munch[]; kernel = (SOME $kernel:expr); workgroup_dim = $w:tt;
thread_dim = $t:tt; dyn_cache = $d:tt; device = $device:tt; args =
(SOME_TUPLE($($arg:expr),* $(,)?))
) => { ... };
(
@ munch[]; kernel = (SOME $kernel:expr); workgroup_dim = $w:tt;
thread_dim = $t:tt; dyn_cache = $d:tt; device = $device:tt; args =
(SOME $args:expr)
) => { ... };
(@ value(SOME $val:expr)) => { ... };
(@ value($val:expr)) => { ... };
(@ device NONE) => { ... };
(@ device(SOME $val:expr)) => { ... };
($($tt:tt)*) => { ... };
}🔬This is a nightly-only experimental API. (
gpu_offload #131513)Expand description
Launches a kernel on an offload device (e.g., a GPU).
This macro is an interface over the offload intrinsic. The kernel itself must be defined
using the offload_kernel macro.
The following named arguments are accepted:
kernel: The kernel function to offload. Must be a function item. (required)args: A tuple of arguments forwarded tokernel. (required)workgroup_dim: A 3D size specifying the number of workgroups to launch. Defaults to[1, 1, 1].thread_dim: A 3D size specifying the number of threads per workgroup. Defaults to[1, 1, 1].dyn_cache: The amount of dynamic shared memory, in bytes, to allocate for the kernel. Defaults to0.device: The index of the device to offload to. Must be>= 0. If omitted, the default device is used. Usecrate::intrinsics::offload_get_num_devicesto discover which device ids are valid.
Each argument may only be specified once.
§Examples
ⓘ
let mut x = [0.0f64; 256];
core::offload::offload! {
kernel = kernel,
workgroup_dim = [256, 1, 1],
args = (&mut x as *mut [f64; 256],),
}