Created
March 3, 2020 16:39
-
-
Save Ken-Kuroki/9741bffe3df49305a43fb16c7de32fb1 to your computer and use it in GitHub Desktop.
Julia multithreads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check nthreads() is large enough | |
println(Threads.nthreads()) | |
function f(input) | |
return input*2 | |
end | |
function main() | |
inputs = [i for i in 20:30]; | |
outputs = zeros(10); | |
Threads.@threads for i in 1:10 | |
output[i] = f(inputs[i]); | |
end | |
end | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment