Implement cuda runtime api. (cudart) (#17)

* [WIP] Implement cudart.

* wip

* wip

* Implement cudart.

* wip

* Ready to merge.
This commit is contained in:
Seunghoon Lee 2024-05-17 13:15:16 +09:00 committed by GitHub
parent 95f881004f
commit 11cc584451
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 10497 additions and 0 deletions

8
Cargo.lock generated
View file

@ -2561,6 +2561,14 @@ dependencies = [
"hiprtc-sys",
]
[[package]]
name = "zluda_runtime"
version = "0.0.0"
dependencies = [
"hip_common",
"hip_runtime-sys",
]
[[package]]
name = "zluda_sparse"
version = "0.0.0"

View file

@ -41,6 +41,7 @@ members = [
"zluda_redirect",
"zluda_rt",
"zluda_rtc",
"zluda_runtime",
"zluda_sparse",
]

View file

@ -7133,3 +7133,95 @@ extern "C" {
userData: *mut ::std::os::raw::c_void,
) -> hipError_t;
}
extern "C" {
#[must_use]
pub fn __hipPopCallConfiguration(
gridDim: *mut dim3,
blockDim: *mut dim3,
sharedMem: *mut usize,
stream: *mut hipStream_t,
) -> hipError_t;
}
extern "C" {
#[must_use]
pub fn __hipPushCallConfiguration(
gridDim: dim3,
blockDim: dim3,
sharedMem: usize,
stream: hipStream_t,
) -> hipError_t;
}
extern "C" {
#[must_use]
pub fn __hipRegisterFatBinary(
data: *const ::std::os::raw::c_void,
) -> *mut *mut ::std::os::raw::c_void;
}
extern "C" {
#[must_use]
pub fn __hipRegisterFunction(
modules: *mut *mut ::std::os::raw::c_void,
hostFunction: *const ::std::os::raw::c_void,
deviceFunction: *mut ::std::os::raw::c_char,
deviceName: *const ::std::os::raw::c_char,
threadLimit: ::std::os::raw::c_uint,
tid: *mut ::std::os::raw::c_void,
bid: *mut ::std::os::raw::c_void,
blockDim: *mut dim3,
gridDim: *mut dim3,
wSize: *mut ::std::os::raw::c_int,
) -> ::std::os::raw::c_void;
}
extern "C" {
#[must_use]
pub fn __hipRegisterManagedVar(
hipModule: *mut ::std::os::raw::c_void,
pointer: *mut *mut ::std::os::raw::c_void,
init_value: *mut ::std::os::raw::c_void,
name: *const ::std::os::raw::c_char,
size: usize,
align: ::std::os::raw::c_uint,
) -> ::std::os::raw::c_void;
}
extern "C" {
#[must_use]
pub fn __hipRegisterSurface(
modules: *mut *mut ::std::os::raw::c_void,
var: *mut ::std::os::raw::c_void,
hostVar: *mut ::std::os::raw::c_char,
deviceVar: *mut ::std::os::raw::c_char,
type_: ::std::os::raw::c_int,
ext: ::std::os::raw::c_int,
) -> ::std::os::raw::c_void;
}
extern "C" {
#[must_use]
pub fn __hipRegisterTexture(
modules: *mut *mut ::std::os::raw::c_void,
var: *mut ::std::os::raw::c_void,
hostVar: *mut ::std::os::raw::c_char,
deviceVar: *mut ::std::os::raw::c_char,
type_: ::std::os::raw::c_int,
norm: ::std::os::raw::c_int,
ext: ::std::os::raw::c_int,
) -> ::std::os::raw::c_void;
}
extern "C" {
#[must_use]
pub fn __hipRegisterVar(
modules: *mut *mut ::std::os::raw::c_void,
var: *mut ::std::os::raw::c_void,
hostVar: *mut ::std::os::raw::c_char,
deviceVar: *mut ::std::os::raw::c_char,
ext: ::std::os::raw::c_int,
size: usize,
constant: ::std::os::raw::c_int,
global: ::std::os::raw::c_int,
) -> ::std::os::raw::c_void;
}
extern "C" {
#[must_use]
pub fn __hipUnregisterFatBinary(
modules: *mut *mut ::std::os::raw::c_void,
) -> ::std::os::raw::c_void;
}

17
zluda_runtime/Cargo.toml Normal file
View file

@ -0,0 +1,17 @@
[package]
name = "zluda_runtime"
version = "0.0.0"
authors = ["Seunghoon Lee <op@lsh.sh>"]
edition = "2018"
[lib]
name = "cudart"
crate-type = ["cdylib"]
[dependencies]
hip_common = { path = "../hip_common" }
hip_runtime-sys = { path = "../hip_runtime-sys" }
[package.metadata.zluda]
linux_names = ["libcudart.so.10", "libcudart.so.11"]
dump_names = ["libcudart.so"]

3
zluda_runtime/README Normal file
View file

@ -0,0 +1,3 @@
bindgen \\wsl.localhost\Ubuntu-22.04\usr\include\cuda_runtime.h -o src/cudart.rs --allowlist-function="^cuda.*" --allowlist-type="cu.*" --default-enum-style=newtype --no-layout-tests --no-derive-debug -- -I\\wsl.localhost\Ubuntu-22.04\usr\include
sed -i -e 's/extern "C" {//g' -e 's/-> cudaError_t;/-> cudaError_t { crate::unsupported()/g' -e 's/pub fn /#[no_mangle] pub extern "system" fn /g' src/cudart.rs
rustfmt src/cudart.rs

7619
zluda_runtime/src/cudart.rs Normal file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,18 @@
#[no_mangle]
pub extern "system" fn cudaProfilerInitialize(
configFile: *const ::std::os::raw::c_char,
outputFile: *const ::std::os::raw::c_char,
outputMode: cudaOutputMode_t,
) -> cudaError_t {
crate::unsupported()
}
#[no_mangle]
pub extern "system" fn cudaProfilerStart() -> cudaError_t {
crate::unsupported()
}
#[no_mangle]
pub extern "system" fn cudaProfilerStop() -> cudaError_t {
crate::unsupported()
}

2739
zluda_runtime/src/lib.rs Normal file

File diff suppressed because it is too large Load diff