Skip to content

Commit fd94b4e

Browse files
vchuravyKristofferC
authored andcommitted
Adjust calling convention of LAPACK functions (#38836)
* Adjust calling convetion of dgebal and co * Adjust calling convention of BLAS & LAPACK (cherry picked from commit 9f4a807)
1 parent 10f699e commit fd94b4e

File tree

2 files changed

+283
-239
lines changed

2 files changed

+283
-239
lines changed

stdlib/LinearAlgebra/src/blas.jl

Lines changed: 54 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -704,10 +704,10 @@ for (fname, elty) in ((:dgemv_,:Float64),
704704
ccall((@blasfunc($fname), libblas), Cvoid,
705705
(Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elty},
706706
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
707-
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}),
707+
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}, Clong),
708708
trans, size(A,1), size(A,2), alpha,
709709
A, max(1,stride(A,2)), X, stride(X,1),
710-
beta, Y, stride(Y,1))
710+
beta, Y, stride(Y,1), 1)
711711
Y
712712
end
713713
function gemv(trans::AbstractChar, alpha::($elty), A::AbstractMatrix{$elty}, X::AbstractVector{$elty})
@@ -785,10 +785,10 @@ for (fname, elty) in ((:dgbmv_,:Float64),
785785
(Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{BlasInt},
786786
Ref{BlasInt}, Ref{$elty}, Ptr{$elty}, Ref{BlasInt},
787787
Ptr{$elty}, Ref{BlasInt}, Ref{$elty}, Ptr{$elty},
788-
Ref{BlasInt}),
788+
Ref{BlasInt}, Clong),
789789
trans, m, size(A,2), kl,
790790
ku, alpha, A, max(1,stride(A,2)),
791-
x, stride(x,1), beta, y, stride(y,1))
791+
x, stride(x,1), beta, y, stride(y,1), 1)
792792
y
793793
end
794794
function gbmv(trans::AbstractChar, m::Integer, kl::Integer, ku::Integer, alpha::($elty), A::AbstractMatrix{$elty}, x::AbstractVector{$elty})
@@ -844,10 +844,10 @@ for (fname, elty, lib) in ((:dsymv_,:Float64,libblas),
844844
ccall((@blasfunc($fname), $lib), Cvoid,
845845
(Ref{UInt8}, Ref{BlasInt}, Ref{$elty}, Ptr{$elty},
846846
Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}, Ref{$elty},
847-
Ptr{$elty}, Ref{BlasInt}),
847+
Ptr{$elty}, Ref{BlasInt}, Clong),
848848
uplo, n, alpha, A,
849849
max(1,stride(A,2)), x, stride(x,1), beta,
850-
y, stride(y,1))
850+
y, stride(y,1), 1)
851851
y
852852
end
853853
function symv(uplo::AbstractChar, alpha::($elty), A::AbstractMatrix{$elty}, x::AbstractVector{$elty})
@@ -908,10 +908,10 @@ for (fname, elty) in ((:zhemv_,:ComplexF64),
908908
ccall((@blasfunc($fname), libblas), Cvoid,
909909
(Ref{UInt8}, Ref{BlasInt}, Ref{$elty}, Ptr{$elty},
910910
Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}, Ref{$elty},
911-
Ptr{$elty}, Ref{BlasInt}),
911+
Ptr{$elty}, Ref{BlasInt}, Clong),
912912
uplo, n, α, A,
913913
lda, x, incx, β,
914-
y, incy)
914+
y, incy, 1)
915915
y
916916
end
917917
function hemv(uplo::AbstractChar, α::($elty), A::AbstractMatrix{$elty}, x::AbstractVector{$elty})
@@ -971,7 +971,8 @@ for (fname, elty) in ((:zhpmv_, :ComplexF64),
971971
Ref{BlasInt}, # incx,
972972
Ref{$elty}, # β,
973973
Ptr{$elty}, # y, output
974-
Ref{BlasInt}), # incy
974+
Ref{BlasInt}, # incy
975+
Clong), # length of uplo
975976
uplo,
976977
n,
977978
α,
@@ -980,7 +981,8 @@ for (fname, elty) in ((:zhpmv_, :ComplexF64),
980981
incx,
981982
β,
982983
y,
983-
incy)
984+
incy,
985+
1)
984986
return y
985987
end
986988
end
@@ -1041,10 +1043,10 @@ for (fname, elty) in ((:dsbmv_,:Float64),
10411043
ccall((@blasfunc($fname), libblas), Cvoid,
10421044
(Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elty},
10431045
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
1044-
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}),
1046+
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}, Clong),
10451047
uplo, size(A,2), k, alpha,
10461048
A, max(1,stride(A,2)), x, stride(x,1),
1047-
beta, y, stride(y,1))
1049+
beta, y, stride(y,1), 1)
10481050
y
10491051
end
10501052
function sbmv(uplo::AbstractChar, k::Integer, alpha::($elty), A::AbstractMatrix{$elty}, x::AbstractVector{$elty})
@@ -1119,7 +1121,8 @@ for (fname, elty) in ((:dspmv_, :Float64),
11191121
Ref{BlasInt}, # incx,
11201122
Ref{$elty}, # β,
11211123
Ptr{$elty}, # y, out
1122-
Ref{BlasInt}), # incy
1124+
Ref{BlasInt}, # incy
1125+
Clong), # length of uplo
11231126
uplo,
11241127
n,
11251128
α,
@@ -1128,7 +1131,8 @@ for (fname, elty) in ((:dspmv_, :Float64),
11281131
incx,
11291132
β,
11301133
y,
1131-
incy)
1134+
incy,
1135+
1)
11321136
return y
11331137
end
11341138
end
@@ -1189,10 +1193,10 @@ for (fname, elty) in ((:zhbmv_,:ComplexF64),
11891193
ccall((@blasfunc($fname), libblas), Cvoid,
11901194
(Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elty},
11911195
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
1192-
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}),
1196+
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}, Clong),
11931197
uplo, size(A,2), k, alpha,
11941198
A, max(1,stride(A,2)), x, stride(x,1),
1195-
beta, y, stride(y,1))
1199+
beta, y, stride(y,1), 1)
11961200
y
11971201
end
11981202
function hbmv(uplo::AbstractChar, k::Integer, alpha::($elty), A::AbstractMatrix{$elty}, x::AbstractVector{$elty})
@@ -1248,9 +1252,10 @@ for (fname, elty) in ((:dtrmv_,:Float64),
12481252
chkstride1(A)
12491253
ccall((@blasfunc($fname), libblas), Cvoid,
12501254
(Ref{UInt8}, Ref{UInt8}, Ref{UInt8}, Ref{BlasInt},
1251-
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}),
1255+
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
1256+
Clong, Clong, Clong),
12521257
uplo, trans, diag, n,
1253-
A, max(1,stride(A,2)), x, max(1,stride(x, 1)))
1258+
A, max(1,stride(A,2)), x, max(1,stride(x, 1)), 1, 1, 1)
12541259
x
12551260
end
12561261
function trmv(uplo::AbstractChar, trans::AbstractChar, diag::AbstractChar, A::AbstractMatrix{$elty}, x::AbstractVector{$elty})
@@ -1302,9 +1307,10 @@ for (fname, elty) in ((:dtrsv_,:Float64),
13021307
chkstride1(A)
13031308
ccall((@blasfunc($fname), libblas), Cvoid,
13041309
(Ref{UInt8}, Ref{UInt8}, Ref{UInt8}, Ref{BlasInt},
1305-
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}),
1310+
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
1311+
Clong, Clong, Clong),
13061312
uplo, trans, diag, n,
1307-
A, max(1,stride(A,2)), x, stride(x, 1))
1313+
A, max(1,stride(A,2)), x, stride(x, 1), 1, 1, 1)
13081314
x
13091315
end
13101316
function trsv(uplo::AbstractChar, trans::AbstractChar, diag::AbstractChar, A::AbstractMatrix{$elty}, x::AbstractVector{$elty})
@@ -1398,9 +1404,9 @@ for (fname, elty, relty) in ((:zher_,:ComplexF64, :Float64),
13981404
end
13991405
ccall((@blasfunc($fname), libblas), Cvoid,
14001406
(Ref{UInt8}, Ref{BlasInt}, Ref{$relty}, Ptr{$elty},
1401-
Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}),
1407+
Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}, Clong),
14021408
uplo, n, α, x,
1403-
stride(x, 1), A, max(1,stride(A,2)))
1409+
stride(x, 1), A, max(1,stride(A,2)), 1)
14041410
A
14051411
end
14061412
end
@@ -1453,11 +1459,11 @@ for (gemm, elty) in
14531459
(Ref{UInt8}, Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt},
14541460
Ref{BlasInt}, Ref{$elty}, Ptr{$elty}, Ref{BlasInt},
14551461
Ptr{$elty}, Ref{BlasInt}, Ref{$elty}, Ptr{$elty},
1456-
Ref{BlasInt}),
1462+
Ref{BlasInt}, Clong, Clong),
14571463
transA, transB, m, n,
14581464
ka, alpha, A, max(1,stride(A,2)),
14591465
B, max(1,stride(B,2)), beta, C,
1460-
max(1,stride(C,2)))
1466+
max(1,stride(C,2)), 1, 1)
14611467
C
14621468
end
14631469
function gemm(transA::AbstractChar, transB::AbstractChar, alpha::($elty), A::AbstractMatrix{$elty}, B::AbstractMatrix{$elty})
@@ -1515,10 +1521,12 @@ for (mfname, elty) in ((:dsymm_,:Float64),
15151521
ccall((@blasfunc($mfname), libblas), Cvoid,
15161522
(Ref{UInt8}, Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt},
15171523
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}, Ptr{$elty},
1518-
Ref{BlasInt}, Ref{$elty}, Ptr{$elty}, Ref{BlasInt}),
1524+
Ref{BlasInt}, Ref{$elty}, Ptr{$elty}, Ref{BlasInt},
1525+
Clong, Clong),
15191526
side, uplo, m, n,
15201527
alpha, A, max(1,stride(A,2)), B,
1521-
max(1,stride(B,2)), beta, C, max(1,stride(C,2)))
1528+
max(1,stride(B,2)), beta, C, max(1,stride(C,2)),
1529+
1, 1)
15221530
C
15231531
end
15241532
function symm(side::AbstractChar, uplo::AbstractChar, alpha::($elty), A::AbstractMatrix{$elty}, B::AbstractMatrix{$elty})
@@ -1586,10 +1594,12 @@ for (mfname, elty) in ((:zhemm_,:ComplexF64),
15861594
ccall((@blasfunc($mfname), libblas), Cvoid,
15871595
(Ref{UInt8}, Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt},
15881596
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}, Ptr{$elty},
1589-
Ref{BlasInt}, Ref{$elty}, Ptr{$elty}, Ref{BlasInt}),
1597+
Ref{BlasInt}, Ref{$elty}, Ptr{$elty}, Ref{BlasInt},
1598+
Clong, Clong),
15901599
side, uplo, m, n,
15911600
alpha, A, max(1,stride(A,2)), B,
1592-
max(1,stride(B,2)), beta, C, max(1,stride(C,2)))
1601+
max(1,stride(B,2)), beta, C, max(1,stride(C,2)),
1602+
1, 1)
15931603
C
15941604
end
15951605
function hemm(side::AbstractChar, uplo::AbstractChar, alpha::($elty), A::AbstractMatrix{$elty}, B::AbstractMatrix{$elty})
@@ -1673,10 +1683,10 @@ for (fname, elty) in ((:dsyrk_,:Float64),
16731683
ccall((@blasfunc($fname), libblas), Cvoid,
16741684
(Ref{UInt8}, Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt},
16751685
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}, Ref{$elty},
1676-
Ptr{$elty}, Ref{BlasInt}),
1686+
Ptr{$elty}, Ref{BlasInt}, Clong, Clong),
16771687
uplo, trans, n, k,
16781688
alpha, A, max(1,stride(A,2)), beta,
1679-
C, max(1,stride(C,2)))
1689+
C, max(1,stride(C,2)), 1, 1)
16801690
C
16811691
end
16821692
end
@@ -1731,10 +1741,10 @@ for (fname, elty, relty) in ((:zherk_, :ComplexF64, :Float64),
17311741
ccall((@blasfunc($fname), libblas), Cvoid,
17321742
(Ref{UInt8}, Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt},
17331743
Ref{$relty}, Ptr{$elty}, Ref{BlasInt}, Ref{$relty},
1734-
Ptr{$elty}, Ref{BlasInt}),
1744+
Ptr{$elty}, Ref{BlasInt}, Clong, Clong),
17351745
uplo, trans, n, k,
17361746
α, A, max(1,stride(A,2)), β,
1737-
C, max(1,stride(C,2)))
1747+
C, max(1,stride(C,2)), 1, 1)
17381748
C
17391749
end
17401750
function herk(uplo::AbstractChar, trans::AbstractChar, α::$relty, A::AbstractVecOrMat{$elty})
@@ -1774,10 +1784,10 @@ for (fname, elty) in ((:dsyr2k_,:Float64),
17741784
ccall((@blasfunc($fname), libblas), Cvoid,
17751785
(Ref{UInt8}, Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt},
17761786
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}, Ref{$elty},
1777-
Ptr{$elty}, Ref{BlasInt}),
1787+
Ptr{$elty}, Ref{BlasInt}, Clong, Clong),
17781788
uplo, trans, n, k,
17791789
alpha, A, max(1,stride(A,2)), B, max(1,stride(B,2)), beta,
1780-
C, max(1,stride(C,2)))
1790+
C, max(1,stride(C,2)), 1, 1)
17811791
C
17821792
end
17831793
end
@@ -1841,10 +1851,10 @@ for (fname, elty1, elty2) in ((:zher2k_,:ComplexF64,:Float64), (:cher2k_,:Comple
18411851
ccall((@blasfunc($fname), libblas), Cvoid,
18421852
(Ref{UInt8}, Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt},
18431853
Ref{$elty1}, Ptr{$elty1}, Ref{BlasInt}, Ptr{$elty1}, Ref{BlasInt},
1844-
Ref{$elty2}, Ptr{$elty1}, Ref{BlasInt}),
1854+
Ref{$elty2}, Ptr{$elty1}, Ref{BlasInt}, Clong, Clong),
18451855
uplo, trans, n, k,
18461856
alpha, A, max(1,stride(A,2)), B, max(1,stride(B,2)),
1847-
beta, C, max(1,stride(C,2)))
1857+
beta, C, max(1,stride(C,2)), 1, 1)
18481858
C
18491859
end
18501860
function her2k(uplo::AbstractChar, trans::AbstractChar, alpha::($elty1), A::AbstractVecOrMat{$elty1}, B::AbstractVecOrMat{$elty1})
@@ -1954,9 +1964,11 @@ for (mmname, smname, elty) in
19541964
chkstride1(B)
19551965
ccall((@blasfunc($mmname), libblas), Cvoid,
19561966
(Ref{UInt8}, Ref{UInt8}, Ref{UInt8}, Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt},
1957-
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}),
1967+
Ref{$elty}, Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
1968+
Clong, Clong, Clong, Clong),
19581969
side, uplo, transa, diag, m, n,
1959-
alpha, A, max(1,stride(A,2)), B, max(1,stride(B,2)))
1970+
alpha, A, max(1,stride(A,2)), B, max(1,stride(B,2)),
1971+
1, 1, 1, 1)
19601972
B
19611973
end
19621974
function trmm(side::AbstractChar, uplo::AbstractChar, transa::AbstractChar, diag::AbstractChar,
@@ -1983,10 +1995,12 @@ for (mmname, smname, elty) in
19831995
ccall((@blasfunc($smname), libblas), Cvoid,
19841996
(Ref{UInt8}, Ref{UInt8}, Ref{UInt8}, Ref{UInt8},
19851997
Ref{BlasInt}, Ref{BlasInt}, Ref{$elty}, Ptr{$elty},
1986-
Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}),
1998+
Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt},
1999+
Clong, Clong, Clong, Clong),
19872000
side, uplo, transa, diag,
19882001
m, n, alpha, A,
1989-
max(1,stride(A,2)), B, max(1,stride(B,2)))
2002+
max(1,stride(A,2)), B, max(1,stride(B,2)),
2003+
1, 1, 1, 1)
19902004
B
19912005
end
19922006
function trsm(side::AbstractChar, uplo::AbstractChar, transa::AbstractChar, diag::AbstractChar, alpha::$elty, A::AbstractMatrix{$elty}, B::AbstractMatrix{$elty})

0 commit comments

Comments
 (0)