#include "petscthreadcomm.h" PetscErrorCode PetscThreadCommRegister(const char sname[],PetscErrorCode (*function)(PetscThreadComm))Not collective
*/ PetscErrorCode PetscThreadCommGetAffinities(MPI_Comm comm,PetscInt affinities[]) { PetscErrorCode ierr; PetscThreadComm tcomm=0;
PetscFunctionBegin; ierr = PetscCommGetThreadComm(comm,&tcomm);CHKERRQ(ierr); PetscValidIntPointer(affinities,2); ierr = PetscMemcpy(affinities,tcomm->affinities,tcomm->nworkThreads*sizeof(PetscInt));CHKERRQ(ierr); PetscFunctionReturn(0); }
#undef __FUNCT__ #define __FUNCT__ "PetscThreadCommSetType" /* PetscThreadCommSetType - Sets the threading model for the thread communicator
Logically collective
tcomm | - the thread communicator | |
type | - the type of thread model needed |
Available types See "petsc/include/petscthreadcomm.h" for available types
*/ PetscErrorCode PetscThreadCommSetType(PetscThreadComm tcomm,PetscThreadCommType type) { PetscErrorCode ierr,(*r)(PetscThreadComm); char ttype[256]; PetscBool flg;
PetscFunctionBegin; PetscValidCharPointer(type,2); if (!PetscThreadCommRegisterAllCalled) { ierr = PetscThreadCommRegisterAll();CHKERRQ(ierr);}
ierr = PetscOptionsBegin(PETSC_COMM_WORLD,NULL,"Thread comm - setting threading model",NULL);CHKERRQ(ierr); ierr = PetscOptionsFList("-threadcomm_type","Thread communicator model","PetscThreadCommSetType",PetscThreadCommList,type,ttype,256,&flg);CHKERRQ(ierr); ierr = PetscOptionsEnd();CHKERRQ(ierr); if (!flg) { ierr = PetscStrcpy(ttype,type);CHKERRQ(ierr); } ierr = PetscFunctionListFind(PetscThreadCommList,ttype,&r);CHKERRQ(ierr); if (!r) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_UNKNOWN_TYPE,"Unable to find requested PetscThreadComm type %s",ttype); ierr = (*r)(tcomm);CHKERRQ(ierr); ierr = PetscStrcmp(NOTHREAD,tcomm->type,&tcomm->isnothread);CHKERRQ(ierr); PetscFunctionReturn(0); }
#undef __FUNCT__ #define __FUNCT__ "PetscThreadCommBarrier" /* PetscThreadCommBarrier - Apply a barrier on the thread communicator associated with the MPI communicator
Not collective
Called by the main thread only.
May not be applicable to all types. */ PetscErrorCode PetscThreadCommBarrier(MPI_Comm comm) { PetscErrorCode ierr; PetscThreadComm tcomm=0;
PetscFunctionBegin; ierr = PetscLogEventBegin(ThreadComm_Barrier,0,0,0,0);CHKERRQ(ierr); ierr = PetscCommGetThreadComm(comm,&tcomm);CHKERRQ(ierr); if (tcomm->ops->barrier) { ierr = (*tcomm->ops->barrier)(tcomm);CHKERRQ(ierr); } ierr = PetscLogEventEnd(ThreadComm_Barrier,0,0,0,0);CHKERRQ(ierr); PetscFunctionReturn(0); }
#undef __FUNCT__ #define __FUNCT__ "PetscThreadCommRegister" /*@C PetscThreadCommRegister -
Level:developer
Location:src/sys/threadcomm/interface/threadcomm.c
Index of all PetscThreadComm routines
Table of Contents for all manual pages
Index of all manual pages