Skip to content
Closed
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
6 changes: 6 additions & 0 deletions src/target/llvm/codegen_hexagon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,12 @@ runtime::Module BuildHexagon(IRModule mod, Target target) {
funcs.emplace_back(f);
}

std::sort(funcs.begin(), funcs.end(), [](PrimFunc func_a, PrimFunc func_b) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, is this something we should fix else where in the compiler? its probably good to add sorting/ordering for determinism.

cc @mbs-octoml @tkonolige

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are definitely more places in the compiler where the names should be sorted for reproducibility. I had a branch where I tried to make codegen more reproducible, but I can't find it. I remember adding sorts to llvm codegen as well as some places where IRModules were constructed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a generalized version of this PR: #8958.

std::string name_a = func_a->GetAttr<String>(tvm::attr::kGlobalSymbol).value();
std::string name_b = func_b->GetAttr<String>(tvm::attr::kGlobalSymbol).value();
return name_a < name_b;
});

cg->Init("TVMHexagonModule", tm.get(), ctx.get(), false, false, false);
for (const PrimFunc& f : funcs) {
cg->AddFunction(f);
Expand Down