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

add multithreading to speed up #9

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

add multithreading to speed up #9

wants to merge 5 commits into from

Conversation

rainsummer613
Copy link
Collaborator

Use Threads to run fast_filter across permutations and channels in parallel: Issue #7

for perm = 1:n_permutations


Threads.@threads for perm = 1:n_permutations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there might be a problem of race-condition, as we currently filter inplace. That is dat_filtered is now shared between threads and might not indicate a unique permutation. I'm not entirely sure how much performance gain the filtering inplace has over allocating a new array.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(couldnt mark it, but I mean the filter_fast! function below (or whatever it is called exctly)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point!
can you please have a look at the new commits on multiproc branch? eb9a3e5 and d0b06a6

I measured time with and without threads and inplace operations.
inplace+ threading- 240 s
inplace- threading+ 50 s

@rainsummer613
Copy link
Collaborator Author

work on inplace changes of dat

@rainsummer613 rainsummer613 reopened this May 19, 2024
@behinger
Copy link
Member

behinger commented May 21, 2024

hey, nice work there.

Can you check with e.g. https://github.com/LilithHafner/Chairmarks.jl the performance a bit more systematic? I would be interested especially in the filt! vs filt difference, both one-threaded. I'm specifically asking because we could also pre-allocate one array per thread, which is with e.g. 4 threads (is that how many you used?) much smaller than the number of permutations (100 x n_predictors)

There are also some threds on discourse if you really want to digg deeper (but I think GPU is the way to go). search "julia threads preallocation" or similar. Also https://github.com/JuliaFolds/FLoops.jl might be a good fit - but it hasnt seen updates in quite some time.

@rainsummer613
Copy link
Collaborator Author

@behinger thank you!

I am back from conferences and vacations and have more time now, so I will look into it this week

@rainsummer613
Copy link
Collaborator Author

rainsummer613 commented Jul 13, 2024

@behinger
Hey Benedikt, I have an update on measuring the performance time with Chairmarks:

1 thread, inplace changes (fast_filter!) 198 s
1 thread, no inplace changes (fast_filter) 209 s
10 threads, no inplace changes (fast_filter) 57 s

I will try to look into Floops too, if neccessary

@behinger
Copy link
Member

cool! interesting that the inpace filtering doesnt really help.

I think right now best is to discuss with Vlad, we try to sidestep the filtering and just take some (right now even non-overlapping) means instead

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