Psi4
operation.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Psi4: an open-source quantum chemistry software package
5  *
6  * Copyright (c) 2007-2018 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This file is part of Psi4.
12  *
13  * Psi4 is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License as published by
15  * the Free Software Foundation, version 3.
16  *
17  * Psi4 is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License along
23  * with Psi4; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  *
26  * @END LICENSE
27  */
28 
29 #ifndef _psi_src_bin_psimrcc_ccoperation_h
30 #define _psi_src_bin_psimrcc_ccoperation_h
31 
32 #include <string>
33 
34 namespace psi {
35 namespace psimrcc {
36 
37 class CCIndex;
38 class CCMatrix;
39 
40 class CCOperation {
41  // Used to define operations of the type:
42  // A [+ -]= ## factor B [* / @] C
43  public:
44  CCOperation(double in_factor, std::string in_assignment, std::string in_reindexing, std::string in_operation,
45  CCMatrix* in_A_Matrix, CCMatrix* in_B_Matrix, CCMatrix* in_C_Matrix, double* work, double* buffer);
46  ~CCOperation();
47  double get_factor() { return (factor); }
48  std::string get_assignment() { return (assignment); }
49  std::string get_reindexing() { return (reindexing); }
50  std::string get_operation() { return (operation); }
51  CCMatrix* get_A_Matrix() { return (A_Matrix); }
52  CCMatrix* get_B_Matrix() { return (B_Matrix); }
53  CCMatrix* get_C_Matrix() { return (C_Matrix); }
54  void print();
55  void print_operation();
56  void compute();
57  static void print_timing();
58 
59  private:
60  // Variable Syntax (p,q,r,s=integers)
61  double factor; // + - +p/q -p/q
62  std::string assignment; // = += >= +>=
63  std::string reindexing; // ## #pq# #pqrs#
64  std::string operation; // . @ / * X plus
65  static double* out_of_core_buffer;
66  static double* local_work;
70 
71  private:
72  // Check that an operation can be performed
73  bool compatible_dot();
74  bool compatible_contract();
76  //
77  static double zero_timing;
78  static double numerical_timing;
79  static double contract_timing;
80  static double tensor_timing;
81  static double dot_timing;
82  static double plus_timing;
83  static double product_timing;
84  static double division_timing;
85  static double sort_timing;
86  static double PartA_timing;
87  static double PartB_timing;
88  static double PartC_timing;
89  void fail_to_compute();
90  void add_numerical_factor();
91  void contract();
92  void dot_product();
96  void different_index_contract(int A_type, double factor, int B_type, std::string& operation, int C_type,
97  std::string& reindexing);
98  void reindex(double constant);
99  void* reindex_thread(void* my_id);
100  void* reindex_thread_right_expand(void* my_id);
101  void tensor_product();
102  void setup_contractions();
103  void contract_in_core(double** A_matrix, double** B_matrix, double** C_matrix, bool B_on_disk, bool C_on_disk,
104  int rows_A, int rows_B, int rows_C, int cols_A, int cols_B, int cols_C, int offset);
105  void sort(CCIndex* T_left, CCIndex* T_right, double*** T_matrix, double constant);
106  void sort();
107  void check_and_zero_target();
108  void check_and_zero_target_block(int h);
109  void zero_target();
110  void zero_target_block(int h);
111  void zero_two_diagonal();
112 };
113 
114 } // namespace psimrcc
115 } // namespace psi
116 
117 #endif // _psi_src_bin_psimrcc_ccoperation_h
void dot_product()
Definition: operation_compute.cc:117
void contract_in_core(double **A_matrix, double **B_matrix, double **C_matrix, bool B_on_disk, bool C_on_disk, int rows_A, int rows_B, int rows_C, int cols_A, int cols_B, int cols_C, int offset)
Definition: operation_contraction.cc:233
void tensor_product()
Definition: operation_compute.cc:179
PsiReturnType psimrcc(SharedWavefunction, Options &)
Definition: psimrcc/main.cc:86
static double sort_timing
Definition: operation.h:85
void * reindex_thread_right_expand(void *my_id)
static double * out_of_core_buffer
Definition: operation.h:65
void zero_target()
Definition: operation_compute.cc:211
Definition: psimrcc/matrix.h:49
std::string operation
Definition: operation.h:64
~CCOperation()
Definition: operation.cc:69
static double plus_timing
Definition: operation.h:82
void fail_to_compute()
Definition: operation_compute.cc:221
Definition: operation.h:40
CCMatrix * get_C_Matrix()
Definition: operation.h:53
std::string get_assignment()
Definition: operation.h:48
std::string get_operation()
Definition: operation.h:50
static double zero_timing
Definition: operation.h:77
std::string assignment
Definition: operation.h:62
static double contract_timing
Definition: operation.h:79
Definition: index.h:67
bool compatible_element_by_element()
Definition: blas_compatibile.cc:70
CCMatrix * B_Matrix
Definition: operation.h:68
void contract()
Definition: operation_compute.cc:190
bool compatible_contract()
Definition: blas_compatibile.cc:104
void print_operation()
Definition: operation.cc:81
CCMatrix * C_Matrix
Definition: operation.h:69
CCMatrix * get_A_Matrix()
Definition: operation.h:51
static double * local_work
Definition: operation.h:66
std::string get_reindexing()
Definition: operation.h:49
void different_index_contract(int A_type, double factor, int B_type, std::string &operation, int C_type, std::string &reindexing)
void * reindex_thread(void *my_id)
void compute()
Definition: operation_compute.cc:55
void zero_target_block(int h)
Definition: operation_compute.cc:215
void zero_two_diagonal()
Definition: operation_compute.cc:201
void reindex(double constant)
static double product_timing
Definition: operation.h:83
static double dot_timing
Definition: operation.h:81
double factor
Definition: operation.h:61
static double numerical_timing
Definition: operation.h:78
CCOperation(double in_factor, std::string in_assignment, std::string in_reindexing, std::string in_operation, CCMatrix *in_A_Matrix, CCMatrix *in_B_Matrix, CCMatrix *in_C_Matrix, double *work, double *buffer)
Definition: operation.cc:55
void print()
Definition: operation.cc:71
void check_and_zero_target()
Definition: operation_compute.cc:203
static double PartB_timing
Definition: operation.h:87
static double division_timing
Definition: operation.h:84
static double tensor_timing
Definition: operation.h:80
void element_by_element_division()
Definition: operation_compute.cc:147
void setup_contractions()
Definition: operation_contraction.cc:49
void add_numerical_factor()
Definition: operation_compute.cc:109
bool compatible_dot()
Definition: blas_compatibile.cc:42
CCMatrix * get_B_Matrix()
Definition: operation.h:52
static double PartC_timing
Definition: operation.h:88
static double PartA_timing
Definition: operation.h:86
double get_factor()
Definition: operation.h:47
std::string reindexing
Definition: operation.h:63
void check_and_zero_target_block(int h)
Definition: operation_compute.cc:207
void element_by_element_product()
Definition: operation_compute.cc:134
void sort()
Definition: operation_sort.cc:45
static void print_timing()
Definition: operation.cc:91
CCMatrix * A_Matrix
Definition: operation.h:67
void element_by_element_addition()
Definition: operation_compute.cc:160