-
Notifications
You must be signed in to change notification settings - Fork 4
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
Experimental/threadcall #21
Conversation
@dehann, I think the example may need work to better illustrate the use of this function. |
Codecov Report
@@ Coverage Diff @@
## master #21 +/- ##
==========================================
+ Coverage 94.23% 94.46% +0.22%
==========================================
Files 4 4
Lines 243 253 +10
==========================================
+ Hits 229 239 +10
Misses 14 14
Continue to review full report at Codecov.
|
Keeping link to general discussion on shared memory multithreading here: JuliaLang/julia#1790 |
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!
detection_destroy and zarray_destroy yourself. | ||
""" | ||
function threadcall_apriltag_detector_detect(td, im_orig) | ||
@threadcall((:apriltag_detector_detect, :libapriltag), Ptr{zarray_t}, (Ptr{apriltag_detector_t}, Ptr{image_u8_t}), td, Ref(im_orig)) |
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.
As long as you are not calling back into Julia from the C implementation (which AprilTags is not doing).
https://docs.julialang.org/en/stable/stdlib/parallel/#ccall-using-a-threadpool-(Experimental)-1
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.
#call detector in thread | ||
@async global t1 = @timed begin | ||
println("time before detector $(Dates.value(now())-starttime) ms") | ||
global tags = AprilTags.threadcalldetect(detector, image) |
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.
global
is slower since Julia optimizes at a per function level. This is fine for testing, but try avoid for general implementation.
#Run against a file | ||
image = load(dirname(Base.source_path()) *"/../data/tagtest.jpg") | ||
|
||
@sync begin |
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.
Yes, I think this is the right way to do it. Haven't worked with @threadcall
before but understand from docs that it is non-blocking.
HI @Affie, I think you can merge when ready. |
Thanks @dehann |
Using the julia's experimental threadcall for calling the apriltag detector