From 3b56898135ea19dfc28c891989babf75945865d4 Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Tue, 23 May 2017 18:39:23 -0700 Subject: [PATCH] Actually everything works with 0.5 too --- REQUIRE | 3 ++- src/libcusparse_types.jl | 55 ++++++++++++++++++++-------------------- src/util.jl | 23 +++++++++-------- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/REQUIRE b/REQUIRE index e0c630c..28c0472 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1,3 @@ -julia 0.6- +julia 0.5 CUDArt +Compat diff --git a/src/libcusparse_types.jl b/src/libcusparse_types.jl index 0119bf4..a33c275 100644 --- a/src/libcusparse_types.jl +++ b/src/libcusparse_types.jl @@ -1,10 +1,12 @@ +using Compat + #enum cusparseStatus_t #error messages from CUSPARSE """ Status messages from CUSPARSE's C API. """ -const cusparseStatus_t = UInt32 +@compat const cusparseStatus_t = UInt32 const CUSPARSE_STATUS_SUCCESS = 0 const CUSPARSE_STATUS_NOT_INITIALIZED = 1 const CUSPARSE_STATUS_ALLOC_FAILED = 2 @@ -21,7 +23,7 @@ Perform operation on indices only (`CUSPARSE_ACTION_SYMBOLIC`) or on both data and indices (`CUSPARSE_ACTION_NUMERIC`). Used in conversion routines. """ -const cusparseAction_t = UInt32 +@compat const cusparseAction_t = UInt32 const CUSPARSE_ACTION_SYMBOLIC = 0 const CUSPARSE_ACTION_NUMERIC = 1 @@ -30,7 +32,7 @@ const CUSPARSE_ACTION_NUMERIC = 1 Parse dense matrix by rows (`CUSPARSE_DIRECTION_ROW`) or columns (`CUSPARSE_DIRECTION_COL`) to compute its number of non-zeros. """ -const cusparseDirection_t = UInt32 +@compat const cusparseDirection_t = UInt32 const CUSPARSE_DIRECTION_ROW = 0 const CUSPARSE_DIRECTION_COL = 1 @@ -42,8 +44,7 @@ There are three choices: * `CUSPARSE_HYB_PARTITION_USER` - set the partition manually in the conversion function. * `CUSPARSE_HYB_PARTITION_MAX` - use the maximum partition, putting the matrix in ELL format. """ -# how to partition the HYB matrix -const cusparseHybPartition_t = UInt32 +@compat const cusparseHybPartition_t = UInt32 const CUSPARSE_HYB_PARTITION_AUTO = 0 const CUSPARSE_HYB_PARTITION_USER = 1 const CUSPARSE_HYB_PARTITION_MAX = 2 @@ -54,7 +55,7 @@ Determines if a symmetric/Hermitian/triangular matrix has its upper (`CUSPARSE_FILL_MODE_UPPER`) or lower (`CUSPARSE_FILL_MODE_LOWER`) triangle filled. """ -const cusparseFillMode_t = UInt32 +@compat const cusparseFillMode_t = UInt32 const CUSPARSE_FILL_MODE_LOWER = 0 const CUSPARSE_FILL_MODE_UPPER = 1 @@ -63,7 +64,7 @@ const CUSPARSE_FILL_MODE_UPPER = 1 Determines if the diagonal of a matrix is all ones (`CUSPARSE_DIAG_TYPE_UNIT`) or not all ones (`CUSPARSE_DIAG_TYPE_NON_UNIT`). """ -const cusparseDiagType_t = UInt32 +@compat const cusparseDiagType_t = UInt32 const CUSPARSE_DIAG_TYPE_NON_UNIT = 0 const CUSPARSE_DIAG_TYPE_UNIT = 1 @@ -72,7 +73,7 @@ const CUSPARSE_DIAG_TYPE_UNIT = 1 Determines if scalar arguments to a function are present on the host CPU (`CUSPARSE_POINTER_MODE_HOST`) or on the GPU (`CUSPARSE_POINTER_MODE_DEVICE`). """ -const cusparsePointerMode_t = UInt32 +@compat const cusparsePointerMode_t = UInt32 const CUSPARSE_POINTER_MODE_HOST = 0 const CUSPARSE_POINTER_MODE_DEVICE = 1 @@ -83,7 +84,7 @@ or solve, on the matrix as-is (`CUSPARSE_OPERATION_NON_TRANSPOSE`), on the matrix's transpose (`CUSPARSE_OPERATION_TRANSPOSE`), or on its conjugate transpose (`CUSPARSE_OPERATION_CONJUGATE_TRANSPOSE`). """ -const cusparseOperation_t = UInt32 +@compat const cusparseOperation_t = UInt32 const CUSPARSE_OPERATION_NON_TRANSPOSE = 0 const CUSPARSE_OPERATION_TRANSPOSE = 1 const CUSPARSE_OPERATION_CONJUGATE_TRANSPOSE = 2 @@ -97,7 +98,7 @@ symmetric (`CUSPARSE_MATRIX_TYPE_SYMMETRIC`), Hermitian (those in [`CompressedSparse`](@ref)), this can be inferred for some function calls. """ -const cusparseMatrixType_t = UInt32 +@compat const cusparseMatrixType_t = UInt32 const CUSPARSE_MATRIX_TYPE_GENERAL = 0 const CUSPARSE_MATRIX_TYPE_SYMMETRIC = 1 const CUSPARSE_MATRIX_TYPE_HERMITIAN = 2 @@ -108,7 +109,7 @@ const CUSPARSE_MATRIX_TYPE_TRIANGULAR = 3 Indicates whether to keep level info in solvers (`CUSPARSE_SOLVE_POLICY_USE_LEVEL`) or whether to not use it (`CUSPARSE_SOLVE_POLICY_NO_LEVEL`). """ -const cusparseSolvePolicy_t = UInt32 +@compat const cusparseSolvePolicy_t = UInt32 const CUSPARSE_SOLVE_POLICY_NO_LEVEL = 0 const CUSPARSE_SOLVE_POLICY_USE_LEVEL = 1 @@ -119,7 +120,7 @@ or one-indexed (`CUSPARSE_INDEX_BASE_ONE`). CUSPARSE.jl supports both. Julia sparse matrices are one-indexed, but you may wish to pass matrices from other libraries which use zero-indexing (e.g. C language ODE solvers). """ -const cusparseIndexBase_t = UInt32 +@compat const cusparseIndexBase_t = UInt32 const CUSPARSE_INDEX_BASE_ZERO = 0 const CUSPARSE_INDEX_BASE_ONE = 1 @@ -149,23 +150,23 @@ CUSPARSE will take. Generated by [`sv_analysis`](@ref) or [`sm_analysis`](@ref) and passed to [`sv_solve!`](@ref), [`sm_solve`](@ref), [`ic0!`](@ref), or [`ilu0!`](@ref). """ -const cusparseSolveAnalysisInfo_t = Ptr{Void} -const bsrsm2Info_t = Ptr{Void} -const bsrsv2Info_t = Ptr{Void} -const csrsv2Info_t = Ptr{Void} -const csric02Info_t = Ptr{Void} -const csrilu02Info_t = Ptr{Void} -const bsric02Info_t = Ptr{Void} -const bsrilu02Info_t = Ptr{Void} +@compat const cusparseSolveAnalysisInfo_t = Ptr{Void} +@compat const bsrsm2Info_t = Ptr{Void} +@compat const bsrsv2Info_t = Ptr{Void} +@compat const csrsv2Info_t = Ptr{Void} +@compat const csric02Info_t = Ptr{Void} +@compat const csrilu02Info_t = Ptr{Void} +@compat const bsric02Info_t = Ptr{Void} +@compat const bsrilu02Info_t = Ptr{Void} -const cusparseContext = Void -const cusparseHandle_t = Ptr{cusparseContext} +@compat const cusparseContext = Void +@compat const cusparseHandle_t = Ptr{cusparseContext} #complex numbers -const cuComplex = Complex{Float32} -const cuDoubleComplex = Complex{Float64} +@compat const cuComplex = Complex{Float32} +@compat const cuDoubleComplex = Complex{Float64} -const CusparseFloat = Union{Float64,Float32,Complex128,Complex64} -const CusparseReal = Union{Float64,Float32} -const CusparseComplex = Union{Complex128,Complex64} +@compat const CusparseFloat = Union{Float64,Float32,Complex128,Complex64} +@compat const CusparseReal = Union{Float64,Float32} +@compat const CusparseComplex = Union{Complex128,Complex64} diff --git a/src/util.jl b/src/util.jl index 0849e6d..ec4f375 100644 --- a/src/util.jl +++ b/src/util.jl @@ -6,10 +6,11 @@ import Base: length, size, ndims, eltype, similar, pointer, stride, ishermitian, isupper, islower import Base.LinAlg: BlasFloat, Hermitian, HermOrSym import CUDArt: device, to_host, free +using Compat -abstract type AbstractCudaSparseArray{Tv,N} <: AbstractSparseArray{Tv,Cint,N} end -const AbstractCudaSparseVector{Tv} = AbstractCudaSparseArray{Tv,1} -const AbstractCudaSparseMatrix{Tv} = AbstractCudaSparseArray{Tv,2} +@compat abstract type AbstractCudaSparseArray{Tv,N} <: AbstractSparseArray{Tv,Cint,N} end +@compat const AbstractCudaSparseVector{Tv} = AbstractCudaSparseArray{Tv,1} +@compat const AbstractCudaSparseMatrix{Tv} = AbstractCudaSparseArray{Tv,2} """ Container to hold sparse vectors on the GPU, similar to `SparseVector` in base Julia. @@ -20,7 +21,7 @@ type CudaSparseVector{Tv} <: AbstractCudaSparseVector{Tv} dims::NTuple{2,Int} nnz::Cint dev::Int - function CudaSparseVector{Tv}(iPtr::CudaVector{Cint}, nzVal::CudaVector{Tv}, dims::Int, nnz::Cint, dev::Int) where {Tv} + function CudaSparseVector{Tv}(iPtr::CudaVector{Cint}, nzVal::CudaVector{Tv}, dims::Int, nnz::Cint, dev::Int) new(iPtr,nzVal,(dims,1),nnz,dev) end end @@ -40,7 +41,7 @@ type CudaSparseMatrixCSC{Tv} <: AbstractCudaSparseMatrix{Tv} nnz::Cint dev::Int - function CudaSparseMatrixCSC{Tv}(colPtr::CudaVector{Cint}, rowVal::CudaVector{Cint}, nzVal::CudaVector{Tv}, dims::NTuple{2,Int}, nnz::Cint, dev::Int) where {Tv} + function CudaSparseMatrixCSC{Tv}(colPtr::CudaVector{Cint}, rowVal::CudaVector{Cint}, nzVal::CudaVector{Tv}, dims::NTuple{2,Int}, nnz::Cint, dev::Int) new(colPtr,rowVal,nzVal,dims,nnz,dev) end end @@ -60,7 +61,7 @@ type CudaSparseMatrixCSR{Tv} <: AbstractCudaSparseMatrix{Tv} nnz::Cint dev::Int - function CudaSparseMatrixCSR{Tv}(rowPtr::CudaVector{Cint}, colVal::CudaVector{Cint}, nzVal::CudaVector{Tv}, dims::NTuple{2,Int}, nnz::Cint, dev::Int) where {Tv} + function CudaSparseMatrixCSR{Tv}(rowPtr::CudaVector{Cint}, colVal::CudaVector{Cint}, nzVal::CudaVector{Tv}, dims::NTuple{2,Int}, nnz::Cint, dev::Int) new(rowPtr,colVal,nzVal,dims,nnz,dev) end end @@ -80,7 +81,7 @@ type CudaSparseMatrixBSR{Tv} <: AbstractCudaSparseMatrix{Tv} nnz::Cint dev::Int - function CudaSparseMatrixBSR{Tv}(rowPtr::CudaVector{Cint}, colVal::CudaVector{Cint}, nzVal::CudaVector{Tv}, dims::NTuple{2,Int},blockDim::Cint, dir::SparseChar, nnz::Cint, dev::Int) where{Tv} + function CudaSparseMatrixBSR{Tv}(rowPtr::CudaVector{Cint}, colVal::CudaVector{Cint}, nzVal::CudaVector{Tv}, dims::NTuple{2,Int},blockDim::Cint, dir::SparseChar, nnz::Cint, dev::Int) new(rowPtr,colVal,nzVal,dims,blockDim,dir,nnz,dev) end end @@ -90,14 +91,14 @@ Container to hold sparse matrices in NVIDIA's hybrid (HYB) format on the GPU. HYB format is an opaque struct, which can be converted to/from using CUSPARSE routines. """ -const cusparseHybMat_t = Ptr{Void} +@compat const cusparseHybMat_t = Ptr{Void} type CudaSparseMatrixHYB{Tv} <: AbstractCudaSparseMatrix{Tv} Mat::cusparseHybMat_t dims::NTuple{2,Int} nnz::Cint dev::Int - function CudaSparseMatrixHYB{Tv}(Mat::cusparseHybMat_t, dims::NTuple{2,Int}, nnz::Cint, dev::Int) where {Tv} + function CudaSparseMatrixHYB(Mat::cusparseHybMat_t, dims::NTuple{2,Int}, nnz::Cint, dev::Int) new(Mat,dims,nnz,dev) end end @@ -108,13 +109,13 @@ and `Hermitian` and `Symmetric` versions of these two containers. A function acc this type can make use of performance improvements by only indexing one triangle of the matrix if it is guaranteed to be hermitian/symmetric. """ -const CompressedSparse{T} = Union{CudaSparseMatrixCSC{T},CudaSparseMatrixCSR{T},HermOrSym{T,CudaSparseMatrixCSC{T}},HermOrSym{T,CudaSparseMatrixCSR{T}}} +@compat const CompressedSparse{T} = Union{CudaSparseMatrixCSC{T},CudaSparseMatrixCSR{T},HermOrSym{T,CudaSparseMatrixCSC{T}},HermOrSym{T,CudaSparseMatrixCSR{T}}} """ Utility union type of [`CudaSparseMatrixCSC`](@ref), [`CudaSparseMatrixCSR`](@ref), [`CudaSparseMatrixBSR`](@ref), and [`CudaSparseMatrixHYB`](@ref). """ -const CudaSparseMatrix{T} = Union{CudaSparseMatrixCSC{T},CudaSparseMatrixCSR{T}, CudaSparseMatrixBSR{T}, CudaSparseMatrixHYB{T}} +@compat const CudaSparseMatrix{T} = Union{CudaSparseMatrixCSC{T},CudaSparseMatrixCSR{T}, CudaSparseMatrixBSR{T}, CudaSparseMatrixHYB{T}} Hermitian{T}(Mat::CudaSparseMatrix{T}) = Hermitian{T,typeof(Mat)}(Mat,'U')