use std::marker::PhantomData;
use crate::error::{PrismError, Result};
use super::device::GpuDevice;
#[derive(Debug)]
pub struct GpuBuffer<T> {
len: usize,
_phantom: PhantomData<T>,
}
impl<T> GpuBuffer<T> {
pub fn alloc_zeros(device: &GpuDevice, len: usize) -> Result<Self> {
let _ = device;
let _ = len;
Err(PrismError::BackendUnsupported {
backend: "gpu".to_string(),
operation: "alloc_zeros (scaffold only)".to_string(),
})
}
pub fn copy_from_host(&mut self, host: &[T]) -> Result<()> {
let _ = host;
Err(PrismError::BackendUnsupported {
backend: "gpu".to_string(),
operation: "copy_from_host (scaffold only)".to_string(),
})
}
pub fn copy_to_host(&self, host: &mut [T]) -> Result<()> {
let _ = host;
Err(PrismError::BackendUnsupported {
backend: "gpu".to_string(),
operation: "copy_to_host (scaffold only)".to_string(),
})
}
pub fn len(&self) -> usize {
self.len
}
pub fn is_empty(&self) -> bool {
self.len == 0
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn alloc_returns_unsupported_in_scaffold() {
let dev_err = GpuDevice::new(0).unwrap_err();
assert!(matches!(dev_err, PrismError::BackendUnsupported { .. }));
}
}