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 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 ** ,
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 }