Psi4
PK_workers.h
Go to the documentation of this file.
1 /*
2  *@BEGIN LICENSE
3  *
4  * PSI4: an ab initio quantum chemistry software package
5  *
6  * This file is part of Psi4.
7  *
8  * Psi4 is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation, version 3.
11  *
12  * Psi4 is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License along
18  * with Psi4; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  *@END LICENSE
22  */
23 
24 #ifndef PKWRKR_H
25 #define PKWRKR_H
26 
27 #if !defined( EXPLICIT_IOFF )
28 # define EXPLICIT_IOFF(i) ( (i) * ((i) + 1) / 2 )
29 #endif
30 
31 #if !defined( INDEX2 )
32 # define INDEX2(i, j) ( (i) >= (j) ? EXPLICIT_IOFF(i) + (j) : EXPLICIT_IOFF(j) + (i) )
33 #endif
34 
35 #if !defined( INDEX4 )
36 # define INDEX4(i, j, k, l) ( INDEX2( INDEX2((i), (j)), INDEX2((k), (l)) ) )
37 #endif
38 
39 #include "psi4/libiwl/config.h"
40 #include "psi4/libpsio/config.h"
42 
43 
44 namespace psi {
45 
46 class AIOHandler;
47 class ERISieve;
48 class BasisSet;
49 class GaussianShell;
50 
51 namespace pk {
52 
53 // Forward declarations just before definitions
54 class AOShellSieveIterator;
56 
57 typedef std::unique_ptr<AOShellSieveIterator> UniqueAOShellIt;
58 typedef std::shared_ptr<ERISieve> SharedSieve;
59 
65  private:
66  // Basis set
67  std::shared_ptr<BasisSet> bs_;
68  // Sieve object
70  // Vector of significant shell pairs
71  const std::vector< std::pair<int, int> >& shell_pairs_;
72  // Number of shell pairs
73  size_t npairs_;
74  // Shell triangular indices
75  size_t PQ_, RS_;
76  // Shell indices
77  int P_, Q_, R_, S_;
78  // Are we there yet?
79  bool done_;
80 
81  // Populate indices from shell_pairs
82  void populate_indices();
83 public:
85  AOShellSieveIterator(std::shared_ptr< BasisSet > prim, SharedSieve sieve_input);
86 
88  void first();
89  void next();
90  bool is_done() { return done_; }
91 
93  int p() const { return P_; }
94  int q() const { return Q_; }
95  int r() const { return R_; }
96  int s() const { return S_; }
97 
100 };
101 
107 private:
108  // Sieve
109  std::shared_ptr<ERISieve> sieve_;
110  // Integral indices
111  int i_, j_, k_, l_;
112  // Relative integral indices within shells
114  // Gaussian shells of interest
119  // Number of functions for each shell
120  int ni_, nj_, nk_, nl_;
121  // First index for each shell
122  int fi_, fj_, fk_, fl_;
123  // Max index for each shell
125  // Are we there yet ?
126  bool done_;
127 
128  // Do we have the same shells in the quartets?
129  bool sh_aaaa_;
130  bool sh_abab_;
131  //Populate the integral indices, and reorder them
132  void populate_indices();
133  // Increment the integral indices to the next ones for ij
134  void increment_bra();
135  // Increment integral indices to the next ones for l,k,j,i (in this order)
136  void increment_ket();
137  // Reorder indices in canonical order
138  void reorder_inds();
139 public:
141  AOFctSieveIterator(const GaussianShell& s1, const GaussianShell& s2,
142  const GaussianShell& s3, const GaussianShell& s4,
143  std::shared_ptr<ERISieve> siev);
144 
146  void first();
147  void next();
148  bool is_done() { return done_; }
149 
150  int i() const { return i_; }
151  int j() const { return j_; }
152  int k() const { return k_; }
153  int l() const { return l_; }
154 };
155 
156 
164 class IWLAsync_PK {
165 private:
167  int itap_;
169  size_t* address_;
175  size_t JobID_[2];
179  size_t nints_;
181  int lastbuf_;
183  int idx_;
185  std::shared_ptr<AIOHandler> AIO_;
186 
187 public:
189  IWLAsync_PK(size_t* address, std::shared_ptr<AIOHandler> AIO, int itap);
191  ~IWLAsync_PK();
192 
194  void fill_values(double val, size_t i, size_t j, size_t k, size_t l);
196  void pop_value(double &val, size_t &i, size_t &j, size_t &k, size_t &l);
198  void write();
201  void flush();
202 
204  size_t nints() { return nints_; }
205  size_t maxints() { return ints_per_buf_; }
206 
207 };
208 
216 class PKWorker {
217 private:
218 
220  std::shared_ptr<BasisSet> primary_;
224  bool do_wK_;
225 
227  std::shared_ptr<AIOHandler> AIO_;
230 
234  size_t bufidx_;
236  size_t offset_;
238  size_t max_idx_;
240  size_t buf_size_;
242  size_t nbuf_;
245 
247  size_t P_, Q_, R_, S_;
248 
250  bool is_shell_relevant();
251 
252  // This class should never be copied
253  PKWorker(const PKWorker &other) {}
255 
256 protected:
258  void set_nbuf(size_t tmp) {nbuf_ = tmp; }
260  void set_bufsize(size_t len) { buf_size_ = len; }
262  void set_max_idx(size_t tmp) { max_idx_ = tmp; }
263 
264 public:
266  PKWorker(std::shared_ptr<BasisSet> primary, SharedSieve sieve,
267  std::shared_ptr<AIOHandler> AIO, int target_file,
268  size_t buf_size);
270  virtual ~PKWorker() {}
271 
273  std::shared_ptr< AIOHandler > AIO() const { return AIO_; }
274  size_t nbuf() const { return nbuf_; }
275  size_t buf_size() const { return buf_size_; }
276  size_t max_idx() const { return max_idx_; }
277  size_t offset() const { return offset_; }
278  int target_file() const { return target_file_; }
279  size_t bufidx() const { return bufidx_; }
280  size_t P() const { return P_; }
281  size_t Q() const { return Q_; }
282  size_t R() const { return R_; }
283  size_t S() const { return S_; }
284  bool do_wK() const { return do_wK_; }
286  void set_do_wK(bool tmp) { do_wK_ = tmp; }
287 
289  static char* get_label_J(const int batch);
290  static char* get_label_K(const int batch);
291  static char* get_label_wK(const int batch);
292 
295  virtual void initialize_task()=0;
296 
298  void first_quartet(size_t i);
300  bool more_work() { return shells_left_; }
302  void next_quartet();
303 
305  virtual void allocate_wK(size_t buf_size, size_t buf_per_thread) {
306  throw PSIEXCEPTION("Function allocate_wK not implemented for this PK algorithm.\n");
307  }
309  virtual void allocate_wK(std::shared_ptr<std::vector<size_t>> pos, int wKfile) {
310  throw PSIEXCEPTION("Invoked function allocate_wK not implemented for this PK algorithm.\n");
311  }
312 
314  virtual void fill_values(double val, size_t i, size_t j, size_t k, size_t l) = 0;
316  virtual void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l) = 0;
317 
319  virtual void write(std::vector< size_t > min_ind, std::vector< size_t > max_ind,
320  size_t pk_pairs) = 0;
322  virtual void write_wK(std::vector< size_t > min_ind, std::vector< size_t > max_ind,
323  size_t pk_pairs) {
324  throw PSIEXCEPTION("Function write_wK not implemented for current PK algorithm\n");
325  }
326 
328  virtual void finalize_ints(size_t pk_pairs) {
329  throw PSIEXCEPTION("Function not implemented for this PK algorithm.\n");
330  }
332  virtual void finalize_ints_wK(size_t pk_pairs) {
333  throw PSIEXCEPTION("Function not implemented for this PK algorithm.\n");
334  }
335 
337  virtual bool pop_value(size_t bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l) {
338  throw PSIEXCEPTION("Function pop_value not implemented for this class\n");
339  }
341  virtual bool pop_value_wK(size_t bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l) {
342  throw PSIEXCEPTION("Function pop_value_wK not implemented for this class\n");
343  }
344 
345  virtual void insert_value(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l) {
346  throw PSIEXCEPTION("Function insert_value not implemented for this class\n");
347  }
348  virtual void insert_value_wK(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l) {
349  throw PSIEXCEPTION("Function insert_value_wK not implemented for this class\n");
350  }
351 
353  virtual void flush() {
354  throw PSIEXCEPTION("Function flush not implemented for this class\n");
355  }
356  virtual void flush_wK() {
357  throw PSIEXCEPTION("Function flush not implemented for this class\n");
358  }
359 };
360 
374 class PKWrkrReord : public PKWorker {
375 private:
379 
381  std::vector< std::vector<char*> > labels_J_;
382  std::vector< std::vector<char*> > labels_K_;
383  std::vector< std::vector<char*> > labels_wK_;
385  std::vector< std::vector<size_t> > jobID_J_;
386  std::vector< std::vector<size_t> > jobID_K_;
387  std::vector< std::vector<size_t> > jobID_wK_;
389  std::vector< double* > J_bufs_;
390  std::vector< double* > K_bufs_;
391  std::vector< double* > wK_bufs_;
392 
395 
397  size_t buf_;
398 
399  virtual void initialize_task();
400 
401 public:
403  PKWrkrReord(std::shared_ptr<BasisSet> primary, SharedSieve sieve,
404  std::shared_ptr<AIOHandler> AIO, int target_file,
405  size_t buffer_size, size_t nbuffer);
407  ~PKWrkrReord();
408 
411  virtual void allocate_wK(size_t buf_size, size_t buf_per_thread);
412 
414  virtual void fill_values(double val, size_t i, size_t j, size_t k, size_t l);
416  virtual void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l);
417 
419  virtual void write(std::vector<size_t> min_ind,
420  std::vector<size_t> max_ind, size_t pk_pairs);
422  virtual void write_wK(std::vector<size_t> min_ind,
423  std::vector<size_t> max_ind, size_t pk_pairs);
424 };
425 
434 class PKWrkrInCore : public PKWorker {
435 private:
436  // We need to know the number of workers to properly
437  // adjust the size of the last buffer
439  size_t pk_size_;
440  size_t last_buf_;
441  // Memory allocated and deleted outside this worker
442  // Pointers to absolute memory start
443  double* J_buf0_;
444  double* K_buf0_;
445  double* wK_buf0_;
446  // Pointers to local memory start
447  double* J_bufp_;
448  double* K_bufp_;
449  double* wK_bufp_;
450 
451  virtual void initialize_task();
452 
453 public:
454  PKWrkrInCore(std::shared_ptr<BasisSet> primary, SharedSieve sieve,
455  size_t buf_size, size_t lastbuf, double* Jbuf,
456  double* Kbuf, double* wKbuf, int nworkers);
457 
459  virtual void fill_values(double val, size_t i, size_t j, size_t k, size_t l);
461  virtual void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l);
462 
464  virtual void finalize_ints(size_t pk_pairs);
466  virtual void finalize_ints_wK(size_t pk_pairs);
467 
469  virtual void write(std::vector<size_t> min_ind, std::vector<size_t> max_ind, size_t pk_pairs) {
470  throw PSIEXCEPTION("Function not implemented for in-core");
471  }
472 };
473 
480 class PKWrkrIWL : public PKWorker {
481 private:
483  int K_file_;
485  int wK_file_;
487  std::vector< int > buf_for_pq_;
489  std::vector< IWLAsync_PK* > IWL_J_;
490  std::vector< IWLAsync_PK* > IWL_K_;
491  std::vector< IWLAsync_PK* > IWL_wK_;
494  std::shared_ptr<std::vector<size_t>> addresses_;
495  std::shared_ptr<std::vector<size_t>> addresses_wK_;
496 
497 public:
499  PKWrkrIWL(std::shared_ptr<BasisSet> primary, SharedSieve sieve,
500  std::shared_ptr<AIOHandler> AIOp, int targetfile, int K_file,
501  size_t buf_size, std::vector< int > &bufforpq,
502  std::shared_ptr<std::vector<size_t>> pos);
504  ~PKWrkrIWL();
505 
507  virtual void allocate_wK(std::shared_ptr<std::vector<size_t>> pos, int wKfile);
508 
510  virtual void fill_values(double val, size_t i, size_t j, size_t k, size_t l);
512  virtual void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l);
514  virtual bool pop_value(size_t bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l);
516  virtual void insert_value(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l);
518  virtual bool pop_value_wK(size_t bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l);
520  virtual void insert_value_wK(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l);
522  virtual void flush();
524  virtual void flush_wK();
525 
527  virtual void initialize_task() {
528  throw PSIEXCEPTION("initialize_task not implemented for this class\n");
529  }
530  virtual void write(std::vector<size_t> min_ind, std::vector<size_t> max_ind,
531  size_t pk_pairs) {
532  throw PSIEXCEPTION("write not implemented for this class\n");
533  }
534 };
535 
536 } // End namespace pk
537 } // End namespace psi
538 
539 #endif
int q() const
Definition: PK_workers.h:94
virtual void allocate_wK(std::shared_ptr< std::vector< size_t >> pos, int wKfile)
Preparing for wK pre-sorting to file.
Definition: PK_workers.cc:894
int fj_
Definition: PK_workers.h:122
static char * get_label_J(const int batch)
Get TOC labels for J or K.
Definition: PK_workers.cc:341
virtual void allocate_wK(size_t buf_size, size_t buf_per_thread)
Reallocate the buffer memory for wK.
Definition: PK_workers.h:305
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:348
virtual void flush()
Flushing all buffers for current worker.
Definition: PK_workers.cc:994
int krel_
Definition: PK_workers.h:113
Definition: PK_workers.h:216
const GaussianShell & usj_
Definition: PK_workers.h:116
std::vector< std::vector< size_t > > jobID_J_
Job IDs.
Definition: PK_workers.h:385
int Q_
Definition: PK_workers.h:77
double * wK_buf0_
Definition: PK_workers.h:445
int r() const
Definition: PK_workers.h:95
std::shared_ptr< AIOHandler > AIO() const
Accessor functions.
Definition: PK_workers.h:273
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:867
void next()
Definition: PK_workers.cc:304
bool done_
Definition: PK_workers.h:79
const std::vector< std::pair< int, int > > & shell_pairs_
Definition: PK_workers.h:71
void reorder_inds()
Definition: PK_workers.cc:234
void increment_bra()
Definition: PK_workers.cc:139
short int Label
Definition: libiwl/config.h:34
IWLAsync_PK(size_t *address, std::shared_ptr< AIOHandler > AIO, int itap)
Constructor, also allocates the arrays.
Definition: PK_workers.cc:1012
size_t nints_
Current number of integrals in buffer.
Definition: PK_workers.h:179
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:1036
virtual bool pop_value_wK(size_t bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l)
Popping a wK value from a buffer to finalize writing.
Definition: PK_workers.cc:964
std::vector< double * > K_bufs_
Definition: PK_workers.h:390
void set_bufsize(size_t len)
Setting the buffer size, changes for wK.
Definition: PK_workers.h:260
int k_
Definition: PK_workers.h:111
virtual void initialize_task()
Definition: PK_workers.cc:579
void write()
Actually writing integrals from the buffer to the disk.
Definition: PK_workers.cc:1046
int p() const
Accessor functions.
Definition: PK_workers.h:93
psio_address dummy_
Dummy psio_address for storage of write return value.
Definition: PK_workers.h:394
const GaussianShell & usl_
Definition: PK_workers.h:118
int irel_
Definition: PK_workers.h:113
int j_
Definition: PK_workers.h:111
virtual void insert_value(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l)
Inserting a value back into a buffer.
Definition: PK_workers.cc:973
size_t pk_size_
Definition: PK_workers.h:439
size_t buf_size() const
Definition: PK_workers.h:275
size_t P() const
Definition: PK_workers.h:280
void next()
Definition: PK_workers.cc:78
virtual void finalize_ints(size_t pk_pairs)
Finalize the buffer: divide by two diagonal elements.
Definition: PK_workers.cc:845
bool is_done()
Definition: PK_workers.h:90
void set_max_idx(size_t tmp)
Setter function for max_idx.
Definition: PK_workers.h:262
int nk_
Definition: PK_workers.h:120
int l() const
Definition: PK_workers.h:153
int fk_
Definition: PK_workers.h:122
std::unique_ptr< AOShellSieveIterator > UniqueAOShellIt
Definition: PK_workers.h:55
int maxl_
Definition: PK_workers.h:124
bool sh_aaaa_
Definition: PK_workers.h:129
~PKWrkrIWL()
Destructor.
Definition: PK_workers.cc:884
virtual void finalize_ints_wK(size_t pk_pairs)
For in-core: only finalize the wK integral array.
Definition: PK_workers.h:332
int itap_
File number.
Definition: PK_workers.h:167
virtual void write(std::vector< size_t > min_ind, std::vector< size_t > max_ind, size_t pk_pairs)
Writing values in the appropriate PK file entry.
Definition: PK_workers.cc:617
UniqueAOShellIt shelliter_
Iterator over basis functions within a shell quartet.
Definition: PK_workers.h:232
double * J_buf0_
Definition: PK_workers.h:443
int ni_
Definition: PK_workers.h:120
Definition: pointgrp.h:106
size_t buf_
Internal buffer index.
Definition: PK_workers.h:397
Definition: libpsio/config.h:63
size_t nbuf_
Number of buffers in the worker.
Definition: PK_workers.h:242
virtual void insert_value_wK(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l)
Inserting a wK value back into a buffer.
Definition: PK_workers.cc:986
std::shared_ptr< ERISieve > sieve_
Definition: PK_workers.h:109
virtual void write(std::vector< size_t > min_ind, std::vector< size_t > max_ind, size_t pk_pairs)
Writing integral arrays for storage.
Definition: PK_workers.h:530
virtual void flush_wK()
Definition: PK_workers.h:356
bool done_
Definition: PK_workers.h:126
Definition: PK_workers.h:64
size_t nbuf() const
Definition: PK_workers.h:274
void first_quartet(size_t i)
Set up the first shell quartet to be computed.
Definition: PK_workers.cc:359
int k() const
Definition: PK_workers.h:152
AOFctSieveIterator integrals_iterator()
Sieved iterator over the basis functions of a given shell.
Definition: PK_workers.cc:105
double * J_bufp_
Definition: PK_workers.h:447
size_t JobID_[2]
Job Ids for AIO.
Definition: PK_workers.h:175
size_t offset() const
Definition: PK_workers.h:277
const GaussianShell & usk_
Definition: PK_workers.h:117
bool shells_left_
Are there any shells left ?
Definition: PK_workers.h:244
virtual void allocate_wK(std::shared_ptr< std::vector< size_t >> pos, int wKfile)
For IWL, we need different arguments.
Definition: PK_workers.h:309
size_t R() const
Definition: PK_workers.h:282
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.
virtual void fill_values(double val, size_t i, size_t j, size_t k, size_t l)
Filling values in the relevant part of the buffer.
Definition: PK_workers.cc:785
size_t * address_
Position in bytes for next write.
Definition: PK_workers.h:169
std::vector< double * > J_bufs_
The internal buffers themselves.
Definition: PK_workers.h:389
void flush()
Definition: PK_workers.cc:1075
int j() const
Definition: PK_workers.h:151
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:345
std::shared_ptr< std::vector< size_t > > addresses_wK_
Definition: PK_workers.h:495
int nworkers_
Definition: PK_workers.h:438
size_t S_
Definition: PK_workers.h:247
Label * labels_[2]
Integral labels.
Definition: PK_workers.h:171
virtual void fill_values(double val, size_t i, size_t j, size_t k, size_t l)
Filling integrals in the appropriate buffers.
Definition: PK_workers.cc:904
bool more_work()
Is there a shell quartet left to compute ?
Definition: PK_workers.h:300
size_t max_idx() const
Definition: PK_workers.h:276
size_t nints()
Accessor functions.
Definition: PK_workers.h:204
virtual void allocate_wK(size_t buf_size, size_t buf_per_thread)
Definition: PK_workers.cc:537
std::vector< std::vector< char * > > labels_J_
TOC entry labels.
Definition: PK_workers.h:381
~PKWrkrReord()
Destructor.
Definition: PK_workers.cc:498
size_t R_
Definition: PK_workers.h:247
SharedSieve sieve_
Definition: PK_workers.h:69
void first()
Iterator functions.
Definition: PK_workers.cc:265
std::vector< std::vector< char * > > labels_wK_
Definition: PK_workers.h:383
std::shared_ptr< std::vector< size_t > > addresses_
Definition: PK_workers.h:494
int target_file() const
Definition: PK_workers.h:278
bool is_done()
Definition: PK_workers.h:148
int maxk_
Definition: PK_workers.h:124
std::shared_ptr< AIOHandler > AIO_
AIOHandler.
Definition: PK_workers.h:227
int R_
Definition: PK_workers.h:77
size_t max_idx_
Current max ijkl index in the buffer.
Definition: PK_workers.h:238
int s() const
Definition: PK_workers.h:96
double * K_buf0_
Definition: PK_workers.h:444
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:752
void set_do_wK(bool tmp)
Set do_wK.
Definition: PK_workers.h:286
virtual ~PKWorker()
Destructor for PKWorker, does nothing.
Definition: PK_workers.h:270
int P_
Definition: PK_workers.h:77
std::vector< int > buf_for_pq_
Vector mapping pq index to a bucket.
Definition: PK_workers.h:487
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:281
Value * values_[2]
Integral values.
Definition: PK_workers.h:173
int fl_
Definition: PK_workers.h:122
virtual void flush()
Flush a buffer to disk.
Definition: PK_workers.h:353
std::shared_ptr< BasisSet > primary_
Current basis set.
Definition: PK_workers.h:220
size_t ints_per_buf_
Number of integrals per buffer.
Definition: PK_workers.h:177
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:469
bool sh_abab_
Definition: PK_workers.h:130
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:337
int nl_
Definition: PK_workers.h:120
const GaussianShell & usi_
Definition: PK_workers.h:115
std::shared_ptr< ERISieve > SharedSieve
Definition: PK_workers.h:58
virtual void fill_values(double val, size_t i, size_t j, size_t k, size_t l)
Filling integral values in relevant buffer.
Definition: PK_workers.cc:583
Definition: PK_workers.h:480
int nj_
Definition: PK_workers.h:120
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 next_quartet()
Get the next shell quartet for the current worker.
Definition: PK_workers.cc:451
int lrel_
Definition: PK_workers.h:113
int jrel_
Definition: PK_workers.h:113
size_t last_buf_
Definition: PK_workers.h:440
void first()
Iterator functions.
Definition: PK_workers.cc:56
int S_
Definition: PK_workers.h:77
SharedSieve sieve_
Current sieve.
Definition: PK_workers.h:222
static char * get_label_K(const int batch)
Definition: PK_workers.cc:347
std::vector< IWLAsync_PK * > IWL_J_
Vectors of IWL buffers for storage in the proper pre-sorting bucket.
Definition: PK_workers.h:489
size_t Q_
Definition: PK_workers.h:247
std::vector< std::vector< char * > > labels_K_
Definition: PK_workers.h:382
Definition: PK_workers.h:434
int i() const
Definition: PK_workers.h:150
virtual void initialize_task()
Functions that are not used here.
Definition: PK_workers.h:527
virtual void write(std::vector< size_t > min_ind, std::vector< size_t > max_ind, size_t pk_pairs)
Function write is never used.
Definition: PK_workers.h:469
Gaussian orbital shell.
Definition: gshell.h:189
std::shared_ptr< AIOHandler > AIO_
The AIO Handler.
Definition: PK_workers.h:185
int idx_
Are we using buffer 1 or 2?
Definition: PK_workers.h:183
int i_
Definition: PK_workers.h:111
std::vector< std::vector< size_t > > jobID_wK_
Definition: PK_workers.h:387
double * K_bufp_
Definition: PK_workers.h:448
bool is_shell_relevant()
Is the current shell relevant to the current worker ?
Definition: PK_workers.cc:379
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:234
Definition: PK_workers.h:106
std::shared_ptr< BasisSet > bs_
Definition: PK_workers.h:67
virtual void initialize_task()=0
virtual void initialize_task()
Definition: PK_workers.cc:768
std::vector< IWLAsync_PK * > IWL_wK_
Definition: PK_workers.h:491
virtual bool pop_value(size_t bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l)
Popping a value from a buffer to finalize writing.
Definition: PK_workers.cc:950
virtual void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l)
Filling wK integrals in relevant buffer.
Definition: PK_workers.cc:610
size_t RS_
Definition: PK_workers.h:75
size_t P_
Indices of the current shell quartet.
Definition: PK_workers.h:247
size_t buf_size_
Size of one buffer.
Definition: PK_workers.h:240
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:341
int K_file_
File for K IWL batches.
Definition: PK_workers.h:483
void populate_indices()
Definition: PK_workers.cc:49
virtual void finalize_ints(size_t pk_pairs)
For in-core: only finalize the integral array.
Definition: PK_workers.h:328
int l_
Definition: PK_workers.h:111
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:1062
PKWorker & operator=(PKWorker &other)
Definition: PK_workers.h:254
bool do_wK() const
Definition: PK_workers.h:284
Definition: PK_workers.h:374
double Value
Definition: libiwl/config.h:35
virtual void finalize_ints_wK(size_t pk_pairs)
Finalize the buffer for wK: divide by two diagonal elements.
Definition: PK_workers.cc:857
Definition: PK_workers.h:164
int wK_file_
File for wK IWL batches.
Definition: PK_workers.h:485
size_t S() const
Definition: PK_workers.h:283
size_t offset_
Current offset.
Definition: PK_workers.h:236
~IWLAsync_PK()
Destructor, also deallocates the arrays.
Definition: PK_workers.cc:1029
int fi_
Definition: PK_workers.h:122
virtual void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l)
Filling values in the relevant part of the buffer for wK.
Definition: PK_workers.cc:830
size_t bufidx() const
Definition: PK_workers.h:279
int maxj_
Definition: PK_workers.h:124
void increment_ket()
Definition: PK_workers.cc:168
virtual void flush_wK()
Flushing all wK buffers for current worker.
Definition: PK_workers.cc:1004
std::vector< double * > wK_bufs_
Definition: PK_workers.h:391
int target_file_
File to write to.
Definition: PK_workers.h:229
size_t PQ_
Definition: PK_workers.h:75
#define PSIEXCEPTION(message)
Definition: exception.h:48
AOShellSieveIterator(std::shared_ptr< BasisSet > prim, SharedSieve sieve_input)
Constructor.
Definition: PK_workers.cc:38
virtual void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l)
Filling wK integrals in the appropriate buffers.
Definition: PK_workers.cc:941
virtual void write_wK(std::vector< size_t > min_ind, std::vector< size_t > max_ind, size_t pk_pairs)
Writing wK values in the appropriate PK file entry.
Definition: PK_workers.cc:691
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 set_nbuf(size_t tmp)
Setter function for nbuf_.
Definition: PK_workers.h:258
std::vector< std::vector< size_t > > jobID_K_
Definition: PK_workers.h:386
int lastbuf_
Is this the last buffer for PK bucket?
Definition: PK_workers.h:181
int maxi_
Definition: PK_workers.h:124
void populate_indices()
Definition: PK_workers.cc:132
size_t npairs_
Definition: PK_workers.h:73
size_t maxints()
Definition: PK_workers.h:205
bool do_wK_
Are we doing wK?
Definition: PK_workers.h:224
double * wK_bufp_
Definition: PK_workers.h:449
std::vector< IWLAsync_PK * > IWL_K_
Definition: PK_workers.h:490
static char * get_label_wK(const int batch)
Definition: PK_workers.cc:353
PKWorker(const PKWorker &other)
Definition: PK_workers.h:253