Skip to content

Commit

Permalink
[aot] C-API error handling mechanism (#5847)
Browse files Browse the repository at this point in the history
* C-API error handling

* Check procedural errors

* Null check

* Fixed compilation

* Vulkan interop

* Fixed compilation

* Fixed compilation

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixed compilation

* Update c_api/src/taichi_core_impl.cpp

Co-authored-by: Ailing  <[email protected]>

* Fixed typo

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ailing  <[email protected]>
  • Loading branch information
3 people authored Aug 24, 2022
1 parent 814fba5 commit 52db011
Show file tree
Hide file tree
Showing 12 changed files with 480 additions and 262 deletions.
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ if ($env:VK_SDK_PATH) {

# Chain up the cmake arguments.
Write-Host "Will build Taichi ($BuildType) with the following CMake args:"
$TaichiCMakeArgs = $env:TAICHI_CMAKE_ARGS
$TaichiCMakeArgs = $env:TAICHI_CMAKE_ARGS ?? ""
foreach ($Pair in $CMakeArgs.GetEnumerator()) {
$Key = $Pair | Select-Object -ExpandProperty Key
$Value = ($Pair | Select-Object -ExpandProperty Value) -replace "\\", "/"
Expand Down
23 changes: 23 additions & 0 deletions c_api/include/taichi/taichi_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ typedef struct TiKernel_t *TiKernel;
// handle.compute_graph
typedef struct TiComputeGraph_t *TiComputeGraph;

// enumeration.error
typedef enum TiError {
TI_ERROR_INCOMPLETE = 1,
TI_ERROR_SUCCESS = 0,
TI_ERROR_NOT_SUPPORTED = -1,
TI_ERROR_CORRUPTED_DATA = -2,
TI_ERROR_NAME_NOT_FOUND = -3,
TI_ERROR_INVALID_ARGUMENT = -4,
TI_ERROR_ARGUMENT_NULL = -5,
TI_ERROR_ARGUMENT_OUT_OF_RANGE = -6,
TI_ERROR_ARGUMENT_NOT_FOUND = -7,
TI_ERROR_INVALID_INTEROP = -8,
TI_ERROR_MAX_ENUM = 0xffffffff,
} TiError;

// enumeration.arch
typedef enum TiArch {
TI_ARCH_X64 = 0,
Expand Down Expand Up @@ -262,6 +277,14 @@ typedef struct TiNamedArgument {
TiArgument argument;
} TiNamedArgument;

// function.get_last_error
TI_DLL_EXPORT TiError TI_API_CALL ti_get_last_error(uint64_t message_size,
char *message);

// function.set_last_error
TI_DLL_EXPORT void TI_API_CALL ti_set_last_error(TiError error,
const char *message);

// function.create_runtime
TI_DLL_EXPORT TiRuntime TI_API_CALL ti_create_runtime(TiArch arch);

Expand Down
Loading

0 comments on commit 52db011

Please sign in to comment.