Psi4
PK_workers.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 PKWRKR_H
30 #define PKWRKR_H
31 
32 #if !defined(EXPLICIT_IOFF)
33 #define EXPLICIT_IOFF(i) ((i) * ((i) + 1) / 2)
34 #endif
35 
36 #if !defined(INDEX2)
37 #define INDEX2(i, j) ((i) >= (j) ? EXPLICIT_IOFF(i) + (j) : EXPLICIT_IOFF(j) + (i))
38 #endif
39 
40 #if !defined(INDEX4)
41 #define INDEX4(i, j, k, l) (INDEX2(INDEX2((i), (j)), INDEX2((k), (l))))
42 #endif
43 
44 #include "psi4/libiwl/config.h"
45 #include "psi4/libpsio/config.h"
47 
48 namespace psi {
49 
50 class AIOHandler;
51 class ERISieve;
52 class BasisSet;
53 class GaussianShell;
54 
55 namespace pk {
56 
57 // Forward declarations just before definitions
58 class AOShellSieveIterator;
60 
61 typedef std::unique_ptr<AOShellSieveIterator> UniqueAOShellIt;
62 typedef std::shared_ptr<ERISieve> SharedSieve;
63 
69  private:
70  // Basis set
71  std::shared_ptr<BasisSet> bs_;
72  // Sieve object
74  // Vector of significant shell pairs
75  const std::vector<std::pair<int, int>>& shell_pairs_;
76  // Number of shell pairs
77  size_t npairs_;
78  // Shell triangular indices
79  size_t PQ_, RS_;
80  // Shell indices
81  int P_, Q_, R_, S_;
82  // Are we there yet?
83  bool done_;
84 
85  // Populate indices from shell_pairs
86  void populate_indices();
87 
88  public:
90  AOShellSieveIterator(std::shared_ptr<BasisSet> prim, SharedSieve sieve_input);
91 
93  void first();
94  void next();
95  bool is_done() { return done_; }
96 
98  int p() const { return P_; }
99  int q() const { return Q_; }
100  int r() const { return R_; }
101  int s() const { return S_; }
102 
105 };
106 
112  private:
113  // Sieve
114  std::shared_ptr<ERISieve> sieve_;
115  // Integral indices
116  int i_, j_, k_, l_;
117  // Relative integral indices within shells
119  // Gaussian shells of interest
124  // Number of functions for each shell
125  int ni_, nj_, nk_, nl_;
126  // First index for each shell
127  int fi_, fj_, fk_, fl_;
128  // Max index for each shell
130  // Are we there yet ?
131  bool done_;
132 
133  // Do we have the same shells in the quartets?
134  bool sh_aaaa_;
135  bool sh_abab_;
136  // Populate the integral indices, and reorder them
137  void populate_indices();
138  // Increment the integral indices to the next ones for ij
139  void increment_bra();
140  // Increment integral indices to the next ones for l,k,j,i (in this order)
141  void increment_ket();
142  // Reorder indices in canonical order
143  void reorder_inds();
144 
145  public:
147  AOFctSieveIterator(const GaussianShell& s1, const GaussianShell& s2, const GaussianShell& s3,
148  const GaussianShell& s4, std::shared_ptr<ERISieve> siev);
149 
151  void first();
152  void next();
153  bool is_done() { return done_; }
154 
155  int i() const { return i_; }
156  int j() const { return j_; }
157  int k() const { return k_; }
158  int l() const { return l_; }
159 };
160 
168 class IWLAsync_PK {
169  private:
171  int itap_;
173  size_t* address_;
179  size_t JobID_[2];
183  size_t nints_;
185  int lastbuf_;
187  int idx_;
189  std::shared_ptr<AIOHandler> AIO_;
190 
191  public:
193  IWLAsync_PK(size_t* address, std::shared_ptr<AIOHandler> AIO, int itap);
195  ~IWLAsync_PK();
196 
198  void fill_values(double val, size_t i, size_t j, size_t k, size_t l);
200  void pop_value(double& val, size_t& i, size_t& j, size_t& k, size_t& l);
202  void write();
205  void flush();
206 
208  size_t nints() { return nints_; }
209  size_t maxints() { return ints_per_buf_; }
210 };
211 
219 class PKWorker {
220  private:
222  std::shared_ptr<BasisSet> primary_;
226  bool do_wK_;
227 
229  std::shared_ptr<AIOHandler> AIO_;
232 
236  size_t bufidx_;
238  size_t offset_;
240  size_t max_idx_;
242  size_t buf_size_;
244  size_t nbuf_;
247 
249  size_t P_, Q_, R_, S_;
250 
252  bool is_shell_relevant();
253 
254  // This class should never be copied
255  PKWorker(const PKWorker& other) = delete;
256  PKWorker& operator=(PKWorker& other) = delete;
257 
258  protected:
260  void set_nbuf(size_t tmp) { nbuf_ = tmp; }
262  void set_bufsize(size_t len) { buf_size_ = len; }
264  void set_max_idx(size_t tmp) { max_idx_ = tmp; }
265 
266  public:
268  PKWorker(std::shared_ptr<BasisSet> primary, SharedSieve sieve, std::shared_ptr<AIOHandler> AIO, int target_file,
269  size_t buf_size);
271  virtual ~PKWorker() {}
272 
274  std::shared_ptr<AIOHandler> AIO() const { return AIO_; }
275  size_t nbuf() const { return nbuf_; }
276  size_t buf_size() const { return buf_size_; }
277  size_t max_idx() const { return max_idx_; }
278  size_t offset() const { return offset_; }
279  int target_file() const { return target_file_; }
280  size_t bufidx() const { return bufidx_; }
281  size_t P() const { return P_; }
282  size_t Q() const { return Q_; }
283  size_t R() const { return R_; }
284  size_t S() const { return S_; }
285  bool do_wK() const { return do_wK_; }
287  void set_do_wK(bool tmp) { do_wK_ = tmp; }
288 
290  static char* get_label_J(const int batch);
291  static char* get_label_K(const int batch);
292  static char* get_label_wK(const int batch);
293 
296  virtual void initialize_task() = 0;
297 
299  void first_quartet(size_t i);
301  bool more_work() { return shells_left_; }
303  void next_quartet();
304 
306  virtual void allocate_wK(size_t buf_size, size_t buf_per_thread) {
307  throw PSIEXCEPTION("Function allocate_wK not implemented for this PK algorithm.\n");
308  }
310  virtual void allocate_wK(std::shared_ptr<std::vector<size_t>> pos, int wKfile) {
311  throw PSIEXCEPTION("Invoked function allocate_wK not implemented for this PK algorithm.\n");
312  }
313 
315  virtual void fill_values(double val, size_t i, size_t j, size_t k, size_t l) = 0;
317  virtual void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l) = 0;
318 
320  virtual void write(std::vector<size_t> min_ind, std::vector<size_t> max_ind, size_t pk_pairs) = 0;
322  virtual void write_wK(std::vector<size_t> min_ind, std::vector<size_t> max_ind, size_t pk_pairs) {
323  throw PSIEXCEPTION("Function write_wK not implemented for current PK algorithm\n");
324  }
325 
327  virtual void finalize_ints(size_t pk_pairs) {
328  throw PSIEXCEPTION("Function not implemented for this PK algorithm.\n");
329  }
331  virtual void finalize_ints_wK(size_t pk_pairs) {
332  throw PSIEXCEPTION("Function not implemented for this PK algorithm.\n");
333  }
334 
336  virtual bool pop_value(size_t bufid, double& val, size_t& i, size_t& j, size_t& k, size_t& l) {
337  throw PSIEXCEPTION("Function pop_value not implemented for this class\n");
338  }
340  virtual bool pop_value_wK(size_t bufid, double& val, size_t& i, size_t& j, size_t& k, size_t& l) {
341  throw PSIEXCEPTION("Function pop_value_wK not implemented for this class\n");
342  }
343 
344  virtual void insert_value(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l) {
345  throw PSIEXCEPTION("Function insert_value not implemented for this class\n");
346  }
347  virtual void insert_value_wK(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l) {
348  throw PSIEXCEPTION("Function insert_value_wK not implemented for this class\n");
349  }
350 
352  virtual void flush() { throw PSIEXCEPTION("Function flush not implemented for this class\n"); }
353  virtual void flush_wK() { throw PSIEXCEPTION("Function flush not implemented for this class\n"); }
354 };
355 
369 class PKWrkrReord : public PKWorker {
370  private:
374 
376  std::vector<std::vector<char*>> labels_J_;
377  std::vector<std::vector<char*>> labels_K_;
378  std::vector<std::vector<char*>> labels_wK_;
380  std::vector<std::vector<size_t>> jobID_J_;
381  std::vector<std::vector<size_t>> jobID_K_;
382  std::vector<std::vector<size_t>> jobID_wK_;
384  std::vector<double*> J_bufs_;
385  std::vector<double*> K_bufs_;
386  std::vector<double*> wK_bufs_;
387 
390 
392  size_t buf_;
393 
394  void initialize_task() override;
395 
396  public:
398  PKWrkrReord(std::shared_ptr<BasisSet> primary, SharedSieve sieve, std::shared_ptr<AIOHandler> AIO, int target_file,
399  size_t buffer_size, size_t nbuffer);
401  ~PKWrkrReord() override;
402 
405  void allocate_wK(size_t buf_size, size_t buf_per_thread) override;
406 
408  void fill_values(double val, size_t i, size_t j, size_t k, size_t l) override;
410  void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l) override;
411 
413  void write(std::vector<size_t> min_ind, std::vector<size_t> max_ind, size_t pk_pairs) override;
415  void write_wK(std::vector<size_t> min_ind, std::vector<size_t> max_ind, size_t pk_pairs) override;
416 };
417 
426 class PKWrkrInCore : public PKWorker {
427  private:
428  // We need to know the number of workers to properly
429  // adjust the size of the last buffer
431  size_t pk_size_;
432  size_t last_buf_;
433  // Memory allocated and deleted outside this worker
434  // Pointers to absolute memory start
435  double* J_buf0_;
436  double* K_buf0_;
437  double* wK_buf0_;
438  // Pointers to local memory start
439  double* J_bufp_;
440  double* K_bufp_;
441  double* wK_bufp_;
442 
443  void initialize_task() override;
444 
445  public:
446  PKWrkrInCore(std::shared_ptr<BasisSet> primary, SharedSieve sieve, size_t buf_size, size_t lastbuf, double* Jbuf,
447  double* Kbuf, double* wKbuf, int nworkers);
448 
450  void fill_values(double val, size_t i, size_t j, size_t k, size_t l) override;
452  void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l) override;
453 
455  void finalize_ints(size_t pk_pairs) override;
457  void finalize_ints_wK(size_t pk_pairs) override;
458 
460  void write(std::vector<size_t> min_ind, std::vector<size_t> max_ind, size_t pk_pairs) override {
461  throw PSIEXCEPTION("Function not implemented for in-core");
462  }
463 };
464 
471 class PKWrkrIWL : public PKWorker {
472  private:
474  int K_file_;
476  int wK_file_;
478  std::vector<int> buf_for_pq_;
480  std::vector<IWLAsync_PK*> IWL_J_;
481  std::vector<IWLAsync_PK*> IWL_K_;
482  std::vector<IWLAsync_PK*> IWL_wK_;
485  std::shared_ptr<std::vector<size_t>> addresses_;
486  std::shared_ptr<std::vector<size_t>> addresses_wK_;
487 
488  public:
490  PKWrkrIWL(std::shared_ptr<BasisSet> primary, SharedSieve sieve, std::shared_ptr<AIOHandler> AIOp, int targetfile,
491  int K_file, size_t buf_size, std::vector<int>& bufforpq, std::shared_ptr<std::vector<size_t>> pos);
493  ~PKWrkrIWL() override;
494 
496  void allocate_wK(std::shared_ptr<std::vector<size_t>> pos, int wKfile) override;
497 
499  void fill_values(double val, size_t i, size_t j, size_t k, size_t l) override;
501  void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l) override;
503  bool pop_value(size_t bufid, double& val, size_t& i, size_t& j, size_t& k, size_t& l) override;
505  void insert_value(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l) override;
507  bool pop_value_wK(size_t bufid, double& val, size_t& i, size_t& j, size_t& k, size_t& l) override;
509  void insert_value_wK(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l) override;
511  void flush() override;
513  void flush_wK() override;
514 
516  void initialize_task() override { throw PSIEXCEPTION("initialize_task not implemented for this class\n"); }
517  void write(std::vector<size_t> min_ind, std::vector<size_t> max_ind, size_t pk_pairs) override {
518  throw PSIEXCEPTION("write not implemented for this class\n");
519  }
520 };
521 
522 } // End namespace pk
523 } // End namespace psi
524 
525 #endif
int q() const
Definition: PK_workers.h:99
int fj_
Definition: PK_workers.h:127
static char * get_label_J(const int batch)
Get TOC labels for J or K.
Definition: PK_workers.cc:333
void initialize_task() override
Definition: PK_workers.cc:568
virtual void allocate_wK(size_t buf_size, size_t buf_per_thread)
Reallocate the buffer memory for wK.
Definition: PK_workers.h:306
virtual void insert_value_wK(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l)
Definition: PK_workers.h:347
int krel_
Definition: PK_workers.h:118
Definition: PK_workers.h:219
const GaussianShell & usj_
Definition: PK_workers.h:121
void fill_values(double val, size_t i, size_t j, size_t k, size_t l) override
Filling values in the relevant part of the buffer.
Definition: PK_workers.cc:771
void allocate_wK(size_t buf_size, size_t buf_per_thread) override
Definition: PK_workers.cc:526
std::vector< std::vector< char * > > labels_wK_
Definition: PK_workers.h:378
std::vector< std::vector< size_t > > jobID_wK_
Definition: PK_workers.h:382
std::vector< std::vector< size_t > > jobID_K_
Definition: PK_workers.h:381
const std::vector< std::pair< int, int > > & shell_pairs_
Definition: PK_workers.h:75
int Q_
Definition: PK_workers.h:81
double * wK_buf0_
Definition: PK_workers.h:437
int r() const
Definition: PK_workers.h:100
PKWrkrIWL(std::shared_ptr< BasisSet > primary, SharedSieve sieve, std::shared_ptr< AIOHandler > AIOp, int targetfile, int K_file, size_t buf_size, std::vector< int > &bufforpq, std::shared_ptr< std::vector< size_t >> pos)
Constructor.
Definition: PK_workers.cc:850
~PKWrkrReord() override
Destructor.
Definition: PK_workers.cc:488
~PKWrkrIWL() override
Destructor.
Definition: PK_workers.cc:867
void next()
Definition: PK_workers.cc:300
bool done_
Definition: PK_workers.h:83
void reorder_inds()
Definition: PK_workers.cc:232
std::vector< double * > J_bufs_
The internal buffers themselves.
Definition: PK_workers.h:384
void allocate_wK(std::shared_ptr< std::vector< size_t >> pos, int wKfile) override
Preparing for wK pre-sorting to file.
Definition: PK_workers.cc:877
void increment_bra()
Definition: PK_workers.cc:139
short int Label
Definition: libiwl/config.h:34
std::shared_ptr< AIOHandler > AIO() const
Accessor functions.
Definition: PK_workers.h:274
IWLAsync_PK(size_t *address, std::shared_ptr< AIOHandler > AIO, int itap)
Constructor, also allocates the arrays.
Definition: PK_workers.cc:995
size_t nints_
Current number of integrals in buffer.
Definition: PK_workers.h:183
void fill_values(double val, size_t i, size_t j, size_t k, size_t l)
Filling values in the bucket.
Definition: PK_workers.cc:1018
void set_bufsize(size_t len)
Setting the buffer size, changes for wK.
Definition: PK_workers.h:262
int k_
Definition: PK_workers.h:116
void write()
Actually writing integrals from the buffer to the disk.
Definition: PK_workers.cc:1028
int p() const
Accessor functions.
Definition: PK_workers.h:98
psio_address dummy_
Dummy psio_address for storage of write return value.
Definition: PK_workers.h:389
const GaussianShell & usl_
Definition: PK_workers.h:123
std::vector< double * > wK_bufs_
Definition: PK_workers.h:386
int irel_
Definition: PK_workers.h:118
int j_
Definition: PK_workers.h:116
std::vector< double * > K_bufs_
Definition: PK_workers.h:385
size_t pk_size_
Definition: PK_workers.h:431
void initialize_task() override
Definition: PK_workers.cc:754
size_t buf_size() const
Definition: PK_workers.h:276
size_t P() const
Definition: PK_workers.h:281
void next()
Definition: PK_workers.cc:80
bool is_done()
Definition: PK_workers.h:95
void set_max_idx(size_t tmp)
Setter function for max_idx.
Definition: PK_workers.h:264
int nk_
Definition: PK_workers.h:125
bool pop_value(size_t bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l) override
Popping a value from a buffer to finalize writing.
Definition: PK_workers.cc:933
int l() const
Definition: PK_workers.h:158
int fk_
Definition: PK_workers.h:127
std::unique_ptr< AOShellSieveIterator > UniqueAOShellIt
Definition: PK_workers.h:59
int maxl_
Definition: PK_workers.h:129
bool sh_aaaa_
Definition: PK_workers.h:134
virtual void finalize_ints_wK(size_t pk_pairs)
For in-core: only finalize the wK integral array.
Definition: PK_workers.h:331
int itap_
File number.
Definition: PK_workers.h:171
UniqueAOShellIt shelliter_
Iterator over basis functions within a shell quartet.
Definition: PK_workers.h:234
double * J_buf0_
Definition: PK_workers.h:435
int ni_
Definition: PK_workers.h:125
Definition: pointgrp.h:104
size_t buf_
Internal buffer index.
Definition: PK_workers.h:392
Definition: libpsio/config.h:65
size_t nbuf_
Number of buffers in the worker.
Definition: PK_workers.h:244
void fill_values(double val, size_t i, size_t j, size_t k, size_t l) override
Filling integral values in relevant buffer.
Definition: PK_workers.cc:570
PKWorker & operator=(PKWorker &other)=delete
std::shared_ptr< ERISieve > sieve_
Definition: PK_workers.h:114
virtual void flush_wK()
Definition: PK_workers.h:353
bool done_
Definition: PK_workers.h:131
Definition: PK_workers.h:68
size_t nbuf() const
Definition: PK_workers.h:275
std::vector< IWLAsync_PK * > IWL_wK_
Definition: PK_workers.h:482
void first_quartet(size_t i)
Set up the first shell quartet to be computed.
Definition: PK_workers.cc:351
int k() const
Definition: PK_workers.h:157
AOFctSieveIterator integrals_iterator()
Sieved iterator over the basis functions of a given shell.
Definition: PK_workers.cc:107
double * J_bufp_
Definition: PK_workers.h:439
size_t JobID_[2]
Job Ids for AIO.
Definition: PK_workers.h:179
size_t offset() const
Definition: PK_workers.h:278
const GaussianShell & usk_
Definition: PK_workers.h:122
bool shells_left_
Are there any shells left ?
Definition: PK_workers.h:246
virtual void allocate_wK(std::shared_ptr< std::vector< size_t >> pos, int wKfile)
For IWL, we need different arguments.
Definition: PK_workers.h:310
size_t R() const
Definition: PK_workers.h:283
virtual void fill_values(double val, size_t i, size_t j, size_t k, size_t l)=0
Filling integral values in the relevant buffers.
size_t * address_
Position in bytes for next write.
Definition: PK_workers.h:173
void flush()
Definition: PK_workers.cc:1057
int j() const
Definition: PK_workers.h:156
virtual void insert_value(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l)
Definition: PK_workers.h:344
std::shared_ptr< std::vector< size_t > > addresses_wK_
Definition: PK_workers.h:486
int nworkers_
Definition: PK_workers.h:430
size_t S_
Definition: PK_workers.h:249
Label * labels_[2]
Integral labels.
Definition: PK_workers.h:175
bool more_work()
Is there a shell quartet left to compute ?
Definition: PK_workers.h:301
size_t max_idx() const
Definition: PK_workers.h:277
size_t nints()
Accessor functions.
Definition: PK_workers.h:208
void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l) override
Filling values in the relevant part of the buffer for wK.
Definition: PK_workers.cc:816
size_t R_
Definition: PK_workers.h:249
SharedSieve sieve_
Definition: PK_workers.h:73
std::vector< IWLAsync_PK * > IWL_K_
Definition: PK_workers.h:481
void first()
Iterator functions.
Definition: PK_workers.cc:261
std::shared_ptr< std::vector< size_t > > addresses_
Definition: PK_workers.h:485
void insert_value(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l) override
Inserting a value back into a buffer.
Definition: PK_workers.cc:956
int target_file() const
Definition: PK_workers.h:279
bool is_done()
Definition: PK_workers.h:153
int maxk_
Definition: PK_workers.h:129
std::shared_ptr< AIOHandler > AIO_
AIOHandler.
Definition: PK_workers.h:229
void write(std::vector< size_t > min_ind, std::vector< size_t > max_ind, size_t pk_pairs) override
Writing values in the appropriate PK file entry.
Definition: PK_workers.cc:603
int R_
Definition: PK_workers.h:81
size_t max_idx_
Current max ijkl index in the buffer.
Definition: PK_workers.h:240
int s() const
Definition: PK_workers.h:101
double * K_buf0_
Definition: PK_workers.h:436
bool pop_value_wK(size_t bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l) override
Popping a wK value from a buffer to finalize writing.
Definition: PK_workers.cc:947
PKWrkrInCore(std::shared_ptr< BasisSet > primary, SharedSieve sieve, size_t buf_size, size_t lastbuf, double *Jbuf, double *Kbuf, double *wKbuf, int nworkers)
Definition: PK_workers.cc:739
void set_do_wK(bool tmp)
Set do_wK.
Definition: PK_workers.h:287
virtual ~PKWorker()
Destructor for PKWorker, does nothing.
Definition: PK_workers.h:271
int P_
Definition: PK_workers.h:81
virtual void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l)=0
Filling integral values in the relevant buffers for wK.
size_t Q() const
Definition: PK_workers.h:282
Value * values_[2]
Integral values.
Definition: PK_workers.h:177
int fl_
Definition: PK_workers.h:127
std::vector< std::vector< char * > > labels_J_
TOC entry labels.
Definition: PK_workers.h:376
void fill_values(double val, size_t i, size_t j, size_t k, size_t l) override
Filling integrals in the appropriate buffers.
Definition: PK_workers.cc:887
virtual void flush()
Flush a buffer to disk.
Definition: PK_workers.h:352
std::shared_ptr< BasisSet > primary_
Current basis set.
Definition: PK_workers.h:222
size_t ints_per_buf_
Number of integrals per buffer.
Definition: PK_workers.h:181
PKWrkrReord(std::shared_ptr< BasisSet > primary, SharedSieve sieve, std::shared_ptr< AIOHandler > AIO, int target_file, size_t buffer_size, size_t nbuffer)
Constructor.
Definition: PK_workers.cc:460
bool sh_abab_
Definition: PK_workers.h:135
virtual bool pop_value(size_t bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l)
Functions specific to disk pre-sorting of integrals.
Definition: PK_workers.h:336
int nl_
Definition: PK_workers.h:125
const GaussianShell & usi_
Definition: PK_workers.h:120
std::shared_ptr< ERISieve > SharedSieve
Definition: PK_workers.h:62
Definition: PK_workers.h:471
int nj_
Definition: PK_workers.h:125
void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l) override
Filling wK integrals in the appropriate buffers.
Definition: PK_workers.cc:924
virtual void write_wK(std::vector< size_t > min_ind, std::vector< size_t > max_ind, size_t pk_pairs)
Writing wK integral arrays for storage.
Definition: PK_workers.h:322
void initialize_task() override
Functions that are not used here.
Definition: PK_workers.h:516
void next_quartet()
Get the next shell quartet for the current worker.
Definition: PK_workers.cc:442
int lrel_
Definition: PK_workers.h:118
int jrel_
Definition: PK_workers.h:118
size_t last_buf_
Definition: PK_workers.h:432
void first()
Iterator functions.
Definition: PK_workers.cc:60
int S_
Definition: PK_workers.h:81
SharedSieve sieve_
Current sieve.
Definition: PK_workers.h:224
static char * get_label_K(const int batch)
Definition: PK_workers.cc:339
size_t Q_
Definition: PK_workers.h:249
Definition: PK_workers.h:426
int i() const
Definition: PK_workers.h:155
Gaussian orbital shell.
Definition: gshell.h:168
std::shared_ptr< AIOHandler > AIO_
The AIO Handler.
Definition: PK_workers.h:189
int idx_
Are we using buffer 1 or 2?
Definition: PK_workers.h:187
int i_
Definition: PK_workers.h:116
double * K_bufp_
Definition: PK_workers.h:440
bool is_shell_relevant()
Is the current shell relevant to the current worker ?
Definition: PK_workers.cc:371
void finalize_ints_wK(size_t pk_pairs) override
Finalize the buffer for wK: divide by two diagonal elements.
Definition: PK_workers.cc:841
virtual void write(std::vector< size_t > min_ind, std::vector< size_t > max_ind, size_t pk_pairs)=0
Writing integral arrays for storage.
size_t bufidx_
Current global index of the buffer.
Definition: PK_workers.h:236
Definition: PK_workers.h:111
std::shared_ptr< BasisSet > bs_
Definition: PK_workers.h:71
virtual void initialize_task()=0
size_t RS_
Definition: PK_workers.h:79
size_t P_
Indices of the current shell quartet.
Definition: PK_workers.h:249
size_t buf_size_
Size of one buffer.
Definition: PK_workers.h:242
virtual bool pop_value_wK(size_t bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l)
Functions specific to disk pre-sorting of integrals.
Definition: PK_workers.h:340
int K_file_
File for K IWL batches.
Definition: PK_workers.h:474
void populate_indices()
Definition: PK_workers.cc:53
std::vector< IWLAsync_PK * > IWL_J_
Vectors of IWL buffers for storage in the proper pre-sorting bucket.
Definition: PK_workers.h:480
virtual void finalize_ints(size_t pk_pairs)
For in-core: only finalize the integral array.
Definition: PK_workers.h:327
int l_
Definition: PK_workers.h:116
void pop_value(double &val, size_t &i, size_t &j, size_t &k, size_t &l)
Popping a value from the current buffer, also decrements integral count.
Definition: PK_workers.cc:1044
void flush_wK() override
Flushing all wK buffers for current worker.
Definition: PK_workers.cc:987
void flush() override
Flushing all buffers for current worker.
Definition: PK_workers.cc:977
bool do_wK() const
Definition: PK_workers.h:285
std::vector< int > buf_for_pq_
Vector mapping pq index to a bucket.
Definition: PK_workers.h:478
PKWorker(const PKWorker &other)=delete
void finalize_ints(size_t pk_pairs) override
Finalize the buffer: divide by two diagonal elements.
Definition: PK_workers.cc:831
void write(std::vector< size_t > min_ind, std::vector< size_t > max_ind, size_t pk_pairs) override
Function write is never used.
Definition: PK_workers.h:460
Definition: PK_workers.h:369
double Value
Definition: libiwl/config.h:35
Definition: PK_workers.h:168
int wK_file_
File for wK IWL batches.
Definition: PK_workers.h:476
size_t S() const
Definition: PK_workers.h:284
size_t offset_
Current offset.
Definition: PK_workers.h:238
~IWLAsync_PK()
Destructor, also deallocates the arrays.
Definition: PK_workers.cc:1011
int fi_
Definition: PK_workers.h:127
void insert_value_wK(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l) override
Inserting a wK value back into a buffer.
Definition: PK_workers.cc:969
size_t bufidx() const
Definition: PK_workers.h:280
void write(std::vector< size_t > min_ind, std::vector< size_t > max_ind, size_t pk_pairs) override
Writing integral arrays for storage.
Definition: PK_workers.h:517
std::vector< std::vector< size_t > > jobID_J_
Job IDs.
Definition: PK_workers.h:380
int maxj_
Definition: PK_workers.h:129
void increment_ket()
Definition: PK_workers.cc:168
std::vector< std::vector< char * > > labels_K_
Definition: PK_workers.h:377
int target_file_
File to write to.
Definition: PK_workers.h:231
size_t PQ_
Definition: PK_workers.h:79
#define PSIEXCEPTION(message)
Definition: exception.h:48
AOShellSieveIterator(std::shared_ptr< BasisSet > prim, SharedSieve sieve_input)
Constructor.
Definition: PK_workers.cc:43
AOFctSieveIterator(const GaussianShell &s1, const GaussianShell &s2, const GaussianShell &s3, const GaussianShell &s4, std::shared_ptr< ERISieve > siev)
Constructor.
Definition: PK_workers.cc:111
void write_wK(std::vector< size_t > min_ind, std::vector< size_t > max_ind, size_t pk_pairs) override
Writing wK values in the appropriate PK file entry.
Definition: PK_workers.cc:678
void set_nbuf(size_t tmp)
Setter function for nbuf_.
Definition: PK_workers.h:260
int lastbuf_
Is this the last buffer for PK bucket?
Definition: PK_workers.h:185
int maxi_
Definition: PK_workers.h:129
void populate_indices()
Definition: PK_workers.cc:132
size_t npairs_
Definition: PK_workers.h:77
size_t maxints()
Definition: PK_workers.h:209
bool do_wK_
Are we doing wK?
Definition: PK_workers.h:226
double * wK_bufp_
Definition: PK_workers.h:441
void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l) override
Filling wK integrals in relevant buffer.
Definition: PK_workers.cc:596
static char * get_label_wK(const int batch)
Definition: PK_workers.cc:345