Date: 2013-07-02T14:39:53+00:00

Actual source code: dlregisvec.c
petsc-3.4.2 2013-07-02

      2: #include <petsc-private/vecimpl.h>
      3: #include <petscpf.h>
      4: #include <petscsf.h>
      5: #include <petscao.h>

      7: static PetscBool ISPackageInitialized = PETSC_FALSE;
     10: /*@C
     11:   ISFinalizePackage - This function destroys everything in the IS package. It is
     12:   called from PetscFinalize().

     14:   Level: developer

     16: .keywords: Petsc, destroy, package
     17: .seealso: PetscFinalize()
     18: @*/
     19: PetscErrorCode  ISFinalizePackage(void)
     20: {

     24:   PetscFunctionListDestroy(&ISList);
     25:   ISPackageInitialized = PETSC_FALSE;
     26:   ISRegisterAllCalled  = PETSC_FALSE;
     27:   return(0);
     28: }

     32: /*@C
     33:       ISInitializePackage - This function initializes everything in the IS package. It is called
     34:   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to ISCreateXXXX()
     35:   when using static libraries.

     37:   Level: developer

     39: .keywords: Vec, initialize, package
     40: .seealso: PetscInitialize()
     41: @*/
     42: PetscErrorCode  ISInitializePackage(void)
     43: {
     44:   char           logList[256];
     45:   char           *className;
     46:   PetscBool      opt;

     50:   if (ISPackageInitialized) return(0);
     51:   ISPackageInitialized = PETSC_TRUE;
     52:   /* Register Constructors */
     53:   ISRegisterAll();
     54:   /* Register Classes */
     55:   PetscClassIdRegister("Index Set",&IS_CLASSID);
     56:   PetscClassIdRegister("IS L to G Mapping",&IS_LTOGM_CLASSID);
     57:   PetscClassIdRegister("Section",&PETSC_SECTION_CLASSID);

     59:   /* Process info exclusions */
     60:   PetscOptionsGetString(NULL, "-info_exclude", logList, 256, &opt);
     61:   if (opt) {
     62:     PetscStrstr(logList, "is", &className);
     63:     if (className) {
     64:       PetscInfoDeactivateClass(IS_CLASSID);
     65:       PetscInfoDeactivateClass(IS_LTOGM_CLASSID);
     66:     }
     67:   }
     68:   /* Process summary exclusions */
     69:   PetscOptionsGetString(NULL, "-log_summary_exclude", logList, 256, &opt);
     70:   if (opt) {
     71:     PetscStrstr(logList, "is", &className);
     72:     if (className) {
     73:       PetscLogEventDeactivateClass(IS_CLASSID);
     74:       PetscLogEventDeactivateClass(IS_LTOGM_CLASSID);
     75:     }
     76:   }
     77:   PetscRegisterFinalize(ISFinalizePackage);
     78:   return(0);
     79: }

     81: extern MPI_Op PetscSplitReduction_Op;
     82: extern MPI_Op VecMax_Local_Op;
     83: extern MPI_Op VecMin_Local_Op;

     85: PETSC_EXTERN void MPIAPI VecMax_Local(void*,void*,PetscMPIInt*,MPI_Datatype*);
     86: PETSC_EXTERN void MPIAPI VecMin_Local(void*,void*,PetscMPIInt*,MPI_Datatype*);
     87: PETSC_EXTERN void MPIAPI PetscSplitReduction_Local(void*,void*,PetscMPIInt*,MPI_Datatype*);

     89: const char *const NormTypes[] = {"1","2","FROBENIUS","INFINITY","1_AND_2","NormType","NORM_",0};
     90: PetscInt          NormIds[7];  /* map from NormType to IDs used to cache Normvalues */

     92: static PetscBool  VecPackageInitialized = PETSC_FALSE;

     96: /*@C
     97:   VecInitializePackage - This function initializes everything in the Vec package. It is called
     98:   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to VecCreate()
     99:   when using static libraries.

    101:   Level: developer

    103: .keywords: Vec, initialize, package
    104: .seealso: PetscInitialize()
    105: @*/
    106: PetscErrorCode  VecInitializePackage(void)
    107: {
    108:   char           logList[256];
    109:   char           *className;
    110:   PetscBool      opt;
    112:   PetscInt       i;

    115:   if (VecPackageInitialized) return(0);
    116:   VecPackageInitialized = PETSC_TRUE;
    117:   /* Register Classes */
    118:   PetscClassIdRegister("Vector",&VEC_CLASSID);
    119:   PetscClassIdRegister("Vector Scatter",&VEC_SCATTER_CLASSID);
    120:   /* Register Constructors */
    121:   VecRegisterAll();
    122:   /* Register Events */
    123:   PetscLogEventRegister("VecView",          VEC_CLASSID,&VEC_View);
    124:   PetscLogEventRegister("VecMax",           VEC_CLASSID,&VEC_Max);
    125:   PetscLogEventRegister("VecMin",           VEC_CLASSID,&VEC_Min);
    126:   PetscLogEventRegister("VecDotBarrier",    VEC_CLASSID,&VEC_DotBarrier);
    127:   PetscLogEventRegister("VecDot",           VEC_CLASSID,&VEC_Dot);
    128:   PetscLogEventRegister("VecDotNormBarr",   VEC_CLASSID,&VEC_DotNormBarrier);
    129:   PetscLogEventRegister("VecDotNorm2",      VEC_CLASSID,&VEC_DotNorm);
    130:   PetscLogEventRegister("VecMDotBarrier",   VEC_CLASSID,&VEC_MDotBarrier);
    131:   PetscLogEventRegister("VecMDot",          VEC_CLASSID,&VEC_MDot);
    132:   PetscLogEventRegister("VecTDot",          VEC_CLASSID,&VEC_TDot);
    133:   PetscLogEventRegister("VecMTDot",         VEC_CLASSID,&VEC_MTDot);
    134:   PetscLogEventRegister("VecNormBarrier",   VEC_CLASSID,&VEC_NormBarrier);
    135:   PetscLogEventRegister("VecNorm",          VEC_CLASSID,&VEC_Norm);
    136:   PetscLogEventRegister("VecScale",         VEC_CLASSID,&VEC_Scale);
    137:   PetscLogEventRegister("VecCopy",          VEC_CLASSID,&VEC_Copy);
    138:   PetscLogEventRegister("VecSet",           VEC_CLASSID,&VEC_Set);
    139:   PetscLogEventRegister("VecAXPY",          VEC_CLASSID,&VEC_AXPY);
    140:   PetscLogEventRegister("VecAYPX",          VEC_CLASSID,&VEC_AYPX);
    141:   PetscLogEventRegister("VecAXPBYCZ",       VEC_CLASSID,&VEC_AXPBYPCZ);
    142:   PetscLogEventRegister("VecWAXPY",         VEC_CLASSID,&VEC_WAXPY);
    143:   PetscLogEventRegister("VecMAXPY",         VEC_CLASSID,&VEC_MAXPY);
    144:   PetscLogEventRegister("VecSwap",          VEC_CLASSID,&VEC_Swap);
    145:   PetscLogEventRegister("VecOps",           VEC_CLASSID,&VEC_Ops);
    146:   PetscLogEventRegister("VecAssemblyBegin", VEC_CLASSID,&VEC_AssemblyBegin);
    147:   PetscLogEventRegister("VecAssemblyEnd",   VEC_CLASSID,&VEC_AssemblyEnd);
    148:   PetscLogEventRegister("VecPointwiseMult", VEC_CLASSID,&VEC_PointwiseMult);
    149:   PetscLogEventRegister("VecSetValues",     VEC_CLASSID,&VEC_SetValues);
    150:   PetscLogEventRegister("VecLoad",          VEC_CLASSID,&VEC_Load);
    151:   PetscLogEventRegister("VecScatterBarrie", VEC_CLASSID,&VEC_ScatterBarrier);
    152:   PetscLogEventRegister("VecScatterBegin",  VEC_CLASSID,&VEC_ScatterBegin);
    153:   PetscLogEventRegister("VecScatterEnd",    VEC_CLASSID,&VEC_ScatterEnd);
    154:   PetscLogEventRegister("VecSetRandom",     VEC_CLASSID,&VEC_SetRandom);
    155:   PetscLogEventRegister("VecReduceArith",   VEC_CLASSID,&VEC_ReduceArithmetic);
    156:   PetscLogEventRegister("VecReduceBarrier", VEC_CLASSID,&VEC_ReduceBarrier);
    157:   PetscLogEventRegister("VecReduceComm",    VEC_CLASSID,&VEC_ReduceCommunication); /* must follow barrier */
    158:   PetscLogEventRegister("VecReduceBegin",   VEC_CLASSID,&VEC_ReduceBegin);
    159:   PetscLogEventRegister("VecReduceEnd",     VEC_CLASSID,&VEC_ReduceEnd);
    160:   PetscLogEventRegister("VecNormalize",     VEC_CLASSID,&VEC_Normalize);
    161: #if defined(PETSC_HAVE_CUSP)
    162:   PetscLogEventRegister("VecCUSPCopyTo",     VEC_CLASSID,&VEC_CUSPCopyToGPU);
    163:   PetscLogEventRegister("VecCUSPCopyFrom",   VEC_CLASSID,&VEC_CUSPCopyFromGPU);
    164:   PetscLogEventRegister("VecCopyToSome",     VEC_CLASSID,&VEC_CUSPCopyToGPUSome);
    165:   PetscLogEventRegister("VecCopyFromSome",   VEC_CLASSID,&VEC_CUSPCopyFromGPUSome);
    166: #endif
    167:   /* Turn off high traffic events by default */
    168:   PetscLogEventSetActiveAll(VEC_DotBarrier, PETSC_FALSE);
    169:   PetscLogEventSetActiveAll(VEC_DotNormBarrier, PETSC_FALSE);
    170:   PetscLogEventSetActiveAll(VEC_MDotBarrier, PETSC_FALSE);
    171:   PetscLogEventSetActiveAll(VEC_NormBarrier, PETSC_FALSE);
    172:   PetscLogEventSetActiveAll(VEC_SetValues, PETSC_FALSE);
    173:   PetscLogEventSetActiveAll(VEC_ScatterBarrier, PETSC_FALSE);
    174:   PetscLogEventSetActiveAll(VEC_ReduceBarrier, PETSC_FALSE);
    175:   /* Process info exclusions */
    176:   PetscOptionsGetString(NULL, "-info_exclude", logList, 256, &opt);
    177:   if (opt) {
    178:     PetscStrstr(logList, "vec", &className);
    179:     if (className) {
    180:       PetscInfoDeactivateClass(VEC_CLASSID);
    181:     }
    182:   }
    183:   /* Process summary exclusions */
    184:   PetscOptionsGetString(NULL, "-log_summary_exclude", logList, 256, &opt);
    185:   if (opt) {
    186:     PetscStrstr(logList, "vec", &className);
    187:     if (className) {
    188:       PetscLogEventDeactivateClass(VEC_CLASSID);
    189:     }
    190:   }
    191:   /* Special processing */
    192:   opt  = PETSC_FALSE;
    193:   PetscOptionsGetBool(NULL, "-log_sync", &opt,NULL);
    194:   if (opt) {
    195:     PetscLogEventSetActiveAll(VEC_ScatterBarrier, PETSC_TRUE);
    196:     PetscLogEventSetActiveAll(VEC_NormBarrier, PETSC_TRUE);
    197:     PetscLogEventSetActiveAll(VEC_DotBarrier, PETSC_TRUE);
    198:     PetscLogEventSetActiveAll(VEC_DotNormBarrier, PETSC_TRUE);
    199:     PetscLogEventSetActiveAll(VEC_MDotBarrier, PETSC_TRUE);
    200:     PetscLogEventSetActiveAll(VEC_ReduceBarrier, PETSC_TRUE);
    201:   }

    203:   /*
    204:     Create the special MPI reduction operation that may be used by VecNorm/DotBegin()
    205:   */
    206:   MPI_Op_create(PetscSplitReduction_Local,1,&PetscSplitReduction_Op);
    207:   MPI_Op_create(VecMax_Local,2,&VecMax_Local_Op);
    208:   MPI_Op_create(VecMin_Local,2,&VecMin_Local_Op);

    210:   /* Register the different norm types for cached norms */
    211:   for (i=0; i<4; i++) {
    212:     PetscObjectComposedDataRegister(NormIds+i);
    213:   }

    215:   /* Register finalization routine */
    216:   PetscRegisterFinalize(VecFinalizePackage);
    217:   return(0);
    218: }

    222: /*@C
    223:   VecFinalizePackage - This function finalizes everything in the Vec package. It is called
    224:   from PetscFinalize().

    226:   Level: developer

    228: .keywords: Vec, initialize, package
    229: .seealso: PetscInitialize()
    230: @*/
    231: PetscErrorCode  VecFinalizePackage(void)
    232: {

    236:   PetscFunctionListDestroy(&VecList);
    237:   MPI_Op_free(&PetscSplitReduction_Op);
    238:   MPI_Op_free(&VecMax_Local_Op);
    239:   MPI_Op_free(&VecMin_Local_Op);
    240:   VecPackageInitialized = PETSC_FALSE;
    241:   VecRegisterAllCalled  = PETSC_FALSE;
    242:   return(0);
    243: }

    245: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
    248: /*
    249:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

    251:   This one registers all the methods that are in the basic PETSc Vec library.

    253:  */
    254: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscvec(void)
    255: {

    259:   PetscSFInitializePackage();
    260:   ISInitializePackage();
    261:   AOInitializePackage();
    262:   VecInitializePackage();
    263:   PFInitializePackage();
    264:   return(0);
    265: }

    267: #endif /* PETSC_USE_DYNAMIC_LIBRARIES */