log.h

Go to the documentation of this file.
00001 /* ./common/log.h 
00002 **********************************
00003 Copyright INRIA and CEA 
00004 
00005 author : Guillaume ANCIAUX (anciaux@labri.fr, g.anciaux@laposte.net)
00006 
00007 The LibMultiScale is a C++ parallel framework for the multiscale
00008 coupling methods dedicated to material simulations. This framework
00009 provides an API which makes it possible to program coupled simulations
00010 and integration of already existing codes.
00011 
00012 This Project is done in a collaboration between INRIA Futurs Bordeaux
00013 within ScAlApplix team and CEA/DPTA Ile de France. 
00014 
00015 This software is governed by the CeCILL-C license under French law and
00016 abiding by the rules of distribution of free software.  You can  use, 
00017 modify and/ or redistribute the software under the terms of the CeCILL-C
00018 license as circulated by CEA, CNRS and INRIA at the following URL
00019 "http://www.cecill.info". 
00020 
00021 As a counterpart to the access to the source code and  rights to copy,
00022 modify and redistribute granted by the license, users are provided only
00023 with a limited warranty  and the software's author,  the holder of the
00024 economic rights,  and the successive licensors  have only  limited
00025 liability. 
00026 
00027 In this respect, the user's attention is drawn to the risks associated
00028 with loading,  using,  modifying and/or developing or reproducing the
00029 software by the user in light of its specific status of free software,
00030 that may mean  that it is complicated to manipulate,  and  that  also
00031 therefore means  that it is reserved for developers  and  experienced
00032 professionals having in-depth computer knowledge. Users are therefore
00033 encouraged to load and test the software's suitability as regards their
00034 requirements in conditions enabling the security of their systems and/or 
00035 data to be ensured and,  more generally, to use and operate it in the 
00036 same conditions as regards security. 
00037 
00038 The fact that you are presently reading this means that you have had
00039 knowledge of the CeCILL-C license and that you accept its terms.
00040 ***********************************/
00041 
00042 #ifndef LOG_SYSTEM
00043 #define LOG_SYSTEM
00044 #define LEVEL_MAX 10
00045 
00046 EXTERN int global_level;
00047 EXTERN int global_mod;
00048 EXTERN int global_proc;
00049 EXTERN int global_proc1;
00050 EXTERN int global_proc2;
00051 EXTERN int start_dump;
00052 EXTERN int end_dump;
00053 EXTERN char my_hostname[512];
00054 //definition des differentes partie 
00055 
00056 #define MOD_MD 0x0001
00057 #define MOD_CONTINU 0x0002
00058 #define MOD_COUPLING 0x0004
00059 #define MOD_DUMPER 0x0008
00060 #define MOD_STIMULATION 0x0010
00061 #define MOD_GEOMETRY 0x0020
00062 #define MOD_FILTER 0x0040
00063 #define MOD_PARSER 0x0080
00064 #define MOD_MAIN 0xffff
00065 /* #define MOD_UNITS 0x0100 */
00066 /* #define MOD_LIBMESH 0x0200 */
00067 /* #define MOD_STAMP 0x0400 */
00068 /* #define MOD_LAMMPS 0x0800 */
00069 /* #define MOD_MD1D 0x1000 */
00070 #define MOD_ALL 0xFFFF
00071 
00072 #include <iomanip>
00073 
00074 #define DBG_ERROR 0
00075 #define DBG_WARNING 1
00076 #define DBG_INFO_STARTUP 2
00077 #define DBG_INFO 3
00078 #define DBG_DETAIL 4
00079 #define DBG_ALL 5
00080 
00081 EXTERN std::ofstream global_out;
00082 
00083 #define FORMATREAL(x) setprecision(15) << x
00084 
00085 #define DUMP(x,level) DUMP##level(x)
00086 #define DUMPFILE(f,x) f << "[" << my_proc_id << "]<" <<  __FILE__ << "," << __LINE__ << ">" <<  x << endl;
00087 
00088 #if LEVEL_MAX > 0
00089 #define DUMPDBG_ERROR(x) {if(global_level >= 0) PRINTOUT("ERROR : " << x)}
00090 #else 
00091 #define DUMPDBG_ERROR(x) {}
00092 #endif
00093 
00094 #if LEVEL_MAX > 1
00095 #define DUMPDBG_WARNING(x) {if(global_level >= 1) PRINTOUT("WARNING : " << x)}
00096 #else 
00097 #define DUMPDBG_WARNING(x) {}
00098 #endif
00099 
00100 #if LEVEL_MAX > 2
00101 #define DUMPDBG_INFO_STARTUP(x) {if(global_level >= 2) PRINTOUT("INFO_STARTUP : " << x)}
00102 #else 
00103 #define DUMPDBG_INFO_STARTUP(x) {}
00104 #endif
00105 
00106 #if LEVEL_MAX > 3
00107 #define DUMPDBG_INFO(x) {if(global_level >= 3) PRINTOUT("INFO : " << x)}
00108 #else 
00109 #define DUMPDBG_INFO(x) {}
00110 #endif
00111 
00112 #if LEVEL_MAX > 4
00113 #define DUMPDBG_DETAIL(x) {if(global_level >= 4) PRINTOUT("DETAIL : " << x)}
00114 #else 
00115 #define DUMPDBG_DETAIL(x) {}
00116 #endif
00117 
00118 #if LEVEL_MAX > 5
00119 #define DUMPDBG_ALL(x) {if(global_level >= 5) PRINTOUT(x)}
00120 #else 
00121 #define DUMPDBG_ALL(x) {}
00122 #endif
00123 
00124 
00125 
00126 #if defined(HAVE_MPI) && !defined(AIX)
00127 #define PRINTOUT(x) if((global_mod & LOCAL_MODULE) && (global_proc == -1 || global_proc == my_proc_id || global_proc1 == my_proc_id || global_proc2 == my_proc_id) && \
00128                        (current_step >= start_dump && (end_dump == -1 || current_step <= end_dump))) \
00129        {cerr << "(" << current_step << ")[" << my_proc_id << "," << my_hostname << "]<" <<  __FILE__ << "," << __LINE__ << ">" <<  x << endl << std::flush;}
00130 //#define PRINTOUT(x) if((global_mod & LOCAL_MODULE) && (global_proc == -1 || global_proc == my_proc_id || global_proc1 == my_proc_id || global_proc2 == my_proc_id) && \
00131 //                     (current_step >= start_dump && (end_dump == -1 || current_step <= end_dump))) \
00132 //       {global_out << "(" << current_step << ")[" << my_proc_id << "," << my_hostname << "]<" <<  __FILE__ << "," << __LINE__ << ">" <<  x << endl << std::flush;}
00133 #else
00134 #define PRINTOUT(x) {cerr << "<" <<  __FILE__ << "," << __LINE__ << ">" <<  x << endl;}
00135 #endif // HAVE_MPI
00136 
00137 //#define FATAL(x) {global_out << "[" << my_proc_id << "]<" <<  __FILE__ << "," << __LINE__ << "> FATAL : " <<  x << endl;global_out.close();}
00138 #define FATAL(x) {cerr << "[" << my_proc_id << "]<" <<  __FILE__ << "," << __LINE__ << "> FATAL : " <<  x << endl;global_out.close();exit(-1);}
00139 
00140 //#define TIMER
00141 #if defined(TIMER)
00142 #include <map>
00143 
00144 EXTERN std::map<string,int> mesT;
00145 EXTERN std::map<string,int> mesTmicro;
00146 EXTERN std::map<string,int> nmes;
00147 EXTERN int s;
00148 EXTERN int ms;
00149 
00150 #include <sys/time.h>
00151 #include <fstream>
00152 EXTERN std::map<string,struct timeval> tstart;
00153 EXTERN std::map<string,struct timeval> tstop;
00154 #define STARTTIMER(x) gettimeofday(&(tstart[x]),NULL)
00155 #define STOPTIMER(x) gettimeofday(&(tstop[x]),NULL); \
00156                          s = tstop[x].tv_sec - tstart[x].tv_sec; \
00157                          ms = tstop[x].tv_usec - tstart[x].tv_usec; \
00158                          if (ms < 0) {--s;ms+=1000000;}  \
00159                          if (mesTmicro[x] + ms >= 1000000){++s;ms-= 1000000;} \
00160                          mesT[x]+= s;mesTmicro[x] += ms;nmes[x]++ 
00161                          
00162 /* #define DUMP_TIMES  for (int procs__ = 0 ; procs__ < world_size ; ++ procs__){ \ */
00163 /*   if(procs__ == my_proc_id){ \ */
00164 /*    map<string,int>::iterator courant = mesT.begin(); \ */
00165 /*   map<string,int>::iterator dernier = mesT.end(); \ */
00166 /*   while(courant != dernier){ \ */
00167 /*     s = (*courant).second*1000000; \ */
00168 /*     ms = mesTmicro[(*courant).first]; \ */
00169 /*     s /= nmes[(*courant).first];ms /= nmes[(*courant).first]; \ */
00170 /*     ms+=s%1000000;s/=1000000; \ */
00171 /*     DUMP("TIMER " << (*courant).first << " : " << s << " secondes et " << ms << " microsecondes"); \ */
00172 /*     DUMP("TIMER " << (*courant).first << " : " << (*courant).second << " secondes et " << mesTmicro[(*courant).first] << " microsecondes sur " << nmes[(*courant).first] << " mesures"); \ */
00173 /*     ++courant;}}  MPI_Barrier(MPI_COMM_WORLD);  }  */
00174 #define DUMP_TIMES  char fname[255]; sprintf(fname,"perf-%.5d",my_proc_id); \
00175   std::ofstream out(fname); \
00176   map<string,int>::iterator courant = mesT.begin();     \
00177   map<string,int>::iterator dernier = mesT.end(); \
00178   while(courant != dernier){ \
00179     s = (*courant).second*1000000; \
00180     ms = mesTmicro[(*courant).first]; \
00181     s /= nmes[(*courant).first];ms /= nmes[(*courant).first]; \
00182     ms+=s%1000000;s/=1000000; \
00183     out << (*courant).first << " : " << s << " secondes et " << ms << " microsecondes" << endl; \
00184     out << (*courant).first << " : " << (*courant).second << " secondes et " << mesTmicro[(*courant).first] << " microsecondes sur " << nmes[(*courant).first] << " mesures" << endl; \
00185     ++courant;}
00186 #else
00187 #define DUMP_TIMES
00188 #define STARTTIMER(x)
00189 #define STOPTIMER(x)
00190 #endif // TIMER
00191 
00192 #endif // LOG_SYSTEM

Generated on Fri Sep 7 13:12:33 2007 for LibMultiScale by  doxygen 1.5.2