I would like to create a parallel solver using petsc4py as one component of a larger application. I can easily get PETSc.COMM_WORLD.getSize() to be 4 by calling mpiexec -n 4 python my_prog.pyhowever, this creates 4 applications, whereas I only want the PETSc solve in parallel. Currently it is only using one process, and provides performance essentially the same as scipy's spsolve. I can refactor such that the KSP solve is its own program and spawn that from the main program, using IO between them to send the matrices etc, but that seems less than ideal. Is it possible for petsc4py to create its own mpi procs via petsc4py.init or somesuch, or specify the number of partitions programatically? Or am I missing something more fundamental to the whole question?
setting COMM_WORLD size from petsc4py without mpiexec command line
petsc;mpi