AMGX in Julia
| Documentation | Build Status |
|---|---|
The AMGX.jl package provides an interface for using NVIDIA's AMGX library from the Julia language.
using Pkg; Pkg.add("AMGX")Prebuilt binaries are available for Linux. On other systems you need a local AMGX
build; point JULIA_AMGX_PATH at the shared library before loading the package.
using AMGX, CUDA, SparseArrays
AMGX.initialize()
config = AMGX.Config(Dict("monitor_residual" => 1, "max_iters" => 100))
resources = AMGX.Resources(config)
A = sparse([1,1,2,2,3,3], [1,2,2,3,1,3], [4.0,1.0,4.0,1.0,1.0,4.0], 3, 3)
matrix = AMGX.AMGXMatrix(resources, AMGX.dDDI)
AMGX.upload!(matrix, CUDA.CUSPARSE.CuSparseMatrixCSR(A))
rhs = AMGX.AMGXVector(resources, AMGX.dDDI)
AMGX.upload!(rhs, [1.0, 2.0, 3.0])
x = AMGX.AMGXVector(resources, AMGX.dDDI)
AMGX.set_zero!(x, 3)
solver = AMGX.Solver(resources, AMGX.dDDI, config)
AMGX.setup!(solver, matrix)
AMGX.solve!(x, solver, rhs)
@show AMGX.get_status(solver)
@show Vector(x)
# AMGX objects are not garbage collected: close them, children before parents
foreach(close, (solver, x, rhs, matrix, resources, config))
AMGX.finalize()Note that AMGX objects must be closed explicitly and in the right order — see
Memory management — and that
a solve which does not converge is not an error, so get_status should always be
checked.
Full documentation is at juliagpu.github.io/AMGX.jl, covering configuration, vectors and matrices, solving, memory management, the utility functions, and the complete API reference.
Reading the official AMGX reference manual is also recommended — the configuration parameters are AMGX's own.