Actual source code: petscthreadcomm.h

petsc-3.4.5 2014-06-29
  4: #include <petscsys.h>

  6: /* Function pointer cast for the kernel function */
  7: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*PetscThreadKernel)(PetscInt,...);

  9: /*
 10:   PetscThreadComm - Abstract object that manages all thread communication models

 12:   Level: developer

 14:   Concepts: threads

 16: .seealso: PetscThreadCommCreate(), PetscThreadCommDestroy
 17: */
 18: typedef struct _p_PetscThreadComm *PetscThreadComm;

 20: /*
 21:    PetscThreadCommReduction - Context used for managing threaded reductions

 23:    Level: developer
 24: */
 25: typedef struct _p_PetscThreadCommReduction *PetscThreadCommReduction;

 27: typedef const char* PetscThreadCommType;
 28: #define PTHREAD             "pthread"
 29: #define NOTHREAD            "nothread"
 30: #define OPENMP              "openmp"

 32: PETSC_EXTERN PetscFunctionList PetscThreadCommList;

 34: typedef enum {THREADCOMM_SUM,THREADCOMM_PROD,THREADCOMM_MAX,THREADCOMM_MIN,THREADCOMM_MAXLOC,THREADCOMM_MINLOC} PetscThreadCommReductionOp;
 35: PETSC_EXTERN const char* const PetscThreadCommReductionOps[];

 37: /* Max. number of reductions */
 38: #define PETSC_REDUCTIONS_MAX 32

 40: PETSC_EXTERN PetscErrorCode PetscGetNCores(PetscInt*);
 41: PETSC_EXTERN PetscErrorCode PetscCommGetThreadComm(MPI_Comm,PetscThreadComm*);
 42: PETSC_EXTERN PetscErrorCode PetscThreadCommInitializePackage(void);
 43: PETSC_EXTERN PetscErrorCode PetscThreadCommFinalizePackage(void);
 44: PETSC_EXTERN PetscErrorCode PetscThreadCommInitialize(void);
 45: PETSC_EXTERN PetscErrorCode PetscThreadCommGetNThreads(MPI_Comm,PetscInt*);
 46: PETSC_EXTERN PetscErrorCode PetscThreadCommGetAffinities(MPI_Comm,PetscInt[]);
 47: PETSC_EXTERN PetscErrorCode PetscThreadCommView(MPI_Comm,PetscViewer);
 48: PETSC_EXTERN PetscErrorCode PetscThreadCommGetScalars(MPI_Comm,PetscScalar**,PetscScalar**,PetscScalar**);
 49: PETSC_EXTERN PetscErrorCode PetscThreadCommGetInts(MPI_Comm,PetscInt**,PetscInt**,PetscInt**);
 50: PETSC_EXTERN PetscErrorCode PetscThreadCommRunKernel(MPI_Comm,PetscErrorCode (*)(PetscInt,...),PetscInt,...);
 51: PETSC_EXTERN PetscErrorCode PetscThreadCommRunKernel0(MPI_Comm,PetscErrorCode (*)(PetscInt,...));
 52: PETSC_EXTERN PetscErrorCode PetscThreadCommRunKernel1(MPI_Comm,PetscErrorCode (*)(PetscInt,...),void*);
 53: PETSC_EXTERN PetscErrorCode PetscThreadCommRunKernel2(MPI_Comm,PetscErrorCode (*)(PetscInt,...),void*,void*);
 54: PETSC_EXTERN PetscErrorCode PetscThreadCommRunKernel3(MPI_Comm,PetscErrorCode (*)(PetscInt,...),void*,void*,void*);
 55: PETSC_EXTERN PetscErrorCode PetscThreadCommRunKernel4(MPI_Comm,PetscErrorCode (*)(PetscInt,...),void*,void*,void*,void*);
 56: PETSC_EXTERN PetscErrorCode PetscThreadCommRunKernel6(MPI_Comm,PetscErrorCode (*)(PetscInt,...),void*,void*,void*,void*,void*,void*);
 57: PETSC_EXTERN PetscErrorCode PetscThreadCommBarrier(MPI_Comm);
 58: PETSC_EXTERN PetscErrorCode PetscThreadCommGetOwnershipRanges(MPI_Comm,PetscInt,PetscInt*[]);
 59: PETSC_EXTERN PetscErrorCode PetscThreadCommGetRank(PetscThreadComm,PetscInt*);
 60: PETSC_EXTERN PetscErrorCode PetscThreadCommAttach(MPI_Comm,PetscThreadComm);
 61: PETSC_EXTERN PetscErrorCode PetscThreadCommDestroy(PetscThreadComm*);
 62: PETSC_EXTERN PetscErrorCode PetscGetThreadCommWorld(PetscThreadComm*);

 64: /* Reduction operations */
 65: PETSC_EXTERN PetscErrorCode PetscThreadReductionKernelPost(PetscInt,PetscThreadCommReduction,void*);
 66: PETSC_EXTERN PetscErrorCode PetscThreadReductionKernelEnd(PetscInt,PetscThreadCommReduction,void*);
 67: PETSC_EXTERN PetscErrorCode PetscThreadReductionBegin(MPI_Comm,PetscThreadCommReductionOp,PetscDataType,PetscInt,PetscThreadCommReduction*);
 68: PETSC_EXTERN PetscErrorCode PetscThreadReductionEnd(PetscThreadCommReduction,void*);

 70: #endif