From 7fbb7e34ed598c94a9bb826134aa815b6298e48f Mon Sep 17 00:00:00 2001 From: Zhanlue Yang Date: Tue, 3 Jan 2023 14:04:16 +0800 Subject: [PATCH 1/7] [build] Remove libexport_core.so dependency for Android App CI (#6997) Issue: # ### Brief Summary --- .github/workflows/scripts/aot-demo.sh | 28 ++++++++++++--------------- .github/workflows/testing.yml | 2 +- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.github/workflows/scripts/aot-demo.sh b/.github/workflows/scripts/aot-demo.sh index 6b20e58cff1ba..b887f80713916 100755 --- a/.github/workflows/scripts/aot-demo.sh +++ b/.github/workflows/scripts/aot-demo.sh @@ -17,6 +17,8 @@ export TAICHI_UNITY_EXAMPLE_BRANCH=main function build-and-smoke-test-android-aot-demo { + setup-android-ndk-env + pushd taichi GIT_COMMIT=$(git rev-parse HEAD | cut -c1-7) setup_python @@ -26,26 +28,20 @@ function build-and-smoke-test-android-aot-demo { rm -rf taichi-aot-demo # IF YOU PIN THIS TO A COMMIT/BRANCH, YOU'RE RESPONSIBLE TO REVERT IT BACK TO MASTER ONCE MERGED. - git clone --depth=1 -b "$TAICHI_AOT_DEMO_BRANCH" "$TAICHI_AOT_DEMO_URL" - - APP_ROOT=taichi-aot-demo/implicit_fem - ANDROID_APP_ROOT=$APP_ROOT/android - JNI_PATH=$ANDROID_APP_ROOT/app/src/main/jniLibs/arm64-v8a/ + git clone --recursive --depth=1 -b "$TAICHI_AOT_DEMO_BRANCH" "$TAICHI_AOT_DEMO_URL" + # Install taichi-python pip install /taichi-wheel/*.whl - pushd $APP_ROOT/python - sudo chmod 0777 $HOME/.cache - python implicit_fem.py --aot - popd - mkdir -p $JNI_PATH - cp taichi/build/libtaichi_export_core.so $JNI_PATH - cd $ANDROID_APP_ROOT - sed -i "s/TaichiAOT/AOT-$GIT_COMMIT/g" app/src/main/res/values/strings.xml - ./gradlew build + + # Build Android Apps + cd taichi-aot-demo + ./scripts/build-taichi-android.sh + ./scripts/build-android.sh + ./scripts/build-android-app.sh E3_implicit_fem run-android-app \ - app/build/outputs/apk/debug/app-debug.apk \ - com.taichigraphics.aot_demos.implicit_fem/android.app.NativeActivity + framework/android/app/build/outputs/apk/debug/E3_implicit_fem-debug.apk \ + org.taichi.aot_demo/android.app.NativeActivity } function prepare-unity-build-env { diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 1025f1d117a39..db60e112e5a1b 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -537,7 +537,7 @@ jobs: -DTI_WITH_LLVM:BOOL=OFF -DTI_WITH_C_API=ON - - name: Test For Android AOT (export core) + - name: Test For Android AOT if: ${{ needs.check_files.outputs.run_job != 'false' }} run: | . .github/workflows/scripts/common-utils.sh From f3dd60c63bfda2d34fec114c6903af7699975a00 Mon Sep 17 00:00:00 2001 From: Ailing Date: Tue, 3 Jan 2023 14:35:07 +0800 Subject: [PATCH 2/7] Revert "[opengl] Enable more gles tests in CI" (#7029) --- .github/workflows/scripts/unix_test.sh | 1 - .github/workflows/testing.yml | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/scripts/unix_test.sh b/.github/workflows/scripts/unix_test.sh index 4196937d1ee86..5a3a425759d39 100755 --- a/.github/workflows/scripts/unix_test.sh +++ b/.github/workflows/scripts/unix_test.sh @@ -117,7 +117,6 @@ else run-it cpu $(nproc) run-it vulkan 8 run-it opengl 4 - run-it gles 4 python3 tests/run_tests.py -vr2 -t1 -k "torch" -a "$TI_WANTED_ARCHS" # Paddle's paddle.fluid.core.Tensor._ptr() is only available on develop branch, and CUDA version on linux will get error `Illegal Instruction` diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index db60e112e5a1b..9dc2ca2eb2469 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -236,7 +236,7 @@ jobs: /home/dev/taichi/.github/workflows/scripts/unix_test.sh env: PY: '3.8' - TI_WANTED_ARCHS: 'cc,cpu,cuda,vulkan,opengl,gles' + TI_WANTED_ARCHS: 'cc,cpu,cuda,vulkan,opengl' TI_DEVICE_MEMORY_GB: '1' TI_RUN_RELEASE_TESTS: '1' @@ -344,7 +344,7 @@ jobs: include: - os: windows-2019 llvmVer : '15' - archs: "cpu,cuda,opengl,gles" + archs: "cpu,cuda,opengl" runsOn: [self-hosted, windows, cuda, OpenGL] runs-on: ${{ matrix.runsOn }} timeout-minutes: ${{ github.event.schedule != '0 18 * * *' && 90 || 180 }} From 1ae5ca0fbbab0d587aa79424a766e6785f1b25ef Mon Sep 17 00:00:00 2001 From: Zhao Liang Date: Tue, 3 Jan 2023 16:09:38 +0800 Subject: [PATCH 3/7] [Doc] Remove packed mode in doc (#7030) This PR removes the `packed` option in `ti.init` according to the changes in v1.4.0. --- docs/lang/articles/reference/global_settings.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/lang/articles/reference/global_settings.md b/docs/lang/articles/reference/global_settings.md index 8ef7bcb7ebe8b..44c54666fed3b 100644 --- a/docs/lang/articles/reference/global_settings.md +++ b/docs/lang/articles/reference/global_settings.md @@ -70,9 +70,6 @@ Following are some frequently-used configurations in `ti.init()`: offline_cache_file_path: str Set a directory for holding the offline cached files. - packed: bool - Enable/disable the packed memory layout. - random_seed: int Set a custom seed for the random number generator. @@ -174,7 +171,6 @@ If you want to use CUDA and Taichi's GGUI system at the same time on a machine w - To set a custom seed for the random number generator used by `ti.random()`: `ti.init(random_seed=seed)`. `seed` should be an integer. An example: `ti.init(random_seed=int(time.time()))`. - To set the default precision of floating-point numbers of Taichi runtime to `ti.f64`: `ti.init(default_fp=ti.i64)`. - To set the default precision of floating-point numbers of Taichi runtime to `ti.i32`: `ti.init(default_ip=ti.i32)`. -- To enable the packed mode for memory layout: `ti.init(packed=True)`. See the [Packed mode](../basic/layout.md#packed-mode) for more information. - To disable the offline cache of compiled kernels: `ti.init(offline_cache=False)`. See the [Offline cache](../performance_tuning/performance.md#offline-cache) for more information. - To enable the use of variables as indices to access vector/matrix elements in the Taichi scope: `ti.init(dynamic_index=True)`. - To turn on kernel profiling: `ti.init(kernel_profiler=True)`. See the [Profiler](../performance_tuning/profiler.md#kernelprofiler) for more information. @@ -182,7 +178,7 @@ If you want to use CUDA and Taichi's GGUI system at the same time on a machine w ## Logging -- To set the logging level: `ti.init(log_level=ti.TRACE)` or `ti.set_logging_level(ti.TRACE)` enables the TRACE level. The environment variable `TI_LOG_LEVEL` serves the same purpose. +- To set the logging level: `ti.init(log_level=ti.TRACE)` or `ti.set_logging_level(ti.TRACE)` enables the TRACE level. The environment variable `TI_LOG_LEVEL` serves the same purpose. - To eliminate verbose outputs: `ti.init(verbose=False)`. ## Develop From 218e854399db62defecacf807ff384ab71c5b464 Mon Sep 17 00:00:00 2001 From: Proton Date: Tue, 3 Jan 2023 17:44:32 +0800 Subject: [PATCH 4/7] [ci] Update pre-commit app versions (#7025) Issue: # ### Brief Summary --- .pre-commit-config.yaml | 8 ++-- misc/baselines/bandwidth.cu | 4 +- taichi/analysis/gen_offline_cache_key.cpp | 4 +- taichi/common/interface.h | 10 ++--- taichi/common/json.cpp | 2 +- taichi/ir/expression.h | 6 +-- taichi/ir/expression_ops.h | 12 ++--- taichi/ir/ir.cpp | 6 +-- taichi/ir/ir.h | 6 +-- taichi/math/sifakis_svd.h | 44 +++++++++---------- taichi/program/field_info.h | 12 ++--- taichi/rhi/device.h | 4 +- taichi/rhi/dx/dx_device.h | 2 +- taichi/runtime/llvm/runtime_module/atomic.h | 18 +++----- .../runtime/llvm/runtime_module/runtime.cpp | 24 +++------- taichi/ui/utils/utils.h | 12 ++--- taichi/util/bit.h | 10 ++--- 17 files changed, 68 insertions(+), 116 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9764922063e38..e5a3cf202155b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,24 +11,24 @@ repos: additional_dependencies: [toml] - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.11.4 hooks: - id: isort - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v13.0.1 + rev: v15.0.6 hooks: - id: clang-format exclude: .*\.json$ - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 + rev: v4.4.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - repo: https://github.com/PyCQA/pylint - rev: v2.13.4 + rev: v2.15.9 hooks: - id: pylint args: ['-rn', '-sn'] diff --git a/misc/baselines/bandwidth.cu b/misc/baselines/bandwidth.cu index 13aa5279ec4d5..cb901c38eb6ad 100644 --- a/misc/baselines/bandwidth.cu +++ b/misc/baselines/bandwidth.cu @@ -54,8 +54,8 @@ __global__ void fd(float *a, float *b, int *c, int n) { // i = (i * 1e-10f); // i = i * i * i * i * i % m; // b_s[i % m] = 1; - //#define C(x) i += (i >> x); - //#define C(x) i += (i >> x); + // #define C(x) i += (i >> x); + // #define C(x) i += (i >> x); // for (int t = 0; t < 240; t++) // C(30); i += int(sin(i * 1e-20f)); diff --git a/taichi/analysis/gen_offline_cache_key.cpp b/taichi/analysis/gen_offline_cache_key.cpp index fe511e473cc58..ba44b15efc404 100644 --- a/taichi/analysis/gen_offline_cache_key.cpp +++ b/taichi/analysis/gen_offline_cache_key.cpp @@ -621,9 +621,7 @@ class ASTSerializer : public IRVisitor, public ExpressionVisitor { } #define DEFINE_EMIT_ENUM(EnumType) \ - void emit(EnumType type) { \ - emit_pod(type); \ - } + void emit(EnumType type) { emit_pod(type); } DEFINE_EMIT_ENUM(ExprOpCode); DEFINE_EMIT_ENUM(StmtOpCode); diff --git a/taichi/common/interface.h b/taichi/common/interface.h index 164f8d5c229da..057eeacc8f246 100644 --- a/taichi/common/interface.h +++ b/taichi/common/interface.h @@ -325,12 +325,8 @@ class InterfaceHolder { } \ } ImplementationInjector_##base_class_name##class_name##instance; -#define TI_NAME(alias) \ - virtual std::string get_name() const override { \ - return get_name_static(); \ - } \ - static std::string get_name_static() { \ - return alias; \ - } +#define TI_NAME(alias) \ + virtual std::string get_name() const override { return get_name_static(); } \ + static std::string get_name_static() { return alias; } } // namespace taichi diff --git a/taichi/common/json.cpp b/taichi/common/json.cpp index 10601696834a7..fe9413507bb34 100644 --- a/taichi/common/json.cpp +++ b/taichi/common/json.cpp @@ -29,7 +29,7 @@ // JSON serialization/deserialization. // @PENGUINLIONG #include -//#include "gft/log.hpp" +// #include "gft/log.hpp" #include "taichi/common/json.h" namespace liong { diff --git a/taichi/ir/expression.h b/taichi/ir/expression.h index 7b49a16dfa713..e0dfb1f328632 100644 --- a/taichi/ir/expression.h +++ b/taichi/ir/expression.h @@ -163,9 +163,7 @@ class ExpressionVisitor { bool invoke_default_visitor_{false}; }; -#define TI_DEFINE_ACCEPT_FOR_EXPRESSION \ - void accept(ExpressionVisitor *visitor) override { \ - visitor->visit(this); \ - } +#define TI_DEFINE_ACCEPT_FOR_EXPRESSION \ + void accept(ExpressionVisitor *visitor) override { visitor->visit(this); } } // namespace taichi::lang diff --git a/taichi/ir/expression_ops.h b/taichi/ir/expression_ops.h index 845c86cb6b0a7..242c7290316fb 100644 --- a/taichi/ir/expression_ops.h +++ b/taichi/ir/expression_ops.h @@ -12,25 +12,19 @@ Expr expr_##opname(const Expr &expr) { \ return Expr::make(UnaryOpType::opname, expr); \ } \ - Expr operator op(const Expr &expr) { \ - return expr_##opname(expr); \ - } + Expr operator op(const Expr &expr) { return expr_##opname(expr); } #define DEFINE_EXPRESSION_FUNC_UNARY(opname) \ Expr opname(const Expr &expr) { \ return Expr::make(UnaryOpType::opname, expr); \ } \ - Expr expr_##opname(const Expr &expr) { \ - return opname(expr); \ - } + Expr expr_##opname(const Expr &expr) { return opname(expr); } #define DEFINE_EXPRESSION_OP_BINARY(op, opname) \ Expr operator op(const Expr &lhs, const Expr &rhs) { \ return Expr::make(BinaryOpType::opname, lhs, rhs); \ } \ - Expr expr_##opname(const Expr &lhs, const Expr &rhs) { \ - return lhs op rhs; \ - } + Expr expr_##opname(const Expr &lhs, const Expr &rhs) { return lhs op rhs; } #define DEFINE_EXPRESSION_FUNC_BINARY(opname) \ Expr opname(const Expr &lhs, const Expr &rhs) { \ diff --git a/taichi/ir/ir.cpp b/taichi/ir/ir.cpp index cffdf09443c77..5041da1dba893 100644 --- a/taichi/ir/ir.cpp +++ b/taichi/ir/ir.cpp @@ -62,10 +62,8 @@ class StatementTypeNameVisitor : public IRVisitor { StatementTypeNameVisitor() { } -#define PER_STATEMENT(x) \ - void visit(x *stmt) override { \ - type_name = #x; \ - } +#define PER_STATEMENT(x) \ + void visit(x *stmt) override { type_name = #x; } #include "taichi/inc/statements.inc.h" #undef PER_STATEMENT diff --git a/taichi/ir/ir.h b/taichi/ir/ir.h index 12f22794e832e..c71b303f640e9 100644 --- a/taichi/ir/ir.h +++ b/taichi/ir/ir.h @@ -272,10 +272,8 @@ class IRNode { std::unique_ptr clone(); }; -#define TI_DEFINE_ACCEPT \ - void accept(IRVisitor *visitor) override { \ - visitor->visit(this); \ - } +#define TI_DEFINE_ACCEPT \ + void accept(IRVisitor *visitor) override { visitor->visit(this); } #define TI_DEFINE_CLONE \ std::unique_ptr clone() const override { \ diff --git a/taichi/math/sifakis_svd.h b/taichi/math/sifakis_svd.h index 9530311711a0d..2036dd52bb138 100644 --- a/taichi/math/sifakis_svd.h +++ b/taichi/math/sifakis_svd.h @@ -13,30 +13,30 @@ branching and elementary floating point operations A. McAdams, A. Selle, R. Tamstorf, J. Teran and E. Sifakis */ -//##################################################################### -// Copyright (c) 2010-2011, Eftychios Sifakis. +// ##################################################################### +// Copyright (c) 2010-2011, Eftychios Sifakis. // -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or -// other materials provided with the distribution. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or +// other materials provided with the distribution. // -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -//##################################################################### +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// ##################################################################### TI_FORCE_INLINE float rsqrt(const float f) { return 1.0f / std::sqrt(f); diff --git a/taichi/program/field_info.h b/taichi/program/field_info.h index e966294693b3e..db611ade40347 100644 --- a/taichi/program/field_info.h +++ b/taichi/program/field_info.h @@ -4,14 +4,10 @@ #include "taichi/rhi/device.h" #include "taichi/program/program.h" -#define DEFINE_PROPERTY(Type, name) \ - Type name; \ - void set_##name(const Type &new_name) { \ - name = new_name; \ - } \ - Type get_##name() { \ - return name; \ - } +#define DEFINE_PROPERTY(Type, name) \ + Type name; \ + void set_##name(const Type &new_name) { name = new_name; } \ + Type get_##name() { return name; } namespace taichi { diff --git a/taichi/rhi/device.h b/taichi/rhi/device.h index a2b59ba970d85..aa4d360e55f12 100644 --- a/taichi/rhi/device.h +++ b/taichi/rhi/device.h @@ -29,9 +29,7 @@ constexpr size_t kBufferSizeEntireSize = size_t(-1); inline name operator&(name a, name b) { \ return static_cast(int(a) & int(b)); \ } \ - inline bool operator&&(name a, name b) { \ - return (int(a) & int(b)) != 0; \ - } + inline bool operator&&(name a, name b) { return (int(a) & int(b)) != 0; } enum class BlendOp : uint32_t { add, subtract, reverse_subtract, min, max }; diff --git a/taichi/rhi/dx/dx_device.h b/taichi/rhi/dx/dx_device.h index 4779d3147a700..467087a06ae60 100644 --- a/taichi/rhi/dx/dx_device.h +++ b/taichi/rhi/dx/dx_device.h @@ -15,7 +15,7 @@ constexpr bool kD3d11DebugEnabled = false; // force software rendering. constexpr bool kD3d11ForceRef = false; // Enable to spawn a debug window and swapchain -//#define TAICHI_DX11_DEBUG_WINDOW +// #define TAICHI_DX11_DEBUG_WINDOW void check_dx_error(HRESULT hr, const char *msg); diff --git a/taichi/runtime/llvm/runtime_module/atomic.h b/taichi/runtime/llvm/runtime_module/atomic.h index 08b3d4d76ccf1..8dcb813288ff9 100644 --- a/taichi/runtime/llvm/runtime_module/atomic.h +++ b/taichi/runtime/llvm/runtime_module/atomic.h @@ -36,20 +36,14 @@ DEFINE_ATOMIC_OP_INTRINSIC(xor, i64) DEFINE_ATOMIC_OP_INTRINSIC(xor, u32) DEFINE_ATOMIC_OP_INTRINSIC(xor, u64) -#define DEFINE_ADD(T) \ - T add_##T(T a, T b) { \ - return a + b; \ - } +#define DEFINE_ADD(T) \ + T add_##T(T a, T b) { return a + b; } -#define DEFINE_MIN(T) \ - T min_##T(T a, T b) { \ - return b > a ? a : b; \ - } +#define DEFINE_MIN(T) \ + T min_##T(T a, T b) { return b > a ? a : b; } -#define DEFINE_MAX(T) \ - T max_##T(T a, T b) { \ - return b < a ? a : b; \ - } +#define DEFINE_MAX(T) \ + T max_##T(T a, T b) { return b < a ? a : b; } #define DEFINE_ATOMIC_OP_COMP_EXCH(OP, T) \ T atomic_##OP##_##T(volatile T *dest, T inc) { \ diff --git a/taichi/runtime/llvm/runtime_module/runtime.cpp b/taichi/runtime/llvm/runtime_module/runtime.cpp index 935675e183af2..fc27073381f07 100644 --- a/taichi/runtime/llvm/runtime_module/runtime.cpp +++ b/taichi/runtime/llvm/runtime_module/runtime.cpp @@ -55,16 +55,10 @@ __asm__(".symver expf,expf@GLIBC_2.2.5"); #endif // For accessing struct fields -#define STRUCT_FIELD(S, F) \ - extern "C" decltype(S::F) S##_get_##F(S *s) { \ - return s->F; \ - } \ - extern "C" decltype(S::F) *S##_get_ptr_##F(S *s) { \ - return &(s->F); \ - } \ - extern "C" void S##_set_##F(S *s, decltype(S::F) f) { \ - s->F = f; \ - } +#define STRUCT_FIELD(S, F) \ + extern "C" decltype(S::F) S##_get_##F(S *s) { return s->F; } \ + extern "C" decltype(S::F) *S##_get_ptr_##F(S *s) { return &(s->F); } \ + extern "C" void S##_set_##F(S *s, decltype(S::F) f) { s->F = f; } #define STRUCT_FIELD_ARRAY(S, F) \ extern "C" std::remove_all_extents_t S##_get_##F(S *s, \ @@ -163,13 +157,9 @@ std::size_t taichi_strlen(const char *str) { return len; } -#define DEFINE_UNARY_REAL_FUNC(F) \ - f32 F##_f32(f32 x) { \ - return std::F(x); \ - } \ - f64 F##_f64(f64 x) { \ - return std::F(x); \ - } +#define DEFINE_UNARY_REAL_FUNC(F) \ + f32 F##_f32(f32 x) { return std::F(x); } \ + f64 F##_f64(f64 x) { return std::F(x); } DEFINE_UNARY_REAL_FUNC(exp) DEFINE_UNARY_REAL_FUNC(log) diff --git a/taichi/ui/utils/utils.h b/taichi/ui/utils/utils.h index 4c78c9f1f308e..d3eed68379996 100644 --- a/taichi/ui/utils/utils.h +++ b/taichi/ui/utils/utils.h @@ -206,14 +206,10 @@ inline int next_power_of_2(int n) { return 1 << count; } -#define DEFINE_PROPERTY(Type, name) \ - Type name; \ - void set_##name(const Type &new_name) { \ - name = new_name; \ - } \ - Type get_##name() { \ - return name; \ - } +#define DEFINE_PROPERTY(Type, name) \ + Type name; \ + void set_##name(const Type &new_name) { name = new_name; } \ + Type get_##name() { return name; } inline std::vector read_file(const std::string &filename) { std::ifstream file(filename, std::ios::ate | std::ios::binary); diff --git a/taichi/util/bit.h b/taichi/util/bit.h index 77b8a548e2ae3..6d98026136f52 100644 --- a/taichi/util/bit.h +++ b/taichi/util/bit.h @@ -78,13 +78,9 @@ constexpr int bit_length() { return std::is_same() ? 1 : sizeof(T) * 8; } -#define TI_BIT_FIELD(T, name, start) \ - T get_##name() const { \ - return (T)Base::get()>(); \ - } \ - void set_##name(const T &val) { \ - Base::set()>(val); \ - } +#define TI_BIT_FIELD(T, name, start) \ + T get_##name() const { return (T)Base::get()>(); } \ + void set_##name(const T &val) { Base::set()>(val); } template TI_FORCE_INLINE constexpr T product(const std::array arr) { From c012eb3e8e26517d087a25cbfe7b38c37d750faf Mon Sep 17 00:00:00 2001 From: Proton Date: Tue, 3 Jan 2023 21:18:58 +0800 Subject: [PATCH 5/7] [aot] Revert "C-API opengl runtime interop (#7014)" (#7032) This reverts commit a1485cd8fef92972a91c450b9f703f741c989c9b. Issue: # ### Brief Summary --- c_api/include/taichi/taichi_opengl.h | 15 ----------- c_api/src/taichi_opengl_impl.cpp | 9 ------- c_api/src/taichi_vulkan_impl.cpp | 2 -- c_api/taichi.json | 38 ---------------------------- taichi/rhi/opengl/opengl_api.cpp | 6 +---- taichi/rhi/opengl/opengl_device.cpp | 5 +--- taichi/rhi/opengl/opengl_device.h | 1 - 7 files changed, 2 insertions(+), 74 deletions(-) diff --git a/c_api/include/taichi/taichi_opengl.h b/c_api/include/taichi/taichi_opengl.h index 925e1f8a75c9f..0522de61ce047 100644 --- a/c_api/include/taichi/taichi_opengl.h +++ b/c_api/include/taichi/taichi_opengl.h @@ -6,21 +6,6 @@ extern "C" { #endif // __cplusplus -// Structure `TiOpenglRuntimeInteropInfo` -typedef struct TiOpenglRuntimeInteropInfo { - void *get_proc_addr; -} TiOpenglRuntimeInteropInfo; - -// Function `ti_import_opengl_runtime` -TI_DLL_EXPORT void TI_API_CALL -ti_import_opengl_runtime(TiRuntime runtime, - TiOpenglRuntimeInteropInfo *interop_info); - -// Function `ti_export_opengl_runtime` -TI_DLL_EXPORT void TI_API_CALL -ti_export_opengl_runtime(TiRuntime runtime, - TiOpenglRuntimeInteropInfo *interop_info); - // Structure `TiOpenglMemoryInteropInfo` typedef struct TiOpenglMemoryInteropInfo { GLuint buffer; diff --git a/c_api/src/taichi_opengl_impl.cpp b/c_api/src/taichi_opengl_impl.cpp index ff9d7f290c350..dc52e5ab2ac27 100644 --- a/c_api/src/taichi_opengl_impl.cpp +++ b/c_api/src/taichi_opengl_impl.cpp @@ -3,7 +3,6 @@ OpenglRuntime::OpenglRuntime() : GfxRuntime(taichi::Arch::opengl), - device_(), gfx_runtime_(taichi::lang::gfx::GfxRuntime::Params{ host_result_buffer_.data(), &device_}) { taichi::lang::DeviceCapabilityConfig caps{}; @@ -19,14 +18,6 @@ taichi::lang::gfx::GfxRuntime &OpenglRuntime::get_gfx_runtime() { return gfx_runtime_; } -void ti_export_opengl_runtime(TiRuntime runtime, - TiOpenglRuntimeInteropInfo *interop_info) { - TI_CAPI_TRY_CATCH_BEGIN(); - // FIXME: (penguinliogn) - interop_info->get_proc_addr = taichi::lang::opengl::kGetOpenglProcAddr; - TI_CAPI_TRY_CATCH_END(); -} - void ti_export_opengl_memory(TiRuntime runtime, TiMemory memory, TiOpenglMemoryInteropInfo *interop_info) { diff --git a/c_api/src/taichi_vulkan_impl.cpp b/c_api/src/taichi_vulkan_impl.cpp index 51c583b579380..426d0ab35145a 100644 --- a/c_api/src/taichi_vulkan_impl.cpp +++ b/c_api/src/taichi_vulkan_impl.cpp @@ -26,8 +26,6 @@ VulkanRuntimeImported::Workaround::Workaround( taichi::lang::vulkan::VulkanLoader::instance().load_instance(params.instance); taichi::lang::vulkan::VulkanLoader::instance().load_device(params.device); vk_device.vk_caps().vk_api_version = api_version; - // FIXME: (penguinliong) Workaround missing vulkan caps from import. - vk_device.vk_caps().external_memory = true; taichi::lang::DeviceCapabilityConfig caps{}; diff --git a/c_api/taichi.json b/c_api/taichi.json index 4a7edf819820d..94d7ea041afa2 100644 --- a/c_api/taichi.json +++ b/c_api/taichi.json @@ -1248,44 +1248,6 @@ "taichi/taichi_core.h" ], "declarations": [ - { - "name": "opengl_runtime_interop_info", - "type": "structure", - "fields": [ - { - "name": "get_proc_addr", - "type": "void*" - } - ] - }, - { - "name": "import_opengl_runtime", - "type": "function", - "parameters": [ - { - "type": "handle.runtime" - }, - { - "name": "interop_info", - "type": "structure.opengl_runtime_interop_info", - "by_mut": true - } - ] - }, - { - "name": "export_opengl_runtime", - "type": "function", - "parameters": [ - { - "type": "handle.runtime" - }, - { - "name": "interop_info", - "type": "structure.opengl_runtime_interop_info", - "by_mut": true - } - ] - }, { "name": "opengl_memory_interop_info", "type": "structure", diff --git a/taichi/rhi/opengl/opengl_api.cpp b/taichi/rhi/opengl/opengl_api.cpp index b784351024f7e..a374e9c9e415a 100644 --- a/taichi/rhi/opengl/opengl_api.cpp +++ b/taichi/rhi/opengl/opengl_api.cpp @@ -24,7 +24,6 @@ int opengl_max_grid_dim = 1024; // without this global static boolean. static bool kUseGles = false; static std::optional supported; // std::nullopt -void *kGetOpenglProcAddr; static void glfw_error_callback(int code, const char *description) { TI_WARN("GLFW Error {}: {}", code, description); @@ -45,7 +44,6 @@ bool initialize_opengl(bool use_gles, bool error_tolerance) { // Code below is guaranteed to be called at most once. int opengl_version = 0; - void *get_proc_addr = nullptr; if (glfwInit()) { glfwSetErrorCallback(glfw_error_callback); @@ -55,6 +53,7 @@ bool initialize_opengl(bool use_gles, bool error_tolerance) { glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); } else { + glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); @@ -74,7 +73,6 @@ bool initialize_opengl(bool use_gles, bool error_tolerance) { TI_DEBUG("[glsl] cannot create GLFW window: error {}: {}", status, desc); } else { glfwMakeContextCurrent(window); - get_proc_addr = (void *)&glfwGetProcAddress; if (use_gles) { opengl_version = gladLoadGLES2(glfwGetProcAddress); } else { @@ -150,7 +148,6 @@ bool initialize_opengl(bool use_gles, bool error_tolerance) { eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, egl_context); - get_proc_addr = (void *)&glad_eglGetProcAddress; if (use_gles) { opengl_version = gladLoadGLES2(glad_eglGetProcAddress); } else { @@ -197,7 +194,6 @@ bool initialize_opengl(bool use_gles, bool error_tolerance) { supported = std::make_optional(true); kUseGles = use_gles; - kGetOpenglProcAddr = get_proc_addr; return true; } diff --git a/taichi/rhi/opengl/opengl_device.cpp b/taichi/rhi/opengl/opengl_device.cpp index be6e587f30a13..759edb1637f43 100644 --- a/taichi/rhi/opengl/opengl_device.cpp +++ b/taichi/rhi/opengl/opengl_device.cpp @@ -489,7 +489,6 @@ void GLStream::command_sync() { } GLDevice::GLDevice() : stream_(this) { - initialize_opengl(false, true); DeviceCapabilityConfig caps{}; if (!is_gles()) { // 64bit isn't supported in ES profile @@ -556,9 +555,9 @@ GLint GLDevice::get_devalloc_size(DeviceAllocation handle) { GLint size = 0; glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &size); check_opengl_error("glGetBufferParameteriv"); + return size; glBindBuffer(GL_ARRAY_BUFFER, 0); check_opengl_error("glBindBuffer"); - return size; } std::unique_ptr GLDevice::create_pipeline( @@ -872,9 +871,7 @@ void GLCommandList::CmdImageToBuffer::execute() { (void *)offset); check_opengl_error("glGetTexImage"); glBindTexture(image_dims, /*target=*/0); - check_opengl_error("glBindTexture"); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, /*target=*/0); - check_opengl_error("glBindBuffer"); } } // namespace opengl diff --git a/taichi/rhi/opengl/opengl_device.h b/taichi/rhi/opengl/opengl_device.h index 1ea7a427123c6..7645aaf1c002f 100644 --- a/taichi/rhi/opengl/opengl_device.h +++ b/taichi/rhi/opengl/opengl_device.h @@ -11,7 +11,6 @@ namespace opengl { class GLDevice; void check_opengl_error(const std::string &msg = "OpenGL"); -extern void *kGetOpenglProcAddr; class GLResourceSet : public ShaderResourceSet { public: From ec79dc1b9aebfed3fae40dd93c6102b8342bd449 Mon Sep 17 00:00:00 2001 From: Dunfan Lu Date: Wed, 4 Jan 2023 03:35:52 +0000 Subject: [PATCH 6/7] [GUI] Support colored texts (#7036) Issue: #3013 ### Brief Summary Implementing colored texts: ```py window = ti.ui.Window('Window', (768, 768), vsync=True) canvas = window.get_canvas() gui = window.get_gui() while window.running: with gui.sub_window("Yo", 0.05, 0.05, 0.9, 0.2) as w: w.text("haha", (1.0,0.2,0.3)) window.show() ``` Screenshot 2023-01-03 at 20 07 11 Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- python/taichi/ui/imgui.py | 7 +++++-- taichi/python/export_ggui.cpp | 4 ++++ taichi/ui/backends/vulkan/gui.cpp | 28 +++++++++++++++++++++------- taichi/ui/backends/vulkan/gui.h | 15 ++++++++------- taichi/ui/common/gui_base.h | 16 +++++++++------- 5 files changed, 47 insertions(+), 23 deletions(-) diff --git a/python/taichi/ui/imgui.py b/python/taichi/ui/imgui.py index 0c67cf0d067c1..4200e974a397c 100644 --- a/python/taichi/ui/imgui.py +++ b/python/taichi/ui/imgui.py @@ -58,10 +58,13 @@ def end(self): """ self.gui.end() - def text(self, text): + def text(self, text, color=None): """Declares a line of text. """ - self.gui.text(text) + if color is None: + self.gui.text(text) + else: + self.gui.text_colored(text, color) def checkbox(self, text, old_value): """Declares a checkbox, and returns whether or not it has been checked. diff --git a/taichi/python/export_ggui.cpp b/taichi/python/export_ggui.cpp index 31ce2b284ade3..ba3750ec655f6 100644 --- a/taichi/python/export_ggui.cpp +++ b/taichi/python/export_ggui.cpp @@ -63,6 +63,9 @@ struct PyGui { void text(std::string text) { gui->text(text); } + void text_colored(std::string text, py::tuple color) { + gui->text(text, tuple_to_vec3(color)); + } bool checkbox(std::string name, bool old_value) { return gui->checkbox(name, old_value); } @@ -521,6 +524,7 @@ void export_ggui(py::module &m) { .def("begin", &PyGui::begin) .def("end", &PyGui::end) .def("text", &PyGui::text) + .def("text_colored", &PyGui::text_colored) .def("checkbox", &PyGui::checkbox) .def("slider_int", &PyGui::slider_int) .def("slider_float", &PyGui::slider_float) diff --git a/taichi/ui/backends/vulkan/gui.cpp b/taichi/ui/backends/vulkan/gui.cpp index 9187f93787d85..b71bc690c7892 100644 --- a/taichi/ui/backends/vulkan/gui.cpp +++ b/taichi/ui/backends/vulkan/gui.cpp @@ -131,7 +131,11 @@ float Gui::abs_y(float y) { return y * app_context_->config.height; } -void Gui::begin(std::string name, float x, float y, float width, float height) { +void Gui::begin(const std::string &name, + float x, + float y, + float width, + float height) { if (!initialized()) { return; } @@ -146,27 +150,37 @@ void Gui::end() { } ImGui::End(); } -void Gui::text(std::string text) { +void Gui::text(const std::string &text) { if (!initialized()) { return; } ImGui::Text("%s", text.c_str()); } -bool Gui::checkbox(std::string name, bool old_value) { +void Gui::text(const std::string &text, glm::vec3 color) { + if (!initialized()) { + return; + } + ImGui::TextColored(ImVec4(color[0], color[1], color[2], 1.0f), "%s", + text.c_str()); +} +bool Gui::checkbox(const std::string &name, bool old_value) { if (!initialized()) { return old_value; } ImGui::Checkbox(name.c_str(), &old_value); return old_value; } -int Gui::slider_int(std::string name, int old_value, int minimum, int maximum) { +int Gui::slider_int(const std::string &name, + int old_value, + int minimum, + int maximum) { if (!initialized()) { return old_value; } ImGui::SliderInt(name.c_str(), &old_value, minimum, maximum); return old_value; } -float Gui::slider_float(std::string name, +float Gui::slider_float(const std::string &name, float old_value, float minimum, float maximum) { @@ -176,14 +190,14 @@ float Gui::slider_float(std::string name, ImGui::SliderFloat(name.c_str(), &old_value, minimum, maximum); return old_value; } -glm::vec3 Gui::color_edit_3(std::string name, glm::vec3 old_value) { +glm::vec3 Gui::color_edit_3(const std::string &name, glm::vec3 old_value) { if (!initialized()) { return old_value; } ImGui::ColorEdit3(name.c_str(), (float *)&old_value); return old_value; } -bool Gui::button(std::string text) { +bool Gui::button(const std::string &text) { if (!initialized()) { return false; } diff --git a/taichi/ui/backends/vulkan/gui.h b/taichi/ui/backends/vulkan/gui.h index 68ebb79ba0912..b9782cdb4fde7 100644 --- a/taichi/ui/backends/vulkan/gui.h +++ b/taichi/ui/backends/vulkan/gui.h @@ -30,25 +30,26 @@ class TI_DLL_EXPORT Gui final : public GuiBase { void init_render_resources(VkRenderPass render_pass); void cleanup_render_resources(); - void begin(std::string name, + void begin(const std::string &name, float x, float y, float width, float height) override; void end() override; - void text(std::string text) override; - bool checkbox(std::string name, bool old_value) override; - int slider_int(std::string name, + void text(const std::string &text) override; + void text(const std::string &text, glm::vec3 color) override; + bool checkbox(const std::string &name, bool old_value) override; + int slider_int(const std::string &name, int old_value, int minimum, int maximum) override; - float slider_float(std::string name, + float slider_float(const std::string &name, float old_value, float minimum, float maximum) override; // TODO: consider renaming this? - glm::vec3 color_edit_3(std::string name, glm::vec3 old_value) override; - bool button(std::string text) override; + glm::vec3 color_edit_3(const std::string &name, glm::vec3 old_value) override; + bool button(const std::string &text) override; void draw(taichi::lang::CommandList *cmd_list); diff --git a/taichi/ui/common/gui_base.h b/taichi/ui/common/gui_base.h index 127621789c366..7ba94cd5ad4d8 100644 --- a/taichi/ui/common/gui_base.h +++ b/taichi/ui/common/gui_base.h @@ -6,24 +6,26 @@ namespace taichi::ui { class GuiBase { public: - virtual void begin(std::string name, + virtual void begin(const std::string &name, float x, float y, float width, float height) = 0; virtual void end() = 0; - virtual void text(std::string text) = 0; - virtual bool checkbox(std::string name, bool old_value) = 0; - virtual int slider_int(std::string name, + virtual void text(const std::string &text) = 0; + virtual void text(const std::string &text, glm::vec3 color) = 0; + virtual bool checkbox(const std::string &name, bool old_value) = 0; + virtual int slider_int(const std::string &name, int old_value, int minimum, int maximum) = 0; - virtual float slider_float(std::string name, + virtual float slider_float(const std::string &name, float old_value, float minimum, float maximum) = 0; - virtual glm::vec3 color_edit_3(std::string name, glm::vec3 old_value) = 0; - virtual bool button(std::string text) = 0; + virtual glm::vec3 color_edit_3(const std::string &name, + glm::vec3 old_value) = 0; + virtual bool button(const std::string &text) = 0; virtual ~GuiBase() = default; }; From 481ded6925f4bf926c2d65adb0e27880bf517d9d Mon Sep 17 00:00:00 2001 From: Zhanlue Yang Date: Wed, 4 Jan 2023 12:08:26 +0800 Subject: [PATCH 7/7] [Build] Deprecate export_core (#7028) Issue: # ### Brief Summary --- .github/workflows/scripts/android-build.sh | 1 - CMakeLists.txt | 10 -- cmake/TaichiCore.cmake | 3 - cmake/TaichiExportCore.cmake | 101 --------------------- cmake/taichi_export_coreConfig.cmake.in | 5 - 5 files changed, 120 deletions(-) delete mode 100644 cmake/TaichiExportCore.cmake delete mode 100644 cmake/taichi_export_coreConfig.cmake.in diff --git a/.github/workflows/scripts/android-build.sh b/.github/workflows/scripts/android-build.sh index 339d01e2311cb..19a4f0fcaa8d2 100755 --- a/.github/workflows/scripts/android-build.sh +++ b/.github/workflows/scripts/android-build.sh @@ -18,7 +18,6 @@ python -m pip install -r requirements_dev.txt python setup.py clean python setup.py build_ext cd build -aarch64-linux-android-strip libtaichi_export_core.so aarch64-linux-android-strip libtaichi_c_api.so chmod -R 777 "$SCCACHE_DIR" diff --git a/CMakeLists.txt b/CMakeLists.txt index 822c604f4baa3..cc775f32cff58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,16 +196,6 @@ endif() configure_file(taichi/common/version.h.in ${CMAKE_SOURCE_DIR}/taichi/common/version.h) configure_file(taichi/common/commit_hash.h.in ${CMAKE_SOURCE_DIR}/taichi/common/commit_hash.h) -option(TI_EXPORT_CORE "export taichi core" OFF) - -if(ANDROID) - set(TI_EXPORT_CORE ON) -endif() - -if (TI_EXPORT_CORE) - include(cmake/TaichiExportCore.cmake) -endif() - option(TI_WITH_C_API "build taichi runtime c-api library" OFF) if (TI_WITH_C_API) diff --git a/cmake/TaichiCore.cmake b/cmake/TaichiCore.cmake index 5b715d4bd3def..e09dc68f9aa90 100644 --- a/cmake/TaichiCore.cmake +++ b/cmake/TaichiCore.cmake @@ -25,7 +25,6 @@ set(INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/python/taichi/_lib) if(ANDROID) set(TI_WITH_VULKAN ON) - set(TI_EXPORT_CORE ON) set(TI_WITH_LLVM OFF) set(TI_WITH_METAL OFF) set(TI_WITH_CUDA OFF) @@ -435,8 +434,6 @@ target_link_libraries(taichi_ui PUBLIC ${CORE_LIBRARY_NAME}) if(TI_WITH_PYTHON) message("PYTHON_LIBRARIES: " ${PYTHON_LIBRARIES}) set(CORE_WITH_PYBIND_LIBRARY_NAME taichi_python) - # Cannot compile Python source code with Android, but TI_EXPORT_CORE should be set and - # Android should only use the isolated library ignoring those source code. if (NOT ANDROID) # NO_EXTRAS is required here to avoid llvm symbol error during build file(GLOB TAICHI_PYBIND_SOURCE diff --git a/cmake/TaichiExportCore.cmake b/cmake/TaichiExportCore.cmake deleted file mode 100644 index 5696b49e55324..0000000000000 --- a/cmake/TaichiExportCore.cmake +++ /dev/null @@ -1,101 +0,0 @@ -cmake_minimum_required(VERSION 3.0) - -set(TAICHI_EXPORT_CORE_NAME taichi_export_core) - -message(WARNING "You are trying to build the taichi_export_core target, support for this target will be deprecated in the future, please considering using the taichi_c_api target.") - -add_library(${TAICHI_EXPORT_CORE_NAME} SHARED) -target_link_libraries(${TAICHI_EXPORT_CORE_NAME} PRIVATE taichi_core) -set_target_properties(${TAICHI_EXPORT_CORE_NAME} PROPERTIES - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build" - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build") - -# [TODO] Remove the following two linkages after rewriting AOT Demos with Device APIS -if(TI_WITH_GGUI) - target_link_libraries(${TAICHI_EXPORT_CORE_NAME} PRIVATE taichi_ui_vulkan) - target_link_libraries(${TAICHI_EXPORT_CORE_NAME} PRIVATE taichi_ui) -endif() - -target_include_directories(${TAICHI_EXPORT_CORE_NAME} - PUBLIC - # Used when building the library: - $ - $ - # Used when installing the library: - $ - PRIVATE - # Used only when building the library: - ${PROJECT_SOURCE_DIR}) - -# This helper provides us standard locations across Linux/Windows/MacOS -include(GNUInstallDirs) - -install(TARGETS ${TAICHI_EXPORT_CORE_NAME} EXPORT ${TAICHI_EXPORT_CORE_NAME}Targets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin - INCLUDES DESTINATION include - ) - -# Install the export set, which contains the meta data of the target -install(EXPORT ${TAICHI_EXPORT_CORE_NAME}Targets - FILE ${TAICHI_EXPORT_CORE_NAME}Targets.cmake - NAMESPACE ${TAICHI_EXPORT_CORE_NAME}:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${TAICHI_EXPORT_CORE_NAME} - ) - -include(CMakePackageConfigHelpers) - -# Generate the config file -configure_package_config_file( - "${PROJECT_SOURCE_DIR}/cmake/${TAICHI_EXPORT_CORE_NAME}Config.cmake.in" - "${PROJECT_BINARY_DIR}/${TAICHI_EXPORT_CORE_NAME}Config.cmake" - INSTALL_DESTINATION - ${CMAKE_INSTALL_LIBDIR}/cmake/${TAICHI_EXPORT_CORE_NAME} - ) - -# Generate the config version file -set(${TAICHI_EXPORT_CORE_NAME}_VERSION "${TI_VERSION_MAJOR}.${TI_VERSION_MINOR}.${TI_VERSION_PATCH}") -write_basic_package_version_file( - "${TAICHI_EXPORT_CORE_NAME}ConfigVersion.cmake" - VERSION ${${TAICHI_EXPORT_CORE_NAME}_VERSION} - COMPATIBILITY SameMajorVersion - ) - -# Install the config files -install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/${TAICHI_EXPORT_CORE_NAME}Config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/${TAICHI_EXPORT_CORE_NAME}ConfigVersion.cmake" - DESTINATION - ${CMAKE_INSTALL_LIBDIR}/cmake/${TAICHI_EXPORT_CORE_NAME} - ) - -# Install public headers for this target -# TODO: Replace files here with public headers when ready. -install(DIRECTORY - ${PROJECT_SOURCE_DIR}/taichi - ${PROJECT_SOURCE_DIR}/external/spdlog/include/spdlog - ${PROJECT_SOURCE_DIR}/external/Vulkan-Headers/include/vulkan - ${PROJECT_SOURCE_DIR}/external/Vulkan-Headers/include/vulkan - ${PROJECT_SOURCE_DIR}/external/glm/glm - ${PROJECT_SOURCE_DIR}/external/eigen - DESTINATION include - FILES_MATCHING - PATTERN *.h - PATTERN *.hpp - PATTERN *.inl - ) -install(DIRECTORY - ${PROJECT_SOURCE_DIR}/external/eigen/Eigen - DESTINATION include - ) -file(GLOB TAICHI_PUBLIC_HEADERS_TEMP - "external/volk/*.h" "external/volk/*.hpp" - "external/imgui/*.h" "external/imgui/*.hpp" - "external/imgui/backends/*.h" "external/imgui/backends/*.hpp" - "external/VulkanMemoryAllocator/include/*.h" - ) -install(FILES - ${TAICHI_PUBLIC_HEADERS_TEMP} - DESTINATION include - ) diff --git a/cmake/taichi_export_coreConfig.cmake.in b/cmake/taichi_export_coreConfig.cmake.in deleted file mode 100644 index d90c1a26e35cc..0000000000000 --- a/cmake/taichi_export_coreConfig.cmake.in +++ /dev/null @@ -1,5 +0,0 @@ -@PACKAGE_INIT@ - -include("${CMAKE_CURRENT_LIST_DIR}/taichi_export_coreTargets.cmake") - -check_required_components("@PROJECT_NAME@")