Skip to content

Commit

Permalink
Some blas/lapack related cosmetic cleanups as part of JuliaLang#1248
Browse files Browse the repository at this point in the history
  • Loading branch information
Viral B. Shah committed Sep 22, 2012
1 parent f7f4a16 commit 35ca186
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 84 deletions.
4 changes: 2 additions & 2 deletions base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ os_detect.jl: ../src/os_detect.h
$(QUIET_PERL) ${CC} -E -P -DJULIA ../src/os_detect.h | perl -p -e 's/\\n/\n/g' > $@

build_h.jl: ../Make.inc
@echo "_jl_libblas_name = \"$(LIBBLASNAME)\"" > $@
@echo "_jl_liblapack_name = \"$(LIBLAPACKNAME)\"" >> $@
@echo "libblas_name = \"$(LIBBLASNAME)\"" > $@
@echo "liblapack_name = \"$(LIBLAPACKNAME)\"" >> $@

clean:
rm -f *# *~
Expand Down
34 changes: 17 additions & 17 deletions base/linalg_blas.jl → base/blas.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
typealias LapackScalar Union(Float64,Float32,Complex128,Complex64)

module BLAS
module Blas
import Base.*

# SUBROUTINE DCOPY(N,DX,INCX,DY,INCY)
for (fname, elty) in ((:dcopy_,:Float64), (:scopy_,:Float32),
(:zcopy_,:Complex128), (:ccopy_,:Complex64))
@eval begin
function copy!(n::Integer, DX::Union(Ptr{$elty},Array{$elty}), incx::Integer, DY::Union(Ptr{$elty},Array{$elty}), incy::Integer)
ccall(dlsym(Base._jl_libblas, $(string(fname))), Void,
ccall(dlsym(Base.libblas, $(string(fname))), Void,
(Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}),
&n, DX, &incx, DY, &incy)
DY
Expand All @@ -23,7 +23,7 @@ end
for (fname, elty) in ((:ddot_,:Float64), (:sdot_,:Float32))
@eval begin
function dot(n::Integer, DX::Union(Ptr{$elty},Array{$elty}), incx::Integer, DY::Union(Ptr{$elty},Array{$elty}), incy::Integer)
ccall(dlsym(Base._jl_libblas, $(string(fname))), $elty,
ccall(dlsym(Base.libblas, $(string(fname))), $elty,
(Ptr{Int32}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}),
&n, DX, &incx, DY, &incy)
end
Expand All @@ -37,7 +37,7 @@ for (fname, elty, ret_type) in ((:dnrm2_,:Float64,:Float64),
(:scnrm2_,:Complex64,:Float32))
@eval begin
function nrm2(n::Integer, X::Union(Ptr{$elty},Array{$elty}), incx::Integer)
ccall(dlsym(Base._jl_libblas, $(string(fname))), $ret_type,
ccall(dlsym(Base.libblas, $(string(fname))), $ret_type,
(Ptr{Int32}, Ptr{$elty}, Ptr{Int32}),
&n, X, &incx)
end
Expand All @@ -57,7 +57,7 @@ for (fname, elty) in ((:daxpy_,:Float64), (:saxpy_,:Float32),
function axpy!(n::Integer, a::($elty),
DX::Union(Ptr{$elty},Array{$elty}), incx::Integer,
DY::Union(Ptr{$elty},Array{$elty}), incy::Integer)
ccall(dlsym(Base._jl_libblas, $(string(fname))), Void,
ccall(dlsym(Base.libblas, $(string(fname))), Void,
(Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32}),
&n, &a, DX, &incx, DY, &incy)
DY
Expand All @@ -83,7 +83,7 @@ for (fname, elty) in ((:dsyrk_,:Float64), (:ssyrk_,:Float32),
nn = size(A, trans == 'N' ? 1 : 2)
if nn != n error("syrk!: dimension mismatch") end
k = size(A, trans == 'N' ? 2 : 1)
ccall(dlsym(Base._jl_libblas, $(string(fname))), Void,
ccall(dlsym(Base.libblas, $(string(fname))), Void,
(Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty},
Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}),
&uplo, &trans, &n, &k, &alpha, A, &stride(A,2), &beta, C, &stride(C,2))
Expand All @@ -93,7 +93,7 @@ for (fname, elty) in ((:dsyrk_,:Float64), (:ssyrk_,:Float32),
n = size(A, trans == 'N' ? 1 : 2)
k = size(A, trans == 'N' ? 2 : 1)
C = Array($elty, (n, n))
ccall(dlsym(Base._jl_libblas, $(string(fname))), Void,
ccall(dlsym(Base.libblas, $(string(fname))), Void,
(Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty},
Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}),
&uplo, &trans, &n, &k, &alpha, A, &stride(A,2), &0., C, &stride(C,2))
Expand All @@ -119,7 +119,7 @@ for (fname, elty) in ((:zherk_,:Complex128), (:cherk_,:Complex64))
nn = size(A, trans == 'N' ? 1 : 2)
if nn != n error("syrk!: dimension mismatch") end
k = size(A, trans == 'N' ? 2 : 1)
ccall(dlsym(Base._jl_libblas, $(string(fname))), Void,
ccall(dlsym(Base.libblas, $(string(fname))), Void,
(Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty},
Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}),
&uplo, &trans, &n, &k, &alpha, A, &stride(A,2), &beta, C, &stride(C,2))
Expand All @@ -129,7 +129,7 @@ for (fname, elty) in ((:zherk_,:Complex128), (:cherk_,:Complex64))
n = size(A, trans == 'N' ? 1 : 2)
k = size(A, trans == 'N' ? 2 : 1)
C = Array($elty, (n, n))
ccall(dlsym(Base._jl_libblas, $(string(fname))), Void,
ccall(dlsym(Base.libblas, $(string(fname))), Void,
(Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty},
Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}),
&uplo, &trans, &n, &k, &alpha, A, &stride(A,2), &0., C, &stride(C,2))
Expand All @@ -153,7 +153,7 @@ for (fname, elty) in ((:dgbmv_,:Float64), (:sgbmv_,:Float32),
function gbmv!(trans, m::Integer, kl::Integer, ku::Integer,
alpha::($elty), A::StridedMatrix{$elty}, x::StridedVector{$elty},
beta::($elty), y::StridedVector{$elty})
ccall(dlsym(Base._jl_libblas, $(string(fname))), Void,
ccall(dlsym(Base.libblas, $(string(fname))), Void,
(Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{Int32}, Ptr{Int32},
Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32},
Ptr{$elty}, Ptr{$elty}, Ptr{Int32}),
Expand All @@ -165,7 +165,7 @@ for (fname, elty) in ((:dgbmv_,:Float64), (:sgbmv_,:Float32),
alpha::($elty), A::StridedMatrix{$elty}, x::StridedVector{$elty})
n = stride(A,2)
y = Array($elty, n)
ccall(dlsym(Base._jl_libblas, $(string(fname))), Void,
ccall(dlsym(Base.libblas, $(string(fname))), Void,
(Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{Int32}, Ptr{Int32},
Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32},
Ptr{$elty}, Ptr{$elty}, Ptr{Int32}),
Expand All @@ -192,7 +192,7 @@ for (fname, elty) in ((:dsbmv_,:Float64), (:ssbmv_,:Float32),
function sbmv!(uplo, k::Integer,
alpha::($elty), A::StridedMatrix{$elty}, x::StridedVector{$elty},
beta::($elty), y::StridedVector{$elty})
ccall(dlsym(Base._jl_libblas, $(string(fname))), Void,
ccall(dlsym(Base.libblas, $(string(fname))), Void,
(Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32},
Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}),
&uplo, &size(A,2), &k, &alpha, A, &stride(A,2), x, &stride(x,1), &beta, y, &stride(y,1))
Expand All @@ -202,7 +202,7 @@ for (fname, elty) in ((:dsbmv_,:Float64), (:ssbmv_,:Float32),
x::StridedVector{$elty})
n = size(A,2)
y = Array($elty, n)
ccall(dlsym(Base._jl_libblas, $(string(fname))), Void,
ccall(dlsym(Base.libblas, $(string(fname))), Void,
(Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32},
Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}),
&uplo, &size(A,2), &k, &alpha, A, &stride(A,2), x, &stride(x,1), &0., y, &1)
Expand All @@ -228,7 +228,7 @@ for (fname, elty) in ((:dgemm_,:Float64), (:sgemm_,:Float32),
k = size(A, transA == 'N' ? 2 : 1)
n = size(B, transB == 'N' ? 2 : 1)
if m != size(C,1) || n != size(C,2) error("gemm!: mismatched dimensions") end
ccall(dlsym(Base._jl_libblas, $(string(fname))), Void,
ccall(dlsym(Base.libblas, $(string(fname))), Void,
(Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{Int32},
Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32},
Ptr{$elty}, Ptr{$elty}, Ptr{Int32}),
Expand All @@ -242,7 +242,7 @@ for (fname, elty) in ((:dgemm_,:Float64), (:sgemm_,:Float32),
if k != size(B, transB == 'N' ? 1 : 2) error("gemm!: mismatched dimensions") end
n = size(B, transB == 'N' ? 2 : 1)
C = Array($elty, (m, n))
ccall(dlsym(Base._jl_libblas, $(string(fname))), Void,
ccall(dlsym(Base.libblas, $(string(fname))), Void,
(Ptr{Uint8}, Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{Int32},
Ptr{$elty}, Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{Int32},
Ptr{$elty}, Ptr{$elty}, Ptr{Int32}),
Expand All @@ -266,7 +266,7 @@ for (fname, elty) in ((:dgemv_,:Float64), (:sgemv_,:Float32),
@eval begin
function gemv!(trans, alpha::($elty), A::StridedMatrix{$elty},
X::StridedVector{$elty}, beta::($elty), Y::StridedVector{$elty})
ccall(dlsym(Base._jl_libblas, $(string(fname))), Void,
ccall(dlsym(Base.libblas, $(string(fname))), Void,
(Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32},
Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}),
&trans, &size(A,1), &size(A,2), &alpha, A, &stride(A,2),
Expand All @@ -275,7 +275,7 @@ for (fname, elty) in ((:dgemv_,:Float64), (:sgemv_,:Float32),
end
function gemv!(trans, alpha::($elty), A::StridedMatrix{$elty}, X::StridedVector{$elty})
Y = Array($elty, size(A,1))
ccall(dlsym(Base._jl_libblas, $(string(fname))), Void,
ccall(dlsym(Base.libblas, $(string(fname))), Void,
(Ptr{Uint8}, Ptr{Int32}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32},
Ptr{$elty}, Ptr{Int32}, Ptr{$elty}, Ptr{$elty}, Ptr{Int32}),
&trans, &size(A,1), &size(A,2), &alpha, A, &stride(A,2),
Expand Down
2 changes: 1 addition & 1 deletion base/export.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export
FFTW,
DSP,
Lapack,
BLAS,
Blas,

# Types
AbstractMatrix,
Expand Down
2 changes: 1 addition & 1 deletion base/factorizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ abstract Factorization{T}
## LD for BunchKaufman, LR for CholeskyDense, LU for LUDense and
## define size methods for Factorization types using it.

## merge symmetrize with _jl_copy_upper_to_lower in linalg_blas.jl
## merge symmetrize with _jl_copy_upper_to_lower in blas.jl
## maybe another function makehermitian and use conj for complex
function symmetrize!(A::AbstractMatrix, upper::Bool)
m, n = size(A)
Expand Down
Loading

0 comments on commit 35ca186

Please sign in to comment.