announce.cc

00001 /*
00002  *  This file is part of libcxxsupport.
00003  *
00004  *  libcxxsupport is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  libcxxsupport is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with libcxxsupport; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017  */
00018 
00019 /*
00020  *  libcxxsupport is being developed at the Max-Planck-Institut fuer Astrophysik
00021  *  and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
00022  *  (DLR).
00023  */
00024 
00025 /*
00026  *  This file contains the implementation of various convenience functions
00027  *  used by the Planck LevelS package.
00028  *
00029  *  Copyright (C) 2002-2011 Max-Planck-Society
00030  *  Authors: Martin Reinecke, Reinhard Hell
00031  */
00032 
00033 // if we are using g++, check for version 4.0 or higher
00034 #ifdef __GNUC__
00035 #if (__GNUC__<4)
00036 #error your C++ compiler is too old. g++ version 4.0 or higher is required.
00037 #endif
00038 #endif
00039 
00040 #include <iostream>
00041 #include "announce.h"
00042 #include "openmp_support.h"
00043 
00044 using namespace std;
00045 
00046 namespace {
00047 
00048 void openmp_status()
00049   {
00050 #ifndef _OPENMP
00051   cout << "OpenMP: not supported by this binary" << endl;
00052 #else
00053   int threads = openmp_max_threads();
00054   if (threads>1)
00055     cout << "OpenMP active: max. " << threads << " threads." << endl;
00056   else
00057     cout << "OpenMP active, but running with 1 thread only." << endl;
00058 #endif
00059   }
00060 
00061 void vec_status()
00062   {
00063   cout << "Vector math: ";
00064 #if(defined(__AVX__))
00065   cout << "AVX" << endl;
00066 #elif(defined(__SSE2__))
00067   cout << "SSE2" << endl;
00068 #elif(defined(__SSE__))
00069   cout << "SSE" << endl;
00070 #else
00071   cout << "not supported by this binary" << endl;
00072 #endif
00073   }
00074 
00075 } //unnamed namespace
00076 
00077 void announce (const string &name)
00078   {
00079   string version = "v3.10";
00080   string name2 = name+" "+version;
00081   cout << endl << "+-";
00082   for (tsize m=0; m<name2.length(); ++m) cout << "-";
00083   cout << "-+" << endl;
00084   cout << "| " << name2 << " |" << endl;
00085   cout << "+-";
00086   for (tsize m=0; m<name2.length(); ++m) cout << "-";
00087   cout << "-+" << endl << endl;
00088   vec_status();
00089   openmp_status();
00090   cout << endl;
00091   }
00092 
00093 void module_startup (const string &name, bool argc_valid, const string &usage,
00094   bool verbose)
00095   {
00096   if (verbose) announce (name);
00097   if (argc_valid) return;
00098   if (verbose) cerr << usage << endl;
00099   planck_fail_quietly ("Incorrect usage");
00100   }
00101 
00102 void module_startup (const string &name, int argc, const char **,
00103   int argc_expected, const string &argv_expected, bool verbose)
00104   {
00105   module_startup (name,argc==argc_expected,
00106     string("Usage: ")+name+" "+argv_expected, verbose);
00107   }
00108 
00109 void module_startup (const std::string &name, int argc, const char ** /*argv*/,
00110   bool verbose)
00111   {
00112   module_startup (name,argc>=2,
00113     string("Usage:\n  ")+name+" <parameter file / init object>\nor:\n  "
00114                         +name+" par1=val1 par2=val2 ...", verbose);
00115   }

Generated on Wed Apr 24 11:31:16 2013 for LevelS C++ support library