Skip to content

Commit

Permalink
Improve cudss_set and cudss_get
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Mar 25, 2024
1 parent 0b37757 commit 2811cb5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
24 changes: 20 additions & 4 deletions src/interfaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,26 @@ function cudss_set(matrix::CudssMatrix{T}, A::CuSparseMatrixCSR{T,Cint}) where T
end

function cudss_set(solver::CudssSolver, param::String, value)
(param CUDSS_CONFIG_PARAMETERS) && cudss_set(solver.config, param, value)
(param CUDSS_DATA_PARAMETERS) && cudss_set(solver.data, param, value)
if param CUDSS_CONFIG_PARAMETERS
cudss_set(solver.config, param, value)
elseif param CUDSS_DATA_PARAMETERS
cudss_set(solver.data, param, value)
else
throw(ArgumentError("Unknown data or config parameter $param."))
end
end

function cudss_set(data::CudssData, param::String, value)
(param CUDSS_DATA_PARAMETERS) || throw(ArgumentError("Unknown data parameter $param."))
(param == "user_perm") || throw(ArgumentError("Only the data parameter \"user_perm\" can be set."))
type = CUDSS_TYPES[param]
val = Ref{type}(value)
nbytes = sizeof(val)
cudssDataSet(handle(), data, param, val, nbytes)
end

function cudss_set(config::CudssConfig, param::String, value)
(param CUDSS_CONFIG_PARAMETERS) || throw(ArgumentError("Unknown config parameter $config."))
type = CUDSS_TYPES[param]
val = Ref{type}(value)
nbytes = sizeof(val)
Expand Down Expand Up @@ -138,11 +146,18 @@ The data parameters `"perm_row"` and `"perm_col"` are available but not yet func
function cudss_get end

function cudss_get(solver::CudssSolver, param::String)
(param CUDSS_CONFIG_PARAMETERS) && cudss_get(solver.config, param)
(param CUDSS_DATA_PARAMETERS) && cudss_get(solver.data, param)
if param CUDSS_CONFIG_PARAMETERS
cudss_get(solver.config, param)
elseif param CUDSS_DATA_PARAMETERS
cudss_get(solver.data, param)
else
throw(ArgumentError("Unknown data or config parameter $param."))
end
end

function cudss_get(data::CudssData, param::String)
(param CUDSS_DATA_PARAMETERS) || throw(ArgumentError("Unknown data parameter $param."))
(param == "user_perm") && throw(ArgumentError("The data parameter \"user_perm\" cannot be retrieved."))
type = CUDSS_TYPES[param]
val = Ref{type}()
nbytes = sizeof(val)
Expand All @@ -152,6 +167,7 @@ function cudss_get(data::CudssData, param::String)
end

function cudss_get(config::CudssConfig, param::String)
(param CUDSS_CONFIG_PARAMETERS) || throw(ArgumentError("Unknown config parameter $config."))
type = CUDSS_TYPES[param]
val = Ref{type}()
nbytes = sizeof(val)
Expand Down
4 changes: 2 additions & 2 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function Base.convert(::Type{cudssConfigParam_t}, config::String)
elseif config == "max_lu_nnz"
return CUDSS_CONFIG_MAX_LU_NNZ
else
throw(ArgumentError("Unknown config $config"))
throw(ArgumentError("Unknown config parameter $config"))
end
end

Expand All @@ -166,7 +166,7 @@ function Base.convert(::Type{cudssDataParam_t}, data::String)
elseif data == "user_perm"
return CUDSS_DATA_USER_PERM
else
throw(ArgumentError("Unknown data $data"))
throw(ArgumentError("Unknown data parameter $data"))
end
end

Expand Down

0 comments on commit 2811cb5

Please sign in to comment.