Actual source code: dlregisvec.c

petsc-3.5.1 2014-07-24
Report Typos and Errors
  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: #if defined(PETSC_HAVE_VIENNACL)
168:   PetscLogEventRegister("VecViennaCLCopyTo",     VEC_CLASSID,&VEC_ViennaCLCopyToGPU);
169:   PetscLogEventRegister("VecViennaCLCopyFrom",   VEC_CLASSID,&VEC_ViennaCLCopyFromGPU);
170: #endif
171:   /* Turn off high traffic events by default */
172:   PetscLogEventSetActiveAll(VEC_DotBarrier, PETSC_FALSE);
173:   PetscLogEventSetActiveAll(VEC_DotNormBarrier, PETSC_FALSE);
174:   PetscLogEventSetActiveAll(VEC_MDotBarrier, PETSC_FALSE);
175:   PetscLogEventSetActiveAll(VEC_NormBarrier, PETSC_FALSE);
176:   PetscLogEventSetActiveAll(VEC_SetValues, PETSC_FALSE);
177:   PetscLogEventSetActiveAll(VEC_ScatterBarrier, PETSC_FALSE);
178:   PetscLogEventSetActiveAll(VEC_ReduceBarrier, PETSC_FALSE);
179:   /* Process info exclusions */
180:   PetscOptionsGetString(NULL, "-info_exclude", logList, 256, &opt);
181:   if (opt) {
182:     PetscStrstr(logList, "vec", &className);
183:     if (className) {
184:       PetscInfoDeactivateClass(VEC_CLASSID);
185:     }
186:   }
187:   /* Process summary exclusions */
188:   PetscOptionsGetString(NULL, "-log_summary_exclude", logList, 256, &opt);
189:   if (opt) {
190:     PetscStrstr(logList, "vec", &className);
191:     if (className) {
192:       PetscLogEventDeactivateClass(VEC_CLASSID);
193:     }
194:   }
195:   /* Special processing */
196:   opt  = PETSC_FALSE;
197:   PetscOptionsGetBool(NULL, "-log_sync", &opt,NULL);
198:   if (opt) {
199:     PetscLogEventSetActiveAll(VEC_ScatterBarrier, PETSC_TRUE);
200:     PetscLogEventSetActiveAll(VEC_NormBarrier, PETSC_TRUE);
201:     PetscLogEventSetActiveAll(VEC_DotBarrier, PETSC_TRUE);
202:     PetscLogEventSetActiveAll(VEC_DotNormBarrier, PETSC_TRUE);
203:     PetscLogEventSetActiveAll(VEC_MDotBarrier, PETSC_TRUE);
204:     PetscLogEventSetActiveAll(VEC_ReduceBarrier, PETSC_TRUE);
205:   }

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

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

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

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

230:   Level: developer

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

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

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

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

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

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

271: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */