I have a file code_paralell.jl
in which I am parallelizing its for-loop
of simulation time. At the beginning, I am preparing some variables, in which some needs @eval in front of them (due to world age).
To measure the function computation time:
1- First I put @time
before the function (i.e., @time f_parallel(args)). Then run julia and call the code. However, I was always seeing the compilation time even when I re-include the code consequently in the REPL.
$ julia --project=. -t 2
julia> include("code_paralell.jl")
julia> include("code_paralell.jl")
2- To pass that compilation time, I dropped the @time in front of the function and instead put @btime when calling the code in the REPL, as shown below:
############### code_paralell.jl #####################
using SparseArrays, LinearAlgebra, .Threads
# Initilize some variables, in which some are @eval
simulationTime = 1:10000
function f_parallel(args)
# do serial work
for t in simulationTime
# do serial work
@threads for i = 1:nthreads()
# do parallel work
end
# do serial work
end # for
# do serial work
end # f_parallel(args)
f_parallel(args)
$ julia --project=. -t 2
julia> using BenchmarkTools
julia> @btime include("code_paralell.jl")
Is what I am doing correct, either in the first or the second case?