From a1efa04e40b23fe9e25925cbf2a6a143acbf537a Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Tue, 29 Nov 2022 23:12:06 +0800 Subject: [PATCH 1/9] Get available archs --- c_api/docs/taichi/taichi_core.h.md | 13 +++++-- c_api/include/taichi/cpp/taichi.hpp | 18 ++++++++++ c_api/include/taichi/taichi_core.h | 22 ++++++++++-- c_api/include/taichi/taichi_cuda.h | 4 +++ c_api/src/c_api_test_utils.cpp | 21 ----------- c_api/src/c_api_test_utils.h | 3 -- c_api/src/taichi_core_impl.cpp | 34 ++++++++++++++++++ c_api/src/taichi_llvm_impl.cpp | 28 ++++++++++++++- c_api/src/taichi_llvm_impl.h | 4 +++ c_api/src/taichi_opengl_impl.cpp | 8 +++++ c_api/src/taichi_opengl_impl.h | 2 ++ c_api/src/taichi_vulkan_impl.cpp | 8 +++++ c_api/src/taichi_vulkan_impl.h | 2 ++ c_api/taichi.json | 17 +++++++++ c_api/tests/c_api_aot_test.cpp | 8 ++--- c_api/tests/c_api_cgraph_test.cpp | 8 ++--- c_api/tests/c_api_interface_test.cpp | 54 +++++++++++++++++++++------- c_api/tests/c_api_interop_test.cpp | 4 +-- c_api/tests/comet.cpp | 2 +- c_api/tests/mpm88_test.cpp | 6 ++-- c_api/tests/sph.cpp | 6 ++-- c_api/tests/taichi_sparse_test.cpp | 2 +- 22 files changed, 213 insertions(+), 61 deletions(-) diff --git a/c_api/docs/taichi/taichi_core.h.md b/c_api/docs/taichi/taichi_core.h.md index 37ff28955ffc1..e625c0f05c1de 100644 --- a/c_api/docs/taichi/taichi_core.h.md +++ b/c_api/docs/taichi/taichi_core.h.md @@ -440,16 +440,25 @@ A named argument value to feed compute graphs. - `structure.named_argument.name`: Name of the argument. - `structure.named_argument.argument`: Argument body. +`function.get_available_archs` + +Gets a list of available archs on the current platform. An arch is only available if: + +1. The Runtime library is compiled with its support; +2. The current platform is installed with a capable hardware or an emulation software. + +An available arch has at least one device available, i.e., device index 0 is always available. If an arch is not available on the current platform, a call to `function.create_runtime` with that arch is guaranteed failing. + `function.get_last_error` -Get the last error raised by Taichi C-API invocations. Returns the semantical error code. +Gets the last error raised by Taichi C-API invocations. Returns the semantical error code. - `function.get_last_error.message_size`: Size of textual error message in `function.get_last_error.message` - `function.get_last_error.message`: Text buffer for the textual error message. Ignored when `message_size` is 0. `function.set_last_error` -Set the provided error as the last error raised by Taichi C-API invocations. It can be useful in extended validation procedures in Taichi C-API wrappers and helper libraries. +Sets the provided error as the last error raised by Taichi C-API invocations. It can be useful in extended validation procedures in Taichi C-API wrappers and helper libraries. - `function.set_last_error.error`: Semantical error code. - `function.set_last_error.message`: A null-terminated string of the textual error message or `nullptr` for empty error message. diff --git a/c_api/include/taichi/cpp/taichi.hpp b/c_api/include/taichi/cpp/taichi.hpp index ea98278d0c92f..396d2b23d7b8a 100644 --- a/c_api/include/taichi/cpp/taichi.hpp +++ b/c_api/include/taichi/cpp/taichi.hpp @@ -1,5 +1,6 @@ // C++ wrapper of Taichi C-API #pragma once +#include #include #include #include @@ -10,6 +11,23 @@ namespace ti { +inline std::vector get_available_archs() { + uint32_t narch = 0; + ti_get_available_archs(&narch, nullptr); + std::vector archs(narch); + ti_get_available_archs(&narch, archs.data()); + return archs; +} +inline bool is_arch_available(TiArch arch) { + std::vector archs = get_available_archs(); + for (size_t i = 0; i < archs.size(); ++i) { + if (archs.at(i) == arch) { + return true; + } + } + return false; +} + // Token type for half-precision floats. struct half { uint16_t _; diff --git a/c_api/include/taichi/taichi_core.h b/c_api/include/taichi/taichi_core.h index 3242fec7e6078..3ff76a625271a 100644 --- a/c_api/include/taichi/taichi_core.h +++ b/c_api/include/taichi/taichi_core.h @@ -802,10 +802,26 @@ typedef struct TiNamedArgument { TiArgument argument; } TiNamedArgument; +// Function `ti_get_available_archs` +// +// Gets a list of available archs on the current platform. An arch is only +// available if: +// +// 1. The Runtime library is compiled with its support; +// 2. The current platform is installed with a capable hardware or an emulation +// software. +// +// An available arch has at least one device available, i.e., device index 0 is +// always available. If an arch is not available on the current platform, a call +// to [`ti_create_runtime`](#function-ti_create_runtime) with that arch is +// guaranteed failing. +TI_DLL_EXPORT void TI_API_CALL ti_get_available_archs(uint32_t *arch_count, + TiArch *archs); + // Function `ti_get_last_error` // -// Get the last error raised by Taichi C-API invocations. Returns the semantical -// error code. +// Gets the last error raised by Taichi C-API invocations. Returns the +// semantical error code. TI_DLL_EXPORT TiError TI_API_CALL ti_get_last_error( // Size of textual error message in `function.get_last_error.message` uint64_t message_size, @@ -815,7 +831,7 @@ TI_DLL_EXPORT TiError TI_API_CALL ti_get_last_error( // Function `ti_set_last_error` // -// Set the provided error as the last error raised by Taichi C-API invocations. +// Sets the provided error as the last error raised by Taichi C-API invocations. // It can be useful in extended validation procedures in Taichi C-API wrappers // and helper libraries. TI_DLL_EXPORT void TI_API_CALL ti_set_last_error( diff --git a/c_api/include/taichi/taichi_cuda.h b/c_api/include/taichi/taichi_cuda.h index 485953966a159..ab335c73366c5 100644 --- a/c_api/include/taichi/taichi_cuda.h +++ b/c_api/include/taichi/taichi_cuda.h @@ -1,5 +1,9 @@ #pragma once +#ifndef TI_WITH_CUDA +#define TI_WITH_CUDA 1 +#endif // TI_WITH_CUDA + #include #ifdef __cplusplus diff --git a/c_api/src/c_api_test_utils.cpp b/c_api/src/c_api_test_utils.cpp index e4c16e1e0706f..a1cfba40c68b1 100644 --- a/c_api/src/c_api_test_utils.cpp +++ b/c_api/src/c_api_test_utils.cpp @@ -1,6 +1,5 @@ #include "c_api_test_utils.h" #include "taichi_llvm_impl.h" -#include "taichi/platform/cuda/detect_cuda.h" #ifdef TI_WITH_CUDA #include "taichi/rhi/cuda/cuda_driver.h" @@ -37,26 +36,6 @@ bool check_cuda_value(void *ptr, double value) { return check_cuda_value_impl(ptr, value); } -bool is_vulkan_available() { -#ifdef TI_WITH_VULKAN - return taichi::lang::vulkan::is_vulkan_api_available(); -#else - return false; -#endif -} - -bool is_opengl_available() { -#ifdef TI_WITH_OPENGL - return taichi::lang::opengl::is_opengl_api_available(); -#else - return false; -#endif -} - -bool is_cuda_available() { - return taichi::is_cuda_api_available(); -} - void check_runtime_error(TiRuntime runtime) { #ifdef TI_WITH_LLVM auto *llvm_runtime = dynamic_cast((Runtime *)runtime); diff --git a/c_api/src/c_api_test_utils.h b/c_api/src/c_api_test_utils.h index 8d476e424d839..1c1a49dc9b608 100644 --- a/c_api/src/c_api_test_utils.h +++ b/c_api/src/c_api_test_utils.h @@ -4,9 +4,6 @@ namespace capi { namespace utils { -TI_DLL_EXPORT bool TI_API_CALL is_vulkan_available(); -TI_DLL_EXPORT bool TI_API_CALL is_opengl_available(); -TI_DLL_EXPORT bool TI_API_CALL is_cuda_available(); TI_DLL_EXPORT void TI_API_CALL check_runtime_error(TiRuntime runtime); TI_DLL_EXPORT bool TI_API_CALL check_cuda_value(void *ptr, float value); diff --git a/c_api/src/taichi_core_impl.cpp b/c_api/src/taichi_core_impl.cpp index 8616b5b25703d..371460131cc72 100644 --- a/c_api/src/taichi_core_impl.cpp +++ b/c_api/src/taichi_core_impl.cpp @@ -107,6 +107,40 @@ Runtime &Event::runtime() { // ----------------------------------------------------------------------------- +void ti_get_available_archs(uint32_t* arch_count, TiArch* archs) { + if (arch_count == nullptr) { + return; + } + + thread_local std::vector AVAILABLE_ARCHS{}; + if (AVAILABLE_ARCHS.empty()) { + if (is_vulkan_available()) { + AVAILABLE_ARCHS.emplace_back(TI_ARCH_VULKAN); + } + if (is_opengl_available()) { + AVAILABLE_ARCHS.emplace_back(TI_ARCH_OPENGL); + } + if (is_cuda_available()) { + AVAILABLE_ARCHS.emplace_back(TI_ARCH_CUDA); + } + if (is_x64_available()) { + AVAILABLE_ARCHS.emplace_back(TI_ARCH_X64); + } + if (is_arm64_available()) { + AVAILABLE_ARCHS.emplace_back(TI_ARCH_ARM64); + } + } + + size_t n = std::min((size_t)*arch_count, AVAILABLE_ARCHS.size()); + *arch_count = (uint32_t)n; + if (archs != nullptr) { + for (size_t i = 0; i < n; ++i) { + archs[i] = AVAILABLE_ARCHS.at(i); + } + } + +} + TiError ti_get_last_error(uint64_t message_size, char *message) { TiError out = TI_ERROR_INVALID_STATE; TI_CAPI_TRY_CATCH_BEGIN(); diff --git a/c_api/src/taichi_llvm_impl.cpp b/c_api/src/taichi_llvm_impl.cpp index d308446310f39..b84028bdc4563 100644 --- a/c_api/src/taichi_llvm_impl.cpp +++ b/c_api/src/taichi_llvm_impl.cpp @@ -13,6 +13,7 @@ #include "taichi/rhi/cpu/cpu_device.h" #ifdef TI_WITH_CUDA +#include "taichi/platform/cuda/detect_cuda.h" #include "taichi/rhi/cuda/cuda_device.h" #include "taichi/runtime/cuda/aot_module_loader_impl.h" #endif @@ -136,7 +137,6 @@ void LlvmRuntime::wait() { } // namespace capi -#endif // TI_WITH_LLVM // function.export_cpu_runtime void ti_export_cpu_memory(TiRuntime runtime, @@ -197,3 +197,29 @@ void ti_export_cuda_memory(TiRuntime runtime, TI_NOT_IMPLEMENTED; #endif } + +#endif // TI_WITH_LLVM + +bool is_cuda_available() { +#ifdef TI_WITH_CUDA + return taichi::is_cuda_api_available(); +#else + return false; +#endif +} + +bool is_x64_available() { +#if defined(TI_WITH_LLVM) && (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) || defined(__amd64) || defined(_M_X64)) + return true; +#else + return false; +#endif +} + +bool is_arm64_available() { +#if defined(TI_WITH_LLVM) && (defined(__arm64__) || defined(__aarch64__)) + return true; +#else + return false; +#endif +} diff --git a/c_api/src/taichi_llvm_impl.h b/c_api/src/taichi_llvm_impl.h index 4315d9fe409c9..2ebd45fe2b377 100644 --- a/c_api/src/taichi_llvm_impl.h +++ b/c_api/src/taichi_llvm_impl.h @@ -43,3 +43,7 @@ class LlvmRuntime : public Runtime { } // namespace capi #endif // TI_WITH_LLVM + +extern bool is_cuda_available(); +extern bool is_x64_available(); +extern bool is_arm64_available(); diff --git a/c_api/src/taichi_opengl_impl.cpp b/c_api/src/taichi_opengl_impl.cpp index 318f955544e90..2e64083f3f92b 100644 --- a/c_api/src/taichi_opengl_impl.cpp +++ b/c_api/src/taichi_opengl_impl.cpp @@ -35,3 +35,11 @@ void ti_export_opengl_memory(TiRuntime runtime, } #endif // TI_WITH_OPENGL + +bool is_opengl_available() { +#ifdef TI_WITH_OPENGL + return taichi::lang::opengl::is_opengl_api_available(); +#else + return false; +#endif +} diff --git a/c_api/src/taichi_opengl_impl.h b/c_api/src/taichi_opengl_impl.h index 5b2a2bf1bd0ba..2a99c0c6aee37 100644 --- a/c_api/src/taichi_opengl_impl.h +++ b/c_api/src/taichi_opengl_impl.h @@ -19,3 +19,5 @@ class OpenglRuntime : public GfxRuntime { }; #endif // TI_WITH_OPENGL + +extern bool is_opengl_available(); diff --git a/c_api/src/taichi_vulkan_impl.cpp b/c_api/src/taichi_vulkan_impl.cpp index 5cd5fa4d19664..f6538afe708e1 100644 --- a/c_api/src/taichi_vulkan_impl.cpp +++ b/c_api/src/taichi_vulkan_impl.cpp @@ -374,3 +374,11 @@ void ti_export_vulkan_event(TiRuntime runtime, } #endif // TI_WITH_VULKAN + +bool is_vulkan_available() { +#ifdef TI_WITH_VULKAN + return taichi::lang::vulkan::is_vulkan_api_available(); +#else + return false; +#endif +} diff --git a/c_api/src/taichi_vulkan_impl.h b/c_api/src/taichi_vulkan_impl.h index 3dfba7a0a14fd..6c8a39e0b18a7 100644 --- a/c_api/src/taichi_vulkan_impl.h +++ b/c_api/src/taichi_vulkan_impl.h @@ -52,3 +52,5 @@ class VulkanRuntimeOwned : public VulkanRuntime { }; #endif // TI_WITH_VULKAN + +bool is_vulkan_available(); diff --git a/c_api/taichi.json b/c_api/taichi.json index 68e59ae0a880a..f9d25e198acd4 100644 --- a/c_api/taichi.json +++ b/c_api/taichi.json @@ -459,6 +459,23 @@ } ] }, + { + "name": "get_available_archs", + "type": "function", + "parameters": [ + { + "name": "arch_count", + "type": "uint32_t", + "by_mut": true + }, + { + "name": "archs", + "type": "enumeration.arch", + "count": "arch_count", + "by_mut": true + } + ] + }, { "name": "get_last_error", "type": "function", diff --git a/c_api/tests/c_api_aot_test.cpp b/c_api/tests/c_api_aot_test.cpp index 7fbc5f14f191a..b64d1495d5f77 100644 --- a/c_api/tests/c_api_aot_test.cpp +++ b/c_api/tests/c_api_aot_test.cpp @@ -85,7 +85,7 @@ TEST_F(CapiTest, AotTestCpuField) { } TEST_F(CapiTest, AotTestCudaField) { - if (capi::utils::is_cuda_available()) { + if (ti::is_arch_available(TI_ARCH_CUDA)) { TiArch arch = TiArch::TI_ARCH_CUDA; field_aot_test(arch); } @@ -97,21 +97,21 @@ TEST_F(CapiTest, AotTestCpuKernel) { } TEST_F(CapiTest, AotTestCudaKernel) { - if (capi::utils::is_cuda_available()) { + if (ti::is_arch_available(TI_ARCH_CUDA)) { TiArch arch = TiArch::TI_ARCH_CUDA; kernel_aot_test(arch); } } TEST_F(CapiTest, AotTestVulkanKernel) { - if (capi::utils::is_vulkan_available()) { + if (ti::is_arch_available(TI_ARCH_VULKAN)) { TiArch arch = TiArch::TI_ARCH_VULKAN; kernel_aot_test(arch); } } TEST_F(CapiTest, AotTestOpenglKernel) { - if (capi::utils::is_opengl_available()) { + if (ti::is_arch_available(TI_ARCH_OPENGL)) { TiArch arch = TiArch::TI_ARCH_OPENGL; kernel_aot_test(arch); } diff --git a/c_api/tests/c_api_cgraph_test.cpp b/c_api/tests/c_api_cgraph_test.cpp index d2b91ecfdbdae..079ee32a1c8dd 100644 --- a/c_api/tests/c_api_cgraph_test.cpp +++ b/c_api/tests/c_api_cgraph_test.cpp @@ -80,27 +80,27 @@ TEST_F(CapiTest, GraphTestCpuGraph) { } TEST_F(CapiTest, GraphTestCudaGraph) { - if (capi::utils::is_cuda_available()) { + if (ti::is_arch_available(TI_ARCH_CUDA)) { TiArch arch = TiArch::TI_ARCH_CUDA; graph_aot_test(arch); } } TEST_F(CapiTest, GraphTestVulkanGraph) { - if (capi::utils::is_vulkan_available()) { + if (ti::is_arch_available(TI_ARCH_VULKAN)) { TiArch arch = TiArch::TI_ARCH_VULKAN; graph_aot_test(arch); } } TEST_F(CapiTest, GraphTestVulkanTextureGraph) { - if (capi::utils::is_vulkan_available()) { + if (ti::is_arch_available(TI_ARCH_VULKAN)) { TiArch arch = TiArch::TI_ARCH_VULKAN; texture_aot_test(arch); } } TEST_F(CapiTest, GraphTestOpenglGraph) { - if (capi::utils::is_opengl_available()) { + if (ti::is_arch_available(TI_ARCH_OPENGL)) { TiArch arch = TiArch::TI_ARCH_OPENGL; graph_aot_test(arch); } diff --git a/c_api/tests/c_api_interface_test.cpp b/c_api/tests/c_api_interface_test.cpp index 477d8ca5ea944..243a8bef0122e 100644 --- a/c_api/tests/c_api_interface_test.cpp +++ b/c_api/tests/c_api_interface_test.cpp @@ -3,6 +3,34 @@ #include "taichi/cpp/taichi.hpp" #include "c_api/tests/gtest_fixture.h" +TEST_F(CapiTest, AvailableArchs) { + std::vector archs = ti::get_available_archs(); + +#define HAS_ARCH(a) (std::find(archs.begin(), archs.end(), a) != archs.end()) + +#ifdef TI_WITH_VULKAN + TI_ASSERT(HAS_ARCH(TI_ARCH_VULKAN)); +#else + TI_ASSERT(!HAS_ARCH(TI_ARCH_VULKAN)); +#endif + +#ifdef TI_WITH_OPENGL + TI_ASSERT(HAS_ARCH(TI_ARCH_OPENGL)); +#else + TI_ASSERT(!HAS_ARCH(TI_ARCH_OPENGL)); +#endif + +#ifdef TI_WITH_CUDA + TI_ASSERT(HAS_ARCH(TI_ARCH_CUDA)); +#else + TI_ASSERT(!HAS_ARCH(TI_ARCH_CUDA)); +#endif + + TI_ASSERT(HAS_ARCH(TI_ARCH_X64)); + +#undef HAS_ARCH +} + TEST_F(CapiTest, DryRunRuntime) { { // CPU Runtime @@ -10,26 +38,26 @@ TEST_F(CapiTest, DryRunRuntime) { ti::Runtime runtime(arch); } - if (capi::utils::is_vulkan_available()) { + if (ti::is_arch_available(TI_ARCH_VULKAN)) { // Vulkan Runtime TiArch arch = TiArch::TI_ARCH_VULKAN; ti::Runtime runtime(arch); } - if (capi::utils::is_cuda_available()) { + if (ti::is_arch_available(TI_ARCH_CUDA)) { // Vulkan Runtime TiArch arch = TiArch::TI_ARCH_CUDA; ti::Runtime runtime(arch); } - if (capi::utils::is_opengl_available()) { + if (ti::is_arch_available(TI_ARCH_OPENGL)) { TiArch arch = TiArch::TI_ARCH_OPENGL; ti::Runtime runtime(arch); } } TEST_F(CapiTest, DryRunCapabilities) { - if (capi::utils::is_vulkan_available()) { + if (ti::is_arch_available(TI_ARCH_VULKAN)) { // Vulkan Runtime { ti::Runtime runtime(TI_ARCH_VULKAN); @@ -50,7 +78,7 @@ TEST_F(CapiTest, DryRunMemoryAllocation) { ti::NdArray ndarray = runtime.allocate_ndarray({100}, {}); } - if (capi::utils::is_vulkan_available()) { + if (ti::is_arch_available(TI_ARCH_VULKAN)) { // Vulkan Runtime TiArch arch = TiArch::TI_ARCH_VULKAN; ti::Runtime runtime(arch); @@ -58,7 +86,7 @@ TEST_F(CapiTest, DryRunMemoryAllocation) { ti::NdArray ndarray = runtime.allocate_ndarray({100}, {}); } - if (capi::utils::is_opengl_available()) { + if (ti::is_arch_available(TI_ARCH_OPENGL)) { // Opengl Runtime TiArch arch = TiArch::TI_ARCH_OPENGL; ti::Runtime runtime(arch); @@ -66,7 +94,7 @@ TEST_F(CapiTest, DryRunMemoryAllocation) { ti::NdArray ndarray = runtime.allocate_ndarray({100}, {}); } - if (capi::utils::is_cuda_available()) { + if (ti::is_arch_available(TI_ARCH_CUDA)) { // Cuda Runtime TiArch arch = TiArch::TI_ARCH_CUDA; ti::Runtime runtime(arch); @@ -76,7 +104,7 @@ TEST_F(CapiTest, DryRunMemoryAllocation) { } TEST_F(CapiTest, FailMapDeviceOnlyMemory) { - if (capi::utils::is_vulkan_available()) { + if (ti::is_arch_available(TI_ARCH_VULKAN)) { ti::Runtime runtime(TI_ARCH_VULKAN); ti::Memory mem = runtime.allocate_memory(100); @@ -95,7 +123,7 @@ TEST_F(CapiTest, FailMapDeviceOnlyMemory) { } TEST_F(CapiTest, DryRunImageAllocation) { - if (capi::utils::is_vulkan_available()) { + if (ti::is_arch_available(TI_ARCH_VULKAN)) { { // Vulkan Runtime TiArch arch = TiArch::TI_ARCH_VULKAN; @@ -107,7 +135,7 @@ TEST_F(CapiTest, DryRunImageAllocation) { } TEST_F(CapiTest, DryRunVulkanAotModule) { - if (capi::utils::is_vulkan_available()) { + if (ti::is_arch_available(TI_ARCH_VULKAN)) { const auto folder_dir = getenv("TAICHI_AOT_FOLDER_PATH"); std::stringstream aot_mod_ss; @@ -123,7 +151,7 @@ TEST_F(CapiTest, DryRunVulkanAotModule) { } TEST_F(CapiTest, DryRunOpenglAotModule) { - if (capi::utils::is_opengl_available()) { + if (ti::is_arch_available(TI_ARCH_OPENGL)) { const auto folder_dir = getenv("TAICHI_AOT_FOLDER_PATH"); std::stringstream aot_mod_ss; @@ -140,7 +168,7 @@ TEST_F(CapiTest, DryRunOpenglAotModule) { } TEST_F(CapiTest, TestLoadTcmAotModule) { - if (capi::utils::is_vulkan_available()) { + if (ti::is_arch_available(TI_ARCH_VULKAN)) { const auto folder_dir = getenv("TAICHI_AOT_FOLDER_PATH"); std::stringstream aot_mod_ss; @@ -167,7 +195,7 @@ TEST_F(CapiTest, TestLoadTcmAotModule) { } TEST_F(CapiTest, TestCreateTcmAotModule) { - if (capi::utils::is_vulkan_available()) { + if (ti::is_arch_available(TI_ARCH_VULKAN)) { const auto folder_dir = getenv("TAICHI_AOT_FOLDER_PATH"); std::stringstream aot_mod_ss; diff --git a/c_api/tests/c_api_interop_test.cpp b/c_api/tests/c_api_interop_test.cpp index eee4142b3a1e1..b718c1ea46e44 100644 --- a/c_api/tests/c_api_interop_test.cpp +++ b/c_api/tests/c_api_interop_test.cpp @@ -36,7 +36,7 @@ TEST_F(CapiTest, AotTestCpuBufferInterop) { } TEST_F(CapiTest, AotTestCudaBufferInterop) { - if (capi::utils::is_cuda_available()) { + if (ti::is_arch_available(TI_ARCH_CUDA)) { TiArch arch = TiArch::TI_ARCH_CUDA; ti::Runtime runtime(arch); uint32_t size0 = 4; @@ -80,7 +80,7 @@ static void texture_interop_test(TiArch arch) { } TEST_F(CapiTest, AotTestVulkanTextureInterop) { - if (capi::utils::is_vulkan_available()) { + if (ti::is_arch_available(TI_ARCH_VULKAN)) { TiArch arch = TiArch::TI_ARCH_VULKAN; texture_interop_test(arch); } diff --git a/c_api/tests/comet.cpp b/c_api/tests/comet.cpp index 2938519e166b0..33a390d2f7ac0 100644 --- a/c_api/tests/comet.cpp +++ b/c_api/tests/comet.cpp @@ -35,7 +35,7 @@ static void comet_run(TiArch arch, const std::string &folder_dir) { } TEST_F(CapiTest, CometTestCuda) { - if (capi::utils::is_cuda_available()) { + if (ti::is_arch_available(TI_ARCH_CUDA)) { const auto folder_dir = getenv("TAICHI_AOT_FOLDER_PATH"); std::stringstream aot_mod_ss; diff --git a/c_api/tests/mpm88_test.cpp b/c_api/tests/mpm88_test.cpp index f0ded636255b5..ebf12ea2b5c1d 100644 --- a/c_api/tests/mpm88_test.cpp +++ b/c_api/tests/mpm88_test.cpp @@ -101,7 +101,7 @@ class MPM88DemoImpl { } // namespace demo TEST_F(CapiTest, Mpm88TestCuda) { - if (capi::utils::is_cuda_available()) { + if (ti::is_arch_available(TI_ARCH_CUDA)) { const auto folder_dir = getenv("TAICHI_AOT_FOLDER_PATH"); std::stringstream aot_mod_ss; @@ -114,7 +114,7 @@ TEST_F(CapiTest, Mpm88TestCuda) { } TEST_F(CapiTest, Mpm88TestVulkan) { - if (capi::utils::is_vulkan_available()) { + if (ti::is_arch_available(TI_ARCH_VULKAN)) { const auto folder_dir = getenv("TAICHI_AOT_FOLDER_PATH"); std::stringstream aot_mod_ss; @@ -127,7 +127,7 @@ TEST_F(CapiTest, Mpm88TestVulkan) { } TEST_F(CapiTest, Mpm88TestOpengl) { - if (capi::utils::is_opengl_available()) { + if (ti::is_arch_available(TI_ARCH_OPENGL)) { const auto folder_dir = getenv("TAICHI_AOT_FOLDER_PATH"); std::stringstream aot_mod_ss; diff --git a/c_api/tests/sph.cpp b/c_api/tests/sph.cpp index d76e8ace1255e..a68367adfe665 100644 --- a/c_api/tests/sph.cpp +++ b/c_api/tests/sph.cpp @@ -87,7 +87,7 @@ void run(TiArch arch, const std::string &folder_dir) { } TEST_F(CapiTest, SphTestCuda) { - if (capi::utils::is_cuda_available()) { + if (ti::is_arch_available(TI_ARCH_CUDA)) { const auto folder_dir = getenv("TAICHI_AOT_FOLDER_PATH"); std::stringstream aot_mod_ss; @@ -98,7 +98,7 @@ TEST_F(CapiTest, SphTestCuda) { } TEST_F(CapiTest, SphTestVulkan) { - if (capi::utils::is_vulkan_available()) { + if (ti::is_arch_available(TI_ARCH_VULKAN)) { const auto folder_dir = getenv("TAICHI_AOT_FOLDER_PATH"); std::stringstream aot_mod_ss; @@ -109,7 +109,7 @@ TEST_F(CapiTest, SphTestVulkan) { } TEST_F(CapiTest, SphTestOpengl) { - if (capi::utils::is_opengl_available()) { + if (ti::is_arch_available(TI_ARCH_OPENGL)) { const auto folder_dir = getenv("TAICHI_AOT_FOLDER_PATH"); std::stringstream aot_mod_ss; diff --git a/c_api/tests/taichi_sparse_test.cpp b/c_api/tests/taichi_sparse_test.cpp index c1064a63b9680..729a3c107b6a9 100644 --- a/c_api/tests/taichi_sparse_test.cpp +++ b/c_api/tests/taichi_sparse_test.cpp @@ -38,7 +38,7 @@ static void taichi_sparse_test(TiArch arch) { } TEST_F(CapiTest, TaichiSparseTestCuda) { - if (capi::utils::is_cuda_available()) { + if (ti::is_arch_available(TI_ARCH_CUDA)) { TiArch arch = TiArch::TI_ARCH_CUDA; taichi_sparse_test(arch); } From dfe0f5068b8e17048897e66382eb747fabefd333 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Nov 2022 15:17:17 +0000 Subject: [PATCH 2/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- c_api/src/taichi_core_impl.cpp | 3 +-- c_api/src/taichi_llvm_impl.cpp | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/c_api/src/taichi_core_impl.cpp b/c_api/src/taichi_core_impl.cpp index 371460131cc72..42adce0d8f015 100644 --- a/c_api/src/taichi_core_impl.cpp +++ b/c_api/src/taichi_core_impl.cpp @@ -107,7 +107,7 @@ Runtime &Event::runtime() { // ----------------------------------------------------------------------------- -void ti_get_available_archs(uint32_t* arch_count, TiArch* archs) { +void ti_get_available_archs(uint32_t *arch_count, TiArch *archs) { if (arch_count == nullptr) { return; } @@ -138,7 +138,6 @@ void ti_get_available_archs(uint32_t* arch_count, TiArch* archs) { archs[i] = AVAILABLE_ARCHS.at(i); } } - } TiError ti_get_last_error(uint64_t message_size, char *message) { diff --git a/c_api/src/taichi_llvm_impl.cpp b/c_api/src/taichi_llvm_impl.cpp index b84028bdc4563..b9df3e79bc216 100644 --- a/c_api/src/taichi_llvm_impl.cpp +++ b/c_api/src/taichi_llvm_impl.cpp @@ -137,7 +137,6 @@ void LlvmRuntime::wait() { } // namespace capi - // function.export_cpu_runtime void ti_export_cpu_memory(TiRuntime runtime, TiMemory memory, @@ -209,7 +208,9 @@ bool is_cuda_available() { } bool is_x64_available() { -#if defined(TI_WITH_LLVM) && (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) || defined(__amd64) || defined(_M_X64)) +#if defined(TI_WITH_LLVM) && \ + (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) || \ + defined(__amd64) || defined(_M_X64)) return true; #else return false; From 7a63ecd72bfa277002cb5eea2e47b46ad1881a9e Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Tue, 29 Nov 2022 23:26:15 +0800 Subject: [PATCH 3/9] Fixed compilation --- c_api/src/taichi_opengl_impl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/c_api/src/taichi_opengl_impl.cpp b/c_api/src/taichi_opengl_impl.cpp index 2e64083f3f92b..e9f5ef3ef0364 100644 --- a/c_api/src/taichi_opengl_impl.cpp +++ b/c_api/src/taichi_opengl_impl.cpp @@ -1,5 +1,6 @@ -#include "taichi_opengl_impl.h" #ifdef TI_WITH_OPENGL +#include "taichi_opengl_impl.h" +#include "taichi/rhi/opengl/opengl_api.h" OpenglRuntime::OpenglRuntime() : GfxRuntime(taichi::Arch::opengl), From 2806225b7dfa4c95fba36435a5fbd04b68985b37 Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Tue, 29 Nov 2022 23:34:11 +0800 Subject: [PATCH 4/9] Fixed compilation --- c_api/src/taichi_core_impl.cpp | 42 ++++++++++++++++++++++++++++++++ c_api/src/taichi_llvm_impl.cpp | 26 -------------------- c_api/src/taichi_llvm_impl.h | 4 --- c_api/src/taichi_opengl_impl.cpp | 8 ------ c_api/src/taichi_opengl_impl.h | 2 -- c_api/src/taichi_vulkan_impl.cpp | 8 ------ c_api/src/taichi_vulkan_impl.h | 2 -- 7 files changed, 42 insertions(+), 50 deletions(-) diff --git a/c_api/src/taichi_core_impl.cpp b/c_api/src/taichi_core_impl.cpp index 42adce0d8f015..ab8429a18d73d 100644 --- a/c_api/src/taichi_core_impl.cpp +++ b/c_api/src/taichi_core_impl.cpp @@ -6,6 +6,48 @@ #include "taichi/program/texture.h" #include "taichi/common/virtual_dir.h" +bool is_vulkan_available() { +#ifdef TI_WITH_VULKAN + return taichi::lang::vulkan::is_vulkan_api_available(); +#else + return false; +#endif +} + +bool is_opengl_available() { +#ifdef TI_WITH_OPENGL + return taichi::lang::opengl::is_opengl_api_available(); +#else + return false; +#endif +} + +bool is_cuda_available() { +#ifdef TI_WITH_CUDA + return taichi::is_cuda_api_available(); +#else + return false; +#endif +} + +bool is_x64_available() { +#if defined(TI_WITH_LLVM) && \ + (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) || \ + defined(__amd64) || defined(_M_X64)) + return true; +#else + return false; +#endif +} + +bool is_arm64_available() { +#if defined(TI_WITH_LLVM) && (defined(__arm64__) || defined(__aarch64__)) + return true; +#else + return false; +#endif +} + struct ErrorCache { TiError error{TI_ERROR_SUCCESS}; std::string message{}; diff --git a/c_api/src/taichi_llvm_impl.cpp b/c_api/src/taichi_llvm_impl.cpp index b9df3e79bc216..04301135035f6 100644 --- a/c_api/src/taichi_llvm_impl.cpp +++ b/c_api/src/taichi_llvm_impl.cpp @@ -198,29 +198,3 @@ void ti_export_cuda_memory(TiRuntime runtime, } #endif // TI_WITH_LLVM - -bool is_cuda_available() { -#ifdef TI_WITH_CUDA - return taichi::is_cuda_api_available(); -#else - return false; -#endif -} - -bool is_x64_available() { -#if defined(TI_WITH_LLVM) && \ - (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) || \ - defined(__amd64) || defined(_M_X64)) - return true; -#else - return false; -#endif -} - -bool is_arm64_available() { -#if defined(TI_WITH_LLVM) && (defined(__arm64__) || defined(__aarch64__)) - return true; -#else - return false; -#endif -} diff --git a/c_api/src/taichi_llvm_impl.h b/c_api/src/taichi_llvm_impl.h index 2ebd45fe2b377..4315d9fe409c9 100644 --- a/c_api/src/taichi_llvm_impl.h +++ b/c_api/src/taichi_llvm_impl.h @@ -43,7 +43,3 @@ class LlvmRuntime : public Runtime { } // namespace capi #endif // TI_WITH_LLVM - -extern bool is_cuda_available(); -extern bool is_x64_available(); -extern bool is_arm64_available(); diff --git a/c_api/src/taichi_opengl_impl.cpp b/c_api/src/taichi_opengl_impl.cpp index e9f5ef3ef0364..da20b9a19ef72 100644 --- a/c_api/src/taichi_opengl_impl.cpp +++ b/c_api/src/taichi_opengl_impl.cpp @@ -36,11 +36,3 @@ void ti_export_opengl_memory(TiRuntime runtime, } #endif // TI_WITH_OPENGL - -bool is_opengl_available() { -#ifdef TI_WITH_OPENGL - return taichi::lang::opengl::is_opengl_api_available(); -#else - return false; -#endif -} diff --git a/c_api/src/taichi_opengl_impl.h b/c_api/src/taichi_opengl_impl.h index 2a99c0c6aee37..5b2a2bf1bd0ba 100644 --- a/c_api/src/taichi_opengl_impl.h +++ b/c_api/src/taichi_opengl_impl.h @@ -19,5 +19,3 @@ class OpenglRuntime : public GfxRuntime { }; #endif // TI_WITH_OPENGL - -extern bool is_opengl_available(); diff --git a/c_api/src/taichi_vulkan_impl.cpp b/c_api/src/taichi_vulkan_impl.cpp index f6538afe708e1..5cd5fa4d19664 100644 --- a/c_api/src/taichi_vulkan_impl.cpp +++ b/c_api/src/taichi_vulkan_impl.cpp @@ -374,11 +374,3 @@ void ti_export_vulkan_event(TiRuntime runtime, } #endif // TI_WITH_VULKAN - -bool is_vulkan_available() { -#ifdef TI_WITH_VULKAN - return taichi::lang::vulkan::is_vulkan_api_available(); -#else - return false; -#endif -} diff --git a/c_api/src/taichi_vulkan_impl.h b/c_api/src/taichi_vulkan_impl.h index 6c8a39e0b18a7..3dfba7a0a14fd 100644 --- a/c_api/src/taichi_vulkan_impl.h +++ b/c_api/src/taichi_vulkan_impl.h @@ -52,5 +52,3 @@ class VulkanRuntimeOwned : public VulkanRuntime { }; #endif // TI_WITH_VULKAN - -bool is_vulkan_available(); From 8e83182902b255c8f91cb3bba9fb08d3b2809645 Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Tue, 29 Nov 2022 23:40:57 +0800 Subject: [PATCH 5/9] Fixed compilation --- c_api/src/taichi_opengl_impl.cpp | 1 - c_api/src/taichi_opengl_impl.h | 1 + c_api/src/taichi_vulkan_impl.h | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/c_api/src/taichi_opengl_impl.cpp b/c_api/src/taichi_opengl_impl.cpp index da20b9a19ef72..b9cd5ba425cc0 100644 --- a/c_api/src/taichi_opengl_impl.cpp +++ b/c_api/src/taichi_opengl_impl.cpp @@ -1,6 +1,5 @@ #ifdef TI_WITH_OPENGL #include "taichi_opengl_impl.h" -#include "taichi/rhi/opengl/opengl_api.h" OpenglRuntime::OpenglRuntime() : GfxRuntime(taichi::Arch::opengl), diff --git a/c_api/src/taichi_opengl_impl.h b/c_api/src/taichi_opengl_impl.h index 5b2a2bf1bd0ba..24678ea14e0d7 100644 --- a/c_api/src/taichi_opengl_impl.h +++ b/c_api/src/taichi_opengl_impl.h @@ -2,6 +2,7 @@ #ifdef TI_WITH_OPENGL #include "taichi_gfx_impl.h" +#include "taichi/rhi/opengl/opengl_api.h" #include "taichi/rhi/opengl/opengl_device.h" class OpenglRuntime : public GfxRuntime { diff --git a/c_api/src/taichi_vulkan_impl.h b/c_api/src/taichi_vulkan_impl.h index 3dfba7a0a14fd..751daab7b73c7 100644 --- a/c_api/src/taichi_vulkan_impl.h +++ b/c_api/src/taichi_vulkan_impl.h @@ -3,6 +3,7 @@ #include "taichi_core_impl.h" #include "taichi_gfx_impl.h" +#include "taichi/rhi/vulkan/vulkan_loader.h" #include "taichi/rhi/vulkan/vulkan_device.h" #include "taichi/rhi/vulkan/vulkan_device_creator.h" From 2342fe310de90996d4b227265a8cdbce643e68ad Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Tue, 29 Nov 2022 23:45:09 +0800 Subject: [PATCH 6/9] Fixed compilation --- c_api/src/taichi_llvm_impl.cpp | 1 - c_api/src/taichi_llvm_impl.h | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/c_api/src/taichi_llvm_impl.cpp b/c_api/src/taichi_llvm_impl.cpp index 04301135035f6..e83b2382e7a83 100644 --- a/c_api/src/taichi_llvm_impl.cpp +++ b/c_api/src/taichi_llvm_impl.cpp @@ -13,7 +13,6 @@ #include "taichi/rhi/cpu/cpu_device.h" #ifdef TI_WITH_CUDA -#include "taichi/platform/cuda/detect_cuda.h" #include "taichi/rhi/cuda/cuda_device.h" #include "taichi/runtime/cuda/aot_module_loader_impl.h" #endif diff --git a/c_api/src/taichi_llvm_impl.h b/c_api/src/taichi_llvm_impl.h index 4315d9fe409c9..51e990810bdd0 100644 --- a/c_api/src/taichi_llvm_impl.h +++ b/c_api/src/taichi_llvm_impl.h @@ -3,6 +3,10 @@ #include "taichi_core_impl.h" +#ifdef TI_WITH_CUDA +#include "taichi/platform/cuda/detect_cuda.h" +#endif + namespace taichi::lang { class LlvmRuntimeExecutor; class MemoryPool; From bce203cd23d68d8d4b09912c5cd17c527de57cc2 Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Tue, 29 Nov 2022 23:55:50 +0800 Subject: [PATCH 7/9] Give up testing every arch --- c_api/tests/c_api_interface_test.cpp | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/c_api/tests/c_api_interface_test.cpp b/c_api/tests/c_api_interface_test.cpp index 243a8bef0122e..21e99ebeebfec 100644 --- a/c_api/tests/c_api_interface_test.cpp +++ b/c_api/tests/c_api_interface_test.cpp @@ -3,32 +3,8 @@ #include "taichi/cpp/taichi.hpp" #include "c_api/tests/gtest_fixture.h" -TEST_F(CapiTest, AvailableArchs) { +TEST_F(CapiTest, DryRunAvailableArchs) { std::vector archs = ti::get_available_archs(); - -#define HAS_ARCH(a) (std::find(archs.begin(), archs.end(), a) != archs.end()) - -#ifdef TI_WITH_VULKAN - TI_ASSERT(HAS_ARCH(TI_ARCH_VULKAN)); -#else - TI_ASSERT(!HAS_ARCH(TI_ARCH_VULKAN)); -#endif - -#ifdef TI_WITH_OPENGL - TI_ASSERT(HAS_ARCH(TI_ARCH_OPENGL)); -#else - TI_ASSERT(!HAS_ARCH(TI_ARCH_OPENGL)); -#endif - -#ifdef TI_WITH_CUDA - TI_ASSERT(HAS_ARCH(TI_ARCH_CUDA)); -#else - TI_ASSERT(!HAS_ARCH(TI_ARCH_CUDA)); -#endif - - TI_ASSERT(HAS_ARCH(TI_ARCH_X64)); - -#undef HAS_ARCH } TEST_F(CapiTest, DryRunRuntime) { From 88ea650a98298501d8f61d0900ea90cf85a353b5 Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Wed, 30 Nov 2022 10:55:43 +0800 Subject: [PATCH 8/9] Requested changes --- c_api/include/taichi/taichi_cuda.h | 4 --- c_api/include/taichi/taichi_opengl.h | 4 --- c_api/include/taichi/taichi_vulkan.h | 4 --- c_api/taichi.json | 18 ---------- docs/lang/articles/c-api/taichi_core.md | 34 +++++++++++++++++-- python/taichi/examples/graph/texture_graph.py | 2 +- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/c_api/include/taichi/taichi_cuda.h b/c_api/include/taichi/taichi_cuda.h index ab335c73366c5..485953966a159 100644 --- a/c_api/include/taichi/taichi_cuda.h +++ b/c_api/include/taichi/taichi_cuda.h @@ -1,9 +1,5 @@ #pragma once -#ifndef TI_WITH_CUDA -#define TI_WITH_CUDA 1 -#endif // TI_WITH_CUDA - #include #ifdef __cplusplus diff --git a/c_api/include/taichi/taichi_opengl.h b/c_api/include/taichi/taichi_opengl.h index 4a73c3f6c1a32..0522de61ce047 100644 --- a/c_api/include/taichi/taichi_opengl.h +++ b/c_api/include/taichi/taichi_opengl.h @@ -1,9 +1,5 @@ #pragma once -#ifndef TI_WITH_OPENGL -#define TI_WITH_OPENGL 1 -#endif // TI_WITH_OPENGL - #include #ifdef __cplusplus diff --git a/c_api/include/taichi/taichi_vulkan.h b/c_api/include/taichi/taichi_vulkan.h index dcc2384c671db..2a440092013fb 100644 --- a/c_api/include/taichi/taichi_vulkan.h +++ b/c_api/include/taichi/taichi_vulkan.h @@ -6,10 +6,6 @@ // #pragma once -#ifndef TI_WITH_VULKAN -#define TI_WITH_VULKAN 1 -#endif // TI_WITH_VULKAN - #include #ifdef __cplusplus diff --git a/c_api/taichi.json b/c_api/taichi.json index f9d25e198acd4..62d2aa5adc359 100644 --- a/c_api/taichi.json +++ b/c_api/taichi.json @@ -990,12 +990,6 @@ }, { "name": "taichi/taichi_cuda.h", - "default_definitions": [ - { - "name": "TI_WITH_CUDA", - "value": "1" - } - ], "required_modules": [ "taichi/taichi_core.h" ], @@ -1035,12 +1029,6 @@ }, { "name": "taichi/taichi_vulkan.h", - "default_definitions": [ - { - "name": "TI_WITH_VULKAN", - "value": "1" - } - ], "doc": "taichi/taichi_vulkan.h.md", "required_modules": [ "taichi/taichi_core.h" @@ -1343,12 +1331,6 @@ }, { "name": "taichi/taichi_opengl.h", - "default_definitions": [ - { - "name": "TI_WITH_OPENGL", - "value": "1" - } - ], "required_modules": [ "taichi/taichi_core.h" ], diff --git a/docs/lang/articles/c-api/taichi_core.md b/docs/lang/articles/c-api/taichi_core.md index f748a270bc5fc..c6c64782d3804 100644 --- a/docs/lang/articles/c-api/taichi_core.md +++ b/docs/lang/articles/c-api/taichi_core.md @@ -914,6 +914,24 @@ A named argument value to feed compute graphs. - `name`: Name of the argument. - `argument`: Argument body. +--- +### Function `ti_get_available_archs` + +```c +// function.get_available_archs +TI_DLL_EXPORT void TI_API_CALL ti_get_available_archs( + uint32_t* arch_count, + TiArch* archs +); +``` + +Gets a list of available archs on the current platform. An arch is only available if: + +1. The Runtime library is compiled with its support; +2. The current platform is installed with a capable hardware or an emulation software. + +An available arch has at least one device available, i.e., device index 0 is always available. If an arch is not available on the current platform, a call to [`ti_create_runtime`](#function-ti_create_runtime) with that arch is guaranteed failing. + --- ### Function `ti_get_last_error` @@ -925,7 +943,7 @@ TI_DLL_EXPORT TiError TI_API_CALL ti_get_last_error( ); ``` -Get the last error raised by Taichi C-API invocations. Returns the semantical error code. +Gets the last error raised by Taichi C-API invocations. Returns the semantical error code. - `message_size`: Size of textual error message in `message` - `message`: Text buffer for the textual error message. Ignored when `message_size` is 0. @@ -941,7 +959,7 @@ TI_DLL_EXPORT void TI_API_CALL ti_set_last_error( ); ``` -Set the provided error as the last error raised by Taichi C-API invocations. It can be useful in extended validation procedures in Taichi C-API wrappers and helper libraries. +Sets the provided error as the last error raised by Taichi C-API invocations. It can be useful in extended validation procedures in Taichi C-API wrappers and helper libraries. - `error`: Semantical error code. - `message`: A null-terminated string of the textual error message or `nullptr` for empty error message. @@ -1269,6 +1287,18 @@ TI_DLL_EXPORT TiAotModule TI_API_CALL ti_load_aot_module( Loads a pre-compiled AOT module from the file system. Returns [`TI_NULL_HANDLE`](#definition-ti_null_handle) if the runtime fails to load the AOT module from the specified path. +--- +### Function `ti_create_aot_module` + +```c +// function.create_aot_module +TI_DLL_EXPORT TiAotModule TI_API_CALL ti_create_aot_module( + TiRuntime runtime, + const void* tcm, + uint64_t size +); +``` + --- ### Function `ti_destroy_aot_module` diff --git a/python/taichi/examples/graph/texture_graph.py b/python/taichi/examples/graph/texture_graph.py index cb30e989189b8..93575f2b4b8a8 100644 --- a/python/taichi/examples/graph/texture_graph.py +++ b/python/taichi/examples/graph/texture_graph.py @@ -79,7 +79,7 @@ def main(): mod.save(tmpdir, '') else: t = 0.0 - window = ti.ui.Window('UV', res) + window = ti.ui.Window('UV', res, True) canvas = window.get_canvas() while window.running: g.run({'t': t, 'pixels_arr': pixels_arr, 'tex': texture}) From 8f4af25029da2bc24a34c64e27d445c7adb0c78d Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Wed, 30 Nov 2022 11:58:58 +0800 Subject: [PATCH 9/9] Nit --- python/taichi/examples/graph/texture_graph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/taichi/examples/graph/texture_graph.py b/python/taichi/examples/graph/texture_graph.py index 93575f2b4b8a8..cb30e989189b8 100644 --- a/python/taichi/examples/graph/texture_graph.py +++ b/python/taichi/examples/graph/texture_graph.py @@ -79,7 +79,7 @@ def main(): mod.save(tmpdir, '') else: t = 0.0 - window = ti.ui.Window('UV', res, True) + window = ti.ui.Window('UV', res) canvas = window.get_canvas() while window.running: g.run({'t': t, 'pixels_arr': pixels_arr, 'tex': texture})