]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Take over most of what's in patches r26981:26988 on branch_cmake.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 14 Oct 2012 22:09:32 +0000 (22:09 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 14 Oct 2012 22:09:32 +0000 (22:09 +0000)
git-svn-id: https://svn.dealii.org/trunk@27123 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/base/logstream.h
deal.II/source/base/logstream.cc
deal.II/source/base/multithread_info.cc
deal.II/source/base/thread_management.cc
deal.II/source/base/timer.cc
deal.II/source/base/utilities.cc
deal.II/source/lac/sparse_direct.cc

index f87f5a3aa3b8c4e1531a9d8ab9fd5f6ef4f176ab..e8223227c534f5fa6648c07887d9ee6fc424a1a6 100644 (file)
@@ -24,7 +24,7 @@
 #include <sstream>
 
 #ifdef HAVE_SYS_TIMES_H
-#include <sys/times.h>
+#  include <sys/times.h>
 #else
 struct tms
 {
index 677e0c0f4cf7184824b31ce50e3c8f162dac2931..312c3e03ca36886b7e36f6224e72198a70ab7844 100644 (file)
 #include <deal.II/base/memory_consumption.h>
 #include <deal.II/base/thread_management.h>
 
-// include sys/resource.h for rusage(). Mac OS X needs sys/time.h then
-// as well (strange), so include that, too.
-#ifndef DEAL_II_MSVC
+#ifdef HAVE_SYS_RESOURCE_H
 #  include <sys/resource.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
 #  include <unistd.h>
 #endif
-#include <sys/types.h>
+
 #include <iostream>
 #include <iomanip>
 #include <fstream>
index e60f66f28d91dce2af38c9ea59835b585da25559..66d6eaa3a7a3c456f97e0f9f2f45a4c72d5fb277 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,
index 7549689b4827ca483a588ca15f91083ebfd2dcfc..15891599f6e11dfbc549be9c5e44bba751577c29 100644 (file)
 
 
 #include <deal.II/base/thread_management.h>
-#include <iostream>
-#include <cstdlib>
-
-#ifdef DEAL_II_USE_MT_POSIX
-#  include <list>
-#endif
 
-#ifndef DEAL_II_USE_DIRECT_ERRNO_H
-#  include <errno.h>
-#else
-#  include </usr/include/errno.h>
-#endif
-#ifndef DEAL_II_MSVC
-#  include <sys/errno.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#  include <unistd.h>
-#endif
-
-#ifdef HAVE_SYS_SYSCALL_H
-#  include <sys/syscall.h>
-#endif
+#include <cerrno>
+#include <cstdlib>
+#include <iostream>
+#include <list>
 
 
 DEAL_II_NAMESPACE_OPEN
index 04a4211eaa092f6aefb4e7b0d1327fb7b2882ee5..c7fd69fada7901bdfe2c4b9d0532a64b68080a71 100644 (file)
 // these includes should probably be properly
 // ./configure'd using the AC_HEADER_TIME macro:
 
-#ifndef DEAL_II_MSVC
+#if defined(HAVE_SYS_TIME_H) && defined(HAVE_SYS_RESOURCE_H)
 #  include <sys/time.h>
 #  include <sys/resource.h>
-#else
-#  include <windows.h>
 #endif
 
-// on SunOS 4.x, getrusage is stated in the man pages and exists, but
-// is not declared in resource.h. declare it ourselves
-#ifdef NO_HAVE_GETRUSAGE
-extern "C" {
-  int getrusage(int who, struct rusage* ru);
-}
+#ifdef DEAL_II_MSVC
+#  include <windows.h>
 #endif
 
-DEAL_II_NAMESPACE_OPEN
 
 
+DEAL_II_NAMESPACE_OPEN
 
                                    // in case we use an MPI compiler, need
                                    // to create a communicator just for the
@@ -116,11 +110,7 @@ void Timer::start ()
     MPI_Barrier(mpi_communicator);
 #endif
 
-#ifdef DEAL_II_MSVC
-  start_wall_time = windows::wall_clock();
-  start_time = windows::cpu_clock();
-  start_time_children = start_time;
-#else
+#if defined(HAVE_SYS_TIME_H) && defined(HAVE_SYS_RESOURCE_H)
 
 //TODO: Break this out into a function like the functions in
 //namespace windows above
@@ -135,6 +125,13 @@ void Timer::start ()
   rusage usage_children;
   getrusage (RUSAGE_CHILDREN, &usage_children);
   start_time_children = usage_children.ru_utime.tv_sec + 1.e-6 * usage_children.ru_utime.tv_usec;
+
+#elif defined(DEAL_II_MSVC)
+  start_wall_time = windows::wall_clock();
+  start_time = windows::cpu_clock();
+  start_time_children = start_time;
+#else
+#  error unsupported platform. Porting not finished.
 #endif
 }
 
