petsc-3.3-p7 2013-05-11


Returns the core affinities set for the thread communicator associated with the MPI_Comm


#include "petscthreadcomm.h" 
PetscErrorCode  PetscThreadCommRegisterDestroy(void)
Not collective

Input Parameters

comm -MPI communicator

Output Parameters

affinities -thread affinities


The user must allocate space (nthreads PetscInts) for the affinities. Must call PetscThreadCommSetAffinities before.

*/ 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

Input Parameters

tcomm - the thread communicator
type - the type of thread model needed

Options Database keys

-threadcomm_type <type>

Available types See "petsc/include/petscthreadcomm.h" for available types

*/ PetscErrorCode PetscThreadCommSetType(PetscThreadComm tcomm,const PetscThreadCommType type) { PetscErrorCode ierr,(*r)(PetscThreadComm); char ttype[256]; PetscBool flg;

PetscFunctionBegin; PetscValidCharPointer(type,2); if(!PetscThreadCommRegisterAllCalled) { ierr = PetscThreadCommRegisterAll(PETSC_NULL);CHKERRQ(ierr);}

ierr = PetscOptionsBegin(PETSC_COMM_WORLD,PETSC_NULL,"Thread comm - setting threading model",PETSC_NULL);CHKERRQ(ierr); ierr = PetscOptionsList("-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 = PetscFListFind(PetscThreadCommList,PETSC_COMM_WORLD,ttype,PETSC_TRUE,(void (**)(void)) &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);

PetscFunctionReturn(0); }

#undef __FUNCT__ #define __FUNCT__ "PetscThreadCommBarrier" /* PetscThreadCommBarrier - Apply a barrier on the thread communicator associated with the MPI communicator

Input Parameters

comm -the MPI communicator


This routine provides an interface to put an explicit barrier between successive kernel calls to ensure that the first kernel is executed by all the threads before calling the next one.

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 = PetscCommGetThreadComm(comm,&tcomm);CHKERRQ(ierr); if(tcomm->ops->barrier) { (*tcomm->ops->barrier)(tcomm); } PetscFunctionReturn(0); }

#undef __FUNCT__ #define __FUNCT__ "PetscThreadCommRegisterDestroy" /*@C PetscThreadCommRegisterDestroy - Frees the list of thread communicator models that were registered by PetscThreadCommRegisterDynamic().

Not Collective


PetscThreadComm, register, destroy

See Also


Index of all PetscThreadComm routines
Table of Contents for all manual pages
Index of all manual pages