Skip to content
Snippets Groups Projects
Commit e4c257df authored by Frederik Hennig's avatar Frederik Hennig
Browse files

add lang.gpu to api docs

parent 377bab57
1 merge request!24Extend Support for CUDA and HIP kernel invocations
Pipeline #75702 passed with stages
in 2 minutes and 27 seconds
...@@ -41,3 +41,9 @@ Implementation ...@@ -41,3 +41,9 @@ Implementation
.. automodule:: pystencilssfg.lang.cpp .. automodule:: pystencilssfg.lang.cpp
:members: :members:
GPU Runtime APIs
----------------
.. automodule:: pystencilssfg.lang.gpu
:members:
...@@ -5,38 +5,50 @@ from typing import Protocol ...@@ -5,38 +5,50 @@ from typing import Protocol
from .expressions import CppClass, cpptype, AugExpr from .expressions import CppClass, cpptype, AugExpr
class _Dim3Base(CppClass): class Dim3Interface(CppClass):
"""Interface definition for the ``dim3`` struct of Cuda and HIP."""
def ctor(self, dim0=1, dim1=1, dim2=1): def ctor(self, dim0=1, dim1=1, dim2=1):
"""Constructor invocation of ``dim3``"""
return self.ctor_bind(dim0, dim1, dim2) return self.ctor_bind(dim0, dim1, dim2)
@property @property
def x(self): def x(self) -> AugExpr:
"""The `x` coordinate member."""
return AugExpr.format("{}.x", self) return AugExpr.format("{}.x", self)
@property @property
def y(self): def y(self) -> AugExpr:
"""The `y` coordinate member."""
return AugExpr.format("{}.y", self) return AugExpr.format("{}.y", self)
@property @property
def z(self): def z(self) -> AugExpr:
"""The `z` coordinate member."""
return AugExpr.format("{}.z", self) return AugExpr.format("{}.z", self)
@property @property
def dims(self): def dims(self) -> tuple[AugExpr, AugExpr, AugExpr]:
"""The dims property.""" """`x`, `y`, and `z` as a tuple."""
return [self.x, self.y, self.z] return (self.x, self.y, self.z)
class ProvidesGpuRuntimeAPI(Protocol): class ProvidesGpuRuntimeAPI(Protocol):
"""Protocol definition for a GPU runtime API provider."""
dim3: type[_Dim3Base] dim3: type[Dim3Interface]
"""The ``dim3`` struct type for this GPU runtime"""
stream_t: type[AugExpr] stream_t: type[AugExpr]
"""The ``stream_t`` type for this GPU runtime"""
class CudaAPI(ProvidesGpuRuntimeAPI): class CudaAPI(ProvidesGpuRuntimeAPI):
"""Reflection of the CUDA runtime API"""
class dim3(Dim3Interface):
"""Implements `Dim3Interface` for CUDA"""
class dim3(_Dim3Base):
template = cpptype("dim3", "<cuda_runtime.h>") template = cpptype("dim3", "<cuda_runtime.h>")
class stream_t(CppClass): class stream_t(CppClass):
...@@ -44,8 +56,11 @@ class CudaAPI(ProvidesGpuRuntimeAPI): ...@@ -44,8 +56,11 @@ class CudaAPI(ProvidesGpuRuntimeAPI):
class HipAPI(ProvidesGpuRuntimeAPI): class HipAPI(ProvidesGpuRuntimeAPI):
"""Reflection of the HIP runtime API"""
class dim3(Dim3Interface):
"""Implements `Dim3Interface` for HIP"""
class dim3(_Dim3Base):
template = cpptype("dim3", "<hip/hip_runtime.h>") template = cpptype("dim3", "<hip/hip_runtime.h>")
class stream_t(CppClass): class stream_t(CppClass):
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment