1 /* 2 * Copyright (C) 2004-2021 Edward F. Valeev 3 * 4 * This file is part of Libint. 5 * 6 * Libint is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * Libint is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with Libint. If not, see <http://www.gnu.org/licenses/>. 18 * 19 */ 20 21 #ifndef _libint2_src_bin_libint_tforms_h_ 22 #define _libint2_src_bin_libint_tforms_h_ 23 24 #include <string> 25 #include <memory.h> 26 27 namespace libint2 { 28 29 /** 30 Externally accessible registry of information about a graph. Used to control how many algorithms 31 behave (e.g. which transformation rules are allowed, etc.) 32 */ 33 class GraphRegistry { 34 public: 35 GraphRegistry(); 36 ~GraphRegistry(); 37 38 GraphRegistry* clone() const; 39 40 /// Accumulate (true) or assign (false) target vertices? The default is to assign. accumulate_targets()41 bool accumulate_targets() const { return accumulate_targets_; } accumulate_targets(bool at)42 void accumulate_targets(bool at) { accumulate_targets_ = at; } 43 /// Return pointers to targets via Libint_t::targets? Default is true. return_targets()44 bool return_targets() const { return return_targets_; } return_targets(bool rt)45 void return_targets(bool rt) { return_targets_ = rt; } 46 /// Will unroll the integral sets with size <= unroll_threshold. Default is 0 (no unrolling). unroll_threshold()47 unsigned int unroll_threshold() const { return unroll_threshold_; } unroll_threshold(unsigned int ut)48 void unroll_threshold(unsigned int ut) { 49 unroll_threshold_ = ut; 50 } 51 /// Minimum size when can unroll 52 /// Will uncontract the integral sets if true. Default is no uncontracting uncontract()53 bool uncontract() const { return uncontract_; } uncontract(bool uc)54 void uncontract(bool uc) { uncontract_ = uc; } 55 /// Ignore missing prerequisites -- generate the code as is, without generating code for the prerequisites. This is a hack. ignore_missing_prereqs()56 bool ignore_missing_prereqs() const { return ignore_missing_prereqs_; } ignore_missing_prereqs(bool imp)57 void ignore_missing_prereqs(bool imp) { ignore_missing_prereqs_ = imp; } 58 /// Do Common Subexpression Elimination (CSE)? The default is false. do_cse()59 bool do_cse() const { return do_cse_; } do_cse(bool dc)60 void do_cse(bool dc) { do_cse_ = dc; } 61 /// Names the primary scratch space for the intermediates. The default is "libint->stack". stack_name()62 const std::string& stack_name() const { return stack_name_; } stack_name(const std::string & stack_name)63 void stack_name(const std::string& stack_name) { stack_name_ = stack_name; } 64 /// Condense expressions? The default is false. condense_expr()65 bool condense_expr() const { return condense_expr_; } condense_expr(bool ce)66 void condense_expr(bool ce) { condense_expr_ = ce; } 67 /// if -1, no profiling, otherwise, indicates the current timer current_timer()68 int current_timer() const { return current_timer_; } current_timer(int ct)69 void current_timer(int ct) { current_timer_ = ct; } 70 71 private: 72 bool accumulate_targets_; 73 bool return_targets_; 74 unsigned int unroll_threshold_; 75 bool uncontract_; 76 bool ignore_missing_prereqs_; 77 bool do_cse_; 78 bool condense_expr_; 79 std::string stack_name_; 80 int current_timer_; 81 }; 82 83 /** 84 Internal registry of information. Encapsulates info which should not be controled by the user, 85 */ 86 class InternalGraphRegistry { 87 public: 88 InternalGraphRegistry(); 89 ~InternalGraphRegistry(); 90 91 /// Are targets computed, then accumulated, or accumulated directly? The latter possible only if all targets are unrolled. accumulate_targets_directly()92 bool accumulate_targets_directly() const { return accumulate_targets_directly_; } accumulate_targets_directly(bool atd)93 void accumulate_targets_directly(bool atd) { accumulate_targets_directly_ = atd; } 94 /// The size of the buffer at the beginning of stack allocated to hold accumulated targets size_of_target_accum()95 MemoryManager::Size size_of_target_accum() const { return size_of_target_accum_; } size_of_target_accum(const MemoryManager::Size & sota)96 void size_of_target_accum(const MemoryManager::Size& sota) { size_of_target_accum_ = sota; } 97 98 private: 99 bool accumulate_targets_directly_; 100 MemoryManager::Size size_of_target_accum_; 101 }; 102 103 } 104 105 #endif 106 107