Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions lib/mkl/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,13 @@ function LinearAlgebra.generic_matvecmul!(Y::oneVector, tA::AbstractChar, A::one
throw(DimensionMismatch("first dimension of A, $mA, does not match length of Y, $(length(Y))"))
end

if mA == 0
return Y
end
T = eltype(Y)

if nA == 0
return rmul!(Y, 0)
# an empty inner dimension still needs to apply beta: Y := b*Y
if mA == 0 || nA == 0
return iszero(b) ? fill!(Y, zero(T)) : rmul!(Y, b)
end

T = eltype(Y)
alpha, beta = promote(a, b, zero(T))
if alpha isa Union{Bool,T} && beta isa Union{Bool,T}
if T <: onemklFloat && eltype(A) == eltype(B) == T
Expand Down Expand Up @@ -148,17 +146,16 @@ function LinearAlgebra.generic_matmatmul!(
)
)

# an empty inner dimension still needs to apply beta: C := beta*C
if mA == 0 || nA == 0 || nB == 0
size(C) != (mA, nB) && throw(
DimensionMismatch(
"C has dimensions $(size(C)), should have ($mA,$nB)"
)
)
return LinearAlgebra.rmul!(C, 0)
return iszero(beta) ? fill!(C, zero(T)) : rmul!(C, beta)
end

T = eltype(C)

if T <: Union{onemklFloat, onemklComplex, onemklHalf} &&
alpha isa Union{Bool,T} && beta isa Union{Bool,T}
# TODO: should the gemm part above be included in this branch?
Expand Down
5 changes: 3 additions & 2 deletions src/oneAPIKernels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ function KA.launch_config(kernel::KA.Kernel{oneAPIBackend}, ndrange, workgroupsi
iterspace, dynamic = if KA.workgroupsize(kernel) <: KA.DynamicSize &&
workgroupsize === nothing
# use ndrange as preliminary workgroupsize for autotuning
KA.partition(kernel, ndrange, ndrange)
# (clamped to 1, since an empty ndrange cannot serve as a workgroup size)
KA.partition(kernel, ndrange, max.(ndrange, 1))
else
KA.partition(kernel, ndrange, workgroupsize)
end
Expand All @@ -101,7 +102,7 @@ end
function threads_to_workgroupsize(threads, ndrange)
total = 1
return map(ndrange) do n
x = min(div(threads, total), n)
x = max(1, min(div(threads, total), n))
total *= x
return x
end
Expand Down
Loading