- Main Page
- Related Pages
- Classes
- Files

# r12ia_node0file.h

    00001 //
    00002 // r12ia_node0file.h
    00003 //
    00004 // Copyright (C) 2002 Edward Valeev
    00005 //
    00006 // Author: Edward Valeev <edward.valeev@chemistry.gatech.edu>
    00007 // Maintainer: EV
    00008 //
    00009 // This file is part of the SC Toolkit.
    00010 //
    00011 // The SC Toolkit is free software; you can redistribute it and/or modify
    00012 // it under the terms of the GNU Library General Public License as published by
    00013 // the Free Software Foundation; either version 2, or (at your option)
    00014 // any later version.
    00015 //
    00016 // The SC Toolkit is distributed in the hope that it will be useful,
    00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00019 // GNU Library General Public License for more details.
    00020 //
    00021 // You should have received a copy of the GNU Library General Public License
    00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
    00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
    00024 //
    00025 // The U.S. Government is granted a limited license as per AL 91-7.
    00026 //
    00027
    00028 #ifndef _chemistry_qc_mbptr12_r12ia_node0file_h
    00029 #define _chemistry_qc_mbptr12_r12ia_node0file_h
    00030
    00031 #ifdef __GNUC__
    00032 #pragma interface
    00033 #endif
    00034
    00035 #include <unistd.h>
    00036 #include <util/ref/ref.h>
    00037 #include <util/group/memory.h>
    00038 #include <chemistry/qc/mbptr12/r12ia.h>
    00039
    00040 namespace sc {
    00041
    00043 // R12IntsAcc_Node0File handles transformed integrals stored in file
    00044 // on node 0 (file is a usual POSIX binary file)
    00045 //
    00046 // Transfering integrals to the file from nodes is done via MemoryGrp
    00047 //   given as an argument to store_memorygrp
    00048 // Remote retrieval is not possible
    00049 //
    00050 // The ordering of integrals in blocks is not specified
    00051 // to avoid having to reorder integrals
    00052 // Each pair block has size of num_te_types*nbasis1*nbasis2
    00053
    00054 class R12IntsAcc_Node0File: public R12IntsAcc {
    00055
    00056     Ref<MemoryGrp> mem_; // The MemoryGrp associated with this accumulator
    00057     char *filename_;
    00058     int datafile_;
    00059
    00060     struct PairBlkInfo {
    00061       double* ints_[max_num_te_types_];      // blocks corresponding to each operator type
    00062       int refcount_[max_num_te_types_];      // number of references
    00063       off_t offset_;      // location in file (in bytes)
    00064     } *pairblk_;
    00065
    00066     // Initialization tasks common to all constructors
    00067     void init(bool restart);
    00068     // Check if the file operation went OK
    00069     void check_filedescr_();
    00070
    00072     int ntasks() const { return mem_->n(); }
    00074     int taskid() const { return mem_->me(); }
    00075
    00076   public:
    00077     R12IntsAcc_Node0File(Ref<MemoryGrp>& mem, const char *filename, int num_te_types, int ni, int nj,
    00078                          int nx, int ny);
    00079     R12IntsAcc_Node0File(StateIn&);
    00080     ~R12IntsAcc_Node0File();
    00081     void save_data_state(StateOut&);
    00082
    00090     void store_memorygrp(Ref<MemoryGrp>& mem, int ni, const size_t blksize = 0);
    00092     void store_pair_block(int i, int j, double *ints);
    00095     void commit();
    00097     void activate();
    00100     void deactivate();
    00102     double* retrieve_pair_block(int i, int j, tbint_type oper_type);
    00104     void release_pair_block(int i, int j, tbint_type oper_type);
    00106     bool is_local(int i, int j) const { return (mem_->me() == 0);};
    00108     bool is_avail(int i, int j) const { return (mem_->me() == 0);};
    00110     bool has_access(int proc) const { return (proc == 0);};
    00112     bool can_restart() const { return true; };
    00113
    00114     // Utility functions
    00115     int ij_index(int i, int j) const { return i*nj_ + j; };
    00116     int ij_proc(int i, int j) const { return 0;};
    00117 };
    00118
    00119 }
    00120
    00121 #endif
    00122
    00123 // Local Variables:
    00124 // mode: c++
    00125 // c-file-style: "CLJ"
    00126 // End: