distshpair.h

00001 //
00002 // distshpair.h
00003 // based on mbpt/distsh.h
00004 //
00005 // Copyright (C) 1996 Limit Point Systems, Inc.
00006 //
00007 // Author: Ida Nielsen <ida@kemi.aau.dk>
00008 // Updated: Edward Valeev <edward.valeev@chemistry.gatech.edu>
00009 // Maintainer: LPS
00010 //
00011 // This file is part of the SC Toolkit.
00012 //
00013 // The SC Toolkit is free software; you can redistribute it and/or modify
00014 // it under the terms of the GNU Library General Public License as published by
00015 // the Free Software Foundation; either version 2, or (at your option)
00016 // any later version.
00017 //
00018 // The SC Toolkit is distributed in the hope that it will be useful,
00019 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 // GNU Library General Public License for more details.
00022 //
00023 // You should have received a copy of the GNU Library General Public License
00024 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
00025 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
00026 //
00027 // The U.S. Government is granted a limited license as per AL 91-7.
00028 //
00029 
00030 #ifndef _chemistry_qc_basis_distshpair_h
00031 #define _chemistry_qc_basis_distshpair_h
00032 
00033 #ifdef __GNUC__
00034 #pragma interface
00035 #endif
00036 
00037 #include <util/misc/regtime.h>
00038 #include <util/group/message.h>
00039 #include <util/group/thread.h>
00040 #include <chemistry/qc/basis/basis.h>
00041 
00042 using namespace sc;
00043 
00044 namespace sc {
00045 
00047 class DistShellPair {
00048   public:
00052      class SharedData {
00053        public:
00054          volatile long int shellpair_;
00056          SharedData() { init(); }
00060          void init() { shellpair_ = 0; }
00061      };
00062   private:
00063     Ref<MessageGrp> msg_;
00064     int nthread_;
00065     Ref<ThreadLock> lock_;
00066     Ref<GaussianBasisSet> bs1_;
00067     Ref<GaussianBasisSet> bs2_;
00068     bool bs1_eq_bs2_;
00069     bool task_dynamic_;
00070     bool thread_dynamic_;
00071     int debug_;
00072     // How often updates are printed (i.e. every 10% of total work)
00073     double print_percent_;
00074     SharedData *shared_;
00075 
00076     // Number of tasks handled by thread 0 in task 0:
00077     // if dynamic == true : it will distribute all of them
00078     // if dynamic == false : it will handle its share
00079     long int ntask_;
00080     // Print period
00081     long int print_interval_;
00082     // Index of the next task to be served
00083     long int current_shellpair_;
00084 
00085     // for dynamic load balancing
00086     int req_type_;
00087     int ans_type_;
00088     int ncpu_less_0_;
00089     void serve_tasks();
00090 
00091     // for static load balancing
00092     int S_, R_;          // NOTE: S is in bs1, R is in bs2
00093     int ncpu_;
00094     int incS_, incR_;
00095     int mythread_;
00096 
00097     // sorted work for dynamic load balancing
00098     int *cost_;
00099     int *Svec_;
00100     int *Rvec_;
00101     int *Ivec_;
00102 
00103     void init_dynamic_work();
00104   public:
00108     DistShellPair(const Ref<MessageGrp> &, int nthread, int mythread,
00109                   const Ref<ThreadLock>& lock,
00110                   const Ref<GaussianBasisSet>& bs1, const Ref<GaussianBasisSet>& bs2,
00111                   bool dynamic, SharedData *shared = 0);
00112     ~DistShellPair();
00114     void init();
00116     void set_debug(int d) { debug_ = d; }
00118     void set_print_percent(double p);
00126     int get_task(int &P, int &Q);
00127 };
00128 
00129 }
00130 
00131 #endif
00132 
00133 // //////////////////////////////////////////////////////////////////////////
00134 
00135 // Local Variables:
00136 // mode: c++
00137 // c-file-style: "CLJ-CONDENSED"
00138 // End:

Generated at Mon Dec 3 23:23:35 2007 for MPQC 2.3.1 using the documentation package Doxygen 1.5.2.