Skip to content

Commit

Permalink
[Bug] [ir] Fix a bug in "offload" (#1224)
Browse files Browse the repository at this point in the history
  • Loading branch information
xumingkuan authored Jun 12, 2020
1 parent 18e17ff commit bff5755
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 0 additions & 20 deletions taichi/transforms/offload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,26 +247,6 @@ class IdentifyValuesUsedInOtherOffloads : public BasicStmtVisitor {
}
}

void visit(LocalLoadStmt *stmt) override {
TI_ASSERT(current_offloaded);
TI_ASSERT(stmt->width() == 1);
test_and_allocate(stmt->ptr[0].var);
}

void visit(LocalStoreStmt *stmt) override {
TI_ASSERT(current_offloaded);
TI_ASSERT(stmt->width() == 1);
test_and_allocate(stmt->ptr);
}

void visit(AtomicOpStmt *stmt) override {
TI_ASSERT(current_offloaded);
TI_ASSERT(stmt->width() == 1);
if (stmt->dest->is<AllocaStmt>()) {
test_and_allocate(stmt->dest);
}
}

void visit(Stmt *stmt) override {
int n_op = stmt->num_operands();
for (int i = 0; i < n_op; i++) {
Expand Down
20 changes: 20 additions & 0 deletions tests/python/test_loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,23 @@ def test(b: ti.i32, e: ti.i32):
test(b, e)
for i in range(b, e):
assert x[i - b] == i


@ti.all_archs
def test_assignment_in_nested_loops():
# https://github.com/taichi-dev/taichi/issues/1109
m = ti.var(ti.f32, 3)
x = ti.var(ti.f32, ())

@ti.kernel
def func():
a = x[None]
for i in m:
b = a
for j in range(1):
b = b
x[None] = b

x[None] = 1
func()
assert x[None] == 1

0 comments on commit bff5755

Please sign in to comment.