diff options
author | Andrzej Janik <[email protected]> | 2024-12-02 00:29:57 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-12-02 00:29:57 +0100 |
commit | 7a6df9dcbf59edef371e7f63c16c64916ddb0c0b (patch) | |
tree | 7800524ba25d38c514f1c769c9c1b665542c5500 /zluda/src/lib.rs | |
parent | 870fed4bb69d919a10822032d65ec20f385df9d7 (diff) | |
download | ZLUDA-7a6df9dcbf59edef371e7f63c16c64916ddb0c0b.tar.gz ZLUDA-7a6df9dcbf59edef371e7f63c16c64916ddb0c0b.zip |
Fix host code and update to CUDA 12.4 (#299)
Diffstat (limited to 'zluda/src/lib.rs')
-rw-r--r-- | zluda/src/lib.rs | 90 |
1 files changed, 78 insertions, 12 deletions
diff --git a/zluda/src/lib.rs b/zluda/src/lib.rs index 72ca51c..1568f47 100644 --- a/zluda/src/lib.rs +++ b/zluda/src/lib.rs @@ -1,13 +1,79 @@ -#[macro_use] -extern crate lazy_static; -#[cfg(test)] -extern crate cuda_driver_sys; -#[cfg(test)] -#[macro_use] -extern crate paste; -extern crate ptx; - -#[allow(warnings)] -pub mod cuda; -mod cuda_impl; pub(crate) mod r#impl; + +macro_rules! unimplemented { + ($($abi:literal fn $fn_name:ident( $($arg_id:ident : $arg_type:ty),* ) -> $ret_type:path;)*) => { + $( + #[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 { + crate::r#impl::unimplemented() + } + )* + }; +} + +macro_rules! implemented { + ($($abi:literal fn $fn_name:ident( $($arg_id:ident : $arg_type:ty),* ) -> $ret_type:path;)*) => { + $( + #[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_base::cuda_normalize_fn!( crate::r#impl::$fn_name ) ($(crate::r#impl::FromCuda::from_cuda(&$arg_id)?),*)?; + Ok(()) + } + )* + }; +} + +macro_rules! implemented_in_function { + ($($abi:literal fn $fn_name:ident( $($arg_id:ident : $arg_type:ty),* ) -> $ret_type:path;)*) => { + $( + #[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_base::cuda_normalize_fn!( crate::r#impl::function::$fn_name ) ($(crate::r#impl::FromCuda::from_cuda(&$arg_id)?),*)?; + Ok(()) + } + )* + }; +} + +cuda_base::cuda_function_declarations!( + unimplemented, + implemented <= [ + cuCtxGetLimit, + cuCtxSetCurrent, + cuCtxSetLimit, + cuCtxSynchronize, + cuDeviceComputeCapability, + cuDeviceGet, + cuDeviceGetAttribute, + cuDeviceGetCount, + cuDeviceGetLuid, + cuDeviceGetName, + cuDevicePrimaryCtxRelease, + cuDevicePrimaryCtxRetain, + cuDeviceGetProperties, + cuDeviceGetUuid, + cuDeviceGetUuid_v2, + cuDeviceTotalMem_v2, + cuDriverGetVersion, + cuFuncGetAttribute, + cuInit, + cuMemAlloc_v2, + cuMemFree_v2, + cuMemcpyDtoH_v2, + cuMemcpyHtoD_v2, + cuModuleGetFunction, + cuModuleLoadData, + cuModuleUnload, + cuPointerGetAttribute, + cuMemGetAddressRange_v2, + ], + implemented_in_function <= [ + cuLaunchKernel, + ] +);
\ No newline at end of file |