Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:strongoier/taichi into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
strongoier committed Jul 20, 2021
2 parents 9b23c6b + af26624 commit 0373e78
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
11 changes: 6 additions & 5 deletions taichi/codegen/codegen_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1676,13 +1676,14 @@ void CodeGenLLVM::create_offload_struct_for(OffloadedStmt *stmt, bool spmd) {
if (!prog->config.packed) {
for (int i = 0; i < snode->num_active_indices; i++) {
auto j = snode->physical_index_position[i];
if (!bit::is_power_of_two(snode->extractors[j].num_elements_from_root)) {
if (!bit::is_power_of_two(
snode->extractors[j].num_elements_from_root)) {
auto coord = coord_object.get("val", tlctx->get_constant(j));
exec_cond = builder->CreateAnd(
exec_cond,
builder->CreateICmp(
llvm::CmpInst::ICMP_SLT, coord,
tlctx->get_constant(snode->extractors[j].num_elements_from_root)));
exec_cond, builder->CreateICmp(
llvm::CmpInst::ICMP_SLT, coord,
tlctx->get_constant(
snode->extractors[j].num_elements_from_root)));
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion taichi/struct/struct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ void infer_snode_properties(SNode &snode, bool packed) {
auto &ch = snode.ch[ch_id];
ch->parent = &snode;
for (int i = 0; i < taichi_max_num_indices; i++) {
ch->extractors[i].num_elements_from_root *= snode.extractors[i].num_elements_from_root;
ch->extractors[i].num_elements_from_root *=
snode.extractors[i].num_elements_from_root;
bool found = false;
for (int k = 0; k < taichi_max_num_indices; k++) {
if (snode.physical_index_position[k] == i) {
Expand Down
14 changes: 8 additions & 6 deletions taichi/transforms/lower_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ class LowerAccess : public IRVisitor {
bool packed;

LowerAccess(const std::vector<SNode *> &kernel_forces_no_activate,
bool lower_atomic_ptr, bool packed)
bool lower_atomic_ptr,
bool packed)
: kernel_forces_no_activate(kernel_forces_no_activate),
lower_atomic_ptr(lower_atomic_ptr), packed(packed) {
lower_atomic_ptr(lower_atomic_ptr),
packed(packed) {
// TODO: change this to false
allow_undefined_visitor = true;
current_struct_for = nullptr;
Expand Down Expand Up @@ -100,8 +102,8 @@ class LowerAccess : public IRVisitor {
TI_ASSERT(!pointer_needs_activation);
}

PtrLowererImpl lowerer{leaf_snode, indices, snode_op, is_bit_vectorized,
lowered, packed};
PtrLowererImpl lowerer{leaf_snode, indices, snode_op,
is_bit_vectorized, lowered, packed};
lowerer.set_pointer_needs_activation(pointer_needs_activation);
lowerer.set_lower_access(this);
lowerer.run();
Expand Down Expand Up @@ -305,8 +307,8 @@ namespace irpass {
bool lower_access(IRNode *root,
const CompileConfig &config,
const LowerAccessPass::Args &args) {
bool modified =
LowerAccess::run(root, args.kernel_forces_no_activate, args.lower_atomic, config.packed);
bool modified = LowerAccess::run(root, args.kernel_forces_no_activate,
args.lower_atomic, config.packed);
type_check(root, config);
return modified;
}
Expand Down
4 changes: 3 additions & 1 deletion tests/cpp/transforms/scalar_pointer_lowerer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ TEST_F(ScalarPointerLowererTest, Basic) {
LowererImpl lowerer{leaf_snode_,
std::vector<Stmt *>{builder.get_int32(loop_index)},
SNodeOpType::undefined,
/*is_bit_vectorized=*/false, &lowered, /*packed=*/false};
/*is_bit_vectorized=*/false,
&lowered,
/*packed=*/false};
lowerer.run();
// There are three linearized stmts:
// 0: for root
Expand Down
2 changes: 1 addition & 1 deletion tests/python/test_packed_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
def test_packed_size():
x = ti.field(ti.i32)
ti.root.dense(ti.i, 20).dense(ti.ijk, 334).place(x)
assert x.snode.parent().parent().cell_size_bytes == 4 * 334 ** 3
assert x.snode.parent().parent().cell_size_bytes == 4 * 334**3

0 comments on commit 0373e78

Please sign in to comment.