Actual source code: dlregisvec.c
1: #define PETSCVEC_DLL
3: #include petscvec.h
4: #include petscpf.h
8: /*@C
9: ISInitializePackage - This function initializes everything in the IS package. It is called
10: from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to ISCreateXXXX()
11: when using static libraries.
13: Input Parameter:
14: . path - The dynamic library path, or PETSC_NULL
16: Level: developer
18: .keywords: Vec, initialize, package
19: .seealso: PetscInitialize()
20: @*/
21: PetscErrorCode ISInitializePackage(const char path[])
22: {
23: static PetscTruth initialized = PETSC_FALSE;
24: char logList[256];
25: char *className;
26: PetscTruth opt;
27: PetscErrorCode ierr;
30: if (initialized) return(0);
31: initialized = PETSC_TRUE;
32: /* Register Classes */
33: PetscCookieRegister("Index Set",&IS_COOKIE);
34: PetscCookieRegister("IS L to G Mapping",&IS_LTOGM_COOKIE);
36: /* Process info exclusions */
37: PetscOptionsGetString(PETSC_NULL, "-info_exclude", logList, 256, &opt);
38: if (opt) {
39: PetscStrstr(logList, "is", &className);
40: if (className) {
41: PetscInfoDeactivateClass(IS_COOKIE);
42: PetscInfoDeactivateClass(IS_LTOGM_COOKIE);
43: }
44: }
45: /* Process summary exclusions */
46: PetscOptionsGetString(PETSC_NULL, "-log_summary_exclude", logList, 256, &opt);
47: if (opt) {
48: PetscStrstr(logList, "is", &className);
49: if (className) {
50: PetscLogEventDeactivateClass(IS_COOKIE);
51: PetscLogEventDeactivateClass(IS_LTOGM_COOKIE);
52: }
53: }
54: return(0);
55: }
67: const char *NormTypes[] = {"1","2","FROBENIUS","INFINITY","1_AND_2","NormType","NORM_",0};
68: PetscInt NormIds[7]; /* map from NormType to IDs used to cache Normvalues */
72: /*@C
73: VecInitializePackage - This function initializes everything in the Vec package. It is called
74: from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to VecCreate()
75: when using static libraries.
77: Input Parameter:
78: . path - The dynamic library path, or PETSC_NULL
80: Level: developer
82: .keywords: Vec, initialize, package
83: .seealso: PetscInitialize()
84: @*/
85: PetscErrorCode VecInitializePackage(const char path[])
86: {
87: static PetscTruth initialized = PETSC_FALSE;
88: char logList[256];
89: char *className;
90: PetscTruth opt;
91: PetscErrorCode ierr;
92: PetscInt i;
95: if (initialized) return(0);
96: initialized = PETSC_TRUE;
97: /* Register Classes */
98: PetscCookieRegister("Vec",&VEC_COOKIE);
99: PetscCookieRegister("Vec Scatter",&VEC_SCATTER_COOKIE);
100: /* Register Constructors */
101: VecRegisterAll(path);
102: /* Register Events */
103: PetscLogEventRegister("VecView", VEC_COOKIE,&VEC_View);
104: PetscLogEventRegister("VecMax", VEC_COOKIE,&VEC_Max);
105: PetscLogEventRegister("VecMin", VEC_COOKIE,&VEC_Min);
106: PetscLogEventRegister("VecDotBarrier", VEC_COOKIE,&VEC_DotBarrier);
107: PetscLogEventRegister("VecDot", VEC_COOKIE,&VEC_Dot);
108: PetscLogEventRegister("VecDotNormBarr", VEC_COOKIE,&VEC_DotNormBarrier);
109: PetscLogEventRegister("VecDotNorm2", VEC_COOKIE,&VEC_DotNorm);
110: PetscLogEventRegister("VecMDotBarrier", VEC_COOKIE,&VEC_MDotBarrier);
111: PetscLogEventRegister("VecMDot", VEC_COOKIE,&VEC_MDot);
112: PetscLogEventRegister("VecTDot", VEC_COOKIE,&VEC_TDot);
113: PetscLogEventRegister("VecMTDot", VEC_COOKIE,&VEC_MTDot);
114: PetscLogEventRegister("VecNormBarrier", VEC_COOKIE,&VEC_NormBarrier);
115: PetscLogEventRegister("VecNorm", VEC_COOKIE,&VEC_Norm);
116: PetscLogEventRegister("VecScale", VEC_COOKIE,&VEC_Scale);
117: PetscLogEventRegister("VecCopy", VEC_COOKIE,&VEC_Copy);
118: PetscLogEventRegister("VecSet", VEC_COOKIE,&VEC_Set);
119: PetscLogEventRegister("VecAXPY", VEC_COOKIE,&VEC_AXPY);
120: PetscLogEventRegister("VecAYPX", VEC_COOKIE,&VEC_AYPX);
121: PetscLogEventRegister("VecAXPBYCZ", VEC_COOKIE,&VEC_AXPBYPCZ);
122: PetscLogEventRegister("VecWAXPY", VEC_COOKIE,&VEC_WAXPY);
123: PetscLogEventRegister("VecMAXPY", VEC_COOKIE,&VEC_MAXPY);
124: PetscLogEventRegister("VecSwap", VEC_COOKIE,&VEC_Swap);
125: PetscLogEventRegister("VecOps", VEC_COOKIE,&VEC_Ops);
126: PetscLogEventRegister("VecAssemblyBegin", VEC_COOKIE,&VEC_AssemblyBegin);
127: PetscLogEventRegister("VecAssemblyEnd", VEC_COOKIE,&VEC_AssemblyEnd);
128: PetscLogEventRegister("VecPointwiseMult", VEC_COOKIE,&VEC_PointwiseMult);
129: PetscLogEventRegister("VecSetValues", VEC_COOKIE,&VEC_SetValues);
130: PetscLogEventRegister("VecLoad", VEC_COOKIE,&VEC_Load);
131: PetscLogEventRegister("VecScatterBarrie", VEC_COOKIE,&VEC_ScatterBarrier);
132: PetscLogEventRegister("VecScatterBegin", VEC_COOKIE,&VEC_ScatterBegin);
133: PetscLogEventRegister("VecScatterEnd", VEC_COOKIE,&VEC_ScatterEnd);
134: PetscLogEventRegister("VecSetRandom", VEC_COOKIE,&VEC_SetRandom);
135: PetscLogEventRegister("VecReduceArith", VEC_COOKIE,&VEC_ReduceArithmetic);
136: PetscLogEventRegister("VecReduceBarrier", VEC_COOKIE,&VEC_ReduceBarrier);
137: PetscLogEventRegister("VecReduceComm", VEC_COOKIE,&VEC_ReduceCommunication);
138: PetscLogEventRegister("VecNormalize", VEC_COOKIE,&VEC_Normalize);
139: /* Turn off high traffic events by default */
140: PetscLogEventSetActiveAll(VEC_DotBarrier, PETSC_FALSE);
141: PetscLogEventSetActiveAll(VEC_DotNormBarrier, PETSC_FALSE);
142: PetscLogEventSetActiveAll(VEC_MDotBarrier, PETSC_FALSE);
143: PetscLogEventSetActiveAll(VEC_NormBarrier, PETSC_FALSE);
144: PetscLogEventSetActiveAll(VEC_SetValues, PETSC_FALSE);
145: PetscLogEventSetActiveAll(VEC_ScatterBarrier, PETSC_FALSE);
146: PetscLogEventSetActiveAll(VEC_ReduceBarrier, PETSC_FALSE);
147: /* Process info exclusions */
148: PetscOptionsGetString(PETSC_NULL, "-info_exclude", logList, 256, &opt);
149: if (opt) {
150: PetscStrstr(logList, "vec", &className);
151: if (className) {
152: PetscInfoDeactivateClass(VEC_COOKIE);
153: }
154: }
155: /* Process summary exclusions */
156: PetscOptionsGetString(PETSC_NULL, "-log_summary_exclude", logList, 256, &opt);
157: if (opt) {
158: PetscStrstr(logList, "vec", &className);
159: if (className) {
160: PetscLogEventDeactivateClass(VEC_COOKIE);
161: }
162: }
163: /* Special processing */
164: PetscOptionsHasName(PETSC_NULL, "-log_sync", &opt);
165: if (opt) {
166: PetscLogEventSetActiveAll(VEC_ScatterBarrier, PETSC_TRUE);
167: PetscLogEventSetActiveAll(VEC_NormBarrier, PETSC_TRUE);
168: PetscLogEventSetActiveAll(VEC_DotBarrier, PETSC_TRUE);
169: PetscLogEventSetActiveAll(VEC_DotNormBarrier, PETSC_TRUE);
170: PetscLogEventSetActiveAll(VEC_MDotBarrier, PETSC_TRUE);
171: PetscLogEventSetActiveAll(VEC_ReduceBarrier, PETSC_TRUE);
172: }
174: /*
175: Create the special MPI reduction operation that may be used by VecNorm/DotBegin()
176: */
177: MPI_Op_create(PetscSplitReduction_Local,1,&PetscSplitReduction_Op);
178: MPI_Op_create(VecMax_Local,2,&VecMax_Local_Op);
179: MPI_Op_create(VecMin_Local,2,&VecMin_Local_Op);
181: /* Register the different norm types for cached norms */
182: for (i=0; i<4; i++) {
183: PetscObjectComposedDataRegister(NormIds+i);
184: }
185:
186: /* Register finalization routine */
187: PetscRegisterFinalize(VecFinalizePackage);
188: return(0);
189: }
193: /*@C
194: VecFinalizePackage - This function finalizes everything in the Vec package. It is called
195: from PetscFinalize().
197: Level: developer
199: .keywords: Vec, initialize, package
200: .seealso: PetscInitialize()
201: @*/
202: PetscErrorCode VecFinalizePackage(void) {
205: MPI_Op_free(&PetscSplitReduction_Op);
206: MPI_Op_free(&VecMax_Local_Op);
207: MPI_Op_free(&VecMin_Local_Op);
208: return(0);
209: }
211: #ifdef PETSC_USE_DYNAMIC_LIBRARIES
215: /*
216: PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.
218: This one registers all the methods that are in the basic PETSc Vec library.
220: Input Parameter:
221: path - library path
222: */
223: PetscErrorCode PetscDLLibraryRegister_petscvec(const char path[])
224: {
227: PetscInitializeNoArguments(); if (ierr) return 1;
230: /*
231: If we got here then PETSc was properly loaded
232: */
233: ISInitializePackage(path);
234: VecInitializePackage(path);
235: PFInitializePackage(path);
236: return(0);
237: }
240: #endif /* PETSC_USE_DYNAMIC_LIBRARIES */