Actual source code: dlregisvec.c

  1: #define PETSCVEC_DLL

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

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

 13:   Level: developer

 15: .keywords: Petsc, destroy, package
 16: .seealso: PetscFinalize()
 17: @*/
 18: PetscErrorCode  ISFinalizePackage(void)
 19: {
 21:   ISPackageInitialized = PETSC_FALSE;
 22:   return(0);
 23: }

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

 32:   Input Parameter:
 33: . path - The dynamic library path, or PETSC_NULL

 35:   Level: developer

 37: .keywords: Vec, initialize, package
 38: .seealso: PetscInitialize()
 39: @*/
 40: PetscErrorCode  ISInitializePackage(const char path[])
 41: {
 42:   char              logList[256];
 43:   char              *className;
 44:   PetscTruth        opt;
 45:   PetscErrorCode    ierr;

 48:   if (ISPackageInitialized) return(0);
 49:   ISPackageInitialized = PETSC_TRUE;
 50:   /* Register Classes */
 51:   PetscCookieRegister("Index Set",&IS_COOKIE);
 52:   PetscCookieRegister("IS L to G Mapping",&IS_LTOGM_COOKIE);

 54:   /* Process info exclusions */
 55:   PetscOptionsGetString(PETSC_NULL, "-info_exclude", logList, 256, &opt);
 56:   if (opt) {
 57:     PetscStrstr(logList, "is", &className);
 58:     if (className) {
 59:       PetscInfoDeactivateClass(IS_COOKIE);
 60:       PetscInfoDeactivateClass(IS_LTOGM_COOKIE);
 61:     }
 62:   }
 63:   /* Process summary exclusions */
 64:   PetscOptionsGetString(PETSC_NULL, "-log_summary_exclude", logList, 256, &opt);
 65:   if (opt) {
 66:     PetscStrstr(logList, "is", &className);
 67:     if (className) {
 68:       PetscLogEventDeactivateClass(IS_COOKIE);
 69:       PetscLogEventDeactivateClass(IS_LTOGM_COOKIE);
 70:     }
 71:   }
 72:   PetscRegisterFinalize(ISFinalizePackage);
 73:   return(0);
 74: }



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

 89: static PetscTruth VecPackageInitialized = PETSC_FALSE;

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

 98:   Input Parameter:
 99: . path - The dynamic library path, or PETSC_NULL

101:   Level: developer

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

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

195:   /*
196:     Create the special MPI reduction operation that may be used by VecNorm/DotBegin()
197:   */
198:   MPI_Op_create(PetscSplitReduction_Local,1,&PetscSplitReduction_Op);
199:   MPI_Op_create(VecMax_Local,2,&VecMax_Local_Op);
200:   MPI_Op_create(VecMin_Local,2,&VecMin_Local_Op);

202:   /* Register the different norm types for cached norms */
203:   for (i=0; i<4; i++) {
204:     PetscObjectComposedDataRegister(NormIds+i);
205:   }
206: 
207:   /* Register finalization routine */
208:   PetscRegisterFinalize(VecFinalizePackage);
209:   return(0);
210: }

214: /*@C
215:   VecFinalizePackage - This function finalizes everything in the Vec package. It is called
216:   from PetscFinalize().

218:   Level: developer

220: .keywords: Vec, initialize, package
221: .seealso: PetscInitialize()
222: @*/
223: PetscErrorCode  VecFinalizePackage(void) {
226:   MPI_Op_free(&PetscSplitReduction_Op);
227:   MPI_Op_free(&VecMax_Local_Op);
228:   MPI_Op_free(&VecMin_Local_Op);
229:   VecPackageInitialized = PETSC_FALSE;
230:   VecList               = PETSC_NULL;
231:   VecRegisterAllCalled  = PETSC_FALSE;
232:   return(0);
233: }

235: #ifdef PETSC_USE_DYNAMIC_LIBRARIES
239: /*
240:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

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

244:   Input Parameter:
245:   path - library path
246:  */
247: PetscErrorCode  PetscDLLibraryRegister_petscvec(const char path[])
248: {

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

254:   /*
255:       If we got here then PETSc was properly loaded
256:   */
257:   ISInitializePackage(path);
258:   VecInitializePackage(path);
259:   PFInitializePackage(path);
260:   return(0);
261: }

264: #endif /* PETSC_USE_DYNAMIC_LIBRARIES */