6161function petsc_coo (petsc_comm,I,J,V,rows,cols)
6262 m = own_length (rows)
6363 n = own_length (cols)
64- M = PetscCall . PETSC_DECIDE
65- N = PetscCall . PETSC_DECIDE
64+ M = global_length (rows)
65+ N = global_length (cols)
6666 I .= I .- 1
6767 J .= J .- 1
6868 ownership = (I,J,V)
@@ -72,11 +72,13 @@ function petsc_coo(petsc_comm,I,J,V,rows,cols)
7272 PetscCall. @check_error_code PetscCall. MatSetType (A[],PetscCall. MATMPIAIJ)
7373 PetscCall. @check_error_code PetscCall. MatSetSizes (A[],m,n,M,N)
7474 PetscCall. @check_error_code PetscCall. MatSetFromOptions (A[])
75- PetscCall. @check_error_code PetscCall. MatSetPreallocationCOO (A[],ncoo,I,J)
76- PetscCall. @check_error_code PetscCall. MatSetValuesCOO (A[],V,PetscCall. ADD_VALUES)
77- # PetscCall.@check_error_code PetscCall.MatAssemblyBegin(A[],PetscCall.MAT_FINAL_ASSEMBLY)
78- # PetscCall.@check_error_code PetscCall.MatAssemblyEnd(A[],PetscCall.MAT_FINAL_ASSEMBLY)
79- GC. @preserve ownership PetscCall. @check_error_code PetscCall. MatDestroy (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
8082end
8183
8284function generate_coo (args... )
@@ -86,10 +88,12 @@ function generate_coo(args...)
8688 (I,J,V) = map (partition (A),row_partition,col_partition) do myA,rows,cols
8789 Id,Jd,Vd = findnz (myA. blocks. own_own)
8890 Io,Jo,Vo = findnz (myA. blocks. own_ghost)
89- myI = vcat (map_own_to_global! (Id,rows),map_ghost_to_global ! (Io,rows))
91+ myI = vcat (map_own_to_global! (Id,rows),map_own_to_global ! (Io,rows))
9092 myJ = vcat (map_own_to_global! (Jd,cols),map_ghost_to_global! (Jo,cols))
9193 myV = vcat (Vd,Vo)
92- (myI,myJ,myV)
94+ Ti = PetscCall. PetscInt
95+ Tv = PetscCall. PetscScalar
96+ (convert (Vector{Ti},myI),convert (Vector{Ti},myJ),convert (Vector{Tv},myV))
9397 end |> tuple_of_arrays
9498 I,J,V,row_partition,col_partition
9599end
@@ -118,6 +122,9 @@ function main(distribute,params)
118122 B = 2 * A
119123 test_spmm_petsc (A,B)
120124 I,J,V,row_partition,col_partition = generate_coo (nodes_per_dir,parts_per_dir,ranks)
125+ # index_type = PetscCall.PetscInt
126+ # value_type = PetscCall.PetscScalar
127+ # I,J,V,row_partition,col_partition = laplacian_fem(nodes_per_dir,parts_per_dir,ranks;index_type,value_type)
121128 petsc_comm = PetscCall. setup_petsc_comm (ranks)
122129 map (I,J,V,row_partition,col_partition) do args...
123130 petsc_coo (petsc_comm,args... )
0 commit comments