petsc-3.4.5 2014-06-29

PetscThreadCommGetAffinities

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

Synopsis

#include "petscthreadcomm.h" 
PetscErrorCode  PetscThreadCommRegister(const char sname[],PetscErrorCode (*function)(PetscThreadComm))
Not collective

Input Parameters

comm -MPI communicator

Output Parameters

affinities -thread affinities

Notes

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,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 = 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 = 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

Input Parameters

comm -the MPI communicator

Notes

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 = 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