Skip to content

gpu

fn cuda_memory_new #

fn cuda_memory_new[T](count int) !CudaMemory[T]

cuda_memory_new allocates GPU memory for type T with count elements.

fn (CudaMemory[T]) upload #

fn (mut m CudaMemory[T]) upload(data []T) !

upload copies data from host to device.

fn (CudaMemory[T]) download #

fn (mut m CudaMemory[T]) download(mut out []T) !

download copies data from device to host.

fn (CudaMemory[T]) free #

fn (m &CudaMemory[T]) free() !

free releases the GPU memory.

fn (CudaMemory[T]) destroy #

fn (m &CudaMemory[T]) destroy() !

destroy is an alias for free().

struct CudaMemory #

struct CudaMemory[T] {
pub:
	ptr  voidptr
	size int
}

CudaMemory is a helper for managing GPU device memory. It wraps cudaMalloc/cudaFree and provides upload/download methods.