00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef SST_CORE_MODEL_PYTHON
00016 #define SST_CORE_MODEL_PYTHON
00017
00018
00019
00020 #ifdef SST_CONFIG_HAVE_PYTHON
00021
00022 #include <map>
00023 #include <string>
00024 #include <sstream>
00025 #include <vector>
00026
00027 #include <sst/core/model/sstmodel.h>
00028 #include <sst/core/config.h>
00029 #include <sst/core/output.h>
00030 #include <Python.h>
00031
00032
00033 using namespace SST;
00034
00035 namespace SST {
00036
00037 class SSTPythonModelDefinition : public SSTModelDescription {
00038
00039 public:
00040 SSTPythonModelDefinition(const std::string script_file, int verbosity, Config* config, int argc, char **argv);
00041 SSTPythonModelDefinition(const std::string script_file, int verbosity, Config* config);
00042 virtual ~SSTPythonModelDefinition();
00043
00044 ConfigGraph* createConfigGraph();
00045
00046 protected:
00047 void initModel(const std::string script_file, int verbosity, Config* config, int argc, char** argv);
00048 std::string scriptName;
00049 Output* output;
00050 Config* config;
00051 ConfigGraph *graph;
00052 std::map<std::string, std::string> cfgParams;
00053 char *namePrefix;
00054 size_t namePrefixLen;
00055 std::vector<size_t> nameStack;
00056
00057 public:
00058 std::vector<std::string> statParamKeyArray;
00059 std::vector<std::string> statParamValueArray;
00060
00061 public:
00062 Config* getConfig(void) const { return config; }
00063 std::map<std::string, std::string>& getParams(void) { return cfgParams; }
00064
00065 std::string getConfigString(void) const;
00066 Output* getOutput() const { return output; }
00067 ComponentId_t addComponent(const char *name, const char *type) const { return graph->addComponent(name, type); }
00068 void addParameter(ComponentId_t id, const char *name, const char *value) const { graph->addParameter(id, name, value, true); }
00069
00070 void setComponentRank(ComponentId_t id, int rank) const { graph->setComponentRank(id, rank); }
00071 void setComponentWeight(ComponentId_t id, float weight) const { graph->setComponentWeight(id, weight); }
00072 void addLink(ComponentId_t id, const char *name, const char *port, const char *latency, bool no_cut) const {graph->addLink(id, name, port, latency, no_cut); }
00073
00074 void pushNamePrefix(const char *name);
00075 void popNamePrefix(void);
00076 char* addNamePrefix(const char *name) const;
00077
00078 void setStatisticOutput(const char* Name) { graph->setStatisticOutput(Name); }
00079 void addStatisticOutputParameter(const char* param, const char* value) { graph->addStatisticOutputParameter(param, value); }
00080 void setStatisticLoadLevel(uint8_t loadLevel) { graph->setStatisticLoadLevel(loadLevel); }
00081
00082 void enableComponentStatistic(ComponentId_t compid, const char* statname) const { graph->enableComponentStatistic(compid, statname); }
00083 void enableStatisticForComponentName(const char* compname, const char* statname) const { graph->enableStatisticForComponentName(compname, statname); }
00084 void enableStatisticForComponentType(const char* comptype, const char* statname) const { graph->enableStatisticForComponentType(comptype, statname); }
00085
00086 void addComponentStatisticParameter(ComponentId_t compid, const char* statname, const char* param, const char* value) { graph->addComponentStatisticParameter(compid, statname, param, value); }
00087 void addStatisticParameterForComponentName(const char* compname, const char* statname, const char* param, const char* value) { graph->addStatisticParameterForComponentName(compname, statname, param, value); }
00088 void addStatisticParameterForComponentType(const char* comptype, const char* statname, const char* param, const char* value) { graph->addStatisticParameterForComponentType(comptype, statname, param, value); }
00089 };
00090
00091 }
00092
00093 #endif
00094
00095 #endif