cuda_rust_wasm/backend/
native_gpu.rs1use crate::{Result, runtime_error};
7use super::backend_trait::{BackendTrait, BackendCapabilities, MemcpyKind};
8use async_trait::async_trait;
9
10pub fn is_cuda_available() -> bool {
12 false
15}
16
17pub struct NativeGPUBackend {
19 capabilities: BackendCapabilities,
21}
22
23impl Default for NativeGPUBackend {
24 fn default() -> Self {
25 Self::new()
26 }
27}
28
29impl NativeGPUBackend {
30 pub fn new() -> Self {
32 Self {
33 capabilities: BackendCapabilities {
35 name: "Native GPU (CUDA/ROCm)".to_string(),
36 supports_cuda: true,
37 supports_opencl: false,
38 supports_vulkan: false,
39 supports_webgpu: false,
40 max_threads: 1024 * 1024,
41 max_threads_per_block: 1024,
42 max_blocks_per_grid: 65535,
43 max_shared_memory: 49152, supports_dynamic_parallelism: true,
45 supports_unified_memory: true,
46 max_grid_dim: [2147483647, 65535, 65535],
47 max_block_dim: [1024, 1024, 64],
48 warp_size: 32,
49 },
50 }
51 }
52}
53
54#[async_trait]
55impl BackendTrait for NativeGPUBackend {
56 fn name(&self) -> &str {
57 "Native GPU (CUDA/ROCm)"
58 }
59
60 fn capabilities(&self) -> &BackendCapabilities {
61 &self.capabilities
62 }
63
64 async fn initialize(&mut self) -> Result<()> {
65 Ok(())
67 }
68
69 async fn compile_kernel(&self, _source: &str) -> Result<Vec<u8>> {
70 Err(runtime_error!("Native GPU backend not implemented"))
71 }
72
73 async fn launch_kernel(
74 &self,
75 _kernel: &[u8],
76 _grid: (u32, u32, u32),
77 _block: (u32, u32, u32),
78 _args: &[*const u8],
79 ) -> Result<()> {
80 Err(runtime_error!("Native GPU backend not implemented"))
81 }
82
83 fn allocate_memory(&self, _size: usize) -> Result<*mut u8> {
84 Err(runtime_error!("Native GPU backend not implemented"))
85 }
86
87 fn free_memory(&self, _ptr: *mut u8) -> Result<()> {
88 Err(runtime_error!("Native GPU backend not implemented"))
89 }
90
91 fn copy_memory(
92 &self,
93 _dst: *mut u8,
94 _src: *const u8,
95 _size: usize,
96 _kind: MemcpyKind,
97 ) -> Result<()> {
98 Err(runtime_error!("Native GPU backend not implemented"))
99 }
100
101 fn synchronize(&self) -> Result<()> {
102 Err(runtime_error!("Native GPU backend not implemented"))
103 }
104}