Skip to content

Commit 9040ac3

Browse files
committed
Formatting
1 parent c47aeef commit 9040ac3

4 files changed

Lines changed: 267 additions & 210 deletions

File tree

lib/mkl/array.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mutable struct oneSparseMatrixCSC{Tv, Ti} <: oneAbstractSparseMatrix{Tv, Ti}
1818
colPtr::oneVector{Ti}
1919
rowVal::oneVector{Ti}
2020
nzVal::oneVector{Tv}
21-
dims::NTuple{2,Int}
21+
dims::NTuple{2, Int}
2222
nnz::Ti
2323
end
2424

@@ -46,7 +46,7 @@ SparseArrays.nnz(A::oneAbstractSparseMatrix) = A.nnz
4646
SparseArrays.nonzeros(A::oneAbstractSparseMatrix) = A.nzVal
4747

4848
for (gpu, cpu) in [:oneSparseMatrixCSR => :SparseMatrixCSC,
49-
:oneSparseMatrixCSC => :SparseMatrixCSC,
49+
:oneSparseMatrixCSC => :SparseMatrixCSC,
5050
:oneSparseMatrixCOO => :SparseMatrixCSC]
5151
@eval Base.show(io::IOContext, x::$gpu) =
5252
show(io, $cpu(x))

lib/mkl/interfaces.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ function LinearAlgebra.generic_matvecmul!(C::oneVector{T}, tA::AbstractChar, A::
77
sparse_gemv!(tA, _add.alpha, A, B, _add.beta, C)
88
end
99

10-
function LinearAlgebra.generic_matvecmul!(C::oneVector{T}, tA::AbstractChar, A::oneSparseMatrixCSC{T}, B::oneVector{T}, _add::MulAddMul) where T <: BlasReal
10+
function LinearAlgebra.generic_matvecmul!(C::oneVector{T}, tA::AbstractChar, A::oneSparseMatrixCSC{T}, B::oneVector{T}, _add::MulAddMul) where {T <: BlasReal}
1111
tA = tA in ('S', 's', 'H', 'h') ? 'T' : (tA == 'N' ? 'T' : 'N')
12-
sparse_gemv!(tA, _add.alpha, A, B, _add.beta, C)
12+
return sparse_gemv!(tA, _add.alpha, A, B, _add.beta, C)
1313
end
1414

1515
function LinearAlgebra.generic_matmatmul!(C::oneMatrix{T}, tA, tB, A::oneSparseMatrixCSR{T}, B::oneMatrix{T}, _add::MulAddMul) where T <: BlasFloat
@@ -18,10 +18,10 @@ function LinearAlgebra.generic_matmatmul!(C::oneMatrix{T}, tA, tB, A::oneSparseM
1818
sparse_gemm!(tA, tB, _add.alpha, A, B, _add.beta, C)
1919
end
2020

21-
function LinearAlgebra.generic_matmatmul!(C::oneMatrix{T}, tA, tB, A::oneSparseMatrixCSC{T}, B::oneMatrix{T}, _add::MulAddMul) where T <: BlasReal
21+
function LinearAlgebra.generic_matmatmul!(C::oneMatrix{T}, tA, tB, A::oneSparseMatrixCSC{T}, B::oneMatrix{T}, _add::MulAddMul) where {T <: BlasReal}
2222
tA = tA in ('S', 's', 'H', 'h') ? 'T' : (tA == 'N' ? 'T' : 'N')
2323
tB = tB in ('S', 's', 'H', 'h') ? 'N' : tB
24-
sparse_gemm!(tA, tB, _add.alpha, A, B, _add.beta, C)
24+
return sparse_gemm!(tA, tB, _add.alpha, A, B, _add.beta, C)
2525
end
2626

2727
for SparseMatrixType in (:oneSparseMatrixCSR,)

lib/mkl/wrappers_sparse.jl

Lines changed: 143 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ for (fname, elty, intty) in ((:onemklSsparse_set_csr_data , :Float32 , :Int3
4646
nnzA = length(A.nzval)
4747
queue = global_queue(context(nzVal), device())
4848
$fname(sycl_queue(queue), handle_ptr[], n, m, 'O', colPtr, rowVal, nzVal) # CSC of A is CSR of Aᵀ
49-
dA = oneSparseMatrixCSC{$elty, $intty}(handle_ptr[], colPtr, rowVal, nzVal, (m,n), nnzA)
49+
dA = oneSparseMatrixCSC{$elty, $intty}(handle_ptr[], colPtr, rowVal, nzVal, (m, n), nnzA)
5050
finalizer(sparse_release_matrix_handle, dA)
5151
return dA
5252
end
@@ -122,17 +122,21 @@ for SparseMatrix in (:oneSparseMatrixCSR, :oneSparseMatrixCOO)
122122
end
123123

124124
# Special handling for CSC matrices since they are stored as transposed CSR
125-
for (fname, elty) in ((:onemklSsparse_gemv, :Float32),
126-
(:onemklDsparse_gemv, :Float64),
127-
(:onemklCsparse_gemv, :ComplexF32),
128-
(:onemklZsparse_gemv, :ComplexF64))
125+
for (fname, elty) in (
126+
(:onemklSsparse_gemv, :Float32),
127+
(:onemklDsparse_gemv, :Float64),
128+
(:onemklCsparse_gemv, :ComplexF32),
129+
(:onemklZsparse_gemv, :ComplexF64),
130+
)
129131
@eval begin
130-
function sparse_gemv!(trans::Char,
131-
alpha::Number,
132-
A::oneSparseMatrixCSC{$elty},
133-
x::oneStridedVector{$elty},
134-
beta::Number,
135-
y::oneStridedVector{$elty})
132+
function sparse_gemv!(
133+
trans::Char,
134+
alpha::Number,
135+
A::oneSparseMatrixCSC{$elty},
136+
x::oneStridedVector{$elty},
137+
beta::Number,
138+
y::oneStridedVector{$elty}
139+
)
136140

137141
# CSC(A) is represented by storing CSR(A^T). Map operations accordingly:
138142
# - trans = 'N': want A*x -> use op(S)='T' with S=A^T.
@@ -234,18 +238,22 @@ function sparse_optimize_gemm!(trans::Char, transB::Char, nrhs::Int, A::oneSpars
234238
end
235239

236240
# Special handling for CSC matrices since they are stored as transposed CSR (S = A^T)
237-
for (fname, elty) in ((:onemklSsparse_gemm, :Float32),
238-
(:onemklDsparse_gemm, :Float64),
239-
(:onemklCsparse_gemm, :ComplexF32),
240-
(:onemklZsparse_gemm, :ComplexF64))
241+
for (fname, elty) in (
242+
(:onemklSsparse_gemm, :Float32),
243+
(:onemklDsparse_gemm, :Float64),
244+
(:onemklCsparse_gemm, :ComplexF32),
245+
(:onemklZsparse_gemm, :ComplexF64),
246+
)
241247
@eval begin
242-
function sparse_gemm!(transa::Char,
243-
transb::Char,
244-
alpha::Number,
245-
A::oneSparseMatrixCSC{$elty},
246-
B::oneStridedMatrix{$elty},
247-
beta::Number,
248-
C::oneStridedMatrix{$elty})
248+
function sparse_gemm!(
249+
transa::Char,
250+
transb::Char,
251+
alpha::Number,
252+
A::oneSparseMatrixCSC{$elty},
253+
B::oneStridedMatrix{$elty},
254+
beta::Number,
255+
C::oneStridedMatrix{$elty}
256+
)
249257

250258
# Map op(A) to op(S) where S = A^T stored as CSR in the handle
251259
# transa: 'N' -> op(S)='T'; 'T' -> op(S)='N'; 'C' ->
@@ -257,8 +265,8 @@ for (fname, elty) in ((:onemklSsparse_gemm, :Float32),
257265
(nB != nC) && (transb == 'N') && throw(ArgumentError("B and C must have the same number of columns."))
258266
(mB != nC) && (transb != 'N') && throw(ArgumentError("Bᵀ and C must have the same number of columns."))
259267
nrhs = size(B, 2)
260-
ldb = max(1,stride(B,2))
261-
ldc = max(1,stride(C,2))
268+
ldb = max(1, stride(B, 2))
269+
ldc = max(1, stride(C, 2))
262270

263271
queue = global_queue(context(C), device())
264272

@@ -362,17 +370,21 @@ for (fname, elty) in ((:onemklSsparse_symv, :Float32),
362370
end
363371

364372
# Special handling for CSC matrices since they are stored as transposed CSR
365-
for (fname, elty) in ((:onemklSsparse_symv, :Float32),
366-
(:onemklDsparse_symv, :Float64),
367-
(:onemklCsparse_symv, :ComplexF32),
368-
(:onemklZsparse_symv, :ComplexF64))
373+
for (fname, elty) in (
374+
(:onemklSsparse_symv, :Float32),
375+
(:onemklDsparse_symv, :Float64),
376+
(:onemklCsparse_symv, :ComplexF32),
377+
(:onemklZsparse_symv, :ComplexF64),
378+
)
369379
@eval begin
370-
function sparse_symv!(uplo::Char,
371-
alpha::Number,
372-
A::oneSparseMatrixCSC{$elty},
373-
x::oneStridedVector{$elty},
374-
beta::Number,
375-
y::oneStridedVector{$elty})
380+
function sparse_symv!(
381+
uplo::Char,
382+
alpha::Number,
383+
A::oneSparseMatrixCSC{$elty},
384+
x::oneStridedVector{$elty},
385+
beta::Number,
386+
y::oneStridedVector{$elty}
387+
)
376388

377389
# CSC(A) is represented by storing CSR(A^T). For symmetric matrices:
378390
# If A is symmetric, then A^T is also symmetric.
@@ -382,7 +394,7 @@ for (fname, elty) in ((:onemklSsparse_symv, :Float32),
382394

383395
queue = global_queue(context(y), device())
384396
$fname(sycl_queue(queue), actual_uplo, alpha, A.handle, x, beta, y)
385-
y
397+
return y
386398
end
387399
end
388400
end
@@ -409,26 +421,34 @@ for (fname, elty) in ((:onemklSsparse_trmv, :Float32),
409421
end
410422

411423
# Special handling for CSC matrices since they are stored as transposed CSR
412-
for (fname, elty) in ((:onemklSsparse_trmv, :Float32),
413-
(:onemklDsparse_trmv, :Float64),
414-
(:onemklCsparse_trmv, :ComplexF32),
415-
(:onemklZsparse_trmv, :ComplexF64))
424+
for (fname, elty) in (
425+
(:onemklSsparse_trmv, :Float32),
426+
(:onemklDsparse_trmv, :Float64),
427+
(:onemklCsparse_trmv, :ComplexF32),
428+
(:onemklZsparse_trmv, :ComplexF64),
429+
)
416430
@eval begin
417-
function sparse_trmv!(uplo::Char,
418-
trans::Char,
419-
diag::Char,
420-
alpha::Number,
421-
A::oneSparseMatrixCSC{$elty},
422-
x::oneStridedVector{$elty},
423-
beta::Number,
424-
y::oneStridedVector{$elty})
431+
function sparse_trmv!(
432+
uplo::Char,
433+
trans::Char,
434+
diag::Char,
435+
alpha::Number,
436+
A::oneSparseMatrixCSC{$elty},
437+
x::oneStridedVector{$elty},
438+
beta::Number,
439+
y::oneStridedVector{$elty}
440+
)
425441

426442
# Intel oneAPI sparse trmv only supports nontrans operations.
427443
# Since CSC(A) is stored as CSR(A^T), we cannot map CSC operations
428444
# to CSR operations for triangular operations without transpose support.
429-
throw(ArgumentError("sparse_trmv! is not supported for oneSparseMatrixCSC due to Intel oneAPI limitations. " *
430-
"Intel sparse library only supports nontrans operations for triangular matrix operations. " *
431-
"Convert to oneSparseMatrixCSR format instead."))
445+
throw(
446+
ArgumentError(
447+
"sparse_trmv! is not supported for oneSparseMatrixCSC due to Intel oneAPI limitations. " *
448+
"Intel sparse library only supports nontrans operations for triangular matrix operations. " *
449+
"Convert to oneSparseMatrixCSR format instead."
450+
)
451+
)
432452
end
433453
end
434454
end
@@ -460,25 +480,33 @@ for (fname, elty) in ((:onemklSsparse_trsv, :Float32),
460480
end
461481

462482
# Special handling for CSC matrices since they are stored as transposed CSR
463-
for (fname, elty) in ((:onemklSsparse_trsv, :Float32),
464-
(:onemklDsparse_trsv, :Float64),
465-
(:onemklCsparse_trsv, :ComplexF32),
466-
(:onemklZsparse_trsv, :ComplexF64))
483+
for (fname, elty) in (
484+
(:onemklSsparse_trsv, :Float32),
485+
(:onemklDsparse_trsv, :Float64),
486+
(:onemklCsparse_trsv, :ComplexF32),
487+
(:onemklZsparse_trsv, :ComplexF64),
488+
)
467489
@eval begin
468-
function sparse_trsv!(uplo::Char,
469-
trans::Char,
470-
diag::Char,
471-
alpha::Number,
472-
A::oneSparseMatrixCSC{$elty},
473-
x::oneStridedVector{$elty},
474-
y::oneStridedVector{$elty})
490+
function sparse_trsv!(
491+
uplo::Char,
492+
trans::Char,
493+
diag::Char,
494+
alpha::Number,
495+
A::oneSparseMatrixCSC{$elty},
496+
x::oneStridedVector{$elty},
497+
y::oneStridedVector{$elty}
498+
)
475499

476500
# Intel oneAPI sparse trsv only supports nontrans operations.
477501
# Since CSC(A) is stored as CSR(A^T), we cannot map CSC operations
478502
# to CSR operations for triangular solve operations without transpose support.
479-
throw(ArgumentError("sparse_trsv! is not supported for oneSparseMatrixCSC due to Intel oneAPI limitations. " *
480-
"Intel sparse library only supports nontrans operations for triangular matrix operations. " *
481-
"Convert to oneSparseMatrixCSR format instead."))
503+
throw(
504+
ArgumentError(
505+
"sparse_trsv! is not supported for oneSparseMatrixCSC due to Intel oneAPI limitations. " *
506+
"Intel sparse library only supports nontrans operations for triangular matrix operations. " *
507+
"Convert to oneSparseMatrixCSR format instead."
508+
)
509+
)
482510
end
483511
end
484512
end
@@ -520,26 +548,34 @@ for (fname, elty) in ((:onemklSsparse_trsm, :Float32),
520548
end
521549

522550
# Special handling for CSC matrices since they are stored as transposed CSR
523-
for (fname, elty) in ((:onemklSsparse_trsm, :Float32),
524-
(:onemklDsparse_trsm, :Float64),
525-
(:onemklCsparse_trsm, :ComplexF32),
526-
(:onemklZsparse_trsm, :ComplexF64))
551+
for (fname, elty) in (
552+
(:onemklSsparse_trsm, :Float32),
553+
(:onemklDsparse_trsm, :Float64),
554+
(:onemklCsparse_trsm, :ComplexF32),
555+
(:onemklZsparse_trsm, :ComplexF64),
556+
)
527557
@eval begin
528-
function sparse_trsm!(uplo::Char,
529-
transA::Char,
530-
transX::Char,
531-
diag::Char,
532-
alpha::Number,
533-
A::oneSparseMatrixCSC{$elty},
534-
X::oneStridedMatrix{$elty},
535-
Y::oneStridedMatrix{$elty})
558+
function sparse_trsm!(
559+
uplo::Char,
560+
transA::Char,
561+
transX::Char,
562+
diag::Char,
563+
alpha::Number,
564+
A::oneSparseMatrixCSC{$elty},
565+
X::oneStridedMatrix{$elty},
566+
Y::oneStridedMatrix{$elty}
567+
)
536568

537569
# Intel oneAPI sparse trsm only supports nontrans operations for the matrix A.
538570
# Since CSC(A) is stored as CSR(A^T), we cannot map CSC operations
539571
# to CSR operations for triangular solve operations without transpose support.
540-
throw(ArgumentError("sparse_trsm! is not supported for oneSparseMatrixCSC due to Intel oneAPI limitations. " *
541-
"Intel sparse library only supports nontrans operations for triangular matrix operations. " *
542-
"Convert to oneSparseMatrixCSR format instead."))
572+
throw(
573+
ArgumentError(
574+
"sparse_trsm! is not supported for oneSparseMatrixCSC due to Intel oneAPI limitations. " *
575+
"Intel sparse library only supports nontrans operations for triangular matrix operations. " *
576+
"Convert to oneSparseMatrixCSR format instead."
577+
)
578+
)
543579
end
544580
end
545581
end
@@ -560,31 +596,47 @@ end
560596
function sparse_optimize_trmv!(uplo::Char, trans::Char, diag::Char, A::oneSparseMatrixCSC)
561597
# Intel oneAPI sparse trmv only supports nontrans operations.
562598
# Since CSC(A) is stored as CSR(A^T), triangular operations are not supported for CSC format.
563-
throw(ArgumentError("sparse_optimize_trmv! is not supported for oneSparseMatrixCSC due to Intel oneAPI limitations. " *
564-
"Intel sparse library only supports nontrans operations for triangular matrix operations. " *
565-
"Convert to oneSparseMatrixCSR format instead."))
599+
throw(
600+
ArgumentError(
601+
"sparse_optimize_trmv! is not supported for oneSparseMatrixCSC due to Intel oneAPI limitations. " *
602+
"Intel sparse library only supports nontrans operations for triangular matrix operations. " *
603+
"Convert to oneSparseMatrixCSR format instead."
604+
)
605+
)
566606
end
567607

568608
function sparse_optimize_trsv!(uplo::Char, trans::Char, diag::Char, A::oneSparseMatrixCSC)
569609
# Intel oneAPI sparse trsv only supports nontrans operations.
570610
# Since CSC(A) is stored as CSR(A^T), triangular operations are not supported for CSC format.
571-
throw(ArgumentError("sparse_optimize_trsv! is not supported for oneSparseMatrixCSC due to Intel oneAPI limitations. " *
572-
"Intel sparse library only supports nontrans operations for triangular matrix operations. " *
573-
"Convert to oneSparseMatrixCSR format instead."))
611+
throw(
612+
ArgumentError(
613+
"sparse_optimize_trsv! is not supported for oneSparseMatrixCSC due to Intel oneAPI limitations. " *
614+
"Intel sparse library only supports nontrans operations for triangular matrix operations. " *
615+
"Convert to oneSparseMatrixCSR format instead."
616+
)
617+
)
574618
end
575619

576620
function sparse_optimize_trsm!(uplo::Char, trans::Char, diag::Char, A::oneSparseMatrixCSC)
577621
# Intel oneAPI sparse trsm only supports nontrans operations.
578622
# Since CSC(A) is stored as CSR(A^T), triangular operations are not supported for CSC format.
579-
throw(ArgumentError("sparse_optimize_trsm! is not supported for oneSparseMatrixCSC due to Intel oneAPI limitations. " *
580-
"Intel sparse library only supports nontrans operations for triangular matrix operations. " *
581-
"Convert to oneSparseMatrixCSR format instead."))
623+
throw(
624+
ArgumentError(
625+
"sparse_optimize_trsm! is not supported for oneSparseMatrixCSC due to Intel oneAPI limitations. " *
626+
"Intel sparse library only supports nontrans operations for triangular matrix operations. " *
627+
"Convert to oneSparseMatrixCSR format instead."
628+
)
629+
)
582630
end
583631

584632
function sparse_optimize_trsm!(uplo::Char, trans::Char, diag::Char, nrhs::Int, A::oneSparseMatrixCSC)
585633
# Intel oneAPI sparse trsm only supports nontrans operations.
586634
# Since CSC(A) is stored as CSR(A^T), triangular operations are not supported for CSC format.
587-
throw(ArgumentError("sparse_optimize_trsm! is not supported for oneSparseMatrixCSC due to Intel oneAPI limitations. " *
588-
"Intel sparse library only supports nontrans operations for triangular matrix operations. " *
589-
"Convert to oneSparseMatrixCSR format instead."))
635+
throw(
636+
ArgumentError(
637+
"sparse_optimize_trsm! is not supported for oneSparseMatrixCSC due to Intel oneAPI limitations. " *
638+
"Intel sparse library only supports nontrans operations for triangular matrix operations. " *
639+
"Convert to oneSparseMatrixCSR format instead."
640+
)
641+
)
590642
end

0 commit comments

Comments
 (0)