Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when building a big 2D field. #6258

Closed
mushroomfire opened this issue Oct 9, 2022 · 2 comments · Fixed by #6457
Closed

Error when building a big 2D field. #6258

mushroomfire opened this issue Oct 9, 2022 · 2 comments · Fixed by #6457
Assignees
Labels
potential bug Something that looks like a bug but not yet confirmed

Comments

@mushroomfire
Copy link
Contributor

mushroomfire commented Oct 9, 2022

Describe the bug
The code will shut down when I try to allocate a big 2D field, maybe it's a bug.

To Reproduce

import taichi as ti
ti.init(arch=ti.cpu)

arr = ti.field(ti.f32, (40000000, 50))
#arr.fill(1.) 

@ti.kernel
def fill():
    for I in arr:
        arr[I] = 1.0
fill(arr)

Log/Screenshots

[Taichi] version 1.1.2, llvm 10.0.0, commit f25cf4a2, win, python 3.8.13
[Taichi] Starting on arch=x64
[W 10/09/22 19:49:27.691 22784] [D:/a/taichi/taichi/taichi/ir/snode.cpp:create_node@95] Snode index might be out of int32 boundary but int64 indexing is not supported yet.

But 2**31-1 > 40000000*50 is True!
BTW, arr.fill(1.0) also raise an error as below:

RuntimeError: [D:/a/taichi/taichi/taichi/transforms/demote_dense_struct_fors.cpp:convert_to_range_for@29] Assertion failure: total_bits <= 30
@mushroomfire mushroomfire added the potential bug Something that looks like a bug but not yet confirmed label Oct 9, 2022
@taichi-gardener taichi-gardener moved this to Untriaged in Taichi Lang Oct 9, 2022
@FantasyVR
Copy link
Collaborator

FantasyVR commented Oct 12, 2022

Hi @mushroomfire. According to the doc:

By default, Taichi implicitly fits a field in a larger buffer with power-of-two dimensions.

Even though 40000000*50 is smaller than 2^31 - 1, it would still try to allocate 2^31 memory. You could init with packed mode to solve this problem ti.init(arch=ti.cpu, packed=True).

As for the errors when filling arr, it is because of the shape of your field is still too large.

@mushroomfire
Copy link
Contributor Author

packed=True, that helps. Thanks a lot!

@strongoier strongoier self-assigned this Oct 14, 2022
@strongoier strongoier moved this from Untriaged to Todo in Taichi Lang Oct 14, 2022
Repository owner moved this from Todo to Done in Taichi Lang Oct 28, 2022
strongoier added a commit that referenced this issue Oct 28, 2022
Issue: fix #6258

### Brief Summary

For the script in #6258, which causes overflow only in non-packed mode,
an error will be raised even if `packed=True`. The PR fixes the false
alarm.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
potential bug Something that looks like a bug but not yet confirmed
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants