-
Notifications
You must be signed in to change notification settings - Fork 12
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
Use LoopBuilder to multithread Modern plugins #252
Comments
The cursors do avoid random access, which slow the op down (I've tested). Specifically the random access needed to read the 8-neighbourhood of a pixel. My bet is that the inner lambda function of |
Sure, worth having a go. ATM |
LoopBuilder won't work for this use case. It supports a maximum number of 6 cursors or random accesses. You could work around this be using Views.collapse(Views.stack(...)) but I wouldn't expect any performance improvements by this. I would choose a different approach:
|
@maarzt I just did a little performance testing comparing the legacy and modern Connectivity plugins. You can see that even with some hacky multithreading, and avoiding random accesses with Performance timings
Macro code: print("Timing Legacy Connectivity");
for (i = 0; i < 5; i++){
start = getTime();
run("Connectivity");
end = getTime();
print("Legacy connectivity took "+end - start+" ms");
}
print("Timing Modern Connectivity");
for (i = 0; i < 5; i++){
start = getTime();
run("Connectivity (Modern)", "inputimage=net.imagej.ImgPlus@73672ce");
end = getTime();
print("Modern connectivity took "+end - start+" ms");
} Test image |
Describe the bug
LoopBuilder
is the ImgLib2 way to achieve chunked multithreading, see this for an example (specifically, the 'squared sum' example)https://forum.image.sc/t/imglib2-split-image-into-chunks-for-multi-threaded-processing/37519/4
Modern Connectivity currently uses 8
cursors
to achieve multithreading, which is a bit of a hack.imagej/imagej-ops@6a60315#diff-d6c590f31ede52f4518dba0b4a44cf9fR261
Additional context
Any change to the code needs to be performance benchmarked and reported to @maarzt
If it works out, we might be able to improve the performance of other Modern plugins like VolumeFraction
The text was updated successfully, but these errors were encountered: