-
Notifications
You must be signed in to change notification settings - Fork 555
JIT optimization: Faster generation of an unique funcName #3040
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
Changes from all commits
ce92a67
5adfbc0
1dd18ff
6709626
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,17 +64,17 @@ class NaryNode : public Node { | |
| swap(m_op_str, other.m_op_str); | ||
| } | ||
|
|
||
| void genKerName(std::stringstream &kerStream, | ||
| void genKerName(std::string &kerString, | ||
| const common::Node_ids &ids) const final { | ||
| // Make the dec representation of enum part of the Kernel name | ||
| kerStream << "_" << std::setw(3) << std::setfill('0') << std::dec | ||
| << m_op; | ||
| kerString += '_'; | ||
| kerString += std::to_string(m_op); | ||
| kerString += ','; | ||
| for (int i = 0; i < m_num_children; i++) { | ||
| kerStream << std::setw(3) << std::setfill('0') << std::dec | ||
| << ids.child_ids[i]; | ||
| kerString += std::to_string(ids.child_ids[i]); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The zeros here are necessary to avoid naming conflicts. |
||
| kerString += ','; | ||
| } | ||
| kerStream << std::setw(3) << std::setfill('0') << std::dec << ids.id | ||
| << std::dec; | ||
| kerString += std::to_string(ids.id); | ||
| } | ||
|
|
||
| void genFuncs(std::stringstream &kerStream, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,26 +41,20 @@ int Node::getNodesMap(Node_map_t &node_map, vector<Node *> &full_nodes, | |
| std::string getFuncName(const vector<Node *> &output_nodes, | ||
| const vector<Node *> &full_nodes, | ||
| const vector<Node_ids> &full_ids, bool is_linear) { | ||
| std::stringstream funcName; | ||
| std::stringstream hashName; | ||
|
|
||
| if (is_linear) { | ||
| funcName << "L_"; // Kernel Linear | ||
| } else { | ||
| funcName << "G_"; // Kernel General | ||
| } | ||
| std::string funcName; | ||
| funcName.reserve(512); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am guessing this is the primary reason for the performance increase. I don't think its possible to do something similar with string stream. |
||
| funcName = (is_linear ? 'L' : 'G'); | ||
|
|
||
| for (const auto &node : output_nodes) { | ||
| funcName << node->getNameStr() << "_"; | ||
| funcName += '_'; | ||
| funcName += node->getNameStr(); | ||
| } | ||
|
|
||
| for (int i = 0; i < static_cast<int>(full_nodes.size()); i++) { | ||
| full_nodes[i]->genKerName(funcName, full_ids[i]); | ||
| } | ||
|
|
||
| hashName << "KER"; | ||
| hashName << deterministicHash(funcName.str()); | ||
| return hashName.str(); | ||
| return "KER" + std::to_string(deterministicHash(funcName)); | ||
| } | ||
|
|
||
| } // namespace common | ||
Uh oh!
There was an error while loading. Please reload this page.