Skip to content

Commit c80f4a8

Browse files
authored
Merge pull request #11 from fverdugo/experimental
Release 0.1.3
2 parents 56539b5 + 3cb4994 commit c80f4a8

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.1.3] - 2024-07-27
9+
10+
### Added
11+
12+
- Support for PartitionedArrays v0.5.
13+
814
## [0.1.2] - 2024-05-18
915

1016
### Fixed

Project.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "PetscCall"
22
uuid = "1194c000-87c4-4102-b4a0-a6217ec4849e"
33
authors = ["Francesc Verdugo <[email protected]> and contributors"]
4-
version = "0.1.2"
4+
version = "0.1.3"
55

66
[deps]
77
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
@@ -16,7 +16,7 @@ SparseMatricesCSR = "a0a7dd2c-ebf4-11e9-1f05-cf50bc540ca1"
1616
[compat]
1717
MPI = "0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20"
1818
PETSc_jll = "3"
19-
PartitionedArrays = "0.4"
19+
PartitionedArrays = "0.4.7, 0.5"
2020
Preferences = "1"
2121
SparseArrays = "1"
2222
SparseMatricesCSR = "0.6"

src/api.jl

+1
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ Base.unsafe_convert(::Type{Ptr{Cvoid}},v::Mat) = v.ptr
540540
@wrapper(:MatMumpsSetIcntl,PetscErrorCode,(Mat,PetscInt,PetscInt),(mat,icntl,val),"/Mat/MatMumpsSetIcntl.html")
541541
@wrapper(:MatMumpsSetCntl,PetscErrorCode,(Mat,PetscInt,PetscReal),(mat,icntl,val),"/Mat/MatMumpsSetCntl.html")
542542
@wrapper(:MatMPIAIJSetPreallocation,PetscErrorCode,(Mat,PetscInt,Ptr{PetscInt},PetscInt,Ptr{PetscInt}),(B,d_nz,d_nnz,o_nz,o_nnz),"/Mat/MatMPIAIJSetPreallocation.html")
543+
@wrapper(:MatSetFromOptions,PetscErrorCode,(Mat,),(mat,),"/Mat/MatSetFromOptions.html")
543544

544545
# Matrix products related
545546

test/mpi_array/api_test_defs.jl

+31
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ using PartitionedArrays
44
using PetscCall
55
using LinearAlgebra
66
using Test
7+
using SparseArrays
78

89
function spmv_petsc!(b,A,x)
910
# Convert the input to petsc objects
@@ -57,6 +58,29 @@ function test_spmm_petsc(A,B)
5758
GC.@preserve ownership PetscCall.@check_error_code PetscCall.MatDestroy(mat_C)
5859
end
5960

61+
function petsc_coo(petsc_comm,I,J,V,rows,cols)
62+
m = own_length(rows)
63+
n = own_length(cols)
64+
M = global_length(rows)
65+
N = global_length(cols)
66+
I .= I .- 1
67+
J .= J .- 1
68+
ownership = (I,J,V)
69+
ncoo = length(I)
70+
A = Ref{PetscCall.Mat}()
71+
PetscCall.@check_error_code PetscCall.MatCreate(petsc_comm,A)
72+
PetscCall.@check_error_code PetscCall.MatSetType(A[],PetscCall.MATMPIAIJ)
73+
PetscCall.@check_error_code PetscCall.MatSetSizes(A[],m,n,M,N)
74+
PetscCall.@check_error_code PetscCall.MatSetFromOptions(A[])
75+
GC.@preserve ownership begin
76+
PetscCall.@check_error_code PetscCall.MatSetPreallocationCOO(A[],ncoo,I,J)
77+
PetscCall.@check_error_code PetscCall.MatSetValuesCOO(A[],V,PetscCall.ADD_VALUES)
78+
PetscCall.@check_error_code PetscCall.MatAssemblyBegin(A[],PetscCall.MAT_FINAL_ASSEMBLY)
79+
PetscCall.@check_error_code PetscCall.MatAssemblyEnd(A[],PetscCall.MAT_FINAL_ASSEMBLY)
80+
PetscCall.@check_error_code PetscCall.MatDestroy(A)
81+
end
82+
end
83+
6084
function main(distribute,params)
6185
nodes_per_dir = params.nodes_per_dir
6286
parts_per_dir = params.parts_per_dir
@@ -80,6 +104,13 @@ function main(distribute,params)
80104
@test norm(c)/norm(b1) < tol
81105
B = 2*A
82106
test_spmm_petsc(A,B)
107+
index_type = PetscCall.PetscInt
108+
value_type = PetscCall.PetscScalar
109+
I,J,V,row_partition,col_partition = laplacian_fem(nodes_per_dir,parts_per_dir,ranks;index_type,value_type)
110+
petsc_comm = PetscCall.setup_petsc_comm(ranks)
111+
map(I,J,V,row_partition,col_partition) do args...
112+
petsc_coo(petsc_comm,args...)
113+
end
83114
end
84115

85116
end #module

0 commit comments

Comments
 (0)