diff --git a/CHANGELOG.md b/CHANGELOG.md index 1501da9..c8015cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.1.3] - 2024-07-27 + +### Added + +- Support for PartitionedArrays v0.5. + ## [0.1.2] - 2024-05-18 ### Fixed diff --git a/Project.toml b/Project.toml index 673cd86..a098f24 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PetscCall" uuid = "1194c000-87c4-4102-b4a0-a6217ec4849e" authors = ["Francesc Verdugo and contributors"] -version = "0.1.2" +version = "0.1.3" [deps] Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" @@ -16,7 +16,7 @@ SparseMatricesCSR = "a0a7dd2c-ebf4-11e9-1f05-cf50bc540ca1" [compat] MPI = "0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20" PETSc_jll = "3" -PartitionedArrays = "0.4" +PartitionedArrays = "0.4.7, 0.5" Preferences = "1" SparseArrays = "1" SparseMatricesCSR = "0.6" diff --git a/src/api.jl b/src/api.jl index d6954b2..4b9e7b4 100644 --- a/src/api.jl +++ b/src/api.jl @@ -540,6 +540,7 @@ Base.unsafe_convert(::Type{Ptr{Cvoid}},v::Mat) = v.ptr @wrapper(:MatMumpsSetIcntl,PetscErrorCode,(Mat,PetscInt,PetscInt),(mat,icntl,val),"/Mat/MatMumpsSetIcntl.html") @wrapper(:MatMumpsSetCntl,PetscErrorCode,(Mat,PetscInt,PetscReal),(mat,icntl,val),"/Mat/MatMumpsSetCntl.html") @wrapper(:MatMPIAIJSetPreallocation,PetscErrorCode,(Mat,PetscInt,Ptr{PetscInt},PetscInt,Ptr{PetscInt}),(B,d_nz,d_nnz,o_nz,o_nnz),"/Mat/MatMPIAIJSetPreallocation.html") +@wrapper(:MatSetFromOptions,PetscErrorCode,(Mat,),(mat,),"/Mat/MatSetFromOptions.html") # Matrix products related diff --git a/test/mpi_array/api_test_defs.jl b/test/mpi_array/api_test_defs.jl index d9250cb..63066ae 100644 --- a/test/mpi_array/api_test_defs.jl +++ b/test/mpi_array/api_test_defs.jl @@ -4,6 +4,7 @@ using PartitionedArrays using PetscCall using LinearAlgebra using Test +using SparseArrays function spmv_petsc!(b,A,x) # Convert the input to petsc objects @@ -57,6 +58,29 @@ function test_spmm_petsc(A,B) GC.@preserve ownership PetscCall.@check_error_code PetscCall.MatDestroy(mat_C) end +function petsc_coo(petsc_comm,I,J,V,rows,cols) + m = own_length(rows) + n = own_length(cols) + M = global_length(rows) + N = global_length(cols) + I .= I .- 1 + J .= J .- 1 + ownership = (I,J,V) + ncoo = length(I) + A = Ref{PetscCall.Mat}() + PetscCall.@check_error_code PetscCall.MatCreate(petsc_comm,A) + PetscCall.@check_error_code PetscCall.MatSetType(A[],PetscCall.MATMPIAIJ) + PetscCall.@check_error_code PetscCall.MatSetSizes(A[],m,n,M,N) + PetscCall.@check_error_code PetscCall.MatSetFromOptions(A[]) + GC.@preserve ownership begin + PetscCall.@check_error_code PetscCall.MatSetPreallocationCOO(A[],ncoo,I,J) + PetscCall.@check_error_code PetscCall.MatSetValuesCOO(A[],V,PetscCall.ADD_VALUES) + PetscCall.@check_error_code PetscCall.MatAssemblyBegin(A[],PetscCall.MAT_FINAL_ASSEMBLY) + PetscCall.@check_error_code PetscCall.MatAssemblyEnd(A[],PetscCall.MAT_FINAL_ASSEMBLY) + PetscCall.@check_error_code PetscCall.MatDestroy(A) + end +end + function main(distribute,params) nodes_per_dir = params.nodes_per_dir parts_per_dir = params.parts_per_dir @@ -80,6 +104,13 @@ function main(distribute,params) @test norm(c)/norm(b1) < tol B = 2*A test_spmm_petsc(A,B) + index_type = PetscCall.PetscInt + value_type = PetscCall.PetscScalar + I,J,V,row_partition,col_partition = laplacian_fem(nodes_per_dir,parts_per_dir,ranks;index_type,value_type) + petsc_comm = PetscCall.setup_petsc_comm(ranks) + map(I,J,V,row_partition,col_partition) do args... + petsc_coo(petsc_comm,args...) + end end end #module