Actual source code: dlregisvec.c

      1: #define PETSCVEC_DLL

     3:  #include petscvec.h
     4:  #include petscpf.h

     16: const char *NormTypes[] = {"1","2","FROBENIUS","INFINITY","1_AND_2","NormType","NORM_",0};

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

     25:   Input Parameter:
     26:   path - The dynamic library path, or PETSC_NULL

     28:   Level: developer

     30: .keywords: Vec, initialize, package
     31: .seealso: PetscInitialize()
     32: @*/
     33: PetscErrorCode PETSCVEC_DLLEXPORT VecInitializePackage(char *path)
     34: {
     35:   static PetscTruth initialized = PETSC_FALSE;
     36:   char              logList[256];
     37:   char              *className;
     38:   PetscTruth        opt;
     39:   PetscErrorCode    ierr;

     42:   if (initialized) return(0);
     43:   initialized = PETSC_TRUE;
     44:   /* Register Classes */
     45:   PetscLogClassRegister(&IS_COOKIE,          "Index Set");
     46:   PetscLogClassRegister(&MAP_COOKIE,         "Map");
     47:   PetscLogClassRegister(&VEC_COOKIE,         "Vec");
     48:   PetscLogClassRegister(&VEC_SCATTER_COOKIE, "Vec Scatter");
     49:   PetscLogClassRegister(&PF_COOKIE,          "PointFunction");
     50:   /* Register Constructors */
     51:   PetscMapRegisterAll(path);
     52:   VecRegisterAll(path);
     53:   PFRegisterAll(path);
     54:   /* Register Events */
     55:   PetscLogEventRegister(&VEC_View,                "VecView",          VEC_COOKIE);
     56:   PetscLogEventRegister(&VEC_Max,                 "VecMax",           VEC_COOKIE);
     57:   PetscLogEventRegister(&VEC_Min,                 "VecMin",           VEC_COOKIE);
     58:   PetscLogEventRegister(&VEC_DotBarrier,          "VecDotBarrier",    VEC_COOKIE);
     59:   PetscLogEventRegister(&VEC_Dot,                 "VecDot",           VEC_COOKIE);
     60:   PetscLogEventRegister(&VEC_MDotBarrier,         "VecMDotBarrier",   VEC_COOKIE);
     61:   PetscLogEventRegister(&VEC_MDot,                "VecMDot",          VEC_COOKIE);
     62:   PetscLogEventRegister(&VEC_TDot,                "VecTDot",          VEC_COOKIE);
     63:   PetscLogEventRegister(&VEC_MTDot,               "VecMTDot",         VEC_COOKIE);
     64:   PetscLogEventRegister(&VEC_NormBarrier,         "VecNormBarrier",   VEC_COOKIE);
     65:   PetscLogEventRegister(&VEC_Norm,                "VecNorm",          VEC_COOKIE);
     66:   PetscLogEventRegister(&VEC_Scale,               "VecScale",         VEC_COOKIE);
     67:   PetscLogEventRegister(&VEC_Copy,                "VecCopy",          VEC_COOKIE);
     68:   PetscLogEventRegister(&VEC_Set,                 "VecSet",           VEC_COOKIE);
     69:   PetscLogEventRegister(&VEC_AXPY,                "VecAXPY",          VEC_COOKIE);
     70:   PetscLogEventRegister(&VEC_AYPX,                "VecAYPX",          VEC_COOKIE);
     71:   PetscLogEventRegister(&VEC_WAXPY,               "VecWAXPY",         VEC_COOKIE);
     72:   PetscLogEventRegister(&VEC_MAXPY,               "VecMAXPY",         VEC_COOKIE);
     73:   PetscLogEventRegister(&VEC_Swap,                "VecSwap",          VEC_COOKIE);
     74:   PetscLogEventRegister(&VEC_AssemblyBegin,       "VecAssemblyBegin", VEC_COOKIE);
     75:   PetscLogEventRegister(&VEC_AssemblyEnd,         "VecAssemblyEnd",   VEC_COOKIE);
     76:   PetscLogEventRegister(&VEC_PointwiseMult,       "VecPointwiseMult", VEC_COOKIE);
     77:   PetscLogEventRegister(&VEC_SetValues,           "VecSetValues",     VEC_COOKIE);
     78:   PetscLogEventRegister(&VEC_Load,                "VecLoad",          VEC_COOKIE);
     79:   PetscLogEventRegister(&VEC_ScatterBarrier,      "VecScatterBarrie", VEC_COOKIE);
     80:   PetscLogEventRegister(&VEC_ScatterBegin,        "VecScatterBegin",  VEC_COOKIE);
     81:   PetscLogEventRegister(&VEC_ScatterEnd,          "VecScatterEnd",    VEC_COOKIE);
     82:   PetscLogEventRegister(&VEC_SetRandom,           "VecSetRandom",     VEC_COOKIE);
     83:   PetscLogEventRegister(&VEC_ReduceArithmetic,    "VecReduceArith",   VEC_COOKIE);
     84:   PetscLogEventRegister(&VEC_ReduceBarrier,       "VecReduceBarrier", VEC_COOKIE);
     85:   PetscLogEventRegister(&VEC_ReduceCommunication, "VecReduceComm",    VEC_COOKIE);
     86:   PetscLogEventRegister(&VEC_Normalize,           "VecNormalize",     VEC_COOKIE);
     87:   /* Turn off high traffic events by default */
     88:   PetscLogEventSetActiveAll(VEC_DotBarrier, PETSC_FALSE);
     89:   PetscLogEventSetActiveAll(VEC_MDotBarrier, PETSC_FALSE);
     90:   PetscLogEventSetActiveAll(VEC_NormBarrier, PETSC_FALSE);
     91:   PetscLogEventSetActiveAll(VEC_SetValues, PETSC_FALSE);
     92:   PetscLogEventSetActiveAll(VEC_ScatterBarrier, PETSC_FALSE);
     93:   PetscLogEventSetActiveAll(VEC_ReduceBarrier, PETSC_FALSE);
     94:   /* Process info exclusions */
     95:   PetscOptionsGetString(PETSC_NULL, "-log_info_exclude", logList, 256, &opt);
     96:   if (opt) {
     97:     PetscStrstr(logList, "is", &className);
     98:     if (className) {
     99:       PetscLogInfoDeactivateClass(IS_COOKIE);
    100:     }
    101:     PetscStrstr(logList, "map", &className);
    102:     if (className) {
    103:       PetscLogInfoDeactivateClass(MAP_COOKIE);
    104:     }
    105:     PetscStrstr(logList, "vec", &className);
    106:     if (className) {
    107:       PetscLogInfoDeactivateClass(VEC_COOKIE);
    108:     }
    109:   }
    110:   /* Process summary exclusions */
    111:   PetscOptionsGetString(PETSC_NULL, "-log_summary_exclude", logList, 256, &opt);
    112:   if (opt) {
    113:     PetscStrstr(logList, "is", &className);
    114:     if (className) {
    115:       PetscLogEventDeactivateClass(IS_COOKIE);
    116:     }
    117:     PetscStrstr(logList, "map", &className);
    118:     if (className) {
    119:       PetscLogEventDeactivateClass(MAP_COOKIE);
    120:     }
    121:     PetscStrstr(logList, "vec", &className);
    122:     if (className) {
    123:       PetscLogEventDeactivateClass(VEC_COOKIE);
    124:     }
    125:   }
    126:   /* Special processing */
    127:   PetscOptionsHasName(PETSC_NULL, "-log_sync", &opt);
    128:   if (opt) {
    129:     PetscLogEventActivate(VEC_ScatterBarrier);
    130:     PetscLogEventActivate(VEC_NormBarrier);
    131:     PetscLogEventActivate(VEC_DotBarrier);
    132:     PetscLogEventActivate(VEC_MDotBarrier);
    133:     PetscLogEventActivate(VEC_ReduceBarrier);
    134:   }

    136:   /*
    137:          Create the special MPI reduction operation that may be used by VecNorm/DotBegin()
    138:   */
    139:   MPI_Op_create(PetscSplitReduction_Local,1,&PetscSplitReduction_Op);
    140:   MPI_Op_create(VecMax_Local,2,&VecMax_Local_Op);
    141:   MPI_Op_create(VecMin_Local,2,&VecMin_Local_Op);
    142:   return(0);
    143: }

    145: #ifdef PETSC_USE_DYNAMIC_LIBRARIES
    149: /*
    150:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

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

    154:   Input Parameter:
    155:   path - library path
    156:  */
    157: PetscErrorCode PETSCVEC_DLLEXPORT PetscDLLibraryRegister_petscvec(char *path)
    158: {

    161:   PetscInitializeNoArguments(); if (ierr) return 1;

    164:   /*
    165:       If we got here then PETSc was properly loaded
    166:   */
    167:   VecInitializePackage(path);
    168:   return(0);
    169: }

    172: #endif /* PETSC_USE_DYNAMIC_LIBRARIES */