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

[Type] Built-in fixed point number support? #1925

Closed
archibate opened this issue Oct 6, 2020 · 1 comment
Closed

[Type] Built-in fixed point number support? #1925

archibate opened this issue Oct 6, 2020 · 1 comment
Assignees
Labels
feature request Suggest an idea on this project

Comments

@archibate
Copy link
Collaborator

archibate commented Oct 6, 2020

Concisely describe the proposed feature
Floating point numbers are good, but they're low effcient compared to integers, especially when it comes to atomics.
The OpenGL (mesa) backend yields 40% performance boost in mpm88.py after switching grid_v and grid_m to fixed point.
The switching process was not so intuitive, however, it would be great if users can switch it just changing a character (ti.f32 -> ti.d32).
So I would like to add built-in fixed point number support so users could switch and tune the performance without pain, just like the SNode system provide us.

Describe the solution you'd like (if any)
First, let's call fixed point number ti.d32 and ti.d64.
Based on #1905, let the primitive type of ti.d32 to be ti.i32, and the DataTypeNode should also include an extra parameter shift, e.g.:

x_float = ti.Vector.field(ti.f32)
x_handwrite_fixed = ti.Vector.field(ti.i32)
x_builtin_fixed = ti.Vector.field(ti.d32(shift=10))  # The scale factor is 2**10

x_handwrite_fixed.dtype  # ti.i32
x_builtin_fixed.dtype  # ti.d32(shift=10)
x_builtin_fixed.dtype.shift  # 10

Also note that we'd demote ti.d32 operations into ti.i32, so that no backend maintainance would be envolved.

Additional comments
Am I understanding #1095 correct?

@archibate archibate added the feature request Suggest an idea on this project label Oct 6, 2020
@yuanming-hu
Copy link
Member

This has been planned to be part of #1905 three months ago, as our internal project :-) Hopefully, this will be implemented by 2021.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Suggest an idea on this project
Projects
None yet
Development

No branches or pull requests

2 participants