-
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
[async] Optimization stage 1 #994
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6db36b6
deploy cloning
yuanming-hu 02264eb
test_fuse
yuanming-hu 453dbf8
fusion works
yuanming-hu 86cb39d
.
yuanming-hu ad9bc61
update kernel hash
yuanming-hu 4732b58
finalize test_fuse_dense
yuanming-hu b869193
[async] Optimization stage 1
yuanming-hu b0979dc
[skip ci] enforce code format
taichi-gardener File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import taichi as ti | ||
import time | ||
|
||
ti.init(async=True) | ||
|
||
x = ti.var(ti.i32) | ||
y = ti.var(ti.i32) | ||
z = ti.var(ti.i32) | ||
|
||
ti.root.dense(ti.i, 1024**3).place(x) | ||
ti.root.dense(ti.i, 1024**3).place(y) | ||
ti.root.dense(ti.i, 1024**3).place(z) | ||
|
||
|
||
@ti.kernel | ||
def x_to_y(): | ||
for i in x: | ||
y[i] = x[i] + 1 | ||
|
||
|
||
@ti.kernel | ||
def y_to_z(): | ||
for i in x: | ||
z[i] = y[i] + 4 | ||
|
||
|
||
@ti.kernel | ||
def inc(): | ||
for i in x: | ||
x[i] = x[i] + 1 | ||
|
||
|
||
n = 100 | ||
|
||
for i in range(n): | ||
x[i] = i * 10 | ||
|
||
repeat = 10 | ||
|
||
for i in range(repeat): | ||
t = time.time() | ||
x_to_y() | ||
ti.sync() | ||
print('x_to_y', time.time() - t) | ||
|
||
for i in range(repeat): | ||
t = time.time() | ||
y_to_z() | ||
ti.sync() | ||
print('y_to_z', time.time() - t) | ||
|
||
for i in range(repeat): | ||
t = time.time() | ||
x_to_y() | ||
y_to_z() | ||
ti.sync() | ||
print('fused x->y->z', time.time() - t) | ||
|
||
for i in range(repeat): | ||
t = time.time() | ||
inc() | ||
ti.sync() | ||
print('single inc', time.time() - t) | ||
|
||
for i in range(repeat): | ||
t = time.time() | ||
for j in range(10): | ||
inc() | ||
ti.sync() | ||
print('fused 10 inc', time.time() - t) | ||
|
||
for i in range(n): | ||
assert x[i] == i * 10 | ||
assert y[i] == x[i] + 1 | ||
assert z[i] == x[i] + 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import taichi as ti | ||
|
||
ti.init() | ||
|
||
x = ti.var(ti.i32) | ||
y = ti.var(ti.i32) | ||
z = ti.var(ti.i32) | ||
|
||
ti.root.dynamic(ti.i, 1048576, chunk_size=2048).place(x, y, z) | ||
|
||
|
||
@ti.kernel | ||
def x_to_y(): | ||
for i in x: | ||
y[i] = x[i] + 1 | ||
|
||
|
||
@ti.kernel | ||
def y_to_z(): | ||
for i in x: | ||
z[i] = y[i] + 1 | ||
|
||
|
||
n = 10000 | ||
|
||
for i in range(n): | ||
x[i] = i * 10 | ||
|
||
x_to_y() | ||
y_to_z() | ||
|
||
for i in range(n): | ||
x[i] = i * 10 | ||
assert y[i] == x[i] + 1 | ||
assert z[i] == x[i] + 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Actually this pass is probably unnecessary...
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.
...since all
ret_type
s are cloned.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.
Merging this in for now and let's get rid of all kernel parameters and this type check after #988 is done.