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 namespace sc {
00043 
00045 class DistShellPair {
00046   public:
00050      class SharedData {
00051        public:
00052          volatile long int shellpair_;
00054          SharedData() { init(); }
00058          void init() { shellpair_ = 0; }
00059      };
00060   private:
00061     Ref<MessageGrp> msg_;
00062     int nthread_;
00063     Ref<ThreadLock> lock_;
00064     Ref<GaussianBasisSet> bs1_;
00065     Ref<GaussianBasisSet> bs2_;
00066     bool bs1_eq_bs2_;
00067     bool task_dynamic_;
00068     bool thread_dynamic_;
00069     int debug_;
00070     // How often updates are printed (i.e. every 10% of total work)
00071     double print_percent_;
00072     SharedData *shared_;
00073 
00074     // Number of tasks handled by thread 0 in task 0:
00075     // if dynamic == true : it will distribute all of them
00076     // if dynamic == false : it will handle its share
00077     long int ntask_;
00078     // Print period
00079     long int print_interval_;
00080     // Index of the next task to be served
00081     long int current_shellpair_;
00082 
00083     // for dynamic load balancing
00084     int req_type_;
00085     int ans_type_;
00086     int ncpu_less_0_;
00087     void serve_tasks();
00088 
00089     // for static load balancing
00090     int S_, R_;          // NOTE: S is in bs1, R is in bs2
00091     int ncpu_;
00092     int incS_, incR_;
00093     int mythread_;
00094 
00095     // sorted work for dynamic load balancing
00096     int *cost_;
00097     int *Svec_;
00098     int *Rvec_;
00099     int *Ivec_;
00100 
00101     void init_dynamic_work();
00102   public:
00106     DistShellPair(const Ref<MessageGrp> &, int nthread, int mythread,
00107                   const Ref<ThreadLock>& lock,
00108                   const Ref<GaussianBasisSet>& bs1, const Ref<GaussianBasisSet>& bs2,
00109                   bool dynamic, SharedData *shared = 0);
00110     ~DistShellPair();
00112     void init();
00114     void set_debug(int d) { debug_ = d; }
00117     void set_print_percent(double p);
00125     int get_task(int &P, int &Q);
00126 };
00127 
00128 }
00129 
00130 #endif
00131 
00132 // //////////////////////////////////////////////////////////////////////////
00133 
00134 // Local Variables:
00135 // mode: c++
00136 // c-file-style: "CLJ-CONDENSED"
00137 // End:

Generated at Wed Sep 5 14:02:29 2007 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.5.2.
These pages are hosted on SourceForge.net