]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Quest for platform independence: [4] fixup multithread_info.cc
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 7 Oct 2012 20:19:02 +0000 (20:19 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 7 Oct 2012 20:19:02 +0000 (20:19 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_cmake@26985 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/base/multithread_info.cc

index 99457283380e0530ba040a8f61f868cb2d65e166..6c2afe064370f18591889cccca9ff9a8c3b9ec09 100644 (file)
 
 #include <deal.II/base/multithread_info.h>
 
-#if defined(__linux__)
-#  include <fstream>
-#  include <string>
-#endif
-
-#if defined(__sun__) || defined(__osf__) || defined(_AIX)
-#  include <unistd.h>
-#endif
-
-#if defined(__sgi__)
+#ifdef HAVE_UNISTD_H
 #  include <unistd.h>
 #endif
 
@@ -46,48 +37,13 @@ DEAL_II_NAMESPACE_OPEN
  */
 
 
-#  if defined(__linux__)
-
-unsigned int MultithreadInfo::get_n_cpus()
-{
-                                   // on linux, we simply count the
-                                   // number of lines listing
-                                   // individual processors when
-                                   // reading from /proc/cpuinfo
-  std::ifstream cpuinfo;
-  std::string search;
-  unsigned int nCPU = 0;
-
-  cpuinfo.open("/proc/cpuinfo");
-
-  AssertThrow(cpuinfo,ExcProcNotPresent());
-
-  while(cpuinfo)
-    {
-      cpuinfo >> search;
-      if (search.find("processor") != std::string::npos)
-        nCPU++;
-    }
-  cpuinfo.close();
-
-  return nCPU;
-}
-
-#  elif defined(__sun__) || defined(__osf__) || defined(_AIX)
+#  if defined(__linux__) ||  defined(__sun__) || defined(__osf__) || defined(_AIX)
 
 unsigned int MultithreadInfo::get_n_cpus()
 {
   return sysconf(_SC_NPROCESSORS_ONLN);
 }
 
-
-#  elif defined(__sgi__)
-
-unsigned int MultithreadInfo::get_n_cpus()
-{
-  return sysconf(_SC_NPROC_ONLN);
-}
-
 #  elif defined(__MACH__) && defined(__APPLE__)
 // This is only tested on a dual G5 2.5GHz running MacOSX 10.3.6
 // and on an Intel Mac Book Pro.
@@ -106,7 +62,6 @@ unsigned int MultithreadInfo::get_n_cpus()
         return n_cpus;
 }
 
-
 #  else
 
 // If you get n_cpus=1 although you are on a multi-processor machine,

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.