Skip to content

Commit

Permalink
Merge branch 'master' of github.com:taichi-dev/taichi into warnings_s…
Browse files Browse the repository at this point in the history
…uppression_pr0
  • Loading branch information
jim19930609 committed May 6, 2022
2 parents 0091a0a + abd0136 commit 29a6a3f
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 27 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/scripts/win_test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion docs/lang/articles/advanced/odop.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions docs/lang/articles/advanced/sparse.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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).

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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`

Expand Down
2 changes: 1 addition & 1 deletion docs/lang/articles/basic/field.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/lang/articles/basic/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
10 changes: 5 additions & 5 deletions docs/lang/articles/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion python/taichi/lang/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions taichi/backends/vulkan/vulkan_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion taichi/backends/vulkan/vulkan_device_creator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion taichi/backends/wasm/codegen_wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion taichi/codegen/spirv/spirv_codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
8 changes: 7 additions & 1 deletion taichi/program/async_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion taichi/program/state_flow_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 5 additions & 1 deletion taichi/util/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion tests/cpp/ir/ir_type_promotion_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TEST(IRTypePromotionTest, ShiftOp) {

// (u8)x << (i32)1 -> (u8)res
auto *lhs = builder.create_arg_load(0, get_data_type<uint8>(), 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<Block>());
Expand Down
3 changes: 2 additions & 1 deletion tests/cpp/transforms/alg_simp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ TEST_F(AlgebraicSimplicationTest, SimplifyMultiplyZeroFastMath) {
auto add = block->push_back<BinaryOpStmt>(BinaryOpType::add, mul, one);
auto global_store_addr = block->push_back<GlobalTemporaryStmt>(
4, TypeFactory::create_vector_or_scalar_type(1, PrimitiveType::i32));
auto global_store = block->push_back<GlobalStoreStmt>(global_store_addr, add);
[[maybe_unused]] auto global_store =
block->push_back<GlobalStoreStmt>(global_store_addr, add);

CompileConfig config_without_fast_math;
config_without_fast_math.fast_math = false;
Expand Down

0 comments on commit 29a6a3f

Please sign in to comment.