Hi,
Does anybody understand why MatSetSizes seem to behave differently in C and python?
I would expect the attached examples to be strictly equivalent but the python version fails in parallel. It may be that the python interface is different, but I don’t see any mention of this in the python docs.
Regards,
Blaise
SiBookPro:test (master)$ mpirun -np 2 python3 testL2G2.py nrowsLoc: 10 ncolsLoc: 20
Traceback (most recent call last):
File "/Users/blaise/Development/ccG_CR/test/testL2G2.py", line 20, in <module>
nrowsLoc: 11 ncolsLoc: 21
Traceback (most recent call last):
File "/Users/blaise/Development/ccG_CR/test/testL2G2.py", line 20, in <module>
sys.exit(main())
sys.exit(main())
^^^^^^
File "/Users/blaise/Development/ccG_CR/test/testL2G2.py", line 12, in main
^^^^^^
File "/Users/blaise/Development/ccG_CR/test/testL2G2.py", line 12, in main
P.setSizes([nrowsLoc,ncolsLoc],1)
P.setSizes([nrowsLoc,ncolsLoc],1)
File "petsc4py/PETSc/Mat.pyx", line 323, in petsc4py.PETSc.Mat.setSizes
petsc4py.PETSc.Error: error code 62
[1] MatSetSizes() at /opt/HPC/petsc-release/src/mat/utils/gcreate.c:161
[1] Invalid argument
[1] Int value must be same on all processes, argument # 4
File "petsc4py/PETSc/Mat.pyx", line 323, in petsc4py.PETSc.Mat.setSizes
petsc4py.PETSc.Error: error code 62
[0] MatSetSizes() at /opt/HPC/petsc-release/src/mat/utils/gcreate.c:161
[0] Invalid argument
[0] Int value must be same on all processes, argument # 4
Does anybody understand why MatSetSizes seem to behave differently in C and python?
I would expect the attached examples to be strictly equivalent but the python version fails in parallel. It may be that the python interface is different, but I don’t see any mention of this in the python docs.
Regards,
Blaise
SiBookPro:test (master)$ mpirun -np 2 python3 testL2G2.py nrowsLoc: 10 ncolsLoc: 20
Traceback (most recent call last):
File "/Users/blaise/Development/ccG_CR/test/testL2G2.py", line 20, in <module>
nrowsLoc: 11 ncolsLoc: 21
Traceback (most recent call last):
File "/Users/blaise/Development/ccG_CR/test/testL2G2.py", line 20, in <module>
sys.exit(main())
sys.exit(main())
^^^^^^
File "/Users/blaise/Development/ccG_CR/test/testL2G2.py", line 12, in main
^^^^^^
File "/Users/blaise/Development/ccG_CR/test/testL2G2.py", line 12, in main
P.setSizes([nrowsLoc,ncolsLoc],1)
P.setSizes([nrowsLoc,ncolsLoc],1)
File "petsc4py/PETSc/Mat.pyx", line 323, in petsc4py.PETSc.Mat.setSizes
petsc4py.PETSc.Error: error code 62
[1] MatSetSizes() at /opt/HPC/petsc-release/src/mat/utils/gcreate.c:161
[1] Invalid argument
[1] Int value must be same on all processes, argument # 4
File "petsc4py/PETSc/Mat.pyx", line 323, in petsc4py.PETSc.Mat.setSizes
petsc4py.PETSc.Error: error code 62
[0] MatSetSizes() at /opt/HPC/petsc-release/src/mat/utils/gcreate.c:161
[0] Invalid argument
[0] Int value must be same on all processes, argument # 4
—
Canada Research Chair in Mathematical and Computational Aspects of Solid Mechanics (Tier 1)
Professor, Department of Mathematics & Statistics
Hamilton Hall room 409A, McMaster University
1280 Main Street West, Hamilton, Ontario L8S 4K1, Canada
https://www.math.mcmaster.ca/bourdin | +1 (905) 525 9140 ext. 27243
testL2G2.c
Description: testL2G2.c
#!/usr/bin/env python3 import sys from petsc4py import PETSc def main(): comm = PETSc.COMM_WORLD nrowsLoc = 10 + comm.rank ncolsLoc = 20 + comm.rank
P = PETSc.Mat().create(comm=comm) print("nrowsLoc: {} ncolsLoc: {}".format(nrowsLoc,ncolsLoc)) P.setSizes([nrowsLoc,ncolsLoc],1) P.setType('mpiaij') P.setUp() P.assemblyBegin() P.assemblyEnd() P.view() if __name__ == "__main__": sys.exit(main())