Skip to content

Commit 9730589

Browse files
authored
Don't use MKL except on x86_64, fixes #73. (#75)
1 parent df5ab1f commit 9730589

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/BLASBenchmarksCPU.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
module BLASBenchmarksCPU
22

33
# BLAS libs (& Libdl)
4-
using MKL_jll, OpenBLAS_jll, blis_jll#, Libdl
4+
@static if Sys.ARCH === :x86_64
5+
using MKL_jll
6+
end
7+
using OpenBLAS_jll, blis_jll#, Libdl
58
# Julia BLAS
69
using Tullio, Octavian, Gaius
710

@@ -45,10 +48,12 @@ export gemmmkl!, gemmmkl_direct!
4548
export mkl_set_num_threads
4649

4750
# set threads
51+
@static if Sys.ARCH === :x86_64
4852
const libMKL = MKL_jll.libmkl_rt # more convenient name
4953
function mkl_set_num_threads(N::Integer)
5054
ccall((:MKL_Set_Num_Threads,libMKL), Cvoid, (Int32,), N % Int32)
5155
end
56+
end
5257
const libOPENBLAS = OpenBLAS_jll.libopenblas # more convenient name
5358
function openblas_set_num_threads(N::Integer)
5459
ccall((:openblas_set_num_threads64_,libOPENBLAS), Cvoid, (Int64,), N)
@@ -69,7 +74,7 @@ include("runbenchmark.jl")
6974
include("plotting.jl")
7075

7176
function __init__()
72-
mkl_set_num_threads(num_cores())
77+
Sys.ARCH === :x86_64 && mkl_set_num_threads(num_cores())
7378
openblas_set_num_threads(num_cores())
7479
blis_set_num_threads(num_cores())
7580
end

src/ccallblas.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ for (name,BlasInt,suff) ∈ [
5454
("openblas", :Int64, "_64_"),
5555
("blis", :Int64, "_64_")
5656
]
57+
(Sys.ARCH !== :x86_64 && name === "mkl") && continue
5758
uname = uppercase(name)
5859
lib = Symbol("lib", uname)
5960
fgemm = Symbol("gemm", name, '!')
@@ -151,6 +152,7 @@ for (name,BlasInt,suff) ∈ [
151152

152153
end
153154
end
155+
@static if Sys.ARCH === :x86_64
154156
let BlasInt = :Int32
155157
for (T,prefix) [(:Float32,'s'),(:Float64,'d')]
156158
f = Symbol(prefix, "gemm_direct")
@@ -176,6 +178,7 @@ let BlasInt = :Int32
176178
end
177179
end
178180
end
181+
end
179182

180183

181184

src/runbenchmark.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,12 @@ function all_libs()
201201
libs = Symbol[
202202
:BLIS,
203203
:Gaius,
204-
:MKL,
205204
:Octavian,
206205
:OpenBLAS,
207206
:Tullio,
208207
:LoopVectorization
209208
]
209+
Sys.ARCH === :x86_64 && push!(libs, :MKL)
210210
return libs
211211
end
212212

@@ -276,11 +276,11 @@ function runbench(
276276
sleep_time = 0.0
277277
) where {T}
278278
if threaded
279-
mkl_set_num_threads(num_cores())
279+
Sys.ARCH === :x86_64 && mkl_set_num_threads(num_cores())
280280
openblas_set_num_threads(num_cores())
281281
blis_set_num_threads(num_cores())
282282
else
283-
mkl_set_num_threads(1)
283+
Sys.ARCH === :x86_64 && mkl_set_num_threads(1)
284284
openblas_set_num_threads(1)
285285
blis_set_num_threads(1)
286286
end
@@ -355,7 +355,11 @@ function runbench(
355355
BenchmarkResult{T}(libs, sizes, gflop, times, threaded)
356356
end
357357

358+
@static if Sys.ARCH === :x86_64
358359
const LUFUNCS = Dict(:RecursiveFactorization => RecursiveFactorization.lu!, :MKL => lumkl!, :OpenBLAS => luopenblas!)
360+
else
361+
const LUFUNCS = Dict(:RecursiveFactorization => RecursiveFactorization.lu!, :OpenBLAS => luopenblas)
362+
end
359363
struct LUWrapperFunc{F}; f::F; end
360364
(lu::LUWrapperFunc)(A,B,C) = lu.f(copyto!(A,B))
361365
function runlubench(

0 commit comments

Comments
 (0)