MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
setupenv.cpp File Reference
#include <map>
#include <string>
#include <sstream>
#include <cstdlib>
+ Include dependency graph for setupenv.cpp:

Go to the source code of this file.

Namespaces

 moose
 

Functions

const map< string, string > & moose::getArgMap ()
 
unsigned getNumCores ()
 

Function Documentation

unsigned getNumCores ( )

Definition at line 93 of file main.cpp.

Referenced by moose::getArgMap(), and init().

94 {
95  unsigned int numCPU = 0;
96 #ifdef WIN_32
97  SYSTEM_INFO sysinfo;
98  GetSystemInfo( &sysinfo );
99 
100  numCPU = sysinfo.dwNumberOfProcessors;
101 #endif
102 
103 #ifdef LINUX
104  numCPU = sysconf( _SC_NPROCESSORS_ONLN );
105 #endif
106 
107 #ifdef MACOSX
108  int mib[4];
109  size_t len = sizeof(numCPU);
110 
111  /* set the mib for hw.ncpu */
112  mib[0] = CTL_HW;
113  mib[1] = HW_AVAILCPU; // alternatively, try HW_NCPU;
114 
115  /* get the number of CPUs from the system */
116  sysctl(mib, 2, &numCPU, &len, NULL, 0);
117 
118  if( numCPU < 1 )
119  {
120  mib[1] = HW_NCPU;
121  sysctl( mib, 2, &numCPU, &len, NULL, 0 );
122  }
123 #endif
124  if ( numCPU < 1 )
125  {
126  cout << "No CPU information available. Assuming single core." << endl;
127  numCPU = 1;
128  }
129  return numCPU;
130 }

+ Here is the caller graph for this function: