Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement cuda runtime api. (cudart) #17

Merged
merged 7 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ members = [
"zluda_redirect",
"zluda_rt",
"zluda_rtc",
"zluda_runtime",
"zluda_sparse",
]

Expand Down
92 changes: 92 additions & 0 deletions hip_runtime-sys/src/hip_runtime_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 17 additions & 0 deletions zluda_runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "zluda_runtime"
version = "0.0.0"
authors = ["Seunghoon Lee <[email protected]>"]
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 changes: 3 additions & 0 deletions zluda_runtime/README
Original file line number Diff line number Diff line change
@@ -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
7,619 changes: 7,619 additions & 0 deletions zluda_runtime/src/cudart.rs

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions zluda_runtime/src/cudart_profiler.rs
Original file line number Diff line number Diff line change
@@ -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()
}
Loading