Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed some python issues #1032

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/sst/core/cfgoutput/pythonConfigOutput.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@ PythonConfigGraphOutput::generateParams(const Params& params)
}

const std::string&
PythonConfigGraphOutput::getLinkObject(LinkId_t id, bool no_cut)
PythonConfigGraphOutput::getLinkObject(LinkId_t id, const std::string& name, bool no_cut)
{
if ( linkMap.find(id) == linkMap.end() ) {
char tmp[8 + 8 + 1];
snprintf(tmp, 8 + 8 + 1, "link_id_%08" PRIx32, id);
fprintf(outputFile, "%s = sst.Link(\"%s\")\n", tmp, tmp);
if ( no_cut ) fprintf(outputFile, "%s.setNoCut()\n", tmp);
linkMap[id] = tmp;
char* pyLinkName = makePythonSafeWithPrefix(name.c_str(), "link_");
fprintf(outputFile, "%s = sst.Link(\"%s\")\n", pyLinkName, name.c_str());
if ( no_cut ) fprintf(outputFile, "%s.setNoCut()\n", pyLinkName);
linkMap[id] = pyLinkName;
}
return linkMap[id];
}
Expand Down Expand Up @@ -114,7 +113,7 @@ PythonConfigGraphOutput::generateCommonComponent(const char* objName, const Conf
std::string latencyStr = link->latency_str[idx];
char* esPortName = makeEscapeSafe(link->port[idx].c_str());

const std::string& linkName = getLinkObject(linkID, link->no_cut);
const std::string& linkName = getLinkObject(linkID, link->name, link->no_cut);
fprintf(
outputFile, "%s.addLink(%s, \"%s\", \"%s\")\n", objName, linkName.c_str(), esPortName,
tmp.toStringBestSI().c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/sst/core/cfgoutput/pythonConfigOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PythonConfigGraphOutput : public ConfigGraphOutput
void generateComponent(const ConfigComponent* comp, bool output_parition_info);
void generateStatGroup(const ConfigGraph* graph, const ConfigStatGroup& grp);

const std::string& getLinkObject(LinkId_t id, bool no_cut);
const std::string& getLinkObject(LinkId_t id, const std::string& name, bool no_cut);

char* makePythonSafeWithPrefix(const std::string& name, const std::string& prefix) const;
void makeBufferPythonSafe(char* buffer) const;
Expand Down
4 changes: 2 additions & 2 deletions src/sst/core/model/python/pymodel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ SSTPythonModelDefinition::pushNamePrefix(const char* name)
namePrefixLen *= 2;
}

if ( origLen > 0 ) {
if ( origLen > 0 && newLen > 0 ) {
namePrefix[origLen] = '.';
namePrefix[origLen + 1] = '\0';
}
Expand All @@ -1241,7 +1241,7 @@ SSTPythonModelDefinition::popNamePrefix(void)
char*
SSTPythonModelDefinition::addNamePrefix(const char* name) const
{
if ( nameStack.empty() ) { return strdup(name); }
if ( nameStack.empty() || strlen(namePrefix) == 0 ) { return strdup(name); }
size_t prefixLen = strlen(namePrefix);
char* buf = (char*)malloc(prefixLen + 2 + strlen(name));

Expand Down
Loading