@@ -146,10 +143,7 @@ double Timer::stop ()
     {
       running = false;
 
-#ifdef DEAL_II_MSVC
-      double time = windows::wall_clock() - start_wall_time;
-      cumulative_time += windows::cpu_clock() - start_time;
-#else
+#if defined(HAVE_SYS_TIME_H) && defined(HAVE_SYS_RESOURCE_H)
 //TODO: Break this out into a function like the functions in
 //namespace windows above
       rusage usage;
@@ -167,6 +161,11 @@ double Timer::stop ()
       gettimeofday(&wall_timer, NULL);
       double time = wall_timer.tv_sec + 1.e-6 * wall_timer.tv_usec
                               - start_wall_time;
+#elif defined(DEAL_II_MSVC)
+      double time = windows::wall_clock() - start_wall_time;
+      cumulative_time += windows::cpu_clock() - start_time;
+#else
+#  error Unsupported platform. Porting not finished.
 #endif
 #ifdef DEAL_II_COMPILER_USE_MPI
       if (sync_wall_time && Utilities::System::job_supports_mpi())
@@ -189,10 +188,7 @@ double Timer::operator() () const
 {
   if (running)
     {
-#ifdef DEAL_II_MSVC
-      const double running_time = windows::cpu_clock() - start_time + cumulative_time;
-      return running_time;
-#else
+#if defined(HAVE_SYS_TIME_H) && defined(HAVE_SYS_RESOURCE_H)
       rusage usage;
       getrusage (RUSAGE_SELF, &usage);
       const double dtime =  usage.ru_utime.tv_sec + 1.e-6 * usage.ru_utime.tv_usec;
@@ -215,6 +211,11 @@ double Timer::operator() () const
         return Utilities::MPI::sum (running_time, mpi_communicator);
       else
         return running_time;
+#elif defined(DEAL_II_MSVC)
+      const double running_time = windows::cpu_clock() - start_time + cumulative_time;
+      return running_time;
+#else
+#  error unsupported platform. Porting not finished.
 #endif
     }
   else
@@ -232,16 +233,16 @@ double Timer::wall_time () const
 {
   if (running)
     {
-#ifdef DEAL_II_MSVC
-//TODO[BG]: Do something useful here
-      return 0;
-#else
+#if defined(HAVE_SYS_TIME_H) && defined(HAVE_SYS_RESOURCE_H)
       struct timeval wall_timer;
       gettimeofday(&wall_timer, NULL);
       return (wall_timer.tv_sec
               + 1.e-6 * wall_timer.tv_usec
               - start_wall_time
               + cumulative_wall_time);
+#else
+//TODO[BG]: Do something useful here
+      return 0;
 #endif
     }
   else
index 3c25ba69b22762133e5893188947185d977e2b5e..6996f21d2d981773a780c6d2c14706030520ecc4 100644 (file)
 #include <deal.II/base/utilities.h>
 #include <deal.II/base/exceptions.h>
 
-#include <fstream>
-#include <iomanip>
+#include <boost/math/special_functions/erf.hpp>
+
 #include <algorithm>
-#include <cstdlib>
-#include <cstdio>
-#include <cstddef>
-#include <ctime>
 #include <cerrno>
 #include <cmath>
+#include <cstddef>
+#include <cstdio>
+#include <cstdlib>
+#include <ctime>
+#include <fstream>
+#include <iomanip>
+#include <iostream>
+#include <limits>
+#include <sstream>
 
-#ifdef HAVE_UNISTD_H
-#  include <unistd.h>
-#endif
 #ifdef DEAL_II_MSVC
 #  include <winsock2.h>
 #endif
 
-#include <boost/math/special_functions/erf.hpp>
-
-#include <sys/types.h>
-#include <sstream>
-#include <iostream>
-#include <limits>
 
 #ifdef DEAL_II_USE_TRILINOS
 #  ifdef DEAL_II_COMPILER_SUPPORTS_MPI
index 98ec51a1946d1fba46b4d0870fefbc92f97164ac..47139fc87420bf53bfc1e29d2bd8e4c41803dc5f 100644 (file)
 #include <deal.II/lac/block_sparse_matrix.h>
 #include <deal.II/lac/vector.h>
 
+#include <cerrno>
 #include <iostream>
 #include <list>
 #include <typeinfo>
 
-// this is a weird hack: on newer linux systems, some system headers
-// include /usr/include/linux/compiler.h which explicitly checks which
-// gcc is in use. in that file is also a comment that explains that
-// the check for gcc version also applies to icc since icc identifies
-// itself as gcc via __GNUC__; if the gcc major version is not >=2, it
-// aborts.
-//
-// now, only icc8 and later identify themselves as gcc, so older icc
-// versions fail to compile this file on such systems. to avoid this
-// failure, we allow icc to identify itself as gcc if it doesn't
-// already do so by itself:
-#if defined(__INTEL_COMPILER) && !defined(__GNUC__)
-#  define __GNUC__ 3
-#endif
-
-#ifndef DEAL_II_MSVC
-#  include <sys/wait.h>
-#  include <unistd.h>
-#ifndef DEAL_II_USE_DIRECT_ERRNO_H
-#  include <errno.h>
-#else
-#  include </usr/include/errno.h>
-#endif
-#include <sys/errno.h>
-#endif
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <signal.h>
-
 
 DEAL_II_NAMESPACE_OPEN
 

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.