Skip to content

Release 0.1.3 #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PetscCall"
uuid = "1194c000-87c4-4102-b4a0-a6217ec4849e"
authors = ["Francesc Verdugo <[email protected]> and contributors"]
version = "0.1.2"
version = "0.1.3"

[deps]
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
31 changes: 31 additions & 0 deletions test/mpi_array/api_test_defs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Loading