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

optimize: remove hash table lookup from render ops #3

Merged
merged 4 commits into from
Mar 27, 2024
Merged
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
18 changes: 9 additions & 9 deletions runtime/elem/GraphRenderSequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ namespace elem

// Next we prepare the render operation
bufferMap.emplace(node->getId(), ba.next());
auto* outputData = bufferMap.at(node->getId());

renderOps.push_back([=, bufferMap = this->bufferMap](HostContext<FloatType>& ctx) {
auto* outputData = bufferMap.at(node->getId());
renderOps.push_back([=](HostContext<FloatType>& ctx) {

node->process(BlockContext<FloatType> {
ctx.inputData,
Expand All @@ -117,18 +117,18 @@ namespace elem
}

// Next we prepare the render operation
bufferMap.emplace(node->getId(), ba.next());
auto* outputData = ba.next();
bufferMap.emplace(node->getId(), outputData);

// Allocate room for the child pointers here, gets moved into the lambda capture group below
std::vector<FloatType*> ptrs(children.size());
auto const numChildren = children.size();

renderOps.push_back([=, bufferMap = this->bufferMap, ptrs = std::move(ptrs)](HostContext<FloatType>& ctx) mutable {
auto* outputData = bufferMap.at(node->getId());
auto const numChildren = children.size();
for (size_t j = 0; j < numChildren; ++j) {
ptrs[j] = bufferMap.at(children[j]);
}

for (size_t j = 0; j < numChildren; ++j) {
ptrs[j] = bufferMap.at(children[j]);
}
renderOps.push_back([=, ptrs = std::move(ptrs)](HostContext<FloatType>& ctx) mutable {

node->process(BlockContext<FloatType> {
const_cast<const FloatType**>(ptrs.data()),
Expand Down