mirror of
https://github.com/vosen/ZLUDA.git
synced 2025-08-02 14:57:43 +03:00
Use FromCuda
in zluda_blas
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1816,6 +1816,7 @@ version = "0.0.0"
|
||||
dependencies = [
|
||||
"cuda_macros",
|
||||
"cuda_types",
|
||||
"zluda_common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -10,6 +10,7 @@ name = "cublas"
|
||||
[dependencies]
|
||||
cuda_macros = { path = "../cuda_macros" }
|
||||
cuda_types = { path = "../cuda_types" }
|
||||
zluda_common = { path = "../zluda_common" }
|
||||
|
||||
[package.metadata.zluda]
|
||||
linux_symlinks = [
|
||||
|
@ -10,15 +10,18 @@ pub(crate) fn unimplemented() -> cublasStatus_t {
|
||||
cublasStatus_t::ERROR_NOT_SUPPORTED
|
||||
}
|
||||
|
||||
pub(crate) fn get_status_name(_status: cublasStatus_t) -> *const ::core::ffi::c_char {
|
||||
pub(crate) fn get_status_name(_status: Option<cublasStatus_t>) -> *const ::core::ffi::c_char {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub(crate) fn get_status_string(_status: cublasStatus_t) -> *const ::core::ffi::c_char {
|
||||
pub(crate) fn get_status_string(_status: Option<cublasStatus_t>) -> *const ::core::ffi::c_char {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub(crate) fn xerbla(_sr_name: *const ::core::ffi::c_char, _info: ::core::ffi::c_int) -> () {
|
||||
pub(crate) fn xerbla(
|
||||
_sr_name: Option<*const ::core::ffi::c_char>,
|
||||
_info: Option<::core::ffi::c_int>,
|
||||
) -> () {
|
||||
todo!()
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
mod r#impl;
|
||||
|
||||
use cuda_types::cublas::cublasError_t;
|
||||
|
||||
macro_rules! unimplemented {
|
||||
($($abi:literal fn $fn_name:ident( $($arg_id:ident : $arg_type:ty),* ) -> $ret_type:ty;)*) => {
|
||||
$(
|
||||
@ -20,7 +22,21 @@ macro_rules! implemented {
|
||||
#[allow(improper_ctypes)]
|
||||
#[allow(improper_ctypes_definitions)]
|
||||
pub unsafe extern $abi fn $fn_name ( $( $arg_id : $arg_type),* ) -> $ret_type {
|
||||
cuda_macros::cublas_normalize_fn!( crate::r#impl::$fn_name ) ( $( $arg_id ),* )
|
||||
cuda_macros::cublas_normalize_fn!( crate::r#impl::$fn_name ) ($(zluda_common::FromCuda::<_, cublasError_t>::from_cuda(&$arg_id)?),*)?;
|
||||
Ok(())
|
||||
}
|
||||
)*
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! implemented_and_always_succeeds {
|
||||
($($abi:literal fn $fn_name:ident( $($arg_id:ident : $arg_type:ty),* ) -> $ret_type:ty;)*) => {
|
||||
$(
|
||||
#[cfg_attr(not(test), no_mangle)]
|
||||
#[allow(improper_ctypes)]
|
||||
#[allow(improper_ctypes_definitions)]
|
||||
pub unsafe extern $abi fn $fn_name ( $( $arg_id : $arg_type),* ) -> $ret_type {
|
||||
cuda_macros::cublas_normalize_fn!( crate::r#impl::$fn_name ) ($(zluda_common::FromCuda::<_, cublasError_t>::from_cuda(&$arg_id).ok()),*)
|
||||
}
|
||||
)*
|
||||
};
|
||||
@ -28,7 +44,8 @@ macro_rules! implemented {
|
||||
|
||||
cuda_macros::cublas_function_declarations!(
|
||||
unimplemented,
|
||||
implemented
|
||||
implemented <= [],
|
||||
implemented_and_always_succeeds
|
||||
<= [
|
||||
cublasGetStatusName,
|
||||
cublasGetStatusString,
|
||||
|
@ -1,4 +1,4 @@
|
||||
use cuda_types::cuda::*;
|
||||
use cuda_types::{cublas::*, cuda::*};
|
||||
use hip_runtime_sys::*;
|
||||
use std::{
|
||||
ffi::CStr,
|
||||
@ -16,6 +16,11 @@ impl CudaErrorType for CUerror {
|
||||
const NOT_SUPPORTED: Self = Self::NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
impl CudaErrorType for cublasError_t {
|
||||
const INVALID_VALUE: Self = Self::INVALID_VALUE;
|
||||
const NOT_SUPPORTED: Self = Self::NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
/// Used to try to convert CUDA API values into our internal representation.
|
||||
///
|
||||
/// Similar to [`TryFrom`], but we can implement this for primitive types. We also provide conversions from pointers to references.
|
||||
@ -123,7 +128,9 @@ from_cuda_nop!(
|
||||
CUuuid,
|
||||
CUlibrary,
|
||||
CUmodule,
|
||||
CUcontext
|
||||
CUcontext,
|
||||
cublasHandle_t,
|
||||
cublasStatus_t
|
||||
);
|
||||
from_cuda_transmute!(
|
||||
CUuuid => hipUUID,
|
||||
|
Reference in New Issue
Block a user