Skip to content

Commit 9b50b0b

Browse files
committed
Fix DerivGaussV2 target indexing for size-1 integral sets
handle_trivial_nodes() used default_dims() (hardcoded "1") before adapt_dims_() provided correct runtime dims ("lowdim"/"highdim"). Pass localdims through optimize_rr_out → handle_trivial_nodes.
1 parent 98d7d37 commit 9b50b0b

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

src/bin/libint/dg.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,11 @@ void DirectedGraph::apply_to(const std::shared_ptr<DGVertex>& vertex,
499499

500500
// Optimize out simple recurrence relations
501501
void DirectedGraph::optimize_rr_out(
502-
const std::shared_ptr<CodeContext>& context) {
502+
const std::shared_ptr<CodeContext>& context,
503+
const std::shared_ptr<ImplicitDimensions>& dims) {
503504
replace_rr_with_expr();
504505
remove_trivial_arithmetics();
505-
handle_trivial_nodes(context);
506+
handle_trivial_nodes(context, dims);
506507
remove_disconnected_vertices();
507508
find_subtrees();
508509
}
@@ -797,7 +798,8 @@ inline std::string to_vector_symbol(const std::shared_ptr<DGVertex>& v) {
797798
// refer to another node so that no code is generated for it.
798799
//
799800
void DirectedGraph::handle_trivial_nodes(
800-
const std::shared_ptr<CodeContext>& context) {
801+
const std::shared_ptr<CodeContext>& context,
802+
const std::shared_ptr<ImplicitDimensions>& dims) {
801803
typedef vertices::iterator iter;
802804
for (iter v = stack_.begin(); v != stack_.end(); ++v) {
803805
const ver_ptr& vptr = vertex_ptr(*v);
@@ -821,8 +823,6 @@ void DirectedGraph::handle_trivial_nodes(
821823
// if (child->symbol_set() == false)
822824
{
823825
const std::string stack_name("stack");
824-
const std::shared_ptr<ImplicitDimensions>& dims =
825-
ImplicitDimensions::default_dims();
826826
std::string low_rank = dims->low_label();
827827
std::string veclen = dims->vecdim_label();
828828

src/bin/libint/dg.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#define _libint2_src_bin_libint_dg_h_
2323

2424
#include <dgvertex.h>
25+
#include <dims.h>
2526
#include <exception.h>
2627
#include <global_macros.h>
2728
#include <key.h>
@@ -253,7 +254,9 @@ class DirectedGraph : public std::enable_shared_from_this<DirectedGraph> {
253254
optimized away. optimize_rr_out() will replace all simple recurrence
254255
relations with code representing them.
255256
*/
256-
void optimize_rr_out(const std::shared_ptr<CodeContext>& context);
257+
void optimize_rr_out(const std::shared_ptr<CodeContext>& context,
258+
const std::shared_ptr<ImplicitDimensions>& dims =
259+
ImplicitDimensions::default_dims());
257260

258261
/** after all apply's have been called, traverse()
259262
construct a heuristic order of traversal for the graph.
@@ -438,7 +441,9 @@ class DirectedGraph : public std::enable_shared_from_this<DirectedGraph> {
438441
to their equivalents (such as (ss|ss) shell quartet can only be connected to
439442
(ss|ss) integral)
440443
*/
441-
void handle_trivial_nodes(const std::shared_ptr<CodeContext>& context);
444+
void handle_trivial_nodes(const std::shared_ptr<CodeContext>& context,
445+
const std::shared_ptr<ImplicitDimensions>& dims =
446+
ImplicitDimensions::default_dims());
442447
/// This functions removes vertices not connected to other vertices
443448
void remove_disconnected_vertices();
444449
/** Finds (binary) subtrees. The subtrees correspond to a single-line code (no

src/bin/libint/rr.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,11 @@ void RecurrenceRelation::generate_code(
127127
// Assign symbols for the target and source integral sets
128128
std::shared_ptr<CodeSymbols> symbols(new CodeSymbols);
129129
assign_symbols_(symbols);
130+
// Compute local dimensions before optimize_rr_out so that
131+
// handle_trivial_nodes uses the correct dims (e.g., "lowdim" instead of "1")
132+
std::shared_ptr<ImplicitDimensions> localdims = adapt_dims_(dims);
130133
// Traverse the graph
131-
dg->optimize_rr_out(context);
134+
dg->optimize_rr_out(context, localdims);
132135
dg->traverse();
133136
#if PRINT_DAG_GRAPHVIZ
134137
{
@@ -138,7 +141,6 @@ void RecurrenceRelation::generate_code(
138141
#endif
139142
// Generate code
140143
std::shared_ptr<MemoryManager> memman(new WorstFitMemoryManager());
141-
std::shared_ptr<ImplicitDimensions> localdims = adapt_dims_(dims);
142144
dg->generate_code(context, memman, localdims, symbols, funcname, decl, def);
143145

144146
// extract all external symbols -- these will be members of the evaluator

0 commit comments

Comments
 (0)