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"
41 
42 namespace psi {
43 
44 class AIOHandler;
45 class ERISieve;
46 class BasisSet;
47 class GaussianShell;
48 
49 namespace pk {
50 
51 // Forward declarations just before definitions
52 class AOShellSieveIterator;
54 
55 typedef std::unique_ptr<AOShellSieveIterator> UniqueAOShellIt;
56 typedef std::shared_ptr<ERISieve> SharedSieve;
57 
63  private:
64  // Basis set
65  std::shared_ptr<BasisSet> bs_;
66  // Sieve object
68  // Vector of significant shell pairs
69  const std::vector< std::pair<int, int> >& shell_pairs_;
70  // Number of shell pairs
71  size_t npairs_;
72  // Shell triangular indices
73  size_t PQ_, RS_;
74  // Shell indices
75  int P_, Q_, R_, S_;
76  // Are we there yet?
77  bool done_;
78 
79  // Populate indices from shell_pairs
80  void populate_indices();
81 public:
83  AOShellSieveIterator(std::shared_ptr< BasisSet > prim, SharedSieve sieve_input);
84 
86  void first();
87  void next();
88  bool is_done() { return done_; }
89 
91  int p() const { return P_; }
92  int q() const { return Q_; }
93  int r() const { return R_; }
94  int s() const { return S_; }
95 
98 };
99 
105 private:
106  // Sieve
107  std::shared_ptr<ERISieve> sieve_;
108  // Integral indices
109  int i_, j_, k_, l_;
110  // Relative integral indices within shells
112  // Gaussian shells of interest
117  // Number of functions for each shell
118  int ni_, nj_, nk_, nl_;
119  // First index for each shell
120  int fi_, fj_, fk_, fl_;
121  // Max index for each shell
123  // Are we there yet ?
124  bool done_;
125 
126  // Do we have the same shells in the quartets?
127  bool sh_aaaa_;
128  bool sh_abab_;
129  //Populate the integral indices, and reorder them
130  void populate_indices();
131  // Increment the integral indices to the next ones for ij
132  void increment_bra();
133  // Increment integral indices to the next ones for l,k,j,i (in this order)
134  void increment_ket();
135  // Reorder indices in canonical order
136  void reorder_inds();
137 public:
139  AOFctSieveIterator(const GaussianShell& s1, const GaussianShell& s2,
140  const GaussianShell& s3, const GaussianShell& s4,
141  std::shared_ptr<ERISieve> siev);
142 
144  void first();
145  void next();
146  bool is_done() { return done_; }
147 
148  int i() const { return i_; }
149  int j() const { return j_; }
150  int k() const { return k_; }
151  int l() const { return l_; }
152 };
153 
154 
162 class IWLAsync_PK {
163 private:
165  int itap_;
167  size_t* address_;
173  size_t JobID_[2];
177  size_t nints_;
179  int lastbuf_;
181  int idx_;
183  std::shared_ptr<AIOHandler> AIO_;
184 
185 public:
187  IWLAsync_PK(size_t* address, std::shared_ptr<AIOHandler> AIO, int itap);
189  ~IWLAsync_PK();
190 
192  void fill_values(double val, size_t i, size_t j, size_t k, size_t l);
194  void pop_value(double &val, size_t &i, size_t &j, size_t &k, size_t &l);
196  void write();
199  void flush();
200 
202  size_t nints() { return nints_; }
203  size_t maxints() { return ints_per_buf_; }
204 
205 };
206 
214 class PKWorker {
215 private:
216 
218  std::shared_ptr<BasisSet> primary_;
222  bool do_wK_;
223 
225  std::shared_ptr<AIOHandler> AIO_;
228 
232  unsigned int bufidx_;
234  size_t offset_;
236  size_t max_idx_;
238  size_t buf_size_;
240  unsigned int nbuf_;
243 
245  unsigned int P_, Q_, R_, S_;
246 
248  bool is_shell_relevant();
249 
250  // This class should never be copied
251  PKWorker(const PKWorker &other) {}
253 
254 protected:
256  void set_nbuf(unsigned int tmp) {nbuf_ = tmp; }
258  void set_bufsize(size_t len) { buf_size_ = len; }
260  void set_max_idx(size_t tmp) { max_idx_ = tmp; }
261 
262 public:
264  PKWorker(std::shared_ptr<BasisSet> primary, SharedSieve sieve,
265  std::shared_ptr<AIOHandler> AIO, int target_file,
266  size_t buf_size);
268  virtual ~PKWorker() {}
269 
271  std::shared_ptr< AIOHandler > AIO() const { return AIO_; }
272  size_t nbuf() const { return nbuf_; }
273  size_t buf_size() const { return buf_size_; }
274  size_t max_idx() const { return max_idx_; }
275  size_t offset() const { return offset_; }
276  int target_file() const { return target_file_; }
277  unsigned int bufidx() const { return bufidx_; }
278  unsigned int P() const { return P_; }
279  unsigned int Q() const { return Q_; }
280  unsigned int R() const { return R_; }
281  unsigned int S() const { return S_; }
282  bool do_wK() const { return do_wK_; }
284  void set_do_wK(bool tmp) { do_wK_ = tmp; }
285 
287  static char* get_label_J(const int batch);
288  static char* get_label_K(const int batch);
289  static char* get_label_wK(const int batch);
290 
293  virtual void initialize_task()=0;
294 
296  void first_quartet(size_t i);
298  bool more_work() { return shells_left_; }
300  void next_quartet();
301 
303  virtual void allocate_wK(size_t buf_size, unsigned int buf_per_thread) {
304  throw PSIEXCEPTION("Function allocate_wK not implemented for this PK algorithm.\n");
305  }
307  virtual void allocate_wK(std::shared_ptr<std::vector<size_t>> pos, int wKfile) {
308  throw PSIEXCEPTION("Invoked function allocate_wK not implemented for this PK algorithm.\n");
309  }
310 
312  virtual void fill_values(double val, size_t i, size_t j, size_t k, size_t l) = 0;
314  virtual void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l) = 0;
315 
317  virtual void write(std::vector< size_t > min_ind, std::vector< size_t > max_ind,
318  size_t pk_pairs) = 0;
320  virtual void write_wK(std::vector< size_t > min_ind, std::vector< size_t > max_ind,
321  size_t pk_pairs) {
322  throw PSIEXCEPTION("Function write_wK not implemented for current PK algorithm\n");
323  }
324 
326  virtual void finalize_ints(size_t pk_pairs) {
327  throw PSIEXCEPTION("Function not implemented for this PK algorithm.\n");
328  }
330  virtual void finalize_ints_wK(size_t pk_pairs) {
331  throw PSIEXCEPTION("Function not implemented for this PK algorithm.\n");
332  }
333 
335  virtual bool pop_value(unsigned int bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l) {
336  throw PSIEXCEPTION("Function pop_value not implemented for this class\n");
337  }
339  virtual bool pop_value_wK(unsigned int bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l) {
340  throw PSIEXCEPTION("Function pop_value_wK not implemented for this class\n");
341  }
342 
343  virtual void insert_value(unsigned int bufid, double val, size_t i, size_t j, size_t k, size_t l) {
344  throw PSIEXCEPTION("Function insert_value not implemented for this class\n");
345  }
346  virtual void insert_value_wK(unsigned int bufid, double val, size_t i, size_t j, size_t k, size_t l) {
347  throw PSIEXCEPTION("Function insert_value_wK not implemented for this class\n");
348  }
349 
351  virtual void flush() {
352  throw PSIEXCEPTION("Function flush not implemented for this class\n");
353  }
354  virtual void flush_wK() {
355  throw PSIEXCEPTION("Function flush not implemented for this class\n");
356  }
357 };
358 
372 class PKWrkrReord : public PKWorker {
373 private:
377 
379  std::vector< std::vector<char*> > labels_J_;
380  std::vector< std::vector<char*> > labels_K_;
381  std::vector< std::vector<char*> > labels_wK_;
383  std::vector< std::vector<size_t> > jobID_J_;
384  std::vector< std::vector<size_t> > jobID_K_;
385  std::vector< std::vector<size_t> > jobID_wK_;
387  std::vector< double* > J_bufs_;
388  std::vector< double* > K_bufs_;
389  std::vector< double* > wK_bufs_;
390 
393 
395  unsigned int buf_;
396 
397  virtual void initialize_task();
398 
399 public:
401  PKWrkrReord(std::shared_ptr<BasisSet> primary, SharedSieve sieve,
402  std::shared_ptr<AIOHandler> AIO, int target_file,
403  size_t buffer_size, unsigned int nbuffer);
405  ~PKWrkrReord();
406 
409  virtual void allocate_wK(size_t buf_size, unsigned int buf_per_thread);
410 
412  virtual void fill_values(double val, size_t i, size_t j, size_t k, size_t l);
414  virtual void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l);
415 
417  virtual void write(std::vector<size_t> min_ind,
418  std::vector<size_t> max_ind, size_t pk_pairs);
420  virtual void write_wK(std::vector<size_t> min_ind,
421  std::vector<size_t> max_ind, size_t pk_pairs);
422 };
423 
432 class PKWrkrInCore : public PKWorker {
433 private:
434  // We need to know the number of workers to properly
435  // adjust the size of the last buffer
437  size_t pk_size_;
438  size_t last_buf_;
439  // Memory allocated and deleted outside this worker
440  // Pointers to absolute memory start
441  double* J_buf0_;
442  double* K_buf0_;
443  double* wK_buf0_;
444  // Pointers to local memory start
445  double* J_bufp_;
446  double* K_bufp_;
447  double* wK_bufp_;
448 
449  virtual void initialize_task();
450 
451 public:
452  PKWrkrInCore(std::shared_ptr<BasisSet> primary, SharedSieve sieve,
453  size_t buf_size, size_t lastbuf, double* Jbuf,
454  double* Kbuf, double* wKbuf, int nworkers);
455 
457  virtual void fill_values(double val, size_t i, size_t j, size_t k, size_t l);
459  virtual void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l);
460 
462  virtual void finalize_ints(size_t pk_pairs);
464  virtual void finalize_ints_wK(size_t pk_pairs);
465 
467  virtual void write(std::vector<size_t> min_ind, std::vector<size_t> max_ind, size_t pk_pairs) {
468  throw PSIEXCEPTION("Function not implemented for in-core");
469  }
470 };
471 
478 class PKWrkrIWL : public PKWorker {
479 private:
481  int K_file_;
483  int wK_file_;
485  std::vector< int > buf_for_pq_;
487  std::vector< IWLAsync_PK* > IWL_J_;
488  std::vector< IWLAsync_PK* > IWL_K_;
489  std::vector< IWLAsync_PK* > IWL_wK_;
492  std::shared_ptr<std::vector<size_t>> addresses_;
493  std::shared_ptr<std::vector<size_t>> addresses_wK_;
494 
495 public:
497  PKWrkrIWL(std::shared_ptr<BasisSet> primary, SharedSieve sieve,
498  std::shared_ptr<AIOHandler> AIOp, int targetfile, int K_file,
499  size_t buf_size, std::vector< int > &bufforpq,
500  std::shared_ptr<std::vector<size_t>> pos);
502  ~PKWrkrIWL();
503 
505  virtual void allocate_wK(std::shared_ptr<std::vector<size_t>> pos, int wKfile);
506 
508  virtual void fill_values(double val, size_t i, size_t j, size_t k, size_t l);
510  virtual void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l);
512  virtual bool pop_value(unsigned int bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l);
514  virtual void insert_value(unsigned int bufid, double val, size_t i, size_t j, size_t k, size_t l);
516  virtual bool pop_value_wK(unsigned int bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l);
518  virtual void insert_value_wK(unsigned int bufid, double val, size_t i, size_t j, size_t k, size_t l);
520  virtual void flush();
522  virtual void flush_wK();
523 
525  virtual void initialize_task() {
526  throw PSIEXCEPTION("initialize_task not implemented for this class\n");
527  }
528  virtual void write(std::vector<size_t> min_ind, std::vector<size_t> max_ind,
529  size_t pk_pairs) {
530  throw PSIEXCEPTION("write not implemented for this class\n");
531  }
532 };
533 
534 } // End namespace pk
535 } // End namespace psi
536 
537 #endif
int q() const
Definition: PK_workers.h:92
void set_nbuf(unsigned int tmp)
Setter function for nbuf_.
Definition: PK_workers.h:256
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:120
static char * get_label_J(const int batch)
Get TOC labels for J or K.
Definition: PK_workers.cc:341
virtual void flush()
Flushing all buffers for current worker.
Definition: PK_workers.cc:994
int krel_
Definition: PK_workers.h:111
virtual void allocate_wK(size_t buf_size, unsigned int buf_per_thread)
Reallocate the buffer memory for wK.
Definition: PK_workers.h:303
Definition: PK_workers.h:214
const GaussianShell & usj_
Definition: PK_workers.h:114
std::vector< std::vector< size_t > > jobID_J_
Job IDs.
Definition: PK_workers.h:383
unsigned int R() const
Definition: PK_workers.h:280
int Q_
Definition: PK_workers.h:75
double * wK_buf0_
Definition: PK_workers.h:443
int r() const
Definition: PK_workers.h:93
std::shared_ptr< AIOHandler > AIO() const
Accessor functions.
Definition: PK_workers.h:271
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
virtual void insert_value(unsigned int 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
unsigned int P() const
Definition: PK_workers.h:278
void next()
Definition: PK_workers.cc:304
bool done_
Definition: PK_workers.h:77
unsigned int S_
Definition: PK_workers.h:245
const std::vector< std::pair< int, int > > & shell_pairs_
Definition: PK_workers.h:69
void reorder_inds()
Definition: PK_workers.cc:234
void increment_bra()
Definition: PK_workers.cc:139
virtual bool pop_value_wK(unsigned int 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
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:177
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
std::vector< double * > K_bufs_
Definition: PK_workers.h:388
void set_bufsize(size_t len)
Setting the buffer size, changes for wK.
Definition: PK_workers.h:258
int k_
Definition: PK_workers.h:109
virtual void initialize_task()
Definition: PK_workers.cc:579
unsigned int Q() const
Definition: PK_workers.h:279
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:91
psio_address dummy_
Dummy psio_address for storage of write return value.
Definition: PK_workers.h:392
const GaussianShell & usl_
Definition: PK_workers.h:116
int irel_
Definition: PK_workers.h:111
int j_
Definition: PK_workers.h:109
size_t pk_size_
Definition: PK_workers.h:437
size_t buf_size() const
Definition: PK_workers.h:273
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:88
void set_max_idx(size_t tmp)
Setter function for max_idx.
Definition: PK_workers.h:260
int nk_
Definition: PK_workers.h:118
virtual bool pop_value_wK(unsigned int 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:339
virtual bool pop_value(unsigned int 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
int l() const
Definition: PK_workers.h:151
int fk_
Definition: PK_workers.h:120
std::unique_ptr< AOShellSieveIterator > UniqueAOShellIt
Definition: PK_workers.h:53
int maxl_
Definition: PK_workers.h:122
bool sh_aaaa_
Definition: PK_workers.h:127
~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:330
int itap_
File number.
Definition: PK_workers.h:165
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:230
double * J_buf0_
Definition: PK_workers.h:441
int ni_
Definition: PK_workers.h:118
Definition: pointgrp.h:106
Definition: libpsio/config.h:65
std::shared_ptr< ERISieve > sieve_
Definition: PK_workers.h:107
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:528
virtual void flush_wK()
Definition: PK_workers.h:354
bool done_
Definition: PK_workers.h:124
Definition: PK_workers.h:62
size_t nbuf() const
Definition: PK_workers.h:272
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:150
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:445
size_t JobID_[2]
Job Ids for AIO.
Definition: PK_workers.h:173
size_t offset() const
Definition: PK_workers.h:275
const GaussianShell & usk_
Definition: PK_workers.h:115
bool shells_left_
Are there any shells left ?
Definition: PK_workers.h:242
virtual void allocate_wK(std::shared_ptr< std::vector< size_t >> pos, int wKfile)
For IWL, we need different arguments.
Definition: PK_workers.h:307
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:167
std::vector< double * > J_bufs_
The internal buffers themselves.
Definition: PK_workers.h:387
void flush()
Definition: PK_workers.cc:1075
int j() const
Definition: PK_workers.h:149
std::shared_ptr< std::vector< size_t > > addresses_wK_
Definition: PK_workers.h:493
int nworkers_
Definition: PK_workers.h:436
Label * labels_[2]
Integral labels.
Definition: PK_workers.h:169
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:298
size_t max_idx() const
Definition: PK_workers.h:274
size_t nints()
Accessor functions.
Definition: PK_workers.h:202
std::vector< std::vector< char * > > labels_J_
TOC entry labels.
Definition: PK_workers.h:379
~PKWrkrReord()
Destructor.
Definition: PK_workers.cc:498
SharedSieve sieve_
Definition: PK_workers.h:67
virtual void insert_value_wK(unsigned int bufid, double val, size_t i, size_t j, size_t k, size_t l)
Definition: PK_workers.h:346
unsigned int P_
Indices of the current shell quartet.
Definition: PK_workers.h:245
void first()
Iterator functions.
Definition: PK_workers.cc:265
std::vector< std::vector< char * > > labels_wK_
Definition: PK_workers.h:381
std::shared_ptr< std::vector< size_t > > addresses_
Definition: PK_workers.h:492
int target_file() const
Definition: PK_workers.h:276
bool is_done()
Definition: PK_workers.h:146
int maxk_
Definition: PK_workers.h:122
PKWrkrReord(std::shared_ptr< BasisSet > primary, SharedSieve sieve, std::shared_ptr< AIOHandler > AIO, int target_file, size_t buffer_size, unsigned int nbuffer)
Constructor.
Definition: PK_workers.cc:469
std::shared_ptr< AIOHandler > AIO_
AIOHandler.
Definition: PK_workers.h:225
int R_
Definition: PK_workers.h:75
size_t max_idx_
Current max ijkl index in the buffer.
Definition: PK_workers.h:236
int s() const
Definition: PK_workers.h:94
unsigned int bufidx() const
Definition: PK_workers.h:277
double * K_buf0_
Definition: PK_workers.h:442
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:284
virtual ~PKWorker()
Destructor for PKWorker, does nothing.
Definition: PK_workers.h:268
int P_
Definition: PK_workers.h:75
std::vector< int > buf_for_pq_
Vector mapping pq index to a bucket.
Definition: PK_workers.h:485
virtual void insert_value_wK(unsigned int 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
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.
unsigned int S() const
Definition: PK_workers.h:281
Value * values_[2]
Integral values.
Definition: PK_workers.h:171
int fl_
Definition: PK_workers.h:120
virtual void flush()
Flush a buffer to disk.
Definition: PK_workers.h:351
std::shared_ptr< BasisSet > primary_
Current basis set.
Definition: PK_workers.h:218
size_t ints_per_buf_
Number of integrals per buffer.
Definition: PK_workers.h:175
unsigned int R_
Definition: PK_workers.h:245
bool sh_abab_
Definition: PK_workers.h:128
int nl_
Definition: PK_workers.h:118
const GaussianShell & usi_
Definition: PK_workers.h:113
unsigned int Q_
Definition: PK_workers.h:245
std::shared_ptr< ERISieve > SharedSieve
Definition: PK_workers.h:56
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:478
int nj_
Definition: PK_workers.h:118
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:320
void next_quartet()
Get the next shell quartet for the current worker.
Definition: PK_workers.cc:451
int lrel_
Definition: PK_workers.h:111
int jrel_
Definition: PK_workers.h:111
size_t last_buf_
Definition: PK_workers.h:438
void first()
Iterator functions.
Definition: PK_workers.cc:56
int S_
Definition: PK_workers.h:75
SharedSieve sieve_
Current sieve.
Definition: PK_workers.h:220
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:487
unsigned int buf_
Internal buffer index.
Definition: PK_workers.h:395
std::vector< std::vector< char * > > labels_K_
Definition: PK_workers.h:380
Definition: PK_workers.h:432
int i() const
Definition: PK_workers.h:148
virtual void initialize_task()
Functions that are not used here.
Definition: PK_workers.h:525
unsigned int nbuf_
Number of buffers in the worker.
Definition: PK_workers.h:240
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:467
Gaussian orbital shell.
Definition: gshell.h:222
std::shared_ptr< AIOHandler > AIO_
The AIO Handler.
Definition: PK_workers.h:183
int idx_
Are we using buffer 1 or 2?
Definition: PK_workers.h:181
int i_
Definition: PK_workers.h:109
std::vector< std::vector< size_t > > jobID_wK_
Definition: PK_workers.h:385
double * K_bufp_
Definition: PK_workers.h:446
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.
Definition: PK_workers.h:104
std::shared_ptr< BasisSet > bs_
Definition: PK_workers.h:65
virtual void insert_value(unsigned int bufid, double val, size_t i, size_t j, size_t k, size_t l)
Definition: PK_workers.h:343
virtual void initialize_task()=0
virtual void initialize_task()
Definition: PK_workers.cc:768
std::vector< IWLAsync_PK * > IWL_wK_
Definition: PK_workers.h:489
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:73
size_t buf_size_
Size of one buffer.
Definition: PK_workers.h:238
int K_file_
File for K IWL batches.
Definition: PK_workers.h:481
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:326
int l_
Definition: PK_workers.h:109
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
unsigned int bufidx_
Current global index of the buffer.
Definition: PK_workers.h:232
PKWorker & operator=(PKWorker &other)
Definition: PK_workers.h:252
bool do_wK() const
Definition: PK_workers.h:282
Definition: PK_workers.h:372
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:162
int wK_file_
File for wK IWL batches.
Definition: PK_workers.h:483
size_t offset_
Current offset.
Definition: PK_workers.h:234
~IWLAsync_PK()
Destructor, also deallocates the arrays.
Definition: PK_workers.cc:1029
virtual void allocate_wK(size_t buf_size, unsigned int buf_per_thread)
Definition: PK_workers.cc:537
int fi_
Definition: PK_workers.h:120
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
int maxj_
Definition: PK_workers.h:122
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:389
int target_file_
File to write to.
Definition: PK_workers.h:227
size_t PQ_
Definition: PK_workers.h:73
#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
std::vector< std::vector< size_t > > jobID_K_
Definition: PK_workers.h:384
int lastbuf_
Is this the last buffer for PK bucket?
Definition: PK_workers.h:179
int maxi_
Definition: PK_workers.h:122
void populate_indices()
Definition: PK_workers.cc:132
size_t npairs_
Definition: PK_workers.h:71
size_t maxints()
Definition: PK_workers.h:203
bool do_wK_
Are we doing wK?
Definition: PK_workers.h:222
double * wK_bufp_
Definition: PK_workers.h:447
std::vector< IWLAsync_PK * > IWL_K_
Definition: PK_workers.h:488
static char * get_label_wK(const int batch)
Definition: PK_workers.cc:353
virtual bool pop_value(unsigned int 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:335
PKWorker(const PKWorker &other)
Definition: PK_workers.h:251