Skip to content

Commit

Permalink
Process DiffRequests to immediate functions earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailMihov committed Oct 3, 2024
1 parent bd998a0 commit a91260f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/clad/Differentiator/DynamicGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ template <typename T> class DynamicGraph {
bool isProcessingNode() { return m_currentId != -1; }

/// Get the nodes in the graph.
const std::vector<T>& getNodes() { return m_nodes; }
std::vector<T>& getNodes() { return m_nodes; }

/// Print the nodes and edges in the graph.
void print() {
Expand Down
11 changes: 11 additions & 0 deletions tools/ClangPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ namespace clad {
SetRequestOptions(opts);
DiffCollector collector(DGR, CladEnabledRange, m_DiffRequestGraph, S,
opts);

for (DiffRequest& request : m_DiffRequestGraph.getNodes()) {
if (!request.Function->isImmediateFunction() &&
!request.Function->isConstexpr())
continue;

m_DiffRequestGraph.setCurrentProcessingNode(request);
ProcessDiffRequest(request);
m_DiffRequestGraph.markCurrentNodeProcessed();
}

// We could not delay the processing of derivatives, inform act as if each
// call is final. That would still have vgvassilev/clad#248 unresolved.
if (!m_Multiplexer)
Expand Down

0 comments on commit a91260f

Please sign in to comment.