announce.cc
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
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 }
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 ** ,
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 }