Skip to content

Commit

Permalink
Actually everything works with 0.5 too
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt committed May 24, 2017
1 parent c004942 commit 3b56898
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 39 deletions.
3 changes: 2 additions & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
julia 0.6-
julia 0.5
CUDArt
Compat
55 changes: 28 additions & 27 deletions src/libcusparse_types.jl
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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}
23 changes: 12 additions & 11 deletions src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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')

Expand Down

0 comments on commit 3b56898

Please sign in to comment.