From 172e35a2debb6985456bca798c47dde43ea343c0 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Thu, 9 Feb 2023 08:54:41 -0500 Subject: [PATCH 01/17] Use AMGX_jll 2.3 and bump julia compat to 1.6 --- Project.toml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Project.toml b/Project.toml index 020feb5..4672413 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,14 @@ +authors = ["JuliaHub"] name = "AMGX" uuid = "c963dde9-0319-47f5-bf0c-b07d3c80ffa6" -authors = ["JuliaHub"] -version = "0.1.4" +version = "0.2.0" + +[compat] +AMGX_jll = "2.3" +CEnum = "0.4" +CUDA = "3, 4" +JSON = "0.21" +julia = "1.6" [deps] AMGX_jll = "656d14af-56e4-5275-8e68-4e861d7b5043" @@ -11,12 +18,6 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -[compat] -CEnum = "0.4" -CUDA = "2.2, 3, 4" -JSON = "0.21" -julia = "1.5" - [extras] Defer = "6f25fe36-ecbb-5dff-aeb8-f7b50c87fb5f" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" From 04359eecef97832bbbdb505d2a1b28657564fe98 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Thu, 9 Feb 2023 09:04:48 -0500 Subject: [PATCH 02/17] Don't use artifacts for CUDA@4 on CUDA@3 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 4672413..81ae27a 100644 --- a/Project.toml +++ b/Project.toml @@ -6,7 +6,7 @@ version = "0.2.0" [compat] AMGX_jll = "2.3" CEnum = "0.4" -CUDA = "3, 4" +CUDA = "4" JSON = "0.21" julia = "1.6" From 57dbe6a24afe04f20c7828e871d90c645e7d0feb Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Thu, 9 Feb 2023 10:01:18 -0500 Subject: [PATCH 03/17] simplify C-API --- lib/libAMGX.jl | 140 ++++++++++++++++++++++++------------------------- src/AMGX.jl | 39 -------------- 2 files changed, 70 insertions(+), 109 deletions(-) diff --git a/lib/libAMGX.jl b/lib/libAMGX.jl index b8677a1..1188d76 100644 --- a/lib/libAMGX.jl +++ b/lib/libAMGX.jl @@ -3,283 +3,283 @@ function AMGX_get_api_version(major, minor) - @runtime_ccall((:AMGX_get_api_version, libAMGX), AMGX_RC, (Ptr{Cint}, Ptr{Cint}), major, minor) + @ccall((:AMGX_get_api_version, libAMGX), AMGX_RC, (Ptr{Cint}, Ptr{Cint}), major, minor) end function AMGX_get_build_info_strings(version, date, time) - @runtime_ccall((:AMGX_get_build_info_strings, libAMGX), AMGX_RC, (Ptr{Cstring}, Ptr{Cstring}, Ptr{Cstring}), version, date, time) + @ccall((:AMGX_get_build_info_strings, libAMGX), AMGX_RC, (Ptr{Cstring}, Ptr{Cstring}, Ptr{Cstring}), version, date, time) end function AMGX_get_error_string(err, buf, buf_len) - @runtime_ccall((:AMGX_get_error_string, libAMGX), AMGX_RC, (AMGX_RC, Cstring, Cint), err, buf, buf_len) + @ccall((:AMGX_get_error_string, libAMGX), AMGX_RC, (AMGX_RC, Cstring, Cint), err, buf, buf_len) end function AMGX_initialize() - @runtime_ccall((:AMGX_initialize, libAMGX), AMGX_RC, ()) + @ccall((:AMGX_initialize, libAMGX), AMGX_RC, ()) end function AMGX_initialize_plugins() - @runtime_ccall((:AMGX_initialize_plugins, libAMGX), AMGX_RC, ()) + @ccall((:AMGX_initialize_plugins, libAMGX), AMGX_RC, ()) end function AMGX_finalize() - @runtime_ccall((:AMGX_finalize, libAMGX), AMGX_RC, ()) + @ccall((:AMGX_finalize, libAMGX), AMGX_RC, ()) end function AMGX_finalize_plugins() - @runtime_ccall((:AMGX_finalize_plugins, libAMGX), AMGX_RC, ()) + @ccall((:AMGX_finalize_plugins, libAMGX), AMGX_RC, ()) end function AMGX_abort(rsrc, err) - @runtime_ccall((:AMGX_abort, libAMGX), Cvoid, (AMGX_resources_handle, Cint), rsrc, err) + @ccall((:AMGX_abort, libAMGX), Cvoid, (AMGX_resources_handle, Cint), rsrc, err) end function AMGX_pin_memory(ptr, bytes) - @runtime_ccall((:AMGX_pin_memory, libAMGX), AMGX_RC, (Ptr{Cvoid}, UInt32), ptr, bytes) + @ccall((:AMGX_pin_memory, libAMGX), AMGX_RC, (Ptr{Cvoid}, UInt32), ptr, bytes) end function AMGX_unpin_memory(ptr) - @runtime_ccall((:AMGX_unpin_memory, libAMGX), AMGX_RC, (Ptr{Cvoid},), ptr) + @ccall((:AMGX_unpin_memory, libAMGX), AMGX_RC, (Ptr{Cvoid},), ptr) end function AMGX_install_signal_handler() - @runtime_ccall((:AMGX_install_signal_handler, libAMGX), AMGX_RC, ()) + @ccall((:AMGX_install_signal_handler, libAMGX), AMGX_RC, ()) end function AMGX_reset_signal_handler() - @runtime_ccall((:AMGX_reset_signal_handler, libAMGX), AMGX_RC, ()) + @ccall((:AMGX_reset_signal_handler, libAMGX), AMGX_RC, ()) end function AMGX_register_print_callback(func) - @runtime_ccall((:AMGX_register_print_callback, libAMGX), AMGX_RC, (AMGX_print_callback,), func) + @ccall((:AMGX_register_print_callback, libAMGX), AMGX_RC, (AMGX_print_callback,), func) end function AMGX_config_create(cfg, options) - @runtime_ccall((:AMGX_config_create, libAMGX), AMGX_RC, (Ptr{AMGX_config_handle}, Cstring), cfg, options) + @ccall((:AMGX_config_create, libAMGX), AMGX_RC, (Ptr{AMGX_config_handle}, Cstring), cfg, options) end function AMGX_config_add_parameters(cfg, options) - @runtime_ccall((:AMGX_config_add_parameters, libAMGX), AMGX_RC, (Ptr{AMGX_config_handle}, Cstring), cfg, options) + @ccall((:AMGX_config_add_parameters, libAMGX), AMGX_RC, (Ptr{AMGX_config_handle}, Cstring), cfg, options) end function AMGX_config_create_from_file(cfg, param_file) - @runtime_ccall((:AMGX_config_create_from_file, libAMGX), AMGX_RC, (Ptr{AMGX_config_handle}, Cstring), cfg, param_file) + @ccall((:AMGX_config_create_from_file, libAMGX), AMGX_RC, (Ptr{AMGX_config_handle}, Cstring), cfg, param_file) end function AMGX_config_create_from_file_and_string(cfg, param_file, options) - @runtime_ccall((:AMGX_config_create_from_file_and_string, libAMGX), AMGX_RC, (Ptr{AMGX_config_handle}, Cstring, Cstring), cfg, param_file, options) + @ccall((:AMGX_config_create_from_file_and_string, libAMGX), AMGX_RC, (Ptr{AMGX_config_handle}, Cstring, Cstring), cfg, param_file, options) end function AMGX_config_get_default_number_of_rings(cfg, num_import_rings) - @runtime_ccall((:AMGX_config_get_default_number_of_rings, libAMGX), AMGX_RC, (AMGX_config_handle, Ptr{Cint}), cfg, num_import_rings) + @ccall((:AMGX_config_get_default_number_of_rings, libAMGX), AMGX_RC, (AMGX_config_handle, Ptr{Cint}), cfg, num_import_rings) end function AMGX_config_destroy(cfg) - @runtime_ccall((:AMGX_config_destroy, libAMGX), AMGX_RC, (AMGX_config_handle,), cfg) + @ccall((:AMGX_config_destroy, libAMGX), AMGX_RC, (AMGX_config_handle,), cfg) end function AMGX_resources_create(rsc, cfg, comm, device_num, devices) - @runtime_ccall((:AMGX_resources_create, libAMGX), AMGX_RC, (Ptr{AMGX_resources_handle}, AMGX_config_handle, Ptr{Cvoid}, Cint, Ptr{Cint}), rsc, cfg, comm, device_num, devices) + @ccall((:AMGX_resources_create, libAMGX), AMGX_RC, (Ptr{AMGX_resources_handle}, AMGX_config_handle, Ptr{Cvoid}, Cint, Ptr{Cint}), rsc, cfg, comm, device_num, devices) end function AMGX_resources_create_simple(rsc, cfg) - @runtime_ccall((:AMGX_resources_create_simple, libAMGX), AMGX_RC, (Ptr{AMGX_resources_handle}, AMGX_config_handle), rsc, cfg) + @ccall((:AMGX_resources_create_simple, libAMGX), AMGX_RC, (Ptr{AMGX_resources_handle}, AMGX_config_handle), rsc, cfg) end function AMGX_resources_destroy(rsc) - @runtime_ccall((:AMGX_resources_destroy, libAMGX), AMGX_RC, (AMGX_resources_handle,), rsc) + @ccall((:AMGX_resources_destroy, libAMGX), AMGX_RC, (AMGX_resources_handle,), rsc) end function AMGX_distribution_create(dist, cfg) - @runtime_ccall((:AMGX_distribution_create, libAMGX), AMGX_RC, (Ptr{AMGX_distribution_handle}, AMGX_config_handle), dist, cfg) + @ccall((:AMGX_distribution_create, libAMGX), AMGX_RC, (Ptr{AMGX_distribution_handle}, AMGX_config_handle), dist, cfg) end function AMGX_distribution_destroy(dist) - @runtime_ccall((:AMGX_distribution_destroy, libAMGX), AMGX_RC, (AMGX_distribution_handle,), dist) + @ccall((:AMGX_distribution_destroy, libAMGX), AMGX_RC, (AMGX_distribution_handle,), dist) end function AMGX_distribution_set_partition_data(dist, info, partition_data) - @runtime_ccall((:AMGX_distribution_set_partition_data, libAMGX), AMGX_RC, (AMGX_distribution_handle, AMGX_DIST_PARTITION_INFO, Ptr{Cvoid}), dist, info, partition_data) + @ccall((:AMGX_distribution_set_partition_data, libAMGX), AMGX_RC, (AMGX_distribution_handle, AMGX_DIST_PARTITION_INFO, Ptr{Cvoid}), dist, info, partition_data) end function AMGX_distribution_set_32bit_colindices(dist, use32bit) - @runtime_ccall((:AMGX_distribution_set_32bit_colindices, libAMGX), AMGX_RC, (AMGX_distribution_handle, Cint), dist, use32bit) + @ccall((:AMGX_distribution_set_32bit_colindices, libAMGX), AMGX_RC, (AMGX_distribution_handle, Cint), dist, use32bit) end function AMGX_matrix_create(mtx, rsc, mode) - @runtime_ccall((:AMGX_matrix_create, libAMGX), AMGX_RC, (Ptr{AMGX_matrix_handle}, AMGX_resources_handle, AMGX_Mode), mtx, rsc, mode) + @ccall((:AMGX_matrix_create, libAMGX), AMGX_RC, (Ptr{AMGX_matrix_handle}, AMGX_resources_handle, AMGX_Mode), mtx, rsc, mode) end function AMGX_matrix_destroy(mtx) - @runtime_ccall((:AMGX_matrix_destroy, libAMGX), AMGX_RC, (AMGX_matrix_handle,), mtx) + @ccall((:AMGX_matrix_destroy, libAMGX), AMGX_RC, (AMGX_matrix_handle,), mtx) end function AMGX_matrix_upload_all(mtx, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices, data, diag_data) - @runtime_ccall((:AMGX_matrix_upload_all, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}), mtx, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices, data, diag_data) + @ccall((:AMGX_matrix_upload_all, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}), mtx, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices, data, diag_data) end function AMGX_matrix_replace_coefficients(mtx, n, nnz, data, diag_data) - @runtime_ccall((:AMGX_matrix_replace_coefficients, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Ptr{Cvoid}, Ptr{Cvoid}), mtx, n, nnz, data, diag_data) + @ccall((:AMGX_matrix_replace_coefficients, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Ptr{Cvoid}, Ptr{Cvoid}), mtx, n, nnz, data, diag_data) end function AMGX_matrix_get_size(mtx, n, block_dimx, block_dimy) - @runtime_ccall((:AMGX_matrix_get_size, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}), mtx, n, block_dimx, block_dimy) + @ccall((:AMGX_matrix_get_size, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}), mtx, n, block_dimx, block_dimy) end function AMGX_matrix_get_nnz(mtx, nnz) - @runtime_ccall((:AMGX_matrix_get_nnz, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cint}), mtx, nnz) + @ccall((:AMGX_matrix_get_nnz, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cint}), mtx, nnz) end function AMGX_matrix_download_all(mtx, row_ptrs, col_indices, data, diag_data) - @runtime_ccall((:AMGX_matrix_download_all, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cint}, Ptr{Cint}, Ptr{Cvoid}, Ptr{Ptr{Cvoid}}), mtx, row_ptrs, col_indices, data, diag_data) + @ccall((:AMGX_matrix_download_all, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cint}, Ptr{Cint}, Ptr{Cvoid}, Ptr{Ptr{Cvoid}}), mtx, row_ptrs, col_indices, data, diag_data) end function AMGX_matrix_vector_multiply(mtx, x, y) - @runtime_ccall((:AMGX_matrix_vector_multiply, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle), mtx, x, y) + @ccall((:AMGX_matrix_vector_multiply, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle), mtx, x, y) end function AMGX_matrix_set_boundary_separation(mtx, boundary_separation) - @runtime_ccall((:AMGX_matrix_set_boundary_separation, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint), mtx, boundary_separation) + @ccall((:AMGX_matrix_set_boundary_separation, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint), mtx, boundary_separation) end function AMGX_matrix_comm_from_maps(mtx, allocated_halo_depth, num_import_rings, max_num_neighbors, neighbors, send_ptrs, send_maps, recv_ptrs, recv_maps) - @runtime_ccall((:AMGX_matrix_comm_from_maps, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}), mtx, allocated_halo_depth, num_import_rings, max_num_neighbors, neighbors, send_ptrs, send_maps, recv_ptrs, recv_maps) + @ccall((:AMGX_matrix_comm_from_maps, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}), mtx, allocated_halo_depth, num_import_rings, max_num_neighbors, neighbors, send_ptrs, send_maps, recv_ptrs, recv_maps) end function AMGX_matrix_comm_from_maps_one_ring(mtx, allocated_halo_depth, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps) - @runtime_ccall((:AMGX_matrix_comm_from_maps_one_ring, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Cint}, Ptr{Ptr{Cint}}), mtx, allocated_halo_depth, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps) + @ccall((:AMGX_matrix_comm_from_maps_one_ring, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Cint}, Ptr{Ptr{Cint}}), mtx, allocated_halo_depth, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps) end function AMGX_vector_create(vec, rsc, mode) - @runtime_ccall((:AMGX_vector_create, libAMGX), AMGX_RC, (Ptr{AMGX_vector_handle}, AMGX_resources_handle, AMGX_Mode), vec, rsc, mode) + @ccall((:AMGX_vector_create, libAMGX), AMGX_RC, (Ptr{AMGX_vector_handle}, AMGX_resources_handle, AMGX_Mode), vec, rsc, mode) end function AMGX_vector_destroy(vec) - @runtime_ccall((:AMGX_vector_destroy, libAMGX), AMGX_RC, (AMGX_vector_handle,), vec) + @ccall((:AMGX_vector_destroy, libAMGX), AMGX_RC, (AMGX_vector_handle,), vec) end function AMGX_vector_upload(vec, n, block_dim, data) - @runtime_ccall((:AMGX_vector_upload, libAMGX), AMGX_RC, (AMGX_vector_handle, Cint, Cint, Ptr{Cvoid}), vec, n, block_dim, data) + @ccall((:AMGX_vector_upload, libAMGX), AMGX_RC, (AMGX_vector_handle, Cint, Cint, Ptr{Cvoid}), vec, n, block_dim, data) end function AMGX_vector_set_zero(vec, n, block_dim) - @runtime_ccall((:AMGX_vector_set_zero, libAMGX), AMGX_RC, (AMGX_vector_handle, Cint, Cint), vec, n, block_dim) + @ccall((:AMGX_vector_set_zero, libAMGX), AMGX_RC, (AMGX_vector_handle, Cint, Cint), vec, n, block_dim) end function AMGX_vector_set_random(vec, n) - @runtime_ccall((:AMGX_vector_set_random, libAMGX), AMGX_RC, (AMGX_vector_handle, Cint), vec, n) + @ccall((:AMGX_vector_set_random, libAMGX), AMGX_RC, (AMGX_vector_handle, Cint), vec, n) end function AMGX_vector_download(vec, data) - @runtime_ccall((:AMGX_vector_download, libAMGX), AMGX_RC, (AMGX_vector_handle, Ptr{Cvoid}), vec, data) + @ccall((:AMGX_vector_download, libAMGX), AMGX_RC, (AMGX_vector_handle, Ptr{Cvoid}), vec, data) end function AMGX_vector_get_size(vec, n, block_dim) - @runtime_ccall((:AMGX_vector_get_size, libAMGX), AMGX_RC, (AMGX_vector_handle, Ptr{Cint}, Ptr{Cint}), vec, n, block_dim) + @ccall((:AMGX_vector_get_size, libAMGX), AMGX_RC, (AMGX_vector_handle, Ptr{Cint}, Ptr{Cint}), vec, n, block_dim) end function AMGX_vector_bind(vec, mtx) - @runtime_ccall((:AMGX_vector_bind, libAMGX), AMGX_RC, (AMGX_vector_handle, AMGX_matrix_handle), vec, mtx) + @ccall((:AMGX_vector_bind, libAMGX), AMGX_RC, (AMGX_vector_handle, AMGX_matrix_handle), vec, mtx) end function AMGX_solver_create(slv, rsc, mode, cfg_solver) - @runtime_ccall((:AMGX_solver_create, libAMGX), AMGX_RC, (Ptr{AMGX_solver_handle}, AMGX_resources_handle, AMGX_Mode, AMGX_config_handle), slv, rsc, mode, cfg_solver) + @ccall((:AMGX_solver_create, libAMGX), AMGX_RC, (Ptr{AMGX_solver_handle}, AMGX_resources_handle, AMGX_Mode, AMGX_config_handle), slv, rsc, mode, cfg_solver) end function AMGX_solver_destroy(slv) - @runtime_ccall((:AMGX_solver_destroy, libAMGX), AMGX_RC, (AMGX_solver_handle,), slv) + @ccall((:AMGX_solver_destroy, libAMGX), AMGX_RC, (AMGX_solver_handle,), slv) end function AMGX_solver_setup(slv, mtx) - @runtime_ccall((:AMGX_solver_setup, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_matrix_handle), slv, mtx) + @ccall((:AMGX_solver_setup, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_matrix_handle), slv, mtx) end function AMGX_solver_solve(slv, rhs, sol) - @runtime_ccall((:AMGX_solver_solve, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_vector_handle, AMGX_vector_handle), slv, rhs, sol) + @ccall((:AMGX_solver_solve, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_vector_handle, AMGX_vector_handle), slv, rhs, sol) end function AMGX_solver_solve_with_0_initial_guess(slv, rhs, sol) - @runtime_ccall((:AMGX_solver_solve_with_0_initial_guess, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_vector_handle, AMGX_vector_handle), slv, rhs, sol) + @ccall((:AMGX_solver_solve_with_0_initial_guess, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_vector_handle, AMGX_vector_handle), slv, rhs, sol) end function AMGX_solver_get_iterations_number(slv, n) - @runtime_ccall((:AMGX_solver_get_iterations_number, libAMGX), AMGX_RC, (AMGX_solver_handle, Ptr{Cint}), slv, n) + @ccall((:AMGX_solver_get_iterations_number, libAMGX), AMGX_RC, (AMGX_solver_handle, Ptr{Cint}), slv, n) end function AMGX_solver_get_iteration_residual(slv, it, idx, res) - @runtime_ccall((:AMGX_solver_get_iteration_residual, libAMGX), AMGX_RC, (AMGX_solver_handle, Cint, Cint, Ptr{Cdouble}), slv, it, idx, res) + @ccall((:AMGX_solver_get_iteration_residual, libAMGX), AMGX_RC, (AMGX_solver_handle, Cint, Cint, Ptr{Cdouble}), slv, it, idx, res) end function AMGX_solver_get_status(slv, st) - @runtime_ccall((:AMGX_solver_get_status, libAMGX), AMGX_RC, (AMGX_solver_handle, Ptr{AMGX_SOLVE_STATUS}), slv, st) + @ccall((:AMGX_solver_get_status, libAMGX), AMGX_RC, (AMGX_solver_handle, Ptr{AMGX_SOLVE_STATUS}), slv, st) end function AMGX_solver_calculate_residual_norm(solver, mtx, rhs, x, norm_vector) - @runtime_ccall((:AMGX_solver_calculate_residual_norm, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Ptr{Cvoid}), solver, mtx, rhs, x, norm_vector) + @ccall((:AMGX_solver_calculate_residual_norm, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Ptr{Cvoid}), solver, mtx, rhs, x, norm_vector) end function AMGX_write_system(mtx, rhs, sol, filename) - @runtime_ccall((:AMGX_write_system, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cstring), mtx, rhs, sol, filename) + @ccall((:AMGX_write_system, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cstring), mtx, rhs, sol, filename) end function AMGX_write_system_distributed(mtx, rhs, sol, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) - @runtime_ccall((:AMGX_write_system_distributed, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cstring, Cint, Cint, Ptr{Cint}, Cint, Ptr{Cint}), mtx, rhs, sol, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) + @ccall((:AMGX_write_system_distributed, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cstring, Cint, Cint, Ptr{Cint}, Cint, Ptr{Cint}), mtx, rhs, sol, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) end function AMGX_read_system(mtx, rhs, sol, filename) - @runtime_ccall((:AMGX_read_system, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cstring), mtx, rhs, sol, filename) + @ccall((:AMGX_read_system, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cstring), mtx, rhs, sol, filename) end function AMGX_read_system_distributed(mtx, rhs, sol, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) - @runtime_ccall((:AMGX_read_system_distributed, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cstring, Cint, Cint, Ptr{Cint}, Cint, Ptr{Cint}), mtx, rhs, sol, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) + @ccall((:AMGX_read_system_distributed, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cstring, Cint, Cint, Ptr{Cint}, Cint, Ptr{Cint}), mtx, rhs, sol, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) end function AMGX_read_system_maps_one_ring(n, nnz, block_dimx, block_dimy, row_ptrs, col_indices, data, diag_data, rhs, sol, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps, rsc, mode, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) - @runtime_ccall((:AMGX_read_system_maps_one_ring, libAMGX), AMGX_RC, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Ptr{Cint}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Ptr{Cint}}, Ptr{Ptr{Ptr{Cint}}}, Ptr{Ptr{Cint}}, Ptr{Ptr{Ptr{Cint}}}, AMGX_resources_handle, AMGX_Mode, Cstring, Cint, Cint, Ptr{Cint}, Cint, Ptr{Cint}), n, nnz, block_dimx, block_dimy, row_ptrs, col_indices, data, diag_data, rhs, sol, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps, rsc, mode, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) + @ccall((:AMGX_read_system_maps_one_ring, libAMGX), AMGX_RC, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Ptr{Cint}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Ptr{Cint}}, Ptr{Ptr{Ptr{Cint}}}, Ptr{Ptr{Cint}}, Ptr{Ptr{Ptr{Cint}}}, AMGX_resources_handle, AMGX_Mode, Cstring, Cint, Cint, Ptr{Cint}, Cint, Ptr{Cint}), n, nnz, block_dimx, block_dimy, row_ptrs, col_indices, data, diag_data, rhs, sol, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps, rsc, mode, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) end function AMGX_free_system_maps_one_ring(row_ptrs, col_indices, data, diag_data, rhs, sol, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps) - @runtime_ccall((:AMGX_free_system_maps_one_ring, libAMGX), AMGX_RC, (Ptr{Cint}, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Cint}, Ptr{Ptr{Cint}}), row_ptrs, col_indices, data, diag_data, rhs, sol, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps) + @ccall((:AMGX_free_system_maps_one_ring, libAMGX), AMGX_RC, (Ptr{Cint}, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Cint}, Ptr{Ptr{Cint}}), row_ptrs, col_indices, data, diag_data, rhs, sol, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps) end function AMGX_generate_distributed_poisson_7pt(mtx, rhs, sol, allocated_halo_depth, num_import_rings, nx, ny, nz, px, py, pz) - @runtime_ccall((:AMGX_generate_distributed_poisson_7pt, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cint, Cint, Cint, Cint, Cint, Cint, Cint, Cint), mtx, rhs, sol, allocated_halo_depth, num_import_rings, nx, ny, nz, px, py, pz) + @ccall((:AMGX_generate_distributed_poisson_7pt, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cint, Cint, Cint, Cint, Cint, Cint, Cint, Cint), mtx, rhs, sol, allocated_halo_depth, num_import_rings, nx, ny, nz, px, py, pz) end function AMGX_write_parameters_description(filename, mode) - @runtime_ccall((:AMGX_write_parameters_description, libAMGX), AMGX_RC, (Cstring, AMGX_GET_PARAMS_DESC_FLAG), filename, mode) + @ccall((:AMGX_write_parameters_description, libAMGX), AMGX_RC, (Cstring, AMGX_GET_PARAMS_DESC_FLAG), filename, mode) end function AMGX_matrix_attach_coloring(mtx, row_coloring, num_rows, num_colors) - @runtime_ccall((:AMGX_matrix_attach_coloring, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cint}, Cint, Cint), mtx, row_coloring, num_rows, num_colors) + @ccall((:AMGX_matrix_attach_coloring, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cint}, Cint, Cint), mtx, row_coloring, num_rows, num_colors) end function AMGX_matrix_attach_geometry(mtx, geox, geoy, geoz, n) - @runtime_ccall((:AMGX_matrix_attach_geometry, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Cint), mtx, geox, geoy, geoz, n) + @ccall((:AMGX_matrix_attach_geometry, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Cint), mtx, geox, geoy, geoz, n) end function AMGX_read_system_global(n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, rhs, sol, rsc, mode, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) - @runtime_ccall((:AMGX_read_system_global, libAMGX), AMGX_RC, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, AMGX_resources_handle, AMGX_Mode, Cstring, Cint, Cint, Ptr{Cint}, Cint, Ptr{Cint}), n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, rhs, sol, rsc, mode, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) + @ccall((:AMGX_read_system_global, libAMGX), AMGX_RC, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, AMGX_resources_handle, AMGX_Mode, Cstring, Cint, Cint, Ptr{Cint}, Cint, Ptr{Cint}), n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, rhs, sol, rsc, mode, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) end function AMGX_matrix_upload_all_global(mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, allocated_halo_depth, num_import_rings, partition_vector) - @runtime_ccall((:AMGX_matrix_upload_all_global, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cint, Cint, Ptr{Cint}), mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, allocated_halo_depth, num_import_rings, partition_vector) + @ccall((:AMGX_matrix_upload_all_global, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cint, Cint, Ptr{Cint}), mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, allocated_halo_depth, num_import_rings, partition_vector) end function AMGX_matrix_upload_all_global_32(mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, allocated_halo_depth, num_import_rings, partition_vector) - @runtime_ccall((:AMGX_matrix_upload_all_global_32, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cint, Cint, Ptr{Cint}), mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, allocated_halo_depth, num_import_rings, partition_vector) + @ccall((:AMGX_matrix_upload_all_global_32, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cint, Cint, Ptr{Cint}), mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, allocated_halo_depth, num_import_rings, partition_vector) end function AMGX_matrix_upload_distributed(mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, distribution) - @runtime_ccall((:AMGX_matrix_upload_distributed, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, AMGX_distribution_handle), mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, distribution) + @ccall((:AMGX_matrix_upload_distributed, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, AMGX_distribution_handle), mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, distribution) end function AMGX_solver_register_print_callback(func) - @runtime_ccall((:AMGX_solver_register_print_callback, libAMGX), AMGX_RC, (AMGX_print_callback,), func) + @ccall((:AMGX_solver_register_print_callback, libAMGX), AMGX_RC, (AMGX_print_callback,), func) end function AMGX_solver_resetup(slv, mtx) - @runtime_ccall((:AMGX_solver_resetup, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_matrix_handle), slv, mtx) + @ccall((:AMGX_solver_resetup, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_matrix_handle), slv, mtx) end # Julia wrapper for header: amgx_config.h # Automatically generated using Clang.jl diff --git a/src/AMGX.jl b/src/AMGX.jl index c03f671..daf598e 100644 --- a/src/AMGX.jl +++ b/src/AMGX.jl @@ -38,45 +38,6 @@ end ######### module API - using Libdl - # Taken from LLVM.jl, can be removed when package only supports 1.6 and higher - macro runtime_ccall(target, args...) - if VERSION >= v"1.6.0-DEV.819" - quote - ccall($(esc(target)), $(map(esc, args)...)) - end - else - # decode ccall function/library target - Meta.isexpr(target, :tuple) || error("Expected (function_name, library) tuple") - function_name, library = target.args - - # global const ref to hold the function pointer - @gensym fptr_cache - @eval __module__ begin - # uses atomics (release store, acquire load) for thread safety. - # see https://github.com/JuliaGPU/CUDAapi.jl/issues/106 for details - const $fptr_cache = Threads.Atomic{UInt}(0) - end - - quote - # use a closure to hold the lookup and avoid code bloat in the caller - @noinline function cache_fptr!() - library = Libdl.dlopen($(esc(library))) - $(esc(fptr_cache))[] = Libdl.dlsym(library, $(esc(function_name))) - - $(esc(fptr_cache))[] - end - - fptr = $(esc(fptr_cache))[] - if fptr == 0 # folded into the null check performed by ccall - fptr = cache_fptr!() - end - - ccall(reinterpret(Ptr{Cvoid}, fptr), $(map(esc, args)...)) - end - end - end - using CEnum import ..libAMGX From d6f99e0eb438683a7cafdf6981aaf9e658ca124f Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Thu, 9 Feb 2023 10:02:23 -0500 Subject: [PATCH 04/17] fixup! simplify C-API --- lib/libAMGX.jl | 140 ++++++++++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/lib/libAMGX.jl b/lib/libAMGX.jl index 1188d76..ce12731 100644 --- a/lib/libAMGX.jl +++ b/lib/libAMGX.jl @@ -3,283 +3,283 @@ function AMGX_get_api_version(major, minor) - @ccall((:AMGX_get_api_version, libAMGX), AMGX_RC, (Ptr{Cint}, Ptr{Cint}), major, minor) + ccall((:AMGX_get_api_version, libAMGX), AMGX_RC, (Ptr{Cint}, Ptr{Cint}), major, minor) end function AMGX_get_build_info_strings(version, date, time) - @ccall((:AMGX_get_build_info_strings, libAMGX), AMGX_RC, (Ptr{Cstring}, Ptr{Cstring}, Ptr{Cstring}), version, date, time) + ccall((:AMGX_get_build_info_strings, libAMGX), AMGX_RC, (Ptr{Cstring}, Ptr{Cstring}, Ptr{Cstring}), version, date, time) end function AMGX_get_error_string(err, buf, buf_len) - @ccall((:AMGX_get_error_string, libAMGX), AMGX_RC, (AMGX_RC, Cstring, Cint), err, buf, buf_len) + ccall((:AMGX_get_error_string, libAMGX), AMGX_RC, (AMGX_RC, Cstring, Cint), err, buf, buf_len) end function AMGX_initialize() - @ccall((:AMGX_initialize, libAMGX), AMGX_RC, ()) + ccall((:AMGX_initialize, libAMGX), AMGX_RC, ()) end function AMGX_initialize_plugins() - @ccall((:AMGX_initialize_plugins, libAMGX), AMGX_RC, ()) + ccall((:AMGX_initialize_plugins, libAMGX), AMGX_RC, ()) end function AMGX_finalize() - @ccall((:AMGX_finalize, libAMGX), AMGX_RC, ()) + ccall((:AMGX_finalize, libAMGX), AMGX_RC, ()) end function AMGX_finalize_plugins() - @ccall((:AMGX_finalize_plugins, libAMGX), AMGX_RC, ()) + ccall((:AMGX_finalize_plugins, libAMGX), AMGX_RC, ()) end function AMGX_abort(rsrc, err) - @ccall((:AMGX_abort, libAMGX), Cvoid, (AMGX_resources_handle, Cint), rsrc, err) + ccall((:AMGX_abort, libAMGX), Cvoid, (AMGX_resources_handle, Cint), rsrc, err) end function AMGX_pin_memory(ptr, bytes) - @ccall((:AMGX_pin_memory, libAMGX), AMGX_RC, (Ptr{Cvoid}, UInt32), ptr, bytes) + ccall((:AMGX_pin_memory, libAMGX), AMGX_RC, (Ptr{Cvoid}, UInt32), ptr, bytes) end function AMGX_unpin_memory(ptr) - @ccall((:AMGX_unpin_memory, libAMGX), AMGX_RC, (Ptr{Cvoid},), ptr) + ccall((:AMGX_unpin_memory, libAMGX), AMGX_RC, (Ptr{Cvoid},), ptr) end function AMGX_install_signal_handler() - @ccall((:AMGX_install_signal_handler, libAMGX), AMGX_RC, ()) + ccall((:AMGX_install_signal_handler, libAMGX), AMGX_RC, ()) end function AMGX_reset_signal_handler() - @ccall((:AMGX_reset_signal_handler, libAMGX), AMGX_RC, ()) + ccall((:AMGX_reset_signal_handler, libAMGX), AMGX_RC, ()) end function AMGX_register_print_callback(func) - @ccall((:AMGX_register_print_callback, libAMGX), AMGX_RC, (AMGX_print_callback,), func) + ccall((:AMGX_register_print_callback, libAMGX), AMGX_RC, (AMGX_print_callback,), func) end function AMGX_config_create(cfg, options) - @ccall((:AMGX_config_create, libAMGX), AMGX_RC, (Ptr{AMGX_config_handle}, Cstring), cfg, options) + ccall((:AMGX_config_create, libAMGX), AMGX_RC, (Ptr{AMGX_config_handle}, Cstring), cfg, options) end function AMGX_config_add_parameters(cfg, options) - @ccall((:AMGX_config_add_parameters, libAMGX), AMGX_RC, (Ptr{AMGX_config_handle}, Cstring), cfg, options) + ccall((:AMGX_config_add_parameters, libAMGX), AMGX_RC, (Ptr{AMGX_config_handle}, Cstring), cfg, options) end function AMGX_config_create_from_file(cfg, param_file) - @ccall((:AMGX_config_create_from_file, libAMGX), AMGX_RC, (Ptr{AMGX_config_handle}, Cstring), cfg, param_file) + ccall((:AMGX_config_create_from_file, libAMGX), AMGX_RC, (Ptr{AMGX_config_handle}, Cstring), cfg, param_file) end function AMGX_config_create_from_file_and_string(cfg, param_file, options) - @ccall((:AMGX_config_create_from_file_and_string, libAMGX), AMGX_RC, (Ptr{AMGX_config_handle}, Cstring, Cstring), cfg, param_file, options) + ccall((:AMGX_config_create_from_file_and_string, libAMGX), AMGX_RC, (Ptr{AMGX_config_handle}, Cstring, Cstring), cfg, param_file, options) end function AMGX_config_get_default_number_of_rings(cfg, num_import_rings) - @ccall((:AMGX_config_get_default_number_of_rings, libAMGX), AMGX_RC, (AMGX_config_handle, Ptr{Cint}), cfg, num_import_rings) + ccall((:AMGX_config_get_default_number_of_rings, libAMGX), AMGX_RC, (AMGX_config_handle, Ptr{Cint}), cfg, num_import_rings) end function AMGX_config_destroy(cfg) - @ccall((:AMGX_config_destroy, libAMGX), AMGX_RC, (AMGX_config_handle,), cfg) + ccall((:AMGX_config_destroy, libAMGX), AMGX_RC, (AMGX_config_handle,), cfg) end function AMGX_resources_create(rsc, cfg, comm, device_num, devices) - @ccall((:AMGX_resources_create, libAMGX), AMGX_RC, (Ptr{AMGX_resources_handle}, AMGX_config_handle, Ptr{Cvoid}, Cint, Ptr{Cint}), rsc, cfg, comm, device_num, devices) + ccall((:AMGX_resources_create, libAMGX), AMGX_RC, (Ptr{AMGX_resources_handle}, AMGX_config_handle, Ptr{Cvoid}, Cint, Ptr{Cint}), rsc, cfg, comm, device_num, devices) end function AMGX_resources_create_simple(rsc, cfg) - @ccall((:AMGX_resources_create_simple, libAMGX), AMGX_RC, (Ptr{AMGX_resources_handle}, AMGX_config_handle), rsc, cfg) + ccall((:AMGX_resources_create_simple, libAMGX), AMGX_RC, (Ptr{AMGX_resources_handle}, AMGX_config_handle), rsc, cfg) end function AMGX_resources_destroy(rsc) - @ccall((:AMGX_resources_destroy, libAMGX), AMGX_RC, (AMGX_resources_handle,), rsc) + ccall((:AMGX_resources_destroy, libAMGX), AMGX_RC, (AMGX_resources_handle,), rsc) end function AMGX_distribution_create(dist, cfg) - @ccall((:AMGX_distribution_create, libAMGX), AMGX_RC, (Ptr{AMGX_distribution_handle}, AMGX_config_handle), dist, cfg) + ccall((:AMGX_distribution_create, libAMGX), AMGX_RC, (Ptr{AMGX_distribution_handle}, AMGX_config_handle), dist, cfg) end function AMGX_distribution_destroy(dist) - @ccall((:AMGX_distribution_destroy, libAMGX), AMGX_RC, (AMGX_distribution_handle,), dist) + ccall((:AMGX_distribution_destroy, libAMGX), AMGX_RC, (AMGX_distribution_handle,), dist) end function AMGX_distribution_set_partition_data(dist, info, partition_data) - @ccall((:AMGX_distribution_set_partition_data, libAMGX), AMGX_RC, (AMGX_distribution_handle, AMGX_DIST_PARTITION_INFO, Ptr{Cvoid}), dist, info, partition_data) + ccall((:AMGX_distribution_set_partition_data, libAMGX), AMGX_RC, (AMGX_distribution_handle, AMGX_DIST_PARTITION_INFO, Ptr{Cvoid}), dist, info, partition_data) end function AMGX_distribution_set_32bit_colindices(dist, use32bit) - @ccall((:AMGX_distribution_set_32bit_colindices, libAMGX), AMGX_RC, (AMGX_distribution_handle, Cint), dist, use32bit) + ccall((:AMGX_distribution_set_32bit_colindices, libAMGX), AMGX_RC, (AMGX_distribution_handle, Cint), dist, use32bit) end function AMGX_matrix_create(mtx, rsc, mode) - @ccall((:AMGX_matrix_create, libAMGX), AMGX_RC, (Ptr{AMGX_matrix_handle}, AMGX_resources_handle, AMGX_Mode), mtx, rsc, mode) + ccall((:AMGX_matrix_create, libAMGX), AMGX_RC, (Ptr{AMGX_matrix_handle}, AMGX_resources_handle, AMGX_Mode), mtx, rsc, mode) end function AMGX_matrix_destroy(mtx) - @ccall((:AMGX_matrix_destroy, libAMGX), AMGX_RC, (AMGX_matrix_handle,), mtx) + ccall((:AMGX_matrix_destroy, libAMGX), AMGX_RC, (AMGX_matrix_handle,), mtx) end function AMGX_matrix_upload_all(mtx, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices, data, diag_data) - @ccall((:AMGX_matrix_upload_all, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}), mtx, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices, data, diag_data) + ccall((:AMGX_matrix_upload_all, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}), mtx, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices, data, diag_data) end function AMGX_matrix_replace_coefficients(mtx, n, nnz, data, diag_data) - @ccall((:AMGX_matrix_replace_coefficients, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Ptr{Cvoid}, Ptr{Cvoid}), mtx, n, nnz, data, diag_data) + ccall((:AMGX_matrix_replace_coefficients, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Ptr{Cvoid}, Ptr{Cvoid}), mtx, n, nnz, data, diag_data) end function AMGX_matrix_get_size(mtx, n, block_dimx, block_dimy) - @ccall((:AMGX_matrix_get_size, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}), mtx, n, block_dimx, block_dimy) + ccall((:AMGX_matrix_get_size, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}), mtx, n, block_dimx, block_dimy) end function AMGX_matrix_get_nnz(mtx, nnz) - @ccall((:AMGX_matrix_get_nnz, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cint}), mtx, nnz) + ccall((:AMGX_matrix_get_nnz, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cint}), mtx, nnz) end function AMGX_matrix_download_all(mtx, row_ptrs, col_indices, data, diag_data) - @ccall((:AMGX_matrix_download_all, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cint}, Ptr{Cint}, Ptr{Cvoid}, Ptr{Ptr{Cvoid}}), mtx, row_ptrs, col_indices, data, diag_data) + ccall((:AMGX_matrix_download_all, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cint}, Ptr{Cint}, Ptr{Cvoid}, Ptr{Ptr{Cvoid}}), mtx, row_ptrs, col_indices, data, diag_data) end function AMGX_matrix_vector_multiply(mtx, x, y) - @ccall((:AMGX_matrix_vector_multiply, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle), mtx, x, y) + ccall((:AMGX_matrix_vector_multiply, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle), mtx, x, y) end function AMGX_matrix_set_boundary_separation(mtx, boundary_separation) - @ccall((:AMGX_matrix_set_boundary_separation, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint), mtx, boundary_separation) + ccall((:AMGX_matrix_set_boundary_separation, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint), mtx, boundary_separation) end function AMGX_matrix_comm_from_maps(mtx, allocated_halo_depth, num_import_rings, max_num_neighbors, neighbors, send_ptrs, send_maps, recv_ptrs, recv_maps) - @ccall((:AMGX_matrix_comm_from_maps, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}), mtx, allocated_halo_depth, num_import_rings, max_num_neighbors, neighbors, send_ptrs, send_maps, recv_ptrs, recv_maps) + ccall((:AMGX_matrix_comm_from_maps, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}), mtx, allocated_halo_depth, num_import_rings, max_num_neighbors, neighbors, send_ptrs, send_maps, recv_ptrs, recv_maps) end function AMGX_matrix_comm_from_maps_one_ring(mtx, allocated_halo_depth, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps) - @ccall((:AMGX_matrix_comm_from_maps_one_ring, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Cint}, Ptr{Ptr{Cint}}), mtx, allocated_halo_depth, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps) + ccall((:AMGX_matrix_comm_from_maps_one_ring, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Cint}, Ptr{Ptr{Cint}}), mtx, allocated_halo_depth, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps) end function AMGX_vector_create(vec, rsc, mode) - @ccall((:AMGX_vector_create, libAMGX), AMGX_RC, (Ptr{AMGX_vector_handle}, AMGX_resources_handle, AMGX_Mode), vec, rsc, mode) + ccall((:AMGX_vector_create, libAMGX), AMGX_RC, (Ptr{AMGX_vector_handle}, AMGX_resources_handle, AMGX_Mode), vec, rsc, mode) end function AMGX_vector_destroy(vec) - @ccall((:AMGX_vector_destroy, libAMGX), AMGX_RC, (AMGX_vector_handle,), vec) + ccall((:AMGX_vector_destroy, libAMGX), AMGX_RC, (AMGX_vector_handle,), vec) end function AMGX_vector_upload(vec, n, block_dim, data) - @ccall((:AMGX_vector_upload, libAMGX), AMGX_RC, (AMGX_vector_handle, Cint, Cint, Ptr{Cvoid}), vec, n, block_dim, data) + ccall((:AMGX_vector_upload, libAMGX), AMGX_RC, (AMGX_vector_handle, Cint, Cint, Ptr{Cvoid}), vec, n, block_dim, data) end function AMGX_vector_set_zero(vec, n, block_dim) - @ccall((:AMGX_vector_set_zero, libAMGX), AMGX_RC, (AMGX_vector_handle, Cint, Cint), vec, n, block_dim) + ccall((:AMGX_vector_set_zero, libAMGX), AMGX_RC, (AMGX_vector_handle, Cint, Cint), vec, n, block_dim) end function AMGX_vector_set_random(vec, n) - @ccall((:AMGX_vector_set_random, libAMGX), AMGX_RC, (AMGX_vector_handle, Cint), vec, n) + ccall((:AMGX_vector_set_random, libAMGX), AMGX_RC, (AMGX_vector_handle, Cint), vec, n) end function AMGX_vector_download(vec, data) - @ccall((:AMGX_vector_download, libAMGX), AMGX_RC, (AMGX_vector_handle, Ptr{Cvoid}), vec, data) + ccall((:AMGX_vector_download, libAMGX), AMGX_RC, (AMGX_vector_handle, Ptr{Cvoid}), vec, data) end function AMGX_vector_get_size(vec, n, block_dim) - @ccall((:AMGX_vector_get_size, libAMGX), AMGX_RC, (AMGX_vector_handle, Ptr{Cint}, Ptr{Cint}), vec, n, block_dim) + ccall((:AMGX_vector_get_size, libAMGX), AMGX_RC, (AMGX_vector_handle, Ptr{Cint}, Ptr{Cint}), vec, n, block_dim) end function AMGX_vector_bind(vec, mtx) - @ccall((:AMGX_vector_bind, libAMGX), AMGX_RC, (AMGX_vector_handle, AMGX_matrix_handle), vec, mtx) + ccall((:AMGX_vector_bind, libAMGX), AMGX_RC, (AMGX_vector_handle, AMGX_matrix_handle), vec, mtx) end function AMGX_solver_create(slv, rsc, mode, cfg_solver) - @ccall((:AMGX_solver_create, libAMGX), AMGX_RC, (Ptr{AMGX_solver_handle}, AMGX_resources_handle, AMGX_Mode, AMGX_config_handle), slv, rsc, mode, cfg_solver) + ccall((:AMGX_solver_create, libAMGX), AMGX_RC, (Ptr{AMGX_solver_handle}, AMGX_resources_handle, AMGX_Mode, AMGX_config_handle), slv, rsc, mode, cfg_solver) end function AMGX_solver_destroy(slv) - @ccall((:AMGX_solver_destroy, libAMGX), AMGX_RC, (AMGX_solver_handle,), slv) + ccall((:AMGX_solver_destroy, libAMGX), AMGX_RC, (AMGX_solver_handle,), slv) end function AMGX_solver_setup(slv, mtx) - @ccall((:AMGX_solver_setup, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_matrix_handle), slv, mtx) + ccall((:AMGX_solver_setup, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_matrix_handle), slv, mtx) end function AMGX_solver_solve(slv, rhs, sol) - @ccall((:AMGX_solver_solve, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_vector_handle, AMGX_vector_handle), slv, rhs, sol) + ccall((:AMGX_solver_solve, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_vector_handle, AMGX_vector_handle), slv, rhs, sol) end function AMGX_solver_solve_with_0_initial_guess(slv, rhs, sol) - @ccall((:AMGX_solver_solve_with_0_initial_guess, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_vector_handle, AMGX_vector_handle), slv, rhs, sol) + ccall((:AMGX_solver_solve_with_0_initial_guess, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_vector_handle, AMGX_vector_handle), slv, rhs, sol) end function AMGX_solver_get_iterations_number(slv, n) - @ccall((:AMGX_solver_get_iterations_number, libAMGX), AMGX_RC, (AMGX_solver_handle, Ptr{Cint}), slv, n) + ccall((:AMGX_solver_get_iterations_number, libAMGX), AMGX_RC, (AMGX_solver_handle, Ptr{Cint}), slv, n) end function AMGX_solver_get_iteration_residual(slv, it, idx, res) - @ccall((:AMGX_solver_get_iteration_residual, libAMGX), AMGX_RC, (AMGX_solver_handle, Cint, Cint, Ptr{Cdouble}), slv, it, idx, res) + ccall((:AMGX_solver_get_iteration_residual, libAMGX), AMGX_RC, (AMGX_solver_handle, Cint, Cint, Ptr{Cdouble}), slv, it, idx, res) end function AMGX_solver_get_status(slv, st) - @ccall((:AMGX_solver_get_status, libAMGX), AMGX_RC, (AMGX_solver_handle, Ptr{AMGX_SOLVE_STATUS}), slv, st) + ccall((:AMGX_solver_get_status, libAMGX), AMGX_RC, (AMGX_solver_handle, Ptr{AMGX_SOLVE_STATUS}), slv, st) end function AMGX_solver_calculate_residual_norm(solver, mtx, rhs, x, norm_vector) - @ccall((:AMGX_solver_calculate_residual_norm, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Ptr{Cvoid}), solver, mtx, rhs, x, norm_vector) + ccall((:AMGX_solver_calculate_residual_norm, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Ptr{Cvoid}), solver, mtx, rhs, x, norm_vector) end function AMGX_write_system(mtx, rhs, sol, filename) - @ccall((:AMGX_write_system, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cstring), mtx, rhs, sol, filename) + ccall((:AMGX_write_system, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cstring), mtx, rhs, sol, filename) end function AMGX_write_system_distributed(mtx, rhs, sol, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) - @ccall((:AMGX_write_system_distributed, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cstring, Cint, Cint, Ptr{Cint}, Cint, Ptr{Cint}), mtx, rhs, sol, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) + ccall((:AMGX_write_system_distributed, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cstring, Cint, Cint, Ptr{Cint}, Cint, Ptr{Cint}), mtx, rhs, sol, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) end function AMGX_read_system(mtx, rhs, sol, filename) - @ccall((:AMGX_read_system, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cstring), mtx, rhs, sol, filename) + ccall((:AMGX_read_system, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cstring), mtx, rhs, sol, filename) end function AMGX_read_system_distributed(mtx, rhs, sol, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) - @ccall((:AMGX_read_system_distributed, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cstring, Cint, Cint, Ptr{Cint}, Cint, Ptr{Cint}), mtx, rhs, sol, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) + ccall((:AMGX_read_system_distributed, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cstring, Cint, Cint, Ptr{Cint}, Cint, Ptr{Cint}), mtx, rhs, sol, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) end function AMGX_read_system_maps_one_ring(n, nnz, block_dimx, block_dimy, row_ptrs, col_indices, data, diag_data, rhs, sol, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps, rsc, mode, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) - @ccall((:AMGX_read_system_maps_one_ring, libAMGX), AMGX_RC, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Ptr{Cint}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Ptr{Cint}}, Ptr{Ptr{Ptr{Cint}}}, Ptr{Ptr{Cint}}, Ptr{Ptr{Ptr{Cint}}}, AMGX_resources_handle, AMGX_Mode, Cstring, Cint, Cint, Ptr{Cint}, Cint, Ptr{Cint}), n, nnz, block_dimx, block_dimy, row_ptrs, col_indices, data, diag_data, rhs, sol, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps, rsc, mode, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) + ccall((:AMGX_read_system_maps_one_ring, libAMGX), AMGX_RC, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Ptr{Cint}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Ptr{Cint}}, Ptr{Ptr{Ptr{Cint}}}, Ptr{Ptr{Cint}}, Ptr{Ptr{Ptr{Cint}}}, AMGX_resources_handle, AMGX_Mode, Cstring, Cint, Cint, Ptr{Cint}, Cint, Ptr{Cint}), n, nnz, block_dimx, block_dimy, row_ptrs, col_indices, data, diag_data, rhs, sol, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps, rsc, mode, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) end function AMGX_free_system_maps_one_ring(row_ptrs, col_indices, data, diag_data, rhs, sol, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps) - @ccall((:AMGX_free_system_maps_one_ring, libAMGX), AMGX_RC, (Ptr{Cint}, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Cint}, Ptr{Ptr{Cint}}), row_ptrs, col_indices, data, diag_data, rhs, sol, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps) + ccall((:AMGX_free_system_maps_one_ring, libAMGX), AMGX_RC, (Ptr{Cint}, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Cint}, Ptr{Ptr{Cint}}), row_ptrs, col_indices, data, diag_data, rhs, sol, num_neighbors, neighbors, send_sizes, send_maps, recv_sizes, recv_maps) end function AMGX_generate_distributed_poisson_7pt(mtx, rhs, sol, allocated_halo_depth, num_import_rings, nx, ny, nz, px, py, pz) - @ccall((:AMGX_generate_distributed_poisson_7pt, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cint, Cint, Cint, Cint, Cint, Cint, Cint, Cint), mtx, rhs, sol, allocated_halo_depth, num_import_rings, nx, ny, nz, px, py, pz) + ccall((:AMGX_generate_distributed_poisson_7pt, libAMGX), AMGX_RC, (AMGX_matrix_handle, AMGX_vector_handle, AMGX_vector_handle, Cint, Cint, Cint, Cint, Cint, Cint, Cint, Cint), mtx, rhs, sol, allocated_halo_depth, num_import_rings, nx, ny, nz, px, py, pz) end function AMGX_write_parameters_description(filename, mode) - @ccall((:AMGX_write_parameters_description, libAMGX), AMGX_RC, (Cstring, AMGX_GET_PARAMS_DESC_FLAG), filename, mode) + ccall((:AMGX_write_parameters_description, libAMGX), AMGX_RC, (Cstring, AMGX_GET_PARAMS_DESC_FLAG), filename, mode) end function AMGX_matrix_attach_coloring(mtx, row_coloring, num_rows, num_colors) - @ccall((:AMGX_matrix_attach_coloring, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cint}, Cint, Cint), mtx, row_coloring, num_rows, num_colors) + ccall((:AMGX_matrix_attach_coloring, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cint}, Cint, Cint), mtx, row_coloring, num_rows, num_colors) end function AMGX_matrix_attach_geometry(mtx, geox, geoy, geoz, n) - @ccall((:AMGX_matrix_attach_geometry, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Cint), mtx, geox, geoy, geoz, n) + ccall((:AMGX_matrix_attach_geometry, libAMGX), AMGX_RC, (AMGX_matrix_handle, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Cint), mtx, geox, geoy, geoz, n) end function AMGX_read_system_global(n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, rhs, sol, rsc, mode, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) - @ccall((:AMGX_read_system_global, libAMGX), AMGX_RC, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, AMGX_resources_handle, AMGX_Mode, Cstring, Cint, Cint, Ptr{Cint}, Cint, Ptr{Cint}), n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, rhs, sol, rsc, mode, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) + ccall((:AMGX_read_system_global, libAMGX), AMGX_RC, (Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Ptr{Cint}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, Ptr{Ptr{Cvoid}}, AMGX_resources_handle, AMGX_Mode, Cstring, Cint, Cint, Ptr{Cint}, Cint, Ptr{Cint}), n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, rhs, sol, rsc, mode, filename, allocated_halo_depth, num_partitions, partition_sizes, partition_vector_size, partition_vector) end function AMGX_matrix_upload_all_global(mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, allocated_halo_depth, num_import_rings, partition_vector) - @ccall((:AMGX_matrix_upload_all_global, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cint, Cint, Ptr{Cint}), mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, allocated_halo_depth, num_import_rings, partition_vector) + ccall((:AMGX_matrix_upload_all_global, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cint, Cint, Ptr{Cint}), mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, allocated_halo_depth, num_import_rings, partition_vector) end function AMGX_matrix_upload_all_global_32(mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, allocated_halo_depth, num_import_rings, partition_vector) - @ccall((:AMGX_matrix_upload_all_global_32, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cint, Cint, Ptr{Cint}), mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, allocated_halo_depth, num_import_rings, partition_vector) + ccall((:AMGX_matrix_upload_all_global_32, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, Cint, Cint, Ptr{Cint}), mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, allocated_halo_depth, num_import_rings, partition_vector) end function AMGX_matrix_upload_distributed(mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, distribution) - @ccall((:AMGX_matrix_upload_distributed, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, AMGX_distribution_handle), mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, distribution) + ccall((:AMGX_matrix_upload_distributed, libAMGX), AMGX_RC, (AMGX_matrix_handle, Cint, Cint, Cint, Cint, Cint, Ptr{Cint}, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, AMGX_distribution_handle), mtx, n_global, n, nnz, block_dimx, block_dimy, row_ptrs, col_indices_global, data, diag_data, distribution) end function AMGX_solver_register_print_callback(func) - @ccall((:AMGX_solver_register_print_callback, libAMGX), AMGX_RC, (AMGX_print_callback,), func) + ccall((:AMGX_solver_register_print_callback, libAMGX), AMGX_RC, (AMGX_print_callback,), func) end function AMGX_solver_resetup(slv, mtx) - @ccall((:AMGX_solver_resetup, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_matrix_handle), slv, mtx) + ccall((:AMGX_solver_resetup, libAMGX), AMGX_RC, (AMGX_solver_handle, AMGX_matrix_handle), slv, mtx) end # Julia wrapper for header: amgx_config.h # Automatically generated using Clang.jl From 197f7b3b7bb7b6bb45060ce27cff59d5a3158fba Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Thu, 9 Feb 2023 11:10:28 -0500 Subject: [PATCH 05/17] WIP --- src/Config.jl | 6 +++++- test/test_solver.jl | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Config.jl b/src/Config.jl index fa7521e..9cee028 100644 --- a/src/Config.jl +++ b/src/Config.jl @@ -19,7 +19,11 @@ end Config(content::String) = create!(Config(), content) function create!(config::Config, d::Dict) - str = sprint(JSON.print, d) + str = "" + for (key, val) in d + str *= string(key, "=", val, ", ") + end + @show str create!(config, str) end Config(d::Dict) = create!(Config(), d) diff --git a/test/test_solver.jl b/test/test_solver.jl index c522140..2c5830d 100644 --- a/test/test_solver.jl +++ b/test/test_solver.jl @@ -47,15 +47,22 @@ using AMGX: Config, Resources, AMGXVector, AMGXMatrix, Solver, dDDI, dFFI AMGX.setup!(s, M) AMGX.solve!(x, s, b; zero_inital_guess=true) @test AMGX.get_status(s) == AMGX.DIVERGED - @test AMGX.get_iterations_number(s) == 0 - @test AMGX.get_iteration_residual(s) > 1.0 + + # Need a proper way to test for build version + if AMGX.build_info()[1] != "2.2.0.132-opensource" + @test AMGX.get_iterations_number(s) == 0 + @test AMGX.get_iteration_residual(s) > 1.0 + else + @test AMGX.get_iterations_number(s) == -1 + @test_throws AMGX.AMGXException("Incorrect parameters for amgx call.") AMGX.get_iteration_residual(s) + end close(M) @test_throws ErrorException AMGX.solve!(x, s, b; zero_inital_guess=true) end @scope @testset "get_iterations_number" begin - c = @! Config(Dict("monitor_residual" => 1, "tolerance" => 1e-14, "store_res_history" => 1)) + c = @! Config(Dict("monitor_residual" => 1, "tolerance" => "1e-14", "store_res_history" => 1)) r = @! Resources(c) M = @! AMGXMatrix(r, mode) x = @! AMGXVector(r, mode) @@ -67,8 +74,9 @@ using AMGX: Config, Resources, AMGXVector, AMGXMatrix, Solver, dDDI, dFFI AMGX.upload!(b, [1.0, 2.0, 4.0]) AMGX.setup!(s, M) AMGX.solve!(x, s, b) + @show niter = AMGX.get_iterations_number(s) @test AMGX.get_iteration_residual(s) < 1e-14 - niter = AMGX.get_iterations_number(s) + @show niter = AMGX.get_iterations_number(s) @test AMGX.get_iteration_residual(s, niter) == AMGX.get_iteration_residual(s) end end From d89064701f6b871d06c520a823f1db6f64962803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Tue, 22 Oct 2024 14:47:52 +0200 Subject: [PATCH 06/17] Catch up to changes in AMGX 2.3/2.4 --- Project.toml | 6 +++--- lib/libAMGX_common.jl | 2 +- src/Solver.jl | 4 ++-- test/test_solver.jl | 13 +++---------- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Project.toml b/Project.toml index 81ae27a..0d462dc 100644 --- a/Project.toml +++ b/Project.toml @@ -4,9 +4,9 @@ uuid = "c963dde9-0319-47f5-bf0c-b07d3c80ffa6" version = "0.2.0" [compat] -AMGX_jll = "2.3" -CEnum = "0.4" -CUDA = "4" +AMGX_jll = "2.4" +CEnum = "0.5" +CUDA = "4,5" JSON = "0.21" julia = "1.6" diff --git a/lib/libAMGX_common.jl b/lib/libAMGX_common.jl index 8323d92..aafaf32 100644 --- a/lib/libAMGX_common.jl +++ b/lib/libAMGX_common.jl @@ -38,7 +38,7 @@ end AMGX_SOLVE_SUCCESS = 0 AMGX_SOLVE_FAILED = 1 AMGX_SOLVE_DIVERGED = 2 - AMGX_SOLVE_NOT_CONVERGED = 2 + AMGX_SOLVE_NOT_CONVERGED = 3 end @cenum AMGX_GET_PARAMS_DESC_FLAG::UInt32 begin diff --git a/src/Solver.jl b/src/Solver.jl index a881e9d..e0338e3 100644 --- a/src/Solver.jl +++ b/src/Solver.jl @@ -59,8 +59,7 @@ end function get_iterations_number(solver::Solver) n_ptr = Ref{Cint}() @checked API.AMGX_solver_get_iterations_number(solver.handle, n_ptr) - # for some reason AMGX returns 1 + number of iterations. - return Int(n_ptr[]) - 1 + return Int(n_ptr[]) end function get_iteration_residual(solver::Solver, iter::Int=get_iterations_number(solver), block_idx::Int=0) @@ -73,6 +72,7 @@ end SUCCESS = Int(API.AMGX_SOLVE_SUCCESS) FAILED = Int(API.AMGX_SOLVE_FAILED) DIVERGED = Int(API.AMGX_SOLVE_DIVERGED) + NOT_CONVERGED = Int(API.AMGX_SOLVE_NOT_CONVERGED) end function get_status(solver::Solver) diff --git a/test/test_solver.jl b/test/test_solver.jl index 2c5830d..2d3e9db 100644 --- a/test/test_solver.jl +++ b/test/test_solver.jl @@ -46,16 +46,9 @@ using AMGX: Config, Resources, AMGXVector, AMGXMatrix, Solver, dDDI, dFFI AMGX.upload!(b, [1.0, 2.0, 4.0]) AMGX.setup!(s, M) AMGX.solve!(x, s, b; zero_inital_guess=true) - @test AMGX.get_status(s) == AMGX.DIVERGED - - # Need a proper way to test for build version - if AMGX.build_info()[1] != "2.2.0.132-opensource" - @test AMGX.get_iterations_number(s) == 0 - @test AMGX.get_iteration_residual(s) > 1.0 - else - @test AMGX.get_iterations_number(s) == -1 - @test_throws AMGX.AMGXException("Incorrect parameters for amgx call.") AMGX.get_iteration_residual(s) - end + @test AMGX.get_status(s) == AMGX.NOT_CONVERGED + @test AMGX.get_iterations_number(s) == 0 + @test AMGX.get_iteration_residual(s) > 1.0 close(M) @test_throws ErrorException AMGX.solve!(x, s, b; zero_inital_guess=true) From e75ed6f55a9b9e2a35c11ae1e85482112ea0ec9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Tue, 22 Oct 2024 14:55:55 +0200 Subject: [PATCH 07/17] Remove debug output --- src/Config.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Config.jl b/src/Config.jl index 9cee028..bebca1c 100644 --- a/src/Config.jl +++ b/src/Config.jl @@ -23,7 +23,6 @@ function create!(config::Config, d::Dict) for (key, val) in d str *= string(key, "=", val, ", ") end - @show str create!(config, str) end Config(d::Dict) = create!(Config(), d) From a6b6fd926832aa7056a90622b9516955f4f88cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Tue, 22 Oct 2024 14:56:18 +0200 Subject: [PATCH 08/17] Split tests into two parts - success code no longer true without residual? --- test/test_solver.jl | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/test/test_solver.jl b/test/test_solver.jl index 2d3e9db..958a327 100644 --- a/test/test_solver.jl +++ b/test/test_solver.jl @@ -18,11 +18,36 @@ using AMGX: Config, Resources, AMGXVector, AMGXMatrix, Solver, dDDI, dFFI AMGX.upload!(x, [0.0, 0.0, 0.0]) AMGX.upload!(b, [1.0, 2.0, 4.0]) + AMGX.setup!(s, M) + AMGX.solve!(x, s, b) + x_h = AMGX.download(b) + @test x_h ≈ [1.0, 2.0, 4.0] + + AMGX.upload!(x, [1.0, 2.0, 3.0]) + AMGX.solve!(x, s, b; zero_inital_guess=true) + x_h = AMGX.download(x) + @test x_h ≈ [1.0, 2.0, 4.0] + end + + @scope @testset "solver with residuals" begin + # Same test as above, but this time output residuals. + c = @! Config(Dict("monitor_residual" => 1)) + r = @! Resources(c) + M = @! AMGXMatrix(r, mode) + x = @! AMGXVector(r, mode) + b = @! AMGXVector(r, mode) + s = @! Solver(r, mode, c) + + AMGX.upload!(M, Cint[0, 1, 2, 3], Cint[0, 1, 2], [1.0, 1.0, 1.0]) + AMGX.upload!(x, [0.0, 0.0, 0.0]) + AMGX.upload!(b, [1.0, 2.0, 4.0]) + AMGX.setup!(s, M) AMGX.solve!(x, s, b) x_h = AMGX.download(b) @test x_h ≈ [1.0, 2.0, 4.0] status = AMGX.get_status(s) + # Note: If we don't output @test status == AMGX.SUCCESS AMGX.upload!(x, [1.0, 2.0, 3.0]) @@ -67,9 +92,9 @@ using AMGX: Config, Resources, AMGXVector, AMGXMatrix, Solver, dDDI, dFFI AMGX.upload!(b, [1.0, 2.0, 4.0]) AMGX.setup!(s, M) AMGX.solve!(x, s, b) - @show niter = AMGX.get_iterations_number(s) + niter = AMGX.get_iterations_number(s) @test AMGX.get_iteration_residual(s) < 1e-14 - @show niter = AMGX.get_iterations_number(s) + niter = AMGX.get_iterations_number(s) @test AMGX.get_iteration_residual(s, niter) == AMGX.get_iteration_residual(s) end end From 83183b778f92b6bbb9ed4a24b3b57a28c29656e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Tue, 22 Oct 2024 15:01:18 +0200 Subject: [PATCH 09/17] Add option to use JSON for config creation --- src/Config.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Config.jl b/src/Config.jl index bebca1c..c3d7530 100644 --- a/src/Config.jl +++ b/src/Config.jl @@ -18,10 +18,14 @@ function create!(config::Config, content::String) end Config(content::String) = create!(Config(), content) -function create!(config::Config, d::Dict) - str = "" - for (key, val) in d - str *= string(key, "=", val, ", ") +function create!(config::Config, d::Dict; json = false) + if json + str = sprint(JSON.print, d) + else + str = "" + for (key, val) in d + str *= string(key, "=", val, ", ") + end end create!(config, str) end From dde7091825658ce09d58ebca1932774c5e0f261c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Tue, 22 Oct 2024 15:01:27 +0200 Subject: [PATCH 10/17] Add comment to revised tests --- test/test_solver.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_solver.jl b/test/test_solver.jl index 958a327..24c8912 100644 --- a/test/test_solver.jl +++ b/test/test_solver.jl @@ -47,7 +47,8 @@ using AMGX: Config, Resources, AMGXVector, AMGXMatrix, Solver, dDDI, dFFI x_h = AMGX.download(b) @test x_h ≈ [1.0, 2.0, 4.0] status = AMGX.get_status(s) - # Note: If we don't output + # Note: If we don't set monitor_residual, the status flag does not + # reflect if the solution has converged or not. @test status == AMGX.SUCCESS AMGX.upload!(x, [1.0, 2.0, 3.0]) From 522a0867771d82ed00cf3b981250c9335cba0c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Tue, 22 Oct 2024 15:14:54 +0200 Subject: [PATCH 11/17] Initialize plugins is depreacted for 2.4 --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 135ba21..3e65420 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,6 @@ The library can now be initialized with: ```julia using AMGX AMGX.initialize() -AMGX.initialize_plugins() ``` ### `Config` From 8e1b5e6c96bf31b7893c4901fbe93a260cf45b31 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Thu, 24 Oct 2024 14:41:17 +0200 Subject: [PATCH 12/17] Update CI. --- .buildkite/pipeline.yml | 93 ++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 39 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index fbf5b49..813320d 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,42 +1,57 @@ -env: - SECRET_CODECOV_TOKEN: "MIXvKy8FpOJzyBykdGQdVdn0jVli57e1Mc1QQQQA6RyLBdViYwCOjLQS+Yh5sgeD5eEm9JLtu6ISePq01EjqpHF7/6zJlcEJTqj2JidcH/sp/FnJiIY0MfV48DSrz1XA7rN6hHQ8wh09+BMG1Ur4CbtwVQl1HF3wZqmt+b2Ahknyxd0mrIoT3j6RJ90vVSGagLLqWolaQLLOFoGNyHbeFV15r1YXLZDkwyE1SSNz4JF3qEN7vFbM9ZnbR4edd7zWABdDiGd3FDnbn1OJFbZ3JzJXph6JAxZyF34RFDzZsERiKyIrAM+0LfyDYqCAcYnjDpJoEASZugTTwIKXOjUkyQ==;U2FsdGVkX1+go3U7v0bYSZs2Lx4R/lwnJXQm4ATdXL2Y7x5H9QDOgazDvusO8UmBtwHFi3szvPuuxr/gcXYgxw==" - steps: - - label: "Julia 1.6" - plugins: - - JuliaCI/julia#v1: - version: 1.6 - - JuliaCI/julia-test#v1: ~ - - JuliaCI/julia-coverage#v1: - codecov: true - agents: - queue: "juliagpu" - cuda: "10.0" - if: build.message !~ /\[skip tests\]/ - timeout_in_minutes: 60 + - group: ":julia: Julia" + steps: + - label: "Julia {{matrix.julia}}" + plugins: + - JuliaCI/julia#v1: + version: "{{matrix.julia}}" + - JuliaCI/julia-test#v1: ~ + - JuliaCI/julia-coverage#v1: ~ + agents: + queue: "juliagpu" + cuda: "*" + commands: | + julia --project -e " + using CUDA + CUDA.set_runtime_version!(local_toolkit=true)" + timeout_in_minutes: 60 + matrix: + setup: + julia: + - "1.10" + - "1.11" - - label: "Julia 1.7" - plugins: - - JuliaCI/julia#v1: - version: 1.7 - - JuliaCI/julia-test#v1: ~ - - JuliaCI/julia-coverage#v1: - codecov: true - agents: - queue: "juliagpu" - cuda: "10.0" - if: build.message !~ /\[skip tests\]/ - timeout_in_minutes: 60 + - group: "CUDA" + steps: + - label: "CUDA {{matrix.cuda}}" + plugins: + - JuliaCI/julia#v1: + version: "1.11" + - JuliaCI/julia-test#v1: ~ + - JuliaCI/julia-coverage#v1: ~ + agents: + queue: "juliagpu" + cuda: "*" + timeout_in_minutes: 45 + matrix: + setup: + cuda: + - "12.6" + - "12.5" + - "12.4" + - "12.3" + - "12.2" + - "12.1" + - "12.0" + - "11.8" + - "11.7" + - "11.6" + - "11.5" + - "11.4" + commands: | + julia --project -e " + using CUDA + CUDA.set_runtime_version!(v\"{{matrix.cuda}}\")" - - label: "Julia 1.8" - plugins: - - JuliaCI/julia#v1: - version: 1.8 - - JuliaCI/julia-test#v1: ~ - - JuliaCI/julia-coverage#v1: - codecov: true - agents: - queue: "juliagpu" - cuda: "10.0" - if: build.message !~ /\[skip tests\]/ - timeout_in_minutes: 60 +env: + SECRET_CODECOV_TOKEN: "MIXvKy8FpOJzyBykdGQdVdn0jVli57e1Mc1QQQQA6RyLBdViYwCOjLQS+Yh5sgeD5eEm9JLtu6ISePq01EjqpHF7/6zJlcEJTqj2JidcH/sp/FnJiIY0MfV48DSrz1XA7rN6hHQ8wh09+BMG1Ur4CbtwVQl1HF3wZqmt+b2Ahknyxd0mrIoT3j6RJ90vVSGagLLqWolaQLLOFoGNyHbeFV15r1YXLZDkwyE1SSNz4JF3qEN7vFbM9ZnbR4edd7zWABdDiGd3FDnbn1OJFbZ3JzJXph6JAxZyF34RFDzZsERiKyIrAM+0LfyDYqCAcYnjDpJoEASZugTTwIKXOjUkyQ==;U2FsdGVkX1+go3U7v0bYSZs2Lx4R/lwnJXQm4ATdXL2Y7x5H9QDOgazDvusO8UmBtwHFi3szvPuuxr/gcXYgxw==" From c078ca5e51218edf829b6ac2cf1968d8f556af7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Thu, 24 Oct 2024 19:55:03 +0200 Subject: [PATCH 13/17] Drop support for Julia<1.10 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 0d462dc..a60a3b5 100644 --- a/Project.toml +++ b/Project.toml @@ -8,7 +8,7 @@ AMGX_jll = "2.4" CEnum = "0.5" CUDA = "4,5" JSON = "0.21" -julia = "1.6" +julia = "1.10" [deps] AMGX_jll = "656d14af-56e4-5275-8e68-4e861d7b5043" From ebf6f885454d1f64a185c8fbef29fd1a14b736fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Thu, 24 Oct 2024 19:55:22 +0200 Subject: [PATCH 14/17] Remove duplicate code, test that solver reports its > 0 --- test/test_solver.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_solver.jl b/test/test_solver.jl index 24c8912..585ad79 100644 --- a/test/test_solver.jl +++ b/test/test_solver.jl @@ -94,8 +94,8 @@ using AMGX: Config, Resources, AMGXVector, AMGXMatrix, Solver, dDDI, dFFI AMGX.setup!(s, M) AMGX.solve!(x, s, b) niter = AMGX.get_iterations_number(s) + @test niter > 0 @test AMGX.get_iteration_residual(s) < 1e-14 - niter = AMGX.get_iterations_number(s) @test AMGX.get_iteration_residual(s, niter) == AMGX.get_iteration_residual(s) end end From 6cc6b20c296988e792053f2e0450d86fe554261b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Mon, 4 Nov 2024 11:47:06 +0100 Subject: [PATCH 15/17] IOBuffer for string generation, remove added JSON kwarg --- src/Config.jl | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Config.jl b/src/Config.jl index c3d7530..d9281ad 100644 --- a/src/Config.jl +++ b/src/Config.jl @@ -18,16 +18,12 @@ function create!(config::Config, content::String) end Config(content::String) = create!(Config(), content) -function create!(config::Config, d::Dict; json = false) - if json - str = sprint(JSON.print, d) - else - str = "" - for (key, val) in d - str *= string(key, "=", val, ", ") - end +function create!(config::Config, d::Dict) + buf = IOBuffer() + for (key, val) in d + write(buf, "$key=$val,") end - create!(config, str) + create!(config, String(take!(buf))) end Config(d::Dict) = create!(Config(), d) From ac985eecc4ea07a7397a4ca6706ee7e33ec883aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Mon, 11 Nov 2024 20:06:30 +0100 Subject: [PATCH 16/17] Update README.md with new NOT_CONVERGED value --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3e65420..a80256b 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,7 @@ After a solve, the status can be retrieved using `AMGX.get_status(solver)`. It i - `AMGX.SUCCESS` - `AMGX.FAILED` - `AMGX.DIVERGED` +- `AMGX.NOT_CONVERGED` The total number of iterations can be retrieved with `AMGX.get_iterations_number(solver)`. From c934cc57880206f1b18be67e5524ac664397d30e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Mon, 11 Nov 2024 20:07:40 +0100 Subject: [PATCH 17/17] Add resetup! for reuse of same system --- src/Solver.jl | 6 ++++++ test/test_solver.jl | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/Solver.jl b/src/Solver.jl index e0338e3..9567e30 100644 --- a/src/Solver.jl +++ b/src/Solver.jl @@ -42,6 +42,12 @@ function setup!(solver::Solver, matrix::AMGXMatrix) return solver end +function resetup!(solver::Solver, matrix::AMGXMatrix) + solver.bound_matrix == matrix || throw(ArgumentError("Matrix is not the same as the one bound to the solver")) + @checked API.AMGX_solver_resetup(solver.handle, matrix.handle) + return solver +end + function solve!(sol::AMGXVector, solver::Solver, rhs::AMGXVector; zero_inital_guess::Bool=false) if solver.bound_matrix === nothing error("no matrix attached to solver") diff --git a/test/test_solver.jl b/test/test_solver.jl index 585ad79..a1fd6d7 100644 --- a/test/test_solver.jl +++ b/test/test_solver.jl @@ -27,6 +27,13 @@ using AMGX: Config, Resources, AMGXVector, AMGXMatrix, Solver, dDDI, dFFI AMGX.solve!(x, s, b; zero_inital_guess=true) x_h = AMGX.download(x) @test x_h ≈ [1.0, 2.0, 4.0] + + # We can reuse the same sparsity structure, but change the coefficients + AMGX.replace_coefficients!(M, [0.1, 0.1, 0.1]) + AMGX.resetup!(s, M) + AMGX.solve!(x, s, b) + x_h2 = AMGX.download(x) + @test x_h2 ≈ [10.0, 20.0, 40.0] end @scope @testset "solver with residuals" begin