Function call_host_function

Source
pub unsafe fn call_host_function(
    function: u64,
    arg0: u64,
    arg1: u64,
    arg2: u64,
    arg3: u64,
    arg4: u64,
    arg5: u64,
    arg6: u64,
) -> u128
Expand description

Call a function on the host.

This allows calling functions on the CPU from the GPU. function must be the address of a function on the CPU. Up to 7 64-bit arguments can be passed and two 64-bit values are returned.

The signature of the CPU function must be fn(output: *mut u64, input: *const u64). output points to two u64 values for the return value and input points to seven u64 for the function arguments.

The function pointer must be passed to the GPU through some mechanism like kernel arguments.

§Example

// Get host_func from somewhere, e.g. arguments.
let arg0 = 42;
unsafe {
    amdgpu_device_libs::call_host_function(host_func, arg0, 0, 0, 0, 0, 0, 0);
}

§Additional information

The CPU side is implemented here (SERVICE_FUNCTION_CALL): ROCm/clr/rocclr/device/devhostcall.cpp
The GPU side here: ROCm/llvm-project/amd/device-libs/ockl/src/services.cl