How to use atomic operations with a condition? #8594
Unanswered
Protonix1560
asked this question in
Q&A
Replies: 1 comment
-
Your atomic_min code looks correct to me. Do you have any reason to suspect that it won't work? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am writing a function that renders a scene with python 3.12.3 and taichi 1.7.2. I've got a problem: because function runs on multiple threads without atomic operations image may have some artifacts. Here is example:
On the black part there is white pixel that should be black. That white pixel is from the gray part that is partially underneath the black part. 2 threads while drawing different parts have edited 1 pixel at the same time. In my code I have z_buffer to store distance to drawn pixel and image_buffer to store render result (I've named it surfarray). If I don't use atomic operations, then those artifacts will be on both arrays. But if I use atomic operations on z_buffer, then z_buffer won't have artifacts and image_buffer still will. That is logical, but on z_buffer I can use
ti.atomic_max
, and for image_buffer taichi currently doesn't have atomic operation, because I need to set value only if condition is true. Here is a part of code that checks if distance to pixel is smaller than distance to previous drawn pixel:I think what's happening is:
I think if i use atomic operation that sets value only if a condition is true, then nearest thread will wait untill farthest thread will set value, but taichi doesn't have suitable operation
What should I do to fix that problem?
Beta Was this translation helpful? Give feedback.
All reactions