Actual source code: petscthreadcomm.h
petsc-3.3-p3 2012-08-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: PetscThreadCommRedCtx - Context used for doing threaded reductions
23: Level: developer
24: */
25: typedef struct _p_PetscThreadCommRedCtx *PetscThreadCommRedCtx;
27: #define PetscThreadCommType char*
28: #define PTHREAD "pthread"
29: #define NOTHREAD "nothread"
30: #define OPENMP "openmp"
32: PETSC_EXTERN PetscFList PetscThreadCommList;
34: typedef enum {THREADCOMM_SUM,THREADCOMM_PROD} PetscThreadCommReductionOp;
35: PETSC_EXTERN const char *const PetscThreadCommReductionOps[];
37: PETSC_EXTERN PetscErrorCode PetscGetNCores(PetscInt*);
38: PETSC_EXTERN PetscErrorCode PetscCommGetThreadComm(MPI_Comm,PetscThreadComm*);
39: PETSC_EXTERN PetscErrorCode PetscThreadCommInitializePackage(const char *path);
40: PETSC_EXTERN PetscErrorCode PetscThreadCommFinalizePackage(void);
41: PETSC_EXTERN PetscErrorCode PetscThreadCommInitialize(void);
42: PETSC_EXTERN PetscErrorCode PetscThreadCommGetNThreads(MPI_Comm,PetscInt*);
43: PETSC_EXTERN PetscErrorCode PetscThreadCommGetAffinities(MPI_Comm,PetscInt[]);
44: PETSC_EXTERN PetscErrorCode PetscThreadCommView(MPI_Comm,PetscViewer);
45: PETSC_EXTERN PetscErrorCode PetscThreadCommGetScalars(MPI_Comm,PetscScalar**,PetscScalar**,PetscScalar**);
46: PETSC_EXTERN PetscErrorCode PetscThreadCommRunKernel(MPI_Comm,PetscErrorCode (*)(PetscInt,...),PetscInt,...);
47: PETSC_EXTERN PetscErrorCode PetscThreadCommBarrier(MPI_Comm);
48: PETSC_EXTERN PetscErrorCode PetscThreadCommGetOwnershipRanges(MPI_Comm,PetscInt,PetscInt*[]);
49: PETSC_EXTERN PetscErrorCode PetscThreadCommRegisterDestroy(void);
50: PETSC_EXTERN PetscInt PetscThreadCommGetRank(PetscThreadComm);
52: /* Reduction operations */
53: PETSC_EXTERN PetscErrorCode PetscThreadReductionKernelBegin(PetscInt,PetscThreadCommRedCtx,void*);
54: PETSC_EXTERN PetscErrorCode PetscThreadReductionKernelEnd(PetscInt,PetscThreadCommRedCtx,void*);
55: PETSC_EXTERN PetscErrorCode PetscThreadReductionBegin(MPI_Comm,PetscThreadCommReductionOp,PetscDataType,PetscThreadCommRedCtx*);
56: PETSC_EXTERN PetscErrorCode PetscThreadReductionEnd(PetscThreadCommRedCtx,void*);
60: #endif