Sandia Home Sandia Home
Main Page | Publications | Downloads | Configuration | Running the Code | Solver Parameters | FAQ | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

APPSPACK_Counter.cpp

Go to the documentation of this file.
00001 // $Id: APPSPACK_Counter.cpp,v 1.7 2006/06/30 01:42:08 tgkolda Exp $ 
00002 // $Source: /space/CVS-Acro/acro/packages/appspack/appspack/src/APPSPACK_Counter.cpp,v $ 
00003 
00004 //@HEADER
00005 // ************************************************************************
00006 // 
00007 //          APPSPACK: Asynchronous Parallel Pattern Search
00008 //                 Copyright (2003) Sandia Corporation
00009 // 
00010 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00011 // license for use of this work by or on behalf of the U.S. Government.
00012 // 
00013 // This library is free software; you can redistribute it and/or modify
00014 // it under the terms of the GNU Lesser General Public License as
00015 // published by the Free Software Foundation; either version 2.1 of the
00016 // License, or (at your option) any later version.
00017 //  
00018 // This library is distributed in the hope that it will be useful, but
00019 // WITHOUT ANY WARRANTY; without even the implied warranty of
00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021 // Lesser General Public License for more details.
00022 //                                                                                 
00023 // You should have received a copy of the GNU Lesser General Public
00024 // License along with this library; if not, write to the Free Software
00025 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00026 // USA.                                                                           .
00027 // 
00028 // Questions? Contact Tammy Kolda (tgkolda@sandia.gov) 
00029 // 
00030 // ************************************************************************
00031 //@HEADER
00032 
00038 #include "APPSPACK_Counter.hpp"
00039 
00040 APPSPACK::Counter::Counter() :
00041   nCached(0),
00042   nEvaluated(0)
00043 {
00044 }
00045 
00046 APPSPACK::Counter::~Counter()
00047 {
00048 }
00049 
00050 int APPSPACK::Counter::getNumEvaluations() const
00051 {
00052   return nEvaluated;
00053 }
00054 
00055 string APPSPACK::Counter::getCountString() const
00056 {
00057   ostringstream s;
00058   for (MsgCntConstIterator i = msgCnt.begin(); i != msgCnt.end(); i ++)
00059     s << " " << (*i).first << ": " << (*i).second;
00060   return s.str();
00061 }
00062 
00063 void APPSPACK::Counter::incrementCached()
00064 {
00065   nCached++;
00066 }
00067 
00068 void APPSPACK::Counter::incrementEvaluated(int workerId, const string& msg)
00069 {
00070   nEvaluated++;
00071   incrementMsgCnt(msgCnt, msg);
00072   incrementMsgCnt(wkrMsgCnt[workerId], msg);
00073 }
00074 
00075 // PRIVATE
00076 void APPSPACK::Counter::incrementMsgCnt(MsgCnt& mc, const string& msg)
00077 {
00078   MsgCntIterator i = mc.find(msg);
00079   if (i == mc.end())
00080     mc[msg] = 1;
00081   else
00082     (*i).second ++;
00083 }
00084 
00085 void APPSPACK::Counter::print() const
00086 {
00087   cout << "\n";
00088   cout << "Number of Evaluations       : " << nEvaluated << "\n";
00089   cout << "Number of Cached Evaluations: " << nCached << "\n";
00090 
00091   cout << "Evaluation Breakdown by Message Type...\n";
00092   for (MsgCntConstIterator i = msgCnt.begin(); i != msgCnt.end(); i ++)
00093   {
00094     cout << "  " << (*i).first << ": " << (*i).second << "\n";
00095   }
00096 
00097   cout << "Evaluation Breakdown by Processor and Message Type...\n";
00098   for (WkrMsgCntConstIterator j = wkrMsgCnt.begin(); j != wkrMsgCnt.end(); j++)
00099   {
00100     cout << "  Worker #" << (*j).first << "\n";
00101     for (MsgCntConstIterator i = (*j).second.begin(); i != (*j).second.end(); i ++)
00102     {
00103       cout << "    " << (*i).first << ": " << (*i).second << "\n";
00104     }
00105   }
00106 
00107 }
00108 
00109 

 

© Sandia Corporation | Site Contact | Privacy and Security

Generated on Fri Feb 16 10:33:34 2007 for APPSPACK 5.0.1 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2002