Date: 2015-10-02T22:02:20+00:00

Actual source code: dlregisvec.c
petsc-3.6.2 2015-10-02
Report Typos and Errors

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

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

     15:   Level: developer

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

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

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

     38:   Level: developer

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

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

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

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

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

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

     93: static PetscBool  VecPackageInitialized = PETSC_FALSE;

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

    102:   Level: developer

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

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

    208:   /*
    209:     Create the special MPI reduction operation that may be used by VecNorm/DotBegin()
    210:   */
    211:   MPI_Op_create(PetscSplitReduction_Local,1,&PetscSplitReduction_Op);
    212:   MPI_Op_create(VecMax_Local,2,&VecMax_Local_Op);
    213:   MPI_Op_create(VecMin_Local,2,&VecMin_Local_Op);

    215:   /* Register the different norm types for cached norms */
    216:   for (i=0; i<4; i++) {
    217:     PetscObjectComposedDataRegister(NormIds+i);
    218:   }

    220:   /* Register finalization routine */
    221:   PetscRegisterFinalize(VecFinalizePackage);
    222:   return(0);
    223: }

    227: /*@C
    228:   VecFinalizePackage - This function finalizes everything in the Vec package. It is called
    229:   from PetscFinalize().

    231:   Level: developer

    233: .keywords: Vec, initialize, package
    234: .seealso: PetscInitialize()
    235: @*/
    236: PetscErrorCode  VecFinalizePackage(void)
    237: {

    241:   PetscFunctionListDestroy(&VecList);
    242:   MPI_Op_free(&PetscSplitReduction_Op);
    243:   MPI_Op_free(&VecMax_Local_Op);
    244:   MPI_Op_free(&VecMin_Local_Op);
    245:   VecPackageInitialized = PETSC_FALSE;
    246:   VecRegisterAllCalled  = PETSC_FALSE;
    247:   return(0);
    248: }

    250: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
    253: /*
    254:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

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

    258:  */
    259: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscvec(void)
    260: {

    264:   PetscSFInitializePackage();
    265:   ISInitializePackage();
    266:   AOInitializePackage();
    267:   VecInitializePackage();
    268:   PFInitializePackage();
    269:   return(0);
    270: }

    272: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */