From 894727d7a448a8a39331e2d6038bd824820e37f3 Mon Sep 17 00:00:00 2001 From: yixu Date: Fri, 6 May 2022 10:55:06 +0800 Subject: [PATCH 1/4] remove debug print (#4883) --- python/taichi/lang/mesh.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/taichi/lang/mesh.py b/python/taichi/lang/mesh.py index 08a72305c0c6a4..36e182cbdff279 100644 --- a/python/taichi/lang/mesh.py +++ b/python/taichi/lang/mesh.py @@ -351,7 +351,6 @@ def update_relation(self, from_order, to_order): rel_type = MeshRelationType(relation_by_orders(from_order, to_order)) if rel_type not in self.relation_set: meta = self.patcher.get_relation_meta(from_order, to_order) - print('new relation') def fun(arr, dtype): field = impl.field(dtype=dtype, shape=arr.shape) From 64e0ba81fad09a5d95824d3a1ec4544dd3ed6064 Mon Sep 17 00:00:00 2001 From: Vissidarte-Herman <93570324+Vissidarte-Herman@users.noreply.github.com> Date: Fri, 6 May 2022 11:19:16 +0800 Subject: [PATCH 2/4] [Doc] Updated broken links (#4912) * [Doc] Updated broken links * Updated links that may break. * Added .md --- docs/lang/articles/advanced/odop.md | 2 +- docs/lang/articles/advanced/sparse.md | 6 +++--- .../differences_between_taichi_and_python_programs.md | 6 +++--- docs/lang/articles/basic/field.md | 2 +- docs/lang/articles/basic/overview.md | 2 +- docs/lang/articles/reference.md | 10 +++++----- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/lang/articles/advanced/odop.md b/docs/lang/articles/advanced/odop.md index 7d008adf104c3a..0384482c8fb011 100644 --- a/docs/lang/articles/advanced/odop.md +++ b/docs/lang/articles/advanced/odop.md @@ -41,7 +41,7 @@ a = TiArray(32) a.inc() ``` -Programmers used to define Taichi fields in `__init__` functions of `@ti.data_oriented` classes. With the new **Dynamic SNode** feature (released in `v0.8.0`, see [Field (advanced)](/lang/articles/advanced/layout.md#dynamic-field-allocation-and-destruction) for more details), you can define Taichi fields **at any places** of Python-scope functions. For example, +Programmers used to define Taichi fields in `__init__` functions of `@ti.data_oriented` classes. With the new **Dynamic SNode** feature (released in `v0.8.0`, see [Field (advanced)](layout.md#dynamic-field-allocation-and-destruction) for more details), you can define Taichi fields **at any places** of Python-scope functions. For example, ```python {21,25} import taichi as ti diff --git a/docs/lang/articles/advanced/sparse.md b/docs/lang/articles/advanced/sparse.md index ff7557f3dadabf..2a9b4389e5c972 100644 --- a/docs/lang/articles/advanced/sparse.md +++ b/docs/lang/articles/advanced/sparse.md @@ -5,7 +5,7 @@ sidebar_position: 3 # Sparse spatial data structures :::note -Prerequisite: please read the [Fields](lang/articles/basic/field.md), [Fields (advanced)](lang/articles/advanced/layout.md), and [SNodes](lang/articles/misc/internal.md#data-structure-organization) first. +Prerequisite: please read the [Fields](../basic/field.md), [Fields (advanced)](layout.md), and [SNodes](../misc/internal.md#data-structure-organization) first. ::: ![image](https://raw.githubusercontent.com/taichi-dev/public_files/master/taichi/doc/sparse_grids_3d.jpg) @@ -14,7 +14,7 @@ Figure: A 3D fluid simulation that uses both particles and grids. Left to right: ## Motivation High-resolution 2D/3D grids are often needed in large-scale spatial computation, such as physical simulation, rendering, and 3D reconstruction. -However, these grids tend to consume a huge amount of memory space and computation if we use dense data structures (see [field](lang/articles/basic/field.md) and [field advanced](lang/articles/advanced/layout.md)). +However, these grids tend to consume a huge amount of memory space and computation if we use dense data structures (see [field](../basic/field.md) and [field advanced](layout.md)). While a programmer may allocate large dense grids to store spatial data (especially physical quantities such as a density or velocity field), oftentimes, they only care about a small fraction of this dense grid since the rest may be empty space (vacuum or air). @@ -48,7 +48,7 @@ In Taichi, programmers can compose data structures similar to VDB and SPGrid wit :::note -Sparse matrices are usually **not** implemented in Taichi via sparse spatial data structures. See [sparse matrix](lang/articles/advanced/sparse_matrix.md) instead. +Sparse matrices are usually **not** implemented in Taichi via sparse spatial data structures. See [sparse matrix](sparse_matrix.md) instead. ::: ## Sparse spatial data structures in Taichi diff --git a/docs/lang/articles/basic/differences_between_taichi_and_python_programs.md b/docs/lang/articles/basic/differences_between_taichi_and_python_programs.md index c2c6b7dbd7bc35..0404eb8f33f5c1 100644 --- a/docs/lang/articles/basic/differences_between_taichi_and_python_programs.md +++ b/docs/lang/articles/basic/differences_between_taichi_and_python_programs.md @@ -53,7 +53,7 @@ def discarded_after_first_return(a: ti.i32) -> ti.i32: discarded_after_first_return(0) # OK: returns 1 ``` -- If there are [compile-time evaluations](/lang/articles/advanced/meta.md#compile-time-evaluations) in the code, make sure there is a return statement under all circumstances. +- If there are [compile-time evaluations](../advanced/meta.md#compile-time-evaluations) in the code, make sure there is a return statement under all circumstances. Otherwise, error occurs when a branch is chosen which does not have return statement. ```python {7-8,15-16,21,23-24} @ti.kernel @@ -123,7 +123,7 @@ Currently, Taichi does not support `set`. List and dictionary before assigning to a variable works as the python list and dictionary. However, after assigning to a variable, the content of the list and the values (not keys) of the dictionary are converted to Taichi variables. -Taichi does not have a runtime implementation of `in` currently. Therefore, operator `in` and `not in` only works in [static scope](/lang/articles/advanced/meta.md#static-scope) (inside `ti.static()`). +Taichi does not have a runtime implementation of `in` currently. Therefore, operator `in` and `not in` only works in [static scope](../advanced/meta.md#static-scope) (inside `ti.static()`). ```python {3,11-12,20} @ti.kernel @@ -155,7 +155,7 @@ Taichi partially supports list comprehension and dictionary comprehension, but does not support set comprehension. For list comprehensions and dictionary comprehensions, the `if`s and `for`s in them are evaluated at compile time. -The iterators and conditions are implicitly in [static scope](/lang/articles/advanced/meta.md#static-scope). +The iterators and conditions are implicitly in [static scope](../advanced/meta.md#static-scope). ### Operator `is` diff --git a/docs/lang/articles/basic/field.md b/docs/lang/articles/basic/field.md index 60e83fde7c44f5..8fdd4fd6a94b74 100644 --- a/docs/lang/articles/basic/field.md +++ b/docs/lang/articles/basic/field.md @@ -74,7 +74,7 @@ while gui.running: ``` :::tip -With Taichi versions earlier than v0.8.0, you cannot allocate new fields after executing a kernel. Starting from v0.8.0, you can use the `FieldsBuilder` class to dynamically allocate or destruct fields. See the [Field (advanced)](/lang/articles/advanced/layout.md) for more information. +With Taichi versions earlier than v0.8.0, you cannot allocate new fields after executing a kernel. Starting from v0.8.0, you can use the `FieldsBuilder` class to dynamically allocate or destruct fields. See the [Field (advanced)](./advanced/layout.md) for more information. ::: :::caution WARNING diff --git a/docs/lang/articles/basic/overview.md b/docs/lang/articles/basic/overview.md index 6944c360a3f903..2eeda69a778f62 100644 --- a/docs/lang/articles/basic/overview.md +++ b/docs/lang/articles/basic/overview.md @@ -17,7 +17,7 @@ To be fair, a domain-specific language (DSL) with a Python frontend is not somet * Taichi heavily optimizes the source code using various compiler technologies: common subexpression elimination, dead code elimination, control flow graph analysis, etc. These optimizations are backend neutral, because Taichi hosts its own intermediate representation (IR) layer. * JIT compilation provides additional optimization opportunities. -That said, Taichi goes beyond a Python JIT transpiler. One of the initial design goals is to *decouple the computation from the data structures*. The mechanism that Taichi provides is a set of generic data containers, called *SNode* (/ˈsnoʊd/). SNodes can be used to compose hierarchical, dense or sparse, multi-dimensional fields conveniently. Switching between array-of-structures and structure-of-arrays layouts is usually a matter of ≤10 lines of code. This has sparked many use cases in numerical simulation. If you are interested to learn them, please check out [Fields (advanced)](https://docs.taichi-lang.org/lang/articles/layout), [Sparse spatial data structures](https://docs.taichi-lang.org/lang/articles/sparse), or [the original Taichi paper](https://yuanming.taichi.graphics/publication/2019-taichi/taichi-lang.pdf). +That said, Taichi goes beyond a Python JIT transpiler. One of the initial design goals is to *decouple the computation from the data structures*. The mechanism that Taichi provides is a set of generic data containers, called *SNode* (/ˈsnoʊd/). SNodes can be used to compose hierarchical, dense or sparse, multi-dimensional fields conveniently. Switching between array-of-structures and structure-of-arrays layouts is usually a matter of ≤10 lines of code. This has sparked many use cases in numerical simulation. If you are interested to learn them, please check out [Fields (advanced)](../advanced/layout.md), [Sparse spatial data structures](../advanced/sparse.md), or [the original Taichi paper](https://yuanming.taichi.graphics/publication/2019-taichi/taichi-lang.pdf). The concept of decoupling is further extended to the type system. With GPU memory capacity and bandwidth becoming the major bottlenecks nowadays, it is vital to be able to pack more data per memory unit. Since 2021, Taichi has introduced customizable quantized types, allowing for the definition of fixed point or floating point numbers with arbitrary bits (still needs to be under 64). This has allowed an MPM simulation of over 400 million particles on a single GPU device. Learn more details in [the QuanTaichi paper](https://yuanming.taichi.graphics/publication/2021-quantaichi/quantaichi.pdf). diff --git a/docs/lang/articles/reference.md b/docs/lang/articles/reference.md index 41026974fc8c69..3af07ef06a1c3e 100644 --- a/docs/lang/articles/reference.md +++ b/docs/lang/articles/reference.md @@ -235,8 +235,8 @@ attributeref ::= primary "." identifier Attribute references are evaluated at compile time. The `primary` must be evaluated to a Python value with an attribute named `identifier`. Common use cases in Taichi include metadata queries of -[field](https://docs.taichi-lang.org/lang/articles/meta#field-metadata) and -[matrices](https://docs.taichi-lang.org/lang/articles/meta#matrix--vector-metadata). +[field](advanced/meta.md#field-metadata) and +[matrices](advanced/meta.md#matrix--vector-metadata). #### Subscriptions @@ -440,9 +440,9 @@ The `positional_arguments` is evaluated at compile time, and the items inside mu - When multiple arguments are passed in, it returns a tuple containing all the arguments in the same order as they are passed. The static expressions work as a mechanism to trigger many metaprogramming functions in Taichi, -such as [compile-time loop unrolling and compile-time branching](lang/articles/advanced/meta.md#compile-time-evaluations). +such as [compile-time loop unrolling and compile-time branching](advanced/meta.md#compile-time-evaluations). -The static expressions can also be used to [create aliases for Taichi fields and Taichi functions](lang/articles/advanced/syntax_sugars.md#aliases). +The static expressions can also be used to [create aliases for Taichi fields and Taichi functions](advanced/syntax_sugars.md#aliases). ### Expression lists @@ -728,7 +728,7 @@ The `iter_expression` of ndrange `for` statement must be a call to `ti.ndrange() - If the `iter_expression` is a call to `ti.range()`, it is a normal ndrange `for`. - If the `iter_expression` is a call to `ti.grouped(ti.range())`, it is a grouped ndrange `for`. -You can use grouped `for` loops to write [dimensionality-independent programs](lang/articles/advanced/meta.md#dimensionality-independent-programming-using-grouped-indices). +You can use grouped `for` loops to write [dimensionality-independent programs](advanced/meta.md#dimensionality-independent-programming-using-grouped-indices). `ti.ndrange` receives arbitrary numbers of arguments. The k-th argument represents the iteration range of the k-th dimension, From 92bb3593f6ef1575c41c39a18341072bfb044f70 Mon Sep 17 00:00:00 2001 From: Bo Qiao Date: Fri, 6 May 2022 12:02:55 +0800 Subject: [PATCH 3/4] [test] Exit on error during Paddle windows test (#4910) * [test] Exit on error during Paddle windows test * Check if paddle test leaks memory * Increase device memory and reduce thread number * Revert "Check if paddle test leaks memory" This reverts commit e0522b0e520050fb50d2c338a2a7d0b2a363bfb0. * Disable paddle for non-paddle test --- .github/workflows/scripts/win_test.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/scripts/win_test.ps1 b/.github/workflows/scripts/win_test.ps1 index bc838b04782459..9cd94f1d66f306 100644 --- a/.github/workflows/scripts/win_test.ps1 +++ b/.github/workflows/scripts/win_test.ps1 @@ -15,6 +15,11 @@ if ("$env:TI_WANTED_ARCHS".Contains("cuda")) { } # Fail fast, give priority to the error-prone tests python tests/run_tests.py -vr2 -t1 -k "paddle" -a cpu +if (-not $?) { exit 1 } + +# Disable paddle for the remaining test +$env:TI_ENABLE_PADDLE = "0" + if ("$env:TI_WANTED_ARCHS".Contains("cuda")) { python tests/run_tests.py -vr2 -t4 -k "not torch and not paddle" -a cuda if (-not $?) { exit 1 } From abd0136ee6f46abb69ae34fa08b14caae0a149f9 Mon Sep 17 00:00:00 2001 From: Zhanlue Yang Date: Fri, 6 May 2022 12:07:30 +0800 Subject: [PATCH 4/4] [build] Warning Suppression PR #2: Fixed codebase warnings (#4909) --- taichi/backends/vulkan/vulkan_device.cpp | 5 +---- taichi/backends/vulkan/vulkan_device_creator.cpp | 2 +- taichi/backends/wasm/codegen_wasm.cpp | 2 +- taichi/codegen/spirv/spirv_codegen.cpp | 1 - taichi/program/async_engine.cpp | 8 +++++++- taichi/program/state_flow_graph.cpp | 2 +- taichi/util/io.h | 6 +++++- tests/cpp/ir/ir_type_promotion_test.cpp | 2 +- tests/cpp/transforms/alg_simp_test.cpp | 3 ++- 9 files changed, 19 insertions(+), 12 deletions(-) diff --git a/taichi/backends/vulkan/vulkan_device.cpp b/taichi/backends/vulkan/vulkan_device.cpp index 83c278a0bd058c..62b1b4fe6b865e 100644 --- a/taichi/backends/vulkan/vulkan_device.cpp +++ b/taichi/backends/vulkan/vulkan_device.cpp @@ -1396,9 +1396,8 @@ void VulkanDevice::dealloc_memory(DeviceAllocation handle) { TI_ASSERT_INFO(map_pair != allocations_.end(), "Invalid handle (double free?) {}", handle.alloc_id); - AllocationInternal &alloc = map_pair->second; - #ifdef TI_VULKAN_DEBUG_ALLOCATIONS + AllocationInternal &alloc = map_pair->second; TI_TRACE("Dealloc VK buffer {}, alloc_id={}", (void *)alloc.buffer, handle.alloc_id); #endif @@ -1831,8 +1830,6 @@ void VulkanDevice::destroy_image(DeviceAllocation handle) { TI_ASSERT_INFO(map_pair != image_allocations_.end(), "Invalid handle (double free?) {}", handle.alloc_id); - ImageAllocInternal &alloc_int = map_pair->second; - image_allocations_.erase(handle.alloc_id); } diff --git a/taichi/backends/vulkan/vulkan_device_creator.cpp b/taichi/backends/vulkan/vulkan_device_creator.cpp index 030398947b2d84..4cbce621205328 100644 --- a/taichi/backends/vulkan/vulkan_device_creator.cpp +++ b/taichi/backends/vulkan/vulkan_device_creator.cpp @@ -455,7 +455,7 @@ void VulkanDeviceCreator::create_logical_device() { bool has_swapchain = false; - bool portability_subset_enabled = false; + [[maybe_unused]] bool portability_subset_enabled = false; for (auto &ext : extension_properties) { TI_TRACE("Vulkan device extension {} ({})", ext.extensionName, diff --git a/taichi/backends/wasm/codegen_wasm.cpp b/taichi/backends/wasm/codegen_wasm.cpp index bba625393ecf8c..7170eab5e17791 100644 --- a/taichi/backends/wasm/codegen_wasm.cpp +++ b/taichi/backends/wasm/codegen_wasm.cpp @@ -31,7 +31,7 @@ class CodeGenLLVMWASM : public CodeGenLLVM { } void create_offload_range_for(OffloadedStmt *stmt) override { - int step = 1; + [[maybe_unused]] int step = 1; // In parallel for-loops reversing the order doesn't make sense. // However, we may need to support serial offloaded range for's in the diff --git a/taichi/codegen/spirv/spirv_codegen.cpp b/taichi/codegen/spirv/spirv_codegen.cpp index 0d841a94e2b270..b8901c20c4dde4 100644 --- a/taichi/codegen/spirv/spirv_codegen.cpp +++ b/taichi/codegen/spirv/spirv_codegen.cpp @@ -474,7 +474,6 @@ class TaskCodegen : public IRVisitor { void visit(GlobalStoreStmt *stmt) override { TI_ASSERT(stmt->width() == 1); - const auto dt = stmt->val->element_type(); spirv::Value val = ir_->query_value(stmt->val->raw_name()); diff --git a/taichi/program/async_engine.cpp b/taichi/program/async_engine.cpp index a8e644ef610f2e..ffd4cae24d1999 100644 --- a/taichi/program/async_engine.cpp +++ b/taichi/program/async_engine.cpp @@ -325,8 +325,14 @@ void AsyncEngine::debug_sfg(const std::string &stage) { std::ofstream dot_file(dot_fn + ".dot"); dot_file << dot; } - std::system( + + int return_code = std::system( fmt::format("dot -Tpdf -o {}.pdf {}.dot", dot_fn, dot_fn).c_str()); + if (return_code != 0) { + throw std::runtime_error( + fmt::format("Unable to convert {dot_fn}.dot into {dot_fn}.pdf") + .c_str()); + } } TLANG_NAMESPACE_END diff --git a/taichi/program/state_flow_graph.cpp b/taichi/program/state_flow_graph.cpp index aa4e6a1ae9e3bd..b1354b644c8ef3 100644 --- a/taichi/program/state_flow_graph.cpp +++ b/taichi/program/state_flow_graph.cpp @@ -447,7 +447,7 @@ bool StateFlowGraph::optimize_listgen() { for (int i = i_start; i < listgens.size(); i++) { auto node_a = listgens[i]; - bool erased_any = false; + [[maybe_unused]] bool erased_any = false; auto new_i = i; diff --git a/taichi/util/io.h b/taichi/util/io.h index e3e372e90a63f5..df95671738d799 100644 --- a/taichi/util/io.h +++ b/taichi/util/io.h @@ -22,7 +22,11 @@ inline void create_directories(const std::string &dir) { #if defined(TI_PLATFORM_WINDOWS) std::filesystem::create_directories(dir); #else - std::system(fmt::format("mkdir -p {}", dir).c_str()); + int return_code = std::system(fmt::format("mkdir -p {}", dir).c_str()); + if (return_code != 0) { + throw std::runtime_error( + fmt::format("Unable to create directory at: {dir}").c_str()); + } #endif } diff --git a/tests/cpp/ir/ir_type_promotion_test.cpp b/tests/cpp/ir/ir_type_promotion_test.cpp index 6f444763d7bd0f..b4b71b50440928 100644 --- a/tests/cpp/ir/ir_type_promotion_test.cpp +++ b/tests/cpp/ir/ir_type_promotion_test.cpp @@ -13,7 +13,7 @@ TEST(IRTypePromotionTest, ShiftOp) { // (u8)x << (i32)1 -> (u8)res auto *lhs = builder.create_arg_load(0, get_data_type(), false); - auto *res = builder.create_shl(lhs, builder.get_int32(1)); + builder.create_shl(lhs, builder.get_int32(1)); auto ir = builder.extract_ir(); ASSERT_TRUE(ir->is()); diff --git a/tests/cpp/transforms/alg_simp_test.cpp b/tests/cpp/transforms/alg_simp_test.cpp index 469e40b34c371c..a8e8f2b850ac6a 100644 --- a/tests/cpp/transforms/alg_simp_test.cpp +++ b/tests/cpp/transforms/alg_simp_test.cpp @@ -96,7 +96,8 @@ TEST_F(AlgebraicSimplicationTest, SimplifyMultiplyZeroFastMath) { auto add = block->push_back(BinaryOpType::add, mul, one); auto global_store_addr = block->push_back( 4, TypeFactory::create_vector_or_scalar_type(1, PrimitiveType::i32)); - auto global_store = block->push_back(global_store_addr, add); + [[maybe_unused]] auto global_store = + block->push_back(global_store_addr, add); CompileConfig config_without_fast_math; config_without_fast_math.fast_math = false;