10#if defined(MAIA_MS_COMPILER)
31#include <sys/socket.h>
48 NEW_TIMER_GROUP(tg_newenv,
"New environment");
49 NEW_TIMER(t_completenewenv,
"complete new environment", tg_newenv);
50 RECORD_TIMER_START(t_completenewenv);
53 NEW_SUB_TIMER(t_parseCL,
"parse command line", t_completenewenv);
54 RECORD_TIMER_START(t_parseCL);
58 RECORD_TIMER_STOP(t_parseCL);
68 NEW_SUB_TIMER(t_readProp,
"read property file", t_completenewenv);
69 RECORD_TIMER_START(t_readProp);
70 MInt tmpScratchNoCells = 750000;
74 DEBUG(
"Environment:: Context::readPropertyFile", MAIA_DEBUG_IO);
83 RECORD_TIMER_STOP(t_readProp);
96 MInt maxNoOMPThreads = 1;
97 if(getenv(
"OMP_NUM_THREADS")) {
98 maxNoOMPThreads = atoi(getenv(
"OMP_NUM_THREADS"));
100 maxNoOMPThreads = Context::getBasicProperty<MInt>(
"numOMPThreads", AT_, &maxNoOMPThreads);
101 omp_set_num_threads(maxNoOMPThreads);
104 MInt maxNoCells = Context::getBasicProperty<MInt>(
"maxNoCells", AT_);
106 const MInt testNoDomains = Context::getBasicProperty<MInt>(
"noDomains", AT_, 0);
113 cerr0 <<
"noDomain > number of used mpi ranks! Therefore, increasing maxNoCells: " <<
maxNoCells << std::endl;
125 NEW_SUB_TIMER(t_allocScratch,
"allocate scratch", t_completenewenv);
126 RECORD_TIMER_START(t_allocScratch);
128 scratchSize = Context::getBasicProperty<MFloat>(
"scratchSize", AT_, &scratchSize);
133 RECORD_TIMER_STOP(t_allocScratch);
136 DEBUG(
"Environment:: create Application", MAIA_DEBUG_LEVEL1);
138 RECORD_TIMER_STOP(t_completenewenv);
150 Profile runProfile(
"Environment::run");
157 MBool flowSolver =
false;
158 flowSolver = Context::getBasicProperty<MBool>(
"flowSolver", AT_, &flowSolver);
165 MInt nDim = read_nDim();
169 }
else if(nDim == 3) {
172 mTerm(1, AT_,
"Invalid value of nDim!");
182#ifdef MAIA_WRITE_ACCESS_PROPERTIES_FILE
193#if defined(MAIA_MS_COMPILER) || defined(_SX)
194#pragma message("WARNING: Not implemented!")
199 DIR* directory =
nullptr;
200 string inputDirectory;
201 string outputDirectory;
202 int option_index = 0;
203 static option long_options[] = {
204 {
"debug", 1, 0,
'd'}, {
"help", 0, 0,
'h'}, {
"input", 1, 0,
'i'}, {
"output", 1, 0,
'o'},
205 {
"version", 0, 0,
'v'}, {
"compiler", 0, 0,
'c'}, {
"build-type", 0, 0,
'b'}, {0, 0, 0, 0}};
207 c = getopt_long(
m_argc,
m_argv,
"d:hi:o:p:vcb", long_options, &option_index);
214 cout <<
"option " << long_options[option_index].name << endl;
215 if(optarg !=
nullptr) cout <<
"with arg " << optarg << endl;
223 cout <<
"SET DEBUG LEVEL TO: " << atoi(optarg) << endl;
225 m_log <<
"SET DEBUG LEVEL TO: " << atoi(optarg) << endl;
226 DEBUG(
"Environment::parseCommandline: option -d " << atoi(optarg), MAIA_DEBUG_IO);
228 cerr <<
"Error: debug level out of range!" << endl;
229 cerr <<
"Specified debug level is " << atoi(optarg) <<
", but must be in the range of " << endl;
231 cerr <<
"Debug level is unchanged" << endl;
237 cout <<
"usage: " <<
m_argv[0] <<
" [-h] [-b] [-c] [--debug LEVEL] [--input DIRECTORY] "
238 <<
"[--output DIRECTORY] [-v] [PROPERTY_FILE]" << endl
240 <<
"positional arguments:" << endl
241 <<
" PROPERTY_FILE name of property file to use (default: '" <<
m_propertyFileInput <<
"')\n"
243 <<
"optional arguments:\n"
244 <<
" -b, --build-type show build type that was used\n"
245 <<
" -c, --compiler show used compiler\n"
246 <<
" -d, --debug LEVEL use specified debug level\n"
247 <<
" -h, --help this help screen\n"
248 <<
" -i, --input DIRECTORY specified directory is used for all "
250 <<
" -o, --output DIRECTORY specified directory is used for all "
252 <<
" -v, --version show MAIA version\n"
261 directory = opendir(optarg);
262 if(directory !=
nullptr) {
264 inputDirectory.append(optarg);
265 DEBUG(
"Environment::parseCommandline: option -i " << optarg, MAIA_DEBUG_IO);
267 stringstream errorMessage;
268 errorMessage <<
" error opening inputDirectory \"" << optarg <<
"\"!" << endl;
269 mTerm(1, AT_, errorMessage.str());
274 directory = opendir(optarg);
275 if(directory !=
nullptr) {
277 outputDirectory.append(optarg);
278 DEBUG(
"Environment::parseCommandline: option -o " << optarg, MAIA_DEBUG_IO);
280 stringstream errorMessage;
281 errorMessage <<
"Error opening outputDirectory \"" << optarg <<
"\"!";
282 mTerm(1, AT_, errorMessage.str());
288#ifndef MAIA_VERSION_STRING
289#define MAIA_VERSION_STRING unknown
291 cout << XSTRINGIFY(MAIA_VERSION_STRING) << endl;
300#ifndef MAIA_COMPILER_STRING
301#define MAIA_COMPILER_STRING unknown
303 cout << XSTRINGIFY(MAIA_COMPILER_STRING) << endl;
312#ifndef MAIA_BUILD_TYPE_STRING
313#define MAIA_BUILD_TYPE_STRING unknown
315 cout << XSTRINGIFY(MAIA_BUILD_TYPE_STRING) << endl;
326 cerr <<
"Environment::parseCommandline: Error getopt returned "
327 "unkown option code \""
328 << c <<
"\"" << endl;
354 const MInt bufferSize = 1024;
357 array<char, bufferSize> host_{};
358 gethostname(&host_[0], bufferSize - 1);
359 host_[bufferSize - 1] =
'\0';
363 MString user =
"(unknown user)";
364#if defined(MAIA_MS_COMPILER)
365 constexpr MInt INFO_BUFFER_SIZE = 32767;
366 TCHAR infoBuf[INFO_BUFFER_SIZE];
367 DWORD bufCharCount = INFO_BUFFER_SIZE;
368 if(GetUserName(infoBuf, &bufCharCount)) {
373 p = getpwuid(getuid());
380 array<char, bufferSize> dir_{};
381#if defined(MAIA_MS_COMPILER)
382 _getcwd(&dir_[0], bufferSize - 1);
384 if(getcwd(&dir_[0], bufferSize - 1) ==
nullptr) {
388 dir_[bufferSize - 1] =
'\0';
405 array<char, bufferSize> dateString_{};
412 tm* timeInfo = localtime(&rawTime);
415 strftime(&dateString_[0], bufferSize,
"%Y-%m-%d %H:%M:%S", timeInfo);
418 const MString dateString(&dateString_[0]);
421 cout <<
" _____ ______ ________ ___ ________ \n"
422 " ____|\\ _ \\ _ \\ |\\ __ \\ |\\ \\ |\\ __ \\ ___ \n"
423 " ___\\ \\ \\\\\\__\\ \\ \\\\ \\ \\|\\ \\\\ \\ \\\\ \\ \\|\\ \\ ___ \n"
424 " ___\\ \\ \\\\|__| \\ \\\\ \\ __ \\\\ \\ \\\\ \\ __ \\ ___ \n"
425 " ___\\ \\ \\ \\ \\ \\\\ \\ \\ \\ \\\\ \\ \\\\ \\ \\ \\ \\ ___ \n"
426 " ___\\ \\__\\ \\ \\__\\\\ \\__\\ \\__\\\\ \\__\\\\ \\__\\ \\__\\ ___ \n"
427 " ___\\|__| \\|__| \\|__|\\|__| \\|__| \\|__|\\|__| ____ \n"
429 cout <<
"Start time: " << dateString <<
"\n"
432 <<
"Number of OMP threads: " << omp_get_max_threads() <<
"\n"
434 <<
"Host (of rank 0): " << host <<
"\n"
435 <<
"Working directory: " << dir <<
"\n"
436 <<
"User: " << user <<
"\n"
437 <<
"Executable: " << executable <<
"\n"
438 <<
"Command line args: " << args <<
"\n"
Manages the initialisation of the solvers, the methods depending to the solvers and the start of the ...
static void communicateProperties()
Communicates properties to check if default falues match.
static void initializationProcessFinished()
Sets flag to forbide property access.
static void writePropertiesHumanReadable()
Write the properties into a text file.
static void readPropertyFile(FileType, const MString &fileName)
static MBool propertyExists(const MString &name, MInt solver=m_noSolvers)
This function checks if a property exists in general.
void parseCommandline()
Reads out the options that where used by the program call.
static void printStartupInformation()
Print startup summary of MAIA.
Environment(int, char **)
Application * mApplication
MInt run()
Runs the Environment, makes the Application run.
MInt end()
Ends the Environment.
~Environment()
Destructor.
MString m_propertyFileInput
static MInt m_argc
Reads the name of the property-file and creates a new Application.
void close(MBool forceClose=false)
Pass the close call to the respective internal buffer.
static const MInt m_minLevel
static const MInt m_maxLevel
This class collects all function timings and produces a profiling for certain areas of the code.
This class holds the complete scratch space.
static MString printSelf()
Returns a string summing up the scratch state information and all scratch space elements information.
enum { MAIA_DEBUG_ASSERTION=1, MAIA_DEBUG_IO=2, MAIA_DEBUG_ALLOCATION=4, MAIA_DEBUG_TRACE=8, MAIA_DEBUG_TRACE_IN=16, MAIA_DEBUG_TRACE_OUT=32, MAIA_DEBUG_LEVEL1=64, MAIA_DEBUG_LEVEL2=128, MAIA_DEBUG_LEVEL3=256, MAIA_DEBUG_LEVEL4=512, MAIA_DEBUG_LEVEL5=1024, MAIA_DEBUG_USER1=2048, MAIA_DEBUG_USER2=4096, MAIA_DEBUG_USER3=8192, MAIA_DEBUG_USER4=16384, MAIA_DEBUG_USER5=32768 } MDebugLevel
This enum holds the error levels of the DEBUG class.
void mTerm(const MInt errorCode, const MString &location, const MString &message)
MInt globalNoDomains()
Return global number of domains.
MInt globalDomainId()
Return global domain id.
std::basic_string< char > MString
void const MInt const MInt const MInt const MInt maxNoCells