1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
use hip_runtime_sys::*;
pub(crate) fn get_attribute(
pi: &mut i32,
cu_attrib: hipFunction_attribute,
func: hipFunction_t,
) -> hipError_t {
// TODO: implement HIP_FUNC_ATTRIBUTE_PTX_VERSION
// TODO: implement HIP_FUNC_ATTRIBUTE_BINARY_VERSION
unsafe { hipFuncGetAttribute(pi, cu_attrib, func) }?;
if cu_attrib == hipFunction_attribute::HIP_FUNC_ATTRIBUTE_NUM_REGS {
*pi = (*pi).max(1);
}
Ok(())
}
pub(crate) fn launch_kernel(
f: hipFunction_t,
grid_dim_x: ::core::ffi::c_uint,
grid_dim_y: ::core::ffi::c_uint,
grid_dim_z: ::core::ffi::c_uint,
block_dim_x: ::core::ffi::c_uint,
block_dim_y: ::core::ffi::c_uint,
block_dim_z: ::core::ffi::c_uint,
shared_mem_bytes: ::core::ffi::c_uint,
stream: hipStream_t,
kernel_params: *mut *mut ::core::ffi::c_void,
extra: *mut *mut ::core::ffi::c_void,
) -> hipError_t {
// TODO: fix constants in extra
unsafe {
hipModuleLaunchKernel(
f,
grid_dim_x,
grid_dim_y,
grid_dim_z,
block_dim_x,
block_dim_y,
block_dim_z,
shared_mem_bytes,
stream,
kernel_params,
extra,
)
}
}
|