Date: 2016-07-24T16:49:29+00:00

Actual source code: dlregisvec.c
petsc-3.7.3 2016-07-24
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,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,NULL, "-log_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: #elif defined(PETSC_HAVE_VIENNACL)
    168:   PetscLogEventRegister("VecViennaCLCopyTo",     VEC_CLASSID,&VEC_ViennaCLCopyToGPU);
    169:   PetscLogEventRegister("VecViennaCLCopyFrom",   VEC_CLASSID,&VEC_ViennaCLCopyFromGPU);
    170: #elif defined(PETSC_HAVE_VECCUDA)
    171:   PetscLogEventRegister("VecCUDACopyTo",     VEC_CLASSID,&VEC_CUDACopyToGPU);
    172:   PetscLogEventRegister("VecCUDACopyFrom",   VEC_CLASSID,&VEC_CUDACopyFromGPU);
    173:   PetscLogEventRegister("VecCopyToSome",     VEC_CLASSID,&VEC_CUDACopyToGPUSome);
    174:   PetscLogEventRegister("VecCopyFromSome",   VEC_CLASSID,&VEC_CUDACopyFromGPUSome);
    175: #endif
    176:   /* Turn off high traffic events by default */
    177:   PetscLogEventSetActiveAll(VEC_DotBarrier, PETSC_FALSE);
    178:   PetscLogEventSetActiveAll(VEC_DotNormBarrier, PETSC_FALSE);
    179:   PetscLogEventSetActiveAll(VEC_MDotBarrier, PETSC_FALSE);
    180:   PetscLogEventSetActiveAll(VEC_NormBarrier, PETSC_FALSE);
    181:   PetscLogEventSetActiveAll(VEC_SetValues, PETSC_FALSE);
    182:   PetscLogEventSetActiveAll(VEC_ScatterBarrier, PETSC_FALSE);
    183:   PetscLogEventSetActiveAll(VEC_ReduceBarrier, PETSC_FALSE);
    184:   /* Process info exclusions */
    185:   PetscOptionsGetString(NULL,NULL, "-info_exclude", logList, 256, &opt);
    186:   if (opt) {
    187:     PetscStrstr(logList, "vec", &className);
    188:     if (className) {
    189:       PetscInfoDeactivateClass(VEC_CLASSID);
    190:     }
    191:   }
    192:   /* Process summary exclusions */
    193:   PetscOptionsGetString(NULL,NULL, "-log_exclude", logList, 256, &opt);
    194:   if (opt) {
    195:     PetscStrstr(logList, "vec", &className);
    196:     if (className) {
    197:       PetscLogEventDeactivateClass(VEC_CLASSID);
    198:     }
    199:   }
    200:   /* Special processing */
    201:   opt  = PETSC_FALSE;
    202:   PetscOptionsGetBool(NULL,NULL, "-log_sync", &opt,NULL);
    203:   if (opt) {
    204:     PetscLogEventSetActiveAll(VEC_ScatterBarrier, PETSC_TRUE);
    205:     PetscLogEventSetActiveAll(VEC_NormBarrier, PETSC_TRUE);
    206:     PetscLogEventSetActiveAll(VEC_DotBarrier, PETSC_TRUE);
    207:     PetscLogEventSetActiveAll(VEC_DotNormBarrier, PETSC_TRUE);
    208:     PetscLogEventSetActiveAll(VEC_MDotBarrier, PETSC_TRUE);
    209:     PetscLogEventSetActiveAll(VEC_ReduceBarrier, PETSC_TRUE);
    210:   }

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

    219:   /* Register the different norm types for cached norms */
    220:   for (i=0; i<4; i++) {
    221:     PetscObjectComposedDataRegister(NormIds+i);
    222:   }

    224:   /* Register finalization routine */
    225:   PetscRegisterFinalize(VecFinalizePackage);
    226:   return(0);
    227: }

    231: /*@C
    232:   VecFinalizePackage - This function finalizes everything in the Vec package. It is called
    233:   from PetscFinalize().

    235:   Level: developer

    237: .keywords: Vec, initialize, package
    238: .seealso: PetscInitialize()
    239: @*/
    240: PetscErrorCode  VecFinalizePackage(void)
    241: {

    245:   PetscFunctionListDestroy(&VecList);
    246:   MPI_Op_free(&PetscSplitReduction_Op);
    247:   MPI_Op_free(&VecMax_Local_Op);
    248:   MPI_Op_free(&VecMin_Local_Op);
    249:   VecPackageInitialized = PETSC_FALSE;
    250:   VecRegisterAllCalled  = PETSC_FALSE;
    251:   return(0);
    252: }

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

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

    262:  */
    263: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscvec(void)
    264: {

    268:   PetscSFInitializePackage();
    269:   ISInitializePackage();
    270:   AOInitializePackage();
    271:   VecInitializePackage();
    272:   PFInitializePackage();
    273:   return(0);
    274: }

    276: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */