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 
49 namespace psi {
50 
51 class AIOHandler;
52 class ERISieve;
53 class BasisSet;
54 class GaussianShell;
55 
56 namespace pk {
57 
58 // Forward declarations just before definitions
59 class AOShellSieveIterator;
61 
62 typedef std::unique_ptr<AOShellSieveIterator> UniqueAOShellIt;
63 typedef std::shared_ptr<ERISieve> SharedSieve;
64 
70  private:
71  // Basis set
72  std::shared_ptr<BasisSet> bs_;
73  // Sieve object
75  // Vector of significant shell pairs
76  const std::vector< std::pair<int, int> >& shell_pairs_;
77  // Number of shell pairs
78  size_t npairs_;
79  // Shell triangular indices
80  size_t PQ_, RS_;
81  // Shell indices
82  int P_, Q_, R_, S_;
83  // Are we there yet?
84  bool done_;
85 
86  // Populate indices from shell_pairs
87  void populate_indices();
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 public:
146  AOFctSieveIterator(const GaussianShell& s1, const GaussianShell& s2,
147  const GaussianShell& s3, const GaussianShell& s4,
148  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 
161 
169 class IWLAsync_PK {
170 private:
172  int itap_;
174  size_t* address_;
180  size_t JobID_[2];
184  size_t nints_;
186  int lastbuf_;
188  int idx_;
190  std::shared_ptr<AIOHandler> AIO_;
191 
192 public:
194  IWLAsync_PK(size_t* address, std::shared_ptr<AIOHandler> AIO, int itap);
196  ~IWLAsync_PK();
197 
199  void fill_values(double val, size_t i, size_t j, size_t k, size_t l);
201  void pop_value(double &val, size_t &i, size_t &j, size_t &k, size_t &l);
203  void write();
206  void flush();
207 
209  size_t nints() { return nints_; }
210  size_t maxints() { return ints_per_buf_; }
211 
212 };
213 
221 class PKWorker {
222 private:
223 
225  std::shared_ptr<BasisSet> primary_;
229  bool do_wK_;
230 
232  std::shared_ptr<AIOHandler> AIO_;
235 
239  size_t bufidx_;
241  size_t offset_;
243  size_t max_idx_;
245  size_t buf_size_;
247  size_t nbuf_;
250 
252  size_t P_, Q_, R_, S_;
253 
255  bool is_shell_relevant();
256 
257  // This class should never be copied
258  PKWorker(const PKWorker &other) = delete;
259  PKWorker & operator = (PKWorker &other) = delete;
260 
261 protected:
263  void set_nbuf(size_t tmp) {nbuf_ = tmp; }
265  void set_bufsize(size_t len) { buf_size_ = len; }
267  void set_max_idx(size_t tmp) { max_idx_ = tmp; }
268 
269 public:
271  PKWorker(std::shared_ptr<BasisSet> primary, SharedSieve sieve,
272  std::shared_ptr<AIOHandler> AIO, int target_file,
273  size_t buf_size);
275  virtual ~PKWorker() {}
276 
278  std::shared_ptr< AIOHandler > AIO() const { return AIO_; }
279  size_t nbuf() const { return nbuf_; }
280  size_t buf_size() const { return buf_size_; }
281  size_t max_idx() const { return max_idx_; }
282  size_t offset() const { return offset_; }
283  int target_file() const { return target_file_; }
284  size_t bufidx() const { return bufidx_; }
285  size_t P() const { return P_; }
286  size_t Q() const { return Q_; }
287  size_t R() const { return R_; }
288  size_t S() const { return S_; }
289  bool do_wK() const { return do_wK_; }
291  void set_do_wK(bool tmp) { do_wK_ = tmp; }
292 
294  static char* get_label_J(const int batch);
295  static char* get_label_K(const int batch);
296  static char* get_label_wK(const int batch);
297 
300  virtual void initialize_task()=0;
301 
303  void first_quartet(size_t i);
305  bool more_work() { return shells_left_; }
307  void next_quartet();
308 
310  virtual void allocate_wK(size_t buf_size, size_t buf_per_thread) {
311  throw PSIEXCEPTION("Function allocate_wK not implemented for this PK algorithm.\n");
312  }
314  virtual void allocate_wK(std::shared_ptr<std::vector<size_t>> pos, int wKfile) {
315  throw PSIEXCEPTION("Invoked function allocate_wK not implemented for this PK algorithm.\n");
316  }
317 
319  virtual void fill_values(double val, size_t i, size_t j, size_t k, size_t l) = 0;
321  virtual void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l) = 0;
322 
324  virtual void write(std::vector< size_t > min_ind, std::vector< size_t > max_ind,
325  size_t pk_pairs) = 0;
327  virtual void write_wK(std::vector< size_t > min_ind, std::vector< size_t > max_ind,
328  size_t pk_pairs) {
329  throw PSIEXCEPTION("Function write_wK not implemented for current PK algorithm\n");
330  }
331 
333  virtual void finalize_ints(size_t pk_pairs) {
334  throw PSIEXCEPTION("Function not implemented for this PK algorithm.\n");
335  }
337  virtual void finalize_ints_wK(size_t pk_pairs) {
338  throw PSIEXCEPTION("Function not implemented for this PK algorithm.\n");
339  }
340 
342  virtual bool pop_value(size_t bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l) {
343  throw PSIEXCEPTION("Function pop_value not implemented for this class\n");
344  }
346  virtual bool pop_value_wK(size_t bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l) {
347  throw PSIEXCEPTION("Function pop_value_wK not implemented for this class\n");
348  }
349 
350  virtual void insert_value(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l) {
351  throw PSIEXCEPTION("Function insert_value not implemented for this class\n");
352  }
353  virtual void insert_value_wK(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l) {
354  throw PSIEXCEPTION("Function insert_value_wK not implemented for this class\n");
355  }
356 
358  virtual void flush() {
359  throw PSIEXCEPTION("Function flush not implemented for this class\n");
360  }
361  virtual void flush_wK() {
362  throw PSIEXCEPTION("Function flush not implemented for this class\n");
363  }
364 };
365 
379 class PKWrkrReord : public PKWorker {
380 private:
384 
386  std::vector< std::vector<char*> > labels_J_;
387  std::vector< std::vector<char*> > labels_K_;
388  std::vector< std::vector<char*> > labels_wK_;
390  std::vector< std::vector<size_t> > jobID_J_;
391  std::vector< std::vector<size_t> > jobID_K_;
392  std::vector< std::vector<size_t> > jobID_wK_;
394  std::vector< double* > J_bufs_;
395  std::vector< double* > K_bufs_;
396  std::vector< double* > wK_bufs_;
397 
400 
402  size_t buf_;
403 
404  virtual void initialize_task();
405 
406 public:
408  PKWrkrReord(std::shared_ptr<BasisSet> primary, SharedSieve sieve,
409  std::shared_ptr<AIOHandler> AIO, int target_file,
410  size_t buffer_size, size_t nbuffer);
412  ~PKWrkrReord();
413 
416  virtual void allocate_wK(size_t buf_size, size_t buf_per_thread);
417 
419  virtual void fill_values(double val, size_t i, size_t j, size_t k, size_t l);
421  virtual void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l);
422 
424  virtual void write(std::vector<size_t> min_ind,
425  std::vector<size_t> max_ind, size_t pk_pairs);
427  virtual void write_wK(std::vector<size_t> min_ind,
428  std::vector<size_t> max_ind, size_t pk_pairs);
429 };
430 
439 class PKWrkrInCore : public PKWorker {
440 private:
441  // We need to know the number of workers to properly
442  // adjust the size of the last buffer
444  size_t pk_size_;
445  size_t last_buf_;
446  // Memory allocated and deleted outside this worker
447  // Pointers to absolute memory start
448  double* J_buf0_;
449  double* K_buf0_;
450  double* wK_buf0_;
451  // Pointers to local memory start
452  double* J_bufp_;
453  double* K_bufp_;
454  double* wK_bufp_;
455 
456  virtual void initialize_task();
457 
458 public:
459  PKWrkrInCore(std::shared_ptr<BasisSet> primary, SharedSieve sieve,
460  size_t buf_size, size_t lastbuf, double* Jbuf,
461  double* Kbuf, double* wKbuf, int nworkers);
462 
464  virtual void fill_values(double val, size_t i, size_t j, size_t k, size_t l);
466  virtual void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l);
467 
469  virtual void finalize_ints(size_t pk_pairs);
471  virtual void finalize_ints_wK(size_t pk_pairs);
472 
474  virtual void write(std::vector<size_t> min_ind, std::vector<size_t> max_ind, size_t pk_pairs) {
475  throw PSIEXCEPTION("Function not implemented for in-core");
476  }
477 };
478 
485 class PKWrkrIWL : public PKWorker {
486 private:
488  int K_file_;
490  int wK_file_;
492  std::vector< int > buf_for_pq_;
494  std::vector< IWLAsync_PK* > IWL_J_;
495  std::vector< IWLAsync_PK* > IWL_K_;
496  std::vector< IWLAsync_PK* > IWL_wK_;
499  std::shared_ptr<std::vector<size_t>> addresses_;
500  std::shared_ptr<std::vector<size_t>> addresses_wK_;
501 
502 public:
504  PKWrkrIWL(std::shared_ptr<BasisSet> primary, SharedSieve sieve,
505  std::shared_ptr<AIOHandler> AIOp, int targetfile, int K_file,
506  size_t buf_size, std::vector< int > &bufforpq,
507  std::shared_ptr<std::vector<size_t>> pos);
509  ~PKWrkrIWL();
510 
512  virtual void allocate_wK(std::shared_ptr<std::vector<size_t>> pos, int wKfile);
513 
515  virtual void fill_values(double val, size_t i, size_t j, size_t k, size_t l);
517  virtual void fill_values_wK(double val, size_t i, size_t j, size_t k, size_t l);
519  virtual bool pop_value(size_t bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l);
521  virtual void insert_value(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l);
523  virtual bool pop_value_wK(size_t bufid, double &val, size_t &i, size_t &j, size_t &k, size_t &l);
525  virtual void insert_value_wK(size_t bufid, double val, size_t i, size_t j, size_t k, size_t l);
527  virtual void flush();
529  virtual void flush_wK();
530 
532  virtual void initialize_task() {
533  throw PSIEXCEPTION("initialize_task not implemented for this class\n");
534  }
535  virtual void write(std::vector<size_t> min_ind, std::vector<size_t> max_ind,
536  size_t pk_pairs) {
537  throw PSIEXCEPTION("write not implemented for this class\n");
538  }
539 };
540 
541 } // End namespace pk
542 } // End namespace psi
543 
544 #endif
int q() const
Definition: PK_workers.h:99
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:877
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
virtual void allocate_wK(size_t buf_size, size_t buf_per_thread)
Reallocate the buffer memory for wK.
Definition: PK_workers.h:310
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:353
virtual void flush()
Flushing all buffers for current worker.
Definition: PK_workers.cc:977
int krel_
Definition: PK_workers.h:118
Definition: PK_workers.h:221
const GaussianShell & usj_
Definition: PK_workers.h:121
std::vector< std::vector< size_t > > jobID_J_
Job IDs.
Definition: PK_workers.h:390
int Q_
Definition: PK_workers.h:82
double * wK_buf0_
Definition: PK_workers.h:450
int r() const
Definition: PK_workers.h:100
std::shared_ptr< AIOHandler > AIO() const
Accessor functions.
Definition: PK_workers.h:278
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
void next()
Definition: PK_workers.cc:300
bool done_
Definition: PK_workers.h:84
const std::vector< std::pair< int, int > > & shell_pairs_
Definition: PK_workers.h:76
void reorder_inds()
Definition: PK_workers.cc:232
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:995
size_t nints_
Current number of integrals in buffer.
Definition: PK_workers.h:184
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
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:947
std::vector< double * > K_bufs_
Definition: PK_workers.h:395
void set_bufsize(size_t len)
Setting the buffer size, changes for wK.
Definition: PK_workers.h:265
int k_
Definition: PK_workers.h:116
virtual void initialize_task()
Definition: PK_workers.cc:568
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:399
const GaussianShell & usl_
Definition: PK_workers.h:123
int irel_
Definition: PK_workers.h:118
int j_
Definition: PK_workers.h:116
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:956
size_t pk_size_
Definition: PK_workers.h:444
size_t buf_size() const
Definition: PK_workers.h:280
size_t P() const
Definition: PK_workers.h:285
void next()
Definition: PK_workers.cc:80
virtual void finalize_ints(size_t pk_pairs)
Finalize the buffer: divide by two diagonal elements.
Definition: PK_workers.cc:831
bool is_done()
Definition: PK_workers.h:95
void set_max_idx(size_t tmp)
Setter function for max_idx.
Definition: PK_workers.h:267
int nk_
Definition: PK_workers.h:125
int l() const
Definition: PK_workers.h:158
int fk_
Definition: PK_workers.h:127
std::unique_ptr< AOShellSieveIterator > UniqueAOShellIt
Definition: PK_workers.h:60
int maxl_
Definition: PK_workers.h:129
bool sh_aaaa_
Definition: PK_workers.h:134
~PKWrkrIWL()
Destructor.
Definition: PK_workers.cc:867
virtual void finalize_ints_wK(size_t pk_pairs)
For in-core: only finalize the wK integral array.
Definition: PK_workers.h:337
int itap_
File number.
Definition: PK_workers.h:172
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:603
UniqueAOShellIt shelliter_
Iterator over basis functions within a shell quartet.
Definition: PK_workers.h:237
double * J_buf0_
Definition: PK_workers.h:448
int ni_
Definition: PK_workers.h:125
Definition: pointgrp.h:104
size_t buf_
Internal buffer index.
Definition: PK_workers.h:402
Definition: libpsio/config.h:65
size_t nbuf_
Number of buffers in the worker.
Definition: PK_workers.h:247
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:969
PKWorker & operator=(PKWorker &other)=delete
std::shared_ptr< ERISieve > sieve_
Definition: PK_workers.h:114
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:535
virtual void flush_wK()
Definition: PK_workers.h:361
bool done_
Definition: PK_workers.h:131
Definition: PK_workers.h:69
size_t nbuf() const
Definition: PK_workers.h:279
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:452
size_t JobID_[2]
Job Ids for AIO.
Definition: PK_workers.h:180
size_t offset() const
Definition: PK_workers.h:282
const GaussianShell & usk_
Definition: PK_workers.h:122
bool shells_left_
Are there any shells left ?
Definition: PK_workers.h:249
virtual void allocate_wK(std::shared_ptr< std::vector< size_t >> pos, int wKfile)
For IWL, we need different arguments.
Definition: PK_workers.h:314
size_t R() const
Definition: PK_workers.h:287
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:771
size_t * address_
Position in bytes for next write.
Definition: PK_workers.h:174
std::vector< double * > J_bufs_
The internal buffers themselves.
Definition: PK_workers.h:394
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:350
std::shared_ptr< std::vector< size_t > > addresses_wK_
Definition: PK_workers.h:500
int nworkers_
Definition: PK_workers.h:443
size_t S_
Definition: PK_workers.h:252
Label * labels_[2]
Integral labels.
Definition: PK_workers.h:176
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:887
bool more_work()
Is there a shell quartet left to compute ?
Definition: PK_workers.h:305
size_t max_idx() const
Definition: PK_workers.h:281
size_t nints()
Accessor functions.
Definition: PK_workers.h:209
virtual void allocate_wK(size_t buf_size, size_t buf_per_thread)
Definition: PK_workers.cc:526
std::vector< std::vector< char * > > labels_J_
TOC entry labels.
Definition: PK_workers.h:386
~PKWrkrReord()
Destructor.
Definition: PK_workers.cc:488
size_t R_
Definition: PK_workers.h:252
SharedSieve sieve_
Definition: PK_workers.h:74
void first()
Iterator functions.
Definition: PK_workers.cc:261
std::vector< std::vector< char * > > labels_wK_
Definition: PK_workers.h:388
std::shared_ptr< std::vector< size_t > > addresses_
Definition: PK_workers.h:499
int target_file() const
Definition: PK_workers.h:283
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:232
int R_
Definition: PK_workers.h:82
size_t max_idx_
Current max ijkl index in the buffer.
Definition: PK_workers.h:243
int s() const
Definition: PK_workers.h:101
double * K_buf0_
Definition: PK_workers.h:449
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:291
virtual ~PKWorker()
Destructor for PKWorker, does nothing.
Definition: PK_workers.h:275
int P_
Definition: PK_workers.h:82
std::vector< int > buf_for_pq_
Vector mapping pq index to a bucket.
Definition: PK_workers.h:492
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:286
Value * values_[2]
Integral values.
Definition: PK_workers.h:178
int fl_
Definition: PK_workers.h:127
virtual void flush()
Flush a buffer to disk.
Definition: PK_workers.h:358
std::shared_ptr< BasisSet > primary_
Current basis set.
Definition: PK_workers.h:225
size_t ints_per_buf_
Number of integrals per buffer.
Definition: PK_workers.h:182
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:342
int nl_
Definition: PK_workers.h:125
const GaussianShell & usi_
Definition: PK_workers.h:120
std::shared_ptr< ERISieve > SharedSieve
Definition: PK_workers.h:63
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:570
Definition: PK_workers.h:485
int nj_
Definition: PK_workers.h:125
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:327
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:445
void first()
Iterator functions.
Definition: PK_workers.cc:60
int S_
Definition: PK_workers.h:82
SharedSieve sieve_
Current sieve.
Definition: PK_workers.h:227
static char * get_label_K(const int batch)
Definition: PK_workers.cc:339
std::vector< IWLAsync_PK * > IWL_J_
Vectors of IWL buffers for storage in the proper pre-sorting bucket.
Definition: PK_workers.h:494
size_t Q_
Definition: PK_workers.h:252
std::vector< std::vector< char * > > labels_K_
Definition: PK_workers.h:387
Definition: PK_workers.h:439
int i() const
Definition: PK_workers.h:155
virtual void initialize_task()
Functions that are not used here.
Definition: PK_workers.h:532
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:474
Gaussian orbital shell.
Definition: gshell.h:168
std::shared_ptr< AIOHandler > AIO_
The AIO Handler.
Definition: PK_workers.h:190
int idx_
Are we using buffer 1 or 2?
Definition: PK_workers.h:188
int i_
Definition: PK_workers.h:116
std::vector< std::vector< size_t > > jobID_wK_
Definition: PK_workers.h:392
double * K_bufp_
Definition: PK_workers.h:453
bool is_shell_relevant()
Is the current shell relevant to the current worker ?
Definition: PK_workers.cc:371
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:239
Definition: PK_workers.h:111
std::shared_ptr< BasisSet > bs_
Definition: PK_workers.h:72
virtual void initialize_task()=0
virtual void initialize_task()
Definition: PK_workers.cc:754
std::vector< IWLAsync_PK * > IWL_wK_
Definition: PK_workers.h:496
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:933
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:596
size_t RS_
Definition: PK_workers.h:80
size_t P_
Indices of the current shell quartet.
Definition: PK_workers.h:252
size_t buf_size_
Size of one buffer.
Definition: PK_workers.h:245
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:346
int K_file_
File for K IWL batches.
Definition: PK_workers.h:488
void populate_indices()
Definition: PK_workers.cc:53
virtual void finalize_ints(size_t pk_pairs)
For in-core: only finalize the integral array.
Definition: PK_workers.h:333
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
bool do_wK() const
Definition: PK_workers.h:289
PKWorker(const PKWorker &other)=delete
Definition: PK_workers.h:379
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:841
Definition: PK_workers.h:169
int wK_file_
File for wK IWL batches.
Definition: PK_workers.h:490
size_t S() const
Definition: PK_workers.h:288
size_t offset_
Current offset.
Definition: PK_workers.h:241
~IWLAsync_PK()
Destructor, also deallocates the arrays.
Definition: PK_workers.cc:1011
int fi_
Definition: PK_workers.h:127
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:816
size_t bufidx() const
Definition: PK_workers.h:284
int maxj_
Definition: PK_workers.h:129
void increment_ket()
Definition: PK_workers.cc:168
virtual void flush_wK()
Flushing all wK buffers for current worker.
Definition: PK_workers.cc:987
std::vector< double * > wK_bufs_
Definition: PK_workers.h:396
int target_file_
File to write to.
Definition: PK_workers.h:234
size_t PQ_
Definition: PK_workers.h:80
#define PSIEXCEPTION(message)
Definition: exception.h:50
AOShellSieveIterator(std::shared_ptr< BasisSet > prim, SharedSieve sieve_input)
Constructor.
Definition: PK_workers.cc:43
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:924
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:678
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:263
std::vector< std::vector< size_t > > jobID_K_
Definition: PK_workers.h:391
int lastbuf_
Is this the last buffer for PK bucket?
Definition: PK_workers.h:186
int maxi_
Definition: PK_workers.h:129
void populate_indices()
Definition: PK_workers.cc:132
size_t npairs_
Definition: PK_workers.h:78
size_t maxints()
Definition: PK_workers.h:210
bool do_wK_
Are we doing wK?
Definition: PK_workers.h:229
double * wK_bufp_
Definition: PK_workers.h:454
std::vector< IWLAsync_PK * > IWL_K_
Definition: PK_workers.h:495
static char * get_label_wK(const int batch)
Definition: PK_workers.cc:345