# r12ia_mpiiofile.h

    00001 //
    00002 // r12ia_mpiiofile.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_mpiiofile_h
    00029 #define _chemistry_qc_mbptr12_r12ia_mpiiofile_h
    00030
    00031 #ifdef __GNUC__
    00032 #pragma interface
    00033 #endif
    00034
    00035 #define MPICH_SKIP_MPICXX
    00036 #include <mpi.h>
    00037 #include <util/ref/ref.h>
    00038 #include <util/group/memory.h>
    00039 #include <chemistry/qc/mbptr12/r12ia.h>
    00040
    00041 namespace sc {
    00042
    00044 // R12IntsAcc_MPIIOFile handles transformed integrals stored in a binary
    00045 // file accessed through MPI-IO. This is an abstract base for MPIIO-based
    00046 // accumulators using individual and collective I/O.
    00047 //
    00048 // The ordering of integrals in blocks is not specified
    00049 // to avoid having to reorder integrals
    00050 // Each pair block has size of num_te_types*nbasis1*nbasis2
    00051
    00052 class R12IntsAcc_MPIIOFile: public R12IntsAcc {
    00053
    00054   protected:
    00055     Ref<MemoryGrp> mem_; // The MemoryGrp associated with this accumulator
    00056     int nproc_;
    00057     size_t nints_per_block_;  // number of integrals per block = num_te_types*nbasis__2_
    00058     int icounter_;      // the number of i's for which blocks have been written to
    00059     char *filename_;
    00060     MPI_File datafile_;
    00061
    00062     struct PairBlkInfo {
    00063       double* ints_[max_num_te_types_];      // blocks corresponding to each operator type
    00064       int refcount_[max_num_te_types_];      // number of references
    00065       MPI_Offset offset_;      // location in file (in bytes)
    00066     } *pairblk_;
    00067
    00069     void check_error_code_(int errcod) const;
    00070
    00071   public:
    00072     R12IntsAcc_MPIIOFile(Ref<MemoryGrp>& mem, const char *filename, int num_te_types, int nbasis1, int nbasis2,
    00073                          int nocc, int nfzc, bool restart);
    00074     ~R12IntsAcc_MPIIOFile();
    00075
    00077     void store_pair_block(int i, int j, double *ints);
    00080     void commit();
    00083     void deactivate();
    00085     void release_pair_block(int i, int j, tbint_type oper_type);
    00087     bool is_local(int i, int j) const { return true;};
    00089     bool is_avail(int i, int j) const { return true;};
    00091     bool has_access(int proc) const { return true;};
    00093     bool can_restart() const { return true; };
    00094
    00095     // Utility functions
    00096     int ij_index(int i, int j) const { return i*nocc_act_ + j; };
    00097 };
    00098
    00100 // R12IntsAcc_MPIIOFile_Ind handles transformed integrals stored in a binary
    00101 // file accessed through MPI-IO individual I/O routines.
    00102 //
    00103 // The ordering of integrals in blocks is not specified
    00104 // to avoid having to reorder integrals
    00105 // Each pair block has size of num_te_types*nbasis*nbasis
    00106
    00107 class R12IntsAcc_MPIIOFile_Ind: public R12IntsAcc_MPIIOFile {
    00108
    00109   public:
    00110     R12IntsAcc_MPIIOFile_Ind(Ref<MemoryGrp>& mem, const char *filename, int num_te_types, int nbasis1, int nbasis2,
    00111                              int nocc, int nfzc, bool restart);
    00112     ~R12IntsAcc_MPIIOFile_Ind();
    00113
    00119     void store_memorygrp(Ref<MemoryGrp>& mem, int ni);
    00121     double* retrieve_pair_block(int i, int j, tbint_type oper_type);
    00122 };
    00123
    00124 }
    00125
    00126 #endif
    00127
    00128 // Local Variables:
    00129 // mode: c++
    00130 // c-file-style: "CLJ"
    00131 // End: