Skip to content

Commit

Permalink
restructuring/formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
carstenbauer committed Jul 5, 2023
1 parent 8b988a1 commit c0cc82b
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/MKL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"))
Expand All @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit c0cc82b

Please sign in to comment.