:orphan:
# PetscObjectGetComm
Gets the MPI communicator for any `PetscObject`, regardless of the type.
## Synopsis
```
#include "petscsys.h"
PetscErrorCode PetscObjectGetComm(PetscObject obj, MPI_Comm *comm)
```
Not Collective
## Input Parameter
- ***obj -*** any PETSc object, for example a `Vec`, `Mat` or `KSP`. Thus must be
cast with a (`PetscObject`), for example,
`PetscObjectGetComm`((`PetscObject`)mat,&comm);
## Output Parameter
- ***comm -*** the MPI communicator
## See Also
`PetscObject`, `PetscObjectComm()`
## Level
advanced
## Location
src/sys/objects/gcomm.c
## Examples
src/dm/impls/plex/tutorials/ex11.c
src/dm/tutorials/ex15.c
src/ksp/ksp/tutorials/ex42.c
src/ksp/ksp/tutorials/ex55.c
src/ksp/ksp/tutorials/ex73.c
src/snes/tutorials/ex12.c
src/snes/tutorials/ex13.c
src/snes/tutorials/ex26.c
src/snes/tutorials/ex30.c
src/snes/tutorials/ex47cu.cu
src/snes/tutorials/ex48.c
---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/objects/gcomm.c)
[Index of all Sys routines](index.md)
[Table of Contents for all manual pages](/manualpages/index.md)
[Index of all manual pages](/manualpages/singleindex.md)