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

Experimental/threadcall #21

Merged
merged 5 commits into from
Jul 24, 2018
Merged

Experimental/threadcall #21

merged 5 commits into from
Jul 24, 2018

Conversation

Affie
Copy link
Member

@Affie Affie commented Jul 23, 2018

Using the julia's experimental threadcall for calling the apriltag detector

@Affie Affie requested a review from dehann July 23, 2018 15:20
@Affie
Copy link
Member Author

Affie commented Jul 23, 2018

@dehann, I think the example may need work to better illustrate the use of this function.
Let me know what you think.

@codecov-io
Copy link

codecov-io commented Jul 23, 2018

Codecov Report

Merging #21 into master will increase coverage by 0.22%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/wrapper.jl 53.84% <100%> (+1.84%) ⬆️
src/helpers.jl 98.57% <100%> (+0.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 75e8c58...113f0e4. Read the comment docs.

@dehann
Copy link
Member

dehann commented Jul 24, 2018

Keeping link to general discussion on shared memory multithreading here: JuliaLang/julia#1790

Copy link
Member

@dehann dehann left a 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))
Copy link
Member

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

Copy link
Member

@dehann dehann Jul 24, 2018

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)
Copy link
Member

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
Copy link
Member

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.

@dehann
Copy link
Member

dehann commented Jul 24, 2018

HI @Affie, I think you can merge when ready.

@Affie Affie merged commit 373c1ea into master Jul 24, 2018
@Affie
Copy link
Member Author

Affie commented Jul 24, 2018

Thanks @dehann

@dehann dehann added this to the v0.0.2 milestone Jul 24, 2018
@Affie Affie deleted the experimental/threadcall branch August 23, 2018 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants