The `gpu-kernel` calling convention has several restrictions that were not enforced by the compiler until now. Add the following restrictions: 1. Cannot be async 2. Cannot be called 3. Cannot return values, return type must be `()` or `!` 4. Arguments should be primitives, i.e. passed by value. More complicated types can work when you know what you are doing, but it is rather unintuitive, one needs to know ABI/compiler internals. 5. Export name should be unmangled, either through `no_mangle` or `export_name`. Kernels are searched by name on the CPU side, having a mangled name makes it hard to find and probably almost always unintentional.
18 lines
564 B
Rust
18 lines
564 B
Rust
//@ add-minicore
|
|
//@ ignore-backends: gcc
|
|
//@ edition: 2024
|
|
//@ revisions: amdgpu nvptx
|
|
//
|
|
//@ [amdgpu] needs-llvm-components: amdgpu
|
|
//@ [amdgpu] compile-flags: --target amdgcn-amd-amdhsa -Ctarget-cpu=gfx900 --crate-type=rlib
|
|
//@ [nvptx] needs-llvm-components: nvptx
|
|
//@ [nvptx] compile-flags: --target nvptx64-nvidia-cuda --crate-type=rlib
|
|
#![no_core]
|
|
#![feature(no_core, abi_gpu_kernel)]
|
|
|
|
extern crate minicore;
|
|
use minicore::*;
|
|
|
|
#[unsafe(no_mangle)]
|
|
extern "gpu-kernel" fn ret_i32() -> i32 { 0 }
|
|
//~^ ERROR invalid signature for `extern "gpu-kernel"` function
|