Get the current version of Taichi C API.
Parameters:
None
Returns:
c_uint32
- the current version of Taichi C API
Get the last error raised by Taichi C-API invocations.
Parameters:
None
Returns:
str
- the last error message
Create a Taichi runtime.
Parameters:
arch
(Type:TiArch
): The architecture for the runtime.device
(Type:int
): The device index.Returns:
TiRuntime
- the created Taichi runtime
Get the available architectures.
Parameters:
None
Returns: Tuple(
List[c_uint32]
,List[TiArch]
) - available architectures
Destroy a Taichi runtime.
Parameters:
runtime
(Type:TiRuntime
): The runtime to be destroyed.Returns:
None
Set the last error in Taichi C-API.
Parameters:
error
(Type:TiError
): The error code.message
(Type:str
): The error message.Returns:
None
Allocate memory and return a TiMemory pointer.
Parameters:
runtime
(Type:TiRuntime
): The runtime on which memory will be allocated.allocate_info
(Type:TiMemoryAllocateInfo
): Memory allocation parameters.Returns:
TiMemory
- Pointer to the allocated memory
Free the allocated memory.
Parameters:
runtime
(Type:TiRuntime
): The runtime on which memory was allocated.memory
(Type:TiMemory
): Pointer to the allocated memory.Returns:
None
Map device memory to host-addressable space.
Parameters:
runtime
(Type:TiRuntime
): The runtime on which memory is mapped.memory
(Type:TiMemory
): Pointer to the allocated memory.Returns:
c_void_p
- Mapped host-addressable space
Unmap device memory, making host-side changes visible to the device.
Parameters:
runtime
(Type:TiRuntime
): The runtime on which memory is unmapped.memory
(Type:TiMemory
): Pointer to the allocated memory.Returns:
None
Allocate an image and return a pointer.
Parameters:
runtime
(Type:TiRuntime
): The runtime on which the image will be allocated.allocate_info
(Type:TiImageAllocateInfo
): Image allocation parameters.Returns:
c_void_p
- Pointer to the allocated image
Free the allocated image.
Parameters:
runtime
(Type:TiRuntime
): The runtime on which the image was allocated.image
(Type:TiImage
): Pointer to the allocated image.Returns:
None
Create a sampler.
Parameters:
runtime
(Type:TiRuntime
): The runtime on which the sampler will be created.create_info
(Type:TiSamplerCreateInfo
): Sampler creation parameters.Returns:
TiSampler
- Created sampler
Destroy a sampler.
Parameters:
runtime
(Type:TiRuntime
): The runtime on which the sampler was created.sampler
(Type:TiSampler
): The sampler to be destroyed.Returns:
None
function copy_memory_device_to_device
(runtime: TiRuntime, src: TiMemorySlice, dst: TiMemorySlice
) -> None
Copy device memory from source to destination.
Parameters:
runtime
(Type:TiRuntime
): The runtime for the memory copy operation.src
(Type:TiMemorySlice
): Source memory slice.dst
(Type:TiMemorySlice
): Destination memory slice.Returns:
None
function copy_image_device_to_device
(runtime: TiRuntime, src: TiImageSlice, dst: TiImageSlice
) -> None
Copy device image from source to destination.
Parameters:
runtime
(Type:TiRuntime
): The runtime for the image copy operation.src
(Type:TiImageSlice
): Source image slice.dst
(Type:TiImageSlice
): Destination image slice.Returns:
None
function launch_kernel
(runtime: TiRuntime, kernel: TiKernel, num_args: int, args: List[TiArgument]
) -> None
Launch a Taichi kernel with provided arguments.
Parameters:
runtime
(Type:TiRuntime
): The runtime on which the kernel will be launched.kernel
(Type:TiKernel
): The kernel to be launched.num_args
(Type:int
): Number of kernel arguments.args
(Type:List[TiArgument]
): List of kernel arguments.Returns:
None
function launch_compute_graph
(runtime: TiRuntime, graph: TiComputeGraph, num_args: int, named_args: List[TiNamedArgument]
) -> None
Launch a Taichi compute graph with provided arguments.
Parameters:
runtime
(Type:TiRuntime
): The runtime on which the compute graph will be launched.graph
(Type:TiComputeGraph
): The compute graph to be launched.num_args
(Type:int
): Number of compute graph arguments.named_args
(Type:List[TiNamedArgument]
): List of compute graph arguments.Returns:
None
Flush pending operations on the runtime.
Parameters:
runtime
(Type:TiRuntime
): The runtime to be flushed.Returns:
None
Wait for all operations on the runtime to complete.
Parameters:
runtime
(Type:TiRuntime
): The runtime to wait for.Returns:
None
Load an Ahead-of-Time (AOT) module from a file.
Parameters:
runtime
(Type:TiRuntime
): The runtime on which the AOT module will be loaded.filepath
(Type:str
): The path to the AOT module file.Returns:
TiAotModule
- Loaded AOT module
Destroy an Ahead-of-Time (AOT) module.
Parameters:
module
(Type:TiAotModule
): The AOT module to be destroyed.Returns:
None
Get a kernel from an Ahead-of-Time (AOT) module by name.
Parameters:
module
(Type:TiAotModule
): The AOT module containing the kernel.kernel_name
(Type:str
): The name of the kernel.Returns:
TiKernel
- Kernel from the AOT module
Get a compute graph from an Ahead-of-Time (AOT) module by name.
Parameters:
module
(Type:TiAotModule
): The AOT module containing the compute graph.graph_name
(Type:str
): The name of the compute graph.Returns:
TiComputeGraph
- Compute graph from the AOT module