SALSA Analysis Modules
anamod.h
Go to the documentation of this file.
00001 /*! \file anamod.h \ingroup functions
00002   \brief Prototypes for general module functions
00003 
00004   This file defines the functions for defining and querying 
00005   analysis modules.
00006 */
00007 #ifndef MODULE_FUNCTIONS_H
00008 #define MODULE_FUNCTIONS_H
00009 
00010 #define ANAMOD_FORMAT_VERSION "1.0"
00011 #define MXC 30
00012 #define INC 7
00013 
00014 #include "petscmat.h"
00015 #include "anamodtypes.h"
00016 
00017 #define TRUTH(x) ( (x) ? PETSC_TRUE : PETSC_FALSE )
00018 #define HASTOEXIST(h) \
00019   if (!h) {                                      \
00020     printf("ERROR asking for unknown module\n"); \
00021     PetscFunctionReturn(1);                      \
00022   }
00023 #define ANAMODCHECKVALID(i,c,s) {if (!(i)) SETERRQ(1,"Null pointer"); if ((i)->cookie!=c) SETERRQ1(1,"Not a valid <%s>",s);}
00024 
00025 typedef struct categoryobject_* categoryobject;
00026 typedef struct componentobject_* componentobject;
00027 
00028 /*
00029  * Init/Final
00030  */
00031 extern PetscErrorCode AnaModInitialize();
00032 extern PetscErrorCode AnaModFinalize();
00033 extern PetscErrorCode AnaModGetTypeName(int id,const char **name);
00034 extern PetscErrorCode AnaModGetTypeMySQLName(int id,const char **name);
00035 
00036 /*
00037  * Categories and modules
00038  */
00039 extern PetscErrorCode AllocCategoryObjects();
00040 extern PetscErrorCode FreeCategoryObjects();
00041 extern PetscErrorCode CreateCategoryObject(const char*,categoryobject*);
00042 extern PetscErrorCode DestroyCategoryObject(categoryobject);
00043 extern PetscErrorCode GetCategory(const char*,categoryobject*,PetscTruth*);
00044 extern PetscErrorCode GetOrCreateCategory(const char*,categoryobject*);
00045 extern PetscErrorCode CategoryGetComponentIndex
00046 (categoryobject,const char*,int*,PetscTruth*);
00047 extern PetscErrorCode CategoryComponentSetModule
00048 (const char*,const char*,AnalysisDataType,int,
00049  PetscErrorCode(*)(AnaModNumericalProblem,AnalysisItem*,int*,PetscTruth*));
00050 
00051 extern PetscErrorCode AnaModRegisterStandardModules();
00052 extern PetscErrorCode RegisterModule
00053 (const char*,const char*,AnalysisDataType,
00054  PetscErrorCode(*f)(AnaModNumericalProblem,AnalysisItem*,int*,PetscTruth*));
00055 extern PetscErrorCode DeRegisterCategory(const char *cat);
00056 extern PetscErrorCode DeregisterModules(void);
00057 extern PetscErrorCode GetCategories(int*,const char***);
00058 extern PetscErrorCode CategoryGetModules
00059 (const char*,const char***,AnalysisDataType**,int**,int*);
00060 extern PetscErrorCode HasComputeCategory(const char*,PetscTruth*);
00061 extern PetscErrorCode HasComputeModule(const char*,const char*,PetscTruth*);
00062 typedef enum { 
00063   CATCMP_ENABLE, CATCMP_SKIP_FROM_LOOPS,CATCMP_DISABLE} CatCmpEnableMode;
00064 extern PetscErrorCode CategoryEnableByName(const char*,int);
00065 extern PetscErrorCode GetFirstCategory(const char**,PetscTruth*);
00066 extern PetscErrorCode GetNextCategory(const char**,PetscTruth*);
00067 
00068 /*
00069  * Components
00070  */
00071 extern PetscErrorCode CreateComponentObject(const char*,componentobject*);
00072 extern PetscErrorCode DestroyComponentObject(componentobject);
00073 extern PetscErrorCode CategoryGetOrCreateComponent
00074 (categoryobject,const char*,componentobject*);
00075 extern PetscErrorCode CategoryGetComponent
00076 (categoryobject,const char*,componentobject*,PetscTruth*);
00077 extern PetscErrorCode ComponentSetModule
00078 (componentobject,AnalysisDataType,int,
00079  PetscErrorCode(*)(AnaModNumericalProblem,AnalysisItem*,int*,PetscTruth*));
00080 extern PetscErrorCode ComponentGetType(componentobject,AnalysisDataType*);
00081 extern PetscErrorCode ComponentCompute
00082 (componentobject,AnaModNumericalProblem,AnalysisItem*,int*,PetscTruth*);
00083 extern PetscErrorCode ComponentRetrieve
00084 (componentobject,AnaModNumericalProblem,AnalysisItem*,int*,PetscTruth*);
00085 extern PetscErrorCode ComponentGetType(componentobject,AnalysisDataType*);
00086 extern PetscErrorCode ComponentGetName(componentobject,const char**);
00087 extern PetscErrorCode ComponentGetId(componentobject,int*);
00088 
00089 /*
00090  * Quantities
00091  */
00092 extern PetscErrorCode GetDataID(const char*,const char*,int*,PetscTruth*);
00093 extern PetscErrorCode GetDataType(const char*,const char*,AnalysisDataType*,PetscTruth*);
00094 extern PetscErrorCode ComputeQuantity
00095 (AnaModNumericalProblem,const char*,const char*,AnalysisItem*,int*,PetscTruth*);
00096 extern PetscErrorCode ComputeQuantityByID
00097 (AnaModNumericalProblem,int,int,AnalysisItem*,int*,PetscTruth*);
00098 extern PetscErrorCode HasQuantity
00099 (AnaModNumericalProblem,const char*,const char*,PetscTruth*);
00100 extern PetscErrorCode HasQuantityByID
00101 (AnaModNumericalProblem,int,AnalysisDataType,PetscTruth*);
00102 extern PetscErrorCode RetrieveQuantity
00103 (AnaModNumericalProblem,const char*,const char*,AnalysisItem*,int*,PetscTruth*);
00104 extern PetscErrorCode RetrieveQuantityByID
00105 (AnaModNumericalProblem,int,AnalysisDataType,AnalysisItem*,PetscTruth*);
00106 extern PetscErrorCode QuantityAsString(AnalysisItem*,AnalysisDataType,const char**);
00107 
00108 /*
00109  * Execution control
00110  */
00111 extern PetscErrorCode AnaModOptionsHandling(void);
00112 extern PetscErrorCode AnaModShowOptions(MPI_Comm);
00113 extern PetscErrorCode DeclareCategoryOptionFunction
00114 (const char *cat,PetscErrorCode(*f)(char*));
00115 extern PetscErrorCode CategoryGetOptionFunction
00116 (const char *cat,PetscErrorCode(**f)(char*));
00117 extern PetscErrorCode AnaModHasForcedSequentialComputation(PetscTruth*);
00118 extern PetscErrorCode AnaModHasForcedExpensiveComputation(PetscTruth*);
00119 extern PetscErrorCode AnaModGetSequentialMatrix
00120 (Mat A,Mat *Awork,PetscTruth *mem,PetscTruth *local,PetscTruth *global);
00121 
00122 /*
00123  * Tracing and output
00124  */
00125 extern PetscErrorCode AnaModDeclareTraceFunction
00126 (PetscErrorCode(*)(void*,const char*,va_list));
00127 extern PetscErrorCode AnaModDeclareTraceContext(void*);
00128 extern PetscErrorCode AnaModTraceMessage(const char *fmt,...);
00129 extern PetscErrorCode AnaModHasTrace(PetscTruth *flg);
00130 extern PetscErrorCode AnaModSetTraceArrays(PetscTruth f);
00131 extern PetscErrorCode AnaModTraceArrays(PetscTruth *f);
00132 #if defined(HAVE_NMD)
00133 extern PetscErrorCode TabReportModules(char**,int);
00134 extern PetscErrorCode TabReportValues(NMD_metadata,char**,char**,int);
00135 #else
00136 extern PetscErrorCode TabReportModules(Mat,char**,char**,int);
00137 #endif
00138 extern PetscErrorCode PurgeAttachedArrays(Mat A);
00139 
00140 /*
00141  * Feature sets
00142  */
00143 typedef struct FeatureSet_* FeatureSet;
00144 typedef struct FeatureValues_* FeatureValues;
00145 extern PetscErrorCode NewFeatureSet(FeatureSet*);
00146 extern PetscErrorCode DeleteFeatureSet(FeatureSet);
00147 extern PetscErrorCode AddToFeatureSet(FeatureSet,const char*,const char*,int*);
00148 extern PetscErrorCode NewFeatureValues(FeatureValues*);
00149 extern PetscErrorCode DeleteFeatureValues(FeatureValues);
00150 extern PetscErrorCode InstantiateFeatureSet
00151 (AnaModNumericalProblem,FeatureSet,FeatureValues);
00152 extern PetscErrorCode GetFeatureValue
00153 (FeatureValues,int,AnalysisItem*,PetscTruth*);
00154 extern PetscErrorCode AnaModSetRetrievalFunction
00155 (PetscErrorCode(*)(void*,char*,char*,AnalysisItem*,AnalysisDataType*,PetscTruth*));
00156 extern PetscErrorCode AnaModGetRetrievalFunction
00157 (PetscErrorCode(**)(void*,char*,char*,AnalysisItem*,AnalysisDataType*,PetscTruth*),PetscTruth*);
00158 extern PetscErrorCode AnaModCheckValidFeatureSet(void*);
00159 
00160 /*
00161  * Utils
00162  */
00163 extern PetscErrorCode CreateIntArray(const char*,int,IntArray*);
00164 extern PetscErrorCode DeleteIntArray(IntArray);
00165 extern PetscErrorCode IntArrayAdd(IntArray,int,int*);
00166 extern PetscErrorCode IntArraySetAt(IntArray,int,int);
00167 extern PetscErrorCode IntArrayTryGetAt(IntArray,int,int*,PetscTruth*);
00168 extern PetscErrorCode IntArrayGetAt(IntArray,int,int*);
00169 extern PetscErrorCode IntArrayGetFill(IntArray,int*);
00170 
00171 extern PetscErrorCode CreateStringArray(const char*,int,StringArray*);
00172 extern PetscErrorCode DeleteStringArray(StringArray);
00173 extern PetscErrorCode StringArrayAdd(StringArray,const char*,int*);
00174 extern PetscErrorCode StringArraySetAt(StringArray,int,const char*);
00175 extern PetscErrorCode StringArrayTryGetAt(StringArray,int,char**,PetscTruth*);
00176 extern PetscErrorCode StringArrayGetAt(StringArray,int,char**);
00177 extern PetscErrorCode StringArrayGetFill(StringArray,int*);
00178 
00179 extern PetscErrorCode CreateAnalysisItemArray(const char*,int,AnalysisItemArray*);
00180 extern PetscErrorCode DeleteAnalysisItemArray(AnalysisItemArray);
00181 extern PetscErrorCode AnalysisItemArrayAdd(AnalysisItemArray,AnalysisItem,int*);
00182 extern PetscErrorCode AnalysisItemArraySetAt(AnalysisItemArray,int,AnalysisItem);
00183 extern PetscErrorCode AnalysisItemArrayTryGetAt(AnalysisItemArray,int,AnalysisItem*,PetscTruth*);
00184 extern PetscErrorCode AnalysisItemArrayGetAt(AnalysisItemArray,int,AnalysisItem*);
00185 
00186 extern PetscErrorCode CreateAnalysisDataTypeArray(const char*,int,AnalysisDataTypeArray*);
00187 extern PetscErrorCode DeleteAnalysisDataTypeArray(AnalysisDataTypeArray);
00188 extern PetscErrorCode AnalysisDataTypeArrayAdd(AnalysisDataTypeArray,AnalysisDataType,int*);
00189 extern PetscErrorCode AnalysisDataTypeArraySetAt(AnalysisDataTypeArray,int,AnalysisDataType);
00190 extern PetscErrorCode AnalysisDataTypeArrayTryGetAt(AnalysisDataTypeArray,int,AnalysisDataType*,PetscTruth*);
00191 extern PetscErrorCode AnalysisDataTypeArrayGetAt(AnalysisDataTypeArray,int,AnalysisDataType*);
00192 
00193 /*
00194  * Logging
00195  */
00196 extern PetscErrorCode CategoryLogEventRegister(char *cat,int icat);
00197 
00198 #endif