Skip to content

Commit

Permalink
avoid runtime @eval in @parallel test
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Sep 28, 2016
1 parent f532395 commit 3176ec8
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions test/parallel_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1108,31 +1108,28 @@ end

# Test addprocs enable_threaded_blas parameter

function define_get_num_threads()
@everywhere get_num_threads = function()
blas = BLAS.vendor()
# Wrap in a try to catch unsupported blas versions
try
if blas == :openblas
return ccall((:openblas_get_num_threads, Base.libblas_name), Cint, ())
elseif blas == :openblas64
return ccall((:openblas_get_num_threads64_, Base.libblas_name), Cint, ())
elseif blas == :mkl
return ccall((:MKL_Get_Max_Num_Threads, Base.libblas_name), Cint, ())
end

# OSX BLAS looks at an environment variable
if is_apple()
return ENV["VECLIB_MAXIMUM_THREADS"]
end
const get_num_threads = function() # anonymous so it will be serialized when called
blas = BLAS.vendor()
# Wrap in a try to catch unsupported blas versions
try
if blas == :openblas
return ccall((:openblas_get_num_threads, Base.libblas_name), Cint, ())
elseif blas == :openblas64
return ccall((:openblas_get_num_threads64_, Base.libblas_name), Cint, ())
elseif blas == :mkl
return ccall((:MKL_Get_Max_Num_Threads, Base.libblas_name), Cint, ())
end

return nothing
# OSX BLAS looks at an environment variable
if is_apple()
return ENV["VECLIB_MAXIMUM_THREADS"]
end
end

return nothing
end

function get_remote_num_threads(processes_added)
define_get_num_threads()
return [remotecall_fetch(get_num_threads, proc_id) for proc_id in processes_added]
end

Expand All @@ -1146,7 +1143,6 @@ function test_blas_config(pid, expected)
end

function test_add_procs_threaded_blas()
define_get_num_threads()
if get_num_threads() == nothing
warn("Skipping blas num threads tests due to unsupported blas version")
return
Expand Down

0 comments on commit 3176ec8

Please sign in to comment.