From: maier Date: Tue, 11 Sep 2012 17:02:01 +0000 (+0000) Subject: Rest of change from #if to #ifdef X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbf0b3fdd2aad59e513e88d22f5afe87e2cbf7e5;p=dealii-svn.git Rest of change from #if to #ifdef git-svn-id: https://svn.dealii.org/branches/branch_cmake@26292 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/CMakeLists.txt b/deal.II/CMakeLists.txt index 30230879be..32d210bc8b 100644 --- a/deal.II/CMakeLists.txt +++ b/deal.II/CMakeLists.txt @@ -162,6 +162,8 @@ ENDIF() # Platform checks: # +INCLUDE(check_for_compiler_features) + INCLUDE(check_for_cxx_features) INCLUDE(check_for_compiler_bugs) diff --git a/deal.II/include/deal.II/base/config.h.in b/deal.II/include/deal.II/base/config.h.in index ea46530a2d..7854256881 100644 --- a/deal.II/include/deal.II/base/config.h.in +++ b/deal.II/include/deal.II/base/config.h.in @@ -120,7 +120,7 @@ * volatile. We do this here in a very old-fashioned C-style, but still * convenient way. */ -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT # define DEAL_VOLATILE volatile #else # define DEAL_VOLATILE diff --git a/deal.II/include/deal.II/base/parallel.h b/deal.II/include/deal.II/base/parallel.h index d4f46a59aa..363462bf42 100644 --- a/deal.II/include/deal.II/base/parallel.h +++ b/deal.II/include/deal.II/base/parallel.h @@ -24,7 +24,7 @@ #include -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT # include # include # include @@ -340,7 +340,7 @@ namespace parallel namespace internal { -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT /** * Take a range argument and call the * given function with its begin and end. @@ -546,7 +546,7 @@ namespace parallel namespace internal { -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT /** * A class that conforms to the Body * requirements of the TBB @@ -813,7 +813,7 @@ namespace internal namespace parallel { -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT namespace internal { @@ -851,7 +851,7 @@ namespace parallel const std::size_t end, const std::size_t minimum_parallel_grain_size) const { -#if DEAL_II_USE_MT == 0 +#ifndef DEAL_II_USE_MT // make sure we don't get compiler // warnings about unused arguments (void) minimum_parallel_grain_size; diff --git a/deal.II/include/deal.II/base/thread_local_storage.h b/deal.II/include/deal.II/base/thread_local_storage.h index 210b90c80d..75f5e69a27 100644 --- a/deal.II/include/deal.II/base/thread_local_storage.h +++ b/deal.II/include/deal.II/base/thread_local_storage.h @@ -15,7 +15,7 @@ #include -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT # include #endif @@ -121,7 +121,7 @@ namespace Threads ThreadLocalStorage & operator = (const T &t); private: -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT /** * The data element we store. If we support threads, then this * object will be of a type that provides a separate object @@ -163,7 +163,7 @@ namespace Threads T & ThreadLocalStorage::get () { -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT return data.local(); #else return data; diff --git a/deal.II/include/deal.II/base/thread_management.h b/deal.II/include/deal.II/base/thread_management.h index e16b39078f..c0a0eb4473 100644 --- a/deal.II/include/deal.II/base/thread_management.h +++ b/deal.II/include/deal.II/base/thread_management.h @@ -21,7 +21,7 @@ #include #include -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT # include # include # include @@ -33,8 +33,8 @@ #include -#if DEAL_II_USE_MT -# if defined(DEAL_II_USE_MT_POSIX) +#ifdef DEAL_II_USE_MT +# ifdef DEAL_II_USE_MT_POSIX # include # endif # include @@ -273,7 +273,7 @@ namespace Threads }; -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT /** * Class implementing a @@ -1229,7 +1229,7 @@ namespace Threads namespace internal { -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT /** * A class that represents threads. For @@ -3735,7 +3735,7 @@ namespace Threads namespace internal { -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT template struct TaskDescriptor; diff --git a/deal.II/include/deal.II/base/work_stream.h b/deal.II/include/deal.II/base/work_stream.h index f70eb9afd4..c1af07325c 100644 --- a/deal.II/include/deal.II/base/work_stream.h +++ b/deal.II/include/deal.II/base/work_stream.h @@ -19,7 +19,7 @@ #include #include -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT # include # include #endif @@ -125,7 +125,7 @@ DEAL_II_NAMESPACE_OPEN namespace WorkStream { -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT namespace internal @@ -527,7 +527,7 @@ namespace WorkStream if (!(begin != end)) return; -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT // create the three stages of the // pipeline internal::IteratorRangeToItemStream diff --git a/deal.II/include/deal.II/lac/sparse_vanka.templates.h b/deal.II/include/deal.II/lac/sparse_vanka.templates.h index 38e8c133fc..cde7ca6b9a 100644 --- a/deal.II/include/deal.II/lac/sparse_vanka.templates.h +++ b/deal.II/include/deal.II/lac/sparse_vanka.templates.h @@ -62,66 +62,65 @@ template void SparseVanka::compute_inverses () { - if (!DEAL_II_USE_MT) - compute_inverses (0, matrix->m()); - else - { - const unsigned int n_inverses = std::count (selected.begin(), - selected.end(), - true); - - const unsigned int n_inverses_per_thread = std::max(n_inverses / n_threads, - 1U); - - // set up start and end index - // for each of the - // threads. note that we have - // to work somewhat to get this - // appropriate, since the - // indices for which inverses - // have to be computed may not - // be evenly distributed in the - // vector. as an extreme - // example consider numbering - // of DoFs by component, then - // all indices for which we - // have to do work will be - // consecutive, with other - // consecutive regions where we - // do not have to do something - std::vector > blocking (n_threads); +#ifndef DEAL_II_USE_MT + compute_inverses (0, matrix->m()); +#else + const unsigned int n_inverses = std::count (selected.begin(), + selected.end(), + true); - unsigned int c = 0; - unsigned int thread = 0; - blocking[0].first = 0; + const unsigned int n_inverses_per_thread = std::max(n_inverses / n_threads, + 1U); + + // set up start and end index + // for each of the + // threads. note that we have + // to work somewhat to get this + // appropriate, since the + // indices for which inverses + // have to be computed may not + // be evenly distributed in the + // vector. as an extreme + // example consider numbering + // of DoFs by component, then + // all indices for which we + // have to do work will be + // consecutive, with other + // consecutive regions where we + // do not have to do something + std::vector > blocking (n_threads); - for (unsigned int i=0; (im()) && (thread+1m()) && (thread+1m(); - - typedef void (SparseVanka::*FunPtr)(const unsigned int, - const unsigned int); - const FunPtr fun_ptr = &SparseVanka::compute_inverses; - - // Now spawn the threads - Threads::ThreadGroup<> threads; - for (unsigned int i=0; im(); + + typedef void (SparseVanka::*FunPtr)(const unsigned int, + const unsigned int); + const FunPtr fun_ptr = &SparseVanka::compute_inverses; + + // Now spawn the threads + Threads::ThreadGroup<> threads; + for (unsigned int i=0; i::vmult (Vector &dst, else // otherwise: blocking requested { - if (DEAL_II_USE_MT) - { - // spawn threads. since - // some compilers have - // trouble finding out - // which 'encapsulate' - // function to take of all - // those possible ones if - // we simply drop in the - // address of an overloaded - // template member - // function, make it - // simpler for the compiler - // by giving it the correct - // type right away: - typedef void (SparseVanka::*mem_fun_p) - (Vector &, - const Vector &, - const std::vector * const) const; - const mem_fun_p comp - = &SparseVanka::template apply_preconditioner; - Threads::ThreadGroup<> threads; - for (unsigned int block=0; block*>(this), - dst, src,&dof_masks[block]); - threads.join_all (); - } - else +#ifdef DEAL_II_USE_MT + // spawn threads. since + // some compilers have + // trouble finding out + // which 'encapsulate' + // function to take of all + // those possible ones if + // we simply drop in the + // address of an overloaded + // template member + // function, make it + // simpler for the compiler + // by giving it the correct + // type right away: + typedef void (SparseVanka::*mem_fun_p) + (Vector &, + const Vector &, + const std::vector * const) const; + const mem_fun_p comp + = &SparseVanka::template apply_preconditioner; + Threads::ThreadGroup<> threads; + for (unsigned int block=0; block*>(this), + dst, src,&dof_masks[block]); + threads.join_all (); +#else for (unsigned int block=0; blockapply_preconditioner (dst, src, &dof_masks[block]); +#endif } } diff --git a/deal.II/include/deal.II/lac/swappable_vector.templates.h b/deal.II/include/deal.II/lac/swappable_vector.templates.h index cb56dec44b..c6252665e7 100644 --- a/deal.II/include/deal.II/lac/swappable_vector.templates.h +++ b/deal.II/include/deal.II/lac/swappable_vector.templates.h @@ -145,10 +145,11 @@ void SwappableVector::reload () template void SwappableVector::alert () { +#ifndef DEAL_II_USE_MT // note: this function does nothing // in non-MT mode - if (!DEAL_II_USE_MT) return; +#else // synchronise with possible other // invocations of this function and @@ -170,6 +171,7 @@ void SwappableVector::alert () Threads::new_thread (&SwappableVector::reload_vector, *this, true); // note that reload_vector also // releases the lock +#endif } @@ -184,16 +186,16 @@ void SwappableVector::reload_vector (const bool set_flag) this->block_read (tmp_in); tmp_in.close (); +#ifdef DEAL_II_USE_MT // release the lock that was // acquired by the calling // functions - if (DEAL_II_USE_MT) - { - // set the flag if so required - if (set_flag) - data_is_preloaded = true; - lock.release (); - }; + + // set the flag if so required + if (set_flag) + data_is_preloaded = true; + lock.release (); +#endif } diff --git a/deal.II/include/deal.II/matrix_free/mapping_info.templates.h b/deal.II/include/deal.II/matrix_free/mapping_info.templates.h index 9d1626f45a..227e9f8d1a 100644 --- a/deal.II/include/deal.II/matrix_free/mapping_info.templates.h +++ b/deal.II/include/deal.II/matrix_free/mapping_info.templates.h @@ -947,7 +947,7 @@ namespace MatrixFreeFunctions // global communication, so we can // disable the check here only if no // processor has any such data -#if DEAL_II_COMPILER_SUPPORTS_MPI +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI unsigned int general_size_glob = 0, general_size_loc = jacobians.size(); MPI_Allreduce (&general_size_loc, &general_size_glob, 1, MPI_UNSIGNED, MPI_MAX, size_info.communicator); @@ -966,7 +966,7 @@ namespace MatrixFreeFunctions MemoryConsumption::memory_consumption (jacobians_grad_upper)); } -#if DEAL_II_COMPILER_SUPPORTS_MPI +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI unsigned int quad_size_glob = 0, quad_size_loc = quadrature_points.size(); MPI_Allreduce (&quad_size_loc, &quad_size_glob, 1, MPI_UNSIGNED, MPI_MAX, size_info.communicator); diff --git a/deal.II/include/deal.II/matrix_free/matrix_free.h b/deal.II/include/deal.II/matrix_free/matrix_free.h index b9e75d5117..e60a9cabd8 100644 --- a/deal.II/include/deal.II/matrix_free/matrix_free.h +++ b/deal.II/include/deal.II/matrix_free/matrix_free.h @@ -33,7 +33,7 @@ #include #include -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT #include #include #include @@ -2101,7 +2101,7 @@ namespace internal } -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT // This defines the TBB data structures that // are needed to schedule the @@ -2353,7 +2353,7 @@ namespace internal VectorStruct &dst; }; -#endif // #if DEAL_II_USE_MT +#endif // DEAL_II_USE_MT } // end of namespace internal @@ -2372,7 +2372,7 @@ MatrixFree::cell_loop OutVector &dst, const InVector &src) const { -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT // Use multithreading if so requested and if // there is enough work to do in parallel (the diff --git a/deal.II/include/deal.II/matrix_free/matrix_free.templates.h b/deal.II/include/deal.II/matrix_free/matrix_free.templates.h index 77a4f07592..ad562dcaea 100644 --- a/deal.II/include/deal.II/matrix_free/matrix_free.templates.h +++ b/deal.II/include/deal.II/matrix_free/matrix_free.templates.h @@ -73,7 +73,7 @@ namespace internal void assert_communicator_equality (const dealii::Triangulation&tria, const MPI_Comm &comm_mf) { -#if DEAL_II_COMPILER_SUPPORTS_MPI +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI const parallel::distributed::Triangulation* dist_tria = dynamic_cast*>(&tria); if (dist_tria != 0) @@ -139,7 +139,7 @@ internal_reinit(const Mapping &mapping, // initialize the basic multithreading // information that needs to be passed to the // DoFInfo structure -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT if (additional_data.tasks_parallel_scheme != AdditionalData::none) { task_info.use_multithreading = true; @@ -242,7 +242,7 @@ internal_reinit(const Mapping &mapping, // initialize the basic multithreading // information that needs to be passed to the // DoFInfo structure -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT if (additional_data.tasks_parallel_scheme != AdditionalData::none) { task_info.use_multithreading = true; @@ -984,7 +984,7 @@ namespace internal // try to balance the number of cells before // and after the boundary part on each // processor. probably not worth it! -#if DEAL_II_COMPILER_SUPPORTS_MPI +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI MPI_Allreduce (&n_boundary_cells, &n_max_boundary_cells, 1, MPI_UNSIGNED, MPI_MAX, size_info.communicator); #endif diff --git a/deal.II/include/deal.II/numerics/vector_tools.templates.h b/deal.II/include/deal.II/numerics/vector_tools.templates.h index bea6de958e..d30b1c824f 100644 --- a/deal.II/include/deal.II/numerics/vector_tools.templates.h +++ b/deal.II/include/deal.II/numerics/vector_tools.templates.h @@ -5661,7 +5661,7 @@ namespace VectorTools } } -#if DEAL_II_USE_P4EST +#ifdef DEAL_II_USE_P4EST // if this was a distributed // DoFHandler, we need to do the // reduction over the entire domain diff --git a/deal.II/source/base/boost_threads.cc b/deal.II/source/base/boost_threads.cc index 7c14d74918..05dde5a01d 100644 --- a/deal.II/source/base/boost_threads.cc +++ b/deal.II/source/base/boost_threads.cc @@ -13,7 +13,7 @@ #include -#if DEAL_II_USE_MT && !defined(DEAL_II_CAN_USE_CXX1X) && !defined(DEAL_II_USE_EXTERNAL_BOOST) +#if defined(DEAL_II_USE_MT) && !defined(DEAL_II_CAN_USE_CXX1X) && !defined(DEAL_II_USE_EXTERNAL_BOOST) // if the C++ compiler doesn't completely support the C++1x standard (and // consequently we can't use std::thread, std::mutex, etc), then include all @@ -21,8 +21,8 @@ // build BOOST itself only to get at this small part of it. it also ensures // that we use the correct compiler and flags -# define BOOST_THREAD_BUILD_LIB 1 -# define DBOOST_ALL_NO_LIB 1 +# define BOOST_THREAD_BUILD_LIB +# define DBOOST_ALL_NO_LIB # ifdef DEAL_II_USE_MT_POSIX # define BOOST_THREAD_POSIX diff --git a/deal.II/source/base/multithread_info.cc b/deal.II/source/base/multithread_info.cc index 421f4a4474..9945728338 100644 --- a/deal.II/source/base/multithread_info.cc +++ b/deal.II/source/base/multithread_info.cc @@ -36,7 +36,7 @@ DEAL_II_NAMESPACE_OPEN -#if DEAL_II_USE_MT +#ifdef DEAL_II_USE_MT /* Detecting how many processors a given machine has is something that varies greatly between operating systems. For a few operating diff --git a/deal.II/source/base/subscriptor.cc b/deal.II/source/base/subscriptor.cc index ec6f3534ab..0d98ee6f8a 100644 --- a/deal.II/source/base/subscriptor.cc +++ b/deal.II/source/base/subscriptor.cc @@ -147,7 +147,7 @@ void Subscriptor::do_subscribe (const char* id) const Threads::ThreadMutex::ScopedLock lock (subscription_lock); ++counter; -#if DEAL_USE_MT == 0 +#ifndef DEAL_II_USE_MT const char* const name = (id != 0) ? id : unknown_subscriber; map_iterator it = counter_map.find(name); @@ -174,7 +174,7 @@ void Subscriptor::do_unsubscribe (const char* id) const Threads::ThreadMutex::ScopedLock lock (subscription_lock); --counter; -#if DEAL_USE_MT == 0 +#ifndef DEAL_II_USE_MT map_iterator it = counter_map.find(name); Assert (it != counter_map.end(), ExcNoSubscriber(object_info->name(), name)); Assert (it->second > 0, ExcNoSubscriber(object_info->name(), name)); @@ -193,7 +193,7 @@ unsigned int Subscriptor::n_subscriptions () const void Subscriptor::list_subscribers () const { -#if DEAL_USE_MT == 0 +#ifndef DEAL_II_USE_MT for (map_iterator it = counter_map.begin(); it != counter_map.end(); ++it) deallog << it->second << '/' diff --git a/deal.II/source/numerics/time_dependent.cc b/deal.II/source/numerics/time_dependent.cc index c5d1355cc4..24ad0d22ee 100644 --- a/deal.II/source/numerics/time_dependent.cc +++ b/deal.II/source/numerics/time_dependent.cc @@ -206,7 +206,8 @@ void TimeDependent::start_sweep (const unsigned int s) void TimeDependent::end_sweep (const unsigned int n_threads) { - if (DEAL_II_USE_MT && (n_threads > 1)) +#ifdef DEAL_II_USE_MT + if (n_threads > 1) { const unsigned int stride = timesteps.size() / n_threads; Threads::ThreadGroup<> threads; @@ -220,8 +221,13 @@ void TimeDependent::end_sweep (const unsigned int n_threads) threads.join_all(); } else + { // now do the work end_sweep (0, timesteps.size()); + } +#else + end_sweep (0, timesteps.size()); +#endif }