Skip to content

module internal.gpu

Source: stdlib/internal/gpu.codon


CUDA_SUCCESS: Literal[int] = 0


CUDA_ERROR_NOT_FOUND: Literal[int] = 500


CUresult = i32


CUdevice = i32


CUdeviceptr = u64


CUmodule = cobj


CUcontext = cobj


CUfunction = cobj


modules: List[CUmodule] = []


cuCtxCreate = Function[([Ptr[cobj], u32, CUdevice], CUresult)](cobj())


cuMemAlloc = Function[([Ptr[CUdeviceptr], i64], CUresult)](cobj())


cuMemcpyDtoH = Function[([cobj, CUdeviceptr, u64], CUresult)](cobj())


cuMemcpyHtoD = Function[([CUdeviceptr, cobj, u64], CUresult)](cobj())


cuMemFree = Function[([CUdeviceptr], CUresult)](cobj())


cuDeviceComputeCapability = Function[([Ptr[i32], Ptr[i32], CUdevice], CUresult)](cobj())


cuDeviceGet = Function[([Ptr[CUdevice], i32], CUresult)](cobj())


cuDeviceGetCount = Function[([Ptr[i32]], CUresult)](cobj())


cuDeviceGetName = Function[([Ptr[byte], i32, CUdevice], CUresult)](cobj())


cuGetErrorName = Function[([CUresult, Ptr[cobj]], CUresult)](cobj())


cuGetErrorString = Function[([CUresult, Ptr[cobj]], CUresult)](cobj())


cuInit = Function[([u32], CUresult)](cobj())


cuLaunchKernel = Function[([CUfunction, u32, u32, u32, u32, u32, u32, u32, cobj, cobj, cobj], CUresult)](cobj())


cuModuleGetFunction = Function[([Ptr[CUfunction], CUmodule, cobj], CUresult)](cobj())


cuModuleLoadData = Function[([Ptr[CUmodule], cobj], CUresult)](cobj())


CUDAError

Fields

result: int

Magic methods

__init__(self, result: int, message: str = "")


Device @tuple Class is named tuple (cannot write fields)

Properties

compute_capability @property Method is a class property

Magic methods

__new__(idx: int)

__str__(self)

__index__(self)

__bool__(self)

Methods

count() @staticmethod Method is static (does not take 'self' argument)


cuda_init_handles(cuda_handle: cobj)


cuda_check(err)


nvptx_init()


nvptx_load_module()


cuda_init(debug: bool = False)


Memory[T] @tuple Class is named tuple (cannot write fields)

Fields

T: type

Properties

ptr @property Method is a class property

Magic methods

__new__(ptr: cobj)

Methods

to_ptr(p: CUdeviceptr) @pure Function has no side effects and returns same value for same inputs @llvm Function is implemented with inline LLVM IR

%0 = inttoptr i64 %p to ptr
ret ptr %0

syncthreads() @llvm Function is implemented with inline LLVM IR

declare void @llvm.nvvm.barrier0()
call void @llvm.nvvm.barrier0()
ret {} {}

Dim3 @tuple Class is named tuple (cannot write fields)

Properties

x @property Method is a class property

y @property Method is a class property

z @property Method is a class property

Magic methods

__new__(x: int, y: int, z: int)


Thread @tuple Class is named tuple (cannot write fields)

Properties

x @property Method is a class property

y @property Method is a class property

z @property Method is a class property


Block @tuple Class is named tuple (cannot write fields)

Properties

x @property Method is a class property

y @property Method is a class property

z @property Method is a class property

dim @property Method is a class property


Grid @tuple Class is named tuple (cannot write fields)

Properties

dim @property Method is a class property


Warp @tuple Class is named tuple (cannot write fields)

Magic methods

__len__(self)


thread = Thread()


block = Block()


grid = Grid()


warp = Warp()


AllocCache @tuple Class is named tuple (cannot write fields)

Fields

v: List[Ptr[byte]]

Methods

add(self, p: Ptr[byte])

free(self)


kernel(fn)


Pointer[T] @tuple Class is named tuple (cannot write fields)

Fields

T: type

Magic methods

__to_gpu__(self, cache: AllocCache)

__from_gpu__(self, other: Ptr[T])

__from_gpu_new__(other: Ptr[T])


raw(v)


Ptr[T] @extend Class is extended to add given methods

Magic methods

__to_gpu__(self, cache: AllocCache)

__from_gpu__(self, other: Ptr[T])

__from_gpu_new__(other: Ptr[T])


NoneType @extend Class is extended to add given methods

Magic methods

__to_gpu__(self, cache: AllocCache)

__from_gpu__(self, other: NoneType)

__from_gpu_new__(other: NoneType)


int @extend Class is extended to add given methods

Magic methods

__to_gpu__(self, cache: AllocCache)

__from_gpu__(self, other: int)

__from_gpu_new__(other: int)


float @extend Class is extended to add given methods

Magic methods

__to_gpu__(self, cache: AllocCache)

__from_gpu__(self, other: float)

__from_gpu_new__(other: float)


float32 @extend Class is extended to add given methods

Magic methods

__to_gpu__(self, cache: AllocCache)

__from_gpu__(self, other: float32)

__from_gpu_new__(other: float32)


bool @extend Class is extended to add given methods

Magic methods

__to_gpu__(self, cache: AllocCache)

__from_gpu__(self, other: bool)

__from_gpu_new__(other: bool)


byte @extend Class is extended to add given methods

Magic methods

__to_gpu__(self, cache: AllocCache)

__from_gpu__(self, other: byte)

__from_gpu_new__(other: byte)


Int[N] @extend Class is extended to add given methods

Magic methods

__to_gpu__(self, cache: AllocCache)

__from_gpu__(self, other: Int[N])

__from_gpu_new__(other: Int[N])


UInt[N] @extend Class is extended to add given methods

Magic methods

__to_gpu__(self, cache: AllocCache)

__from_gpu__(self, other: UInt[N])

__from_gpu_new__(other: UInt[N])


str @extend Class is extended to add given methods

Magic methods

__to_gpu__(self, cache: AllocCache)

__from_gpu__(self, other: str)

__from_gpu_new__(other: str)


List[T] @extend Class is extended to add given methods

Magic methods

__to_gpu__(self, cache: AllocCache) @inline Function always inlined

__from_gpu__(self, other: List[T]) @inline Function always inlined

__from_gpu_new__(other: List[T]) @inline Function always inlined


DynamicTuple[T] @extend Class is extended to add given methods

Magic methods

__to_gpu__(self, cache: AllocCache) @inline Function always inlined

__from_gpu__(self, other: DynamicTuple[T]) @inline Function always inlined

__from_gpu_new__(other: DynamicTuple[T]) @inline Function always inlined


Dict[K,V] @extend Class is extended to add given methods

Magic methods

__to_gpu__(self, cache: AllocCache)

__from_gpu__(self, other: Dict[K, V])

__from_gpu_new__(other: Dict[K, V])


Set[K] @extend Class is extended to add given methods

Magic methods

__to_gpu__(self, cache: AllocCache)

__from_gpu__(self, other: Set[K])

__from_gpu_new__(other: Set[K])


Optional[T] @extend Class is extended to add given methods

Magic methods

__to_gpu__(self, cache: AllocCache)

__from_gpu__(self, other: Optional[T])

__from_gpu_new__(other: Optional[T])