-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[Metal] Changes to enable bitmasked
on Metal!
#661
Conversation
Interesting! Is there any pre-requirements for OpenGL to also support this? Not familiar to what |
@ti.kernel | ||
def sum(): | ||
for i, j in x: | ||
ti.atomic_add(c[None], ti.is_active(bm, [i, j])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the difference bitmasked
introduced is, only those assigned slots are marked as is_active
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm thinking right, this can be used for performance optimization, like Game of Life - only the non-static cells are calculated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. For sparse data structures, struct_for
will only loop over the active indices (it could still iterate over more slots due to POT paddings, but not all of them).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm thinking right, this can be used for performance optimization, like Game of Life - only the non-static cells are calculated?
Great idea! If you are interested, having a game of life demo with sparse grids would be super cool!!
It's the simplest sparse data structure in taichi. Under the hood, it is taichi/taichi/runtime/llvm/node_dense.h Lines 19 to 25 in 068af03
For each
taichi/taichi/platform/metal/shaders/runtime_utils.metal.h Lines 39 to 53 in 068af03
taichi/taichi/runtime/llvm/runtime.cpp Lines 1105 to 1108 in 068af03
If you want to support sparse SNodes on OpenGL, i think https://github.com/taichi-dev/taichi/blob/master/taichi/runtime/llvm/runtime.cpp is a really good start. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thanks so much for contributing this!!
Looking at the recurring pattern snode->is_dense && snode->is_bitmasked
, I'm wondering if we should promote bitmasked
to be a standalone SNodeType
, instead of a decorator to dense
. We used to have dense.pointer
, yet later pointers
are made a standalone data structure (thanks to @KLozes). Maybe we should do the same for bitmasked
since
bitmasked
is always used withdense
, so maybe we should save the verbosity;dense.bitmasked
is too different fromdense
so bitmasked worths a standaloneSNodeType
.
SGTM! Shall I make the change before merging this? |
That doesn't sound like a small change to me. Let's merge this in first :-) |
Related issue id = #593
[Click here for the format server]
Feel like the tests are pretty weak...