From c0cc82ba97897eb04a342013a8ad38eb0c13537f Mon Sep 17 00:00:00 2001 From: Carsten Bauer Date: Wed, 5 Jul 2023 15:00:43 +0200 Subject: [PATCH] restructuring/formatting --- src/MKL.jl | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/MKL.jl b/src/MKL.jl index 20f177c..80eb60e 100644 --- a/src/MKL.jl +++ b/src/MKL.jl @@ -31,17 +31,6 @@ else mkl_found || @warn("Couldn't find MKL library at $libmkl_rt.") end -# Changing the MKL provider/path preference -function set_mkl_path(path) - if lowercase(path) ∉ ("mkl_jll", "system") && !isfile(path) - error("The provided argument $path neither seems to be a valid path to libmkl_rt nor \"mkl_jll\" or \"system\".") - end - @set_preferences!("mkl_path" => path) - @info("New MKL preference set; please restart Julia to see this take effect", path) -end - -using LinearAlgebra - if Base.USE_BLAS64 const MKLBlasInt = Int64 else @@ -62,6 +51,14 @@ end INTERFACE_GNU end +function set_mkl_path(path) + if lowercase(path) ∉ ("mkl_jll", "system") && !isfile(path) + error("The provided argument $path neither seems to be a valid path to libmkl_rt nor \"mkl_jll\" or \"system\".") + end + @set_preferences!("mkl_path" => path) + @info("New MKL preference set; please restart Julia to see this take effect", path) +end + function set_threading_layer(layer::Threading = THREADING_SEQUENTIAL) err = ccall((:MKL_Set_Threading_Layer, libmkl_rt), Cint, (Cint,), layer) err == -1 && throw(ErrorException("MKL_Set_Threading_Layer() returned -1")) @@ -74,6 +71,11 @@ function set_interface_layer(interface::Interface = INTERFACE_LP64) return nothing end +function mklnorm(x::Vector{Float64}) + ccall((:dnrm2_, libmkl_rt), Float64, + (Ref{MKLBlasInt}, Ptr{Float64}, Ref{MKLBlasInt}), length(x), x, 1) +end + function lbt_mkl_forwarding() if Sys.isapple() set_threading_layer(THREADING_SEQUENTIAL) @@ -101,9 +103,4 @@ function __init__() end end -function mklnorm(x::Vector{Float64}) - ccall((:dnrm2_, libmkl_rt), Float64, - (Ref{MKLBlasInt}, Ptr{Float64}, Ref{MKLBlasInt}), length(x), x, 1) -end - end # module