Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aot] C-API error handling mechanism #5847

Merged
merged 11 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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