Skip to content

Commit

Permalink
Auto Format
Browse files Browse the repository at this point in the history
  • Loading branch information
taichi-gardener committed Dec 14, 2021
1 parent 70f3b05 commit c89a1b3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion taichi/llvm/llvm_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ std::size_t TaichiLLVMContext::get_type_size(llvm::Type *type) {
return get_data_layout().getTypeAllocSize(type);
}

std::size_t TaichiLLVMContext::get_struct_element_offset(llvm::StructType *type, int idx) {
std::size_t TaichiLLVMContext::get_struct_element_offset(llvm::StructType *type,
int idx) {
return get_data_layout().getStructLayout(type)->getElementOffset(idx);
}

Expand Down
3 changes: 2 additions & 1 deletion taichi/python/export_lang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ void export_lang(py::module &m) {
.def("num_active_indices",
[](SNode *snode) { return snode->num_active_indices; })
.def_readonly("cell_size_bytes", &SNode::cell_size_bytes)
.def_readonly("offset_bytes_in_parent_cell", &SNode::offset_bytes_in_parent_cell)
.def_readonly("offset_bytes_in_parent_cell",
&SNode::offset_bytes_in_parent_cell)
.def("begin_shared_exp_placement", &SNode::begin_shared_exp_placement)
.def("end_shared_exp_placement", &SNode::end_shared_exp_placement);

Expand Down
3 changes: 2 additions & 1 deletion taichi/struct/struct_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ void StructCompilerLLVM::generate_types(SNode &snode) {

for (int i = 0; i < snode.ch.size(); i++) {
if (!snode.ch[i]->is_bit_level) {
snode.ch[i]->offset_bytes_in_parent_cell = tlctx_->get_struct_element_offset(ch_type, i);
snode.ch[i]->offset_bytes_in_parent_cell =
tlctx_->get_struct_element_offset(ch_type, i);
}
}

Expand Down
4 changes: 3 additions & 1 deletion tests/python/test_snode_layout_inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def test_primitives():

assert n1.offset_bytes_in_parent_cell == 0
assert n2.offset_bytes_in_parent_cell == 2 * 32
assert n3.offset_bytes_in_parent_cell in [2 * 32 + 12 * 32, 2 * 32 + 16 * 32]
assert n3.offset_bytes_in_parent_cell in [
2 * 32 + 12 * 32, 2 * 32 + 16 * 32
]

assert x.snode.offset_bytes_in_parent_cell == 0
assert y.snode.offset_bytes_in_parent_cell == 0
Expand Down

0 comments on commit c89a1b3

Please sign in to comment.