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 #ifndef VERSION
00080 #define VERSION "?.?"
00081 #endif
00082   string version ="3.30";
00083   string name2 = name+" "+version;
00084   cout << endl << "+-";
00085   for (tsize m=0; m<name2.length(); ++m) cout << "-";
00086   cout << "-+" << endl;
00087   cout << "| " << name2 << " |" << endl;
00088   cout << "+-";
00089   for (tsize m=0; m<name2.length(); ++m) cout << "-";
00090   cout << "-+" << endl << endl;
00091   vec_status();
00092   openmp_status();
00093   cout << endl;
00094   }
00095 
00096 void module_startup (const string &name, bool argc_valid, const string &usage,
00097   bool verbose)
00098   {
00099   if (verbose) announce (name);
00100   if (argc_valid) return;
00101   if (verbose) cerr << usage << endl;
00102   planck_fail_quietly ("Incorrect usage");
00103   }
00104 
00105 void module_startup (const string &name, int argc, const char **,
00106   int argc_expected, const string &argv_expected, bool verbose)
00107   {
00108   module_startup (name,argc==argc_expected,
00109     string("Usage: ")+name+" "+argv_expected, verbose);
00110   }
00111 
00112 void module_startup (const std::string &name, int argc, const char ** /*argv*/,
00113   bool verbose)
00114   {
00115   module_startup (name,argc>=2,
00116     string("Usage:\n  ")+name+" <parameter file / init object>\nor:\n  "
00117                         +name+" par1=val1 par2=val2 ...", verbose);
00118   }

Generated on Thu Oct 8 14:48:51 2015 for LevelS C++ support library