-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[llvm] [aot] Add LLVM to CAPI part 4: Enabled C-API tests on CI & Add…
…ed C-API tests for CPU backend (#5435) * [build] Enabled C-API compilation on CI * Fixed minor issue * Enabled CAPI compilation on windows build bots * Fixed minor issue * Removed LLVM-15 test on windows * [llvm] [aot] Add LLVM to CAPI part 4: Enabled C-API tests on CI & Add basic C-API interface test cases * Removed debug info * Fixed CI issues * Added C-API tests for LLVM-CPU backend
- Loading branch information
1 parent
98d5075
commit 08f6d60
Showing
11 changed files
with
162 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include "gtest/gtest.h" | ||
#include "taichi/taichi_core.h" | ||
|
||
TEST(CapiDryRun, Runtime) { | ||
{ | ||
// CPU Runtime | ||
TiArch arch = TiArch::TI_ARCH_X64; | ||
TiRuntime runtime = ti_create_runtime(arch); | ||
ti_destroy_runtime(runtime); | ||
} | ||
} | ||
|
||
TEST(CapiDryRun, MemoryAllocation) { | ||
TiMemoryAllocateInfo alloc_info; | ||
alloc_info.size = 100; | ||
alloc_info.host_write = false; | ||
alloc_info.host_read = false; | ||
alloc_info.export_sharing = false; | ||
alloc_info.usage = TiMemoryUsageFlagBits::TI_MEMORY_USAGE_STORAGE_BIT; | ||
|
||
{ | ||
// CPU Runtime | ||
TiArch arch = TiArch::TI_ARCH_X64; | ||
TiRuntime runtime = ti_create_runtime(arch); | ||
|
||
ti_allocate_memory(runtime, &alloc_info); | ||
|
||
// Unfortunately, memory deallocation for | ||
// CPU backend has not been implemented yet... | ||
|
||
ti_destroy_runtime(runtime); | ||
} | ||
} | ||
|
||
TEST(CapiDryRun, CpuAotModule) { | ||
const auto folder_dir = getenv("TAICHI_AOT_FOLDER_PATH"); | ||
|
||
std::stringstream aot_mod_ss; | ||
aot_mod_ss << folder_dir; | ||
|
||
{ | ||
// CPU Runtime | ||
TiArch arch = TiArch::TI_ARCH_X64; | ||
TiRuntime runtime = ti_create_runtime(arch); | ||
|
||
TiAotModule aot_mod = ti_load_aot_module(runtime, aot_mod_ss.str().c_str()); | ||
ti_destroy_aot_module(aot_mod); | ||
|
||
ti_destroy_runtime(runtime); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
set(C_API_TESTS_NAME taichi_c_api_tests) | ||
if (WIN32) | ||
# Prevent overriding the parent project's compiler/linker | ||
# settings on Windows | ||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
endif() | ||
|
||
# TODO(#2195): | ||
# 1. "cpp" -> "cpp_legacy", "cpp_new" -> "cpp" | ||
# 2. Re-implement the legacy CPP tests using googletest | ||
file(GLOB_RECURSE TAICHI_C_API_TESTS_SOURCE | ||
"c_api/tests/*.cpp") | ||
|
||
add_executable(${C_API_TESTS_NAME} ${TAICHI_C_API_TESTS_SOURCE}) | ||
|
||
target_link_libraries(${C_API_TESTS_NAME} PRIVATE taichi_c_api) | ||
target_link_libraries(${C_API_TESTS_NAME} PRIVATE gtest_main) | ||
|
||
target_include_directories(${C_API_TESTS_NAME} | ||
PRIVATE | ||
${PROJECT_SOURCE_DIR} | ||
${PROJECT_SOURCE_DIR}/c_api/include | ||
) | ||
|
||
add_test(NAME ${C_API_TESTS_NAME} COMMAND ${C_API_TESTS_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters