diff --git a/CMakeLists.txt b/CMakeLists.txt index 308c8aca0f12..ba8ae1eaeacf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -411,6 +411,12 @@ foreach(_scheduler ${HPX_WITH_THREAD_SCHEDULERS_UC}) hpx_add_config_define(HPX_HAVE_STATIC_SCHEDULER) set(HPX_HAVE_STATIC_SCHEDULER ON CACHE INTERNAL "") endif() + if(HPX_WITH_APEX) + if(_scheduler STREQUAL "THROTTLE" OR _all) + hpx_add_config_define(HPX_HAVE_THROTTLE_SCHEDULER) + set(HPX_HAVE_THROTTLE_SCHEDULER ON CACHE INTERNAL "") + endif() + endif(HPX_WITH_APEX) if(_scheduler STREQUAL "HIERARCHY" OR _all) hpx_add_config_define(HPX_HAVE_HIERARCHY_SCHEDULER) set(HPX_HAVE_HIERARCHY_SCHEDULER ON CACHE INTERNAL "") @@ -520,6 +526,12 @@ if(HPX_WITH_THREAD_MANAGER_IDLE_BACKOFF) hpx_add_config_define(HPX_HAVE_THREAD_MANAGER_IDLE_BACKOFF) endif() +# If APEX is defined, the action timers need thread debug info. +if(HPX_WITH_APEX) + hpx_add_config_define(HPX_HAVE_THREAD_DESCRIPTION) + set(HPX_HAVE_THREAD_DESCRIPTION ON CACHE INTERNAL "") +endif() + if(HPX_WITH_THREAD_DEBUG_INFO) hpx_add_config_define(HPX_HAVE_THREAD_PARENT_REFERENCE) hpx_add_config_define(HPX_HAVE_THREAD_PHASE_INFORMATION) @@ -871,7 +883,7 @@ if(HPX_WITH_COMPILER_WARNINGS) # OpenMPI triggers a lot of forcing value to bool 'true' or 'false' # (performance warning) - if(MPI_FOUND) + if(MPI_FOUND OR HPX_WITH_APEX) hpx_add_compile_flag(-wd4800) endif() else() # Trial and error approach for any other compiler ... @@ -962,6 +974,7 @@ else() endif() # Check if our libraries have unresolved symbols + #if(NOT APPLE AND NOT HPX_WITH_APEX) if(NOT APPLE) hpx_add_link_flag_if_available(-Wl,-z,defs TARGETS SHARED EXE) endif() @@ -1072,16 +1085,50 @@ endif() # Enable integration with Apex event counters ################################################################################ if(HPX_WITH_APEX) - find_package(APEX) + # handle APEX library + include(GitExternal) + git_external(apex + https://github.com/khuck/xpress-apex.git + master + NO_UPDATE VERBOSE) + + LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/apex/cmake/Modules") + add_subdirectory(apex/src/apex) if(NOT APEX_FOUND) - hpx_error("Apex could not be found and HPX_WITH_APEX=On, please specify APEX_ROOT to point to the root of your Apex installation") + hpx_error("Apex could not be found and HPX_WITH_APEX=On") endif() - hpx_libraries(${APEX_LIBRARIES}) - include_directories(${APEX_INCLUDE_DIR}) if(AMPLIFIER_FOUND) hpx_error("AMPLIFIER_FOUND has been set. Please disable the use of the Intel Amplifier (WITH_AMPLIFIER=Off) in order to use Apex") endif() - hpx_add_config_define(HPX_HAVE_ITTNOTIFY) + + include_directories(${APEX_SOURCE_DIR}) + hpx_add_config_define(HPX_HAVE_APEX 1) + set(HPX_ADDITIONAL_RUNTIME_DEPENDENCIES + ${HPX_ADDITIONAL_RUNTIME_DEPENDENCIES} apex_lib) + if(APEX_WITH_MSR) + set(HPX_ADDITIONAL_RUNTIME_DEPENDENCIES + ${HPX_ADDITIONAL_RUNTIME_DEPENDENCIES} -L${MSR_ROOT}/lib -lmsr) + endif() + if(APEX_WITH_ACTIVEHARMONY) + set(HPX_ADDITIONAL_RUNTIME_DEPENDENCIES + ${HPX_ADDITIONAL_RUNTIME_DEPENDENCIES} -L${ACTIVEHARMONY_ROOT}/lib -lharmony) + endif() + if(APEX_WITH_TAU) + set(HPX_ADDITIONAL_RUNTIME_DEPENDENCIES + ${HPX_ADDITIONAL_RUNTIME_DEPENDENCIES} -L${TAU_ROOT}/lib -lTAU) + endif() + + # handle optional ITTNotify library + if(HPX_WITH_ITTNOTIFY) + add_subdirectory(apex/src/ITTNotify) + if(NOT ITTNOTIFY_FOUND) + hpx_error("ITTNotify could not be found and HPX_WITH_ITTNOTIFY=On") + endif() + include_directories(${ITTNOTIFY_SOURCE_DIR}) + hpx_add_config_define(HPX_HAVE_ITTNOTIFY 1) + set(HPX_ADDITIONAL_RUNTIME_DEPENDENCIES + ${HPX_ADDITIONAL_RUNTIME_DEPENDENCIES} ittnotify_lib) + endif() endif() if(HPX_WITH_GOOGLE_PERFTOOLS) @@ -1402,11 +1449,11 @@ install( # Install HPX Python scripts # #make copy, so that we have intact symlink in CMAKE_BINARY_DIR # execute_process( # COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${script}" "${script_name}" -# WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/python/scripts") +# WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/python/scripts") # # execute_process( # COMMAND "${CMAKE_COMMAND}" -E create_symlink "${script_name}" "${script_name_we}" -# WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/python/scripts") +# WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/python/scripts") # # install(FILES "${CMAKE_BINARY_DIR}/python/scripts/${script_name_we}" DESTINATION "bin") # endforeach() diff --git a/cmake/templates/HPXConfig.cmake.in b/cmake/templates/HPXConfig.cmake.in index 5753d2e40d98..121b91d82e08 100644 --- a/cmake/templates/HPXConfig.cmake.in +++ b/cmake/templates/HPXConfig.cmake.in @@ -38,6 +38,10 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} @CXX_FLAG@") set(HPX_BOOST_ROOT @BOOST_ROOT@) set(HPX_WITH_MALLOC_DEFAULT @HPX_WITH_MALLOC@) +set(HPX_WITH_PARCELPORT_TCP @HPX_WITH_PARCELPORT_TCP@) +set(HPX_WITH_PARCELPORT_MPI @HPX_WITH_PARCELPORT_MPI@) +set(HPX_WITH_PARCELPORT_IPC @HPX_WITH_PARCELPORT_IPC@) +set(HPX_WITH_PARCELPORT_IBVERBS @HPX_WITH_PARCELPORT_IBVERBS@) if(NOT HPX_CMAKE_LOGLEVEL) set(HPX_CMAKE_LOGLEVEL "WARN") diff --git a/cmake/templates/hpxrun.py.in b/cmake/templates/hpxrun.py.in index cd9b46fd5b16..81bcb98cd31e 100755 --- a/cmake/templates/hpxrun.py.in +++ b/cmake/templates/hpxrun.py.in @@ -271,7 +271,9 @@ if __name__ == '__main__': msg += ')' print(msg) while procs: - term(procs.pop(0)) + nextproc = procs.pop(0) + if nextproc != proc: + term(nextproc) except: pass finally: procs_lock.release() diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index ef30c5ff70c9..9e84fca71a4d 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -52,6 +52,7 @@ set(doxygen_dependencies "${PROJECT_SOURCE_DIR}/hpx/error.hpp" "${PROJECT_SOURCE_DIR}/hpx/exception.hpp" "${PROJECT_SOURCE_DIR}/hpx/exception_list.hpp" + "${PROJECT_SOURCE_DIR}/hpx/lcos_fwd.hpp" "${PROJECT_SOURCE_DIR}/hpx/components/component_storage/migrate_from_storage.hpp" "${PROJECT_SOURCE_DIR}/hpx/components/component_storage/migrate_to_storage.hpp" "${PROJECT_SOURCE_DIR}/hpx/parallel/execution_policy.hpp" @@ -105,6 +106,7 @@ set(doxygen_dependencies "${PROJECT_SOURCE_DIR}/hpx/parallel/executors/static_chunk_size.hpp" "${PROJECT_SOURCE_DIR}/hpx/parallel/executors/thread_pool_executors.hpp" "${PROJECT_SOURCE_DIR}/hpx/parallel/executors/timed_executor_traits.hpp" + "${PROJECT_SOURCE_DIR}/hpx/runtime/basename_registration.hpp" "${PROJECT_SOURCE_DIR}/hpx/runtime/get_ptr.hpp" "${PROJECT_SOURCE_DIR}/hpx/runtime/get_locality_name.hpp" "${PROJECT_SOURCE_DIR}/hpx/runtime/launch_policy.hpp" @@ -122,6 +124,7 @@ set(doxygen_dependencies "${PROJECT_SOURCE_DIR}/hpx/runtime/components/new.hpp" "${PROJECT_SOURCE_DIR}/hpx/runtime/naming/unmanaged.hpp" "${PROJECT_SOURCE_DIR}/hpx/runtime/threads/thread_enums.hpp" + "${PROJECT_SOURCE_DIR}/hpx/runtime/threads_fwd.hpp" "${PROJECT_SOURCE_DIR}/hpx/lcos/broadcast.hpp" "${PROJECT_SOURCE_DIR}/hpx/lcos/fold.hpp" "${PROJECT_SOURCE_DIR}/hpx/lcos/reduce.hpp" diff --git a/docs/hpx.idx b/docs/hpx.idx index 3108d24db81d..178bbdd2e5b1 100644 --- a/docs/hpx.idx +++ b/docs/hpx.idx @@ -19,11 +19,11 @@ find_all_localities "" "hpx\.find_all_localities.*" find_remote_localities "" "hpx\.find_remote_localities.*" find_locality "" "hpx\.find_locality.*" -find_all_ids_from_basename "" "hpx\.find_all_ids_from_basename.*" -find_ids_from_basename "" "hpx\.find_ids_from_basename.*" -find_id_from_basename "" "hpx\.find_id_from_basename.*" -register_id_with_basename "" "hpx\.register_id_with_basename.*" -unregister_id_with_basename "" "hpx\.unregister_id_with_basename.*" +# hpx/runtime/basename_registration.hpp +find_all_from_basename "" "hpx\.find_all_from_basename.*" +find_from_basename "" "hpx\.find_from_basenam_id.*" +register_with_basename "" "hpx\.register_with_bas_id.*" +unregister_with_basename "" "hpx\.unregister_with_basename.*" get_num_localities_sync "" "hpx\.get_num_localitie_id.*" get_num_localities "" "hpx\.get_num_localitie_id.*" @@ -45,13 +45,16 @@ is_stopped_or_shutting_down "" "hpx\.is_stopped_or_shutting_down.*" get_worker_thread_num "" "hpx\.get_worker_thread_num.*" get_thread_name "" "hpx\.get_thread_name.*" -get_locality_name "" "hpx\.get_locality_name.*" get_num_worker_threads "" "hpx\.get_num_worker_threads.*" +# hpx/runtime/get_locality_name.hpp +get_locality_name "" "hpx\.get_locality_name.*" + get_system_uptime "" "hpx\.get_system_uptime.*" get_colocation_id "" "hpx\.get_colocation_id.*" get_colocation_id_sync "" "hpx\.get_colocation_id_sync.*" +# hpx/runtime/trigger_lco.hpp trigger_lco_event "" "hpx\.trigger_lco_event.*" set_lco_event "" "hpx\.set_lco_event.*" set_lco_value "" "hpx\.set_lco_value.*" @@ -62,6 +65,7 @@ reset_active_counters "" "hpx\.reset_active_counters.*" stop_active_counters "" "hpx\.stop_active_counters.*" evaluate_active_counters "" "hpx\.evaluate_active_counters.*" +# hpx/runtime/set_parcel_write_handler.hpp set_parcel_write_handler "" "hpx\.set_parcel_write_.*" parcel_write_handler_type "" "hpx\.parcel_write_hand.*" @@ -392,7 +396,7 @@ task_region_not_active "" "hpx\.error" unmanaged "" "header\.hpx\.runtime\.naming\.unmanaged.*" # hpx/runtime/get_ptr.hpp -get_ptr "" "hpx\.get_ptr.*" +get_ptr "" "hpx\.runtime\.get_ptr.*" # hpx/lcos/broadcast.hpp broadcast "" "header\.hpx\.lcos\.broadcast.*" diff --git a/docs/html/src/boostbook.css b/docs/html/src/boostbook.css index e3693b97f120..0a159d7c329e 100644 --- a/docs/html/src/boostbook.css +++ b/docs/html/src/boostbook.css @@ -424,7 +424,8 @@ Colors h1 a, h2 a, h3 a, h4 a, h5 a, h6 a, h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover, - h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited + h1 a:visited, h2 a:visited, h3 a:visited, + h4 a:visited, h5 a:visited, h6 a:visited { text-decoration: none; /* no underline */ color: #000000; diff --git a/docs/manual/parallel_algorithms.qbk b/docs/manual/parallel_algorithms.qbk index 9ea99cbade8c..42272df645ae 100644 --- a/docs/manual/parallel_algorithms.qbk +++ b/docs/manual/parallel_algorithms.qbk @@ -134,6 +134,9 @@ __hpx__ provides implementations of the following parallel algorithms: [[ [algoref for_each] ] [Applies a function to a range of elements.] [``]] + [[ [algoref for_each_n] ] + [Applies a function to a number of elements.] + [``]] [[ [algoref count] ] [Returns the number of elements equal to a given value.] [``]] diff --git a/docs/namespace_func/agas.txt b/docs/namespace_func/agas.txt index 67ce808af68d..840f6c3ec244 100644 --- a/docs/namespace_func/agas.txt +++ b/docs/namespace_func/agas.txt @@ -44,7 +44,8 @@ hpx::agas::addressing_service naming::address primary_ns_addr_; naming::address component_ns_addr_; naming::address symbol_ns_addr_; - addressing_service(parcelset::parcelport&,util::runtime_configuration const&,runtime_mode) + addressing_service(parcelset::parcelport&, + util::runtime_configuration const&,runtime_mode) void launch_bootstrap(parcelset::parcelport&,util::runtime_configuration const&) void launch_hosted(parcelset::parcelport&,util::runtime_configuration const&) state status() const @@ -66,22 +67,28 @@ hpx::agas::addressing_service // lots of params documented that aren't present bool get_console_locality(naming::gid_type&,error_code& ec = throw) // type refers to component type. what are the types? - bool get_localities(std::vector&,components::component_type,**throws) + bool get_localities + (std::vector&,components::component_type,**throws) bool get_localities(std::vector&,**throws) components::component_type get_component_id(std::string const& name,**throws) void iterate_types(iterate_types_function_type const&,**throws) // factory for components by type - components::component_type register_factory(naming::gid_type const& locality_id,std::string const& name,**throws) - components::component_type register_factory(boost::uint32_t locality_id,std::string const& name,**throws) + components::component_type register_factory(naming::gid_type const& locality_id, + std::string const& name,**throws) + components::component_type register_factory(boost::uint32_t locality_id, + std::string const& name,**throws) /// \brief Get unique range of freely assignable global ids. - bool get_id_range(naming::locality const&,boost::uint64_t count,naming::gid_type& lower_bound,naming::gid_type& upper_bound,**throws) + bool get_id_range(naming::locality const&,boost::uint64_t count, + naming::gid_type& lower_bound,naming::gid_type& upper_bound,**throws) /// \brief Bind a global address to a local address. bool bind(naming::gid_type const&,naming::address const&,**throws) - bool bind_range(naming::gid_type const& lower_id,boost::uint64_t count,naming::address const&,boost::uint64_t offset,**throws) + bool bind_range(naming::gid_type const& lower_id,boost::uint64_t count, + naming::address const&,boost::uint64_t offset,**throws) bool unbind(naming::gid_type const&,**throws) bool unbind(naming::gid_type const&,naming::address&,**throws) bool unbind_range(naming::gid_type const& lower_id,boost::uint64_t count,**throws) - bool unbind_range(naming::gid_type const& lower_id,boost::uint64_t countnaming::address& addr,**throws) + bool unbind_range(naming::gid_type const& lower_id, + boost::uint64_t countnaming::address& addr,**throws) bool is_local_address(naming::gid_type const&,**throws) bool is_local_address(naming::gid_type const&,naming::address& addr,**throws) @@ -95,9 +102,11 @@ hpx::agas::addressing_service bool resolve_full(naming::id_type const&,naming::address&,**throws) bool resolve_cached(naming::gid_type const&,naming::address&,**throws) - void incref(naming::gid_type const& lower,naming::gid_type const& upper,boost::int64_t credits = 1,**throws) + void incref(naming::gid_type const& lower,naming::gid_type const& upper, + boost::int64_t credits = 1,**throws) void incref(naming::gid_type const& id,boost::int64_t credits = 1,**throws) - void decref(naming::gid_type const& lower,naming::gid_type const& upper,boost::int64_t credits = 1,**throws) + void decref(naming::gid_type const& lower, + naming::gid_type const& upper,boost::int64_t credits = 1,**throws) void decref(naming::gid_type const& id,boost::int64_t credits = 1,**throws) bool iterate_ids(iterate_names_function_type const&,**throws) bool register_name(std::string const& name,naming::gid_type const&,**throws) @@ -110,25 +119,32 @@ hpx::agas::addressing_service hpx::agas::big_boot_barrier - big_boot_barrier(parcelset::parcelport&,util::runtime_configuration const&,runtime_mode) + big_boot_barrier + (parcelset::parcelport&,util::runtime_configuration const&,runtime_mode) void apply(boost::uint32_t prefix,naming::address const&,actions::base_action*) void wait() void trigger() void add_thunk(HPX_STD_FUNCTION* f) -void create_big_boot_barrier(parcelset::parcelport&,util::runtime_configuration const&,runtime_mode) +void create_big_boot_barrier(parcelset::parcelport&,util::runtime_configuration const&, + runtime_mode) void destroy_big_boot_barrier() big_boot_barrier& get_big_boot_barrier() hpx::agas::component_namespace component_namespace() explicit component_namespace(naming::id_type const& id) - void service[_non_blocking](request const&,threads::thread_priority priority = default,**throws) - std::vector bulk_service[_non_blocking](std::vector const&,threads::thread_priority priority = default,**throws) + void service[_non_blocking](request const&,threads::thread_priority priority = + default,**throws) + std::vector bulk_service[_non_blocking](std::vector const&, + threads::thread_priority priority = default,**throws) hpx::agas::gva gva() - gva(naming::locality const&,component_type t = components::component_invalid, boost::uint64_t c = 1,lva_type a = 0, boost::uint64_t o = 0) - gva(naming::locality const& ep, component_type t, boost::uint64_t c, void* a,boost::uint64_t o = 0) + gva(naming::locality const&,component_type t = + components::component_invalid, boost::uint64_t c = + 1,lva_type a = 0, boost::uint64_t o = 0) + gva(naming::locality const& ep, component_type t, + boost::uint64_t c, void* a,boost::uint64_t o = 0) gva(lva_type a) gva(void* a) gva& operator=(lva_type a) @@ -138,7 +154,9 @@ hpx::agas::gva bool operator!=(gva const& rhs) const void lva(lva_type a) void lva(void* a) - lva_type lva(naming::gid_type const& gid = naming::invalid_gid,naming::gid_type const& gidbase = naming::invalid_gid) const + lva_type lva(naming::gid_type const& gid + = naming::invalid_gid,naming::gid_type const& gidbase + = naming::invalid_gid) const gva resolve(naming::gid_type const& gid,naming::gid_type const& gidbase) const naming::locality endpoint; component_type type; @@ -148,7 +166,8 @@ operator<< (std::basic_ostream& os, gva const& addr) hpx::agas bool register_name(std::string const&,naming::id_type const&,**throws) - lcos::future register_name_async(std::string const&,naming::id_type const&) + lcos::future register_name_async(std::string const&, + naming::id_type const&) bool unregister_name(std::string const& name,**throws) bool unregister_name(std::string const&,naming::id_type&,**throws) lcos::future unregister_name_async(std::string const&) @@ -161,7 +180,8 @@ hpx::agas bool is_local_address_cached(naming::gid_type const&,**throws) bool is_local_address_cached(naming::gid_type const&,naming::address&,**throws) bool is_local_address_cached(naming::id_type const&,**throws) - bool is_local_address_cached(naming::id_type const&,naming::address&,**throws)obool is_local_lva_encoded_address(naming::gid_type const&) + bool is_local_address_cached(naming::id_type const&,naming::address&,**throws) + obool is_local_lva_encoded_address(naming::gid_type const&) bool is_local_lva_encoded_address(naming::id_type const&) void garbage_collect[_non_blocking](**throws) void garbage_collect[_non_blocking](naming::id_type const&,**throws) @@ -174,12 +194,16 @@ hpx::agas::primary_namespace explicit primary_namespace(naming::id_type const& id) response service(request const&,threads::thread_priority priority = default,**throws) void service_non_blocking(request const&,threads::thread_priority priority = default) - std::vector bulk_service[_non_blocking](std::vector const&,threads::thread_priority priority = default,**throws) - bool route(parcelset::parcel const,threads::thread_priority priority = default,**throws) + std::vector + bulk_service[_non_blocking](std::vector const&, + threads::thread_priority priority = default,**throws) + bool route + (parcelset::parcel const,threads::thread_priority priority = default,**throws) hpx::agas::request request() - request(namespace_action_code,naming::gid_type const& lower_,naming::gid_type const& upper_,boost::int64_t count_) + request(namespace_action_code,naming::gid_type const& lower_, + naming::gid_type const& upper_,boost::int64_t count_) request(namespace_action_code,naming::gid_type const&,boost::uint64_t count_) // Should this be here? request(namespace_action_code,naming::gid_type const&,gva const&) @@ -214,7 +238,8 @@ hpx::agas::response response() // should error_status = success be **throws? response(namespace_action_code, - naming::gid_type lower_,naming::gid_type upper_,boost::uint32_t prefix_,error status_ = success) + naming::gid_type lower_, + naming::gid_type upper_,boost::uint32_t prefix_,error status_ = success) response(namespace_action_code, naming::gid_type const&,gva const&,error status_ = success) response(namespace_action_code, @@ -251,4 +276,5 @@ hpx::agas::traits hpx::agas::symbol_namespace symbol_namespace() explicit symbol_namespace(naming::id_type const& id) - response [block_]service[_non_blocking](request const&,threads::thread_priority priority = default,**throws) + response [block_]service[_non_blocking] + (request const&,threads::thread_priority priority = default,**throws) diff --git a/docs/namespace_func/components.txt b/docs/namespace_func/components.txt index e39df07d6b00..b5dfa7c8b32a 100644 --- a/docs/namespace_func/components.txt +++ b/docs/namespace_func/components.txt @@ -5,34 +5,55 @@ Namespace: hpx::performance_counters -API Component: File: Comments: +Format: +API Component + File + Comments * functions -server::locality_results hpx/components/server/distributing_factory.hpp +server::locality_results + hpx/components/server/distributing_factory.hpp -remote_object::new_<> hpx/components/remote_object/new.hpp -server::remote_object::apply<> hpx/components/remote_object/server/remote_object.hpp +remote_object::new_<> + hpx/components/remote_object/new.hpp +server::remote_object::apply<> + hpx/components/remote_object/server/remote_object.hpp * classes -distributing_factory hpx/components/distributing_factory.hpp +distributing_factory + hpx/components/distributing_factory.hpp -server::remote_locality_result hpx/components/server/distributing_factory.hpp -server::locality_result hpx/components/server/distributing_factory.hpp -server::partition_info hpx/components/server/distributing_factory.hpp -server::distributing_factory hpx/components/server/distributing_factory.hpp -server::locality_result_iterator hpx/components/server/distributing_factory.hpp +server::remote_locality_result + hpx/components/server/distributing_factory.hpp +server::locality_result + hpx/components/server/distributing_factory.hpp +server::partition_info + hpx/components/server/distributing_factory.hpp +server::distributing_factory + hpx/components/server/distributing_factory.hpp +server::locality_result_iterator + hpx/components/server/distributing_factory.hpp -server::remote_object hpx/components/remote_object/server/remote_object.hpp -server::remote_object_apply_action<> hpx/components/remote_object/server/remote_object.hpp -server::remote_object_apply_action hpx/components/remote_object/server/remote_object.hpp +server::remote_object + hpx/components/remote_object/server/remote_object.hpp +server::remote_object_apply_action<> + hpx/components/remote_object/server/remote_object.hpp +server::remote_object_apply_action + hpx/components/remote_object/server/remote_object.hpp -stubs::distributing_factory hpx/components/stub/distributing_factory.hpp -stubs::remote_object hpx/components/remote_object/stubs/remote_object.hpp +stubs::distributing_factory + hpx/components/stub/distributing_factory.hpp +stubs::remote_object + hpx/components/remote_object/stubs/remote_object.hpp -remote_object::ctor_fun<> hpx/components/remote_object/ctor_fun.hpp -remote_object::dtor_fun<> hpx/components/remote_object/new.hpp -remote_object::invoke_apply_fun<> hpx/components/remote_object/object.hpp -remote_object::object<> hpx/components/remote_object/object.hpp +remote_object::ctor_fun<> + hpx/components/remote_object/ctor_fun.hpp +remote_object::dtor_fun<> + hpx/components/remote_object/new.hpp +remote_object::invoke_apply_fun<> + hpx/components/remote_object/object.hpp +remote_object::object<> + hpx/components/remote_object/object.hpp * macros @@ -40,40 +61,75 @@ remote_object::object<> hpx/components/remote_object/obj Other namespaces: * functions -boost::serialization::serialize hpx/components/server/distributing_factory.hpp -hpx::lcos::wait<> hpx/components/dataflow/async_dataflow_wait.hpp -hpx::iostreams::operator<< hpx/components/iostreams/manipulators.hpp -hpx::iostreams::create_cout hpx/components/iostreams/standard_streams.hpp -hpx::iostreams::create_cerr hpx/components/iostreams/standard_streams.hpp -hpx::iostreams::cout hpx/components/iostreams/standard_streams.hpp -hpx::iostreams::cerr hpx/components/iostreams/standard_streams.hpp -hpx::iostreams::iterator_write_function<> hpx/components/iostreams/write_functions.hpp -hpx::iostreams::make_iterator_write_function<> hpx/components/iostreams/write_functions.hpp -hpx::iostreams::std_ostream_write_function hpx/components/iostreams/write_functions.hpp -hpx::iostreams::make_std_ostream_write_function hpx/components/iostreams/write_functions.hpp +boost::serialization::serialize + hpx/components/server/distributing_factory.hpp +hpx::lcos::wait<> + hpx/components/dataflow/async_dataflow_wait.hpp +hpx::iostreams::operator<< + hpx/components/iostreams/manipulators.hpp +hpx::iostreams::create_cout + hpx/components/iostreams/standard_streams.hpp +hpx::iostreams::create_cerr + hpx/components/iostreams/standard_streams.hpp +hpx::iostreams::cout + hpx/components/iostreams/standard_streams.hpp +hpx::iostreams::cerr + hpx/components/iostreams/standard_streams.hpp +hpx::iostreams::iterator_write_function<> + hpx/components/iostreams/write_functions.hpp +hpx::iostreams::make_iterator_write_function<> + hpx/components/iostreams/write_functions.hpp +hpx::iostreams::std_ostream_write_function + hpx/components/iostreams/write_functions.hpp +hpx::iostreams::make_std_ostream_write_function + hpx/components/iostreams/write_functions.hpp * classes -hpx::traits::get_remote_result hpx/components/server/distributing_factory.hpp -hpx::traits::promise_remote_result<> hpx/components/remote_object/object.hpp -hpx::traits::component_type_database<> hpx/components/remote_object/object.hpp -hpx::lcos::dataflow<> hpx/components/dataflow/dataflow.hpp -hpx::lcos::dataflow_base<> hpx/components/dataflow/dataflow_base.hpp -hpx::lcos::dataflow_base hpx/components/dataflow/dataflow_base_void.hpp -hpx::lcos::dataflow_trigger hpx/components/dataflow/dataflow_trigger.hpp -hpx::traits::is_dataflow<> hpx/components/dataflow/is_dataflow.hpp -hpx::lcos::server::dataflow hpx/components/dataflow/server/dataflow.hpp -hpx::lcos::server::dataflow_trigger hpx/components/dataflow/server/dataflow_trigger.hpp -hpx::lcos::stubs::dataflow hpx/components/dataflow/stubs/dataflow.hpp -hpx::lcos::stubs::dataflow_trigger hpx/components/dataflow/stubs/dataflow_trigger.hpp -hpx::iostreams::lazy_ostream hpx/components/iostreams/lazy_ostream.hpp -hpx::iostreams::sync_flush_type hpx/components/iostreams/manipulators.hpp -hpx::iostreams::sync_endl_type hpx/components/iostreams/manipulators.hpp -hpx::iostreams::flush_type hpx/components/iostreams/manipulators.hpp -hpx::iostreams::endl_type hpx/components/iostreams/manipulators.hpp -hpx::iostreams::async_flush_type hpx/components/iostreams/manipulators.hpp -hpx::iostreams::async_endl_type hpx/components/iostreams/manipulators.hpp -hpx::iostreams::local_flush_type hpx/components/iostreams/manipulators.hpp -hpx::iostreams::local_endl_type hpx/components/iostreams/manipulators.hpp -hpx::iostreams::buffer hpx/components/iostreams/server/output_stream.hpp -hpx::iostreams::server::output_stream hpx/components/iostreams/server/output_stream.hpp -hpx::iostreams::stubs::output_stream hpx/components/iostreams/stubs/output_stream.hpp +hpx::traits::get_remote_result + hpx/components/server/distributing_factory.hpp +hpx::traits::promise_remote_result<> + hpx/components/remote_object/object.hpp +hpx::traits::component_type_database<> + hpx/components/remote_object/object.hpp +hpx::lcos::dataflow<> + hpx/components/dataflow/dataflow.hpp +hpx::lcos::dataflow_base<> + hpx/components/dataflow/dataflow_base.hpp +hpx::lcos::dataflow_base + hpx/components/dataflow/dataflow_base_void.hpp +hpx::lcos::dataflow_trigger + hpx/components/dataflow/dataflow_trigger.hpp +hpx::traits::is_dataflow<> + hpx/components/dataflow/is_dataflow.hpp +hpx::lcos::server::dataflow + hpx/components/dataflow/server/dataflow.hpp +hpx::lcos::server::dataflow_trigger + hpx/components/dataflow/server/dataflow_trigger.hpp +hpx::lcos::stubs::dataflow + hpx/components/dataflow/stubs/dataflow.hpp +hpx::lcos::stubs::dataflow_trigger + hpx/components/dataflow/stubs/dataflow_trigger.hpp +hpx::iostreams::lazy_ostream + hpx/components/iostreams/lazy_ostream.hpp +hpx::iostreams::sync_flush_type + hpx/components/iostreams/manipulators.hpp +hpx::iostreams::sync_endl_type + hpx/components/iostreams/manipulators.hpp +hpx::iostreams::flush_type + hpx/components/iostreams/manipulators.hpp +hpx::iostreams::endl_type + hpx/components/iostreams/manipulators.hpp +hpx::iostreams::async_flush_type + hpx/components/iostreams/manipulators.hpp +hpx::iostreams::async_endl_type + hpx/components/iostreams/manipulators.hpp +hpx::iostreams::local_flush_type + hpx/components/iostreams/manipulators.hpp +hpx::iostreams::local_endl_type + hpx/components/iostreams/manipulators.hpp +hpx::iostreams::buffer + hpx/components/iostreams/server/output_stream.hpp +hpx::iostreams::server::output_stream + hpx/components/iostreams/server/output_stream.hpp +hpx::iostreams::stubs::output_stream + hpx/components/iostreams/stubs/output_stream.hpp diff --git a/docs/namespace_func/performance_counters.txt b/docs/namespace_func/performance_counters.txt index ff241d382389..f388b9a3e7e4 100644 --- a/docs/namespace_func/performance_counters.txt +++ b/docs/namespace_func/performance_counters.txt @@ -5,55 +5,98 @@ Namespace: hpx::performance_counters -API Component: File: Comments: +Format: +API Component: + File: + Comments: * functions -default_counter_discoverer hpx/performance_counters/counter_creators.hpp -locality_counter_discoverer hpx/performance_counters/counter_creators.hpp -locality_thread_counter_discoverer hpx/performance_counters/counter_creators.hpp -locality_raw_counter_creator hpx/performance_counters/counter_creators.hpp -ensure_counter_prefix hpx/performance_counters/counters.hpp -status_is_valid hpx/performance_counters/counters.hpp -get_counter_type_name hpx/performance_counters/counters.hpp -get_full_counter_type_name hpx/performance_counters/counters.hpp -get_counter_name hpx/performance_counters/counters.hpp -get_counter_type_path_elements hpx/performance_counters/counters.hpp -get_counter_counter_path_elements hpx/performance_counters/counters.hpp -complement_counter_info hpx/performance_counters/counters.hpp -add_counter_type hpx/performance_counters/counters.hpp -discover_counter_types hpx/performance_counters/counters.hpp -remove_counter_type hpx/performance_counters/counters.hpp -get_counter_type hpx/performance_counters/counters.hpp -get_counter hpx/performance_counters/counters.hpp -get_counter_infos hpx/performance_counters/counters.hpp -install_counter hpx/performance_counters/manage_counter.hpp -install_counter_type hpx/performance_counters/manage_counter_type.hpp +default_counter_discoverer + hpx/performance_counters/counter_creators.hpp +locality_counter_discoverer + hpx/performance_counters/counter_creators.hpp +locality_thread_counter_discoverer + hpx/performance_counters/counter_creators.hpp +locality_raw_counter_creator + hpx/performance_counters/counter_creators.hpp +ensure_counter_prefix + hpx/performance_counters/counters.hpp +status_is_valid + hpx/performance_counters/counters.hpp +get_counter_type_name + hpx/performance_counters/counters.hpp +get_full_counter_type_name + hpx/performance_counters/counters.hpp +get_counter_name + hpx/performance_counters/counters.hpp +get_counter_type_path_elements + hpx/performance_counters/counters.hpp +get_counter_counter_path_elements + hpx/performance_counters/counters.hpp +complement_counter_info + hpx/performance_counters/counters.hpp +add_counter_type + hpx/performance_counters/counters.hpp +discover_counter_types + hpx/performance_counters/counters.hpp +remove_counter_type + hpx/performance_counters/counters.hpp +get_counter_type + hpx/performance_counters/counters.hpp +get_counter + hpx/performance_counters/counters.hpp +get_counter_infos + hpx/performance_counters/counters.hpp +install_counter + hpx/performance_counters/manage_counter.hpp +install_counter_type + hpx/performance_counters/manage_counter_type.hpp * classes -counter_type_path_elements hpx/performance_counters/counters.hpp -counter_path_elements hpx/performance_counters/counters.hpp -counter_info hpx/performance_counters/counters.hpp -counter_value hpx/performance_counters/counters.hpp -high_resolution_clock hpx/performance_counters/high_resolution_clock.hpp -manage_counter hpx/performance_counters/manage_counter.hpp -manage_counter_type hpx/performance_counters/manage_counter_type.hpp -generic_counter_type_data hpx/performance_counters/manage_counter_type.hpp -registry hpx/performance_counters/registry.hpp - -server::aggregating_counter hpx/performance_counters/server/aggregating_counter.hpp -server::base_performance_counter hpx/performance_counters/server/base_performance_counter.hpp -server::elapsed_time_counter hpx/performance_counters/server/elapsed_time_counter.hpp -server::raw_counter hpx/performance_counters/server/raw_counter.hpp - -stubs::performance_counter hpx/performance_counters/stubs/performance_counter.hpp - -parcels::count_and_time_data_point hpx/performance_counters/parcels/count_and_time_data_point.hpp -parcels::count_time_stats hpx/performance_counters/parcels/count_time_stats.hpp -parcels::data_point hpx/performance_counters/parcels/data_point.hpp -parcels::gatherer hpx/performance_counters/parcels/gatherer.hpp +counter_type_path_elements + hpx/performance_counters/counters.hpp +counter_path_elements + hpx/performance_counters/counters.hpp +counter_info + hpx/performance_counters/counters.hpp +counter_value + hpx/performance_counters/counters.hpp +high_resolution_clock + hpx/performance_counters/high_resolution_clock.hpp +manage_counter + hpx/performance_counters/manage_counter.hpp +manage_counter_type + hpx/performance_counters/manage_counter_type.hpp +generic_counter_type_data + hpx/performance_counters/manage_counter_type.hpp +registry + hpx/performance_counters/registry.hpp + +server::aggregating_counter + hpx/performance_counters/server/aggregating_counter.hpp +server::base_performance_counter + hpx/performance_counters/server/base_performance_counter.hpp +server::elapsed_time_counter + hpx/performance_counters/server/elapsed_time_counter.hpp +server::raw_counter + hpx/performance_counters/server/raw_counter.hpp + +stubs::performance_counter + hpx/performance_counters/stubs/performance_counter.hpp + +parcels::count_and_time_data_point + hpx/performance_counters/parcels/count_and_time_data_point.hpp +parcels::count_time_stats + hpx/performance_counters/parcels/count_time_stats.hpp +parcels::data_point + hpx/performance_counters/parcels/data_point.hpp +parcels::gatherer + hpx/performance_counters/parcels/gatherer.hpp * macros * enums -counter_type hpx/performance_counters/counters.hpp -counter_status hpx/performance_counters/counters.hpp +counter_type + hpx/performance_counters/counters.hpp +counter_status + hpx/performance_counters/counters.hpp diff --git a/docs/namespace_func/threads.txt b/docs/namespace_func/threads.txt index a5dd34f7dd89..9cb578738940 100644 --- a/docs/namespace_func/threads.txt +++ b/docs/namespace_func/threads.txt @@ -56,7 +56,8 @@ namespace hpx::threads // advanced? thread_state set_state(thread_state_enum) - bool set_state_tagged(thread_state_enum,thread_state& prevstate,thread_state& newstate) + bool set_state_tagged(thread_state_enum,thread_state& prevstate, + thread_state& newstate) bool restore_state(thread_state_enum newval,thread_state oldval) thread_state_ex get_state_ex() const diff --git a/examples/1d_hydro/1d_hydro_upwind.cpp b/examples/1d_hydro/1d_hydro_upwind.cpp index 441f74273efa..4a44404c6bb0 100644 --- a/examples/1d_hydro/1d_hydro_upwind.cpp +++ b/examples/1d_hydro/1d_hydro_upwind.cpp @@ -92,14 +92,16 @@ struct cell{ // // cell c1, c2; // c1 = c2; // invoked by this syntax - // Bryce: I think i'd like to change this so the "calculated" is not copied in the assignment op + // Bryce: I think i'd like to change this so the "calculated" is not + // copied in the assignment op cell& operator=( cell const& other ) { // first, we lock both the mutex of this cell, and the mutex of the other // cell - // boost::lock_guard this_lock(mtx), other_lock(other.mtx); + // boost::lock_guard this_lock(mtx), + // other_lock(other.mtx); rho = other.rho; mom = other.mom; @@ -177,7 +179,8 @@ struct time_element{ // Object to store the Fluid separated in cell and computed by a Time Zone of tie Steps -// Will store the 2d grid created by the division of the fluid into cells and the computation over time +// Will store the 2d grid created by the division of the fluid +// into cells and the computation over time // Will be able to Retrieve,remove,add a timestep to the grid class One_Dimension_Grid @@ -190,7 +193,8 @@ class One_Dimension_Grid void addNewTimeStep(); public: - std::vector time_array;//pointer to the Grid we will create whden the user starts a simulation + std::vector time_array; + //pointer to the Grid we will create whden the user starts a simulation }; void One_Dimension_Grid::remove_bottom_time_step() @@ -246,7 +250,9 @@ double timestep_size(boost::uint64_t timestep) grid.time_array.at(timestep).dt = dx*0.033;// this should be fine unless // the initial conditions are changed if(timestep>0&&grid.time_array.at(timestep-1).computed) - grid.time_array[timestep].physics_time = (grid.time_array.at(timestep-1).physics_time+grid.time_array.at(timestep).dt); + grid.time_array[timestep].physics_time = + (grid.time_array.at(timestep-1).physics_time+grid. + time_array.at(timestep).dt); // time_array[timestep].dt = cfl_predict_factor*dt_cfl; else if(timestep==0) { @@ -258,11 +264,13 @@ double timestep_size(boost::uint64_t timestep) // send back the compute futures for the whole grid // n_predict timesteps previous to the one we want to decide // the timestep for - // cout << (boost::format("pushing back futures for ts calc, ts=%1% \n") % timestep) << flush; + // cout << (boost::format("pushing back futures for ts calc, ts=%1% \n") % timestep) + // << flush; if(timestep>=n_predict) { for (boost::uint64_t i=0;i(here,timestep-n_predict,i)); + grid.time_array.at(timestep).fluid_future.push_back(async + (here,timestep-n_predict,i)); } double dt_cfl = 1000.0; @@ -324,26 +332,31 @@ double timestep_size(boost::uint64_t timestep) , 1.25*grid.time_array.at(timestep-1).dt); - // cout << (boost::format("timestep = %1%, dt = %2%\n") % timestep % time_array[timestep].dt) << flush; + // cout << (boost::format("timestep = %1%, dt = %2%\n") + // % timestep % time_array[timestep].dt) << flush; return grid.time_array[timestep].dt; } cell compute(boost::uint64_t timestep, boost::uint64_t location) { - boost::lock_guard l(grid.time_array.at(timestep).fluid.at(location).mtx); + boost::lock_guard l(grid.time_array.at(timestep) + .fluid.at(location).mtx); // if it is already computed then just return the value if (grid.time_array.at(timestep).fluid.at(location).computed == true) return grid.time_array.at(timestep).fluid.at(location); - // cout << (boost::format("computing new value, loc = %1%,ts=%2% \n") % location % timestep) << flush; + // cout << (boost::format("computing new value, loc = %1%,ts=%2% \n") + // % location % timestep) << flush; //initial values if (timestep == 0) { - // cout << (boost::format("calling initial_sod, loc = %1%,ts=%2% \n") % location % timestep) << flush; + // cout << (boost::format("calling initial_sod, loc = %1%,ts=%2% \n") + // % location % timestep) << flush; grid.time_array.at(timestep).fluid.at(location) = initial_sod(location); - // cout << (boost::format("returning value, loc = %1%,ts=%2% \n") % location % timestep) << flush; + // cout << (boost::format("returning value, loc = %1%,ts=%2% \n") + // % location % timestep) << flush; grid.time_array.at(timestep).fluid.at(location).computed = true; return grid.time_array.at(timestep).fluid.at(location); } @@ -459,11 +472,13 @@ cell compute(boost::uint64_t timestep, boost::uint64_t location) //cout << (boost::format("gas is shocking!\n")) << flush; now.tau = pow(e_internal,(1.0/fluid_gamma)); } - // cout << (boost::format("computing new value, loc = %1%, ts= %2%\n") % location % timestep) << flush; + // cout << (boost::format("computing new value, loc = %1%, ts= %2%\n") + // % location % timestep) << flush; // cout << (boost::format("loc = %1%, rho = %2%\n") % location % left.rho) << flush; // cout << (boost::format("loc = %1%, mom = %2%\n") % location % left.mom) << flush; // cout << (boost::format("loc = %1%, etot = %2%\n") % location % left.etot) << flush; - // cout << (boost::format("loc = %1%, vel left = %2%\n") % location % velocity_left) << flush; + // cout << (boost::format("loc = %1%, vel left = %2%\n") % location % velocity_left) + // << flush; // if (location == 1) // cout << (boost::format("calculating timestep = %1%\n") % timestep) << flush; @@ -473,7 +488,8 @@ cell compute(boost::uint64_t timestep, boost::uint64_t location) bool time_step_complete= false; for(boost::uint64_t i=0;i(); // Number of partitions. - // Number of partitions dynamically determined - - boost::uint64_t nx = vm["nx"].as(); // Number of grid points. - boost::uint64_t nt = vm["nt"].as(); // Number of steps. - boost::uint64_t nr = vm["nr"].as(); // Number of runs (repartition between runs). + /* Number of partitions dynamically determined + // Number of partitions. + // boost::uint64_t np = vm["np"].as(); + */ + + // Number of grid points. + boost::uint64_t nx = vm["nx"].as(); + // Number of steps. + boost::uint64_t nt = vm["nt"].as(); + // Number of runs (repartition between runs). + boost::uint64_t nr = vm["nr"].as(); if (vm.count("no-header")) header = false; diff --git a/examples/1d_stencil/1d_stencil_8.cpp b/examples/1d_stencil/1d_stencil_8.cpp index cf3047b72269..4f726de694a9 100644 --- a/examples/1d_stencil/1d_stencil_8.cpp +++ b/examples/1d_stencil/1d_stencil_8.cpp @@ -321,8 +321,10 @@ struct stepper_server : hpx::components::simple_component_base stepper_server() {} stepper_server(std::size_t nl) - : left_(hpx::find_id_from_basename(stepper_basename, idx(hpx::get_locality_id(), -1, nl))), - right_(hpx::find_id_from_basename(stepper_basename, idx(hpx::get_locality_id(), +1, nl))), + : left_(hpx::find_from_basename( + stepper_basename, idx(hpx::get_locality_id(), -1, nl))), + right_(hpx::find_from_basename( + stepper_basename, idx(hpx::get_locality_id(), +1, nl))), U_(2) { } @@ -411,9 +413,11 @@ struct stepper : hpx::components::client_base // construct new instances/wrap existing steppers from other localities stepper() - : base_type(hpx::new_(hpx::find_here(), hpx::get_num_localities_sync())) + : base_type(hpx::new_ + (hpx::find_here(), hpx::get_num_localities_sync())) { - hpx::register_id_with_basename(stepper_basename, get_id(), hpx::get_locality_id()); + hpx::register_with_basename( + stepper_basename, get_id(), hpx::get_locality_id()); } stepper(hpx::future && id) diff --git a/examples/accumulator/accumulators/stubs/template_function_accumulator.hpp b/examples/accumulator/accumulators/stubs/template_function_accumulator.hpp index 303fd170eef2..25115e902330 100644 --- a/examples/accumulator/accumulators/stubs/template_function_accumulator.hpp +++ b/examples/accumulator/accumulators/stubs/template_function_accumulator.hpp @@ -63,7 +63,8 @@ namespace examples { namespace stubs static void add_sync(hpx::naming::id_type const& gid, T arg) { - typedef typename server::template_function_accumulator::add_action action_type; + typedef typename server::template_function_accumulator::add_action + action_type; hpx::async(gid, arg).get(); } diff --git a/examples/apex/CMakeLists.txt b/examples/apex/CMakeLists.txt index 4351734e3a96..cb41809060ea 100644 --- a/examples/apex/CMakeLists.txt +++ b/examples/apex/CMakeLists.txt @@ -9,6 +9,7 @@ set(example_programs apex_policy_engine_events apex_policy_engine_active_thread_count apex_balance + apex_fibonacci ) foreach(example_program ${example_programs}) diff --git a/examples/apex/fibonacci.cpp b/examples/apex/apex_fibonacci.cpp similarity index 65% rename from examples/apex/fibonacci.cpp rename to examples/apex/apex_fibonacci.cpp index fac278aedd8e..5456a933c741 100644 --- a/examples/apex/fibonacci.cpp +++ b/examples/apex/apex_fibonacci.cpp @@ -1,17 +1,17 @@ -/ -G////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2011 Bryce Lelbach // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //////////////////////////////////////////////////////////////////////////////// -/ggG/ Naive SMP version implemented with futures. +// Naive SMP version implemented with futures. #include #include +#include #include -#include +#include #include @@ -79,6 +79,8 @@ int hpx_main(boost::program_options::variables_map& vm) //[fib_main int main(int argc, char* argv[]) { + apex::apex_options::use_screen_output(true); + // Configure application-specific options boost::program_options::options_description desc_commandline("Usage: " HPX_APPLICATION_STRING " [options]"); @@ -89,23 +91,45 @@ int main(int argc, char* argv[]) "n value for the Fibonacci function") ; - std::set when = {apex::STARTUP, apex::SHUTDOWN, apex::NEW_NODE, apex::NEW_THREAD, - apex::START_EVENT, apex::STOP_EVENT, apex::SAMPLE_VALUE}; - apex::register_event_policy(when, [](void * e){return true;}, [](void * e){ - apex::event_data * evt = (apex::event_data *) e; - switch(evt->event_type_) { - case apex::APEX_STARTUP: std::cout << "Startup event" << std::endl; break; - case apex::APEX_SHUTDOWN: std::cout << "Shutdown event" << std::endl; break; - case apex::APEX_NEW_NODE: std::cout << "New node event" << std::endl; break; - case apex::APEX_NEW_THREAD: std::cout << "New thread event" << std::endl; break; - case apex::APEX_START_EVENT: std::cout << "Start event" << std::endl; break; - case apex::APEX_STOP_EVENT: std::cout << "Stop event" << std::endl; break; - case apex::APEX_SAMPLE_VALUE: std::cout << "Sample value event" << std::endl; break; - default: std::cout << "Unknown event" << std::endl; + std::set when = {APEX_STARTUP, APEX_SHUTDOWN, APEX_NEW_NODE, + APEX_NEW_THREAD, APEX_START_EVENT, APEX_STOP_EVENT, APEX_SAMPLE_VALUE}; + apex::register_policy(when, [](apex_context const& context)->int{ + switch(context.event_type) { + case APEX_STARTUP: { + std::cout << "Startup event" << std::endl; + break; + } + case APEX_SHUTDOWN: { + std::cout << "Shutdown event" << std::endl; + break; + } + case APEX_NEW_NODE: { + std::cout << "New node event" << std::endl; + break; + } + case APEX_NEW_THREAD: { + std::cout << "New thread event" << std::endl; + break; + } + case APEX_START_EVENT: { + std::cout << "Start event" << std::endl; + break; + } + case APEX_STOP_EVENT: { + std::cout << "Stop event" << std::endl; + break; + } + case APEX_SAMPLE_VALUE: { + std::cout << "Sample value event" << std::endl; + break; + } + default: { + std::cout << "Unknown event" << std::endl; + } } + return APEX_NOERROR; }); - // Initialize and run HPX return hpx::init(desc_commandline, argc, argv); } diff --git a/examples/apex/apex_policy_engine_active_thread_count.cpp b/examples/apex/apex_policy_engine_active_thread_count.cpp index b2703454089c..b94015dae23f 100644 --- a/examples/apex/apex_policy_engine_active_thread_count.cpp +++ b/examples/apex/apex_policy_engine_active_thread_count.cpp @@ -65,7 +65,10 @@ static const char * counter_name = "/threadqueue{locality#%d/total}/length"; id_type get_counter_id() { // Resolve the GID of the performances counter using it's symbolic name. boost::uint32_t const prefix = hpx::get_locality_id(); - //boost::format active_threads("/threads{locality#%d/total}/count/instantaneous/active"); + /* + boost::format + active_threads("/threads{locality#%d/total}/count/instantaneous/active"); + */ boost::format active_threads(counter_name); id_type id = get_counter(boost::str(active_threads % prefix)); return id; @@ -117,15 +120,16 @@ bool test_function(apex_context const& context) { //id_type id = get_counter_id(); counter_value value1 = performance_counter::get_value(counter_id); if (value1.get_value() % 2 == 1) { - return true; + return APEX_NOERROR; } else { - return false; + std::cerr << "Expecting an error message..." << std::endl; + return APEX_ERROR; } } catch(hpx::exception const& e) { std::cerr << "apex_policy_engine_active_thread_count: caught exception: " << e.what() << std::endl; - return false; + return APEX_ERROR; } } diff --git a/examples/apex/apex_policy_engine_events.cpp b/examples/apex/apex_policy_engine_events.cpp index 1576eef17bde..2ba1c296c2bf 100644 --- a/examples/apex/apex_policy_engine_events.cpp +++ b/examples/apex/apex_policy_engine_events.cpp @@ -88,7 +88,7 @@ int main(int argc, char* argv[]) const apex_event_type when = APEX_START_EVENT; apex::register_policy(when, [](apex_context const& context){ std::cout << "Start event!" << std::endl; - return true; + return APEX_NOERROR; }); // Initialize and run HPX diff --git a/examples/apex/apex_policy_engine_periodic.cpp b/examples/apex/apex_policy_engine_periodic.cpp index 1d136913f795..d53813d7b884 100644 --- a/examples/apex/apex_policy_engine_periodic.cpp +++ b/examples/apex/apex_policy_engine_periodic.cpp @@ -75,7 +75,7 @@ int hpx_main(boost::program_options::variables_map& vm) void register_policy(void) { apex::register_periodic_policy(1000, [](apex_context const& context) { std::cout << "Periodic policy!" << std::endl; - return true; + return APEX_NOERROR; }); } diff --git a/examples/diskperf/diskperf_ofs_pxfs_action.cpp b/examples/diskperf/diskperf_ofs_pxfs_action.cpp index e698123c8116..358d306d6fc0 100644 --- a/examples/diskperf/diskperf_ofs_pxfs_action.cpp +++ b/examples/diskperf/diskperf_ofs_pxfs_action.cpp @@ -173,8 +173,10 @@ RESULT write_files_test(ofs_test_info_type ofs_test_info, int proc) boost::shared_array num_written_array(new ssize_t[count * wfiles]); std::vector > futures; - boost::shared_array int_promise_array(new int_promise_type[count * wfiles]); - boost::shared_array promise_rt_ptr_array(new promise_rt_ptr_type[count * wfiles]); + boost::shared_array + int_promise_array(new int_promise_type[count * wfiles]); + boost::shared_array + promise_rt_ptr_array(new promise_rt_ptr_type[count * wfiles]); srand((unsigned)time(0)); for(ssize_t c = 0; c < bufsiz; c++) @@ -189,7 +191,8 @@ RESULT write_files_test(ofs_test_info_type ofs_test_info, int proc) int oflags; oflags = O_WRONLY|O_CREAT; - sprintf(filename, "%s/loc_%d_file%d.%ld", ofspath.c_str(), hpx::get_locality_id(), proc, i); + sprintf(filename, "%s/loc_%d_file%d.%ld", + ofspath.c_str(), hpx::get_locality_id(), proc, i); int_promise_type open_p; std::ostringstream sstream; @@ -253,8 +256,10 @@ RESULT write_files_test(ofs_test_info_type ofs_test_info, int proc) } r.real = ((double) end - (double) start) / (double) sysconf(_SC_CLK_TCK); - r.user = ((double) t2.tms_utime - (double) t1.tms_utime) / (double) sysconf(_SC_CLK_TCK); - r.sys = ((double) t2.tms_stime - (double) t1.tms_stime) / (double) sysconf(_SC_CLK_TCK); + r.user = ((double) t2.tms_utime - (double) t1.tms_utime) + / (double) sysconf(_SC_CLK_TCK); + r.sys = ((double) t2.tms_stime - (double) t1.tms_stime) + / (double) sysconf(_SC_CLK_TCK); for(uint64_t i=0; i num_read_array(new ssize_t[count * rfiles]); std::vector > futures; - boost::shared_array int_promise_array(new int_promise_type[count * rfiles]); - boost::shared_array promise_rt_ptr_array(new promise_rt_ptr_type[count * rfiles]); + boost::shared_array + int_promise_array(new int_promise_type[count * rfiles]); + boost::shared_array + promise_rt_ptr_array(new promise_rt_ptr_type[count * rfiles]); start = times(&t1); @@ -311,7 +318,8 @@ RESULT read_files_test(ofs_test_info_type ofs_test_info, int proc) int oflags; oflags = O_RDONLY; - sprintf(filename, "%s/loc_%d_file%d.%ld", ofspath.c_str(), hpx::get_locality_id(), proc, i); + sprintf(filename, "%s/loc_%d_file%d.%ld", + ofspath.c_str(), hpx::get_locality_id(), proc, i); int_promise_type open_p; std::ostringstream sstream; @@ -376,8 +384,10 @@ RESULT read_files_test(ofs_test_info_type ofs_test_info, int proc) r.real = ((double) end - (double) start) / (double) sysconf(_SC_CLK_TCK); - r.user = ((double) t2.tms_utime - (double) t1.tms_utime) / (double) sysconf(_SC_CLK_TCK); - r.sys = ((double) t2.tms_stime - (double) t1.tms_stime) / (double) sysconf(_SC_CLK_TCK); + r.user = ((double) t2.tms_utime - (double) t1.tms_utime) + / (double) sysconf(_SC_CLK_TCK); + r.sys = ((double) t2.tms_stime - (double) t1.tms_stime) + / (double) sysconf(_SC_CLK_TCK); for(uint64_t i=0; i 0) { - hpx::cout << (boost::format("%1% localities each has %2% threads, Reading %3% files") % localities.size() % procs % rfiles); + hpx::cout << (boost::format("%1% localities each has %2% threads, + Reading %3% files") % localities.size() % procs % rfiles); } else { - hpx::cout << (boost::format("%1% localities each has %2% threads, Writing %3% files") % localities.size() % procs % wfiles); + hpx::cout << (boost::format("%1% localities each has %2% threads, + Writing %3% files") % localities.size() % procs % wfiles); } char const* fmt = " with count %1% x buffer size %2%M: \n"; @@ -546,7 +559,8 @@ int hpx_main(variables_map& vm) if(rfiles > 0) { hpx::cout<<(boost::format("Aggregate Reading Throughput: %1% [MB/s]\n") % - (localities.size() * procs * rfiles * count * bufsiz / tt / (1024*1024))); + (localities.size() * procs * rfiles + * count * bufsiz / tt / (1024*1024))); hpx::cout<<(boost::format("\t Max Throughput per thread: %1% [MB/s]\n") % (rfiles * count * bufsiz / min_time / (1024*1024))); hpx::cout<<(boost::format("\t Min Throughput per thread: %1% [MB/s]\n") % @@ -555,7 +569,8 @@ int hpx_main(variables_map& vm) else { hpx::cout<<(boost::format("Aggregate Writing Throughput: %1% [MB/s]\n") % - (localities.size() * procs * wfiles * count * bufsiz / tt / (1024*1024))); + (localities.size() * procs * wfiles + * count * bufsiz / tt / (1024*1024))); hpx::cout<<(boost::format("\t Max Throughput per thread: %1% [MB/s]\n") % (wfiles * count * bufsiz / min_time / (1024*1024))); hpx::cout<<(boost::format("\t Min Throughput per thread: %1% [MB/s]\n") % @@ -578,7 +593,8 @@ int hpx_main(variables_map& vm) { for(uint64_t i = 0; i < fileno; ++i) { - sprintf(filename, "%s/loc_%d_file%d.%ld", ofspath.c_str(), loc, proc, i); + sprintf(filename, "%s/loc_%d_file%d.%ld", + ofspath.c_str(), loc, proc, i); pvfs_unlink(filename); } } diff --git a/examples/heartbeat/heartbeat.cpp b/examples/heartbeat/heartbeat.cpp index 337e5ef76d9a..fe984a6a27f1 100644 --- a/examples/heartbeat/heartbeat.cpp +++ b/examples/heartbeat/heartbeat.cpp @@ -138,6 +138,7 @@ int main(int argc, char* argv[]) cfg.push_back("hpx.run_hpx_main!=1"); hpx::util::function_nonser const empty; - return hpx::init(desc_commandline, argc, argv, cfg, empty, empty, hpx::runtime_mode_connect); + return hpx::init(desc_commandline, argc, argv, cfg, empty, + empty, hpx::runtime_mode_connect); } diff --git a/examples/heartbeat/hpx_counters.hpp b/examples/heartbeat/hpx_counters.hpp index d4b43d000f75..018efe683286 100644 --- a/examples/heartbeat/hpx_counters.hpp +++ b/examples/heartbeat/hpx_counters.hpp @@ -3,14 +3,17 @@ // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -/* This file was auto-generated from C:\CVS\hpx\hpx\examples\heartbeat\heartbeat.man by ctrpp.exe */ +/* This file was auto-generated from +C:\CVS\hpx\hpx\examples\heartbeat\heartbeat.man by ctrpp.exe */ #pragma once -EXTERN_C DECLSPEC_SELECTANY GUID HPXHeartBeatGuid = { 0x1178c091, 0x4a8d, 0x4657, 0xb6, 0x56, 0xce, 0x3, 0x0, 0x59, 0xc3, 0x4f }; +EXTERN_C DECLSPEC_SELECTANY GUID HPXHeartBeatGuid = + { 0x1178c091, 0x4a8d, 0x4657, 0xb6, 0x56, 0xce, 0x3, 0x0, 0x59, 0xc3, 0x4f }; -EXTERN_C DECLSPEC_SELECTANY GUID QueueLengthGuid = { 0x9a7a620e, 0x19d0, 0x4697, 0xb6, 0xfa, 0xa8, 0x3, 0x84, 0x5d, 0x73, 0x29 }; +EXTERN_C DECLSPEC_SELECTANY GUID QueueLengthGuid = + { 0x9a7a620e, 0x19d0, 0x4697, 0xb6, 0xfa, 0xa8, 0x3, 0x84, 0x5d, 0x73, 0x29 }; EXTERN_C DECLSPEC_SELECTANY HANDLE HPXHeartBeat = NULL; @@ -20,7 +23,9 @@ EXTERN_C DECLSPEC_SELECTANY struct { PERF_COUNTER_INFO Counter0; PERF_COUNTER_INFO Counter1; } QueueLengthInfo = { - { { 0x9a7a620e, 0x19d0, 0x4697, 0xb6, 0xfa, 0xa8, 0x3, 0x84, 0x5d, 0x73, 0x29 }, { 0x1178c091, 0x4a8d, 0x4657, 0xb6, 0x56, 0xce, 0x3, 0x0, 0x59, 0xc3, 0x4f }, 2, PERF_COUNTERSET_MULTI_AGGREGATE }, + { { 0x9a7a620e, 0x19d0, 0x4697, 0xb6, 0xfa, 0xa8, 0x3, 0x84, 0x5d, 0x73, 0x29 }, + { 0x1178c091, 0x4a8d, 0x4657, 0xb6, 0x56, 0xce, 0x3, 0x0, 0x59, 0xc3, 0x4f }, + 2, PERF_COUNTERSET_MULTI_AGGREGATE }, { 1, PERF_COUNTER_RAWCOUNT, 0, sizeof(ULONG), PERF_DETAIL_NOVICE, 0, 0 }, { 2, PERF_COUNTER_RAWCOUNT, 0, sizeof(ULONG), PERF_DETAIL_NOVICE, 0, 0 }, }; diff --git a/examples/heartbeat/win_perf_counters.cpp b/examples/heartbeat/win_perf_counters.cpp index 7f65b2da3db2..4e3fa300ef47 100644 --- a/examples/heartbeat/win_perf_counters.cpp +++ b/examples/heartbeat/win_perf_counters.cpp @@ -45,7 +45,8 @@ void install_windows_counters() return; } - avg_queue_counter = PerfCreateInstance(HPXHeartBeat, &QueueLengthGuid, L"Instance_2", 0); + avg_queue_counter = PerfCreateInstance + (HPXHeartBeat, &QueueLengthGuid, L"Instance_2", 0); if (avg_queue_counter == NULL) { std::cerr << "PerfCreateInstance for 'avg_queue_counter' failed" "with error code: " @@ -58,7 +59,8 @@ void install_windows_counters() void update_windows_counters(boost::uint64_t value) { // Set raw counter data for queue length. - ULONG status = PerfSetULongCounterValue(HPXHeartBeat, queue_counter, 1, ULONG(value)); + ULONG status = PerfSetULongCounterValue + (HPXHeartBeat, queue_counter, 1, ULONG(value)); if (status != ERROR_SUCCESS) { std::cerr << "PerfSetCounterRefValue for 'sum_queue_counter' failed " "with error code: " diff --git a/examples/jacobi/jacobi_component/row_range.hpp b/examples/jacobi/jacobi_component/row_range.hpp index 19728f1b2f79..834f552bf4dc 100644 --- a/examples/jacobi/jacobi_component/row_range.hpp +++ b/examples/jacobi/jacobi_component/row_range.hpp @@ -69,7 +69,8 @@ namespace jacobi row_range() {} - row_range(boost::intrusive_ptr values, std::ptrdiff_t b, std::ptrdiff_t e) + row_range(boost::intrusive_ptr values, + std::ptrdiff_t b, std::ptrdiff_t e) : begin_(b) , end_(e) , values_(values) @@ -115,7 +116,8 @@ namespace jacobi void save(Archive & ar, unsigned) const { HPX_ASSERT(values_); - std::vector tmp(values_->v_.begin() + begin_, values_->v_.begin() + end_); + std::vector tmp(values_->v_.begin() + + begin_, values_->v_.begin() + end_); ar & tmp; } diff --git a/examples/jacobi/jacobi_component/server/solver.hpp b/examples/jacobi/jacobi_component/server/solver.hpp index 887052a85ec2..fdafbbc26ffa 100644 --- a/examples/jacobi/jacobi_component/server/solver.hpp +++ b/examples/jacobi/jacobi_component/server/solver.hpp @@ -51,7 +51,8 @@ namespace jacobi } } - solver(component_type * back_ptr, grid const & g, std::size_t nx, std::size_t line_block) + solver(component_type * back_ptr, grid const & g, + std::size_t nx, std::size_t line_block) : base_type(back_ptr) , ny(g.rows.size()) , nx(nx) @@ -134,7 +135,8 @@ namespace jacobi double time_elapsed = t.elapsed(); hpx::cout << nx << "x" << ny << " " - << ((double((nx-2)*(ny-2) * max_iterations)/1e6)/time_elapsed) << " MLUPS\n" << hpx::flush; + << ((double((nx-2)*(ny-2) * max_iterations)/1e6)/time_elapsed) + << " MLUPS\n" << hpx::flush; } HPX_DEFINE_COMPONENT_ACTION(solver, run, run_action); diff --git a/examples/jacobi/jacobi_component/server/stencil_iterator.hpp b/examples/jacobi/jacobi_component/server/stencil_iterator.hpp index a684584be65a..2cd29d5daed9 100644 --- a/examples/jacobi/jacobi_component/server/stencil_iterator.hpp +++ b/examples/jacobi/jacobi_component/server/stencil_iterator.hpp @@ -92,7 +92,8 @@ namespace jacobi ); HPX_DEFINE_COMPONENT_ACTION(stencil_iterator, init, init_action); - HPX_DEFINE_COMPONENT_ACTION(stencil_iterator, setup_boundary, setup_boundary_action); + HPX_DEFINE_COMPONENT_ACTION(stencil_iterator, + setup_boundary, setup_boundary_action); HPX_DEFINE_COMPONENT_ACTION(stencil_iterator, step, step_action); HPX_DEFINE_COMPONENT_ACTION(stencil_iterator, get, get_action); diff --git a/examples/jacobi/jacobi_component/stencil_iterator.hpp b/examples/jacobi/jacobi_component/stencil_iterator.hpp index 5fcd62e44fda..a60376a2de68 100644 --- a/examples/jacobi/jacobi_component/stencil_iterator.hpp +++ b/examples/jacobi/jacobi_component/stencil_iterator.hpp @@ -29,7 +29,8 @@ namespace jacobi , std::size_t ny_ , std::size_t l ); - hpx::lcos::future setup_boundary(stencil_iterator const & top, stencil_iterator const & bottom); + hpx::lcos::future setup_boundary(stencil_iterator const & top, + stencil_iterator const & bottom); hpx::lcos::future step(); diff --git a/examples/jacobi_smp/jacobi.hpp b/examples/jacobi_smp/jacobi.hpp index 02b504a7cca0..596b1d13a503 100644 --- a/examples/jacobi_smp/jacobi.hpp +++ b/examples/jacobi_smp/jacobi.hpp @@ -44,7 +44,8 @@ namespace jacobi_smp { << ((double((n-2)*(n-2) * iterations)/1e6)/elapsed) << " MLUPS/s\n"; } - inline void output_grid(std::string filename, std::vector const & grid, std::size_t n) + inline void output_grid(std::string filename, + std::vector const & grid, std::size_t n) { if(!filename.empty()) { diff --git a/examples/jacobi_smp/jacobi_hpx.cpp b/examples/jacobi_smp/jacobi_hpx.cpp index 71b78d45bedc..500dceb00f54 100644 --- a/examples/jacobi_smp/jacobi_hpx.cpp +++ b/examples/jacobi_smp/jacobi_hpx.cpp @@ -13,7 +13,8 @@ namespace jacobi_smp { - void jacobi_kernel_wrap(range const & y_range, std::size_t n, std::vector & dst, std::vector const & src) + void jacobi_kernel_wrap(range const & y_range, std::size_t n, + std::vector & dst, std::vector const & src) { for(std::size_t y = y_range.begin(); y < y_range.end(); ++y) { diff --git a/examples/jacobi_smp/jacobi_nonuniform.cpp b/examples/jacobi_smp/jacobi_nonuniform.cpp index 4897c6b2de7a..6c9937ce4eca 100644 --- a/examples/jacobi_smp/jacobi_nonuniform.cpp +++ b/examples/jacobi_smp/jacobi_nonuniform.cpp @@ -66,7 +66,8 @@ void init(jacobi_smp::crs_matrix & M, std::size_t dim, std::size_t non_z M.rows.push_back(0); } -void add_entry(jacobi_smp::crs_matrix & M, std::size_t & row, std::size_t & n, std::size_t j, std::size_t i, double v) +void add_entry(jacobi_smp::crs_matrix & M, std::size_t & row, + std::size_t & n, std::size_t j, std::size_t i, double v) { M.values.push_back(v); M.indices.push_back(j); @@ -106,26 +107,30 @@ int hpx_main(variables_map &vm) qi::phrase_parse( begin , end - , (qi::int_[phx::ref(dim) = qi::_1] >> qi::int_ >> qi::int_[phx::ref(non_zero_entries) = qi::_1]) + , (qi::int_[phx::ref(dim) = qi::_1] >> qi::int_ >> + qi::int_[phx::ref(non_zero_entries) = qi::_1]) [phx::bind(init, phx::ref(A), dim, non_zero_entries)] >> *( // entry (qi::int_ >> qi::int_ >> qi::double_) - [phx::bind(add_entry, phx::ref(A), phx::ref(current_row), phx::ref(non_zero_row), qi::_1, qi::_2, qi::_3)] + [phx::bind(add_entry, phx::ref(A), phx::ref(current_row), + phx::ref(non_zero_row), qi::_1, qi::_2, qi::_3)] ) , qi::space | (qi::lit("%") >> *(!qi::eol >> qi::char_) >> qi::eol) ); if(dim == 0) { - std::cerr << "Parsed zero non zero values in matrix file " << matrix << "\n"; + std::cerr << "Parsed zero non zero values in matrix file " + << matrix << "\n"; #if !defined(JACOBI_SMP_NO_HPX) hpx::finalize(); #endif return 1; } - std::cout << "A: " << dim << "x" << dim << " number of non zeros: " << non_zero_entries << "\n"; + std::cout << "A: " << dim << "x" << dim << " number of non zeros: " + << non_zero_entries << "\n"; } if(vm.count("vector")) { @@ -173,7 +178,8 @@ int hpx_main(variables_map &vm) std::cout << "\tmax " << max_per_row << "\n"; std::cout << "\tmin " << min_per_row << "\n"; std::cout << "\tmean " << mean_per_row/double(b.size()) << "\n"; - std::cout << "Density is: " << double(A.values.size())/double(b.size() * b.size()) << "\n"; + std::cout << "Density is: " << double(A.values.size()) + /double(b.size() * b.size()) << "\n"; } else { diff --git a/examples/jacobi_smp/jacobi_nonuniform_hpx.cpp b/examples/jacobi_smp/jacobi_nonuniform_hpx.cpp index 9baccc7f48a3..5f2ef6b2db81 100644 --- a/examples/jacobi_smp/jacobi_nonuniform_hpx.cpp +++ b/examples/jacobi_smp/jacobi_nonuniform_hpx.cpp @@ -15,7 +15,8 @@ namespace jacobi_smp { void jacobi_kernel_wrap( range const & r, crs_matrix const & A, - std::vector & x_dst, std::vector const & x_src, std::vector const & b) + std::vector & x_dst, + std::vector const & x_src, std::vector const & b) { for(std::size_t row = r.begin(); row < r.end(); ++row) { @@ -59,7 +60,8 @@ namespace jacobi_smp { { if(block_ranges[j].begin() <= idx && idx < block_ranges[j].end()) { - if(std::find(dependencies[b].begin(), dependencies[b].end(), j) == dependencies[b].end()) + if(std::find(dependencies[b].begin(), + dependencies[b].end(), j) == dependencies[b].end()) { dependencies[b].push_back(j); } @@ -71,8 +73,10 @@ namespace jacobi_smp { } typedef std::vector > future_vector; - boost::shared_ptr deps_dst(new future_vector(dependencies.size(), hpx::make_ready_future())); - boost::shared_ptr deps_src(new future_vector(dependencies.size(), hpx::make_ready_future())); + boost::shared_ptr deps_dst + (new future_vector(dependencies.size(), hpx::make_ready_future())); + boost::shared_ptr deps_src + (new future_vector(dependencies.size(), hpx::make_ready_future())); hpx::util::high_resolution_timer t; for(std::size_t iter = 0; iter < iterations; ++iter) diff --git a/examples/performance_counters/simplest_performance_counter.cpp b/examples/performance_counters/simplest_performance_counter.cpp index 434bafe640ed..7cbedd2205a2 100644 --- a/examples/performance_counters/simplest_performance_counter.cpp +++ b/examples/performance_counters/simplest_performance_counter.cpp @@ -24,9 +24,12 @@ void register_counter_type() { // Call the HPX API function to register the counter type. hpx::performance_counters::install_counter_type( - "/test/data", // counter type name - &some_performance_data, // function providing counter data - "returns a linearly increasing counter value" // description text + "/test/data", + // counter type name + &some_performance_data, + // function providing counter data + "returns a linearly increasing counter value" + // description text ); } diff --git a/examples/qt/widget.cpp b/examples/qt/widget.cpp index 79acc41f49aa..ff7a846cb738 100644 --- a/examples/qt/widget.cpp +++ b/examples/qt/widget.cpp @@ -27,7 +27,8 @@ widget::widget(boost::function callback, QWidget *p QSpinBox * thread_number_widget = new QSpinBox; thread_number_widget->setValue(50); thread_number_widget->setRange(1, 100000); - QObject::connect(thread_number_widget, SIGNAL(valueChanged(int)), this, SLOT(set_threads(int))); + QObject::connect(thread_number_widget, SIGNAL(valueChanged(int)), + this, SLOT(set_threads(int))); run_button = new QPushButton("Run"); QObject::connect(run_button, SIGNAL(clicked(bool)), this, SLOT(run_clicked(bool))); diff --git a/examples/qt/widget.hpp b/examples/qt/widget.hpp index 2f543a39fc8e..19cebd7ee188 100644 --- a/examples/qt/widget.hpp +++ b/examples/qt/widget.hpp @@ -21,7 +21,8 @@ class widget Q_OBJECT public: - widget(boost::function callback, QWidget *parent = 0); + widget(boost::function callback, + QWidget *parent = 0); void add_label(std::size_t i, double t); diff --git a/examples/quickstart/1d_wave_equation.cpp b/examples/quickstart/1d_wave_equation.cpp index 6d534d740cbd..9c4539f4f109 100644 --- a/examples/quickstart/1d_wave_equation.cpp +++ b/examples/quickstart/1d_wave_equation.cpp @@ -11,7 +11,8 @@ // // D^2 U / Dt^2 = c^2 D^2 U / Dx^2 // -// The parameter alpha = c*dt/dx must be less than 1 to ensure the stability of the algorithm. +// The parameter alpha = c*dt/dx must be less than 1 to ensure the stability +// of the algorithm. // Discretizing the equation and solving for U(t+dt,x) yields // alpha^2 * (U(t,x+dx)+U(t,x-dx))+2(1-alpha^2)*U(t,x) - U(t-dt,x) // @@ -203,7 +204,8 @@ int hpx_main(variables_map& vm) // check that alpha_squared satisfies the stability condition if (0.25 < alpha_squared) { - cout << (("alpha^2 = (c*dt/dx)^2 should be less than 0.25 for stability!\n"))<< flush; + cout << (("alpha^2 = (c*dt/dx)^2 should be less than 0.25 for stability!\n")) + << flush; } u = std::vector >(nt, std::vector(nx)); diff --git a/examples/quickstart/error_handling.cpp b/examples/quickstart/error_handling.cpp index 762963b7021b..d37ba5f365df 100644 --- a/examples/quickstart/error_handling.cpp +++ b/examples/quickstart/error_handling.cpp @@ -60,10 +60,12 @@ int hpx_main() hpx::cout << "{file}: " << hpx::get_error_file_name(e) << "\n"; hpx::cout << "{line}: " << hpx::get_error_line_number(e) << "\n"; hpx::cout << "{os-thread}: " << hpx::get_error_os_thread(e) << "\n"; - hpx::cout << "{thread-id}: " << std::hex << hpx::get_error_thread_id(e) << "\n"; + hpx::cout << "{thread-id}: " << std::hex << hpx::get_error_thread_id(e) + << "\n"; hpx::cout << "{thread-description}: " << hpx::get_error_thread_description(e) << "\n"; - hpx::cout << "{state}: " << std::hex << hpx::get_error_state(e) << "\n"; + hpx::cout << "{state}: " << std::hex << hpx::get_error_state(e) + << "\n"; hpx::cout << "{stack-trace}: " << hpx::get_error_backtrace(e) << "\n"; hpx::cout << "{env}: " << hpx::get_error_env(e) << "\n"; } @@ -119,14 +121,17 @@ int hpx_main() hpx::cout << "{locality-id}: " << hpx::get_error_locality_id(ec) << "\n"; hpx::cout << "{hostname}: " << hpx::get_error_host_name(ec) << "\n"; hpx::cout << "{pid}: " << hpx::get_error_process_id(ec) << "\n"; - hpx::cout << "{function}: " << hpx::get_error_function_name(ec) << "\n"; + hpx::cout << "{function}: " << hpx::get_error_function_name(ec) + << "\n"; hpx::cout << "{file}: " << hpx::get_error_file_name(ec) << "\n"; hpx::cout << "{line}: " << hpx::get_error_line_number(ec) << "\n"; hpx::cout << "{os-thread}: " << hpx::get_error_os_thread(ec) << "\n"; - hpx::cout << "{thread-id}: " << std::hex << hpx::get_error_thread_id(ec) << "\n"; + hpx::cout << "{thread-id}: " << std::hex + << hpx::get_error_thread_id(ec) << "\n"; hpx::cout << "{thread-description}: " << hpx::get_error_thread_description(ec) << "\n\n"; - hpx::cout << "{state}: " << std::hex << hpx::get_error_state(ec) << "\n"; + hpx::cout << "{state}: " << std::hex << hpx::get_error_state(ec) + << "\n"; hpx::cout << "{stack-trace}: " << hpx::get_error_backtrace(ec) << "\n"; hpx::cout << "{env}: " << hpx::get_error_env(ec) << "\n"; } diff --git a/examples/quickstart/fibonacci_futures.cpp b/examples/quickstart/fibonacci_futures.cpp index 0d7ad22c2100..4533ca1ce14d 100644 --- a/examples/quickstart/fibonacci_futures.cpp +++ b/examples/quickstart/fibonacci_futures.cpp @@ -387,7 +387,8 @@ int hpx_main(boost::program_options::variables_map& vm) } boost::uint64_t d = hpx::util::high_resolution_clock::now() - start; - char const* fmt = "fibonacci_future_when_all(%1%) == %2%,elapsed time:,%3%,[s]\n"; + char const* fmt = + "fibonacci_future_when_all(%1%) == %2%,elapsed time:,%3%,[s]\n"; std::cout << (boost::format(fmt) % n % r % (d / max_runs)); executed_one = true; @@ -406,7 +407,8 @@ int hpx_main(boost::program_options::variables_map& vm) } boost::uint64_t d = hpx::util::high_resolution_clock::now() - start; - char const* fmt = "fibonacci_future_unwrapped_when_all(%1%) == %2%,elapsed time:,%3%,[s]\n"; + char const* fmt = + "fibonacci_future_unwrapped_when_all(%1%) == %2%,elapsed time:,%3%,[s]\n"; std::cout << (boost::format(fmt) % n % r % (d / max_runs)); executed_one = true; @@ -425,7 +427,8 @@ int hpx_main(boost::program_options::variables_map& vm) } boost::uint64_t d = hpx::util::high_resolution_clock::now() - start; - char const* fmt = "fibonacci_future_all(%1%) == %2%,elapsed time,%3%,[s]\n"; + char const* fmt = + "fibonacci_future_all(%1%) == %2%,elapsed time,%3%,[s]\n"; std::cout << (boost::format(fmt) % n % r % (d / max_runs)); executed_one = true; @@ -444,7 +447,8 @@ int hpx_main(boost::program_options::variables_map& vm) } boost::uint64_t d = hpx::util::high_resolution_clock::now() - start; - char const* fmt = "fibonacci_future_all_when_all(%1%) == %2%,elapsed time:,%3%,[s]\n"; + char const* fmt = + "fibonacci_future_all_when_all(%1%) == %2%,elapsed time:,%3%,[s]\n"; std::cout << (boost::format(fmt) % n % r % (d / max_runs)); executed_one = true; diff --git a/examples/quickstart/fibonacci_futures_distributed.cpp b/examples/quickstart/fibonacci_futures_distributed.cpp index ff1397eee3b3..7872438fe1cf 100644 --- a/examples/quickstart/fibonacci_futures_distributed.cpp +++ b/examples/quickstart/fibonacci_futures_distributed.cpp @@ -150,7 +150,8 @@ int hpx_main(boost::program_options::variables_map& vm) // double d = double(hpx::util::high_resolution_clock::now() - start) / 1.e9; boost::uint64_t d = hpx::util::high_resolution_clock::now() - start; char const* fmt = "fibonacci_future(%1%) == %2%,elapsed time:,%3%,[s],%4%\n"; - std::cout << (boost::format(fmt) % n % r % (d / max_runs) % next_locality.load()); + std::cout << (boost::format(fmt) % n % r % (d / max_runs) + % next_locality.load()); get_serial_execution_count_action serial_count; for (hpx::id_type const& loc : hpx::find_all_localities()) diff --git a/examples/quickstart/interest_calculator.cpp b/examples/quickstart/interest_calculator.cpp index cd6b2fabf840..a01f8ebe227c 100644 --- a/examples/quickstart/interest_calculator.cpp +++ b/examples/quickstart/interest_calculator.cpp @@ -111,7 +111,8 @@ int main(int argc, char ** argv) ("principal", value()->default_value(1000), "The principal [$]") ("rate", value()->default_value(7), "The interest rate [%]") ("cp", value()->default_value(12), "The compound period [months]") - ("time", value()->default_value(12*30), "The time money is invested [months]") + ("time", value()->default_value(12*30), + "The time money is invested [months]") ; return hpx::init(cmdline, argc, argv); diff --git a/examples/quickstart/non_atomic_rma.cpp b/examples/quickstart/non_atomic_rma.cpp index 6c0a47a46bbc..22ade3eca595 100644 --- a/examples/quickstart/non_atomic_rma.cpp +++ b/examples/quickstart/non_atomic_rma.cpp @@ -123,14 +123,16 @@ int hpx_main(po::variables_map &vm) for (int i=0;i result( components::stubs::memory_block::get(n[i].get()) ); - std::cout << " Result index: " << i << " value : " << result->val_ << std::endl; + std::cout << " Result index: " << i << " value : " + << result->val_ << std::endl; } // What is the elapsed time? elapsed = t.elapsed(); // Print out a completion message. The correct answer is 12 for this example. - std::cout << "Achieved result of " << result << " in " << elapsed << " seconds."<< std::endl; + std::cout << "Achieved result of " << result << " in " + << elapsed << " seconds."<< std::endl; } // Initiate shutdown of the runtime systems on all localities diff --git a/examples/quickstart/pingpong.cpp b/examples/quickstart/pingpong.cpp index acf0b3a16b0a..94ddeeeebb3e 100644 --- a/examples/quickstart/pingpong.cpp +++ b/examples/quickstart/pingpong.cpp @@ -91,9 +91,11 @@ int hpx_main(boost::program_options::variables_map &b_arg) if (verbose) { std::cout << "[hpx_pingpong]" << std::endl << "total_time(secs)=" << time << std::endl - << "vsize=" << vsize << " = " << vsize * sizeof(double) << " Bytes" << std::endl + << "vsize=" << vsize << " = " << vsize * sizeof(double) + << " Bytes" << std::endl << "bandwidth(MiB/s)=" - << (((vsize * sizeof(double) * numiter) / time) / 1024) / 1024 << std::endl + << (((vsize * sizeof(double) * numiter) / time) / 1024) / 1024 + << std::endl << "localities=" << localities.size() << std::endl << "numiter=" << numiter << std::endl; } @@ -126,7 +128,8 @@ int hpx_main(boost::program_options::variables_map &b_arg) std::cout << "[hpx_pingpong]" << ":total_time(secs)=" << time << ":vsize=" << vsize - << ":bandwidth(GB/s)=" << (vsize * sizeof(double) * numiter) / (time * 1024 * 1024) + << ":bandwidth(GB/s)=" << (vsize * sizeof(double) * numiter) + / (time * 1024 * 1024) << ":localities=" << localities.size() << ":numiter=" << numiter << std::endl; } diff --git a/examples/random_mem_access/random_mem_access/server/random_mem_access.hpp b/examples/random_mem_access/random_mem_access/server/random_mem_access.hpp index e330c4e1d41a..049589956b33 100644 --- a/examples/random_mem_access/random_mem_access/server/random_mem_access.hpp +++ b/examples/random_mem_access/random_mem_access/server/random_mem_access.hpp @@ -21,7 +21,8 @@ namespace hpx { namespace components { namespace server { /////////////////////////////////////////////////////////////////////////// - /// \class random_mem_access random_mem_access.hpp hpx/components/random_mem_access.hpp + /// \class random_mem_access random_mem_access.hpp + /// hpx/components/random_mem_access.hpp /// /// The random_mem_access is a small example components demonstrating /// the main principles of writing your own components. It exposes 4 diff --git a/examples/random_mem_access/random_mem_access/stubs/random_mem_access.hpp b/examples/random_mem_access/random_mem_access/stubs/random_mem_access.hpp index 1152b462cd07..a37802f329db 100644 --- a/examples/random_mem_access/random_mem_access/stubs/random_mem_access.hpp +++ b/examples/random_mem_access/random_mem_access/stubs/random_mem_access.hpp @@ -65,7 +65,8 @@ namespace hpx { namespace components { namespace stubs /////////////////////////////////////////////////////////////////////// // exposed functionality of this component - /// Initialize the simple_accumulator value of the server#simple_accumulator instance + /// Initialize the simple_accumulator + /// value of the server#simple_accumulator instance /// with the given \a gid static void init(naming::id_type gid,int i) { diff --git a/examples/sheneos/sheneos/interpolator.cpp b/examples/sheneos/sheneos/interpolator.cpp index 701d4506b326..bfaa038ab77b 100644 --- a/examples/sheneos/sheneos/interpolator.cpp +++ b/examples/sheneos/sheneos/interpolator.cpp @@ -48,7 +48,8 @@ namespace sheneos } /////////////////////////////////////////////////////////////////////////// - bool get_shutdown(hpx::util::function_nonser& shutdown_func, bool& pre_shutdown) + bool get_shutdown(hpx::util::function_nonser& shutdown_func, + bool& pre_shutdown) { shutdown_func = shutdown; pre_shutdown = false; // run this as late as possible @@ -240,7 +241,8 @@ namespace sheneos // Create the config object locally. hpx::naming::id_type config_id = hpx::find_locality(configuration::get_component_type()); - cfg_ = configuration(config_id, datafilename, symbolic_name_base, num_localities); + cfg_ = configuration(config_id, datafilename, symbolic_name_base, + num_localities); hpx::agas::register_name(symbolic_name_base, cfg_.get_id()); if (symbolic_name_base[symbolic_name_base.size() - 1] != '/') diff --git a/examples/sheneos/sheneos/server/partition3d.cpp b/examples/sheneos/sheneos/server/partition3d.cpp index 094c8c4423cf..d251dca1d985 100644 --- a/examples/sheneos/sheneos/server/partition3d.cpp +++ b/examples/sheneos/sheneos/server/partition3d.cpp @@ -174,8 +174,10 @@ namespace sheneos { namespace server std::size_t idx_logrho = get_index(dimension::rho, logrho); double delta_ye = (ye - ye_values_[idx_ye]) / delta_[dimension::ye]; - double delta_logtemp = (logtemp - logtemp_values_[idx_logtemp]) / delta_[dimension::temp]; - double delta_logrho = (logrho - logrho_values_[idx_logrho]) / delta_[dimension::rho]; + double delta_logtemp = (logtemp - logtemp_values_[idx_logtemp]) + / delta_[dimension::temp]; + double delta_logrho = (logrho - logrho_values_[idx_logrho]) + / delta_[dimension::rho]; std::vector results; results.reserve(19); @@ -255,8 +257,10 @@ namespace sheneos { namespace server std::size_t idx_logrho = get_index(dimension::rho, logrho); double delta_ye = (ye - ye_values_[idx_ye]) / delta_[dimension::ye]; - double delta_logtemp = (logtemp - logtemp_values_[idx_logtemp]) / delta_[dimension::temp]; - double delta_logrho = (logrho - logrho_values_[idx_logrho]) / delta_[dimension::rho]; + double delta_logtemp = (logtemp - logtemp_values_[idx_logtemp]) + / delta_[dimension::temp]; + double delta_logrho = (logrho - logrho_values_[idx_logrho]) + / delta_[dimension::rho]; if (detail::more_than_one_value_requested(eosvalue)) { HPX_THROW_EXCEPTION(hpx::bad_parameter, diff --git a/examples/sheneos/sheneos/server/partition3d.hpp b/examples/sheneos/sheneos/server/partition3d.hpp index 7cd8c22706cc..2e95a5ee4de5 100644 --- a/examples/sheneos/sheneos/server/partition3d.hpp +++ b/examples/sheneos/sheneos/server/partition3d.hpp @@ -65,7 +65,8 @@ namespace sheneos { namespace server #if SHENEOS_SUPPORT_FULL_API // Chemical potentials. muhat = 0x00000100, ///< mu_n - mu_p - mu_e = 0x00000200, ///< electron chemical potential including electron rest mass + mu_e = 0x00000200, ///< electron chemical potential + ///< including electron rest mass mu_p = 0x00000400, ///< proton chemical potential mu_n = 0x00000800, ///< neutron chemical potential // Compositions. diff --git a/examples/sheneos/sheneos_compare.cpp b/examples/sheneos/sheneos_compare.cpp index 205205495110..3e3cb7519be5 100644 --- a/examples/sheneos/sheneos_compare.cpp +++ b/examples/sheneos/sheneos_compare.cpp @@ -28,9 +28,12 @@ int omp_thread_count() { extern "C" {void FNAME(read_nuc_table)(); } -extern "C" {void FNAME(nuc_eos_short)(double *xrho,double *xtemp,double *xye,double *xenr, - double *xprs,double *xent,double *xcs2,double *xdedt, - double *xdpderho,double *xdpdrhoe,double *xmunu,int *keytemp,int *keyerr,double *rfeps); } +extern "C" {void FNAME(nuc_eos_short)(double *xrho,double *xtemp,double *xye, + double *xenr, + double *xprs,double *xent,double *xcs2, + double *xdedt, + double *xdpderho,double *xdpdrhoe,double *xmunu, + int *keytemp,int *keyerr,double *rfeps); } char const* const shen_symbolic_name = "/sheneos/interpolator_test"; @@ -91,7 +94,8 @@ void test_sheneos(std::size_t num_ye_points, std::size_t num_temp_points, std::size_t nthreads = omp_thread_count(); //std::size_t nthreads = omp_get_num_threads(); std::cout << " Number of OMP threads " << nthreads << std::endl; - std::cout << " Problem Size: Ye " << sequence_ye.size() << " T " << sequence_temp.size() << " R " << sequence_rho.size() << std::endl; + std::cout << " Problem Size: Ye " << sequence_ye.size() << " T " + << sequence_temp.size() << " R " << sequence_rho.size() << std::endl; /////////////////////////////////////////////////////////////////////////// // We want to avoid invoking the same evaluation sequence on all localities diff --git a/examples/thread_aware_timer/thread_aware_timer.cpp b/examples/thread_aware_timer/thread_aware_timer.cpp index 30b24fe70e04..192f14a49ec8 100644 --- a/examples/thread_aware_timer/thread_aware_timer.cpp +++ b/examples/thread_aware_timer/thread_aware_timer.cpp @@ -15,7 +15,8 @@ int main(int argc, char* argv[]) { hpx::util::thread_aware_timer tat; - double sum_samples = 0, min_sample = (std::numeric_limits::max)(), max_sample = 0; + double sum_samples = 0, min_sample = (std::numeric_limits::max) + (), max_sample = 0; for (int i = 0; i < NUMTESTS; ++i) { hpx::util::high_resolution_timer t; tat.elapsed(); diff --git a/examples/throttle/throttle_client.cpp b/examples/throttle/throttle_client.cpp index 0a7ed5d4e0e5..f00fc26b809f 100644 --- a/examples/throttle/throttle_client.cpp +++ b/examples/throttle/throttle_client.cpp @@ -34,7 +34,8 @@ int hpx_main(variables_map& vm) // Try to connect to existing throttle instance, create a new one if // this fails. char const* throttle_component_name = "/throttle/0"; - hpx::naming::id_type gid = hpx::agas::resolve_name(throttle_component_name).get(); + hpx::naming::id_type gid = + hpx::agas::resolve_name(throttle_component_name).get(); throttle::throttle t; if (!t.get_id()) { std::vector localities = diff --git a/examples/transpose/transpose_await.cpp b/examples/transpose/transpose_await.cpp index 424844e0a016..d62497ea94c4 100644 --- a/examples/transpose/transpose_await.cpp +++ b/examples/transpose/transpose_await.cpp @@ -138,7 +138,7 @@ struct block block() {} block(boost::uint64_t id, const char * base_name) - : base_type(hpx::find_id_from_basename(base_name, id)) + : base_type(hpx::find_from_basename(base_name, id)) { get_gid(); } @@ -146,7 +146,7 @@ struct block block(boost::uint64_t id, boost::uint64_t size, const char * base_name) : base_type(hpx::new_(hpx::find_here(), size)) { - hpx::register_id_with_basename(base_name, get_gid(), id); + hpx::register_with_basename(base_name, get_gid(), id); } hpx::future diff --git a/examples/transpose/transpose_block.cpp b/examples/transpose/transpose_block.cpp index 04a4bec9cee1..e2c81e8cbf99 100644 --- a/examples/transpose/transpose_block.cpp +++ b/examples/transpose/transpose_block.cpp @@ -138,7 +138,7 @@ struct block block() {} block(boost::uint64_t id, const char * base_name) - : base_type(hpx::find_id_from_basename(base_name, id)) + : base_type(hpx::find_from_basename(base_name, id)) { get_id(); } @@ -146,7 +146,7 @@ struct block block(boost::uint64_t id, boost::uint64_t size, const char * base_name) : base_type(hpx::new_(hpx::find_here(), size)) { - hpx::register_id_with_basename(base_name, get_id(), id); + hpx::register_with_basename(base_name, get_id(), id); } hpx::future get_sub_block(boost::uint64_t offset, boost::uint64_t size) diff --git a/examples/transpose/transpose_serial_block.cpp b/examples/transpose/transpose_serial_block.cpp index 0ac4533f32cb..b15c0f1a29ab 100644 --- a/examples/transpose/transpose_serial_block.cpp +++ b/examples/transpose/transpose_serial_block.cpp @@ -88,7 +88,8 @@ int hpx_main(boost::program_options::variables_map& vm) const boost::uint64_t from_phase = b; const boost::uint64_t A_offset = from_phase * block_size; const boost::uint64_t B_offset = phase * block_size; - transpose(&A[from_block][A_offset], &B[b][B_offset], block_order, tile_size); + transpose(&A[from_block][A_offset], &B[b][B_offset], + block_order, tile_size); } } @@ -110,7 +111,8 @@ int hpx_main(boost::program_options::variables_map& vm) if(errsq < epsilon) { std::cout << "Solution validates\n"; - avgtime = avgtime/static_cast((std::max)(iterations-1, static_cast(1))); + avgtime = avgtime/static_cast((std::max) + (iterations-1, static_cast(1))); std::cout << "Rate (MB/s): " << 1.e-6 * bytes/mintime << ", " << "Avg time (s): " << avgtime << ", " diff --git a/examples/tuplespace/central_tuplespace/server/tuples_warehouse.hpp b/examples/tuplespace/central_tuplespace/server/tuples_warehouse.hpp index e3b6491b429d..e72b44a2012a 100644 --- a/examples/tuplespace/central_tuplespace/server/tuples_warehouse.hpp +++ b/examples/tuplespace/central_tuplespace/server/tuples_warehouse.hpp @@ -72,7 +72,8 @@ namespace examples { namespace server if(tp.empty()) { - return read_random_tuple(); // return random results for an empty tuple + return read_random_tuple(); + // return random results for an empty tuple } matched_indices_type matched_indices; @@ -94,7 +95,8 @@ namespace examples { namespace server if(tp.empty()) { - return take_random_tuple(); // return random results for an empty tuple + return take_random_tuple(); + // return random results for an empty tuple } matched_indices_type matched_indices; @@ -126,13 +128,17 @@ namespace examples { namespace server continue; // will match any record } - typedef std::pair equal_range_type; + typedef std::pair + equal_range_type; typedef const std::pair pair_type; - equal_range_type found_range = tuple_fields_[pos].field_index_map_.equal_range(*it); + equal_range_type found_range = + tuple_fields_[pos].field_index_map_.equal_range(*it); - if(found_range.first == tuple_fields_[pos].field_index_map_.end()) // no match + if(found_range.first == tuple_fields_[pos].field_index_map_.end()) + // no match { return empty_set; // empty } @@ -258,17 +264,23 @@ namespace examples { namespace server struct tuple_field_container { - typedef examples::server::tuples_warehouse::hash_elem_functor hash_elem_functor; + typedef examples::server + ::tuples_warehouse::hash_elem_functor hash_elem_functor; typedef examples::server::tuples_warehouse::elem_type elem_type; typedef examples::server::tuples_warehouse::index_type index_type; - typedef boost::unordered_multimap field_index_map_type; - typedef field_index_map_type::iterator field_index_map_iterator_type; - typedef field_index_map_type::const_iterator field_index_map_const_iterator_type; + typedef boost::unordered_multimap field_index_map_type; + typedef field_index_map_type::iterator + field_index_map_iterator_type; + typedef field_index_map_type::const_iterator + field_index_map_const_iterator_type; - typedef std::map index_field_map_type; + typedef std::map index_field_map_type; typedef index_field_map_type::iterator index_field_map_iterator_type; - typedef index_field_map_type::const_iterator index_field_map_const_iterator_type; + typedef index_field_map_type::const_iterator + index_field_map_const_iterator_type; field_index_map_type field_index_map_; index_field_map_type index_field_map_; diff --git a/examples/tuplespace/central_tuplespace/simple_central_tuplespace.hpp b/examples/tuplespace/central_tuplespace/simple_central_tuplespace.hpp index 1316f7f2fcac..4965424ca7d4 100644 --- a/examples/tuplespace/central_tuplespace/simple_central_tuplespace.hpp +++ b/examples/tuplespace/central_tuplespace/simple_central_tuplespace.hpp @@ -50,17 +50,22 @@ namespace examples { if(!symbol_name_.empty()) { - hpx::cerr<<"simple_central_tuplespace::create() : ERROR! current instance not empty!\n"; + hpx::cerr<<"simple_central_tuplespace::create() " + <<": ERROR! current instance not empty!\n"; return false; } if(symbol_name_ == symbol_name) // itself { - hpx::cerr<<"simple_central_tuplespace::create() : ERROR! current instance already attached to "<< symbol_name <<"\n"; + hpx::cerr<<"simple_central_tuplespace::create() " + <<": ERROR! current instance already attached to " + << symbol_name <<"\n"; return false; } // request gid; - *this = simple_central_tuplespace(hpx::components::new_(locality)); + *this = simple_central_tuplespace + (hpx::components::new_ + (locality)); bool rc = hpx::agas::register_name(symbol_name, this->get_id()).get(); if(rc) @@ -75,7 +80,9 @@ namespace examples { if(symbol_name_ == symbol_name) { - hpx::cerr<<"simple_central_tuplespace::connect() : ERROR! current instance already attached to "<< symbol_name <<"\n"; + hpx::cerr<<"simple_central_tuplespace::connect()" + <<" : ERROR! current instance already attached to " + << symbol_name <<"\n"; return false; } @@ -117,7 +124,8 @@ namespace examples /// \note This function has fire-and-forget semantics. It will not wait /// for the action to be executed. Instead, it will return /// immediately after the action has has been dispatched. - hpx::lcos::future read_async(const tuple_type& tp, long const timeout) + hpx::lcos::future + read_async(const tuple_type& tp, long const timeout) { HPX_ASSERT(this->get_id()); return this->base_type::read_async(this->get_id(), tp, timeout); @@ -143,7 +151,8 @@ namespace examples /// get() will return immediately; otherwise, it will block /// until the value is ready. //[simple_central_tuplespace_client_take_async - hpx::lcos::future take_async(const tuple_type& tp, long const timeout) + hpx::lcos::future + take_async(const tuple_type& tp, long const timeout) { HPX_ASSERT(this->get_id()); return this->base_type::take_async(this->get_id(), tp, timeout); diff --git a/examples/tuplespace/central_tuplespace/stubs/simple_central_tuplespace.hpp b/examples/tuplespace/central_tuplespace/stubs/simple_central_tuplespace.hpp index eeec2c623722..73c5a1d496f4 100644 --- a/examples/tuplespace/central_tuplespace/stubs/simple_central_tuplespace.hpp +++ b/examples/tuplespace/central_tuplespace/stubs/simple_central_tuplespace.hpp @@ -29,7 +29,8 @@ namespace examples { namespace stubs /// for the action to be executed. Instead, it will return /// immediately after the action has has been dispatched. //[simple_central_tuplespace_stubs_write_async - static hpx::lcos::future write_async(hpx::naming::id_type const& gid, tuple_type const& tuple) + static hpx::lcos::future write_async(hpx::naming::id_type const& gid, + tuple_type const& tuple) { typedef server::simple_central_tuplespace::write_action action_type; return hpx::async(gid, tuple); @@ -52,7 +53,8 @@ namespace examples { namespace stubs /// for the action to be executed. Instead, it will return /// immediately after the action has has been dispatched. static hpx::lcos::future - read_async(hpx::naming::id_type const& gid, const tuple_type& tp, long const timeout) + read_async(hpx::naming::id_type const& gid, const tuple_type& tp, + long const timeout) { typedef server::simple_central_tuplespace::read_action action_type; return hpx::async(gid, tp, timeout); @@ -63,7 +65,8 @@ namespace examples { namespace stubs /// \note This function is fully synchronous. //[simple_central_tuplespace_stubs_read_sync static tuple_type - read_sync(hpx::naming::id_type const& gid, const tuple_type& tp, long const timeout) + read_sync(hpx::naming::id_type const& gid, const tuple_type& tp, + long const timeout) { typedef server::simple_central_tuplespace::read_action action_type; return hpx::async(gid, tp, timeout).get(); @@ -80,7 +83,8 @@ namespace examples { namespace stubs /// until the value is ready. //[simple_central_tuplespace_stubs_take_async static hpx::lcos::future - take_async(hpx::naming::id_type const& gid, const tuple_type& tp, long const timeout) + take_async(hpx::naming::id_type const& gid, const tuple_type& tp, + long const timeout) { typedef server::simple_central_tuplespace::take_action action_type; return hpx::async(gid, tp, timeout); diff --git a/examples/tuplespace/simple_central_tuplespace_client.cpp b/examples/tuplespace/simple_central_tuplespace_client.cpp index c8ec02d4119d..635e2efec11c 100644 --- a/examples/tuplespace/simple_central_tuplespace_client.cpp +++ b/examples/tuplespace/simple_central_tuplespace_client.cpp @@ -40,7 +40,8 @@ void print_tuple(const tuple_type& tuple) -void simple_central_tuplespace_test(const std::string& tuplespace_symbol_name, const tuple_type tuple) +void simple_central_tuplespace_test(const std::string& tuplespace_symbol_name, + const tuple_type tuple) { examples::simple_central_tuplespace central_tuplespace; diff --git a/external/atomic/boost/atomic.hpp b/external/atomic/boost/atomic.hpp index 8617fface09f..1a31166dbf2b 100644 --- a/external/atomic/boost/atomic.hpp +++ b/external/atomic/boost/atomic.hpp @@ -54,7 +54,8 @@ class atomic : private detail::atomic::internal_atomic { }; template<> -class atomic : private detail::atomic::internal_atomic { +class atomic : private detail::atomic + ::internal_atomic { public: typedef detail::atomic::internal_atomic super; @@ -78,7 +79,8 @@ class atomic : private detail::atomic::internal_atomic -class atomic : private detail::atomic::internal_atomic { +class atomic + : private detail::atomic::internal_atomic { public: typedef detail::atomic::internal_atomic super; @@ -98,14 +100,16 @@ class atomic : private detail::atomic::internal_atomic : private detail::atomic::internal_atomic(expected); void * desired_=static_cast(desired); - bool success=super::compare_exchange_weak(expected_, desired_, success_order, failure_order); + bool success=super::compare_exchange_weak(expected_, desired_, + success_order, failure_order); expected=static_cast(expected_); return success; } @@ -127,7 +132,8 @@ class atomic : private detail::atomic::internal_atomic(expected); void * desired_=static_cast(desired); - bool success=super::compare_exchange_strong(expected_, desired_, success_order, failure_order); + bool success=super::compare_exchange_strong(expected_, desired_, + success_order, failure_order); expected=static_cast(expected_); return success; } @@ -201,7 +207,8 @@ typedef atomic atomic_llong; typedef atomic<__uint128_t> atomic_uint128_t; typedef atomic<__int128_t> atomic_int128_t; #endif -#if BOOST_MSVC >= 1500 && (defined(_M_IA64) || defined(_M_AMD64)) && defined(BOOST_ATOMIC_HAVE_SSE2) +#if BOOST_MSVC >= 1500 && (defined(_M_IA64) || defined(_M_AMD64)) + && defined(BOOST_ATOMIC_HAVE_SSE2) typedef atomic<__m128i> atomic_uint128_t; typedef atomic<__m128i> atomic_int128_t; #endif diff --git a/external/atomic/boost/atomic/detail/base.hpp b/external/atomic/boost/atomic/detail/base.hpp index c08a7cb04374..8e22cc94557d 100644 --- a/external/atomic/boost/atomic/detail/base.hpp +++ b/external/atomic/boost/atomic/detail/base.hpp @@ -36,7 +36,8 @@ class platform_atomic : public fallback_atomic { }; template -class platform_atomic_integral : public build_atomic_from_exchange > { +class platform_atomic_integral + : public build_atomic_from_exchange > { public: typedef build_atomic_from_exchange > super; @@ -56,7 +57,8 @@ static inline void platform_atomic_thread_fence(T order) a.exchange(T(), order); } -template::test> +template::test> class internal_atomic; template @@ -80,14 +82,16 @@ class internal_atomic : private detail::atomic::platform_atomic : private detail::atomic::platform_atomic : private detail::atomic::platform_atomic : private detail::atomic::platform_atomic -class internal_atomic : private detail::atomic::platform_atomic_integral { +class internal_atomic + : private detail::atomic::platform_atomic_integral { public: typedef detail::atomic::platform_atomic_integral super; typedef typename super::integral_type integral_type; @@ -149,14 +156,16 @@ class internal_atomic : private detail::atomic::platform_atomic_in integral_type desired, memory_order order=memory_order_seq_cst) volatile { - return super::compare_exchange_strong(expected, desired, order, calculate_failure_order(order)); + return super::compare_exchange_strong(expected, desired, + order, calculate_failure_order(order)); } bool compare_exchange_weak( integral_type &expected, integral_type desired, memory_order order=memory_order_seq_cst) volatile { - return super::compare_exchange_strong(expected, desired, order, calculate_failure_order(order)); + return super::compare_exchange_strong(expected, desired, order, + calculate_failure_order(order)); } bool compare_exchange_strong( integral_type &expected, @@ -164,7 +173,8 @@ class internal_atomic : private detail::atomic::platform_atomic_in memory_order success_order, memory_order failure_order) volatile { - return super::compare_exchange_strong(expected, desired, success_order, failure_order); + return super::compare_exchange_strong(expected, desired, + success_order, failure_order); } bool compare_exchange_weak( integral_type &expected, @@ -172,7 +182,8 @@ class internal_atomic : private detail::atomic::platform_atomic_in memory_order success_order, memory_order failure_order) volatile { - return super::compare_exchange_strong(expected, desired, success_order, failure_order); + return super::compare_exchange_strong(expected, desired, + success_order, failure_order); } private: internal_atomic(const internal_atomic &); diff --git a/external/atomic/boost/atomic/detail/builder.hpp b/external/atomic/boost/atomic/detail/builder.hpp index e7fc6313c8ae..22b59121adc3 100644 --- a/external/atomic/boost/atomic/detail/builder.hpp +++ b/external/atomic/boost/atomic/detail/builder.hpp @@ -18,7 +18,8 @@ namespace atomic { given a Base that implements: - load(memory_order order) -- compare_exchange_weak(integral_type &expected, integral_type desired, memory_order order) +- compare_exchange_weak(integral_type &expected, + integral_type desired, memory_order order) generates exchange and compare_exchange_strong */ @@ -38,13 +39,15 @@ class build_exchange : public Base { { integral_type expected_save=expected; while(true) { - if (compare_exchange_weak(expected, desired, success_order, failure_order)) return true; + if (compare_exchange_weak(expected, desired, + success_order, failure_order)) return true; if (expected_save!=expected) return false; expected=expected_save; } } - integral_type exchange(integral_type replacement, memory_order order=memory_order_seq_cst) volatile + integral_type exchange(integral_type replacement, + memory_order order=memory_order_seq_cst) volatile { integral_type o=load(memory_order_relaxed); do {} while(!compare_exchange_weak(o, replacement, order, memory_order_relaxed)); @@ -97,7 +100,8 @@ class build_const_fetch_add : public Base { given a Base that implements: - load(memory_order order) -- compare_exchange_weak(integral_type &expected, integral_type desired, memory_order order) +- compare_exchange_weak(integral_type &expected, +integral_type desired, memory_order order) generates a -- not very efficient, but correct -- fetch_add operation */ @@ -112,7 +116,8 @@ class build_fetch_add : public Base { integral_type c, memory_order order=memory_order_seq_cst) volatile { integral_type o=Base::load(memory_order_relaxed), n; - do {n=o+c;} while(!compare_exchange_weak(o, n, order, memory_order_relaxed)); + do {n=o+c;} while(!compare_exchange_weak(o, n, + order, memory_order_relaxed)); return o; } @@ -140,7 +145,8 @@ class build_arithmeticops : public Base { { #if defined(BOOST_MSVC) #pragma warning(push) -#pragma warning(disable: 4146) // unary minus operator applied to unsigned type, result still unsigned +#pragma warning(disable: 4146) + // unary minus operator applied to unsigned type, result still unsigned #endif return fetch_add(-c, order); #if defined(BOOST_MSVC) @@ -156,9 +162,11 @@ class build_arithmeticops : public Base { given a Base that implements: - load(memory_order order) -- compare_exchange_weak(integral_type &expected, integral_type desired, memory_order order) +- compare_exchange_weak(integral_type &expected, +integral_type desired, memory_order order) -generates -- not very efficient, but correct -- fetch_and, fetch_or and fetch_xor operators +generates -- not very efficient, but correct +-- fetch_and, fetch_or and fetch_xor operators */ template class build_logicops : public Base { @@ -168,22 +176,28 @@ class build_logicops : public Base { using Base::compare_exchange_weak; using Base::load; - integral_type fetch_and(integral_type c, memory_order order=memory_order_seq_cst) volatile + integral_type fetch_and(integral_type c, + memory_order order=memory_order_seq_cst) volatile { integral_type o=load(memory_order_relaxed), n; - do {n=o&c;} while(!compare_exchange_weak(o, n, order, memory_order_relaxed)); + do {n=o&c;} while(!compare_exchange_weak(o, n, order, + memory_order_relaxed)); return o; } - integral_type fetch_or(integral_type c, memory_order order=memory_order_seq_cst) volatile + integral_type fetch_or(integral_type c, + memory_order order=memory_order_seq_cst) volatile { integral_type o=load(memory_order_relaxed), n; - do {n=o|c;} while(!compare_exchange_weak(o, n, order, memory_order_relaxed)); + do {n=o|c;} while(!compare_exchange_weak(o, n, order, + memory_order_relaxed)); return o; } - integral_type fetch_xor(integral_type c, memory_order order=memory_order_seq_cst) volatile + integral_type fetch_xor(integral_type c, + memory_order order=memory_order_seq_cst) volatile { integral_type o=load(memory_order_relaxed), n; - do {n=o^c;} while(!compare_exchange_weak(o, n, order, memory_order_relaxed)); + do {n=o^c;} while(!compare_exchange_weak(o, n, order, + memory_order_relaxed)); return o; } @@ -196,14 +210,18 @@ given a Base that implements: - load(memory_order order) - store(integral_type i, memory_order order) -- compare_exchange_weak(integral_type &expected, integral_type desired, memory_order order) +- compare_exchange_weak(integral_type &expected, +integral_type desired, memory_order order) generates the full set of atomic operations for integral types */ template -class build_atomic_from_minimal : public build_logicops< build_arithmeticops< build_fetch_add< build_exchange > > > { +class build_atomic_from_minimal + : public build_logicops< build_arithmeticops< + build_fetch_add< build_exchange > > > { public: - typedef build_logicops< build_arithmeticops< build_fetch_add< build_exchange > > > super; + typedef build_logicops< build_arithmeticops< + build_fetch_add< build_exchange > > > super; typedef typename super::integral_type integral_type; build_atomic_from_minimal(void) {} @@ -215,8 +233,10 @@ given a Base that implements: - load(memory_order order) - store(integral_type i, memory_order order) -- compare_exchange_weak(integral_type &expected, integral_type desired, memory_order order) -- compare_exchange_strong(integral_type &expected, integral_type desired, memory_order order) +- compare_exchange_weak(integral_type &expected, +integral_type desired, memory_order order) +- compare_exchange_strong(integral_type &expected, +integral_type desired, memory_order order) - exchange(integral_type replacement, memory_order order) - fetch_add_var(integral_type c, memory_order order) - fetch_inc(memory_order order) @@ -225,7 +245,8 @@ given a Base that implements: generates the full set of atomic operations for integral types */ template -class build_atomic_from_typical : public build_logicops< build_arithmeticops< build_const_fetch_add > > { +class build_atomic_from_typical + : public build_logicops< build_arithmeticops< build_const_fetch_add > > { public: typedef build_logicops< build_arithmeticops< build_const_fetch_add > > super; typedef typename super::integral_type integral_type; @@ -239,15 +260,18 @@ given a Base that implements: - load(memory_order order) - store(integral_type i, memory_order order) -- compare_exchange_weak(integral_type &expected, integral_type desired, memory_order order) -- compare_exchange_strong(integral_type &expected, integral_type desired, memory_order order) +- compare_exchange_weak(integral_type &expected, +integral_type desired, memory_order order) +- compare_exchange_strong(integral_type &expected, +integral_type desired, memory_order order) - exchange(integral_type replacement, memory_order order) - fetch_add(integral_type c, memory_order order) generates the full set of atomic operations for integral types */ template -class build_atomic_from_add : public build_logicops< build_arithmeticops > { +class build_atomic_from_add + : public build_logicops< build_arithmeticops > { public: typedef build_logicops< build_arithmeticops > super; typedef typename super::integral_type integral_type; @@ -261,14 +285,17 @@ given a Base that implements: - load(memory_order order) - store(integral_type i, memory_order order) -- compare_exchange_weak(integral_type &expected, integral_type desired, memory_order order) -- compare_exchange_strong(integral_type &expected, integral_type desired, memory_order order) +- compare_exchange_weak(integral_type &expected, +integral_type desired, memory_order order) +- compare_exchange_strong(integral_type &expected, +integral_type desired, memory_order order) - exchange(integral_type replacement, memory_order order) generates the full set of atomic operations for integral types */ template -class build_atomic_from_exchange : public build_logicops< build_arithmeticops< build_fetch_add > > { +class build_atomic_from_exchange + : public build_logicops< build_arithmeticops< build_fetch_add > > { public: typedef build_logicops< build_arithmeticops< build_fetch_add > > super; typedef typename super::integral_type integral_type; @@ -311,7 +338,8 @@ class build_base_from_larger_type { expected_=get_base().load(memory_order_relaxed); expected_=insert(expected_, expected); desired_=insert(expected_, desired); - bool success=get_base().compare_exchange_weak(expected_, desired_, success_order, failure_order); + bool success=get_base().compare_exchange_weak(expected_, desired_, + success_order, failure_order); expected=extract(expected_); return success; } @@ -322,7 +350,8 @@ class build_base_from_larger_type { expected=get_base().load(memory_order_relaxed); do { desired=insert(expected, v); - } while(!get_base().compare_exchange_weak(expected, desired, order, memory_order_relaxed)); + } while(!get_base().compare_exchange_weak(expected, + desired, order, memory_order_relaxed)); } bool is_lock_free(void) @@ -367,7 +396,8 @@ class build_base_from_larger_type { return v>>get_shift(); } - larger_integral_type insert(larger_integral_type target, integral_type source) const volatile + larger_integral_type insert(larger_integral_type target, + integral_type source) const volatile { larger_integral_type tmp=source; larger_integral_type mask=larger_integral_type(-1); @@ -395,7 +425,8 @@ data type (e.g. an atomic "byte" embedded into a temporary and properly aligned atomic "int"). */ template -class build_atomic_from_larger_type : public build_atomic_from_minimal< build_base_from_larger_type > { +class build_atomic_from_larger_type + : public build_atomic_from_minimal< build_base_from_larger_type > { public: typedef build_atomic_from_minimal< build_base_from_larger_type > super; //typedef typename super::integral_type integral_type; diff --git a/external/atomic/boost/atomic/detail/gcc-alpha.hpp b/external/atomic/boost/atomic/detail/gcc-alpha.hpp index 918557230e9f..d85383767de5 100644 --- a/external/atomic/boost/atomic/detail/gcc-alpha.hpp +++ b/external/atomic/boost/atomic/detail/gcc-alpha.hpp @@ -314,7 +314,8 @@ class atomic_alpha_64 { }; template -class platform_atomic_integral : public build_atomic_from_typical > > { +class platform_atomic_integral + : public build_atomic_from_typical > > { public: typedef build_atomic_from_typical > > super; explicit platform_atomic_integral(T v) : super(v) {} @@ -322,7 +323,8 @@ class platform_atomic_integral : public build_atomic_from_typical -class platform_atomic_integral : public build_atomic_from_typical > > { +class platform_atomic_integral + : public build_atomic_from_typical > > { public: typedef build_atomic_from_typical > > super; explicit platform_atomic_integral(T v) : super(v) {} @@ -330,7 +332,8 @@ class platform_atomic_integral : public build_atomic_from_typical -class platform_atomic_integral: public build_atomic_from_larger_type, T> { +class platform_atomic_integral + : public build_atomic_from_larger_type, T> { public: typedef build_atomic_from_larger_type, T> super; @@ -339,7 +342,8 @@ class platform_atomic_integral: public build_atomic_from_larger_type -class platform_atomic_integral: public build_atomic_from_larger_type, T> { +class platform_atomic_integral + : public build_atomic_from_larger_type, T> { public: typedef build_atomic_from_larger_type, T> super; diff --git a/external/atomic/boost/atomic/detail/gcc-armv6plus.hpp b/external/atomic/boost/atomic/detail/gcc-armv6plus.hpp index e65d8ed5174b..68dbf3a7504a 100644 --- a/external/atomic/boost/atomic/detail/gcc-armv6plus.hpp +++ b/external/atomic/boost/atomic/detail/gcc-armv6plus.hpp @@ -50,7 +50,8 @@ namespace atomic { // instructions. So, if we're compiling in "Thumb 1" mode, we need to wrap all of our // asm blocks with code to temporarily change to ARM mode. // -// You can only change between ARM and Thumb modes when branching using the bx instruction. +// You can only change between ARM and Thumb modes when +// branching using the bx instruction. // bx takes an address specified in a register. The least significant bit of the address // indicates the mode, so 1 is added to indicate that the destination code is Thumb. // A temporary register is needed for the address and is passed as an argument to these @@ -58,16 +59,20 @@ namespace atomic { // usng the "l" attribute in the asm statement. // // Architecture v7 introduces "Thumb 2", which does include (almost?) all of the ARM -// instruction set. So in v7 we don't need to change to ARM mode; we can write "universal +// instruction set. So in v7 we don't need to change to ARM mode; +// we can write "universal // assembler" which will assemble to Thumb 2 or ARM code as appropriate. The only thing -// we need to do to make this "universal" assembler mode work is to insert "IT" instructions +// we need to do to make this "universal" +// assembler mode work is to insert "IT" instructions // to annotate the conditional instructions. These are ignored in other modes (e.g. v6), // so they can always be present. #if defined(__thumb__) && !defined(__ARM_ARCH_7A__) // FIXME also other v7 variants. -#define BOOST_ATOMIC_ARM_ASM_START(TMPREG) "adr " #TMPREG ", 1f\n" "bx " #TMPREG "\n" ".arm\n" ".align 4\n" "1: " -#define BOOST_ATOMIC_ARM_ASM_END(TMPREG) "adr " #TMPREG ", 1f + 1\n" "bx " #TMPREG "\n" ".thumb\n" ".align 2\n" "1: " +#define BOOST_ATOMIC_ARM_ASM_START(TMPREG) \ + "adr " #TMPREG ", 1f\n" "bx " #TMPREG "\n" ".arm\n" ".align 4\n" "1: " +#define BOOST_ATOMIC_ARM_ASM_END(TMPREG) \ + "adr " #TMPREG ", 1f + 1\n" "bx " #TMPREG "\n" ".thumb\n" ".align 2\n" "1: " #else // The tmpreg is wasted in this case, which is non-optimal. @@ -83,7 +88,8 @@ namespace atomic { #define BOOST_ATOMIC_ARM_DMB "mcr\tp15, 0, r0, c7, c10, 5\n" #endif -// There is also a "Data Synchronisation Barrier" DSB; this exists in v6 as another co-processor +// There is also a "Data Synchronisation Barrier" DSB; +// this exists in v6 as another co-processor // instruction like the above. @@ -259,7 +265,8 @@ class atomic_arm_4 { template -class platform_atomic_integral : public build_atomic_from_typical > > { +class platform_atomic_integral + : public build_atomic_from_typical > > { public: typedef build_atomic_from_typical > > super; explicit platform_atomic_integral(T v) : super(v) {} @@ -267,7 +274,8 @@ class platform_atomic_integral : public build_atomic_from_typical -class platform_atomic_integral: public build_atomic_from_larger_type, T> { +class platform_atomic_integral + : public build_atomic_from_larger_type, T> { public: typedef build_atomic_from_larger_type, T> super; @@ -276,7 +284,8 @@ class platform_atomic_integral: public build_atomic_from_larger_type -class platform_atomic_integral: public build_atomic_from_larger_type, T> { +class platform_atomic_integral + : public build_atomic_from_larger_type, T> { public: typedef build_atomic_from_larger_type, T> super; diff --git a/external/atomic/boost/atomic/detail/gcc-ppc.hpp b/external/atomic/boost/atomic/detail/gcc-ppc.hpp index cee20ceaf5d9..712527c6e124 100644 --- a/external/atomic/boost/atomic/detail/gcc-ppc.hpp +++ b/external/atomic/boost/atomic/detail/gcc-ppc.hpp @@ -309,7 +309,8 @@ class atomic_ppc_64 { #endif template -class platform_atomic_integral : public build_atomic_from_typical > > { +class platform_atomic_integral + : public build_atomic_from_typical > > { public: typedef build_atomic_from_typical > > super; explicit platform_atomic_integral(T v) : super(v) {} @@ -317,7 +318,8 @@ class platform_atomic_integral : public build_atomic_from_typical -class platform_atomic_integral: public build_atomic_from_larger_type, T> { +class platform_atomic_integral + : public build_atomic_from_larger_type, T> { public: typedef build_atomic_from_larger_type, T> super; @@ -326,7 +328,8 @@ class platform_atomic_integral: public build_atomic_from_larger_type -class platform_atomic_integral: public build_atomic_from_larger_type, T> { +class platform_atomic_integral + : public build_atomic_from_larger_type, T> { public: typedef build_atomic_from_larger_type, T> super; @@ -336,7 +339,8 @@ class platform_atomic_integral: public build_atomic_from_larger_type -class platform_atomic_integral : public build_atomic_from_typical > > { +class platform_atomic_integral + : public build_atomic_from_typical > > { public: typedef build_atomic_from_typical > > super; explicit platform_atomic_integral(T v) : super(v) {} diff --git a/external/atomic/boost/atomic/detail/gcc-x86.hpp b/external/atomic/boost/atomic/detail/gcc-x86.hpp index 3f945586fef9..9dc7b540d9db 100644 --- a/external/atomic/boost/atomic/detail/gcc-x86.hpp +++ b/external/atomic/boost/atomic/detail/gcc-x86.hpp @@ -107,7 +107,8 @@ class atomic_x86_8 { { fence_before(success_order); T prev=expected; - __asm__ __volatile__("lock; cmpxchgb %1, %2\n" : "=a" (prev) : "q" (desired), "m" (i), "a" (expected) : "memory"); + __asm__ __volatile__("lock; cmpxchgb %1, %2\n" : "=a" (prev) + : "q" (desired), "m" (i), "a" (expected) : "memory"); bool success=(prev==expected); if (success) fence_after(success_order); else fence_after(failure_order); @@ -176,7 +177,8 @@ class atomic_x86_16 { { fence_before(success_order); T prev=expected; - __asm__ __volatile__("lock; cmpxchgw %1, %2\n" : "=a" (prev) : "q" (desired), "m" (i), "a" (expected) : "memory"); + __asm__ __volatile__("lock; cmpxchgw %1, %2\n" : "=a" (prev) + : "q" (desired), "m" (i), "a" (expected) : "memory"); bool success=(prev==expected); if (success) fence_after(success_order); else fence_after(failure_order); @@ -245,7 +247,8 @@ class atomic_x86_32 { { fence_before(success_order); T prev=expected; - __asm__ __volatile__("lock; cmpxchgl %1, %2\n" : "=a" (prev) : "q" (desired), "m" (i), "a" (expected) : "memory"); + __asm__ __volatile__("lock; cmpxchgl %1, %2\n" : "=a" (prev) + : "q" (desired), "m" (i), "a" (expected) : "memory"); bool success=(prev==expected); if (success) fence_after(success_order); else fence_after(failure_order); @@ -315,7 +318,8 @@ class atomic_x86_64 { { fence_before(success_order); T prev=expected; - __asm__ __volatile__("lock; cmpxchgq %1, %2\n" : "=a" (prev) : "q" (desired), "m" (i), "a" (expected) : "memory"); + __asm__ __volatile__("lock; cmpxchgq %1, %2\n" : "=a" (prev) + : "q" (desired), "m" (i), "a" (expected) : "memory"); bool success=(prev==expected); if (success) fence_after(success_order); else fence_after(failure_order); @@ -395,7 +399,8 @@ class atomic_x86_64 { "lock; cmpxchg8b 0(%4)\n" "movl %1, %%ebx\n" : "=A" (prev), "=m" (scratch) - : "D" ((long)desired), "c" ((long)((boost::uint64_t)desired>>32)), "S" (&i), "0" (prev) + : "D" ((long)desired), "c" ((long)((boost::uint64_t)desired>>32)), + "S" (&i), "0" (prev) : "memory"); bool success=(prev==expected); if (success) fence_after(success_order); @@ -426,7 +431,8 @@ class atomic_x86_64 { compare_exchange requires write access to the memory area */ T expected=i; - do { } while(!const_cast(this)->compare_exchange_strong(expected, expected, order, memory_order_relaxed)); + do { } while(!const_cast(this)->compare_exchange_strong(expected, + expected, order, memory_order_relaxed)); return expected; } void store(T v, memory_order order=memory_order_seq_cst) volatile @@ -438,7 +444,8 @@ class atomic_x86_64 { T expected=i, desired;; do { desired=expected+c; - } while(!compare_exchange_strong(expected, desired, order, memory_order_relaxed)); + } while(!compare_exchange_strong(expected, desired, + order, memory_order_relaxed)); return expected; } diff --git a/external/atomic/boost/atomic/detail/generic-cas.hpp b/external/atomic/boost/atomic/detail/generic-cas.hpp index 4d48515954e0..4ef66369a12a 100644 --- a/external/atomic/boost/atomic/detail/generic-cas.hpp +++ b/external/atomic/boost/atomic/detail/generic-cas.hpp @@ -21,7 +21,8 @@ each operation) */ #if defined(__GNUC__) namespace boost { namespace detail { namespace atomic { static inline int32_t - fenced_compare_exchange_strong_32(volatile int32_t *ptr, int32_t expected, int32_t desired) + fenced_compare_exchange_strong_32(volatile int32_t *ptr, + int32_t expected, int32_t desired) { return __sync_val_compare_and_swap_4(ptr, expected, desired); } @@ -48,7 +49,8 @@ each operation) */ static inline int32_t fenced_compare_exchange_strong(int32_t *ptr, int32_t expected, int32_t desired) { - return _InterlockedCompareExchange(reinterpret_cast(ptr), desired, expected); + return _InterlockedCompareExchange(reinterpret_cast(ptr), + desired, expected); } #define BOOST_ATOMIC_HAVE_CAS32 1 #if defined(_WIN64) @@ -120,7 +122,8 @@ class atomic_generic_cas32 { T load(memory_order order=memory_order_seq_cst) const volatile { T expected=(T)i; - do { } while(!const_cast(this)->compare_exchange_weak(expected, expected, order, memory_order_relaxed)); + do { } while(!const_cast(this)->compare_exchange_weak(expected, + expected, order, memory_order_relaxed)); return expected; } void store(T v, memory_order order=memory_order_seq_cst) volatile @@ -134,7 +137,8 @@ class atomic_generic_cas32 { memory_order failure_order) volatile { T found; - found=(T)fenced_compare_exchange_strong_32(&i, (int32_t)expected, (int32_t)desired); + found=(T)fenced_compare_exchange_strong_32(&i, (int32_t)expected, + (int32_t)desired); bool success=(found==expected); expected=found; return success; @@ -161,7 +165,8 @@ class atomic_generic_cas32 { }; template -class platform_atomic_integral : public build_atomic_from_exchange > { +class platform_atomic_integral + : public build_atomic_from_exchange > { public: typedef build_atomic_from_exchange > super; explicit platform_atomic_integral(T v) : super(v) {} @@ -169,7 +174,8 @@ class platform_atomic_integral : public build_atomic_from_exchange -class platform_atomic_integral: public build_atomic_from_larger_type, T> { +class platform_atomic_integral + : public build_atomic_from_larger_type, T> { public: typedef build_atomic_from_larger_type, T> super; @@ -178,7 +184,8 @@ class platform_atomic_integral: public build_atomic_from_larger_type -class platform_atomic_integral: public build_atomic_from_larger_type, T> { +class platform_atomic_integral + : public build_atomic_from_larger_type, T> { public: typedef build_atomic_from_larger_type, T> super; diff --git a/external/atomic/boost/atomic/detail/integral-casts.hpp b/external/atomic/boost/atomic/detail/integral-casts.hpp index 372a1b7cf6d8..952732d07394 100644 --- a/external/atomic/boost/atomic/detail/integral-casts.hpp +++ b/external/atomic/boost/atomic/detail/integral-casts.hpp @@ -43,7 +43,8 @@ class platform_atomic : private platform_atomic_integral { boost::uint8_t _expected, _desired; _expected=to_integral(expected); _desired=to_integral(desired); - bool success=super::compare_exchange_strong(_expected, _desired, success_order, failure_order); + bool success=super::compare_exchange_strong(_expected, _desired, success_order, + failure_order); expected=from_integral(_expected); return success; } @@ -56,7 +57,8 @@ class platform_atomic : private platform_atomic_integral { boost::uint8_t _expected, _desired; _expected=to_integral(expected); _desired=to_integral(desired); - bool success=super::compare_exchange_weak(_expected, _desired, success_order, failure_order); + bool success=super::compare_exchange_weak(_expected, _desired, success_order, + failure_order); expected=from_integral(_expected); return success; } @@ -115,7 +117,8 @@ class platform_atomic : private platform_atomic_integral boost::uint16_t _expected, _desired; _expected=to_integral(expected); _desired=to_integral(desired); - bool success=super::compare_exchange_strong(_expected, _desired, success_order, failure_order); + bool success=super::compare_exchange_strong(_expected, _desired, success_order, + failure_order); expected=from_integral(_expected); return success; } @@ -128,7 +131,8 @@ class platform_atomic : private platform_atomic_integral boost::uint16_t _expected, _desired; _expected=to_integral(expected); _desired=to_integral(desired); - bool success=super::compare_exchange_weak(_expected, _desired, success_order, failure_order); + bool success=super::compare_exchange_weak(_expected, _desired, success_order, + failure_order); expected=from_integral(_expected); return success; } @@ -187,7 +191,8 @@ class platform_atomic : private platform_atomic_integral boost::uint32_t _expected, _desired; _expected=to_integral(expected); _desired=to_integral(desired); - bool success=super::compare_exchange_strong(_expected, _desired, success_order, failure_order); + bool success=super::compare_exchange_strong(_expected, _desired, success_order, + failure_order); expected=from_integral(_expected); return success; } @@ -200,7 +205,8 @@ class platform_atomic : private platform_atomic_integral boost::uint32_t _expected, _desired; _expected=to_integral(expected); _desired=to_integral(desired); - bool success=super::compare_exchange_weak(_expected, _desired, success_order, failure_order); + bool success=super::compare_exchange_weak(_expected, _desired, success_order, + failure_order); expected=from_integral(_expected); return success; } @@ -259,7 +265,8 @@ class platform_atomic : private platform_atomic_integral boost::uint64_t _expected, _desired; _expected=to_integral(expected); _desired=to_integral(desired); - bool success=super::compare_exchange_strong(_expected, _desired, success_order, failure_order); + bool success=super::compare_exchange_strong(_expected, _desired, success_order, + failure_order); expected=from_integral(_expected); return success; } @@ -272,7 +279,8 @@ class platform_atomic : private platform_atomic_integral boost::uint64_t _expected, _desired; _expected=to_integral(expected); _desired=to_integral(desired); - bool success=super::compare_exchange_weak(_expected, _desired, success_order, failure_order); + bool success=super::compare_exchange_weak(_expected, _desired, success_order, + failure_order); expected=from_integral(_expected); return success; } @@ -339,7 +347,8 @@ class platform_atomic : private platform_atomic_integral<__uint128_t> { __uint128_t _expected, _desired; _expected=to_integral(expected); _desired=to_integral(desired); - bool success=super::compare_exchange_strong(_expected, _desired, success_order, failure_order); + bool success=super::compare_exchange_strong(_expected, _desired, + success_order, failure_order); expected=from_integral(_expected); return success; } @@ -352,7 +361,8 @@ class platform_atomic : private platform_atomic_integral<__uint128_t> { __uint128_t _expected, _desired; _expected=to_integral(expected); _desired=to_integral(desired); - bool success=super::compare_exchange_weak(_expected, _desired, success_order, failure_order); + bool success=super::compare_exchange_weak(_expected, _desired, + success_order, failure_order); expected=from_integral(_expected); return success; } @@ -381,7 +391,8 @@ class platform_atomic : private platform_atomic_integral<__uint128_t> { } }; -#elif BOOST_MSVC >= 1500 && (defined(_M_IA64) || defined(_M_AMD64)) && defined(BOOST_ATOMIC_HAVE_SSE2) +#elif BOOST_MSVC >= 1500 && (defined(_M_IA64) || defined(_M_AMD64)) && \ + defined(BOOST_ATOMIC_HAVE_SSE2) #define BOOST_ATOMIC_HAVE_128BIT_SUPPORT @@ -421,7 +432,8 @@ class platform_atomic : private platform_atomic_integral<__m128i> { __m128i _expected, _desired; _expected=to_integral(expected); _desired=to_integral(desired); - bool success=super::compare_exchange_strong(_expected, _desired, success_order, failure_order); + bool success=super::compare_exchange_strong(_expected, _desired, + success_order, failure_order); expected=from_integral(_expected); return success; } @@ -434,7 +446,8 @@ class platform_atomic : private platform_atomic_integral<__m128i> { __m128i _expected, _desired; _expected=to_integral(expected); _desired=to_integral(desired); - bool success=super::compare_exchange_weak(_expected, _desired, success_order, failure_order); + bool success=super::compare_exchange_weak(_expected, _desired, + success_order, failure_order); expected=from_integral(_expected); return success; } diff --git a/external/atomic/boost/atomic/detail/interlocked.hpp b/external/atomic/boost/atomic/detail/interlocked.hpp index 4d7b47df2bca..ff14d776b639 100644 --- a/external/atomic/boost/atomic/detail/interlocked.hpp +++ b/external/atomic/boost/atomic/detail/interlocked.hpp @@ -70,7 +70,8 @@ class atomic_interlocked_32 { memory_order failure_order) volatile { T prev=expected; - expected=(T)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long *)(&i), (long)desired, (long)expected); + expected=(T)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long *)(&i), + (long)desired, (long)expected); bool success=(prev==expected); return success; } @@ -112,9 +113,12 @@ class atomic_interlocked_32 { #else -extern "C" boost::int64_t __cdecl _InterlockedExchangeAdd64(boost::int64_t volatile *, boost::int64_t); -extern "C" boost::int64_t __cdecl _InterlockedExchange64(boost::int64_t volatile *, boost::int64_t); -extern "C" boost::int64_t __cdecl _InterlockedCompareExchange64(boost::int64_t volatile *, boost::int64_t, boost::int64_t); +extern "C" boost::int64_t __cdecl _InterlockedExchangeAdd64(boost::int64_t volatile *, + boost::int64_t); +extern "C" boost::int64_t __cdecl _InterlockedExchange64(boost::int64_t volatile *, + boost::int64_t); +extern "C" boost::int64_t __cdecl _InterlockedCompareExchange64( + boost::int64_t volatile *, boost::int64_t, boost::int64_t); # pragma intrinsic( _InterlockedExchangeAdd64 ) # pragma intrinsic( _InterlockedExchange64 ) @@ -154,7 +158,8 @@ class __declspec(align(8)) atomic_interlocked_64 { memory_order failure_order) volatile { T prev=expected; - expected=(T)BOOST_INTERLOCKED_COMPARE_EXCHANGE64((boost::int64_t *)(&i), (boost::int64_t)desired, (boost::int64_t)expected); + expected=(T)BOOST_INTERLOCKED_COMPARE_EXCHANGE64((boost::int64_t *)(&i), + (boost::int64_t)desired, (boost::int64_t)expected); bool success=(prev==expected); return success; } @@ -272,7 +277,8 @@ class __declspec(align(16)) atomic_interlocked_128 { do { desired = _mm_add_epi32(*(__m128i*)(&expected), *(__m128i*)(&c)); - } while (!compare_exchange_strong(expected, *(T*)(&desired), order, memory_order_relaxed)); + } while (!compare_exchange_strong(expected, *(T*)(&desired), + order, memory_order_relaxed)); return expected; } @@ -293,7 +299,8 @@ class __declspec(align(16)) atomic_interlocked_128 { namespace boost { namespace detail { namespace atomic { template -class platform_atomic_integral : public build_atomic_from_add > { +class platform_atomic_integral + : public build_atomic_from_add > { public: typedef build_atomic_from_add > super; explicit platform_atomic_integral(T v) : super(v) {} @@ -301,7 +308,8 @@ class platform_atomic_integral : public build_atomic_from_add -class platform_atomic_integral: public build_atomic_from_larger_type, T> { +class platform_atomic_integral + : public build_atomic_from_larger_type, T> { public: typedef build_atomic_from_larger_type, T> super; @@ -310,7 +318,8 @@ class platform_atomic_integral: public build_atomic_from_larger_type -class platform_atomic_integral: public build_atomic_from_larger_type, T> { +class platform_atomic_integral + : public build_atomic_from_larger_type, T> { public: typedef build_atomic_from_larger_type, T> super; diff --git a/external/atomic/boost/atomic/detail/linux-arm.hpp b/external/atomic/boost/atomic/detail/linux-arm.hpp index 80585b619838..d6eb068d29b7 100644 --- a/external/atomic/boost/atomic/detail/linux-arm.hpp +++ b/external/atomic/boost/atomic/detail/linux-arm.hpp @@ -105,7 +105,8 @@ class atomic_linux_arm_4 { memory_order success_order, memory_order failure_order) volatile { - return compare_exchange_strong(expected, desired, success_order, failure_order); + return compare_exchange_strong(expected, desired, success_order, + failure_order); } T exchange(T replacement, memory_order order=memory_order_seq_cst) volatile { @@ -115,11 +116,12 @@ class atomic_linux_arm_4 { return o; // Note that ARM has an atomic swap instruction that we could use here: // T oldval; - // asm volatile ("swp\t%0, %1, [%2]" : "=&r"(oldval) : "r" (replacement), "r" (&i) : "memory"); + // asm volatile ("swp\t%0, %1, [%2]" : "=&r"(oldval) : "r" (replacement), + // "r" (&i) : "memory"); // return oldval; - // This instruction is deprecated in architecture >= 6. I'm unsure how inefficient - // its implementation is on those newer architectures. I don't think this would gain - // much since exchange() is not used often. + // This instruction is deprecated in architecture >= 6. I'm unsure + // how inefficient its implementation is on those newer architectures. + // I don't think this would gain much since exchange() is not used often. } bool is_lock_free(void) const volatile {return true;} @@ -133,7 +135,8 @@ class atomic_linux_arm_4 { }; template -class platform_atomic_integral : public build_atomic_from_exchange > { +class platform_atomic_integral + : public build_atomic_from_exchange > { public: typedef build_atomic_from_exchange > super; explicit platform_atomic_integral(T v) : super(v) {} @@ -142,7 +145,8 @@ class platform_atomic_integral : public build_atomic_from_exchange -class platform_atomic_integral : public build_atomic_from_larger_type, T > { +class platform_atomic_integral + : public build_atomic_from_larger_type, T > { public: typedef build_atomic_from_larger_type, T> super; explicit platform_atomic_integral(T v) : super(v) {} @@ -151,7 +155,8 @@ class platform_atomic_integral : public build_atomic_from_larger_type -class platform_atomic_integral : public build_atomic_from_larger_type, T > { +class platform_atomic_integral + : public build_atomic_from_larger_type, T > { public: typedef build_atomic_from_larger_type, T> super; explicit platform_atomic_integral(T v) : super(v) {} diff --git a/external/atomic/boost/atomic/detail/valid_integral_types.hpp b/external/atomic/boost/atomic/detail/valid_integral_types.hpp index b091c9f43281..f32c134573fd 100644 --- a/external/atomic/boost/atomic/detail/valid_integral_types.hpp +++ b/external/atomic/boost/atomic/detail/valid_integral_types.hpp @@ -34,7 +34,8 @@ template<> struct is_integral_type {typedef int test;}; template<> struct is_integral_type<__uint128_t> {typedef int test;}; template<> struct is_integral_type<__int128_t> {typedef int test;}; #endif -#if BOOST_MSVC >= 1500 && (defined(_M_IA64) || defined(_M_AMD64)) && defined(BOOST_ATOMIC_HAVE_SSE2) +#if BOOST_MSVC >= 1500 && (defined(_M_IA64) || defined(_M_AMD64)) && \ + defined(BOOST_ATOMIC_HAVE_SSE2) #include template<> struct is_integral_type<__m128i> {typedef int test;}; #endif diff --git a/external/atomic/boost/atomic/platform.hpp b/external/atomic/boost/atomic/platform.hpp index da4382630db1..d0068fd18d35 100644 --- a/external/atomic/boost/atomic/platform.hpp +++ b/external/atomic/boost/atomic/platform.hpp @@ -6,7 +6,8 @@ #include -#if (defined(__GNUC__) || defined(__INTEL_COMPILER)) && (defined(__i386__) || defined(__amd64__) || defined(__x86_64__)) +#if (defined(__GNUC__) || defined(__INTEL_COMPILER)) && \ + (defined(__i386__) || defined(__amd64__) || defined(__x86_64__)) #include @@ -30,7 +31,9 @@ #include -#elif defined(BOOST_USE_WINDOWS_H) || defined(_WIN32_CE) || defined(BOOST_MSVC) || defined(BOOST_INTEL_WIN) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +#elif defined(BOOST_USE_WINDOWS_H) || defined(_WIN32_CE) || defined(BOOST_MSVC) \ + || defined(BOOST_INTEL_WIN) || defined(WIN32) || defined(_WIN32) \ + || defined(__WIN32__) || defined(__CYGWIN__) #include diff --git a/external/lockfree/boost/lockfree/detail/atomic.hpp b/external/lockfree/boost/lockfree/detail/atomic.hpp index c4accdb3158d..8e990647787f 100644 --- a/external/lockfree/boost/lockfree/detail/atomic.hpp +++ b/external/lockfree/boost/lockfree/detail/atomic.hpp @@ -9,7 +9,8 @@ #if !defined(BOOST_NO_0X_HDR_ATOMIC) #ifdef __GNUC__ -# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6) || !defined(__GXX_EXPERIMENTAL_CXX0X__) +# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6) + || !defined(__GXX_EXPERIMENTAL_CXX0X__) # define BOOST_NO_0X_HDR_ATOMIC # endif #else diff --git a/external/lockfree/boost/lockfree/detail/prefix.hpp b/external/lockfree/boost/lockfree/detail/prefix.hpp index e867b672d20d..c7d5bcb42dbb 100644 --- a/external/lockfree/boost/lockfree/detail/prefix.hpp +++ b/external/lockfree/boost/lockfree/detail/prefix.hpp @@ -21,7 +21,8 @@ #ifdef _MSC_VER -#define BOOST_LOCKFREE_CACHELINE_ALIGNMENT __declspec(align(BOOST_LOCKFREE_CACHELINE_BYTES)) +#define BOOST_LOCKFREE_CACHELINE_ALIGNMENT \ + __declspec(align(BOOST_LOCKFREE_CACHELINE_BYTES)) #if defined(_M_IX86) #define BOOST_LOCKFREE_DCAS_ALIGNMENT @@ -34,7 +35,8 @@ #ifdef __GNUC__ -#define BOOST_LOCKFREE_CACHELINE_ALIGNMENT __attribute__((aligned(BOOST_LOCKFREE_CACHELINE_BYTES))) +#define BOOST_LOCKFREE_CACHELINE_ALIGNMENT \ + __attribute__((aligned(BOOST_LOCKFREE_CACHELINE_BYTES))) #if defined(__i386__) || defined(__ppc__) #define BOOST_LOCKFREE_DCAS_ALIGNMENT @@ -42,7 +44,8 @@ #define BOOST_LOCKFREE_PTR_COMPRESSION 1 #define BOOST_LOCKFREE_DCAS_ALIGNMENT __attribute__((aligned(16))) #elif defined(__alpha__) - // LATER: alpha may benefit from pointer compression. but what is the maximum size of the address space? + // LATER: alpha may benefit from pointer compression. + // but what is the maximum size of the address space? #define BOOST_LOCKFREE_DCAS_ALIGNMENT #endif #endif /* __GNUC__ */ diff --git a/external/lockfree/boost/lockfree/queue.hpp b/external/lockfree/boost/lockfree/queue.hpp index 852174355f22..48d7fde5cb88 100644 --- a/external/lockfree/boost/lockfree/queue.hpp +++ b/external/lockfree/boost/lockfree/queue.hpp @@ -82,9 +82,12 @@ class queue: /** * \return true, if implementation is lock-free. * - * \warning \b Warning: It only checks, if the queue head node is lockfree. On most platforms, the whole implementation is - * lockfree, if this is true. Using c++0x-style atomics, there is no possibility to provide a completely - * accurate implementation, because one would need to test every internal node, which is impossible + * \warning \b Warning: It only checks, if the queue head node is lockfree. + * On most platforms, the whole implementation is + * lockfree, if this is true. Using c++0x-style atomics, there + * is no possibility to provide a completely + * accurate implementation, because one would need to test every + * internal node, which is impossible * if further nodes will be allocated from the operating system. * */ bool is_lock_free (void) const @@ -139,12 +142,14 @@ class queue: return head_.load().get_ptr() == tail_.load().get_ptr(); } - /** Enqueues object t to the queue. Enqueueing may fail, if the freelist is not able to allocate a new queue node. + /** Enqueues object t to the queue. Enqueueing may fail, + * if the freelist is not able to allocate a new queue node. * * \returns true, if the push operation is successful. * * \note Thread-safe and non-blocking - * \warning \b Warning: May block if node needs to be allocated from the operating system + * \warning \b Warning: + * May block if node needs to be allocated from the operating system * */ bool push(T const & t) { @@ -161,23 +166,28 @@ class queue: tagged_node_ptr tail2 = tail_.load(memory_order_acquire); if (likely(tail == tail2)) { if (next_ptr == 0) { - if ( tail->next.compare_exchange_weak(next, tagged_node_ptr(n, next.get_tag() + 1)) ) { - tail_.compare_exchange_strong(tail, tagged_node_ptr(n, tail.get_tag() + 1)); + if ( tail->next.compare_exchange_weak(next, tagged_node_ptr(n, + next.get_tag() + 1)) ) { + tail_.compare_exchange_strong(tail, tagged_node_ptr(n, + tail.get_tag() + 1)); return true; } } else - tail_.compare_exchange_strong(tail, tagged_node_ptr(next_ptr, tail.get_tag() + 1)); + tail_.compare_exchange_strong(tail, tagged_node_ptr(next_ptr, + tail.get_tag() + 1)); } } } - /** Enqueues object t to the queue. Enqueueing may fail, if the freelist is not able to allocate a new queue node. + /** Enqueues object t to the queue. Enqueueing may fail, + * if the freelist is not able to allocate a new queue node. * * \returns true, if the push operation is successful. * * \note Not thread-safe - * \warning \b Warning: May block if node needs to be allocated from the operating system + * \warning \b Warning: May block if node needs to be + * allocated from the operating system * */ bool push_unsafe(T const & t) { @@ -193,18 +203,22 @@ class queue: node * next_ptr = next.get_ptr(); if (next_ptr == 0) { - tail->next.store(tagged_node_ptr(n, next.get_tag() + 1), memory_order_relaxed); - tail_.store(tagged_node_ptr(n, tail.get_tag() + 1), memory_order_relaxed); + tail->next.store(tagged_node_ptr(n, next.get_tag() + 1), + memory_order_relaxed); + tail_.store(tagged_node_ptr(n, tail.get_tag() + 1), + memory_order_relaxed); return true; } else - tail_.store(tagged_node_ptr(next_ptr, tail.get_tag() + 1), memory_order_relaxed); + tail_.store(tagged_node_ptr(next_ptr, tail.get_tag() + 1), + memory_order_relaxed); } } /** Dequeue object from queue. * - * if pop operation is successful, object is written to memory location denoted by ret. + * if pop operation is successful, + * object is written to memory location denoted by ret. * * \returns true, if the pop operation is successful, false if queue was empty. * @@ -225,17 +239,21 @@ class queue: if (head.get_ptr() == tail.get_ptr()) { if (next_ptr == 0) return false; - tail_.compare_exchange_strong(tail, tagged_node_ptr(next_ptr, tail.get_tag() + 1)); + tail_.compare_exchange_strong(tail, tagged_node_ptr(next_ptr, + tail.get_tag() + 1)); } else { if (next_ptr == 0) - /* this check is not part of the original algorithm as published by michael and scott + /* this check is not part of the original algorithm + * as published by michael and scott * - * however we reuse the tagged_ptr part for the and clear the next part during node + * however we reuse the tagged_ptr part for the and + * clear the next part during node * allocation. we can observe a null-pointer here. * */ continue; ret = next_ptr->data; - if (head_.compare_exchange_weak(head, tagged_node_ptr(next_ptr, head.get_tag() + 1))) { + if (head_.compare_exchange_weak(head, tagged_node_ptr(next_ptr, + head.get_tag() + 1))) { pool.destruct(head.get_ptr()); return true; } @@ -246,7 +264,8 @@ class queue: /** Dequeue object from queue. * - * if pop operation is successful, object is written to memory location denoted by ret. + * if pop operation is successful, + * object is written to memory location denoted by ret. * * \returns true, if the pop operation is successful, false if queue was empty. * @@ -265,17 +284,21 @@ class queue: if (head.get_ptr() == tail.get_ptr()) { if (next_ptr == 0) return false; - tail_.store(tagged_node_ptr(next_ptr, tail.get_tag() + 1), memory_order_relaxed); + tail_.store(tagged_node_ptr(next_ptr, tail.get_tag() + 1), + memory_order_relaxed); } else { if (next_ptr == 0) - /* this check is not part of the original algorithm as published by michael and scott + /* this check is not part of the original algorithm as + * published by michael and scott * - * however we reuse the tagged_ptr part for the and clear the next part during node + * however we reuse the tagged_ptr part for the and clear + * the next part during node * allocation. we can observe a null-pointer here. * */ continue; ret = next_ptr->data; - head_.store(tagged_node_ptr(next_ptr, head.get_tag() + 1), memory_order_relaxed); + head_.store(tagged_node_ptr(next_ptr, head.get_tag() + 1), + memory_order_relaxed); pool.destruct_unsafe(head.get_ptr()); return true; } @@ -286,7 +309,8 @@ class queue: private: #ifndef BOOST_DOXYGEN_INVOKED atomic head_; - static const int padding_size = BOOST_LOCKFREE_CACHELINE_BYTES - sizeof(tagged_node_ptr); + static const int padding_size = BOOST_LOCKFREE_CACHELINE_BYTES + - sizeof(tagged_node_ptr); char padding1[padding_size]; atomic tail_; char padding2[padding_size]; @@ -297,14 +321,21 @@ class queue: } /* namespace detail */ -/** The queue class provides a multi-writer/multi-reader queue, pushing and poping is lockfree, - * construction/destruction has to be synchronized. It uses a freelist for memory management, - * freed nodes are pushed to the freelist and not returned to the os before the queue is destroyed. +/** The queue class provides a multi-writer/multi-reader queue, + * pushing and poping is lockfree, + * construction/destruction has to be synchronized. + * It uses a freelist for memory management, + * freed nodes are pushed to the freelist and not returned to the os before + * the queue is destroyed. * - * The memory management of the queue can be controlled via its freelist_t template argument. Two different - * freelists can be used. struct caching_freelist_t selects a caching freelist, which can allocate more nodes - * from the operating system, and struct static_freelist_t uses a fixed-sized freelist. With a fixed-sized - * freelist, the push operation may fail, while with a caching freelist, the push operation may block. + * The memory management of the queue can be controlled via its + * freelist_t template argument. Two different + * freelists can be used. struct caching_freelist_t selects a caching freelist, + * which can allocate more nodes + * from the operating system, and struct static_freelist_t uses a fixed-sized freelist. + * With a fixed-sized + * freelist, the push operation may fail, while with a caching freelist, + * the push operation may block. * * \b Limitation: The class T is required to have a trivial assignment operator. * @@ -330,7 +361,8 @@ class queue: }; -/** Template specialization of the queue class for pointer arguments, that supports pop operations to +/** Template specialization of the queue class for pointer arguments, + * that supports pop operations to * stl/boost-style smart pointers * * */ @@ -374,7 +406,8 @@ class queue: /** Dequeue object from queue to std::auto_ptr * - * if pop operation is successful, object is written to memory location denoted by ret. + * if pop operation is successful, + * object is written to memory location denoted by ret. * * \returns true, if the pop operation is successful, false if queue was empty. * @@ -388,7 +421,8 @@ class queue: /** Dequeue object from queue to boost::scoped_ptr * - * if pop operation is successful, object is written to memory location denoted by ret. + * if pop operation is successful, + * object is written to memory location denoted by ret. * * \returns true, if the pop operation is successful, false if queue was empty. * @@ -403,7 +437,8 @@ class queue: /** Dequeue object from queue to boost::shared_ptr * - * if pop operation is successful, object is written to memory location denoted by ret. + * if pop operation is successful, + * object is written to memory location denoted by ret. * * \returns true, if the pop operation is successful, false if queue was empty. * diff --git a/external/lockfree/boost/lockfree/ringbuffer.hpp b/external/lockfree/boost/lockfree/ringbuffer.hpp index 78580d55a06a..34e7027b5d19 100644 --- a/external/lockfree/boost/lockfree/ringbuffer.hpp +++ b/external/lockfree/boost/lockfree/ringbuffer.hpp @@ -39,7 +39,8 @@ class ringbuffer_base: typedef std::size_t size_t; static const int padding_size = BOOST_LOCKFREE_CACHELINE_BYTES - sizeof(size_t); atomic write_index_; - char padding1[padding_size]; /* force read_index and write_index to different cache lines */ + char padding1[padding_size]; + /* force read_index and write_index to different cache lines */ atomic read_index_; protected: @@ -55,7 +56,8 @@ class ringbuffer_base: return ret; } - static size_t read_available(size_t write_index, size_t read_index, size_t max_size) + static size_t read_available(size_t write_index, size_t read_index, + size_t max_size) { if (write_index >= read_index) return write_index - read_index; @@ -64,7 +66,8 @@ class ringbuffer_base: return ret; } - static size_t write_available(size_t write_index, size_t read_index, size_t max_size) + static size_t write_available(size_t write_index, size_t read_index, + size_t max_size) { size_t ret = read_index - write_index - 1; if (write_index >= read_index) @@ -74,7 +77,8 @@ class ringbuffer_base: bool enqueue(T const & t, T * buffer, size_t max_size) { - size_t write_index = write_index_.load(memory_order_relaxed); // only written from enqueue thread + size_t write_index = write_index_.load(memory_order_relaxed); + // only written from enqueue thread size_t next = next_index(write_index, max_size); if (next == read_index_.load(memory_order_acquire)) @@ -87,9 +91,11 @@ class ringbuffer_base: return true; } - size_t enqueue(const T * input_buffer, size_t input_count, T * internal_buffer, size_t max_size) + size_t enqueue(const T * input_buffer, size_t input_count, + T * internal_buffer, size_t max_size) { - size_t write_index = write_index_.load(memory_order_relaxed); // only written from enqueue thread + size_t write_index = write_index_.load(memory_order_relaxed); + // only written from enqueue thread const size_t read_index = read_index_.load(memory_order_acquire); const size_t avail = write_available(write_index, read_index, max_size); @@ -104,11 +110,14 @@ class ringbuffer_base: /* copy data in two sections */ size_t count0 = max_size - write_index; - std::copy(input_buffer, input_buffer + count0, internal_buffer + write_index); - std::copy(input_buffer + count0, input_buffer + input_count, internal_buffer); + std::copy(input_buffer, input_buffer + count0, + internal_buffer + write_index); + std::copy(input_buffer + count0, input_buffer + input_count, + internal_buffer); new_write_index -= max_size; } else { - std::copy(input_buffer, input_buffer + input_count, internal_buffer + write_index); + std::copy(input_buffer, input_buffer + input_count, + internal_buffer + write_index); if (new_write_index == max_size) new_write_index = 0; @@ -119,11 +128,13 @@ class ringbuffer_base: } template - ConstIterator enqueue(ConstIterator begin, ConstIterator end, T * internal_buffer, size_t max_size) + ConstIterator enqueue(ConstIterator begin, ConstIterator end, + T * internal_buffer, size_t max_size) { // FIXME: avoid std::distance and std::advance - size_t write_index = write_index_.load(memory_order_relaxed); // only written from enqueue thread + size_t write_index = write_index_.load(memory_order_relaxed); + // only written from enqueue thread const size_t read_index = read_index_.load(memory_order_acquire); const size_t avail = write_available(write_index, read_index, max_size); @@ -161,7 +172,8 @@ class ringbuffer_base: bool dequeue (T & ret, T * buffer, size_t max_size) { size_t write_index = write_index_.load(memory_order_acquire); - size_t read_index = read_index_.load(memory_order_relaxed); // only written from dequeue thread + size_t read_index = read_index_.load(memory_order_relaxed); + // only written from dequeue thread if (empty(write_index, read_index)) return false; @@ -171,10 +183,12 @@ class ringbuffer_base: return true; } - size_t dequeue (T * output_buffer, size_t output_count, const T * internal_buffer, size_t max_size) + size_t dequeue (T * output_buffer, size_t output_count, + const T * internal_buffer, size_t max_size) { const size_t write_index = write_index_.load(memory_order_acquire); - size_t read_index = read_index_.load(memory_order_relaxed); // only written from dequeue thread + size_t read_index = read_index_.load(memory_order_relaxed); + // only written from dequeue thread const size_t avail = read_available(write_index, read_index, max_size); @@ -190,12 +204,14 @@ class ringbuffer_base: size_t count0 = max_size - read_index; size_t count1 = output_count - count0; - std::copy(internal_buffer + read_index, internal_buffer + max_size, output_buffer); + std::copy(internal_buffer + read_index, + internal_buffer + max_size, output_buffer); std::copy(internal_buffer, internal_buffer + count1, output_buffer + count0); new_read_index -= max_size; } else { - std::copy(internal_buffer + read_index, internal_buffer + read_index + output_count, output_buffer); + std::copy(internal_buffer + read_index, + internal_buffer + read_index + output_count, output_buffer); if (new_read_index == max_size) new_read_index = 0; } @@ -208,7 +224,8 @@ class ringbuffer_base: size_t dequeue (OutputIterator it, const T * internal_buffer, size_t max_size) { const size_t write_index = write_index_.load(memory_order_acquire); - size_t read_index = read_index_.load(memory_order_relaxed); // only written from dequeue thread + size_t read_index = read_index_.load(memory_order_relaxed); + // only written from dequeue thread const size_t avail = read_available(write_index, read_index, max_size); if (avail == 0) @@ -226,7 +243,8 @@ class ringbuffer_base: new_read_index -= max_size; } else { - std::copy(internal_buffer + read_index, internal_buffer + read_index + avail, it); + std::copy(internal_buffer + read_index, + internal_buffer + read_index + avail, it); if (new_read_index == max_size) new_read_index = 0; } @@ -254,7 +272,8 @@ class ringbuffer_base: * */ bool empty(void) { - return empty(write_index_.load(memory_order_relaxed), read_index_.load(memory_order_relaxed)); + return empty(write_index_.load(memory_order_relaxed), + read_index_.load(memory_order_relaxed)); } //! \copydoc boost::lockfree::stack::is_lock_free @@ -280,7 +299,8 @@ class ringbuffer: boost::array array_; public: - /** Enqueues object t to the ringbuffer. Enqueueing may fail, if the ringbuffer is full. + /** Enqueues object t to the ringbuffer. + * Enqueueing may fail, if the ringbuffer is full. * * \return true, if the enqueue operation is successful. * @@ -293,9 +313,11 @@ class ringbuffer: /** Dequeue object from ringbuffer. * - * If dequeue operation is successful, object is written to memory location denoted by ret. + * If dequeue operation is successful, + * object is written to memory location denoted by ret. * - * \return true, if the dequeue operation is successful, false if ringbuffer was empty. + * \return true, if the dequeue operation is successful, + * false if ringbuffer was empty. * * \note Thread-safe and non-blocking */ @@ -342,12 +364,14 @@ class ringbuffer: template ConstIterator enqueue(ConstIterator begin, ConstIterator end) { - return detail::ringbuffer_base::enqueue(begin, end, array_.c_array(), max_size); + return detail::ringbuffer_base::enqueue(begin, end, + array_.c_array(), max_size); } /** Dequeue a maximum of size objects from ringbuffer. * - * If dequeue operation is successful, object is written to memory location denoted by ret. + * If dequeue operation is successful, + * object is written to memory location denoted by ret. * * \return number of dequeued items * @@ -356,7 +380,8 @@ class ringbuffer: /* @{ */ size_t dequeue(T * ret, size_t size) { - return detail::ringbuffer_base::dequeue(ret, size, array_.c_array(), max_size); + return detail::ringbuffer_base::dequeue(ret, size, + array_.c_array(), max_size); } /** Enqueues all objects from the array t to the ringbuffer. @@ -400,7 +425,8 @@ class ringbuffer: max_size_(max_size), array_(new T[max_size]) {} - /** Enqueues object t to the ringbuffer. Enqueueing may fail, if the ringbuffer is full. + /** Enqueues object t to the ringbuffer. + * Enqueueing may fail, if the ringbuffer is full. * * \return true, if the enqueue operation is successful. * @@ -413,9 +439,11 @@ class ringbuffer: /** Dequeue object from ringbuffer. * - * If dequeue operation is successful, object is written to memory location denoted by ret. + * If dequeue operation is successful, + * object is written to memory location denoted by ret. * - * \return true, if the dequeue operation is successful, false if ringbuffer was empty. + * \return true, if the dequeue operation is successful, + * false if ringbuffer was empty. * * \note Thread-safe and non-blocking */ @@ -467,7 +495,8 @@ class ringbuffer: /** Dequeue a maximum of size objects from ringbuffer. * - * If dequeue operation is successful, object is written to memory location denoted by ret. + * If dequeue operation is successful, object is written to memory + * location denoted by ret. * * \return number of dequeued items * @@ -480,7 +509,8 @@ class ringbuffer: /** Dequeue objects from ringbuffer. * - * If dequeue operation is successful, object is written to memory location denoted by ret. + * If dequeue operation is successful, + object is written to memory location denoted by ret. * * \return number of dequeued items * diff --git a/external/lockfree/boost/lockfree/stack.hpp b/external/lockfree/boost/lockfree/stack.hpp index b1e726eaf70a..ef1a9b977b62 100644 --- a/external/lockfree/boost/lockfree/stack.hpp +++ b/external/lockfree/boost/lockfree/stack.hpp @@ -23,14 +23,21 @@ namespace boost { namespace lockfree { -/** The stack class provides a multi-writer/multi-reader stack, pushing and poping is lockfree, - * construction/destruction has to be synchronized. It uses a freelist for memory management, - * freed nodes are pushed to the freelist and not returned to the os before the stack is destroyed. +/** The stack class provides a multi-writer/multi-reader stack, + * pushing and poping is lockfree, + * construction/destruction has to be synchronized. + * It uses a freelist for memory management, + * freed nodes are pushed to the freelist and not returned to the os before + * the stack is destroyed. * - * The memory management of the stack can be controlled via its freelist_t template argument. Two different - * freelists can be used. struct caching_freelist_t selects a caching freelist, which can allocate more nodes - * from the operating system, and struct static_freelist_t uses a fixed-sized freelist. With a fixed-sized - * freelist, the push operation may fail, while with a caching freelist, the push operation may block. + * The memory management of the stack can be controlled via + * its freelist_t template argument. Two different + * freelists can be used. struct caching_freelist_t selects a caching freelist, + * which can allocate more nodes + * from the operating system, and struct static_freelist_t uses a fixed-sized freelist. + * With a fixed-sized + * freelist, the push operation may fail, while with a caching freelist, + * the push operation may block. * * \b Limitation: The class T is required to have a trivial assignment operator. * */ @@ -118,12 +125,14 @@ class stack: } } - /** Pushes object t to the queue. May fail, if the freelist is not able to allocate a new queue node. + /** Pushes object t to the queue. + * May fail, if the freelist is not able to allocate a new queue node. * * \returns true, if the push operation is successful. * * \note Thread-safe and non-blocking - * \warning \b Warning: May block if node needs to be allocated from the operating system + * \warning \b Warning: + * May block if node needs to be allocated from the operating system * */ bool push(T const & v) { @@ -143,12 +152,14 @@ class stack: } } - /** Pushes object t to the queue. May fail, if the freelist is not able to allocate a new queue node. + /** Pushes object t to the queue. + * May fail, if the freelist is not able to allocate a new queue node. * * \returns true, if the push operation is successful. * * \note Not thread-safe - * \warning \b Warning: May block if node needs to be allocated from the operating system + * \warning \b Warning: + * May block if node needs to be allocated from the operating system * */ bool push_unsafe(T const & v) { @@ -169,7 +180,8 @@ class stack: /** Pops object from stack. * - * If pop operation is successful, object is written to memory location denoted by ret. + * If pop operation is successful, + * object is written to memory location denoted by ret. * * \returns true, if the pop operation is successful, false if stack was empty. * @@ -197,7 +209,8 @@ class stack: /** Pops object from stack. * - * If pop operation is successful, object is written to memory location denoted by ret. + * If pop operation is successful, + * object is written to memory location denoted by ret. * * \returns true, if the pop operation is successful, false if stack was empty. * @@ -225,7 +238,8 @@ class stack: * * \warning The state of the stack can be modified by other threads * - * \note While this function is thread-safe, it only guarantees that at some point during the execution of the function the + * \note While this function is thread-safe, + * it only guarantees that at some point during the execution of the function the * stack has been empty * */ bool empty(void) const @@ -237,7 +251,8 @@ class stack: #ifndef BOOST_DOXYGEN_INVOKED detail::atomic tos; - static const int padding_size = BOOST_LOCKFREE_CACHELINE_BYTES - sizeof(tagged_node_ptr); + static const int padding_size = BOOST_LOCKFREE_CACHELINE_BYTES - + sizeof(tagged_node_ptr); char padding[padding_size]; pool_t pool; diff --git a/hpx/async.hpp b/hpx/async.hpp index 3325036d83bf..930287f5cd6b 100644 --- a/hpx/async.hpp +++ b/hpx/async.hpp @@ -27,7 +27,8 @@ namespace hpx { namespace detail { // Defer the evaluation of result_of during the SFINAE checks below #if defined(__clang__) - template ::type> + template ::type> struct create_future { typedef lcos::future type; @@ -53,7 +54,8 @@ namespace hpx { namespace detail { return lcos::make_ready_future(boost::ref(f())); } catch (...) { - return lcos::make_exceptional_future(boost::current_exception()); + return lcos::make_exceptional_future + (boost::current_exception()); } } @@ -70,7 +72,8 @@ namespace hpx { namespace detail { return lcos::make_ready_future(f()); } catch (...) { - return lcos::make_exceptional_future(boost::current_exception()); + return lcos::make_exceptional_future + (boost::current_exception()); } } diff --git a/hpx/components/containers/vector/vector.hpp b/hpx/components/containers/vector/vector.hpp index f19fbd59708c..3bbe4b82725e 100644 --- a/hpx/components/containers/vector/vector.hpp +++ b/hpx/components/containers/vector/vector.hpp @@ -1326,11 +1326,14 @@ namespace hpx // // clear should modified (clear each partition_vector one by one). // // void clear() // // { -// // //It is keeping one gid hence iterator does not go in an invalid state +// // //It is keeping one gid hence iterator does not go +// // //in an invalid state // // partitions_.erase(partitions_.begin() + 1, // // partitions_.end()-1); -// // partition_vector_stub::clear_async((partitions_[0].second).get()).get(); -// // HPX_ASSERT(partitions_.size() > 1); //As this function changes the size we should have LAST always. +// // partition_vector_stub::clear_async((partitions_[0].second).get()) +// // .get(); +// // HPX_ASSERT(partitions_.size() > 1); +// // //As this function changes the size we should have LAST always. // // } /////////////////////////////////////////////////////////////////////// diff --git a/hpx/components/security/certificate_signing_request.hpp b/hpx/components/security/certificate_signing_request.hpp index 3320d82b816a..9e186573a905 100644 --- a/hpx/components/security/certificate_signing_request.hpp +++ b/hpx/components/security/certificate_signing_request.hpp @@ -54,7 +54,7 @@ namespace hpx { namespace components { namespace security } friend std::ostream & operator<<(std::ostream & os, - certificate_signing_request const & certificate_signing_request) + certificate_signing_request const & certificate_signing_request) { return os << " const & signed_csr) { return hpx::async< - server::certificate_authority_base::sign_certificate_signing_request_action + server::certificate_authority_base + ::sign_certificate_signing_request_action >(gid, signed_csr).get(); } diff --git a/hpx/config.hpp b/hpx/config.hpp index 6ad61ff985fc..3f1cbf7457c7 100644 --- a/hpx/config.hpp +++ b/hpx/config.hpp @@ -7,7 +7,8 @@ #if !defined(HPX_CONFIG_MAR_24_2008_0943AM) #define HPX_CONFIG_MAR_24_2008_0943AM -// We need to detect if user code include boost/config.hpp before including hpx/config.hpp +// We need to detect if user code include boost/config.hpp before +// including hpx/config.hpp // Everything else might lead to hard compile errors and possible very subtile bugs. #if defined(BOOST_CONFIG_HPP) #error Boost.Config was included before the hpx config header. This might lead to subtile failures and compile errors. Please include before any other boost header @@ -29,11 +30,10 @@ #include #include -// On Windows, include winsock2.h as early as possible to work around a known -// include-order issue causing trouble if winsock.h is included before -// winsock2.h. #if defined(BOOST_MSVC) -#include +// On Windows, make sure winsock.h is not included even if windows.h is +// included before winsock2.h +#define _WINSOCKAPI_ #endif /////////////////////////////////////////////////////////////////////////////// @@ -514,12 +514,14 @@ #if defined(HPX_HAVE_SODIUM) # define HPX_ROOT_CERTIFICATE_AUTHORITY_MSB 0x0000000100000001ULL # define HPX_ROOT_CERTIFICATE_AUTHORITY_LSB 0x0000000000000005ULL -# define HPX_SUBORDINATE_CERTIFICATE_AUTHORITY_MSB 0x0000000000000001ULL // this is made locality specific +# define HPX_SUBORDINATE_CERTIFICATE_AUTHORITY_MSB 0x0000000000000001ULL +// this is made locality specific # define HPX_SUBORDINATE_CERTIFICATE_AUTHORITY_LSB 0x0000000000000006ULL #endif #if !defined(HPX_NO_DEPRECATED) -# define HPX_DEPRECATED_MSG "This function is deprecated and will be removed in the future." +# define HPX_DEPRECATED_MSG \ + "This function is deprecated and will be removed in the future." # if defined(BOOST_MSVC) # define HPX_DEPRECATED(x) __declspec(deprecated(x)) # elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) diff --git a/hpx/config/boost/compiler/intel.hpp b/hpx/config/boost/compiler/intel.hpp index 27f500c3ce4b..db60e42fdbde 100644 --- a/hpx/config/boost/compiler/intel.hpp +++ b/hpx/config/boost/compiler/intel.hpp @@ -27,7 +27,8 @@ #endif // Flags determined by comparing output of 'icpc -dM -E' with and without '-std=c++0x' -#if (!(defined(_WIN32) || defined(_WIN64)) && defined(__STDC_HOSTED__) && (__STDC_HOSTED__ && (BOOST_INTEL_CXX_VERSION <= 1310))) \ +#if (!(defined(_WIN32) || defined(_WIN64)) && defined(__STDC_HOSTED__) \ + && (__STDC_HOSTED__ && (BOOST_INTEL_CXX_VERSION <= 1310))) \ || defined(__GXX_EXPERIMENTAL_CPP0X__) || defined(__GXX_EXPERIMENTAL_CXX0X__) # define BOOST_INTEL_STDCXX0X #endif @@ -36,7 +37,8 @@ #endif #ifdef BOOST_INTEL_STDCXX0X -#define BOOST_COMPILER "Intel C++ C++0x mode version " BOOST_STRINGIZE(BOOST_INTEL_CXX_VERSION) +#define BOOST_COMPILER \ + "Intel C++ C++0x mode version " BOOST_STRINGIZE(BOOST_INTEL_CXX_VERSION) #else #define BOOST_COMPILER "Intel C++ version " BOOST_STRINGIZE(BOOST_INTEL_CXX_VERSION) #endif @@ -108,11 +110,13 @@ // later than that if they are set up to emulate gcc 3.2 // or earlier): // -# if ((__GNUC__ == 3) && (__GNUC_MINOR__ <= 2)) || (BOOST_INTEL < 900) || (__INTEL_COMPILER_BUILD_DATE < 20050912) +# if ((__GNUC__ == 3) && (__GNUC_MINOR__ <= 2)) || (BOOST_INTEL < 900) +|| (__INTEL_COMPILER_BUILD_DATE < 20050912) # define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL # endif #endif -#if (defined(__GNUC__) && (__GNUC__ < 4)) || defined(_WIN32) || (BOOST_INTEL_CXX_VERSION <= 1200) +#if (defined(__GNUC__) && (__GNUC__ < 4)) || defined(_WIN32) \ + || (BOOST_INTEL_CXX_VERSION <= 1200) // GCC or VC emulation: #define BOOST_NO_TWO_PHASE_NAME_LOOKUP #endif @@ -180,7 +184,8 @@ template<> struct assert_intrinsic_wchar_t {}; // intel-vc9-win-11.1 may leave a non-POD array uninitialized, in some // cases when it should be value-initialized. // (Niels Dekker, LKEB, May 2010) -// Apparently Intel 12.1 (compiler version number 9999 !!) has the same issue (compiler regression). +// Apparently Intel 12.1 (compiler version number 9999 !!) +// has the same issue (compiler regression). #if defined(__INTEL_COMPILER) # if (__INTEL_COMPILER <= 1110) || (__INTEL_COMPILER == 9999) # define BOOST_NO_COMPLETE_VALUE_INITIALIZATION @@ -213,8 +218,10 @@ template<> struct assert_intrinsic_wchar_t {}; #endif #if defined(BOOST_INTEL_STDCXX0X) && (BOOST_INTEL_CXX_VERSION >= 1200) -//# undef BOOST_NO_CXX11_RVALUE_REFERENCES // Enabling this breaks Filesystem and Exception libraries -//# undef BOOST_NO_CXX11_SCOPED_ENUMS // doesn't really work!! +//# undef BOOST_NO_CXX11_RVALUE_REFERENCES + // Enabling this breaks Filesystem and Exception libraries +//# undef BOOST_NO_CXX11_SCOPED_ENUMS + // doesn't really work!! #ifdef __MIC__ # define BOOST_NO_CXX11_ALLOCATOR # define BOOST_NO_CXX11_SMART_PTR @@ -233,7 +240,8 @@ template<> struct assert_intrinsic_wchar_t {}; #if defined(BOOST_INTEL_STDCXX0X) && (BOOST_INTEL_CXX_VERSION > 1200) # undef BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS // std::nullptr seems to be enabled starting with gcc 4.4.7 -#if defined(_MSC_VER) || (defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 4 && __GNUC_PATCHLEVEL__ <= 7)) +#if defined(_MSC_VER) || (defined(__GNUC__) && !(__GNUC__ == 4 \ + && __GNUC_MINOR__ == 4 && __GNUC_PATCHLEVEL__ <= 7)) # undef BOOST_NO_CXX11_NULLPTR #endif # undef BOOST_NO_CXX11_RVALUE_REFERENCES @@ -248,7 +256,8 @@ template<> struct assert_intrinsic_wchar_t {}; #if defined(_MSC_VER) && (_MSC_VER <= 1700) // -// Although the Intel compiler is capable of supporting these, it appears not to in MSVC compatibility mode: +// Although the Intel compiler is capable of supporting these, +// it appears not to in MSVC compatibility mode: // # define BOOST_NO_CXX11_HDR_INITIALIZER_LIST # define BOOST_NO_CXX11_VARIADIC_TEMPLATES @@ -274,7 +283,8 @@ template<> struct assert_intrinsic_wchar_t {}; // We don't emit this warning any more, since we have so few // defect macros set anyway (just the one). // -//# pragma message("Unknown compiler version - please run the configure tests and report the results") +//# pragma message("Unknown compiler version +//# - please run the configure tests and report the results") # endif #endif diff --git a/hpx/config/compiler_specific.hpp b/hpx/config/compiler_specific.hpp index c1edd62ffa31..459c8772292e 100644 --- a/hpx/config/compiler_specific.hpp +++ b/hpx/config/compiler_specific.hpp @@ -26,7 +26,8 @@ #if defined(__clang__) -# define HPX_CLANG_VERSION (__clang_major__*10000 + __clang_minor__*100 + __clang_patchlevel__) +# define HPX_CLANG_VERSION \ + (__clang_major__*10000 + __clang_minor__*100 + __clang_patchlevel__) # undef HPX_INTEL_VERSION diff --git a/hpx/error.hpp b/hpx/error.hpp index 5edf47279d01..b845e83ca658 100644 --- a/hpx/error.hpp +++ b/hpx/error.hpp @@ -24,63 +24,120 @@ namespace hpx /// reported from any of the API functions. enum error { - success = 0, ///< The operation was successful - no_success = 1, ///< The operation did failed, but not in an unexpected manner - not_implemented = 2, ///< The operation is not implemented - out_of_memory = 3, ///< The operation caused a out of memory condition - bad_action_code = 4, ///< - bad_component_type = 5, ///< The specified component type is not known or otherwise invalid - network_error = 6, ///< A generic network error occurred - version_too_new = 7, ///< The version of the network representation for this object is too new - version_too_old = 8, ///< The version of the network representation for this object is too old - version_unknown = 9, ///< The version of the network representation for this object is unknown - unknown_component_address = 10, ///< - duplicate_component_address = 11, ///< The given global id has already been registered - invalid_status = 12, ///< The operation was executed in an invalid status - bad_parameter = 13, ///< One of the supplied parameters is invalid - internal_server_error = 14, ///< - service_unavailable = 15, ///< - bad_request = 16, ///< - repeated_request = 17, ///< - lock_error = 18, ///< - duplicate_console = 19, ///< There is more than one console locality - no_registered_console = 20, ///< There is no registered console locality available - startup_timed_out = 21, ///< - uninitialized_value = 22, ///< - bad_response_type = 23, ///< - deadlock = 24, ///< - assertion_failure = 25, ///< - null_thread_id = 26, ///< Attempt to invoke a API function from a non-HPX thread - invalid_data = 27, ///< - yield_aborted = 28, ///< The yield operation was aborted - dynamic_link_failure = 29, ///< - commandline_option_error = 30, ///< One of the options given on the command line is erroneous - serialization_error = 31, ///< There was an error during serialization of this object - unhandled_exception = 32, ///< An unhandled exception has been caught - kernel_error = 33, ///< The OS kernel reported an error - broken_task = 34, ///< The task associated with this future object is not available anymore - task_moved = 35, ///< The task associated with this future object has been moved - task_already_started = 36, ///< The task associated with this future object has already been started - future_already_retrieved = 37, ///< The future object has already been retrieved - promise_already_satisfied = 38, ///< The value for this future object has already been set - future_does_not_support_cancellation = 39, ///< The future object does not support cancellation - future_can_not_be_cancelled = 40, ///< The future can't be canceled at this time - no_state = 41, ///< The future object has no valid shared state - broken_promise = 42, ///< The promise has been deleted - thread_resource_error = 43, ///< - future_cancelled = 44, ///< - thread_cancelled = 45, ///< - thread_not_interruptable = 46, ///< - duplicate_component_id = 47, ///< The component type has already been registered - unknown_error = 48, ///< An unknown error occurred - bad_plugin_type = 49, ///< The specified plugin type is not known or otherwise invalid - security_error = 50, ///< An error occurred in the security component - filesystem_error = 51, ///< The specified file does not exist or other filesystem related error - bad_function_call = 52, ///< equivalent of std::bad_function_call - task_canceled_exception = 53, ///< parallel::v2::task_canceled_exception - task_block_not_active = 54, ///< task_region is not active - out_of_range = 55, ///< Equivalent to std::out_of_range - length_error = 56, ///< Equivalent to std::length_error + success = 0, + ///< The operation was successful + no_success = 1, + ///< The operation did failed, but not in an unexpected manner + not_implemented = 2, + ///< The operation is not implemented + out_of_memory = 3, + ///< The operation caused a out of memory condition + bad_action_code = 4, + ///< + bad_component_type = 5, + ///< The specified component type is not known or otherwise invalid + network_error = 6, + ///< A generic network error occurred + version_too_new = 7, + ///< The version of the network representation for this object is too new + version_too_old = 8, + ///< The version of the network representation for this object is too old + version_unknown = 9, + ///< The version of the network representation for this object is unknown + unknown_component_address = 10, + ///< + duplicate_component_address = 11, + ///< The given global id has already been registered + invalid_status = 12, + ///< The operation was executed in an invalid status + bad_parameter = 13, + ///< One of the supplied parameters is invalid + internal_server_error = 14, + ///< + service_unavailable = 15, + ///< + bad_request = 16, + ///< + repeated_request = 17, + ///< + lock_error = 18, + ///< + duplicate_console = 19, + ///< There is more than one console locality + no_registered_console = 20, + ///< There is no registered console locality available + startup_timed_out = 21, + ///< + uninitialized_value = 22, + ///< + bad_response_type = 23, + ///< + deadlock = 24, + ///< + assertion_failure = 25, + ///< + null_thread_id = 26, + ///< Attempt to invoke a API function from a non-HPX thread + invalid_data = 27, + ///< + yield_aborted = 28, + ///< The yield operation was aborted + dynamic_link_failure = 29, + ///< + commandline_option_error = 30, + ///< One of the options given on the command line is erroneous + serialization_error = 31, + ///< There was an error during serialization of this object + unhandled_exception = 32, + ///< An unhandled exception has been caught + kernel_error = 33, + ///< The OS kernel reported an error + broken_task = 34, + ///< The task associated with this future object is not available anymore + task_moved = 35, + ///< The task associated with this future object has been moved + task_already_started = 36, + ///< The task associated with this future object has already been started + future_already_retrieved = 37, + ///< The future object has already been retrieved + promise_already_satisfied = 38, + ///< The value for this future object has already been set + future_does_not_support_cancellation = 39, + ///< The future object does not support cancellation + future_can_not_be_cancelled = 40, + ///< The future can't be canceled at this time + no_state = 41, + ///< The future object has no valid shared state + broken_promise = 42, + ///< The promise has been deleted + thread_resource_error = 43, + ///< + future_cancelled = 44, + ///< + thread_cancelled = 45, + ///< + thread_not_interruptable = 46, + ///< + duplicate_component_id = 47, + ///< The component type has already been registered + unknown_error = 48, + ///< An unknown error occurred + bad_plugin_type = 49, + ///< The specified plugin type is not known or otherwise invalid + security_error = 50, + ///< An error occurred in the security component + filesystem_error = 51, + ///< The specified file does not exist or other filesystem related error + bad_function_call = 52, + ///< equivalent of std::bad_function_call + task_canceled_exception = 53, + ///< parallel::v2::task_canceled_exception + task_block_not_active = 54, + ///< task_region is not active + out_of_range = 55, + ///< Equivalent to std::out_of_range + length_error = 56, + ///< Equivalent to std::length_error /// \cond NOINTERNAL last_error, diff --git a/hpx/exception.hpp b/hpx/exception.hpp index ef622c06612b..8aed67a3cec7 100644 --- a/hpx/exception.hpp +++ b/hpx/exception.hpp @@ -562,7 +562,8 @@ namespace hpx /// temporarily reversed by constructing an instance of /// \a hpx::this_thread::restore_interruption, passing in the /// \a hpx::this_thread::disable_interruption object in question. This will restore - /// the interruption state to what it was when the \a hpx::this_thread::disable_interruption + /// the interruption state to what it was when the + /// \a hpx::this_thread::disable_interruption /// object was constructed, and then disable interruption again when the /// \a hpx::this_thread::restore_interruption object is destroyed. /// diff --git a/hpx/hpx_fwd.hpp b/hpx/hpx_fwd.hpp index 4571cae9cfe7..24bac3e112db 100644 --- a/hpx/hpx_fwd.hpp +++ b/hpx/hpx_fwd.hpp @@ -39,16 +39,17 @@ #include #include -#include // this has to come before the naming/id_type.hpp below +#include +#include +// ^ this has to come before the naming/id_type.hpp below #include #include #include -#include #include #include +#include #include #include -#include /// \cond NOINTERNAL namespace boost @@ -147,250 +148,6 @@ namespace hpx HPX_API_EXPORT bool do_background_work(std::size_t num_thread = 0); } - namespace util - { - namespace coroutines - { - namespace detail - { - template - class coroutine_self; - - template - struct coroutine_allocator; - template class Heap> - class coroutine_impl; - } - - template class Heap, - typename ContextImpl = detail::default_context_impl> - class coroutine; - } - } - - /// \namespace threads - /// - /// The namespace \a thread-manager contains all the definitions required - /// for the scheduling, execution and general management of \a - /// hpx#threadmanager#thread's. - namespace threads - { - namespace policies - { - struct scheduler_base; - - struct lockfree_fifo; - struct lockfree_lifo; - - // multi priority scheduler with work-stealing - template - class HPX_EXPORT local_priority_queue_scheduler; - - // single priority scheduler with work-stealing - template - class HPX_EXPORT local_queue_scheduler; - -#if defined(HPX_HAVE_THROTTLE_SCHEDULER) - template - class HPX_EXPORT throttle_queue_scheduler; -#endif - -#if defined(HPX_HAVE_PERIODIC_PRIORITY_SCHEDULER) - template - class HPX_EXPORT periodic_priority_queue_scheduler; -#endif - -#if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER) - // multi priority scheduler with no work-stealing - template - class HPX_EXPORT static_priority_queue_scheduler; -#endif - -#if defined(HPX_HAVE_STATIC_SCHEDULER) - // single priority scheduler with no work-stealing - template - class HPX_EXPORT static_queue_scheduler; -#endif - -#if defined(HPX_HAVE_HIERARCHY_SCHEDULER) - template - class HPX_EXPORT hierarchy_scheduler; -#endif - - typedef local_priority_queue_scheduler< - boost::mutex, - lockfree_fifo, // FIFO pending queuing - lockfree_fifo, // FIFO staged queuing - lockfree_lifo // LIFO terminated queuing - > fifo_priority_queue_scheduler; - -#if defined(HPX_HAVE_ABP_SCHEDULER) - struct lockfree_abp_fifo; - struct lockfree_abp_lifo; - - typedef local_priority_queue_scheduler< - boost::mutex, - lockfree_abp_fifo, // FIFO + ABP pending queuing - lockfree_abp_fifo, // FIFO + ABP staged queuing - lockfree_lifo // LIFO terminated queuing - > abp_fifo_priority_queue_scheduler; -#endif - - // define the default scheduler to use - typedef fifo_priority_queue_scheduler queue_scheduler; - - class HPX_EXPORT callback_notifier; - } - - struct HPX_EXPORT threadmanager_base; - class HPX_EXPORT thread_data_base; - class HPX_EXPORT thread_data; - - template - class HPX_EXPORT threadmanager_impl; - - typedef thread_state_enum thread_function_sig(thread_state_ex_enum); - typedef util::unique_function_nonser - thread_function_type; - - class HPX_EXPORT executor; - - /////////////////////////////////////////////////////////////////////// - /// \ cond NODETAIL - namespace detail - { - template struct coroutine_allocator; - } - /// \ endcond - typedef util::coroutines::coroutine< - thread_function_sig, detail::coroutine_allocator> coroutine_type; - - typedef util::coroutines::detail::coroutine_self - thread_self; - typedef - util::coroutines::detail::coroutine_impl< - coroutine_type - , util::coroutines::detail::default_context_impl - , detail::coroutine_allocator - > - thread_self_impl_type; - typedef void * thread_id_repr_type; - - typedef boost::intrusive_ptr thread_id_type; - - HPX_EXPORT void intrusive_ptr_add_ref(thread_data_base* p); - HPX_EXPORT void intrusive_ptr_release(thread_data_base* p); - - /////////////////////////////////////////////////////////////////////// - /// \ cond NODETAIL - BOOST_CONSTEXPR_OR_CONST thread_id_repr_type invalid_thread_id_repr = 0; - thread_id_type const invalid_thread_id = thread_id_type(); - /// \ endcond - - /// The function \a get_self returns a reference to the (OS thread - /// specific) self reference to the current HPX thread. - HPX_API_EXPORT thread_self& get_self(); - - /// The function \a get_self_ptr returns a pointer to the (OS thread - /// specific) self reference to the current HPX thread. - HPX_API_EXPORT thread_self* get_self_ptr(); - - /// The function \a get_ctx_ptr returns a pointer to the internal data - /// associated with each coroutine. - HPX_API_EXPORT thread_self_impl_type* get_ctx_ptr(); - - /// The function \a get_self_ptr_checked returns a pointer to the (OS - /// thread specific) self reference to the current HPX thread. - HPX_API_EXPORT thread_self* get_self_ptr_checked(error_code& ec = throws); - - /// The function \a get_self_id returns the HPX thread id of the current - /// thread (or zero if the current thread is not a HPX thread). - HPX_API_EXPORT thread_id_type get_self_id(); - - /// The function \a get_parent_id returns the HPX thread id of the - /// current thread's parent (or zero if the current thread is not a - /// HPX thread). - /// - /// \note This function will return a meaningful value only if the - /// code was compiled with HPX_HAVE_THREAD_PARENT_REFERENCE - /// being defined. - HPX_API_EXPORT thread_id_repr_type get_parent_id(); - - /// The function \a get_parent_phase returns the HPX phase of the - /// current thread's parent (or zero if the current thread is not a - /// HPX thread). - /// - /// \note This function will return a meaningful value only if the - /// code was compiled with HPX_HAVE_THREAD_PARENT_REFERENCE - /// being defined. - HPX_API_EXPORT std::size_t get_parent_phase(); - - /// The function \a get_parent_locality_id returns the id of the locality of - /// the current thread's parent (or zero if the current thread is not a - /// HPX thread). - /// - /// \note This function will return a meaningful value only if the - /// code was compiled with HPX_HAVE_THREAD_PARENT_REFERENCE - /// being defined. - HPX_API_EXPORT boost::uint32_t get_parent_locality_id(); - - /// The function \a get_self_component_id returns the lva of the - /// component the current thread is acting on - /// - /// \note This function will return a meaningful value only if the - /// code was compiled with HPX_HAVE_THREAD_TARGET_ADDRESS - /// being defined. - HPX_API_EXPORT boost::uint64_t get_self_component_id(); - - /// The function \a get_thread_manager returns a reference to the - /// current thread manager. - HPX_API_EXPORT threadmanager_base& get_thread_manager(); - - /// The function \a get_thread_count returns the number of currently - /// known threads. - /// - /// \note If state == unknown this function will not only return the - /// number of currently existing threads, but will add the number - /// of registered task descriptions (which have not been - /// converted into threads yet). - HPX_API_EXPORT boost::int64_t get_thread_count( - thread_state_enum state = unknown); - - /// \copydoc get_thread_count(thread_state_enum state) - HPX_API_EXPORT boost::int64_t get_thread_count( - thread_priority priority, thread_state_enum state = unknown); - } - class HPX_API_EXPORT runtime; class HPX_API_EXPORT thread; @@ -592,51 +349,6 @@ namespace hpx HPX_EXPORT components::server::runtime_support* get_runtime_support_ptr(); - /// \namespace lcos - namespace lcos - { - class base_lco; - template - class base_lco_with_value; - - template ::type> - class promise; - - template ::type, - typename DirectExecute = typename Action::direct_execution> - class packaged_action; - - template - class future; - - template - class shared_future; - - template - struct object_semaphore; - - namespace stubs - { - template - struct object_semaphore; - } - - namespace server - { - template - struct object_semaphore; - } - - namespace local - { - class barrier; - } - } - /// \namespace util namespace util { @@ -690,10 +402,6 @@ namespace hpx using naming::id_type; using naming::invalid_id; - using lcos::future; - using lcos::shared_future; - using lcos::promise; - /// \endcond } @@ -928,113 +636,6 @@ namespace hpx HPX_API_EXPORT naming::id_type find_locality(components::component_type type, error_code& ec = throws); - /////////////////////////////////////////////////////////////////////////// - /// \brief Return all registered ids from all localities from the given - /// base name. - /// - /// This function locates all ids which were registered with the given - /// base name. It returns a list of futures representing those ids. - /// - /// \param base_name [in] The base name for which to retrieve the - /// registered ids. - /// \param num_ids [in] The number of registered ids to expect. - /// - /// \returns A list of futures representing the ids which were registered - /// using the given base name. - /// - /// \note The future will become ready even if the event (for instance, - /// binding the name to an id) has already happened in the past. - /// This is important in order to reliably retrieve ids from a - /// name, even if the name was already registered. - /// - HPX_API_EXPORT std::vector > - find_all_ids_from_basename(char const* base_name, std::size_t num_ids); - - /// \brief Return registered ids from the given base name and sequence numbers. - /// - /// This function locates the ids which were registered with the given - /// base name and the given sequence numbers. It returns a list of futures - /// representing those ids. - /// - /// \param base_name [in] The base name for which to retrieve the - /// registered ids. - /// \param ids [in] The sequence numbers of the registered ids. - /// - /// \returns A list of futures representing the ids which were registered - /// using the given base name and sequence numbers. - /// - /// \note The future will become ready even if the event (for instance, - /// binding the name to an id) has already happened in the past. - /// This is important in order to reliably retrieve ids from a - /// name, even if the name was already registered. - /// - HPX_API_EXPORT std::vector > - find_ids_from_basename(char const* base_name, - std::vector const& ids); - - /// \brief Return registered id from the given base name and sequence number. - /// - /// This function locates the id which was registered with the given - /// base name and the given sequence number. It returns a future - /// representing those id. - /// - /// \param base_name [in] The base name for which to retrieve the - /// registered ids. - /// \param sequence_nr [in] The sequence number of the registered id. - /// - /// \returns A representing the id which was registered using the given - /// base name and sequence numbers. - /// - /// \note The future will become ready even if the event (for instance, - /// binding the name to an id) has already happened in the past. - /// This is important in order to reliably retrieve ids from a - /// name, even if the name was already registered. - /// - HPX_API_EXPORT hpx::future - find_id_from_basename(char const* base_name, - std::size_t sequence_nr = ~0U); - - /////////////////////////////////////////////////////////////////////////// - /// \brief Register the given id using the given base name. - /// - /// The function registers the given ids using the provided base name. - /// - /// \param base_name [in] The base name for which to retrieve the - /// registered ids. - /// \param id [in] The id to register using the given base name. - /// \param sequence_nr [in, optional] The sequential number to use for the - /// registration of the id. This number has to be - /// unique system wide for each registration using the - /// same base name. The default is the current locality - /// identifier. Also, the sequence numbers have to be - /// consecutive starting from zero. - /// - /// \returns A future representing the result of the registration operation - /// itself. - /// - /// \note The operation will fail if the given sequence number is not - /// unique. - /// - HPX_API_EXPORT hpx::future register_id_with_basename( - char const* base_name, hpx::id_type id, std::size_t sequence_nr = ~0U); - - /// \brief Unregister the given id using the given base name. - /// - /// The function unregisters the given ids using the provided base name. - /// - /// \param base_name [in] The base name for which to retrieve the - /// registered ids. - /// \param sequence_nr [in, optional] The sequential number to use for the - /// un-registration. This number has to be the same - /// as has been used with \a register_id_with_basename - /// before. - /// - /// \returns A future representing the result of the un-registration - /// operation itself. - /// - HPX_API_EXPORT hpx::future unregister_id_with_basename( - char const* base_name, std::size_t sequence_nr = ~0U); - /////////////////////////////////////////////////////////////////////////// /// \brief Return the number of localities which are currently registered /// for the running application. @@ -1515,6 +1116,7 @@ namespace hpx } // Including declarations of various API function declarations +#include #include #include #include diff --git a/hpx/hpx_init.hpp b/hpx/hpx_init.hpp index e81be959d21b..c9e9f346757e 100644 --- a/hpx/hpx_init.hpp +++ b/hpx/hpx_init.hpp @@ -474,7 +474,8 @@ namespace hpx inline int init(std::vector const& cfg, hpx::runtime_mode mode = hpx::runtime_mode_default); - /// \fn int init(int (*f)(boost::program_options::variables_map& vm), std::string const& app_name, int argc, char** argv) + /// \fn int init(int (*f)(boost::program_options::variables_map& vm), + /// std::string const& app_name, int argc, char** argv) /// /// \brief Main entry point for launching the HPX runtime system. /// @@ -511,7 +512,8 @@ namespace hpx std::string const& app_name, int argc, char** argv, hpx::runtime_mode mode = hpx::runtime_mode_default); - /// \fn int init(int (*f)(boost::program_options::variables_map& vm), std::string const& app_name, int argc, char** argv) + /// \fn int init(int (*f)(boost::program_options::variables_map& vm), + /// std::string const& app_name, int argc, char** argv) /// /// \brief Main entry point for launching the HPX runtime system. /// diff --git a/hpx/hpx_init_impl.hpp b/hpx/hpx_init_impl.hpp index 81af1957484d..5b2fcfaae1fa 100644 --- a/hpx/hpx_init_impl.hpp +++ b/hpx/hpx_init_impl.hpp @@ -20,7 +20,8 @@ namespace hpx namespace detail { HPX_EXPORT int run_or_start( - util::function_nonser const& f, + util::function_nonser + const& f, boost::program_options::options_description const& desc_cmdline, int argc, char** argv, std::vector const& ini_config, startup_function_type const& startup, diff --git a/hpx/hpx_start.hpp b/hpx/hpx_start.hpp index 5da799ed65d2..c57fa74b9c9a 100644 --- a/hpx/hpx_start.hpp +++ b/hpx/hpx_start.hpp @@ -487,7 +487,8 @@ namespace hpx inline bool start(std::vector const& cfg, hpx::runtime_mode mode = hpx::runtime_mode_default); - /// \fn bool start(int (*f)(boost::program_options::variables_map& vm), std::string const& app_name, int argc, char** argv) + /// \fn bool start(int (*f)(boost::program_options::variables_map& vm), + /// std::string const& app_name, int argc, char** argv) /// /// \brief Main non-blocking entry point for launching the HPX runtime system. /// diff --git a/hpx/hpx_start_impl.hpp b/hpx/hpx_start_impl.hpp index 049f6dd13ed9..68a6e1583254 100644 --- a/hpx/hpx_start_impl.hpp +++ b/hpx/hpx_start_impl.hpp @@ -16,7 +16,8 @@ namespace hpx namespace detail { HPX_EXPORT int run_or_start( - util::function_nonser const& f, + util::function_nonser + const& f, boost::program_options::options_description const& desc_cmdline, int argc, char** argv, std::vector const& ini_config, startup_function_type const& startup, diff --git a/hpx/lcos/broadcast.hpp b/hpx/lcos/broadcast.hpp index 76ae40b566e1..4c2b04f4f6fa 100644 --- a/hpx/lcos/broadcast.hpp +++ b/hpx/lcos/broadcast.hpp @@ -258,7 +258,8 @@ namespace hpx { namespace lcos , typename ...Ts > void - broadcast_invoke(broadcast_with_index, Futures& futures, hpx::id_type const& id + broadcast_invoke(broadcast_with_index, + Futures& futures, hpx::id_type const& id , std::size_t global_idx , Ts const&... vs) { @@ -409,7 +410,8 @@ namespace hpx { namespace lcos struct make_broadcast_action_impl; template - struct make_broadcast_action_impl > + struct make_broadcast_action_impl > { typedef typename broadcast_result::action_result @@ -449,7 +451,8 @@ namespace hpx { namespace lcos struct make_broadcast_apply_action_impl; template - struct make_broadcast_apply_action_impl > + struct make_broadcast_apply_action_impl > { typedef typename broadcast_result::action_result diff --git a/hpx/lcos/detail/async_colocated_fwd.hpp b/hpx/lcos/detail/async_colocated_fwd.hpp index cd1249118aab..637727d9ca3a 100644 --- a/hpx/lcos/detail/async_colocated_fwd.hpp +++ b/hpx/lcos/detail/async_colocated_fwd.hpp @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include namespace hpx { namespace detail @@ -33,6 +35,8 @@ namespace hpx { namespace detail , naming::id_type const& gid, Ts&&... vs); /////////////////////////////////////////////////////////////////////////// + // MSVC complains about ambiguities if it sees this forward declaration +#if !defined(BOOST_MSVC) template typename std::enable_if< traits::is_continuation::value, @@ -61,6 +65,7 @@ namespace hpx { namespace detail Continuation && cont , hpx::actions::basic_action /*act*/ , naming::id_type const& gid, Ts&&... vs); +#endif }} #if defined(HPX_HAVE_COLOCATED_BACKWARDS_COMPATIBILITY) diff --git a/hpx/lcos/detail/future_data.hpp b/hpx/lcos/detail/future_data.hpp index b087889a8879..42a0a0a91488 100644 --- a/hpx/lcos/detail/future_data.hpp +++ b/hpx/lcos/detail/future_data.hpp @@ -62,11 +62,15 @@ namespace detail /////////////////////////////////////////////////////////////////////// struct future_data_refcnt_base { + private: + typedef util::unique_function_nonser completed_callback_type; public: typedef void has_future_data_refcnt_base; virtual ~future_data_refcnt_base() {} + virtual void set_on_completed(completed_callback_type) = 0; + virtual bool requires_delete() { return 0 == --count_; diff --git a/hpx/lcos/future.hpp b/hpx/lcos/future.hpp index 6b96a4edac46..4404af790f36 100644 --- a/hpx/lcos/future.hpp +++ b/hpx/lcos/future.hpp @@ -8,6 +8,7 @@ #define HPX_LCOS_FUTURE_MAR_06_2012_1059AM #include +#include #include #include #include @@ -114,17 +115,43 @@ namespace hpx { namespace lcos { namespace detail { typedef typename traits::future_traits::result_type value_type; + if(ar.is_future_awaiting()) + { + if(!f.is_ready()) + { + typename hpx::traits::detail::shared_state_ptr_for::type state + = hpx::traits::future_access::get_shared_state(f); + + state->execute_deferred(); + + ar.await_future(f); + } + return; + } + +#if defined(HPX_DEBUG) if (f.valid()) { - f.wait(); + HPX_ASSERT(f.is_ready()); } +#endif int state = future_state::invalid; if (f.has_value()) { state = future_state::has_value; - value_type value = const_cast(f).get(); - ar << state << value; + if(ar.is_saving()) + { + value_type value = const_cast(f).get(); + ar << state << value; + } + else + { + value_type const & value = + *hpx::traits::future_access:: + get_shared_state(f)->get_result(); + ar << state << value; + } } else if (f.has_exception()) { state = future_state::has_exception; boost::exception_ptr exception = f.get_exception_ptr(); @@ -140,10 +167,27 @@ namespace hpx { namespace lcos { namespace detail boost::is_void::type> >::type serialize_future_save(Archive& ar, Future const& f) //-V659 { + if(ar.is_future_awaiting()) + { + if(!f.is_ready()) + { + typename + hpx::traits::detail::shared_state_ptr_for::type state + = hpx::traits::future_access::get_shared_state(f); + + state->execute_deferred(); + + ar.await_future(f); + } + return; + } + +#if defined(HPX_DEBUG) if (f.valid()) { - f.wait(); + HPX_ASSERT(f.is_ready()); } +#endif int state = future_state::invalid; if (f.has_value()) diff --git a/hpx/lcos/gather.hpp b/hpx/lcos/gather.hpp index 3dbe7e7dd61f..21a20c70c2ef 100644 --- a/hpx/lcos/gather.hpp +++ b/hpx/lcos/gather.hpp @@ -109,7 +109,7 @@ namespace hpx { namespace lcos char const* basename, std::size_t site) { hpx::id_type target = id.get(); - hpx::register_id_with_basename(basename, target, site); + hpx::register_with_basename(basename, target, site); return target; } @@ -216,7 +216,7 @@ namespace hpx { namespace lcos this_site = hpx::get_locality_id(); return gather_there( - hpx::find_id_from_basename(basename, root_site), + hpx::find_from_basename(basename, root_site), std::move(result), this_site); } }} diff --git a/hpx/lcos/local/recursive_mutex.hpp b/hpx/lcos/local/recursive_mutex.hpp index ea7db049b6bf..fc4d7fe81c68 100644 --- a/hpx/lcos/local/recursive_mutex.hpp +++ b/hpx/lcos/local/recursive_mutex.hpp @@ -158,7 +158,8 @@ namespace hpx { namespace lcos { namespace local util::unregister_lock(this); if (0 == --recursion_count) { - locking_thread_id.exchange(thread_id_from_mutex::invalid_id()); + locking_thread_id.exchange(thread_id_from_mutex + ::invalid_id()); util::reset_ignored(&mtx); mtx.unlock(); } @@ -204,7 +205,8 @@ namespace hpx { namespace lcos { namespace local public: typedef boost::unique_lock scoped_lock; - typedef boost::detail::try_lock_wrapper scoped_try_lock; + typedef boost::detail + ::try_lock_wrapper scoped_try_lock; }; } diff --git a/hpx/lcos/local/shared_mutex.hpp b/hpx/lcos/local/shared_mutex.hpp index 1f8115ef7d98..6d2327c34258 100644 --- a/hpx/lcos/local/shared_mutex.hpp +++ b/hpx/lcos/local/shared_mutex.hpp @@ -148,7 +148,8 @@ namespace hpx { namespace lcos { namespace local { boost::unique_lock lk(state_change); - while (state.exclusive || state.exclusive_waiting_blocked || state.upgrade) + while (state.exclusive || state.exclusive_waiting_blocked + || state.upgrade) { shared_cond.wait(lk, 1); } diff --git a/hpx/lcos/local/spinlock_pool.hpp b/hpx/lcos/local/spinlock_pool.hpp index 69bc22e21d8d..69590824b5f6 100644 --- a/hpx/lcos/local/spinlock_pool.hpp +++ b/hpx/lcos/local/spinlock_pool.hpp @@ -14,7 +14,7 @@ #define HPX_LCOS_LOCAL_SPINLOCK_POOL_HPP #include -#include +#include #include /////////////////////////////////////////////////////////////////////////////// diff --git a/hpx/lcos/wait_all.hpp b/hpx/lcos/wait_all.hpp index 4d7034e00ff4..ea2ca58bbcdd 100644 --- a/hpx/lcos/wait_all.hpp +++ b/hpx/lcos/wait_all.hpp @@ -292,7 +292,8 @@ namespace hpx { namespace lcos typedef typename detail::is_future_or_shared_state::type is_future; - typedef typename detail::is_future_or_shared_state_range::type + typedef typename detail::is_future_or_shared_state_range + ::type is_range; await_next(std::forward(iter), is_future(), is_range()); diff --git a/hpx/lcos/when_some.hpp b/hpx/lcos/when_some.hpp index 5a5e5b3f185a..d538680fd003 100644 --- a/hpx/lcos/when_some.hpp +++ b/hpx/lcos/when_some.hpp @@ -18,7 +18,8 @@ namespace hpx template struct when_some_result { - std::vector indices; ///< List of indices of futures which became ready + std::vector indices; + ///^ List of indices of futures which became ready Sequence futures; ///< The sequence of futures as passed to \a hpx::when_some }; diff --git a/hpx/lcos_fwd.hpp b/hpx/lcos_fwd.hpp new file mode 100644 index 000000000000..7c20d553c01d --- /dev/null +++ b/hpx/lcos_fwd.hpp @@ -0,0 +1,75 @@ +// Copyright (c) 2007-2014 Hartmut Kaiser +// Copyright (c) 2011 Bryce Lelbach +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/// \file lcos_fwd.hpp + +#ifndef HPX_LCOS_FWD_HPP +#define HPX_LCOS_FWD_HPP + +#include +#include + +namespace hpx +{ + /// \namespace lcos + namespace lcos + { + namespace detail + { + struct future_data_refcnt_base; + } + + class base_lco; + template + class base_lco_with_value; + + template ::type> + class promise; + + template ::type, + typename DirectExecute = typename Action::direct_execution> + class packaged_action; + + template + class future; + + template + class shared_future; + + template + struct object_semaphore; + + namespace stubs + { + template + struct object_semaphore; + } + + namespace server + { + template + struct object_semaphore; + } + + namespace local + { + class barrier; + + template + class promise; + } + } + + using lcos::future; + using lcos::shared_future; + using lcos::promise; +} + +#endif diff --git a/hpx/parallel/algorithms/detail/set_operation.hpp b/hpx/parallel/algorithms/detail/set_operation.hpp index 39bef03910e5..c8cf809e1c6b 100644 --- a/hpx/parallel/algorithms/detail/set_operation.hpp +++ b/hpx/parallel/algorithms/detail/set_operation.hpp @@ -85,8 +85,9 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) { namespace detail new buffer_type[combiner(len1, len2)]); typedef typename ExPolicy::executor_type executor_type; - std::size_t cores = executor_traits::os_thread_count( - policy.executor()); + std::size_t cores = executor_traits:: + processing_units_count(policy.executor(), policy.parameters()); + std::size_t step = (len1 + cores - 1) / cores; boost::shared_array chunks(new set_chunk_data[cores]); diff --git a/hpx/parallel/algorithms/exclusive_scan.hpp b/hpx/parallel/algorithms/exclusive_scan.hpp index 4823f1225541..be7fe4f3536e 100644 --- a/hpx/parallel/algorithms/exclusive_scan.hpp +++ b/hpx/parallel/algorithms/exclusive_scan.hpp @@ -159,7 +159,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /////////////////////////////////////////////////////////////////////////// /// Assigns through each iterator \a i in [result, result + (last - first)) /// the value of - /// GENERALIZED_NONCOMMUTATIVE_SUM(binary_op, init, *first, ..., *(first + (i - result) - 1)). + /// GENERALIZED_NONCOMMUTATIVE_SUM(binary_op, init, *first, ..., + /// *(first + (i - result) - 1)). /// /// \note Complexity: O(\a last - \a first) applications of the /// predicate \a op. @@ -225,7 +226,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// /// \note GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aN) is defined as: /// * a1 when N is 1 - /// * op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aK), GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, ..., aN)) + /// * op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aK), + /// GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, ..., aN)) /// where 1 < K+1 = M <= N. /// /// The difference between \a exclusive_scan and \a inclusive_scan is that @@ -323,7 +325,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// /// \note GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, ..., aN) is defined as: /// * a1 when N is 1 - /// * GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, ..., aK) + GENERALIZED_NONCOMMUTATIVE_SUM(+, aM, ..., aN) + /// * GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, ..., aK) + /// + GENERALIZED_NONCOMMUTATIVE_SUM(+, aM, ..., aN) /// where 1 < K+1 = M <= N. /// /// The difference between \a exclusive_scan and \a inclusive_scan is that diff --git a/hpx/parallel/algorithms/find.hpp b/hpx/parallel/algorithms/find.hpp index dbd51e2a2bef..25473d9aeadf 100644 --- a/hpx/parallel/algorithms/find.hpp +++ b/hpx/parallel/algorithms/find.hpp @@ -515,7 +515,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) return util::partitioner:: call_with_index( policy, first1, count-(diff-1), - [=](std::size_t base_idx, FwdIter it, std::size_t part_size) mutable + [=](std::size_t base_idx, FwdIter it, + std::size_t part_size) mutable { FwdIter curr = it; @@ -809,7 +810,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) { util::loop_idx_n( base_idx, it, part_size, tok, - [&tok, &s_first, &s_last, &op](reference v, std::size_t i) + [&tok, &s_first, &s_last, &op] + (reference v, std::size_t i) { for(FwdIter iter = s_first; iter != s_last; ++iter) { if(op(v,*iter)) @@ -880,8 +882,10 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// returns \a InIter otherwise. /// The \a find_first_of algorithm returns an iterator to the first element /// in the range [first, last) that is equal to an element from the range - /// [s_first, s_last). If the length of the subsequence [s_first, s_last) is - /// greater than the length of the range [first, last), \a last is returned. + /// [s_first, s_last). + /// If the length of the subsequence [s_first, s_last) is + /// greater than the length of the range [first, last), + /// \a last is returned. /// Additionally if the size of the subsequence is empty or no subsequence /// is found, \a last is also returned. /// @@ -984,11 +988,14 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// returns \a InIter otherwise. /// The \a find_first_of algorithm returns an iterator to the first element /// in the range [first, last) that is equal to an element from the range - /// [s_first, s_last). If the length of the subsequence [s_first, s_last) is - /// greater than the length of the range [first, last), \a last is returned. + /// [s_first, s_last). + /// If the length of the subsequence [s_first, s_last) is + /// greater than the length of the range [first, last), + /// \a last is returned. /// Additionally if the size of the subsequence is empty or no subsequence /// is found, \a last is also returned. - /// This overload of \a find_end is available if the user decides to provide the + /// This overload of \a find_end is available if + /// the user decides to provide the /// algorithm their own predicate \a f. /// template diff --git a/hpx/parallel/algorithms/for_each.hpp b/hpx/parallel/algorithms/for_each.hpp index e1b179fb098a..7b01e4d812d9 100644 --- a/hpx/parallel/algorithms/for_each.hpp +++ b/hpx/parallel/algorithms/for_each.hpp @@ -337,7 +337,7 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// \param proj Specifies the function (or function object) which /// will be invoked for each of the elements as a /// projection operation before the actual predicate - /// \a is invoked. + /// \a f is invoked. /// /// The application of function objects in parallel algorithm /// invoked with an execution policy object of type @@ -350,7 +350,7 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// permitted to execute in an unordered fashion in unspecified /// threads, and indeterminately sequenced within each thread. /// - /// \returns The \a for_each_n algorithm returns a + /// \returns The \a for_each algorithm returns a /// \a hpx::future if the execution policy is of /// type /// \a sequential_task_execution_policy or diff --git a/hpx/parallel/algorithms/inclusive_scan.hpp b/hpx/parallel/algorithms/inclusive_scan.hpp index 7e61afae54cf..1f061720358d 100644 --- a/hpx/parallel/algorithms/inclusive_scan.hpp +++ b/hpx/parallel/algorithms/inclusive_scan.hpp @@ -219,7 +219,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// /// \note GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aN) is defined as: /// * a1 when N is 1 - /// * op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aK), GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, ..., aN)) + /// * op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aK), + /// GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, ..., aN)) /// where 1 < K+1 = M <= N. /// /// The difference between \a exclusive_scan and \a inclusive_scan is that @@ -317,7 +318,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// /// \note GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, ..., aN) is defined as: /// * a1 when N is 1 - /// * GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aK) + GENERALIZED_NONCOMMUTATIVE_SUM(+, aM, ..., aN) + /// * GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aK) + /// + GENERALIZED_NONCOMMUTATIVE_SUM(+, aM, ..., aN) /// where 1 < K+1 = M <= N. /// /// The difference between \a exclusive_scan and \a inclusive_scan is that @@ -409,7 +411,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// /// \note GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, ..., aN) is defined as: /// * a1 when N is 1 - /// * GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, ..., aK) + GENERALIZED_NONCOMMUTATIVE_SUM(+, aM, ..., aN) + /// * GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, ..., aK) + /// + GENERALIZED_NONCOMMUTATIVE_SUM(+, aM, ..., aN) /// where 1 < K+1 = M <= N. /// /// The difference between \a exclusive_scan and \a inclusive_scan is that diff --git a/hpx/parallel/algorithms/lexicographical_compare.hpp b/hpx/parallel/algorithms/lexicographical_compare.hpp index 982742bd0ba7..525599fcf671 100644 --- a/hpx/parallel/algorithms/lexicographical_compare.hpp +++ b/hpx/parallel/algorithms/lexicographical_compare.hpp @@ -33,7 +33,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) namespace detail { /// \cond NOINTERNAL - struct lexicographical_compare : public detail::algorithm + struct lexicographical_compare + : public detail::algorithm { lexicographical_compare() : lexicographical_compare::algorithm("lexicographical_compare") @@ -150,14 +151,17 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// calling thread. /// /// The comparison operations in the parallel \a lexicographical_compare - /// algorithm invoked with an execution policy object of type \a parallel_execution_policy + /// algorithm invoked with an execution policy object of type + /// \a parallel_execution_policy /// or \a parallel_task_execution_policy are permitted to execute in an unordered /// fashion in unspecified threads, and indeterminately sequenced /// within each thread. /// - /// \note Lexicographical comparison is an operation with the following properties + /// \note Lexicographical comparison is an operation + /// with the following properties /// - Two ranges are compared element by element - /// - The first mismatching element defines which range is lexicographically + /// - The first mismatching element defines which range + /// is lexicographically /// \a less or \a greater than the other /// - If one range is a prefix of another, the shorter range is /// lexicographically \a less than the other @@ -255,14 +259,17 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// calling thread. /// /// The comparison operations in the parallel \a lexicographical_compare - /// algorithm invoked with an execution policy object of type \a parallel_execution_policy + /// algorithm invoked with an execution policy object of type + /// \a parallel_execution_policy /// or \a parallel_task_execution_policy are permitted to execute in an unordered /// fashion in unspecified threads, and indeterminately sequenced /// within each thread. /// - /// \note Lexicographical comparision is an operation with the following properties + /// \note Lexicographical comparision is an operation with the + /// following properties /// - Two ranges are compared element by element - /// - The first mismatching element defines which range is lexicographically + /// - The first mismatching element defines which range + /// is lexicographically /// \a less or \a greater than the other /// - If one range is a prefix of another, the shorter range is /// lexicographically \a less than the other diff --git a/hpx/parallel/algorithms/mismatch.hpp b/hpx/parallel/algorithms/mismatch.hpp index 6f585f6cfa2c..383e4d21da86 100644 --- a/hpx/parallel/algorithms/mismatch.hpp +++ b/hpx/parallel/algorithms/mismatch.hpp @@ -388,7 +388,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) tok.cancel(i); }); }, - [=](std::vector > &&) mutable -> std::pair + [=](std::vector > &&) mutable -> + std::pair { difference_type mismatched = static_cast(tok.get_data()); diff --git a/hpx/parallel/algorithms/remove_copy.hpp b/hpx/parallel/algorithms/remove_copy.hpp index 2b09d6221e90..da2cebbf2ffe 100644 --- a/hpx/parallel/algorithms/remove_copy.hpp +++ b/hpx/parallel/algorithms/remove_copy.hpp @@ -237,8 +237,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// fashion in unspecified threads, and indeterminately sequenced /// within each thread. /// - /// \returns The \a remove_copy_if algorithm returns a \a hpx::future if the - /// execution policy is of type + /// \returns The \a remove_copy_if algorithm returns a \a hpx::future + /// if the execution policy is of type /// \a sequential_task_execution_policy or /// \a parallel_task_execution_policy and /// returns \a OutIter otherwise. diff --git a/hpx/parallel/algorithms/rotate.hpp b/hpx/parallel/algorithms/rotate.hpp index 2e09a6870f26..1b0f673e6859 100644 --- a/hpx/parallel/algorithms/rotate.hpp +++ b/hpx/parallel/algorithms/rotate.hpp @@ -155,7 +155,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// of \a MoveAssignable and \a MoveConstructible. /// /// \returns The \a rotate algorithm returns a \a hpx::future - /// if the execution policy is of type \a parallel_task_execution_policy and + /// if the execution policy is of type + /// \a parallel_task_execution_policy and /// returns \a FwdIter otherwise. /// The \a rotate algorithm returns the iterator equal to /// first + (last - new_first). @@ -281,7 +282,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// within each thread. /// /// \returns The \a rotate_copy algorithm returns a \a hpx::future - /// if the execution policy is of type \a parallel_task_execution_policy and + /// if the execution policy is of type + /// \a parallel_task_execution_policy and /// returns \a OutIter otherwise. /// The \a rotate_copy algorithm returns the output iterator to the /// element past the last element copied. diff --git a/hpx/parallel/algorithms/search.hpp b/hpx/parallel/algorithms/search.hpp index 62a21dffcac5..2ea21b17dddb 100644 --- a/hpx/parallel/algorithms/search.hpp +++ b/hpx/parallel/algorithms/search.hpp @@ -400,7 +400,8 @@ namespace hpx {namespace parallel { HPX_INLINE_NAMESPACE(v1) /// \endcond } - /// Searches the range [first, first+count) for any elements in the range [s_first, s_last). + /// Searches the range [first, first+count) for any elements in the range + /// [s_first, s_last). /// Uses the operator== to compare elements. /// /// \note Complexity: at most (S*N) comparisons where @@ -447,7 +448,8 @@ namespace hpx {namespace parallel { HPX_INLINE_NAMESPACE(v1) /// The \a search_n algorithm returns an iterator to the beginning of /// the first subsequence [s_first, s_last) in range [first, first+count). /// If the length of the subsequence [s_first, s_last) is greater - /// than the length of the range [first, first+count), \a first is returned. + /// than the length of the range [first, first+count), + /// \a first is returned. /// Additionally if the size of the subsequence is empty or no subsequence /// is found, \a first is also returned. /// @@ -545,7 +547,8 @@ namespace hpx {namespace parallel { HPX_INLINE_NAMESPACE(v1) /// The \a search_n algorithm returns an iterator to the beginning of /// the last subsequence [s_first, s_last) in range [first, first+count). /// If the length of the subsequence [s_first, s_last) is greater - /// than the length of the range [first, first+count), \a first is returned. + /// than the length of the range [first, first+count), + /// \a first is returned. /// Additionally if the size of the subsequence is empty or no subsequence /// is found, \a first is also returned. /// diff --git a/hpx/parallel/algorithms/set_symmetric_difference.hpp b/hpx/parallel/algorithms/set_symmetric_difference.hpp index 8b03b0fbe17a..475f75751e60 100644 --- a/hpx/parallel/algorithms/set_symmetric_difference.hpp +++ b/hpx/parallel/algorithms/set_symmetric_difference.hpp @@ -140,7 +140,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// output iterator. /// \tparam F The type of the function/function object to use /// (deduced). Unlike its sequential form, the parallel - /// overload of \a set_symmetric_difference requires \a F to meet the + /// overload of \a set_symmetric_difference requires + /// \a F to meet the /// requirements of \a CopyConstructible. /// /// \param policy The execution policy to use for the scheduling of @@ -180,12 +181,14 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// permitted to execute in an unordered fashion in unspecified /// threads, and indeterminately sequenced within each thread. /// - /// \returns The \a set_symmetric_difference algorithm returns a \a hpx::future + /// \returns The \a set_symmetric_difference algorithm returns a + /// \a hpx::future /// if the execution policy is of type /// \a sequential_task_execution_policy or /// \a parallel_task_execution_policy and /// returns \a OutIter otherwise. - /// The \a set_symmetric_difference algorithm returns the output iterator to the + /// The \a set_symmetric_difference algorithm returns the output + /// iterator to the /// element in the destination range, one past the last element /// copied. /// @@ -296,12 +299,14 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// permitted to execute in an unordered fashion in unspecified /// threads, and indeterminately sequenced within each thread. /// - /// \returns The \a set_symmetric_difference algorithm returns a \a hpx::future + /// \returns The \a set_symmetric_difference algorithm returns a + /// \a hpx::future /// if the execution policy is of type /// \a sequential_task_execution_policy or /// \a parallel_task_execution_policy and /// returns \a OutIter otherwise. - /// The \a set_symmetric_difference algorithm returns the output iterator to the + /// The \a set_symmetric_difference algorithm returns the output + /// iterator to the /// element in the destination range, one past the last element /// copied. /// diff --git a/hpx/parallel/algorithms/transform_exclusive_scan.hpp b/hpx/parallel/algorithms/transform_exclusive_scan.hpp index 8f9e66fe5cd4..26722b828a45 100644 --- a/hpx/parallel/algorithms/transform_exclusive_scan.hpp +++ b/hpx/parallel/algorithms/transform_exclusive_scan.hpp @@ -157,7 +157,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /////////////////////////////////////////////////////////////////////////// /// Assigns through each iterator \a i in [result, result + (last - first)) /// the value of - /// GENERALIZED_NONCOMMUTATIVE_SUM(binary_op, init, conv(*first), ..., conv(*(first + (i - result) - 1))). + /// GENERALIZED_NONCOMMUTATIVE_SUM(binary_op, init, conv(*first), ..., + /// conv(*(first + (i - result) - 1))). /// /// \note Complexity: O(\a last - \a first) applications of the /// predicates \a op and \a conv. @@ -240,7 +241,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// /// \note GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aN) is defined as: /// * a1 when N is 1 - /// * op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aK), GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, ..., aN) + /// * op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aK), + /// GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, ..., aN) /// where 1 < K+1 = M <= N. /// /// Neither \a conv nor \a op shall invalidate iterators or subranges, or diff --git a/hpx/parallel/algorithms/transform_inclusive_scan.hpp b/hpx/parallel/algorithms/transform_inclusive_scan.hpp index d4639a71b190..afbbdb593aa4 100644 --- a/hpx/parallel/algorithms/transform_inclusive_scan.hpp +++ b/hpx/parallel/algorithms/transform_inclusive_scan.hpp @@ -155,7 +155,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /////////////////////////////////////////////////////////////////////////// /// Assigns through each iterator \a i in [result, result + (last - first)) /// the value of - /// GENERALIZED_NONCOMMUTATIVE_SUM(op, init, conv(*first), ..., conv(*(first + (i - result)))). + /// GENERALIZED_NONCOMMUTATIVE_SUM(op, init, conv(*first), ..., + /// conv(*(first + (i - result)))). /// /// \note Complexity: O(\a last - \a first) applications of the /// predicate \a op. @@ -217,11 +218,13 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// sequence can be implicitly converted to any /// of those types. /// - /// The reduce operations in the parallel \a transform_inclusive_scan algorithm invoked + /// The reduce operations in the parallel \a transform_inclusive_scan algorithm + /// invoked /// with an execution policy object of type \a sequential_execution_policy /// execute in sequential order in the calling thread. /// - /// The reduce operations in the parallel \a transform_inclusive_scan algorithm invoked + /// The reduce operations in the parallel \a transform_inclusive_scan algorithm + /// invoked /// with an execution policy object of type \a parallel_execution_policy /// or \a parallel_task_execution_policy are permitted to execute in an unordered /// fashion in unspecified threads, and indeterminately sequenced @@ -238,7 +241,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// /// \note GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aN) is defined as: /// * a1 when N is 1 - /// * op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aK), GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, ..., aN)) + /// * op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aK), + /// GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, ..., aN)) /// where 1 < K+1 = M <= N. /// /// Neither \a conv nor \a op shall invalidate iterators or subranges, or @@ -291,7 +295,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /////////////////////////////////////////////////////////////////////////// /// Assigns through each iterator \a i in [result, result + (last - first)) /// the value of - /// GENERALIZED_NONCOMMUTATIVE_SUM(op, conv(*first), ..., conv(*(first + (i - result)))). + /// GENERALIZED_NONCOMMUTATIVE_SUM(op, conv(*first), ..., + /// conv(*(first + (i - result)))). /// /// \note Complexity: O(\a last - \a first) applications of the /// predicate \a op. @@ -352,11 +357,13 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// sequence can be implicitly converted to any /// of those types. /// - /// The reduce operations in the parallel \a transform_inclusive_scan algorithm invoked + /// The reduce operations in the parallel \a transform_inclusive_scan algorithm + /// invoked /// with an execution policy object of type \a sequential_execution_policy /// execute in sequential order in the calling thread. /// - /// The reduce operations in the parallel \a transform_inclusive_scan algorithm invoked + /// The reduce operations in the parallel \a transform_inclusive_scan algorithm + /// invoked /// with an execution policy object of type \a parallel_execution_policy /// or \a parallel_task_execution_policy are permitted to execute in an unordered /// fashion in unspecified threads, and indeterminately sequenced @@ -373,7 +380,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// /// \note GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aN) is defined as: /// * a1 when N is 1 - /// * op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aK), GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, ..., aN)) + /// * op(GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aK), + /// GENERALIZED_NONCOMMUTATIVE_SUM(op, aM, ..., aN)) /// where 1 < K+1 = M <= N. /// /// Neither \a conv nor \a op shall invalidate iterators or subranges, or diff --git a/hpx/parallel/algorithms/transform_reduce.hpp b/hpx/parallel/algorithms/transform_reduce.hpp index 374cb1ad4186..8d7b59b6fb98 100644 --- a/hpx/parallel/algorithms/transform_reduce.hpp +++ b/hpx/parallel/algorithms/transform_reduce.hpp @@ -139,7 +139,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) /// \endcond } - /// Returns GENERALIZED_SUM(red_op, init, conv_op(*first), ..., conv_op(*(first + (last - first) - 1))). + /// Returns GENERALIZED_SUM(red_op, init, conv_op(*first), ..., + /// conv_op(*(first + (last - first) - 1))). /// /// \note Complexity: O(\a last - \a first) applications of the /// predicates \a red_op and \a conv_op. diff --git a/hpx/parallel/executors/auto_chunk_size.hpp b/hpx/parallel/executors/auto_chunk_size.hpp index 7f328ebf2f17..c296e44febd1 100644 --- a/hpx/parallel/executors/auto_chunk_size.hpp +++ b/hpx/parallel/executors/auto_chunk_size.hpp @@ -60,7 +60,7 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v3) std::size_t get_chunk_size(Executor& exec, F && f, std::size_t count) { std::size_t const cores = - executor_traits::os_thread_count(exec); + executor_traits::processing_units_count(exec, *this); if (count > 100*cores) { diff --git a/hpx/parallel/executors/executor_parameter_traits.hpp b/hpx/parallel/executors/executor_parameter_traits.hpp index fa5322e07653..39819e3dbfd3 100644 --- a/hpx/parallel/executors/executor_parameter_traits.hpp +++ b/hpx/parallel/executors/executor_parameter_traits.hpp @@ -48,6 +48,29 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v3) typedef typename Executor::executor_parameters_type type; }; + /////////////////////////////////////////////////////////////////////// + struct processing_units_count_parameter_helper + { + template + static std::size_t call(wrap_int, Parameters& params) + { + return hpx::get_os_thread_count(); + } + + template + static auto call(int, Parameters& params) + -> decltype(params.processing_units_count()) + { + return params.processing_units_count(); + } + }; + + template + std::size_t call_processing_units_parameter_count(Parameters& params) + { + return processing_units_count_parameter_helper::call(0, params); + } + /////////////////////////////////////////////////////////////////////// struct variable_chunk_size_helper { @@ -153,6 +176,24 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v3) return detail::call_get_chunk_size(params, exec, std::forward(f), num_tasks); } + + /// Retrieve the number of (kernel-)threads used by the associated + /// executor. + /// + /// \param exec [in] The executor object to use for scheduling of the + /// function \a f. + /// \param params [in] The executor parameters object to use as a + /// fallback if the executor does not expose + /// + /// \note This calls exec.processing_units_count() if it exists; + /// otherwise it forwards teh request to the executor parameters + /// object. + /// + static std::size_t processing_units_count( + executor_parameters_type& params) + { + return detail::call_processing_units_parameter_count(params); + } }; /////////////////////////////////////////////////////////////////////////// diff --git a/hpx/parallel/executors/executor_traits.hpp b/hpx/parallel/executors/executor_traits.hpp index e981fae2490c..4f4097feeecb 100644 --- a/hpx/parallel/executors/executor_traits.hpp +++ b/hpx/parallel/executors/executor_traits.hpp @@ -350,26 +350,31 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v3) } /////////////////////////////////////////////////////////////////////// - struct os_thread_count_helper + template + std::size_t call_processing_units_parameter_count(Parameters& params); + + struct processing_units_count_helper { - template - static std::size_t call(wrap_int, Executor& exec) + template + static std::size_t call(wrap_int, Executor& exec, + Parameters& params) { - return hpx::get_os_thread_count(); + return call_processing_units_parameter_count(params); } - template - static auto call(int, Executor& exec) - -> decltype(exec.os_thread_count()) + template + static auto call(int, Executor& exec, Parameters& params) + -> decltype(exec.processing_units_count(params)) { - return exec.os_thread_count(); + return exec.processing_units_count(params); } }; - template - std::size_t call_os_thread_count(Executor& exec) + template + std::size_t call_processing_units_count(Executor& exec, + Parameters& params) { - return os_thread_count_helper::call(0, exec); + return processing_units_count_helper::call(0, exec, params); } /////////////////////////////////////////////////////////////////////// @@ -611,13 +616,18 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v3) /// /// \param exec [in] The executor object to use for scheduling of the /// function \a f. + /// \param params [in] The executor parameters object to use as a + /// fallback if the executor does not expose /// - /// \note This calls exec.os_thread_count() if it exists; - /// otherwise it executes hpx::get_os_thread_count(). + /// \note This calls exec.processing_units_count() if it exists; + /// otherwise it forwards teh request to the executor parameters + /// object. /// - static std::size_t os_thread_count(executor_type const& exec) + template + static std::size_t processing_units_count(executor_type const& exec, + Parameters& params) { - return detail::call_os_thread_count(exec); + return detail::call_processing_units_count(exec, params); } /// Retrieve whether this executor has operations pending or not. diff --git a/hpx/parallel/executors/guided_chunk_size.hpp b/hpx/parallel/executors/guided_chunk_size.hpp index b7686200b11a..824b2b7d4c1f 100644 --- a/hpx/parallel/executors/guided_chunk_size.hpp +++ b/hpx/parallel/executors/guided_chunk_size.hpp @@ -59,7 +59,7 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v3) std::size_t get_chunk_size(Executor& exec, F &&, std::size_t num_tasks) { std::size_t const cores = - executor_traits::os_thread_count(exec); + executor_traits::processing_units_count(exec, *this); std::size_t chunk = (num_tasks + cores - 1) / cores; return (std::max)(min_chunk_size_, chunk); diff --git a/hpx/parallel/executors/sequential_executor.hpp b/hpx/parallel/executors/sequential_executor.hpp index 23bd079edb50..579656cc7a30 100644 --- a/hpx/parallel/executors/sequential_executor.hpp +++ b/hpx/parallel/executors/sequential_executor.hpp @@ -112,7 +112,7 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v3) bulk_async_execute(std::forward(f), shape)); } - std::size_t os_thread_count() + std::size_t processing_units_count() { return 1; } diff --git a/hpx/parallel/executors/static_chunk_size.hpp b/hpx/parallel/executors/static_chunk_size.hpp index 4548df199b32..834675ff7946 100644 --- a/hpx/parallel/executors/static_chunk_size.hpp +++ b/hpx/parallel/executors/static_chunk_size.hpp @@ -59,7 +59,7 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v3) // by default use static work distribution over number of // available compute resources std::size_t const cores = executor_traits:: - os_thread_count(exec); + processing_units_count(exec, *this); return (num_tasks + cores - 1) / cores; } diff --git a/hpx/parallel/executors/thread_executor_traits.hpp b/hpx/parallel/executors/thread_executor_traits.hpp index 79e6ea81b8a5..f160f0c48edd 100644 --- a/hpx/parallel/executors/thread_executor_traits.hpp +++ b/hpx/parallel/executors/thread_executor_traits.hpp @@ -202,7 +202,7 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v3) /// \note This calls exec.os_thread_count() if it exists; /// otherwise it executes hpx::get_os_thread_count(). /// - static std::size_t os_thread_count(executor_type const& sched) + static std::size_t processing_units_count(executor_type const& sched) { return hpx::get_os_thread_count(sched); } diff --git a/hpx/parallel/executors/thread_pool_executors.hpp b/hpx/parallel/executors/thread_pool_executors.hpp index a43ebccabf7f..c053cb927621 100644 --- a/hpx/parallel/executors/thread_pool_executors.hpp +++ b/hpx/parallel/executors/thread_pool_executors.hpp @@ -40,6 +40,18 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v3) typedef threads::executors::static_queue_executor static_queue_executor; #endif +#if defined(HPX_HAVE_THROTTLE_SCHEDULER) + /// Creates a new throttle_queue_executor + /// + /// \param max_punits [in] The maximum number of processing units to + /// associate with the newly created executor. + /// \param min_punits [in] The minimum number of processing units to + /// associate with the newly created executor + /// (default: 1). + /// + typedef threads::executors::throttle_queue_executor throttle_queue_executor; +#endif + /// Creates a new local_priority_queue_executor /// /// \param max_punits [in] The maximum number of processing units to diff --git a/hpx/parallel/task_block.hpp b/hpx/parallel/task_block.hpp index 393376e7b339..30a1f9ab0d97 100644 --- a/hpx/parallel/task_block.hpp +++ b/hpx/parallel/task_block.hpp @@ -463,7 +463,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v2) /// \throws An \a exception_list, as specified in Exception Handling. /// /// Postcondition: All tasks spawned from \a f have finished execution. - /// A call to \a define_task_block_restore_thread always returns on the + /// A call to \a define_task_block_restore_thread always + /// returns on the /// same thread as that on which it was called. /// /// \note It is expected (but not mandated) that f will (directly or @@ -495,7 +496,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v2) /// \throws An \a exception_list, as specified in Exception Handling. /// /// Postcondition: All tasks spawned from \a f have finished execution. - /// A call to \a define_task_block_restore_thread always returns on the + /// A call to \a define_task_block_restore_thread always + /// returns on the /// same thread as that on which it was called. /// /// \note It is expected (but not mandated) that f will (directly or diff --git a/hpx/parallel/util/detail/chunk_size.hpp b/hpx/parallel/util/detail/chunk_size.hpp index ee0d910852f0..5228308845f3 100644 --- a/hpx/parallel/util/detail/chunk_size.hpp +++ b/hpx/parallel/util/detail/chunk_size.hpp @@ -58,7 +58,7 @@ namespace hpx { namespace parallel { namespace util { namespace detail typedef typename ExPolicy::executor_type executor_type; std::size_t const cores = executor_traits:: - os_thread_count(policy.executor()); + processing_units_count(policy.executor(), policy.parameters()); bool variable_chunk_sizes = traits::variable_chunk_size( policy.parameters(), policy.executor()); diff --git a/hpx/performance_counters/counters.hpp b/hpx/performance_counters/counters.hpp index 21cd2c78c58f..53d825539526 100644 --- a/hpx/performance_counters/counters.hpp +++ b/hpx/performance_counters/counters.hpp @@ -203,7 +203,8 @@ namespace hpx { namespace performance_counters /// instance. Generally, a full name of a counter instance has the /// structure: /// - /// /objectname{parentinstancename#parentindex/instancename#instanceindex}/countername#parameters + /// /objectname{parentinstancename#parentindex/instancename#instanceindex} + /// /countername#parameters /// /// i.e. /// /queue{localityprefix/thread#2}/length @@ -232,7 +233,8 @@ namespace hpx { namespace performance_counters std::string instancename_; ///< the name of the object instance boost::int64_t parentinstanceindex_; ///< the parent instance index boost::int64_t instanceindex_; ///< the instance index - bool parentinstance_is_basename_; ///< the parentinstancename_ member holds a base counter name + bool parentinstance_is_basename_; ///< the parentinstancename_ + ///member holds a base counter name private: // serialization support diff --git a/hpx/performance_counters/parcels/data_point.hpp b/hpx/performance_counters/parcels/data_point.hpp index 20a67c6bf4b0..efd3acc8ec64 100644 --- a/hpx/performance_counters/parcels/data_point.hpp +++ b/hpx/performance_counters/parcels/data_point.hpp @@ -42,7 +42,8 @@ namespace hpx { namespace performance_counters { namespace parcels ///< security work timestamp after ///< processing holds elapsed security time #endif - std::size_t num_parcels_; ///< The number of parcels processed by this message + std::size_t num_parcels_; + ///^ The number of parcels processed by this message std::size_t raw_bytes_; ///< number of bytes processed for the action in ///< this parcel (uncompressed) diff --git a/hpx/performance_counters/server/arithmetics_counter.hpp b/hpx/performance_counters/server/arithmetics_counter.hpp index 44a74c397a82..570b34448c30 100644 --- a/hpx/performance_counters/server/arithmetics_counter.hpp +++ b/hpx/performance_counters/server/arithmetics_counter.hpp @@ -70,7 +70,8 @@ namespace hpx { namespace performance_counters { namespace server typedef lcos::local::spinlock mutex_type; mutable mutex_type mtx_; - std::vector base_counter_names_; ///< names of base counters to be queried + std::vector base_counter_names_; + ///^ names of base counters to be queried std::vector base_counter_ids_; boost::uint64_t invocation_count_; }; diff --git a/hpx/performance_counters/server/base_performance_counter.hpp b/hpx/performance_counters/server/base_performance_counter.hpp index 44c419cf5174..50ac407c202f 100644 --- a/hpx/performance_counters/server/base_performance_counter.hpp +++ b/hpx/performance_counters/server/base_performance_counter.hpp @@ -169,27 +169,35 @@ namespace hpx { namespace performance_counters { namespace server }}} HPX_ACTION_HAS_CRITICAL_PRIORITY( - hpx::performance_counters::server::base_performance_counter::get_counter_info_action); + hpx::performance_counters::server::base_performance_counter + ::get_counter_info_action); HPX_REGISTER_ACTION_DECLARATION( - hpx::performance_counters::server::base_performance_counter::get_counter_info_action, + hpx::performance_counters::server::base_performance_counter + ::get_counter_info_action, performance_counter_get_counter_info_action) HPX_ACTION_HAS_CRITICAL_PRIORITY( - hpx::performance_counters::server::base_performance_counter::get_counter_value_action); + hpx::performance_counters::server::base_performance_counter + ::get_counter_value_action); HPX_REGISTER_ACTION_DECLARATION( - hpx::performance_counters::server::base_performance_counter::get_counter_value_action, + hpx::performance_counters::server::base_performance_counter + ::get_counter_value_action, performance_counter_get_counter_value_action) HPX_ACTION_HAS_CRITICAL_PRIORITY( - hpx::performance_counters::server::base_performance_counter::set_counter_value_action); + hpx::performance_counters::server::base_performance_counter + ::set_counter_value_action); HPX_REGISTER_ACTION_DECLARATION( - hpx::performance_counters::server::base_performance_counter::set_counter_value_action, + hpx::performance_counters::server::base_performance_counter + ::set_counter_value_action, performance_counter_set_counter_value_action) HPX_ACTION_HAS_CRITICAL_PRIORITY( - hpx::performance_counters::server::base_performance_counter::reset_counter_value_action); + hpx::performance_counters::server::base_performance_counter + ::reset_counter_value_action); HPX_REGISTER_ACTION_DECLARATION( - hpx::performance_counters::server::base_performance_counter::reset_counter_value_action, + hpx::performance_counters::server::base_performance_counter + ::reset_counter_value_action, performance_counter_reset_counter_value_action) HPX_ACTION_HAS_CRITICAL_PRIORITY( diff --git a/hpx/plugins/binary_filter/bzip2_serialization_filter.hpp b/hpx/plugins/binary_filter/bzip2_serialization_filter.hpp index 8f5fbdd15a41..5cfefe1a3e74 100644 --- a/hpx/plugins/binary_filter/bzip2_serialization_filter.hpp +++ b/hpx/plugins/binary_filter/bzip2_serialization_filter.hpp @@ -62,7 +62,8 @@ namespace hpx { namespace plugins { namespace compression }; } - struct HPX_LIBRARY_EXPORT bzip2_serialization_filter : public serialization::binary_filter + struct HPX_LIBRARY_EXPORT bzip2_serialization_filter + : public serialization::binary_filter { bzip2_serialization_filter() : current_(0) diff --git a/hpx/plugins/parcel/coalescing_message_handler.hpp b/hpx/plugins/parcel/coalescing_message_handler.hpp index 804eaf8df5e7..430ba3df5e94 100644 --- a/hpx/plugins/parcel/coalescing_message_handler.hpp +++ b/hpx/plugins/parcel/coalescing_message_handler.hpp @@ -3,7 +3,8 @@ // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#if !defined(HPX_RUNTIME_PARCELSET_POLICIES_COALESCING_MESSAGE_HANDLER_FEB_24_2013_0302PM) +#if \ + !defined(HPX_RUNTIME_PARCELSET_POLICIES_COALESCING_MESSAGE_HANDLER_FEB_24_2013_0302PM) #define HPX_RUNTIME_PARCELSET_POLICIES_COALESCING_MESSAGE_HANDLER_FEB_24_2013_0302PM #include @@ -41,7 +42,8 @@ namespace hpx { namespace plugins { namespace parcel parcelset::parcelport* pp, std::size_t num = std::size_t(-1), std::size_t interval = std::size_t(-1)); - void put_parcel(parcelset::locality const & dest, parcelset::parcel p, write_handler_type f); + void put_parcel(parcelset::locality const & dest, + parcelset::parcel p, write_handler_type f); bool flush(bool stop_buffering = false); diff --git a/hpx/plugins/parcel/message_buffer.hpp b/hpx/plugins/parcel/message_buffer.hpp index 1f94925d8059..43b260596e8a 100644 --- a/hpx/plugins/parcel/message_buffer.hpp +++ b/hpx/plugins/parcel/message_buffer.hpp @@ -59,7 +59,8 @@ namespace hpx { namespace plugins { namespace parcel { namespace detail set->put_parcels(dests_, std::move(messages_), std::move(handlers_)); } - message_buffer_append_state append(parcelset::locality const & dest, parcelset::parcel p, + message_buffer_append_state append(parcelset::locality const & dest, + parcelset::parcel p, parcelset::parcelport::write_handler_type f) { HPX_ASSERT(messages_.size() == handlers_.size()); diff --git a/hpx/plugins/parcelport/ibverbs/acceptor.hpp b/hpx/plugins/parcelport/ibverbs/acceptor.hpp index fb818a3f1f8b..e21b9238f856 100644 --- a/hpx/plugins/parcelport/ibverbs/acceptor.hpp +++ b/hpx/plugins/parcelport/ibverbs/acceptor.hpp @@ -64,7 +64,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { int verrno = errno; close(ec); - boost::system::error_code err(verrno, boost::system::system_category()); + boost::system::error_code err(verrno, + boost::system::system_category()); HPX_IBVERBS_THROWS_IF( ec , err @@ -85,7 +86,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { int verrno = errno; close(ec); - boost::system::error_code err(verrno, boost::system::system_category()); + boost::system::error_code err(verrno, + boost::system::system_category()); HPX_IBVERBS_THROWS_IF( ec , err @@ -107,7 +109,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { int verrno = errno; close(ec); - boost::system::error_code err(verrno, boost::system::system_category()); + boost::system::error_code err(verrno, + boost::system::system_category()); HPX_IBVERBS_THROWS_IF( ec , err @@ -119,7 +122,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { int verrno = errno; close(ec); - boost::system::error_code err(verrno, boost::system::system_category()); + boost::system::error_code err(verrno, + boost::system::system_category()); HPX_IBVERBS_THROWS_IF( ec , err @@ -166,7 +170,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs template boost::shared_ptr accept( - Parcelport & parcelport, util::memory_chunk_pool & pool, boost::system::error_code &ec) + Parcelport & parcelport, util::memory_chunk_pool & pool, + boost::system::error_code &ec) { boost::shared_ptr rcv; rdma_cm_event event; diff --git a/hpx/plugins/parcelport/ibverbs/client.hpp b/hpx/plugins/parcelport/ibverbs/client.hpp index edab2ddf6422..e405ae0a839c 100644 --- a/hpx/plugins/parcelport/ibverbs/client.hpp +++ b/hpx/plugins/parcelport/ibverbs/client.hpp @@ -10,7 +10,8 @@ #include #include -namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { namespace detail { +namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { + namespace detail { struct client { client() @@ -24,10 +25,12 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { n , id_(0) { int ret = 0; - ret = posix_memalign(reinterpret_cast(&server_msg_), EXEC_PAGESIZE, sizeof(message)); + ret = posix_memalign(reinterpret_cast(&server_msg_), + EXEC_PAGESIZE, sizeof(message)); if(ret != 0) throw std::bad_alloc(); - ret = posix_memalign(reinterpret_cast(&client_msg_), EXEC_PAGESIZE, sizeof(message)); + ret = posix_memalign(reinterpret_cast(&client_msg_), + EXEC_PAGESIZE, sizeof(message)); if(ret != 0) throw std::bad_alloc(); } @@ -106,7 +109,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { n void on_preconnect(rdma_cm_id * id, ibv_pd * pd, boost::system::error_code &ec) { close(); - server_msg_mr_ = ibv_reg_mr(pd, server_msg_, sizeof(message), IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE); + server_msg_mr_ = ibv_reg_mr(pd, server_msg_, sizeof(message), + IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE); if(!server_msg_mr_) { int verrno = errno; @@ -118,7 +122,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { n return; } - client_msg_mr_ = ibv_reg_mr(pd, client_msg_, sizeof(message), IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE); + client_msg_mr_ = ibv_reg_mr(pd, client_msg_, sizeof(message), + IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE); if(!client_msg_mr_) { int verrno = errno; @@ -138,7 +143,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { n id_ = id; } - void write_remote(char * buffer, ibv_mr *mr, std::size_t size, boost::system::error_code &ec) + void write_remote(char * buffer, ibv_mr *mr, std::size_t size, + boost::system::error_code &ec) { if(!id_) { @@ -190,7 +196,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { n } } - void send_message(message_type m, boost::system::error_code &ec, bool payload = false) + void send_message(message_type m, boost::system::error_code &ec, + bool payload = false) { if(!id_) { @@ -242,7 +249,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { n send_message(MSG_SIZE, ec); } - void send_small_msg(char * data, std::size_t size, boost::system::error_code & ec) + void send_small_msg(char * data, std::size_t size, + boost::system::error_code & ec) { HPX_ASSERT(client_msg_); HPX_ASSERT(client_msg_mr_); diff --git a/hpx/plugins/parcelport/ibverbs/connection_handler.hpp b/hpx/plugins/parcelport/ibverbs/connection_handler.hpp index 7ece2b6ce369..804d98cb85fa 100644 --- a/hpx/plugins/parcelport/ibverbs/connection_handler.hpp +++ b/hpx/plugins/parcelport/ibverbs/connection_handler.hpp @@ -62,7 +62,8 @@ namespace hpx { namespace parcelset { static std::size_t max_memory_chunks(util::runtime_configuration const& ini); connection_handler(util::runtime_configuration const& ini, - util::function_nonser const& on_start_thread, + util::function_nonser + const& on_start_thread, util::function_nonser const& on_stop_thread); ~connection_handler(); @@ -78,7 +79,8 @@ namespace hpx { namespace parcelset { boost::shared_ptr create_connection( parcelset::locality const& l, error_code& ec); - parcelset::locality agas_locality(util::runtime_configuration const & ini) const; + parcelset::locality agas_locality(util::runtime_configuration const & ini) + const; parcelset::locality create_locality() const; @@ -86,7 +88,8 @@ namespace hpx { namespace parcelset { ibv_pd *get_pd(ibv_context *context, boost::system::error_code & ec); - ibverbs_mr register_buffer(ibv_pd * pd, char * buffer, std::size_t size, int access); + ibverbs_mr register_buffer(ibv_pd * pd, char * buffer, std::size_t size, + int access); private: // helper functions for receiving parcels @@ -105,7 +108,8 @@ namespace hpx { namespace parcelset { typedef std::pair chunk_pair; typedef boost::cache::entries::lru_entry mr_cache_entry_type; - typedef boost::cache::local_cache mr_cache_type; + typedef boost::cache::local_cache + mr_cache_type; /* typedef std::map diff --git a/hpx/plugins/parcelport/ibverbs/context.hpp b/hpx/plugins/parcelport/ibverbs/context.hpp index 08f8f287052f..2e79fdee6a9c 100644 --- a/hpx/plugins/parcelport/ibverbs/context.hpp +++ b/hpx/plugins/parcelport/ibverbs/context.hpp @@ -60,7 +60,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs int err = errno; if(err != EAGAIN) { - HPX_IBVERBS_THROWS_IF(ec, boost::asio::error::connection_aborted); + HPX_IBVERBS_THROWS_IF(ec, + boost::asio::error::connection_aborted); return MSG_INVALID; } } @@ -79,7 +80,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { if(wc[i].status == IBV_WC_SUCCESS) { - if(this_->connection_.on_completion(&wc[i], ec) == MSG_SHUTDOWN) + if(this_->connection_.on_completion(&wc[i], + ec) == MSG_SHUTDOWN) { return MSG_SHUTDOWN; } @@ -91,7 +93,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs } else { - HPX_IBVERBS_THROWS_IF(ec, boost::asio::error::connection_aborted); + HPX_IBVERBS_THROWS_IF(ec, + boost::asio::error::connection_aborted); return MSG_INVALID; } } @@ -218,7 +221,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs return true; } - void register_buffer(char * buffer, std::size_t size, boost::system::error_code & ec) + void register_buffer(char * buffer, std::size_t size, + boost::system::error_code & ec) { connection_.register_buffer(pd_, buffer, size, ec); } @@ -301,7 +305,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs } template - void connect(Parcelport & parcelport, boost::asio::ip::tcp::endpoint const & there, boost::system::error_code &ec) + void connect(Parcelport & parcelport, + boost::asio::ip::tcp::endpoint const & there, boost::system::error_code &ec) { if(ctx_) { @@ -317,7 +322,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { int verrno = errno; close(ec); - boost::system::error_code err(verrno, boost::system::system_category()); + boost::system::error_code err(verrno, + boost::system::system_category()); HPX_IBVERBS_THROWS_IF( ec , err @@ -338,7 +344,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { int verrno = errno; close(ec); - boost::system::error_code err(verrno, boost::system::system_category()); + boost::system::error_code err(verrno, + boost::system::system_category()); HPX_IBVERBS_THROWS_IF( ec , err @@ -371,7 +378,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { int verrno = errno; close(ec); - boost::system::error_code err(verrno, boost::system::system_category()); + boost::system::error_code err(verrno, + boost::system::system_category()); HPX_IBVERBS_THROWS_IF( ec , err @@ -414,7 +422,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { int verrno = errno; close(ec); - boost::system::error_code err(verrno, boost::system::system_category()); + boost::system::error_code err(verrno, + boost::system::system_category()); HPX_IBVERBS_THROWS_IF( ec , err @@ -440,7 +449,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { int verrno = errno; close(ec); - boost::system::error_code err(verrno, boost::system::system_category()); + boost::system::error_code err(verrno, + boost::system::system_category()); HPX_IBVERBS_THROWS_IF( ec , err @@ -482,7 +492,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs } template - void build_connection(Parcelport & parcelport, rdma_cm_id * id, boost::system::error_code &ec) + void build_connection(Parcelport & parcelport, rdma_cm_id * id, + boost::system::error_code &ec) { ibv_qp_init_attr qp_attr; build_context(parcelport, id->verbs, ec); @@ -519,13 +530,15 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs ibv_pd * pd_; private: template - void build_context(Parcelport & parcelport, ibv_context *verbs, boost::system::error_code &ec) + void build_context(Parcelport & parcelport, ibv_context *verbs, + boost::system::error_code &ec) { if(ctx_) { if(ctx_ != verbs) { - HPX_IBVERBS_THROWS_IF(ec, boost::asio::error::operation_not_supported); + HPX_IBVERBS_THROWS_IF(ec, + boost::asio::error::operation_not_supported); return; } } diff --git a/hpx/plugins/parcelport/ibverbs/receiver.hpp b/hpx/plugins/parcelport/ibverbs/receiver.hpp index 09b0465cd523..36de7cc80082 100644 --- a/hpx/plugins/parcelport/ibverbs/receiver.hpp +++ b/hpx/plugins/parcelport/ibverbs/receiver.hpp @@ -58,7 +58,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs /// Get the data window associated with the parcelport_connection. server_context& context() { return context_; } - boost::shared_ptr get_buffer(parcel const & p = parcel(), std::size_t arg_size = 0) + boost::shared_ptr get_buffer(parcel const & p = parcel(), + std::size_t arg_size = 0) { if(!buffer_ || (buffer_ && !buffer_->parcels_decoded_)) { @@ -123,7 +124,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs buffer_->data_.resize(size); if(size <= message::payload_size) { - std::memcpy(&buffer_->data_[0], context_.connection().msg_payload(), size); + std::memcpy(&buffer_->data_[0], context_.connection().msg_payload(), + size); return next(&receiver::write_ack); } else diff --git a/hpx/plugins/parcelport/ibverbs/sender.hpp b/hpx/plugins/parcelport/ibverbs/sender.hpp index eac7b1def26c..c61a7be87255 100644 --- a/hpx/plugins/parcelport/ibverbs/sender.hpp +++ b/hpx/plugins/parcelport/ibverbs/sender.hpp @@ -49,9 +49,11 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs > postprocess_function_type; - sender(connection_handler & handler, util::memory_chunk_pool & pool, parcelset::locality const& there, + sender(connection_handler & handler, util::memory_chunk_pool & pool, + parcelset::locality const& there, performance_counters::parcels::gatherer& parcels_sent) - : context_(), parcelport_(handler), there_(there), parcels_sent_(parcels_sent), memory_pool_(pool) + : context_(), parcelport_(handler), there_(there), + parcels_sent_(parcels_sent), memory_pool_(pool) { } @@ -76,7 +78,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs return there_; } - boost::shared_ptr get_buffer(parcel const & p, std::size_t arg_size) + boost::shared_ptr get_buffer(parcel const & p, + std::size_t arg_size) { if(!buffer_) { diff --git a/hpx/plugins/parcelport/ibverbs/server.hpp b/hpx/plugins/parcelport/ibverbs/server.hpp index 61fc399d2eaf..8a971c8a7e17 100644 --- a/hpx/plugins/parcelport/ibverbs/server.hpp +++ b/hpx/plugins/parcelport/ibverbs/server.hpp @@ -10,7 +10,8 @@ #include #include -namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { namespace detail +namespace hpx { namespace parcelset { namespace policies { namespace ibverbs +{ namespace detail { struct server { @@ -23,11 +24,13 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { n , id_(0) { int ret = 0; - ret = posix_memalign(reinterpret_cast(&server_msg_), EXEC_PAGESIZE, sizeof(message)); + ret = posix_memalign(reinterpret_cast(&server_msg_), + EXEC_PAGESIZE, sizeof(message)); if(ret != 0) throw std::bad_alloc(); - ret = posix_memalign(reinterpret_cast(&client_msg_), EXEC_PAGESIZE, sizeof(message)); + ret = posix_memalign(reinterpret_cast(&client_msg_), + EXEC_PAGESIZE, sizeof(message)); if(ret != 0) throw std::bad_alloc(); } @@ -175,7 +178,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { n if(!server_msg_mr_) { int verrno = errno; - boost::system::error_code err(verrno, boost::system::system_category()); + boost::system::error_code err(verrno, + boost::system::system_category()); HPX_IBVERBS_THROWS_IF( ec , err @@ -190,7 +194,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs { n if(!client_msg_mr_) { int verrno = errno; - boost::system::error_code err(verrno, boost::system::system_category()); + boost::system::error_code err(verrno, + boost::system::system_category()); HPX_IBVERBS_THROWS_IF( ec , err diff --git a/hpx/plugins/parcelport/ipc/acceptor.hpp b/hpx/plugins/parcelport/ipc/acceptor.hpp index 949d5eaacd70..1dfd4db2df6e 100644 --- a/hpx/plugins/parcelport/ipc/acceptor.hpp +++ b/hpx/plugins/parcelport/ipc/acceptor.hpp @@ -326,7 +326,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ipc } template - bool try_accept(basic_data_window& window, boost::system::error_code &ec) + bool try_accept(basic_data_window& window, + boost::system::error_code &ec) { if (close_operation_.load() || !mq_) { HPX_IPC_THROWS_IF(ec, boost::asio::error::not_connected); diff --git a/hpx/plugins/parcelport/ipc/connection_handler.hpp b/hpx/plugins/parcelport/ipc/connection_handler.hpp index 0ea90c963a99..f48f953a809d 100644 --- a/hpx/plugins/parcelport/ipc/connection_handler.hpp +++ b/hpx/plugins/parcelport/ipc/connection_handler.hpp @@ -58,12 +58,14 @@ namespace hpx { namespace parcelset { public: connection_handler(util::runtime_configuration const& ini, - util::function_nonser const& on_start_thread, + util::function_nonser + const& on_start_thread, util::function_nonser const& on_stop_thread); ~connection_handler(); - bool can_connect(parcelset::locality const &, bool use_alternative_parcelport); + bool can_connect(parcelset::locality const &, + bool use_alternative_parcelport); /// Start the handling of connections. bool do_run(); @@ -74,7 +76,8 @@ namespace hpx { namespace parcelset { boost::shared_ptr create_connection( parcelset::locality const& l, error_code& ec); - parcelset::locality agas_locality(util::runtime_configuration const & ini) const; + parcelset::locality agas_locality(util::runtime_configuration const & ini) + const; parcelset::locality create_locality() const; diff --git a/hpx/plugins/parcelport/ipc/data_buffer.hpp b/hpx/plugins/parcelport/ipc/data_buffer.hpp index 0a6514543a80..29f87ad6d730 100644 --- a/hpx/plugins/parcelport/ipc/data_buffer.hpp +++ b/hpx/plugins/parcelport/ipc/data_buffer.hpp @@ -51,7 +51,8 @@ namespace boost { namespace container { namespace container_detail // We provide the specialization for 'char' to implement proper // uninitialized expansion of the vectors we use below. template <> - struct default_construct_aux_proxy + struct default_construct_aux_proxy : public advanced_insert_aux_int { typedef hpx::parcelset::policies::ipc::ipc_allocator_type allocator_type; @@ -122,12 +123,14 @@ namespace boost { namespace container { namespace container_detail // size_type i = 0; // try { // for(; i < n; ++i, ++p){ -// alloc_traits::construct(this->a_, container_detail::to_raw_pointer(&*p)); +// alloc_traits::construct(this->a_, +// container_detail::to_raw_pointer(&*p)); // } // } // catch(...) { // while(i--) { -// alloc_traits::destroy(this->a_, container_detail::to_raw_pointer(&*orig_p++)); +// alloc_traits::destroy(this->a_, +// container_detail::to_raw_pointer(&*orig_p++)); // } // throw; // } @@ -164,12 +167,14 @@ namespace boost { namespace container { namespace container_detail // size_type n_left = n; // BOOST_TRY{ // for(; n_left--; ++p){ -// alloc_traits::construct(this->a_, container_detail::to_raw_pointer(&*p)); +// alloc_traits::construct(this->a_, +// container_detail::to_raw_pointer(&*p)); // } // } // BOOST_CATCH(...){ // for(; orig_p != p; ++orig_p){ -// alloc_traits::destroy(this->a_, container_detail::to_raw_pointer(&*orig_p++)); +// alloc_traits::destroy(this->a_, +// container_detail::to_raw_pointer(&*orig_p++)); // } // BOOST_RETHROW // } @@ -323,12 +328,14 @@ namespace hpx { namespace parcelset { namespace policies { namespace ipc data_buffer(allocator_type const &) {} - data_buffer(data_buffer const & other, allocator_type const & dummy = allocator_type()) + data_buffer(data_buffer const & other, + allocator_type const & dummy = allocator_type()) : data_(other.data_) {} template - data_buffer(data_buffer && other, allocator_type const & dummy = allocator_type()) + data_buffer(data_buffer && other, + allocator_type const & dummy = allocator_type()) : data_(std::move(other.data_)) {} diff --git a/hpx/plugins/parcelport/ipc/data_window.hpp b/hpx/plugins/parcelport/ipc/data_window.hpp index 5bd59d64d551..adbca70575c2 100644 --- a/hpx/plugins/parcelport/ipc/data_window.hpp +++ b/hpx/plugins/parcelport/ipc/data_window.hpp @@ -623,7 +623,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ipc close_operation_.store(false); } BOOST_SCOPE_EXIT_END -// std::cout << "data_window: " << here_ << "/" << there_ << ": close" << std::endl; +// std::cout << "data_window: " << here_ << "/" << there_ +// << ": close" << std::endl; // wait for pending operations to exit while (executing_operation_.load()) @@ -650,7 +651,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ipc void shutdown(boost::system::error_code &ec) { if (write_mq_) { -// std::cout << "data_window: " << here_ << "/" << there_ << ": shutdown" << std::endl; +// std::cout << "data_window: " << here_ << "/" +// << there_ << ": shutdown" << std::endl; send_command(*write_mq_, message::shutdown, 0, ec); } } @@ -662,7 +664,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ipc aborted_.store(false); } BOOST_SCOPE_EXIT_END -// std::cout << "data_window: " << here_ << "/" << there_ << ": destroy" << std::endl; +// std::cout << "data_window: " << here_ << "/" << there_ +// << ": destroy" << std::endl; // cancel operation while (executing_operation_.load()) diff --git a/hpx/plugins/parcelport/ipc/receiver.hpp b/hpx/plugins/parcelport/ipc/receiver.hpp index 6d57f22de793..e8f35fbbddc7 100644 --- a/hpx/plugins/parcelport/ipc/receiver.hpp +++ b/hpx/plugins/parcelport/ipc/receiver.hpp @@ -50,7 +50,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ipc /// Get the data window associated with the receiver. data_window& window() { return window_; } - boost::shared_ptr get_buffer(parcel const & p = parcel(), std::size_t arg_size = 0) + boost::shared_ptr get_buffer(parcel const & p = parcel(), + std::size_t arg_size = 0) { if(!buffer_ || (buffer_ && !buffer_->parcels_decoded_)) { diff --git a/hpx/plugins/parcelport/ipc/sender.hpp b/hpx/plugins/parcelport/ipc/sender.hpp index ea5ba8105cb1..2cbcd9a1e4a0 100644 --- a/hpx/plugins/parcelport/ipc/sender.hpp +++ b/hpx/plugins/parcelport/ipc/sender.hpp @@ -56,7 +56,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ipc HPX_ASSERT(parcel_locality_id == there_); } - boost::shared_ptr get_buffer(parcel const & p, std::size_t arg_size) + boost::shared_ptr get_buffer(parcel const & p, + std::size_t arg_size) { // generate the name for this data_buffer std::string data_buffer_name(p.get_parcel_id().to_string()); diff --git a/hpx/plugins/parcelport/mpi/header.hpp b/hpx/plugins/parcelport/mpi/header.hpp index caf651e965f6..2e783b72ea14 100644 --- a/hpx/plugins/parcelport/mpi/header.hpp +++ b/hpx/plugins/parcelport/mpi/header.hpp @@ -47,12 +47,14 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi set(static_cast(size)); set(static_cast(numbytes)); set(static_cast(buffer.num_chunks_.first)); - set(static_cast(buffer.num_chunks_.second)); + set(static_cast + (buffer.num_chunks_.second)); if(buffer.data_.size() <= (data_size_ - pos_piggy_back_data)) { data_[pos_piggy_back_flag] = 1; - std::memcpy(&data_[pos_piggy_back_data], &buffer.data_[0], buffer.data_.size()); + std::memcpy(&data_[pos_piggy_back_data], &buffer.data_[0], + buffer.data_.size()); } else { @@ -107,7 +109,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi std::pair num_chunks() const { - return std::make_pair(get(), get()); + return std::make_pair(get(), + get()); } char * piggy_back() diff --git a/hpx/plugins/parcelport/mpi/receiver.hpp b/hpx/plugins/parcelport/mpi/receiver.hpp index 15c648b1702f..cfc91f9c6b38 100644 --- a/hpx/plugins/parcelport/mpi/receiver.hpp +++ b/hpx/plugins/parcelport/mpi/receiver.hpp @@ -31,19 +31,13 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi typedef receiver_connection connection_type; -#if defined(HPX_INTEL_VERSION) && ((__GNUC__ == 4 && __GNUC_MINOR__ == 4) || HPX_INTEL_VERSION < 1400) - typedef boost::shared_ptr connection_ptr; -#else typedef std::unique_ptr connection_ptr; -#endif typedef std::list connection_list; - receiver(parcelport & pp, memory_pool_type & chunk_pool - , std::size_t max_connections) + receiver(parcelport & pp, memory_pool_type & chunk_pool) : pp_(pp) , chunk_pool_(chunk_pool) - , max_connections_(max_connections) - , num_connections_(0) + , max_connections_(16) {} void run() @@ -53,23 +47,6 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi bool background_work(std::size_t num_thread) { - // We accept as many connections as we can ... - while(true) - { - connection_ptr rcv = accept(); - if(rcv) - { - if(!rcv->receive()) - { - boost::unique_lock l(connections_mtx_); - connections_.push_back(std::move(rcv)); - } - } - else - { - break; - } - } connection_list connections; { @@ -96,6 +73,26 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi } return true; } + + // We accept as many connections as we can ... + while(true) + { + connection_ptr rcv = accept(); + if(rcv) + { + if(!rcv->receive()) + { + boost::unique_lock l(connections_mtx_); + connections_.push_back(std::move(rcv)); + if(connections_.size() > max_connections_) + break; + } + } + else + { + break; + } + } return false; } @@ -105,10 +102,13 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi { std::size_t k = 0; connection_list::iterator it = connections.begin(); + hpx::util::high_resolution_timer timer; // Handle all receives while(it != connections.end()) { + if(timer.elapsed() > 1.0) break; + connection_type & rcv = **it; if(rcv.receive()) { @@ -138,13 +138,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi { connections_.insert( connections_.end() -#if defined(HPX_INTEL_VERSION) && ((__GNUC__ == 4 && __GNUC_MINOR__ == 4) || HPX_INTEL_VERSION < 1400) - , connections.begin() - , connections.end() -#else , std::make_move_iterator(connections.begin()) , std::make_move_iterator(connections.end()) -#endif ); } } @@ -213,10 +208,10 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi handles_header_type handles_header_; mutex_type connections_mtx_; - std::size_t const max_connections_; - boost::atomic num_connections_; connection_list connections_; + std::size_t max_connections_; + bool request_done_locked(MPI_Request & r, MPI_Status *status) { int completed = 0; diff --git a/hpx/plugins/parcelport/mpi/receiver_connection.hpp b/hpx/plugins/parcelport/mpi/receiver_connection.hpp index 03e69de49640..a61f4dc72c13 100644 --- a/hpx/plugins/parcelport/mpi/receiver_connection.hpp +++ b/hpx/plugins/parcelport/mpi/receiver_connection.hpp @@ -208,7 +208,7 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi request_ptr_ = &request_; } - decode_parcel(pp_, std::move(buffer_)); + decode_parcels(pp_, std::move(buffer_)); state_ = sent_release_tag; diff --git a/hpx/plugins/parcelport/mpi/sender.hpp b/hpx/plugins/parcelport/mpi/sender.hpp index 72ae04c23bca..4b3e0090bd81 100644 --- a/hpx/plugins/parcelport/mpi/sender.hpp +++ b/hpx/plugins/parcelport/mpi/sender.hpp @@ -13,6 +13,8 @@ #include #include +#include + #include #include #include @@ -21,24 +23,27 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi { - template struct sender { + typedef util::memory_chunk_pool<> memory_pool_type; + typedef + util::detail::memory_chunk_pool_allocator< + char, util::memory_chunk_pool<> + > + allocator_type; typedef - sender_connection::type> + std::vector + data_type; + typedef + sender_connection connection_type; -#if defined(HPX_INTEL_VERSION) && ((__GNUC__ == 4 && __GNUC_MINOR__ == 4) || HPX_INTEL_VERSION < 1400) typedef boost::shared_ptr connection_ptr; -#else - typedef std::unique_ptr connection_ptr; -#endif typedef std::list connection_list; typedef hpx::lcos::local::spinlock mutex_type; - sender(std::size_t max_connections) - : max_connections_(max_connections) - , num_connections_(0) - , next_free_tag_(-1) + sender(memory_pool_type & chunk_pool) + : next_free_tag_(-1) + , chunk_pool_(chunk_pool) { } @@ -47,64 +52,24 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi get_next_free_tag(); } - struct check_num_connections + connection_ptr create_connection(int dest, + boost::atomic & enable, + performance_counters::parcels::gatherer & parcels_sent) { - check_num_connections(sender *s) - : this_(s) - , decrement_(false) - { - if(!threads::get_self_ptr()) return; - - boost::unique_lock l(this_->connections_mtx_); - while(this_->num_connections_ >= this_->max_connections_) - { - this_->connections_cond_.wait(l); - } - ++this_->num_connections_; - decrement_ = true; - } - - ~check_num_connections() - { - if(decrement_) - { - boost::unique_lock l(this_->connections_mtx_); - --this_->num_connections_; - this_->connections_cond_.notify_all(std::move(l)); - } - } - - sender *this_; - bool decrement_; - }; + return + boost::make_shared( + this, dest, chunk_pool_, enable, parcels_sent); + } - template - void send( - int dest - , parcel && p - , Handler && handler - , Buffer && buffer - , performance_counters::parcels::gatherer & parcels_sent - ) + void add(connection_ptr const & ptr) { - check_num_connections chk(this); - - connection_ptr sender( - new connection_type( - tag_provider_.acquire() - , dest - , std::move(p) - , std::move(buffer) - , std::forward(handler) - , parcels_sent - ) - ); + boost::unique_lock l(connections_mtx_); + connections_.push_back(ptr); + } - if(!sender->send()) - { - boost::unique_lock l(connections_mtx_); - connections_.push_back(std::move(sender)); - } + int acquire_tag() + { + return tag_provider_.acquire(); } void send_messages( @@ -112,15 +77,21 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi ) { std::size_t k = 0; - typename connection_list::iterator it = connections.begin(); + connection_list::iterator it = connections.begin(); + hpx::util::high_resolution_timer timer; - // We try to handle all receives within 1 secone + // We try to handle all receives within 1 second while(it != connections.end()) { + if(timer.elapsed() > 1.0) break; + connection_type & sender = **it; if(sender.send()) { + connection_ptr s = *it; it = connections.erase(it); + error_code ec; + s->postprocess_handler_(ec, s->destination(), s); } else { @@ -146,13 +117,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi { connections_.insert( connections_.end() -#if defined(HPX_INTEL_VERSION) && ((__GNUC__ == 4 && __GNUC_MINOR__ == 4) || HPX_INTEL_VERSION < 1400) - , connections.begin() - , connections.end() -#else , std::make_move_iterator(connections.begin()) , std::make_move_iterator(connections.end()) -#endif ); } } @@ -244,15 +210,16 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi mutex_type connections_mtx_; lcos::local::detail::condition_variable connections_cond_; - std::size_t const max_connections_; - std::size_t num_connections_; connection_list connections_; mutex_type next_free_tag_mtx_; MPI_Request next_free_tag_request_; int next_free_tag_; + + memory_pool_type & chunk_pool_; }; + }}}} #endif diff --git a/hpx/plugins/parcelport/mpi/sender_connection.hpp b/hpx/plugins/parcelport/mpi/sender_connection.hpp index 4bc15dc60ac1..b20713d609e8 100644 --- a/hpx/plugins/parcelport/mpi/sender_connection.hpp +++ b/hpx/plugins/parcelport/mpi/sender_connection.hpp @@ -6,18 +6,48 @@ #ifndef HPX_PARCELSET_POLICIES_MPI_SENDER_CONNECTION_HPP #define HPX_PARCELSET_POLICIES_MPI_SENDER_CONNECTION_HPP +#include #include +#include + +#include + +#include namespace hpx { namespace parcelset { namespace policies { namespace mpi { - template + struct sender; + struct sender_connection; + + int acquire_tag(sender *); + void add_connection(sender *, boost::shared_ptr const&); + struct sender_connection + : parcelset::parcelport_connection< + sender_connection + , std::vector< + char + , util::detail::memory_chunk_pool_allocator< + char, util::memory_chunk_pool<> + > + > + > { private: + typedef sender sender_type; + typedef util::function_nonser< void(boost::system::error_code const&, parcel const&) > write_handler_type; + typedef util::memory_chunk_pool<> memory_pool_type; + typedef + util::detail::memory_chunk_pool_allocator> + allocator_type; + typedef + std::vector + data_type; + enum connection_state { initialized @@ -27,31 +57,71 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi , sent_chunks }; + typedef + parcelset::parcelport_connection + base_type; + public: sender_connection( - int tag + sender_type * s , int dst - , parcel && p - , Buffer && buffer - , write_handler_type && handler + , memory_pool_type & chunk_pool + , boost::atomic & enable , performance_counters::parcels::gatherer & parcels_sent ) - : state_(initialized) - , tag_(tag) + : base_type(allocator_type(chunk_pool)) + , state_(initialized) + , sender_(s) , dst_(dst) - , parcel_(std::move(p)) - , buffer_(std::move(buffer)) - , handler_(std::move(handler)) - , header_(buffer_, tag_) , request_ptr_(0) , chunks_idx_(0) + , chunk_pool_(chunk_pool) + , enable_(enable) , parcels_sent_(parcels_sent) + , there_( + parcelset::locality( + locality( + dst_ + ) + ) + ) + { + } + + parcelset::locality const& destination() const { + return there_; + } + + void verify(parcelset::locality const & parcel_locality_id) const + { + } + + template + void async_write(Handler && handler, ParcelPostprocess && parcel_postprocess) + { + HPX_ASSERT(!buffer_.data_.empty()); + request_ptr_ = 0; + chunks_idx_ = 0; + tag_ = acquire_tag(sender_); + header_ = header(buffer_, tag_); header_.assert_valid(); + + handler_ = std::forward(handler); + postprocess_handler_ = std::forward(parcel_postprocess); + + if(!send()) + add_connection(sender_, shared_from_this()); + else + { + error_code ec; + postprocess_handler_(ec, there_, shared_from_this()); + } } bool send() { + if(!enable_) return false; switch(state_) { case initialized: @@ -101,7 +171,7 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi HPX_ASSERT(request_ptr_ == 0); - std::vector& chunks = + std::vector& chunks = buffer_.transmission_chunks_; if(!chunks.empty()) { @@ -110,7 +180,7 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi chunks.data() , static_cast( chunks.size() - * sizeof(typename Buffer::transmission_chunk_type) + * sizeof(parcel_buffer_type::transmission_chunk_type) ) , MPI_BYTE , dst_ @@ -190,10 +260,13 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi if(!request_done()) return false; error_code ec; - handler_(ec, parcel_); + handler_(ec); buffer_.data_point_.time_ = util::high_resolution_clock::now() - buffer_.data_point_.time_; parcels_sent_.add_data(buffer_.data_point_); + buffer_.clear(); + + state_ = initialized; return true; } @@ -218,11 +291,21 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi } connection_state state_; + sender_type * sender_; int tag_; int dst_; - parcel parcel_; - Buffer buffer_; - write_handler_type handler_; + util::unique_function_nonser< + void( + error_code const& + ) + > handler_; + util::unique_function_nonser< + void( + error_code const& + , parcelset::locality const& + , boost::shared_ptr + ) + > postprocess_handler_; header header_; @@ -231,7 +314,13 @@ namespace hpx { namespace parcelset { namespace policies { namespace mpi std::size_t chunks_idx_; char ack_; + memory_pool_type & chunk_pool_; + + boost::atomic & enable_; + performance_counters::parcels::gatherer & parcels_sent_; + + parcelset::locality there_; }; }}}} diff --git a/hpx/plugins/parcelport/tcp/connection_handler.hpp b/hpx/plugins/parcelport/tcp/connection_handler.hpp index 2a23ec17e0e6..2ec92e3da942 100644 --- a/hpx/plugins/parcelport/tcp/connection_handler.hpp +++ b/hpx/plugins/parcelport/tcp/connection_handler.hpp @@ -70,7 +70,8 @@ namespace hpx { namespace parcelset } connection_handler(util::runtime_configuration const& ini, - util::function_nonser const& on_start_thread, + util::function_nonser + const& on_start_thread, util::function_nonser const& on_stop_thread); ~connection_handler(); @@ -90,7 +91,8 @@ namespace hpx { namespace parcelset boost::shared_ptr create_connection( parcelset::locality const& l, error_code& ec); - parcelset::locality agas_locality(util::runtime_configuration const & ini) const; + parcelset::locality agas_locality(util::runtime_configuration const & ini) + const; parcelset::locality create_locality() const; diff --git a/hpx/plugins/parcelport/tcp/receiver.hpp b/hpx/plugins/parcelport/tcp/receiver.hpp index 9d36c1d304fc..d091b1f53be1 100644 --- a/hpx/plugins/parcelport/tcp/receiver.hpp +++ b/hpx/plugins/parcelport/tcp/receiver.hpp @@ -132,7 +132,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace tcp std::size_t bytes_transferred, boost::tuple handler) { if (e) { - if(e==boost::asio::error::not_connected) std::cout << "handle_read_header\n"; + if(e==boost::asio::error::not_connected) std::cout << + "handle_read_header\n"; boost::get<0>(handler)(e); // Issue a read operation to read the next parcel. @@ -296,7 +297,7 @@ namespace hpx { namespace parcelset { namespace policies { namespace tcp = &receiver::handle_write_ack; // decode the received parcels. - decode_parcel(parcelport_, std::move(buffer_)); + decode_parcels(parcelport_, std::move(buffer_)); buffer_ = parcel_buffer_type(); ack_ = true; diff --git a/hpx/plugins/parcelport/tcp/sender.hpp b/hpx/plugins/parcelport/tcp/sender.hpp index 9f06eefef255..0ad27534e647 100644 --- a/hpx/plugins/parcelport/tcp/sender.hpp +++ b/hpx/plugins/parcelport/tcp/sender.hpp @@ -15,6 +15,8 @@ #include #include +#include + #include #include #include @@ -88,10 +90,13 @@ namespace hpx { namespace parcelset { namespace policies { namespace tcp } template - void async_write(Handler handler, ParcelPostprocess parcel_postprocess, parcel && p) + void async_write(Handler && handler, + ParcelPostprocess && parcel_postprocess) { HPX_ASSERT(!buffer_.data_.empty()); - p_ = std::move(p); + + handler_ = std::forward(handler); + postprocess_handler_ = std::forward(parcel_postprocess); #if defined(HPX_TRACK_STATE_OF_OUTGOING_TCP_CONNECTION) state_ = state_async_write; @@ -136,32 +141,26 @@ namespace hpx { namespace parcelset { namespace policies { namespace tcp // this additional wrapping of the handler into a bind object is // needed to keep this parcelport_connection object alive for the whole // write operation - void (sender::*f)(boost::system::error_code const&, std::size_t, - boost::tuple) - = &sender::handle_write; + void (sender::*f)(boost::system::error_code const&, std::size_t) + = &sender::handle_write; boost::asio::async_write(socket_, buffers, - boost::bind(f, shared_from_this(), - boost::asio::placeholders::error, ::_2, - boost::make_tuple(handler, parcel_postprocess))); + boost::bind(f, shared_from_this(), ::_1, ::_2)); } private: /// handle completed write operation - template - void handle_write(boost::system::error_code const& e, std::size_t bytes, - boost::tuple handler) + void handle_write(boost::system::error_code const& e, std::size_t bytes) { #if defined(HPX_TRACK_STATE_OF_OUTGOING_TCP_CONNECTION) state_ = state_handle_write; #endif // just call initial handler - boost::get<0>(handler)(e, p_); - p_.reset(); + handler_(e); if (e) { // inform post-processing handler of error as well - boost::get<1>(handler)(e, there_, shared_from_this()); + postprocess_handler_(e, there_, shared_from_this()); return; } @@ -177,18 +176,15 @@ namespace hpx { namespace parcelset { namespace policies { namespace tcp socket_.set_option(quickack); #endif - void (sender::*f)(boost::system::error_code const&, - boost::tuple) - = &sender::handle_read_ack; + void (sender::*f)(boost::system::error_code const&) + = &sender::handle_read_ack; boost::asio::async_read(socket_, boost::asio::buffer(&ack_, sizeof(ack_)), - boost::bind(f, shared_from_this(), ::_1, handler)); + boost::bind(f, shared_from_this(), ::_1)); } - template - void handle_read_ack(boost::system::error_code const& e, - boost::tuple handler) + void handle_read_ack(boost::system::error_code const& e) { #if defined(HPX_TRACK_STATE_OF_OUTGOING_TCP_CONNECTION) state_ = state_handle_read_ack; @@ -197,7 +193,7 @@ namespace hpx { namespace parcelset { namespace policies { namespace tcp // Call post-processing handler, which will send remaining pending // parcels. Pass along the connection so it can be reused if more // parcels have to be sent. - boost::get<1>(handler)(e, there_, shared_from_this()); + postprocess_handler_(e, there_, shared_from_this()); } /// Socket for the parcelport_connection. @@ -212,7 +208,18 @@ namespace hpx { namespace parcelset { namespace policies { namespace tcp util::high_resolution_timer timer_; performance_counters::parcels::gatherer& parcels_sent_; - parcel p_; + util::unique_function_nonser< + void( + boost::system::error_code const& + ) + > handler_; + util::unique_function_nonser< + void( + boost::system::error_code const& + , parcelset::locality const& + , boost::shared_ptr + ) + > postprocess_handler_; }; }}}} diff --git a/hpx/plugins/parcelport_factory.hpp b/hpx/plugins/parcelport_factory.hpp index 133718cb3a59..a7a0a3fd39f1 100644 --- a/hpx/plugins/parcelport_factory.hpp +++ b/hpx/plugins/parcelport_factory.hpp @@ -79,7 +79,8 @@ namespace hpx { namespace plugins "max_message_size = ${HPX_PARCEL_" + name_uc + "_MAX_MESSAGE_SIZE:$[hpx.parcel.max_message_size]}", "max_outbound_message_size = ${HPX_PARCEL_" + name_uc + - "_MAX_OUTBOUND_MESSAGE_SIZE:$[hpx.parcel.max_outbound_message_size]}", + "_MAX_OUTBOUND_MESSAGE_SIZE" + + ":$[hpx.parcel.max_outbound_message_size]}", "array_optimization = ${HPX_PARCEL_" + name_uc + "_ARRAY_OPTIMIZATION:$[hpx.parcel.array_optimization]}", "zero_copy_optimization = ${HPX_PARCEL_" + name_uc + @@ -92,7 +93,8 @@ namespace hpx { namespace plugins "_ASYNC_SERIALIZATION:" "$[hpx.parcel.async_serialization]}", "priority = ${HPX_PARCEL_" + name_uc + - "_PRIORITY:" + traits::plugin_config_data::priority() + "}" + "_PRIORITY:" + traits::plugin_config_data::priority() + + "}" ; // get the parcelport specific information ... @@ -116,7 +118,8 @@ namespace hpx { namespace plugins /// supported by this factory parcelset::parcelport* create( hpx::util::runtime_configuration const & cfg, - hpx::util::function_nonser const& on_start_thread, + hpx::util::function_nonser + const& on_start_thread, hpx::util::function_nonser const& on_stop_thread) { return new Parcelport(cfg, on_start_thread, on_stop_thread); diff --git a/hpx/runtime.hpp b/hpx/runtime.hpp index f326bb2afe08..3aa3f3776040 100644 --- a/hpx/runtime.hpp +++ b/hpx/runtime.hpp @@ -226,11 +226,13 @@ namespace hpx virtual util::unique_id_ranges& get_id_pool() = 0; - virtual void add_pre_startup_function(util::function_nonser const& f) = 0; + virtual void add_pre_startup_function(util::function_nonser + const& f) = 0; virtual void add_startup_function(util::function_nonser const& f) = 0; - virtual void add_pre_shutdown_function(util::function_nonser const& f) = 0; + virtual void add_pre_shutdown_function(util::function_nonser + const& f) = 0; virtual void add_shutdown_function(util::function_nonser const& f) = 0; diff --git a/hpx/runtime/actions/action_support.hpp b/hpx/runtime/actions/action_support.hpp index 101ddd8bfb23..4ca6a39b28ad 100644 --- a/hpx/runtime/actions/action_support.hpp +++ b/hpx/runtime/actions/action_support.hpp @@ -160,8 +160,8 @@ namespace hpx { namespace actions /// directly or by a HPX-threads enum action_type { - plain_action = 0, ///< The action will be executed by a newly created thread - direct_action = 1 ///< The action needs to be executed directly + plain_action = 0, ///< The action will be executed by a newly created thread + direct_action = 1 ///< The action needs to be executed directly }; /// Destructor diff --git a/hpx/runtime/actions/basic_action.hpp b/hpx/runtime/actions/basic_action.hpp index d4565ab9f0b5..22d85bd38f3a 100644 --- a/hpx/runtime/actions/basic_action.hpp +++ b/hpx/runtime/actions/basic_action.hpp @@ -776,7 +776,8 @@ namespace hpx { namespace actions /// /// // Component actions need to be declared, this also defines the /// // type 'print_greeting_action' representing the action. -/// HPX_DEFINE_COMPONENT_ACTION(server, print_greeting, print_greeting_action); +/// HPX_DEFINE_COMPONENT_ACTION(server, +/// print_greeting, print_greeting_action); /// }; /// } /// diff --git a/hpx/runtime/actions/component_action.hpp b/hpx/runtime/actions/component_action.hpp index 22aa65dfbed7..76e2046d303b 100644 --- a/hpx/runtime/actions/component_action.hpp +++ b/hpx/runtime/actions/component_action.hpp @@ -133,7 +133,8 @@ namespace hpx { namespace actions /// /// // Component actions need to be declared, this also defines the /// // type 'print_greeting_action' representing the action. -/// HPX_DEFINE_COMPONENT_ACTION(server, print_greeting, print_greeting_action); +/// HPX_DEFINE_COMPONENT_ACTION(server, print_greeting, +/// print_greeting_action); /// }; /// } /// \endcode diff --git a/hpx/runtime/actions/continuation.hpp b/hpx/runtime/actions/continuation.hpp index 4a82ababcdbc..2b2ad83ee433 100644 --- a/hpx/runtime/actions/continuation.hpp +++ b/hpx/runtime/actions/continuation.hpp @@ -359,7 +359,8 @@ namespace hpx { namespace actions cont_type cont_; // continuation type hpx::id_type target_; - function_type f_; // set_value action (default: set_lco_value_continuation) + function_type f_; + // set_value action (default: set_lco_value_continuation) }; /////////////////////////////////////////////////////////////////////////// diff --git a/hpx/runtime/actions/plain_action.hpp b/hpx/runtime/actions/plain_action.hpp index 902447f99bfb..11523aad1f9d 100644 --- a/hpx/runtime/actions/plain_action.hpp +++ b/hpx/runtime/actions/plain_action.hpp @@ -178,7 +178,8 @@ namespace hpx { namespace traits { /// \def HPX_PLAIN_ACTION(func, name) /// -/// \brief Defines a plain action type based on the given function \a func and registers it with HPX. +/// \brief Defines a plain action type based on the given function +/// \a func and registers it with HPX. /// /// The macro \a HPX_PLAIN_ACTION can be used to define a plain action (e.g. an /// action encapsulating a global or free function) based on the given function @@ -227,7 +228,8 @@ namespace hpx { namespace traits { /// \def HPX_PLAIN_ACTION_ID(func, actionname, actionid) /// -/// \brief Defines a plain action type based on the given function \a func and registers it with HPX. +/// \brief Defines a plain action type based on the given function \a func and +/// registers it with HPX. /// /// The macro \a HPX_PLAIN_ACTION_ID can be used to define a plain action (e.g. an /// action encapsulating a global or free function) based on the given function @@ -258,7 +260,8 @@ namespace hpx { namespace traits { /// /// // This will define the action type 'some_global_action' which represents /// // the function 'app::some_global_function'. -/// HPX_PLAIN_ACTION_ID(app::some_global_function, some_global_action, some_unique_id); +/// HPX_PLAIN_ACTION_ID(app::some_global_function, some_global_action, +/// some_unique_id); /// \endcode /// /// \note The macro \a HPX_PLAIN_ACTION_ID has to be used at global namespace even diff --git a/hpx/runtime/actions/transfer_action.hpp b/hpx/runtime/actions/transfer_action.hpp index 688bdf65684a..5cabc3ae5cda 100644 --- a/hpx/runtime/actions/transfer_action.hpp +++ b/hpx/runtime/actions/transfer_action.hpp @@ -285,7 +285,8 @@ namespace hpx { namespace actions } threads::thread_init_data& - get_thread_init_data(std::unique_ptr cont, naming::id_type const& target, + get_thread_init_data(std::unique_ptr cont, + naming::id_type const& target, naming::address::address_type lva, threads::thread_init_data& data) { data.func = get_thread_function(std::move(cont), lva); @@ -316,7 +317,8 @@ namespace hpx { namespace actions if (traits::action_decorate_continuation::call(cont)) { traits::action_schedule_thread::call(lva, - get_thread_init_data(std::move(cont), target, lva, data), initial_state); + get_thread_init_data(std::move(cont), target, lva, data), + initial_state); } else { diff --git a/hpx/runtime/agas/response.hpp b/hpx/runtime/agas/response.hpp index 50d33927ca93..98a7f6c0b875 100644 --- a/hpx/runtime/agas/response.hpp +++ b/hpx/runtime/agas/response.hpp @@ -381,14 +381,16 @@ struct get_remote_result, agas::resp } HPX_THROW_EXCEPTION(bad_parameter, - "get_remote_result, agas::response>::call", + "get_remote_result," + " agas::response>::call", "unexpected action code in result conversion"); return std::pair(); } }; template <> -struct get_remote_result, agas::response> +struct get_remote_result, + agas::response> { static std::map call( agas::response const& rep diff --git a/hpx/runtime/agas/server/component_namespace.hpp b/hpx/runtime/agas/server/component_namespace.hpp index dcf06c12ebbd..b513f5a421fa 100644 --- a/hpx/runtime/agas/server/component_namespace.hpp +++ b/hpx/runtime/agas/server/component_namespace.hpp @@ -130,7 +130,8 @@ struct HPX_EXPORT component_namespace api_counter_data resolve_id_; // component_ns_resolve_id api_counter_data unbind_name_; // component_ns_unbind_name api_counter_data iterate_types_; // component_ns_iterate_types - api_counter_data get_component_type_name_; // component_ns_get_component_type_name + api_counter_data get_component_type_name_; + // component_ns_get_component_type_name api_counter_data num_localities_; // component_ns_num_localities }; counter_data counter_data_; @@ -260,7 +261,8 @@ struct HPX_EXPORT component_namespace }; // }}} HPX_DEFINE_COMPONENT_ACTION(component_namespace, remote_service, service_action); - HPX_DEFINE_COMPONENT_ACTION(component_namespace, remote_bulk_service, bulk_service_action); + HPX_DEFINE_COMPONENT_ACTION(component_namespace, remote_bulk_service, + bulk_service_action); }; }}} diff --git a/hpx/runtime/agas/server/locality_namespace.hpp b/hpx/runtime/agas/server/locality_namespace.hpp index e0422dbda1b0..e60d433505ce 100644 --- a/hpx/runtime/agas/server/locality_namespace.hpp +++ b/hpx/runtime/agas/server/locality_namespace.hpp @@ -259,7 +259,8 @@ struct HPX_EXPORT locality_namespace }; // }}} HPX_DEFINE_COMPONENT_ACTION(locality_namespace, remote_service, service_action); - HPX_DEFINE_COMPONENT_ACTION(locality_namespace, remote_bulk_service, bulk_service_action); + HPX_DEFINE_COMPONENT_ACTION(locality_namespace, remote_bulk_service, + bulk_service_action); }; }}} diff --git a/hpx/runtime/agas/server/primary_namespace.hpp b/hpx/runtime/agas/server/primary_namespace.hpp index 44c7811082e2..ff7d87926a22 100644 --- a/hpx/runtime/agas/server/primary_namespace.hpp +++ b/hpx/runtime/agas/server/primary_namespace.hpp @@ -429,7 +429,8 @@ struct HPX_EXPORT primary_namespace }; // }}} HPX_DEFINE_COMPONENT_ACTION(primary_namespace, remote_service, service_action); - HPX_DEFINE_COMPONENT_ACTION(primary_namespace, remote_bulk_service, bulk_service_action); + HPX_DEFINE_COMPONENT_ACTION(primary_namespace, remote_bulk_service, + bulk_service_action); HPX_DEFINE_COMPONENT_ACTION(primary_namespace, route, route_action); diff --git a/hpx/runtime/agas/server/symbol_namespace.hpp b/hpx/runtime/agas/server/symbol_namespace.hpp index b533b0f0e66d..5e5395e949a1 100644 --- a/hpx/runtime/agas/server/symbol_namespace.hpp +++ b/hpx/runtime/agas/server/symbol_namespace.hpp @@ -234,7 +234,8 @@ struct HPX_EXPORT symbol_namespace }; // }}} HPX_DEFINE_COMPONENT_ACTION(symbol_namespace, remote_service, service_action); - HPX_DEFINE_COMPONENT_ACTION(symbol_namespace, remote_bulk_service, bulk_service_action); + HPX_DEFINE_COMPONENT_ACTION(symbol_namespace, remote_bulk_service, + bulk_service_action); }; }}} diff --git a/hpx/runtime/applier/apply.hpp b/hpx/runtime/applier/apply.hpp index aeee49df0364..10317b3c6c1d 100644 --- a/hpx/runtime/applier/apply.hpp +++ b/hpx/runtime/applier/apply.hpp @@ -465,7 +465,8 @@ namespace hpx action_type_(), priority); // Send the parcel through the parcel handler - hpx::applier::get_applier().get_parcel_handler().sync_put_parcel(std::move(p)); + hpx::applier::get_applier().get_parcel_handler() + .sync_put_parcel(std::move(p)); return false; // destination is remote } @@ -504,7 +505,8 @@ namespace hpx apply_l (Continuation && c, naming::id_type const& target, naming::address& addr, Ts&&... vs) { - return apply_l_p(std::forward(c), target, std::move(addr), + return apply_l_p(std::forward(c), + target, std::move(addr), actions::action_priority(), std::forward(vs)...); } }} @@ -521,7 +523,8 @@ namespace hpx std::forward(c), gid, priority, std::forward(vs)...); } - template + template inline typename boost::enable_if_c< traits::is_continuation::value && traits::is_distribution_policy::value, bool @@ -576,11 +579,13 @@ namespace hpx apply(Continuation && c, naming::id_type const& gid, Ts&&... vs) { - return apply_p(std::forward(c), gid, actions::action_priority(), + return apply_p(std::forward(c), gid, + actions::action_priority(), std::forward(vs)...); } - template + template inline typename boost::enable_if_c< traits::is_distribution_policy::value && traits::is_continuation::value diff --git a/hpx/runtime/applier/apply_callback.hpp b/hpx/runtime/applier/apply_callback.hpp index 54b124a26820..e394a7bbdc35 100644 --- a/hpx/runtime/applier/apply_callback.hpp +++ b/hpx/runtime/applier/apply_callback.hpp @@ -107,7 +107,8 @@ namespace hpx /////////////////////////////////////////////////////////////////////////// namespace applier { namespace detail { - template + template inline bool apply_r_p_cb(naming::address&& addr, Continuation && c, naming::id_type const& id, @@ -120,12 +121,14 @@ namespace hpx std::forward(vs)...); } - template + template inline bool apply_r_cb(naming::address&& addr, Continuation && c, naming::id_type const& gid, Callback && cb, Ts&&... vs) { - return apply_r_p_cb(std::move(addr), std::forward(c), gid, + return apply_r_p_cb(std::move(addr), std::forward(c), + gid, actions::action_priority(), std::forward(cb), std::forward(vs)...); } @@ -149,7 +152,8 @@ namespace hpx // Determine whether the gid is local or remote if (addr.locality_ == hpx::get_locality()) { // apply locally - bool result = applier::detail::apply_l_p(std::forward(c), gid, + bool result = + applier::detail::apply_l_p(std::forward(c), gid, std::move(addr), priority, std::forward(vs)...); // invoke callback @@ -168,7 +172,8 @@ namespace hpx apply_p_cb(Continuation && c, naming::id_type const& gid, threads::thread_priority priority, Callback && cb, Ts&&... vs) { - return hpx::detail::apply_cb_impl(std::forward(c), gid, priority, + return hpx::detail::apply_cb_impl(std::forward(c), + gid, priority, std::forward(cb), std::forward(vs)...); } @@ -177,22 +182,26 @@ namespace hpx apply_cb(Continuation && c, naming::id_type const& gid, Callback && cb, Ts&&... vs) { - return apply_p_cb(std::forward(c), gid, actions::action_priority(), + return apply_p_cb(std::forward(c), gid, + actions::action_priority(), std::forward(cb), std::forward(vs)...); } - template inline bool apply_cb(Continuation && c, hpx::actions::basic_action /*act*/, naming::id_type const& gid, Callback && cb, Ts&&... vs) { - return apply_p(std::forward(c), gid, actions::action_priority(), + return apply_p(std::forward(c), gid, + actions::action_priority(), std::forward(cb), std::forward(vs)...); } - template inline typename boost::enable_if_c< traits::is_continuation::value && @@ -205,7 +214,8 @@ namespace hpx priority, std::forward(cb), std::forward(vs)...); } - template inline typename boost::enable_if_c< traits::is_continuation::value && @@ -214,11 +224,13 @@ namespace hpx apply_cb(Continuation && c, DistPolicy const& policy, Callback && cb, Ts&&... vs) { - return apply_p_cb(std::forward(c), policy, actions::action_priority(), + return apply_p_cb(std::forward(c), policy, + actions::action_priority(), std::forward(cb), std::forward(vs)...); } - template inline typename boost::enable_if_c< traits::is_distribution_policy::value, bool @@ -227,7 +239,8 @@ namespace hpx hpx::actions::basic_action /*act*/, DistPolicy const& policy, Callback && cb, Ts&&... vs) { - return apply_p(std::forward(c), policy, actions::action_priority(), + return apply_p(std::forward(c), policy, + actions::action_priority(), std::forward(cb), std::forward(vs)...); } diff --git a/hpx/runtime/applier/apply_helper.hpp b/hpx/runtime/applier/apply_helper.hpp index c281bba9e276..1916456abd55 100644 --- a/hpx/runtime/applier/apply_helper.hpp +++ b/hpx/runtime/applier/apply_helper.hpp @@ -132,16 +132,28 @@ namespace hpx { namespace applier { namespace detail template static void call (Continuation && c, naming::id_type const& target, + naming::address::address_type lva, threads::thread_priority priority, + Ts&&... vs) + { + std::unique_ptr cont( + new typename util::decay::type( + std::forward(c))); + call(std::move(cont), target, lva, priority, std::forward(vs)...); + } + + template + static void + call (std::unique_ptr cont, naming::id_type const& target, naming::address::address_type lva, threads::thread_priority, Ts&&... vs) { try { - c.trigger(Action::execute_function(lva, + cont->trigger(Action::execute_function(lva, std::forward(vs)...)); } catch (hpx::exception const& /*e*/) { // make sure hpx::exceptions are propagated back to the client - c.trigger_error(boost::current_exception()); + cont->trigger_error(boost::current_exception()); } } }; diff --git a/hpx/runtime/applier/detail/apply_colocated.hpp b/hpx/runtime/applier/detail/apply_colocated.hpp index a75043c04437..41fc831b4326 100644 --- a/hpx/runtime/applier/detail/apply_colocated.hpp +++ b/hpx/runtime/applier/detail/apply_colocated.hpp @@ -52,7 +52,11 @@ namespace hpx { namespace detail } template - bool apply_colocated(Continuation && cont, + typename std::enable_if< + traits::is_continuation::value + , bool + >::type + apply_colocated(Continuation && cont, naming::id_type const& gid, Ts&&... vs) { // Attach the requested action as a continuation to a resolve_async diff --git a/hpx/runtime/applier/detail/apply_colocated_fwd.hpp b/hpx/runtime/applier/detail/apply_colocated_fwd.hpp index b2dabb9f046f..477e70668495 100644 --- a/hpx/runtime/applier/detail/apply_colocated_fwd.hpp +++ b/hpx/runtime/applier/detail/apply_colocated_fwd.hpp @@ -9,6 +9,7 @@ #include #include #include +#include namespace hpx { namespace detail { @@ -24,7 +25,11 @@ namespace hpx { namespace detail /////////////////////////////////////////////////////////////////////////// template - bool apply_colocated(Continuation && cont, + typename std::enable_if< + traits::is_continuation::value + , bool + >::type + apply_colocated(Continuation && cont, naming::id_type const& gid, Ts&&... vs); template +#include +#include +#include +#include + +#include + +namespace hpx +{ + /////////////////////////////////////////////////////////////////////////// + /// Return all registered ids from all localities from the given base + /// name. + /// + /// This function locates all ids which were registered with the given + /// base name. It returns a list of futures representing those ids. + /// + /// \param base_name [in] The base name for which to retrieve the + /// registered ids. + /// \param num_ids [in] The number of registered ids to expect. + /// + /// \returns A list of futures representing the ids which were registered + /// using the given base name. + /// + /// \note The futures will become ready even if the event (for instance, + /// binding the name to an id) has already happened in the past. + /// This is important in order to reliably retrieve ids from a + /// name, even if the name was already registered. + /// + HPX_API_EXPORT std::vector > + find_all_from_basename(std::string base_name, std::size_t num_ids); + + /////////////////////////////////////////////////////////////////////////// + /// Return all registered clients from all localities from the given base + /// name. + /// + /// This function locates all ids which were registered with the given + /// base name. It returns a list of futures representing those ids. + /// + /// \tparam Client The client type to return + /// + /// \param base_name [in] The base name for which to retrieve the + /// registered ids. + /// \param num_ids [in] The number of registered ids to expect. + /// + /// \returns A list of futures representing the ids which were registered + /// using the given base name. + /// + /// \note The futures embedded in the returned client objects will become + /// ready even if the event (for instance, + /// binding the name to an id) has already happened in the past. + /// This is important in order to reliably retrieve ids from a + /// name, even if the name was already registered. + /// + template + std::vector + find_all_from_basename(std::string base_name, std::size_t num_ids) + { + return components::make_client( + find_all_from_basename(std::move(base_name), num_ids)); + } + + /// Return registered ids from the given base name and sequence numbers. + /// + /// This function locates the ids which were registered with the given + /// base name and the given sequence numbers. It returns a list of futures + /// representing those ids. + /// + /// \param base_name [in] The base name for which to retrieve the + /// registered ids. + /// \param ids [in] The sequence numbers of the registered ids. + /// + /// \returns A list of futures representing the ids which were registered + /// using the given base name and sequence numbers. + /// + /// \note The futures will become ready even if the event (for instance, + /// binding the name to an id) has already happened in the past. + /// This is important in order to reliably retrieve ids from a + /// name, even if the name was already registered. + /// + HPX_API_EXPORT std::vector > + find_from_basename(std::string base_name, + std::vector const& ids); + + /// Return registered clients from the given base name and sequence numbers. + /// + /// This function locates the ids which were registered with the given + /// base name and the given sequence numbers. It returns a list of futures + /// representing those ids. + /// + /// \tparam Client The client type to return + /// + /// \param base_name [in] The base name for which to retrieve the + /// registered ids. + /// \param ids [in] The sequence numbers of the registered ids. + /// + /// \returns A list of futures representing the ids which were registered + /// using the given base name and sequence numbers. + /// + /// \note The futures embedded in the returned client objects will become + /// ready even if the event (for instance, + /// binding the name to an id) has already happened in the past. + /// This is important in order to reliably retrieve ids from a + /// name, even if the name was already registered. + /// + template + std::vector + find_from_basename(std::string base_name, + std::vector const& ids) + { + return components::make_client( + find_from_basename(std::move(base_name), ids)); + } + + /// \brief Return registered id from the given base name and sequence number. + /// + /// This function locates the id which was registered with the given + /// base name and the given sequence number. It returns a future + /// representing those id. + /// + /// \param base_name [in] The base name for which to retrieve the + /// registered ids. + /// \param sequence_nr [in] The sequence number of the registered id. + /// + /// \returns A representing the id which was registered using the given + /// base name and sequence numbers. + /// + /// \note The future will become ready even if the event (for instance, + /// binding the name to an id) has already happened in the past. + /// This is important in order to reliably retrieve ids from a + /// name, even if the name was already registered. + /// + HPX_API_EXPORT hpx::future + find_from_basename(std::string base_name, + std::size_t sequence_nr = ~0U); + + /// \brief Return registered id from the given base name and sequence number. + /// + /// This function locates the id which was registered with the given + /// base name and the given sequence number. It returns a future + /// representing those id. + /// + /// \tparam Client The client type to return + /// + /// \param base_name [in] The base name for which to retrieve the + /// registered ids. + /// \param sequence_nr [in] The sequence number of the registered id. + /// + /// \returns A representing the id which was registered using the given + /// base name and sequence numbers. + /// + /// \note The future embedded in the returned client object will become + /// ready even if the event (for instance, + /// binding the name to an id) has already happened in the past. + /// This is important in order to reliably retrieve ids from a + /// name, even if the name was already registered. + /// + template + Client find_from_basename(std::string base_name, + std::size_t sequence_nr = ~0U) + { + return components::make_client( + find_from_basename(std::move(base_name), sequence_nr)); + } + + /////////////////////////////////////////////////////////////////////////// + /// \brief Register the given id using the given base name. + /// + /// The function registers the given ids using the provided base name. + /// + /// \param base_name [in] The base name for which to retrieve the + /// registered ids. + /// \param id [in] The id to register using the given base name. + /// \param sequence_nr [in, optional] The sequential number to use for the + /// registration of the id. This number has to be + /// unique system wide for each registration using the + /// same base name. The default is the current locality + /// identifier. Also, the sequence numbers have to be + /// consecutive starting from zero. + /// + /// \returns A future representing the result of the registration operation + /// itself. + /// + /// \note The operation will fail if the given sequence number is not + /// unique. + /// + HPX_API_EXPORT hpx::future register_with_basename( + std::string base_name, hpx::id_type id, std::size_t sequence_nr = ~0U); + + /// Register the id wrapped in the given future using the given base name. + /// + /// The function registers the object the given future refers to using the + /// provided base name. + /// + /// \param base_name [in] The base name for which to retrieve the + /// registered ids. + /// \param f [in] The future which should be registered using + /// the given base name. + /// \param sequence_nr [in, optional] The sequential number to use for the + /// registration of the id. This number has to be + /// unique system wide for each registration using the + /// same base name. The default is the current locality + /// identifier. Also, the sequence numbers have to be + /// consecutive starting from zero. + /// + /// \returns A future representing the result of the registration operation + /// itself. + /// + /// \note The operation will fail if the given sequence number is not + /// unique. + /// + template + hpx::future register_with_basename(std::string base_name, + hpx::future f, std::size_t sequence_nr = ~0U) + { + return f.then( + [=](hpx::future && f) mutable + { + return register_with_basename(std::move(base_name), f.get(), + sequence_nr); + }); + } + + /// Register the id wrapped in the given client using the given base name. + /// + /// The function registers the object the given client refers to using the + /// provided base name. + /// + /// \tparam Client The client type to register + /// + /// \param base_name [in] The base name for which to retrieve the + /// registered ids. + /// \param client [in] The client which should be registered using + /// the given base name. + /// \param sequence_nr [in, optional] The sequential number to use for the + /// registration of the id. This number has to be + /// unique system wide for each registration using the + /// same base name. The default is the current locality + /// identifier. Also, the sequence numbers have to be + /// consecutive starting from zero. + /// + /// \returns A future representing the result of the registration operation + /// itself. + /// + /// \note The operation will fail if the given sequence number is not + /// unique. + /// + template + hpx::future register_with_basename(std::string base_name, + components::client_base& client, + std::size_t sequence_nr = ~0U) + { + return client.then( + [=](components::client_base && c) mutable + { + return register_with_basename(std::move(base_name), c.get_id(), + sequence_nr); + }); + } + + /// \brief Unregister the given id using the given base name. + /// + /// The function unregisters the given ids using the provided base name. + /// + /// \param base_name [in] The base name for which to retrieve the + /// registered ids. + /// \param sequence_nr [in, optional] The sequential number to use for the + /// un-registration. This number has to be the same + /// as has been used with \a register_with_basename + /// before. + /// + /// \returns A future representing the result of the un-registration + /// operation itself. + /// + HPX_API_EXPORT hpx::future unregister_with_basename( + std::string base_name, std::size_t sequence_nr = ~0U); + + /// Unregister the given base name. + /// + /// The function unregisters the given ids using the provided base name. + /// + /// \tparam Client The client type to return + /// + /// \param base_name [in] The base name for which to retrieve the + /// registered ids. + /// \param sequence_nr [in, optional] The sequential number to use for the + /// un-registration. This number has to be the same + /// as has been used with \a register_with_basename + /// before. + /// + /// \returns A future representing the result of the un-registration + /// operation itself. + /// + template + Client unregister_with_basename( + std::string base_name, std::size_t sequence_nr = ~0U) + { + return components::make_client( + unregister_with_basename(std::move(base_name), sequence_nr)); + } +} + +#endif diff --git a/hpx/runtime/components/client_base.hpp b/hpx/runtime/components/client_base.hpp index d678bd3de136..0ce9d793e260 100644 --- a/hpx/runtime/components/client_base.hpp +++ b/hpx/runtime/components/client_base.hpp @@ -378,24 +378,24 @@ namespace hpx { namespace components agas::symbol_ns_bind, true).share(); } -// protected: -// template -// static typename lcos::detail::future_then_result::cont_result -// on_ready(future_type fut, F && f) -// { -// return f(Derived(fut)); -// } -// -// public: -// template -// typename lcos::detail::future_then_result::type -// then(F && f) -// { -// typedef typename util::decay::type func_type; -// return gid_.then(util::bind( -// util::one_shot(&client_base::on_ready), -// std::forward(f))); -// } + protected: + template + static typename lcos::detail::future_then_result::cont_result + on_ready(future_type && fut, F f) + { + return f(client_base(std::move(fut))); + } + + public: + template + typename lcos::detail::future_then_result::type + then(F && f) + { + typedef typename util::decay::type func_type; + return gid_.then(util::bind( + util::one_shot(&client_base::template on_ready), + util::placeholders::_1, std::forward(f))); + } private: friend class hpx::serialization::access; @@ -481,7 +481,7 @@ namespace hpx { namespace components result.reserve(ids.size()); for (hpx::future& id: ids) { - result.push_back(Client(id)); + result.push_back(Client(std::move(id))); } return result; } diff --git a/hpx/runtime/components/colocating_distribution_policy.hpp b/hpx/runtime/components/colocating_distribution_policy.hpp index 723e2aa856a9..02b14a545e16 100644 --- a/hpx/runtime/components/colocating_distribution_policy.hpp +++ b/hpx/runtime/components/colocating_distribution_policy.hpp @@ -210,7 +210,8 @@ namespace hpx { namespace components /// \note This function is part of the invocation policy implemented by /// this class /// - template + template bool apply_cb(Continuation && c, threads::thread_priority priority, Callback&& cb, Ts&&... vs) const { diff --git a/hpx/runtime/components/component_type.hpp b/hpx/runtime/components/component_type.hpp index 4d5b70bad525..21a2592a9bf4 100644 --- a/hpx/runtime/components/component_type.hpp +++ b/hpx/runtime/components/component_type.hpp @@ -61,8 +61,9 @@ namespace hpx { namespace components component_type rhs_base = get_base_type(rhs); // special case for lco's - if ((lhs_base == component_base_lco && rhs_base == component_base_lco_with_value) || - (rhs_base == component_base_lco && lhs_base == component_base_lco_with_value)) + if ((lhs_base == component_base_lco && rhs_base == component_base_lco_with_value) + || (rhs_base == component_base_lco && lhs_base == + component_base_lco_with_value)) { return true; } diff --git a/hpx/runtime/components/default_distribution_policy.hpp b/hpx/runtime/components/default_distribution_policy.hpp index ec16bfba599e..2e38b45dab53 100644 --- a/hpx/runtime/components/default_distribution_policy.hpp +++ b/hpx/runtime/components/default_distribution_policy.hpp @@ -240,7 +240,8 @@ namespace hpx { namespace components /// \note This function is part of the invocation policy implemented by /// this class /// - template + template bool apply_cb(Continuation && c, threads::thread_priority priority, Callback&& cb, Ts&&... vs) const { diff --git a/hpx/runtime/components/derived_component_factory.hpp b/hpx/runtime/components/derived_component_factory.hpp index 44531686913f..8ee616a44248 100644 --- a/hpx/runtime/components/derived_component_factory.hpp +++ b/hpx/runtime/components/derived_component_factory.hpp @@ -101,13 +101,15 @@ namespace hpx { namespace components // First call to get_component_type, ask AGAS for a unique id. // NOTE: This assumes that the derived component is loaded. base_type = agas_client.get_component_id( - unique_component_name::call()); + unique_component_name::call()); } component_type this_type; if (isenabled_) { this_type = agas_client.register_factory( - locality, unique_component_name::call()); + locality, unique_component_name + ::call()); if (component_invalid == this_type) { HPX_THROW_EXCEPTION(duplicate_component_id, diff --git a/hpx/runtime/components/new.hpp b/hpx/runtime/components/new.hpp index f71a9779c635..0b9cb07da79e 100644 --- a/hpx/runtime/components/new.hpp +++ b/hpx/runtime/components/new.hpp @@ -254,7 +254,8 @@ namespace hpx { namespace components std::forward(vs)...); return f.then(launch::sync, - [count](hpx::future > && f) -> std::vector + [count](hpx::future > + && f) -> std::vector { std::vector result; result.reserve(count); diff --git a/hpx/runtime/components/server/managed_component_base.hpp b/hpx/runtime/components/server/managed_component_base.hpp index b1cf6472b54a..16625d124f2c 100644 --- a/hpx/runtime/components/server/managed_component_base.hpp +++ b/hpx/runtime/components/server/managed_component_base.hpp @@ -195,7 +195,8 @@ namespace hpx { namespace components // lifetime of the managed_component BOOST_STATIC_ASSERT(( boost::is_same::value || - boost::is_same::value)); + boost::is_same::value)); managed_component_base() : back_ptr_(0) diff --git a/hpx/runtime/components/targeting_distribution_policy.hpp b/hpx/runtime/components/targeting_distribution_policy.hpp index c9500f7f76e3..15f3eed1bde7 100644 --- a/hpx/runtime/components/targeting_distribution_policy.hpp +++ b/hpx/runtime/components/targeting_distribution_policy.hpp @@ -167,7 +167,8 @@ namespace hpx { namespace components /// \note This function is part of the invocation policy implemented by /// this class /// - template + template bool apply_cb(Continuation && c, threads::thread_priority priority, Callback&& cb, Ts&&... vs) const { diff --git a/hpx/runtime/get_ptr.hpp b/hpx/runtime/get_ptr.hpp index 468d557b17c7..77fbfd4cbd36 100644 --- a/hpx/runtime/get_ptr.hpp +++ b/hpx/runtime/get_ptr.hpp @@ -116,7 +116,8 @@ namespace hpx } /// \endcond - /// \brief Returns a future referring to a the pointer to the underlying memory of a component + /// \brief Returns a future referring to a the pointer to the + /// underlying memory of a component /// /// The function hpx::get_ptr can be used to extract a future /// referring to the pointer to the underlying memory of a given component. diff --git a/hpx/runtime/naming/address.hpp b/hpx/runtime/naming/address.hpp index ae99b97495c1..92f46a2887a1 100644 --- a/hpx/runtime/naming/address.hpp +++ b/hpx/runtime/naming/address.hpp @@ -38,7 +38,8 @@ namespace hpx { namespace naming : locality_(l), type_(t), address_(0), offset_(0) {} - address(gid_type const& l, component_type t, void* lva, boost::uint64_t offset = 0) + address(gid_type const& l, component_type t, void* lva, + boost::uint64_t offset = 0) : locality_(l), type_(t), address_(reinterpret_cast(lva)), offset_(offset) diff --git a/hpx/runtime/naming/id_type.hpp b/hpx/runtime/naming/id_type.hpp index 285df85a8b21..149e5855b192 100644 --- a/hpx/runtime/naming/id_type.hpp +++ b/hpx/runtime/naming/id_type.hpp @@ -55,7 +55,7 @@ namespace hpx { namespace naming id_type(id_type const & o) : gid_(o.gid_) {} id_type(id_type && o) - : gid_(o.gid_) + : gid_(std::move(o.gid_)) { o.gid_.reset(); } diff --git a/hpx/runtime/naming/name.hpp b/hpx/runtime/naming/name.hpp index d15acb215cf8..93c31ede9a4c 100644 --- a/hpx/runtime/naming/name.hpp +++ b/hpx/runtime/naming/name.hpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -580,7 +581,8 @@ namespace hpx { namespace naming HPX_ASSERT(0 == (log2credits & ~gid_type::credit_base_mask)); id.set_msb((id.get_msb() & ~gid_type::credit_mask) | - ((boost::int32_t(log2credits) << gid_type::credit_shift) & gid_type::credit_mask) | + ((boost::int32_t(log2credits) << gid_type::credit_shift) + & gid_type::credit_mask) | gid_type::has_credits_mask); } @@ -635,9 +637,11 @@ namespace hpx { namespace naming } /////////////////////////////////////////////////////////////////////// - HPX_EXPORT gid_type split_gid_if_needed(gid_type& id); - HPX_EXPORT gid_type split_gid_if_needed_locked(gid_type::mutex_type::scoped_try_lock &l, gid_type& gid); - HPX_EXPORT gid_type replenish_new_gid_if_needed(gid_type const& id); + HPX_EXPORT hpx::future split_gid_if_needed(gid_type& id); + HPX_EXPORT hpx::future split_gid_if_needed_locked( + gid_type::mutex_type::scoped_lock &l, gid_type& gid); + HPX_EXPORT hpx::future replenish_new_gid_if_needed( + gid_type const& id); HPX_EXPORT gid_type move_gid(gid_type& id); HPX_EXPORT gid_type move_gid_locked(gid_type& gid); @@ -700,8 +704,10 @@ namespace hpx { namespace naming // detail::strip_internal_bits_and_locality_from_gid(lhs.id_msb_) - // detail::strip_internal_bits_and_locality_from_gid(rhs.id_msb_); // -// boost::uint32_t lhs_locality_id = naming::get_locality_id_from_gid(lhs.id_msb_); -// boost::uint32_t rhs_locality_id = naming::get_locality_id_from_gid(rhs.id_msb_); +// boost::uint32_t lhs_locality_id = +// naming::get_locality_id_from_gid(lhs.id_msb_); +// boost::uint32_t rhs_locality_id = +// naming::get_locality_id_from_gid(rhs.id_msb_); // if (rhs_locality_id != naming::invalid_locality_id) // { // HPX_ASSERT(lhs_locality_id == rhs_locality_id); @@ -768,6 +774,7 @@ namespace hpx { namespace naming /////////////////////////////////////////////////////////////////////// struct HPX_EXPORT id_type_impl : gid_type { + HPX_MOVABLE_BUT_NOT_COPYABLE(id_type_impl); private: typedef void (*deleter_type)(detail::id_type_impl*); static deleter_type get_deleter(id_type_management t); @@ -806,7 +813,7 @@ namespace hpx { namespace naming private: // credit management (called during serialization), this function // has to be 'const' as save() above has to be 'const'. - naming::gid_type preprocess_gid() const; + void preprocess_gid(serialization::output_archive& ar) const; // reference counting friend HPX_EXPORT void intrusive_ptr_add_ref(id_type_impl* p); @@ -848,7 +855,8 @@ namespace hpx { namespace naming inline id_type get_id_from_locality_id(boost::uint32_t locality_id) { - return id_type(boost::uint64_t(locality_id+1) << 32, 0, id_type::unmanaged); //-V112 + return id_type(boost::uint64_t(locality_id+1) << 32, 0, id_type::unmanaged); + //-V112 } inline boost::uint32_t get_locality_id_from_id(id_type const& id) HPX_PURE; diff --git a/hpx/runtime/parcelset/detail/call_for_each.hpp b/hpx/runtime/parcelset/detail/call_for_each.hpp new file mode 100644 index 000000000000..c804ca7a011b --- /dev/null +++ b/hpx/runtime/parcelset/detail/call_for_each.hpp @@ -0,0 +1,59 @@ +// Copyright (c) 2013 Thomas Heller +// Copyright (c) 2007-2013 Hartmut Kaiser +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef HPX_RUNTIME_PARCELSET_DETAIL_CALL_FOR_EACH_HPP +#define HPX_RUNTIME_PARCELSET_DETAIL_CALL_FOR_EACH_HPP + +#include + +/////////////////////////////////////////////////////////////////////////////// +namespace hpx { namespace parcelset +{ + /////////////////////////////////////////////////////////////////////////// + namespace detail + { + struct call_for_each + { + BOOST_MOVABLE_BUT_NOT_COPYABLE(call_for_each); + public: + typedef void result_type; + + typedef std::vector handlers_type; + typedef std::vector parcels_type; + handlers_type handlers_; + parcels_type parcels_; + + call_for_each(handlers_type&& handlers, parcels_type && parcels) + : handlers_(std::move(handlers)) + , parcels_(std::move(parcels)) + {} + + call_for_each(call_for_each &&other) + : handlers_(std::move(other.handlers_)) + , parcels_(std::move(other.parcels_)) + {} + + call_for_each& operator=(call_for_each &&other) + { + handlers_ = std::move(other.handlers_); + parcels_ = std::move(other.parcels_); + + return *this; + } + + result_type operator()(boost::system::error_code const& e) const + { + HPX_ASSERT(parcels_.size() == handlers_.size()); + for(std::size_t i = 0; i < parcels_.size(); ++i) + { + handlers_[i](e, parcels_[i]); + } + } + }; + } +}} + +#endif diff --git a/hpx/runtime/parcelset/encode_parcels.hpp b/hpx/runtime/parcelset/encode_parcels.hpp index 4a853e6ecabb..f5a50f62d5b3 100644 --- a/hpx/runtime/parcelset/encode_parcels.hpp +++ b/hpx/runtime/parcelset/encode_parcels.hpp @@ -124,10 +124,10 @@ namespace hpx } } - template + template std::size_t encode_parcels(parcel const * ps, std::size_t num_parcels, Buffer & buffer, - int archive_flags_, boost::uint64_t max_outbound_size) + int archive_flags_, boost::uint64_t max_outbound_size, NewGids new_gids) { HPX_ASSERT(buffer.data_.empty()); // collect argument sizes from parcels @@ -180,7 +180,8 @@ namespace hpx , archive_flags , dest_locality_id , &buffer.chunks_ - , filter.get()); + , filter.get() + , new_gids); if(num_parcels != std::size_t(-1)) archive << parcels_sent; //-V128 diff --git a/hpx/runtime/parcelset/parcel.hpp b/hpx/runtime/parcelset/parcel.hpp index cd11a8b31141..8b4f88e20d58 100644 --- a/hpx/runtime/parcelset/parcel.hpp +++ b/hpx/runtime/parcelset/parcel.hpp @@ -77,7 +77,8 @@ namespace hpx { namespace parcelset template < typename Action , typename...Args - , typename Enable = typename std::enable_if::value>::type + , typename Enable = + typename std::enable_if::value>::type > parcel( naming::id_type const& dests, @@ -102,7 +103,8 @@ namespace hpx { namespace parcelset template < typename Action , typename...Args - , typename Enable = typename std::enable_if::value>::type + , typename Enable = + typename std::enable_if::value>::type > parcel( std::vector const& dests, @@ -167,7 +169,8 @@ namespace hpx { namespace parcelset addrs_(addrs), #endif cont_( - new typename util::decay::type(std::forward(cont)) + new typename util::decay + ::type(std::forward(cont)) ), action_(new actions::transfer_action(std::forward(args)...)) { diff --git a/hpx/runtime/parcelset/parcel_buffer.hpp b/hpx/runtime/parcelset/parcel_buffer.hpp index b20438321e76..8bc5f25be1f9 100644 --- a/hpx/runtime/parcelset/parcel_buffer.hpp +++ b/hpx/runtime/parcelset/parcel_buffer.hpp @@ -18,7 +18,8 @@ namespace hpx { namespace parcelset { - template + template struct parcel_buffer { typedef std::pair< @@ -40,7 +41,8 @@ namespace hpx { namespace parcelset , size_(0), data_size_(0) {} - explicit parcel_buffer(BufferType && data, allocator_type allocator = allocator_type()) + explicit parcel_buffer(BufferType && data, + allocator_type allocator = allocator_type()) : data_(std::move(data), allocator) , num_chunks_(count_chunks_type(0, 0)) , size_(0), data_size_(0) diff --git a/hpx/runtime/parcelset/parcelhandler.hpp b/hpx/runtime/parcelset/parcelhandler.hpp index cdb2fb1a1bf6..d4ff0e153c33 100644 --- a/hpx/runtime/parcelset/parcelhandler.hpp +++ b/hpx/runtime/parcelset/parcelhandler.hpp @@ -55,7 +55,8 @@ namespace hpx { namespace parcelset { // ensure the source locality id is set (if no component id is given) if (!p.source_id()) - p.set_source_id(naming::id_type(get_locality(), naming::id_type::unmanaged)); + p.set_source_id(naming::id_type(get_locality(), + naming::id_type::unmanaged)); // set the current local time for this locality p.set_start_time(get_current_time()); @@ -382,7 +383,8 @@ namespace hpx { namespace parcelset naming::resolver_client *resolver_; /// the parcelport this handler is associated with - typedef std::map, std::greater > pports_type; + typedef std::map, + std::greater > pports_type; pports_type pports_; std::map priority_; diff --git a/hpx/runtime/parcelset/parcelport.hpp b/hpx/runtime/parcelset/parcelport.hpp index 1a5d1e2ac4ce..0e89021770c7 100644 --- a/hpx/runtime/parcelset/parcelport.hpp +++ b/hpx/runtime/parcelset/parcelport.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014 Thomas Heller +// Copyright (c) 2014-2015 Thomas Heller // Copyright (c) 2007-2014 Hartmut Kaiser // Copyright (c) 2007 Richard D Guidry Jr // Copyright (c) 2011 Bryce Lelbach @@ -28,6 +28,12 @@ #include +#if defined(HPX_INTEL_VERSION) && HPX_INTEL_VERSION < 1400 +#define HPX_PARCELSET_PENDING_PARCELS_WORKAROUND +#elif defined(HPX_GCC_VERSION) && HPX_GCC_VERSION < 40900 +#define HPX_PARCELSET_PENDING_PARCELS_WORKAROUND +#endif + /////////////////////////////////////////////////////////////////////////////// namespace hpx { namespace agas { @@ -62,7 +68,8 @@ namespace hpx { namespace parcelset > read_handler_type; /// Construct the parcelport on the given locality. - parcelport(util::runtime_configuration const& ini, locality const & here, std::string const& type); + parcelport(util::runtime_configuration const& ini, locality const & here, + std::string const& type); /// Virtual destructor virtual ~parcelport() {} @@ -112,7 +119,8 @@ namespace hpx { namespace parcelset /// void handler(boost::system::error_code const& err, /// std::size_t bytes_written); /// \endcode - virtual void put_parcel(locality const & dest, parcel p, write_handler_type f) = 0; + virtual void put_parcel(locality const & dest, parcel p, + write_handler_type f) = 0; /// Queues a list of parcels for transmission to another locality /// @@ -129,7 +137,8 @@ namespace hpx { namespace parcelset /// void handler(boost::system::error_code const& err, /// std::size_t bytes_written); /// \endcode - virtual void put_parcels(std::vector dests, std::vector parcels, + virtual void put_parcels(std::vector dests, + std::vector parcels, std::vector handlers) = 0; /// Send an early parcel through the TCP parcelport @@ -182,7 +191,8 @@ namespace hpx { namespace parcelset virtual locality create_locality() const = 0; - virtual locality agas_locality(util::runtime_configuration const & ini) const = 0; + virtual locality agas_locality(util::runtime_configuration const & ini) + const = 0; /// Performance counter data @@ -353,7 +363,21 @@ namespace hpx { namespace parcelset hpx::applier::applier *applier_; /// The cache for pending parcels - typedef std::pair, std::deque > + typedef std::list new_gids_type; + typedef std::map new_gids_map; +#if defined(HPX_PARCELSET_PENDING_PARCELS_WORKAROUND) + typedef util::tuple< + boost::shared_ptr > + , std::vector + , new_gids_map + > +#else + typedef util::tuple< + std::vector + , std::vector + , new_gids_map + > +#endif map_second_type; typedef std::map pending_parcels_map; pending_parcels_map pending_parcels_; diff --git a/hpx/runtime/parcelset/parcelport_connection.hpp b/hpx/runtime/parcelset/parcelport_connection.hpp index 88b54e07abe2..8f5dd9c71573 100644 --- a/hpx/runtime/parcelset/parcelport_connection.hpp +++ b/hpx/runtime/parcelset/parcelport_connection.hpp @@ -47,6 +47,12 @@ namespace hpx { namespace parcelset { : first_message_(true) , state_(state_initialized) {} + + parcelport_connection(typename BufferType::allocator_type const & alloc) + : first_message_(true) + , state_(state_initialized) + , buffer_(alloc) + {} bool first_message_; state state_; #endif @@ -56,15 +62,35 @@ namespace hpx { namespace parcelset { : first_message_(true) {} bool first_message_; + + parcelport_connection(typename BufferType::allocator_type const & alloc) + : first_message_(true) + , buffer_(alloc) + {} + bool first_message_; #endif #if !defined(HPX_HAVE_SECURITY) && defined(HPX_TRACK_STATE_OF_OUTGOING_TCP_CONNECTION) parcelport_connection() : state_(state_initialized) {} + + parcelport_connection(typename BufferType::allocator_type const & alloc) + : state_(state_initialized) + , buffer_(alloc) + {} state state_; #endif +#if !defined(HPX_HAVE_SECURITY) && !defined(HPX_TRACK_STATE_OF_OUTGOING_TCP_CONNECTION) + parcelport_connection() + {} + + parcelport_connection(typename BufferType::allocator_type const & alloc) + : buffer_(alloc) + {} +#endif + #if defined(HPX_TRACK_STATE_OF_OUTGOING_TCP_CONNECTION) void set_state(state newstate) { @@ -78,13 +104,6 @@ namespace hpx { namespace parcelset { typedef BufferType buffer_type; typedef parcel_buffer parcel_buffer_type; - virtual parcel_buffer_type & get_buffer( - parcel const & p = parcel(), std::size_t arg_size = 0) - { - buffer_.data_.reserve(arg_size); - return buffer_; - } - /// buffer for data parcel_buffer_type buffer_; }; diff --git a/hpx/runtime/parcelset/parcelport_impl.hpp b/hpx/runtime/parcelset/parcelport_impl.hpp index 2dc5aa30ad9b..52c1624f47f4 100644 --- a/hpx/runtime/parcelset/parcelport_impl.hpp +++ b/hpx/runtime/parcelset/parcelport_impl.hpp @@ -12,7 +12,10 @@ #include #include +#include #include +#include +#include #include #include #include @@ -74,13 +77,15 @@ namespace hpx { namespace parcelset ini, key + ".max_connections", HPX_PARCEL_MAX_CONNECTIONS); } - static std::size_t max_connections_per_loc(util::runtime_configuration const& ini) + static + std::size_t max_connections_per_loc(util::runtime_configuration const& ini) { std::string key("hpx.parcel."); key += connection_handler_type(); return hpx::util::get_entry_as( - ini, key + ".max_connections_per_locality", HPX_PARCEL_MAX_CONNECTIONS_PER_LOCALITY); + ini, key + ".max_connections_per_locality", + HPX_PARCEL_MAX_CONNECTIONS_PER_LOCALITY); } public: @@ -168,13 +173,60 @@ namespace hpx { namespace parcelset } void put_parcel(locality const & dest, parcel p, write_handler_type f) + { + put_parcel(dest, std::move(p), std::move(f), true); + } + + void put_parcel(locality const & dest, parcel p, write_handler_type f, + bool trigger) { HPX_ASSERT(dest.type() == type()); + boost::shared_ptr + future_await(new hpx::serialization::detail::future_await_container()); + boost::shared_ptr + archive( + new hpx::serialization::output_archive( + *future_await, 0, 0, 0, 0, &future_await->new_gids_) + ); + (*archive) << p; + + if(future_await->has_futures()) + { + void (parcelport_impl::*awaiter)( + locality const &, parcel, write_handler_type, bool + , boost::shared_ptr const & + , boost::shared_ptr< + hpx::serialization::detail::future_await_container> const & + ) + = &parcelport_impl::put_parcel_impl; + (*future_await)( + util::bind( + util::one_shot(awaiter), this, + dest, std::move(p), std::move(f), true, + archive, future_await) + ); + return; + } + else + { + put_parcel_impl( + dest, std::move(p), std::move(f), trigger, archive, future_await); + } + } + + void put_parcel_impl( + locality const & dest, parcel p, write_handler_type f, bool trigger + , boost::shared_ptr const & + , boost::shared_ptr< + hpx::serialization::detail::future_await_container + > const & future_await) + { // enqueue the outgoing parcel ... - enqueue_parcel(dest, std::move(p), std::move(f)); + enqueue_parcel( + dest, std::move(p), std::move(f), std::move(future_await->new_gids_)); - if (enable_parcel_handling_) + if (trigger && enable_parcel_handling_) { if (hpx::is_running() && async_serialization()) { @@ -211,7 +263,12 @@ namespace hpx { namespace parcelset // enqueue the outgoing parcels ... HPX_ASSERT(parcels.size() == handlers.size()); - enqueue_parcels(locality_id, std::move(parcels), std::move(handlers)); + for(std::size_t i = 0; i < parcels.size(); ++i) + { + put_parcel( + locality_id, std::move(parcels[i]), std::move(handlers[i]), + false); + } if (enable_parcel_handling_) { @@ -241,9 +298,9 @@ namespace hpx { namespace parcelset bool do_background_work(std::size_t num_thread) { bool did_some_work = false; + did_some_work = do_background_work_impl(num_thread); if(num_thread == 0) { - did_some_work = do_background_work_impl(); trigger_pending_work(); } return did_some_work; @@ -315,7 +372,7 @@ namespace hpx { namespace parcelset return connection_handler().get_locality_name(); } - ///////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// // Return the given connection cache statistic boost::int64_t get_connection_cache_statistics( connection_cache_statistics_type t, bool reset) @@ -357,7 +414,7 @@ namespace hpx { namespace parcelset return static_cast(*this); } - /////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// // the code below is needed to bootstrap the parcel layer void early_pending_parcel_handler( boost::system::error_code const& ec, parcel const & p) @@ -416,9 +473,9 @@ namespace hpx { namespace parcelset >::do_background_work, bool >::type - do_background_work_impl() + do_background_work_impl(std::size_t num_thread) { - return connection_handler().background_work(); + return connection_handler().background_work(num_thread); } template @@ -428,7 +485,7 @@ namespace hpx { namespace parcelset >::do_background_work, bool >::type - do_background_work_impl() + do_background_work_impl(std::size_t) { return false; } @@ -463,7 +520,7 @@ namespace hpx { namespace parcelset boost::shared_ptr sender_connection; // Get a connection or reserve space for a new connection. - if (!connection_cache_.get_or_reserve(l, sender_connection, force)) + if (!connection_cache_.get_or_reserve(l, sender_connection)) { // If no slot is available it's not a problem as the parcel // will be sent out whenever the next connection is returned @@ -483,9 +540,26 @@ namespace hpx { namespace parcelset return sender_connection; } + void merge_gids(new_gids_map & gids, new_gids_map && new_gids) + { + for(auto & v : new_gids) + { + new_gids_map::iterator it = gids.find(v.first); + if(it == gids.end()) + { + gids.insert(v); + } + else + { + it->second.insert( + it->second.end(), v.second.begin(), v.second.end()); + } + } + } + /////////////////////////////////////////////////////////////////////// void enqueue_parcel(locality const& locality_id, - parcel&& p, write_handler_type&& f) + parcel&& p, write_handler_type&& f, new_gids_map && new_gids) { typedef pending_parcels_map::mapped_type mapped_type; @@ -498,15 +572,23 @@ namespace hpx { namespace parcelset > il(&l); mapped_type& e = pending_parcels_[locality_id]; - e.first.push_back(std::move(p)); - e.second.push_back(std::move(f)); +#if defined(HPX_PARCELSET_PENDING_PARCELS_WORKAROUND) + if(!util::get<0>(e)) + util::get<0>(e) = boost::make_shared >(); + util::get<0>(e)->push_back(std::move(p)); +#else + util::get<0>(e).push_back(std::move(p)); +#endif + util::get<1>(e).push_back(std::move(f)); + + merge_gids(util::get<2>(e), std::move(new_gids)); parcel_destinations_.insert(locality_id); } void enqueue_parcels(locality const& locality_id, std::vector&& parcels, - std::vector&& handlers) + std::vector&& handlers, new_gids_map && new_gids) { typedef pending_parcels_map::mapped_type mapped_type; @@ -521,24 +603,78 @@ namespace hpx { namespace parcelset HPX_ASSERT(parcels.size() == handlers.size()); mapped_type& e = pending_parcels_[locality_id]; - - for(std::size_t i = 0; i < parcels.size(); ++i) +#if defined(HPX_PARCELSET_PENDING_PARCELS_WORKAROUND) + if(!util::get<0>(e)) + { + util::get<0>(e) = boost::make_shared >(); + HPX_ASSERT(util::get<1>(e).empty()); +#if HPX_GCC_VERSION < 40700 + // GCC4.6 gets incredibly confused + std::swap( + *util::get<0>(e), + static_cast&>(parcels)); + std::swap( + util::get<1>(e), + static_cast&>(handlers)); +#else + std::swap(*util::get<0>(e), parcels); + std::swap(util::get<1>(e), handlers); +#endif + } +#else + if (util::get<0>(e).empty()) + { + HPX_ASSERT(util::get<1>(e).empty()); +#if HPX_GCC_VERSION < 40700 + // GCC4.6 gets incredibly confused + std::swap( + util::get<0>(e), + static_cast&>(parcels)); + std::swap( + util::get<1>(e), + static_cast&>(handlers)); +#else + std::swap(util::get<0>(e), parcels); + std::swap(util::get<1>(e), handlers); +#endif + } +#endif + else { - e.first.push_back(std::move(parcels[i])); - e.second.push_back(std::move(handlers[i])); +#if defined(HPX_PARCELSET_PENDING_PARCELS_WORKAROUND) + HPX_ASSERT(util::get<0>(e)->size() == util::get<1>(e).size()); + std::size_t new_size = util::get<0>(e)->size() + parcels.size(); + util::get<0>(e)->reserve(new_size); + + std::move(parcels.begin(), parcels.end(), + std::back_inserter(*util::get<0>(e))); +#else + HPX_ASSERT(util::get<0>(e).size() == util::get<1>(e).size()); + std::size_t new_size = util::get<0>(e).size() + parcels.size(); + util::get<0>(e).reserve(new_size); + + std::move(parcels.begin(), parcels.end(), + std::back_inserter(util::get<0>(e))); +#endif + util::get<1>(e).reserve(new_size); + std::move(handlers.begin(), handlers.end(), + std::back_inserter(util::get<1>(e))); } + merge_gids(util::get<2>(e), std::move(new_gids)); + parcel_destinations_.insert(locality_id); } - std::pair - dequeue_parcel(locality const& locality_id) + bool dequeue_parcels(locality const& locality_id, + std::vector& parcels, + std::vector& handlers, + new_gids_map & new_gids) { typedef pending_parcels_map::iterator iterator; - std::pair res; if (!enable_parcel_handling_) - return res; + return false; { boost::lock_guard l(mtx_); @@ -547,29 +683,38 @@ namespace hpx { namespace parcelset // do nothing if parcels have already been picked up by // another thread - if (it != pending_parcels_.end() && !it->second.first.empty()) +#if defined(HPX_PARCELSET_PENDING_PARCELS_WORKAROUND) + if (it != pending_parcels_.end() && !util::get<0>(it->second)->empty()) +#else + if (it != pending_parcels_.end() && !util::get<0>(it->second).empty()) +#endif { HPX_ASSERT(it->first == locality_id); - res.first = std::move(it->second.first.front()); - it->second.first.pop_front(); + HPX_ASSERT(handlers.size() == parcels.size()); +#if defined(HPX_PARCELSET_PENDING_PARCELS_WORKAROUND) + std::swap(parcels, *util::get<0>(it->second)); +#else + std::swap(parcels, util::get<0>(it->second)); +#endif + std::swap(handlers, util::get<1>(it->second)); - res.second = std::move(it->second.second.front()); - it->second.second.pop_front(); + std::swap(new_gids, util::get<2>(it->second)); - if(it->second.first.empty()) - parcel_destinations_.erase(locality_id); + HPX_ASSERT(!handlers.empty()); } else { - HPX_ASSERT(it->second.second.empty()); - return res; + HPX_ASSERT(util::get<1>(it->second).empty()); + return false; } + parcel_destinations_.erase(locality_id); - return res; + return true; } } + /////////////////////////////////////////////////////////////////////// bool trigger_sending_parcels(locality const& loc, bool background = false) @@ -627,39 +772,16 @@ namespace hpx { namespace parcelset // repeat until no more parcels are to be sent while (!hpx::is_stopped()) { - std::pair parcel_pair( - dequeue_parcel(locality_id) - ); - if (!parcel_pair.second) + std::vector parcels; + std::vector handlers; + new_gids_map new_gids; + + if(!dequeue_parcels(locality_id, parcels, handlers, new_gids)) break; // If one of the sending threads are in suspended state, we // need to force a new connection to avoid deadlocks. - bool force_connection = false; - { - boost::unique_lock l(sender_threads_mtx_, boost::try_to_lock); - if(l.owns_lock()) - { - std::vector threads; - threads.reserve(sender_threads_.size()); - std::copy(sender_threads_.begin(), sender_threads_.end(), - std::back_inserter(threads)); - l.unlock(); - - for (threads::thread_id_type const& t : threads) - { - if(threads::get_thread_state(t) != threads::suspended) - { - force_connection = true; - break; - } - } - } - else - { - force_connection = true; - } - } + bool force_connection = true; error_code ec; boost::shared_ptr sender_connection = @@ -667,25 +789,15 @@ namespace hpx { namespace parcelset if (!sender_connection) { - if (!force_connection && background) - { - // retry getting a connection, this time enforcing a - // new connection to be created (if needed) - sender_connection = get_connection(locality_id, true, ec); - } - - if (!sender_connection) - { - // give the parcels back to the queues for later - enqueue_parcel(locality_id, std::move(parcel_pair.first), - std::move(parcel_pair.second)); - - // We can safely return if no connection is available - // at this point. As soon as a connection becomes - // available it checks for pending parcels and sends - // those out. - return; - } + // give the parcels back to the queues for later + enqueue_parcels(locality_id, std::move(parcels), + std::move(handlers), std::move(new_gids)); + + // We can safely return if no connection is available + // at this point. As soon as a connection becomes + // available it checks for pending parcels and sends + // those out. + return; } threads::thread_id_type new_send_thread; @@ -697,36 +809,26 @@ namespace hpx { namespace parcelset new_send_thread = hpx::applier::register_thread_nullary( hpx::util::bind( - hpx::util::one_shot(&parcelport_impl::send_pending_parcels) + hpx::util::one_shot(&parcelport_impl + ::send_pending_parcels) , this , locality_id , sender_connection - , std::move(parcel_pair.first) - , std::move(parcel_pair.second) + , std::move(parcels) + , std::move(handlers) + , std::move(new_gids) ) , "parcelport_impl::send_pending_parcels" - , threads::suspended, true, threads::thread_priority_boost, + , threads::pending, true, threads::thread_priority_boost, thread_num, threads::thread_stacksize_default ); - { - boost::lock_guard l(sender_threads_mtx_); - HPX_ASSERT(new_send_thread != threads::invalid_thread_id); - sender_threads_.insert(new_send_thread); - } - threads::set_thread_state(new_send_thread, threads::pending); } else { - new_send_thread = threads::get_self_id(); - if(new_send_thread != threads::invalid_thread_id) - { - boost::lock_guard l(sender_threads_mtx_); - sender_threads_.insert(new_send_thread); - } send_pending_parcels( locality_id, - sender_connection, std::move(parcel_pair.first), - std::move(parcel_pair.second)); + sender_connection, std::move(parcels), + std::move(handlers), std::move(new_gids)); } // We yield here for a short amount of time to give another @@ -746,24 +848,28 @@ namespace hpx { namespace parcelset #if defined(HPX_TRACK_STATE_OF_OUTGOING_TCP_CONNECTION) client_connection->set_state(parcelport_connection::state_scheduled_thread); #endif + if (!ec) + { + // Give this connection back to the cache as it's not + // needed anymore. + connection_cache_.reclaim(locality_id, sender_connection); + } + else + { + // remove this connection from cache + connection_cache_.clear(locality_id, sender_connection); + } { boost::lock_guard l(mtx_); HPX_ASSERT(locality_id == sender_connection->destination()); - if (!ec) - { - // Give this connection back to the cache as it's not - // needed anymore. - connection_cache_.reclaim(locality_id, sender_connection); - } - else - { - // remove this connection from cache - connection_cache_.clear(locality_id, sender_connection); - } - pending_parcels_map::iterator it = pending_parcels_.find(locality_id); - if (it == pending_parcels_.end() || it->second.first.empty()) +#if defined(HPX_PARCELSET_PENDING_PARCELS_WORKAROUND) + if (it == pending_parcels_.end() || + (util::get<0>(it->second) && util::get<0>(it->second)->empty())) +#else + if (it == pending_parcels_.end() || util::get<0>(it->second).empty()) +#endif return; } @@ -775,8 +881,9 @@ namespace hpx { namespace parcelset void send_pending_parcels( parcelset::locality const & parcel_locality_id, boost::shared_ptr sender_connection, - parcel p, - write_handler_type&& handler) + std::vector&& parcels, + std::vector&& handlers, + new_gids_map new_gids) { // If we are stopped already, discard the remaining pending parcels if (hpx::is_stopped()) return; @@ -791,30 +898,59 @@ namespace hpx { namespace parcelset sender_connection->verify(parcel_locality_id); #endif // encode the parcels - encode_parcels(&p, - std::size_t(-1), sender_connection->buffer_, - archive_flags_, - this->get_max_outbound_message_size()); - - ++operations_in_flight_; - // send all of the parcels - sender_connection->async_write( - handler, - util::bind(&parcelport_impl::send_pending_parcels_trampoline, - this, util::placeholders::_1, util::placeholders::_2, - util::placeholders::_3), - std::move(p)); - - do_background_work_impl(); - threads::thread_id_type this_thread = threads::get_self_id(); - if(this_thread != threads::invalid_thread_id) + std::size_t num_parcels = encode_parcels(&parcels[0], + parcels.size(), sender_connection->buffer_, + archive_flags_, + this->get_max_outbound_message_size(), + &new_gids); + + using hpx::parcelset::detail::call_for_each; + using namespace hpx::util::placeholders; + if (num_parcels == parcels.size()) + { + ++operations_in_flight_; + // send all of the parcels + sender_connection->async_write( + call_for_each(std::move(handlers), std::move(parcels)), + util::bind(&parcelport_impl::send_pending_parcels_trampoline, + this, _1, _2, _3)); + } + else { - boost::lock_guard l(sender_threads_mtx_); - std::set::iterator it - = sender_threads_.find(this_thread); - HPX_ASSERT(it != sender_threads_.end()); - sender_threads_.erase(it); + ++operations_in_flight_; + HPX_ASSERT(num_parcels < parcels.size()); + + std::vector handled_handlers; + handled_handlers.reserve(num_parcels); + + std::move(handlers.begin(), handlers.begin()+num_parcels, + std::back_inserter(handled_handlers)); + + std::vector handled_parcels; + handled_parcels.reserve(num_parcels); + + std::move(parcels.begin(), parcels.begin()+num_parcels, + std::back_inserter(handled_parcels)); + + // send only part of the parcels + sender_connection->async_write( + call_for_each( + std::move(handled_handlers), std::move(handled_parcels)), + util::bind(&parcelport_impl::send_pending_parcels_trampoline, + this, _1, _2, _3)); + + // give back unhandled parcels + parcels.erase(parcels.begin(), parcels.begin()+num_parcels); + handlers.erase(handlers.begin(), handlers.begin()+num_parcels); + + enqueue_parcels(parcel_locality_id, std::move(parcels), + std::move(handlers), std::move(new_gids)); } + + std::size_t num_thread(0); + if(threads::get_self_ptr()) + num_thread = hpx::get_worker_thread_num(); + do_background_work_impl(num_thread); } protected: @@ -825,8 +961,6 @@ namespace hpx { namespace parcelset util::connection_cache connection_cache_; typedef hpx::lcos::local::spinlock mutex_type; - mutex_type sender_threads_mtx_; - std::set sender_threads_; int archive_flags_; boost::atomic operations_in_flight_; diff --git a/hpx/runtime/serialization/access.hpp b/hpx/runtime/serialization/access.hpp index 78d3d1daad8f..4aeb9488d38e 100644 --- a/hpx/runtime/serialization/access.hpp +++ b/hpx/runtime/serialization/access.hpp @@ -43,7 +43,8 @@ namespace hpx { namespace serialization t.serialize(ar, 0); } - static void call(hpx::serialization::output_archive& ar, const T& t, unsigned) + static void call(hpx::serialization::output_archive& ar, + const T& t, unsigned) { t.serialize(ar, 0); } diff --git a/hpx/runtime/serialization/container.hpp b/hpx/runtime/serialization/container.hpp index 293a87eea52e..9d48cd6853f8 100644 --- a/hpx/runtime/serialization/container.hpp +++ b/hpx/runtime/serialization/container.hpp @@ -7,6 +7,7 @@ #ifndef HPX_SERIALIZATION_CONTAINER_HPP #define HPX_SERIALIZATION_CONTAINER_HPP +#include #include #include #include @@ -18,6 +19,9 @@ namespace hpx { namespace serialization virtual ~erased_output_container() {} virtual bool is_saving() const { return false; } + virtual bool is_future_awaiting() const = 0; + virtual void await_future( + hpx::lcos::detail::future_data_refcnt_base & future_data) = 0; virtual void set_filter(binary_filter* filter) = 0; virtual void save_binary(void const* address, std::size_t count) = 0; virtual void save_binary_chunk(void const* address, std::size_t count) = 0; diff --git a/hpx/runtime/serialization/detail/future_await_container.hpp b/hpx/runtime/serialization/detail/future_await_container.hpp new file mode 100644 index 000000000000..2b9345686ab1 --- /dev/null +++ b/hpx/runtime/serialization/detail/future_await_container.hpp @@ -0,0 +1,136 @@ +// Copyright (c) 2015 Thomas Heller +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#if !defined(HPX_SERIALIZATION_FUTURE_AWAIT_CONTAINER_HPP) +#define HPX_SERIALIZATION_FUTURE_AWAIT_CONTAINER_HPP + +// This 'container' is used to gather futures that need to become +// ready before the actual serialization process can be started + +#include +#include +#include + +#include +#include + +#include + +namespace hpx +{ + bool is_starting(); +} + +namespace hpx { namespace serialization { namespace detail +{ + template + struct access_data; + + class future_await_container + : public boost::enable_shared_from_this + { + typedef hpx::lcos::local::spinlock mutex_type; + typedef std::list new_gids_type; + typedef std::map new_gids_map; + public: + future_await_container() + : done_(false) + , num_futures_(0) + , triggered_futures_(0) + {} + + std::size_t size() const { return 0; } + void resize(std::size_t size) { } + + void trigger() + { + boost::lock_guard l(mtx_); + ++triggered_futures_; + if(done_ && num_futures_ == triggered_futures_) + { + promise_.set_value(); + } + } + + void await_future(hpx::lcos::detail::future_data_refcnt_base & future_data) + { + { + boost::lock_guard l(mtx_); + ++num_futures_; + } + future_data.set_on_completed( + [this]() + { + trigger(); + } + ); + } + + bool has_futures() + { + if(num_futures_ == 0) + { + promise_.set_value(); + } + return num_futures_ > 0; + } + + template + void operator()(F f) + { + { + boost::lock_guard l(mtx_); + done_ = true; + if(num_futures_ == triggered_futures_) + { + promise_.set_value(); + } + } + + hpx::lcos::local::dataflow(//hpx::launch::sync, + util::unwrapped(std::move(f)) + , promise_.get_future()); + } + + new_gids_map new_gids_; + + private: + mutex_type mtx_; + bool done_; + std::size_t num_futures_; + std::size_t triggered_futures_; + + hpx::lcos::local::promise promise_; + }; + + template <> + struct access_data + { + static bool is_saving() { return false; } + static bool is_future_awaiting() { return true; } + + static void await_future( + future_await_container& cont + , hpx::lcos::detail::future_data_refcnt_base & future_data) + { + cont.await_future(future_data); + } + + static void + write(future_await_container& cont, std::size_t count, + std::size_t current, void const* address) + { + } + + static bool + flush(binary_filter* filter, future_await_container& cont, + std::size_t current, std::size_t size, std::size_t written) + { + return true; + } + }; +}}} + +#endif diff --git a/hpx/runtime/serialization/detail/pointer.hpp b/hpx/runtime/serialization/detail/pointer.hpp index c28076863c63..8fc526b95065 100644 --- a/hpx/runtime/serialization/detail/pointer.hpp +++ b/hpx/runtime/serialization/detail/pointer.hpp @@ -184,7 +184,8 @@ namespace hpx { namespace serialization Pointer temp = detail::pointer_input_dispatcher< Pointer>::type::call(ar); register_pointer(ar, pos, ptr_helper_ptr( - new detail::erase_ptr_helper(std::move(temp), ptr))); + new detail::erase_ptr_helper + (std::move(temp), ptr))); } else { diff --git a/hpx/runtime/serialization/detail/polymorphic_nonintrusive_factory.hpp b/hpx/runtime/serialization/detail/polymorphic_nonintrusive_factory.hpp index 50315c9a27b0..713b3cf837ba 100644 --- a/hpx/runtime/serialization/detail/polymorphic_nonintrusive_factory.hpp +++ b/hpx/runtime/serialization/detail/polymorphic_nonintrusive_factory.hpp @@ -102,7 +102,8 @@ namespace hpx { namespace serialization { namespace detail return factory.get(); } - void register_class(const std::type_info& typeinfo, const std::string& class_name, + void register_class(const std::type_info& typeinfo, + const std::string& class_name, const function_bunch_type& bunch) { if(!typeinfo.name() && std::string(typeinfo.name()).empty()) diff --git a/hpx/runtime/serialization/detail/size_gatherer_container.hpp b/hpx/runtime/serialization/detail/size_gatherer_container.hpp index f75fe36dfc95..8608fc994330 100644 --- a/hpx/runtime/serialization/detail/size_gatherer_container.hpp +++ b/hpx/runtime/serialization/detail/size_gatherer_container.hpp @@ -8,6 +8,7 @@ // This 'container' is used to gather the required archive size for a given // type before it is serialized. +#include namespace hpx { namespace serialization { namespace detail { @@ -30,6 +31,12 @@ namespace hpx { namespace serialization { namespace detail struct access_data { static bool is_saving() { return false; } + static bool is_future_awaiting() { return false; } + + static void await_future( + size_gatherer_container& cont + , hpx::lcos::detail::future_data_refcnt_base & future_data) + {} static void write(size_gatherer_container& cont, std::size_t count, diff --git a/hpx/runtime/serialization/input_archive.hpp b/hpx/runtime/serialization/input_archive.hpp index df79af299df3..cafc416948bc 100644 --- a/hpx/runtime/serialization/input_archive.hpp +++ b/hpx/runtime/serialization/input_archive.hpp @@ -246,7 +246,8 @@ namespace hpx { namespace serialization }; BOOST_FORCEINLINE - void register_pointer(input_archive & ar, boost::uint64_t pos, detail::ptr_helper_ptr helper) + void register_pointer(input_archive & ar, boost::uint64_t pos, + detail::ptr_helper_ptr helper) { ar.register_pointer(pos, std::move(helper)); } diff --git a/hpx/runtime/serialization/input_container.hpp b/hpx/runtime/serialization/input_container.hpp index aa39d9e5de5c..a4aa7a8261c3 100644 --- a/hpx/runtime/serialization/input_container.hpp +++ b/hpx/runtime/serialization/input_container.hpp @@ -106,7 +106,8 @@ namespace hpx { namespace serialization current_chunk_size_ += count; // make sure we switch to the next serialization_chunk if necessary std::size_t current_chunk_size = get_chunk_size(current_chunk_); - if (current_chunk_size != 0 && current_chunk_size_ >= current_chunk_size) + if (current_chunk_size != 0 && current_chunk_size_ >= + current_chunk_size) { // raise an error if we read past the serialization_chunk if (current_chunk_size_ > current_chunk_size) @@ -127,7 +128,8 @@ namespace hpx { namespace serialization { HPX_ASSERT((boost::int64_t)count >= 0); - if (filter_.get() || chunks_ == 0 || count < HPX_ZERO_COPY_SERIALIZATION_THRESHOLD) { + if (filter_.get() || chunks_ == 0 || + count < HPX_ZERO_COPY_SERIALIZATION_THRESHOLD) { // fall back to serialization_chunk-less archive this->input_container::load_binary(address, count); } @@ -143,7 +145,8 @@ namespace hpx { namespace serialization return; } - // unfortunately we can't implement a zero copy policy on the receiving end + // unfortunately we can't implement a zero copy policy on + // the receiving end // as the memory was already allocated by the serialization code std::memcpy(address, get_chunk_data(current_chunk_).pos_, count); ++current_chunk_; diff --git a/hpx/runtime/serialization/map.hpp b/hpx/runtime/serialization/map.hpp index 12cb95d708c6..422e9ba8053f 100644 --- a/hpx/runtime/serialization/map.hpp +++ b/hpx/runtime/serialization/map.hpp @@ -33,7 +33,8 @@ namespace hpx namespace detail { template - void load_pair_impl(input_archive& ar, std::pair& t, boost::mpl::false_) + void load_pair_impl(input_archive& ar, std::pair& t, + boost::mpl::false_) { ar >> const_cast< typename boost::add_reference< @@ -43,7 +44,8 @@ namespace hpx } template - void load_pair_impl(input_archive& ar, std::pair& t, boost::mpl::true_) + void load_pair_impl(input_archive& ar, std::pair& t, + boost::mpl::true_) { if (!has_array_optimization(ar)) load_pair_impl(ar, t, boost::mpl::false_()); @@ -52,14 +54,16 @@ namespace hpx } template - void save_pair_impl(output_archive& ar, std::pair& t, boost::mpl::false_) + void save_pair_impl(output_archive& ar, std::pair& t, + boost::mpl::false_) { ar << t.first; ar << t.second; } template - void save_pair_impl(output_archive& ar, std::pair& t, boost::mpl::true_) + void save_pair_impl(output_archive& ar, std::pair& t, + boost::mpl::true_) { if (!has_array_optimization(ar)) save_pair_impl(ar, t, boost::mpl::false_()); @@ -104,7 +108,8 @@ namespace hpx } template - void serialize(output_archive& ar, std::map& t, unsigned) + void serialize(output_archive& ar, + std::map& t, unsigned) { typedef typename std::map::value_type value_type; diff --git a/hpx/runtime/serialization/multi_array.hpp b/hpx/runtime/serialization/multi_array.hpp index 3387eb64dedb..2af5e0bea844 100644 --- a/hpx/runtime/serialization/multi_array.hpp +++ b/hpx/runtime/serialization/multi_array.hpp @@ -22,7 +22,8 @@ namespace hpx { namespace serialization } template - void save(output_archive& ar, const boost::multi_array& marray, unsigned) + void save(output_archive& ar, const boost::multi_array& marray, unsigned) { ar & make_array(marray.shape(), marray.num_dimensions()); ar & make_array(marray.data(), marray.num_elements()); diff --git a/hpx/runtime/serialization/output_archive.hpp b/hpx/runtime/serialization/output_archive.hpp index 07bd99facb8e..319b412fb620 100644 --- a/hpx/runtime/serialization/output_archive.hpp +++ b/hpx/runtime/serialization/output_archive.hpp @@ -22,6 +22,10 @@ #include +namespace hpx { namespace naming { + struct HPX_EXPORT gid_type; +}} + namespace hpx { namespace serialization { struct HPX_EXPORT output_archive @@ -30,15 +34,20 @@ namespace hpx { namespace serialization typedef basic_archive base_type; typedef std::map pointer_tracker; + typedef std::list new_gids_type; + typedef std::map new_gids_map; + template output_archive(Container & buffer, boost::uint32_t flags = 0U, boost::uint32_t dest_locality_id = ~0U, std::vector* chunks = 0, - binary_filter* filter = 0) + binary_filter* filter = 0, + new_gids_map* new_gids = 0) : base_type(flags) , buffer_(new output_container(buffer, chunks, filter)) , dest_locality_id_(dest_locality_id) + , new_gids_(new_gids) { // endianness needs to be saves separately as it is needed to // properly interpret the flags @@ -66,6 +75,20 @@ namespace hpx { namespace serialization return buffer_->is_saving(); } + bool is_future_awaiting() const + { + return buffer_->is_future_awaiting(); + } + + template + void await_future(Future const & f) + { + if(f.is_ready()) return; + + buffer_->await_future( + *hpx::traits::future_access::get_shared_state(f)); + } + template void invoke_impl(T const & t) { @@ -233,10 +256,15 @@ namespace hpx { namespace serialization return size_; } + void add_gid(naming::gid_type const & gid, naming::gid_type const & splitted_gid); + + naming::gid_type get_new_gid(naming::gid_type const & gid); + private: std::unique_ptr buffer_; pointer_tracker pointer_tracker_; boost::uint32_t dest_locality_id_; + new_gids_map * new_gids_; }; BOOST_FORCEINLINE diff --git a/hpx/runtime/serialization/output_container.hpp b/hpx/runtime/serialization/output_container.hpp index a510514337b6..11c901da62fb 100644 --- a/hpx/runtime/serialization/output_container.hpp +++ b/hpx/runtime/serialization/output_container.hpp @@ -9,6 +9,7 @@ #define HPX_SERIALIZATION_OUTPUT_CONTAINER_HPP #include +#include #include #include #include @@ -25,6 +26,12 @@ namespace hpx { namespace serialization struct access_data { static bool is_saving() { return true; } + static bool is_future_awaiting() { return false; } + + static void await_future( + Container& cont + , hpx::lcos::detail::future_data_refcnt_base & future_data) + {} static void write(Container& cont, std::size_t count, std::size_t current, void const* address) @@ -136,6 +143,17 @@ namespace hpx { namespace serialization return detail::access_data::is_saving(); } + bool is_future_awaiting() const + { + return detail::access_data::is_future_awaiting(); + } + + void await_future( + hpx::lcos::detail::future_data_refcnt_base & future_data) + { + return detail::access_data::await_future(cont_, future_data); + } + void set_filter(binary_filter* filter) // override { HPX_ASSERT(0 == filter_); @@ -193,7 +211,8 @@ namespace hpx { namespace serialization void save_binary_chunk(void const* address, std::size_t count) // override { - if (filter_ || chunks_ == 0 || count < HPX_ZERO_COPY_SERIALIZATION_THRESHOLD) { + if (filter_ || chunks_ == 0 || count < HPX_ZERO_COPY_SERIALIZATION_THRESHOLD) + { // fall back to serialization_chunk-less archive this->output_container::save_binary(address, count); } diff --git a/hpx/runtime/serialization/serialization_chunk.hpp b/hpx/runtime/serialization/serialization_chunk.hpp index ed94367b26c4..b9d45d4a0ac1 100644 --- a/hpx/runtime/serialization/serialization_chunk.hpp +++ b/hpx/runtime/serialization/serialization_chunk.hpp @@ -38,7 +38,8 @@ namespace hpx { namespace serialization struct serialization_chunk { chunk_data data_; // index or pointer - std::size_t size_; // size of the serialization_chunk starting at index_/pos_ + std::size_t size_; + // size of the serialization_chunk starting at index_/pos_ boost::uint8_t type_; // chunk_type }; diff --git a/hpx/runtime/serialization/serialization_fwd.hpp b/hpx/runtime/serialization/serialization_fwd.hpp index b4eb58935e80..a235d3ed241d 100644 --- a/hpx/runtime/serialization/serialization_fwd.hpp +++ b/hpx/runtime/serialization/serialization_fwd.hpp @@ -10,7 +10,8 @@ #include #include -#if defined(HPX_INTEL_VERSION) && ((__GNUC__ == 4 && __GNUC_MINOR__ == 4) || HPX_INTEL_VERSION < 1400) +#if defined(HPX_INTEL_VERSION) && ((__GNUC__ == 4 && __GNUC_MINOR__ == 4) \ + || HPX_INTEL_VERSION < 1400) #include #else #include @@ -21,7 +22,8 @@ namespace hpx { namespace serialization namespace detail { struct ptr_helper; -#if defined(HPX_INTEL_VERSION) && ((__GNUC__ == 4 && __GNUC_MINOR__ == 4) || HPX_INTEL_VERSION < 1400) +#if defined(HPX_INTEL_VERSION) && ((__GNUC__ == 4 && __GNUC_MINOR__ == 4) \ + || HPX_INTEL_VERSION < 1400) typedef boost::shared_ptr ptr_helper_ptr; #else typedef std::unique_ptr ptr_helper_ptr; @@ -32,7 +34,8 @@ namespace hpx { namespace serialization struct output_archive; BOOST_FORCEINLINE - void register_pointer(input_archive & ar, boost::uint64_t pos, detail::ptr_helper_ptr helper); + void register_pointer(input_archive & ar, boost::uint64_t pos, + detail::ptr_helper_ptr helper); template Helper & tracked_pointer(input_archive & ar, boost::uint64_t pos); diff --git a/hpx/runtime/serialization/serialize_buffer.hpp b/hpx/runtime/serialization/serialize_buffer.hpp index b70b85761f36..4f4c41881810 100644 --- a/hpx/runtime/serialization/serialize_buffer.hpp +++ b/hpx/runtime/serialization/serialize_buffer.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2013-2014 Hartmut Kaiser +// Copyright (c) 2015 Andreas Schaefer // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -20,13 +21,8 @@ namespace hpx { namespace serialization { - namespace detail - { - struct serialize_buffer_no_allocator {}; - } - /////////////////////////////////////////////////////////////////////////// - template + template > class serialize_buffer { private: @@ -57,6 +53,18 @@ namespace hpx { namespace serialization , alloc_(alloc) {} + explicit serialize_buffer(std::size_t size, + allocator_type const& alloc = allocator_type()) + : data_() + , size_(size) + , alloc_(alloc) + { + using util::placeholders::_1; + data_.reset(alloc_.allocate(size), + util::bind(&serialize_buffer::deleter, + _1, alloc_, size_)); + } + // The default mode is 'copy' which is consistent with the constructor // taking a T const * below. serialize_buffer (T* data, std::size_t size, init_mode mode = copy, @@ -193,6 +201,7 @@ namespace hpx { namespace serialization , alloc_(alloc) { if (mode == copy) { + using util::placeholders::_1; data_.reset(alloc_.allocate(size), util::bind(&serialize_buffer::deleter, _1, alloc_, size_)); @@ -216,6 +225,9 @@ namespace hpx { namespace serialization T* data() { return data_.get(); } T const* data() const { return data_.get(); } + T* begin() { return data(); } + T* end() { return data() + size_; } + T& operator[](std::size_t idx) { return data_[idx]; } T operator[](std::size_t idx) const { return data_[idx]; } @@ -270,182 +282,6 @@ namespace hpx { namespace serialization std::size_t size_; Allocator alloc_; }; - - /////////////////////////////////////////////////////////////////////////// - template - class serialize_buffer - { - private: - static void no_deleter(T*) {} - - static void array_delete(T * x) - { - delete [] x; - } - - public: - enum init_mode - { - copy = 0, // constructor copies data - reference = 1, // constructor does not copy data and does not - // manage the lifetime of it - take = 2 // constructor does not copy data but does take - // ownership and manages the lifetime of it - }; - - typedef T value_type; - - serialize_buffer() - : size_(0) - {} - - // The default mode is 'copy' which is consistent with the constructor - // taking a T const * below. - serialize_buffer (T* data, std::size_t size, init_mode mode = copy) - : data_(), size_(size) - { - if (mode == copy) { - data_ = boost::shared_array(data, - &serialize_buffer::array_delete); - if (size != 0) - std::copy(data, data + size, data_.get()); - } - else if (mode == reference) { - data_ = boost::shared_array(data, - &serialize_buffer::no_deleter); - } - else { - // take ownership - data_ = boost::shared_array(data, - &serialize_buffer::array_delete); - } - } - - template - serialize_buffer (T* data, std::size_t size, init_mode mode, - Deleter const& deleter) - : data_(), size_(size) - { - if (mode == copy) { - data_.reset(new T[size], deleter); - if (size != 0) - std::copy(data, data + size, data_.get()); - } - else { - // reference or take ownership, behavior is defined by deleter - data_ = boost::shared_array(data, deleter); - } - } - - template - serialize_buffer (T const* data, std::size_t size, init_mode mode, - Deleter const& deleter) - : data_(), size_(size) - { - if (mode == copy) { - data_.reset(new T[size], deleter); - if (size != 0) - std::copy(data, data + size, data_.get()); - } - else if (mode == reference) { - data_ = boost::shared_array(const_cast(data), deleter); - } - else { - // can't take ownership of const buffer - HPX_THROW_EXCEPTION(bad_parameter, - "serialize_buffer::serialize_buffer", - "can't take ownership of const data"); - } - } - - // same set of constructors, but taking const data - serialize_buffer (T const* data, std::size_t size, - init_mode mode = copy) - : data_(), size_(size) - { - if (mode == copy) { - data_ = boost::shared_array(new T[size], - &serialize_buffer::array_delete); - if (size != 0) - std::copy(data, data + size, data_.get()); - } - else if (mode == reference) { - data_ = boost::shared_array( - const_cast(data), - &serialize_buffer::no_deleter); - } - else { - // can't take ownership of const buffer - HPX_THROW_EXCEPTION(bad_parameter, - "serialize_buffer::serialize_buffer", - "can't take ownership of const data"); - } - } - - template - serialize_buffer (T const* data, std::size_t size, - Deleter const& deleter) - : data_(), size_(size) - { - // create from const data implies 'copy' mode - data_.reset(new T[size], deleter); - if (size != 0) - std::copy(data, data + size, data_.get()); - } - - // accessors enabling data access - T* data() { return data_.get(); } - T const* data() const { return data_.get(); } - - T& operator[](std::size_t idx) { return data_[idx]; } - T operator[](std::size_t idx) const { return data_[idx]; } - - boost::shared_array data_array() const { return data_; } - - std::size_t size() const { return size_; } - - private: - // serialization support - friend class hpx::serialization::access; - - /////////////////////////////////////////////////////////////////////// - template - void save(Archive& ar, const unsigned int version) const - { - ar << size_; //-V128 - - if (size_ != 0) - { - ar << hpx::serialization::make_array(data_.get(), size_); - } - } - - /////////////////////////////////////////////////////////////////////// - template - void load(Archive& ar, const unsigned int version) - { - ar >> size_; //-V128 - data_.reset(new T[size_]); - - if (size_ != 0) - { - ar >> hpx::serialization::make_array(data_.get(), size_); - } - } - - HPX_SERIALIZATION_SPLIT_MEMBER() - - // this is needed for util::any - friend bool - operator==(serialize_buffer const& rhs, serialize_buffer const& lhs) - { - return rhs.data_.get() == lhs.data_.get() && rhs.size_ == lhs.size_; - } - - private: - boost::shared_array data_; - std::size_t size_; - }; }} namespace hpx { namespace traits diff --git a/hpx/runtime/serialization/string.hpp b/hpx/runtime/serialization/string.hpp index f57ba4a2c6f7..8fc948a2c866 100644 --- a/hpx/runtime/serialization/string.hpp +++ b/hpx/runtime/serialization/string.hpp @@ -14,7 +14,8 @@ namespace hpx { namespace serialization { // load string template - void serialize(input_archive & ar, std::basic_string & s, unsigned) + void serialize(input_archive & ar, std::basic_string & s, unsigned) { typedef std::basic_string string_type; typedef typename string_type::size_type size_type; @@ -29,7 +30,8 @@ namespace hpx { namespace serialization // save string template - void serialize(output_archive & ar, std::basic_string & s, unsigned) + void serialize(output_archive & ar, std::basic_string & s, unsigned) { ar << s.size(); //-V128 save_binary(ar, s.data(), s.size() * sizeof(Char)); diff --git a/hpx/runtime/serialization/variant.hpp b/hpx/runtime/serialization/variant.hpp index ba07dbfdcf6f..cd30f49b5b04 100644 --- a/hpx/runtime/serialization/variant.hpp +++ b/hpx/runtime/serialization/variant.hpp @@ -114,7 +114,8 @@ namespace hpx { namespace serialization variant_impl::load(ar, which, v); } - HPX_SERIALIZATION_SPLIT_FREE_TEMPLATE((template ), + HPX_SERIALIZATION_SPLIT_FREE_TEMPLATE((template + ), (boost::variant)); } // namespace serialization diff --git a/hpx/runtime/serialization/vector.hpp b/hpx/runtime/serialization/vector.hpp index 00809e1a5b50..5c1b28c8c771 100644 --- a/hpx/runtime/serialization/vector.hpp +++ b/hpx/runtime/serialization/vector.hpp @@ -15,7 +15,8 @@ namespace hpx { namespace serialization { // load vector template - void load_impl(input_archive & ar, std::vector & vs, boost::mpl::false_) + void load_impl(input_archive & ar, std::vector & vs, + boost::mpl::false_) { // normal load ... typedef typename std::vector::size_type size_type; @@ -84,7 +85,8 @@ namespace hpx { namespace serialization // save vector template - void save_impl(output_archive & ar, std::vector & vs, boost::mpl::false_) + void save_impl(output_archive & ar, std::vector & vs, + boost::mpl::false_) { // normal save ... typedef typename std::vector::value_type value_type; diff --git a/hpx/runtime/threads/detail/create_thread.hpp b/hpx/runtime/threads/detail/create_thread.hpp index 2c4ae9fe0792..5231c197a623 100644 --- a/hpx/runtime/threads/detail/create_thread.hpp +++ b/hpx/runtime/threads/detail/create_thread.hpp @@ -73,6 +73,7 @@ namespace hpx { namespace threads { namespace detail } // create the new thread + std::size_t num_thread = data.num_os_thread; scheduler->create_thread(data, &id, initial_state, run_now, ec, data.num_os_thread); @@ -85,7 +86,7 @@ namespace hpx { namespace threads { namespace detail << ")"; // potentially wake up waiting thread - scheduler->do_some_work(data.num_os_thread); + scheduler->do_some_work(num_thread); } }}} diff --git a/hpx/runtime/threads/detail/create_work.hpp b/hpx/runtime/threads/detail/create_work.hpp index dbdabb5ddc05..87a880a07477 100644 --- a/hpx/runtime/threads/detail/create_work.hpp +++ b/hpx/runtime/threads/detail/create_work.hpp @@ -86,11 +86,13 @@ namespace hpx { namespace threads { namespace detail thread_priority_boost == data.priority) { // For critical priority threads, create the thread immediately. - scheduler->create_thread(data, 0, initial_state, true, ec, data.num_os_thread); + scheduler->create_thread(data, 0, initial_state, true, ec, + data.num_os_thread); } else { // Create a task description for the new thread. - scheduler->create_thread(data, 0, initial_state, false, ec, data.num_os_thread); + scheduler->create_thread(data, 0, initial_state, false, ec, + data.num_os_thread); } } }}} diff --git a/hpx/runtime/threads/detail/periodic_maintenance.hpp b/hpx/runtime/threads/detail/periodic_maintenance.hpp index 0fc286fecdcc..eef46ecb27ec 100644 --- a/hpx/runtime/threads/detail/periodic_maintenance.hpp +++ b/hpx/runtime/threads/detail/periodic_maintenance.hpp @@ -53,7 +53,8 @@ namespace hpx { namespace threads { namespace detail get_thread_pool("timer-thread")->get_io_service(), boost::chrono::milliseconds(1000)); - void (*handler)(SchedulingPolicy&, boost::atomic&, boost::mpl::true_) = + void (*handler)(SchedulingPolicy&, boost::atomic&, + boost::mpl::true_) = &periodic_maintenance_handler; t.async_wait(boost::bind(handler, boost::ref(scheduler), @@ -83,7 +84,8 @@ namespace hpx { namespace threads { namespace detail get_thread_pool("io-thread")->get_io_service(), boost::chrono::milliseconds(1000)); - void (*handler)(SchedulingPolicy&, boost::atomic&, boost::mpl::true_) = + void (*handler)(SchedulingPolicy&, boost::atomic&, + boost::mpl::true_) = &periodic_maintenance_handler; t.async_wait(util::bind(handler, boost::ref(scheduler), diff --git a/hpx/runtime/threads/detail/scheduling_loop.hpp b/hpx/runtime/threads/detail/scheduling_loop.hpp index d12a1265851a..4f11b6f49e48 100644 --- a/hpx/runtime/threads/detail/scheduling_loop.hpp +++ b/hpx/runtime/threads/detail/scheduling_loop.hpp @@ -19,6 +19,10 @@ #include +#if defined(HPX_HAVE_APEX) +#include +#endif + namespace hpx { namespace threads { namespace detail { /////////////////////////////////////////////////////////////////////// @@ -289,7 +293,19 @@ namespace hpx { namespace threads { namespace detail // Record time elapsed in thread changing state // and add to aggregate execution time. exec_time_wrapper exec_time_collector(idle_rate); +#if defined(HPX_HAVE_APEX) + util::apex_wrapper apex_profiler(thrd->get_description()); +#endif thrd_stat = (*thrd)(); +#if defined(HPX_HAVE_APEX) + thread_state prev_state = thrd_stat.get_previous(); + thread_state_enum prev_state_enum = prev_state; + if(prev_state_enum == terminated) { + apex_profiler.stop(); + } else { + apex_profiler.yield(); + } +#endif } #ifdef HPX_HAVE_THREAD_CUMULATIVE_COUNTS @@ -334,7 +350,8 @@ namespace hpx { namespace threads { namespace detail // schedule this thread again, make sure it ends up at // the end of the queue - scheduler.SchedulingPolicy::schedule_thread_last(thrd, num_thread); + scheduler.SchedulingPolicy::schedule_thread_last(thrd, + num_thread); scheduler.SchedulingPolicy::do_some_work(num_thread); } } diff --git a/hpx/runtime/threads/detail/set_thread_state.hpp b/hpx/runtime/threads/detail/set_thread_state.hpp index d38e376b83fb..3ed063a8efeb 100644 --- a/hpx/runtime/threads/detail/set_thread_state.hpp +++ b/hpx/runtime/threads/detail/set_thread_state.hpp @@ -59,7 +59,8 @@ namespace hpx { namespace threads { namespace detail // just retry, set_state will create new thread if target is still active error_code ec(lightweight); // do not throw - detail::set_thread_state(thrd, newstate, newstate_ex, priority, std::size_t(-1), ec); + detail::set_thread_state(thrd, newstate, newstate_ex, priority, + std::size_t(-1), ec); return terminated; } @@ -88,7 +89,8 @@ namespace hpx { namespace threads { namespace detail if (!thrd) { if (&ec != &throws) ec = make_success_code(); - return thread_state(terminated); // this thread has already been terminated + return thread_state(terminated); + // this thread has already been terminated } thread_state previous_state; @@ -211,7 +213,8 @@ namespace hpx { namespace threads { namespace detail if (new_state == pending) { // REVIEW: Passing a specific target thread may interfere with the // round robin queuing. - thrd->get_scheduler_base()->schedule_thread(thrd.get(), thread_num, priority); + thrd->get_scheduler_base()->schedule_thread(thrd.get(), + thread_num, priority); thrd->get_scheduler_base()->do_some_work(thread_num); } diff --git a/hpx/runtime/threads/executors/thread_pool_executors.hpp b/hpx/runtime/threads/executors/thread_pool_executors.hpp index 87da5da08df6..1335334e1321 100644 --- a/hpx/runtime/threads/executors/thread_pool_executors.hpp +++ b/hpx/runtime/threads/executors/thread_pool_executors.hpp @@ -138,6 +138,16 @@ namespace hpx { namespace threads { namespace executors }; #endif +#if defined(HPX_HAVE_THROTTLE_SCHEDULER) + struct HPX_EXPORT throttle_queue_executor : public scheduled_executor + { + throttle_queue_executor(); + + explicit throttle_queue_executor(std::size_t max_punits, + std::size_t min_punits = 1); + }; +#endif + struct HPX_EXPORT local_priority_queue_executor : public scheduled_executor { local_priority_queue_executor(); diff --git a/hpx/runtime/threads/policies/callback_notifier.hpp b/hpx/runtime/threads/policies/callback_notifier.hpp index 8f0c43e16388..3a1cd49a8faf 100644 --- a/hpx/runtime/threads/policies/callback_notifier.hpp +++ b/hpx/runtime/threads/policies/callback_notifier.hpp @@ -45,9 +45,12 @@ namespace hpx { namespace threads { namespace policies } private: - on_startstop_type on_start_thread_; ///< function to call for each created thread - on_startstop_type on_stop_thread_; ///< function to call in case of unexpected stop - on_error_type on_error_; ///< function to call in case of error + on_startstop_type on_start_thread_; + ///< function to call for each created thread + on_startstop_type on_stop_thread_; + ///< function to call in case of unexpected stop + on_error_type on_error_; + ///< function to call in case of error }; }}} diff --git a/hpx/runtime/threads/policies/hierarchy_scheduler.hpp b/hpx/runtime/threads/policies/hierarchy_scheduler.hpp index 91599888e57d..2a311157a51a 100644 --- a/hpx/runtime/threads/policies/hierarchy_scheduler.hpp +++ b/hpx/runtime/threads/policies/hierarchy_scheduler.hpp @@ -86,7 +86,8 @@ namespace hpx { namespace threads { namespace policies boost::atomic v; flag_type() { v = false; } flag_type(flag_type const & f) { v.store(f.v.load()); } - flag_type & operator=(flag_type const & f) { v.store(f.v.load()); return *this; } + flag_type & operator=(flag_type const & f) { v.store(f.v.load()); + return *this; } flag_type & operator=(bool b) { v.store(b); return *this;} bool operator==(bool b) { return v == b; } operator bool() { return v; } @@ -638,7 +639,8 @@ namespace hpx { namespace threads { namespace policies tree.back()[0]->schedule_thread(thrd); } - void schedule_thread_last(threads::thread_data_base* thrd, std::size_t num_thread, + void schedule_thread_last(threads::thread_data_base* thrd, + std::size_t num_thread, thread_priority priority = thread_priority_normal) { HPX_ASSERT(tree.size()); diff --git a/hpx/runtime/threads/policies/hwloc_topology.hpp b/hpx/runtime/threads/policies/hwloc_topology.hpp index ba5222ddcfd0..7af4e8456c18 100644 --- a/hpx/runtime/threads/policies/hwloc_topology.hpp +++ b/hpx/runtime/threads/policies/hwloc_topology.hpp @@ -125,7 +125,8 @@ namespace hpx { namespace threads ) const; mask_type get_cpubind_mask(error_code& ec = throws) const; - mask_type get_cpubind_mask(boost::thread & handle, error_code& ec = throws) const; + mask_type get_cpubind_mask(boost::thread & handle, + error_code& ec = throws) const; /////////////////////////////////////////////////////////////////////// std::size_t get_number_of_sockets() const; diff --git a/hpx/runtime/threads/policies/local_priority_queue_scheduler.hpp b/hpx/runtime/threads/policies/local_priority_queue_scheduler.hpp index 51ae00a16139..dbd93d88de47 100644 --- a/hpx/runtime/threads/policies/local_priority_queue_scheduler.hpp +++ b/hpx/runtime/threads/policies/local_priority_queue_scheduler.hpp @@ -118,7 +118,8 @@ namespace hpx { namespace threads { namespace policies outside_numa_domain_masks_(init.num_queues_) #else numa_domain_masks_(init.num_queues_, topology_.get_machine_affinity_mask()), - outside_numa_domain_masks_(init.num_queues_, topology_.get_machine_affinity_mask()) + outside_numa_domain_masks_(init.num_queues_, + topology_.get_machine_affinity_mask()) #endif { if (!deferred_initialization) @@ -522,7 +523,8 @@ namespace hpx { namespace threads { namespace policies HPX_ASSERT(idx != num_thread); - if (!test(this_numa_domain, idx) && !test(numa_domain, idx)) //-V560 //-V600 //-V111 + if (!test(this_numa_domain, idx) && !test(numa_domain, idx)) + //-V560 //-V600 //-V111 continue; if (idx < high_priority_queues && @@ -719,7 +721,8 @@ namespace hpx { namespace threads { namespace policies case thread_priority_critical: { if (num_thread < high_priority_queues_.size()) - return high_priority_queues_[num_thread]->get_thread_count(state); + return high_priority_queues_[num_thread]-> + get_thread_count(state); break; } @@ -923,7 +926,8 @@ namespace hpx { namespace threads { namespace policies HPX_ASSERT(idx != num_thread); - if (!test(numa_domain_mask, topology_.get_pu_number(idx))) //-V600 + if (!test(numa_domain_mask, topology_.get_pu_number(idx))) + //-V600 continue; if (idx < high_priority_queues && @@ -968,7 +972,8 @@ namespace hpx { namespace threads { namespace policies HPX_ASSERT(idx != num_thread); - if (!test(numa_domain_mask, topology_.get_pu_number(idx))) //-V600 + if (!test(numa_domain_mask, topology_.get_pu_number(idx))) + //-V600 continue; if (idx < high_priority_queues && @@ -1056,7 +1061,8 @@ namespace hpx { namespace threads { namespace policies << "no new work available, are we deadlocked?"; } else { - LHPX_CONSOLE_(hpx::util::logging::level::error) << " [TM] " //-V128 + LHPX_CONSOLE_(hpx::util::logging::level::error) + << " [TM] " //-V128 << "queue(" << num_thread << "): " << "no new work available, are we deadlocked?\n"; } diff --git a/hpx/runtime/threads/policies/local_queue_scheduler.hpp b/hpx/runtime/threads/policies/local_queue_scheduler.hpp index 4ad617ee8467..e16d575dc810 100644 --- a/hpx/runtime/threads/policies/local_queue_scheduler.hpp +++ b/hpx/runtime/threads/policies/local_queue_scheduler.hpp @@ -107,7 +107,8 @@ namespace hpx { namespace threads { namespace policies outside_numa_domain_masks_(init.num_queues_) #else numa_domain_masks_(init.num_queues_, topology_.get_machine_affinity_mask()), - outside_numa_domain_masks_(init.num_queues_, topology_.get_machine_affinity_mask()) + outside_numa_domain_masks_(init.num_queues_, + topology_.get_machine_affinity_mask()) #endif { if (!deferred_initialization) @@ -193,7 +194,8 @@ namespace hpx { namespace threads { namespace policies return num_stolen_threads; } - num_stolen_threads += queues_[num_thread]->get_num_stolen_from_pending(reset); + num_stolen_threads += queues_[num_thread]-> + get_num_stolen_from_pending(reset); return num_stolen_threads; } @@ -325,7 +327,8 @@ namespace hpx { namespace threads { namespace policies HPX_ASSERT(idx != num_thread); - if (!test(this_numa_domain, idx) && !test(numa_domain, idx)) //-V560 //-V600 //-V111 + if (!test(this_numa_domain, idx) && !test(numa_domain, idx)) + //-V560 //-V600 //-V111 continue; thread_queue_type* q = queues_[idx]; @@ -371,7 +374,8 @@ namespace hpx { namespace threads { namespace policies queues_[num_thread]->schedule_thread(thrd); } - void schedule_thread_last(threads::thread_data_base* thrd, std::size_t num_thread, + void schedule_thread_last(threads::thread_data_base* thrd, + std::size_t num_thread, thread_priority priority = thread_priority_normal) { if (std::size_t(-1) == num_thread) @@ -557,7 +561,8 @@ namespace hpx { namespace threads { namespace policies HPX_ASSERT(idx != num_thread); - if (!test(numa_domain_mask, topology_.get_pu_number(idx))) //-V600 + if (!test(numa_domain_mask, topology_.get_pu_number(idx))) + //-V600 continue; result = queues_[num_thread]->wait_or_add_new(running, @@ -583,7 +588,8 @@ namespace hpx { namespace threads { namespace policies HPX_ASSERT(idx != num_thread); - if (!test(numa_domain_mask, topology_.get_pu_number(idx))) //-V600 + if (!test(numa_domain_mask, topology_.get_pu_number(idx))) + //-V600 continue; result = queues_[num_thread]->wait_or_add_new(running, @@ -637,7 +643,8 @@ namespace hpx { namespace threads { namespace policies << "no new work available, are we deadlocked?"; } else { - LHPX_CONSOLE_(hpx::util::logging::level::error) << " [TM] " //-V128 + LHPX_CONSOLE_(hpx::util::logging::level::error) + << " [TM] " //-V128 << "queue(" << num_thread << "): " << "no new work available, are we deadlocked?\n"; } diff --git a/hpx/runtime/threads/policies/noop_topology.hpp b/hpx/runtime/threads/policies/noop_topology.hpp index 38bf1a900c17..55af95f38090 100644 --- a/hpx/runtime/threads/policies/noop_topology.hpp +++ b/hpx/runtime/threads/policies/noop_topology.hpp @@ -180,7 +180,8 @@ struct noop_topology : topology return 0; } - void print_affinity_mask(std::ostream& os, std::size_t num_thread, mask_type const& m) const + void print_affinity_mask(std::ostream& os, std::size_t num_thread, + mask_type const& m) const { } diff --git a/hpx/runtime/threads/policies/schedulers.hpp b/hpx/runtime/threads/policies/schedulers.hpp index 72fa776367af..27ea8c51f158 100644 --- a/hpx/runtime/threads/policies/schedulers.hpp +++ b/hpx/runtime/threads/policies/schedulers.hpp @@ -8,6 +8,9 @@ #include +#if defined(HPX_HAVE_THROTTLE_SCHEDULER) +#include +#endif #if defined(HPX_HAVE_LOCAL_SCHEDULER) #include #endif diff --git a/hpx/runtime/threads/policies/thread_queue.hpp b/hpx/runtime/threads/policies/thread_queue.hpp index 24c86576b1d9..e2ecee69bd4b 100644 --- a/hpx/runtime/threads/policies/thread_queue.hpp +++ b/hpx/runtime/threads/policies/thread_queue.hpp @@ -311,7 +311,8 @@ namespace hpx { namespace threads { namespace policies std::size_t count = thread_map_.size(); if (max_count_ >= count + min_add_new_count) { //-V104 HPX_ASSERT(max_count_ - count < - static_cast((std::numeric_limits::max)())); + static_cast((std::numeric_limits + ::max)())); add_count = static_cast(max_count_ - count); if (add_count < min_add_new_count) add_count = min_add_new_count; @@ -348,7 +349,8 @@ namespace hpx { namespace threads { namespace policies std::size_t count = thread_map_.size(); if (max_count_ >= count + min_add_new_count) { //-V104 HPX_ASSERT(max_count_ - count < - static_cast((std::numeric_limits::max)())); + static_cast((std::numeric_limits + ::max)())); add_count = static_cast(max_count_ - count); if (add_count < min_add_new_count) add_count = min_add_new_count; @@ -987,26 +989,38 @@ namespace hpx { namespace threads { namespace policies private: mutable mutex_type mtx_; ///< mutex protecting the members - thread_map_type thread_map_; ///< mapping of thread id's to HPX-threads - boost::atomic thread_map_count_; ///< overall count of work items + thread_map_type thread_map_; + ///< mapping of thread id's to HPX-threads + boost::atomic thread_map_count_; + ///< overall count of work items - work_items_type work_items_; ///< list of active work items - boost::atomic work_items_count_; ///< count of active work items + work_items_type work_items_; + ///< list of active work items + boost::atomic work_items_count_; + ///< count of active work items #ifdef HPX_HAVE_THREAD_QUEUE_WAITTIME - boost::atomic work_items_wait_; ///< overall wait time of work items - boost::atomic work_items_wait_count_; ///< overall number of work items in queue + boost::atomic work_items_wait_; + ///< overall wait time of work items + boost::atomic work_items_wait_count_; + ///< overall number of work items in queue #endif terminated_items_type terminated_items_; ///< list of terminated threads - boost::atomic terminated_items_count_; ///< count of terminated items + boost::atomic terminated_items_count_; + ///< count of terminated items - std::size_t max_count_; ///< maximum number of existing HPX-threads - task_items_type new_tasks_; ///< list of new tasks to run + std::size_t max_count_; + ///< maximum number of existing HPX-threads + task_items_type new_tasks_; + ///< list of new tasks to run - boost::atomic new_tasks_count_; ///< count of new tasks to run + boost::atomic new_tasks_count_; + ///< count of new tasks to run #ifdef HPX_HAVE_THREAD_QUEUE_WAITTIME - boost::atomic new_tasks_wait_; ///< overall wait time of new tasks - boost::atomic new_tasks_wait_count_; ///< overall number tasks waited + boost::atomic new_tasks_wait_; + ///< overall wait time of new tasks + boost::atomic new_tasks_wait_count_; + ///< overall number tasks waited #endif threads::thread_pool memory_pool_; ///< OS thread local memory pools for @@ -1030,10 +1044,14 @@ namespace hpx { namespace threads { namespace policies // # of times our associated worker-thread looked for work in work_items boost::atomic pending_accesses_; - boost::atomic stolen_from_pending_; ///< count of work_items stolen from this queue - boost::atomic stolen_from_staged_; ///< count of new_tasks stolen from this queue - boost::atomic stolen_to_pending_; ///< count of work_items stolen to this queue from other queues - boost::atomic stolen_to_staged_; ///< count of new_tasks stolen to this queue from other queues + boost::atomic stolen_from_pending_; + ///< count of work_items stolen from this queue + boost::atomic stolen_from_staged_; + ///< count of new_tasks stolen from this queue + boost::atomic stolen_to_pending_; + ///< count of work_items stolen to this queue from other queues + boost::atomic stolen_to_staged_; + ///< count of new_tasks stolen to this queue from other queues #endif util::block_profiler add_new_logger_; diff --git a/hpx/runtime/threads/policies/throttle_queue_scheduler.hpp b/hpx/runtime/threads/policies/throttle_queue_scheduler.hpp index 0b3f1d980127..baa4c449670f 100644 --- a/hpx/runtime/threads/policies/throttle_queue_scheduler.hpp +++ b/hpx/runtime/threads/policies/throttle_queue_scheduler.hpp @@ -35,37 +35,38 @@ static bool apex_init = false; static boost::shared_mutex init_mutex; -static int foo1 = 0; -static volatile int64_t ** energy; -static int64_t * savedEnergy; -static struct timeval startts, curts; -static int64_t maxThreads, minThreads; #define VALUE_THROTTLING "/threadqueue{locality#0/total}/length" /* Notes on building and running Throttling scheduler +BASED ON THE local_priority_queue scheduler. -add -DHPX_THROTTLE_SCHEDULER=1 to cmake to include the throttling during the HPX build. +add -DHPX_HAVE_THROTTLE_SCHEDULER=1 to cmake to include the throttling during +the HPX build. I haven't tested but the flag to include all schedulers should also work. APEX also needs to be available (-DTAU_ROOT=... -DHPX_HAVE_APEX=1 needed) -To select the throttling scheduler during execution the --hpx:queuing=throttle needs to be included. +To select the throttling scheduler during execution the --hpx:queuing=throttle +needs to be included. -The HPX execution needs to be running on a system with an active RCRdaemon writing the RCRblackboard. -(currently I know {elo,thumper}.hpc.renci.org work) +The HPX execution needs to be running on a system with an active RCRdaemon +writing the RCRblackboard. (currently I know {elo,thumper}.hpc.renci.org work) -The current model is braindead. It checks to see if the energy is above a fixed value (80W) and reduces -the number of active threads to HPX_THROTTLE_MIN environment variable (12 if not specified) and when -the power is below 50 the number of threads is set to HPX_THROTTLE_MAX (16 if not specified). +The current model is braindead. It checks to see if the energy is above a fixed +value (80W) and reduces the number of active threads to HPX_THROTTLE_MIN +environment variable (12 if not specified) and when the power is below 50 the +number of threads is set to HPX_THROTTLE_MAX (16 if not specified). -The Power cutoffs should also be controlled via environment variable and the current memory concurrency -should play a significant role in deciding whether to limit the parallel in the system. During high -concurrency the speed is limited by memory bandwidth and the reduction in parallelism should not -significantly reduce execution time (memory is still going to be running flat out). I may get to -these additions this week, I'll try hard to have them in place before the visit to Oregon. +The Power cutoffs should also be controlled via environment variable and the +current memory concurrency should play a significant role in deciding whether +to limit the parallel in the system. During high concurrency the speed is +limited by memory bandwidth and the reduction in parallelism should not +significantly reduce execution time (memory is still going to be running flat +out). I may get to these additions this week, I'll try hard to have them in +place before the visit to Oregon. */ /////////////////////////////////////////////////////////////////////////////// @@ -78,7 +79,7 @@ namespace hpx { namespace threads { namespace policies // startup code extern bool minimal_deadlock_detection; #endif - static int apex_current_desired_active_threads = INT_MAX; + static std::size_t apex_current_desired_active_threads = INT_MAX; /////////////////////////////////////////////////////////////////////////// /// The local_queue_scheduler maintains exactly one queue of work /// items (threads) per OS thread, where this OS thread pulls its next work @@ -141,16 +142,18 @@ namespace hpx { namespace threads { namespace policies queue_count_(init.num_queues_), apex_current_threads(false), numa_sensitive_(init.numa_sensitive_), -#if !defined(HPX_NATIVE_MIC) // we know that the MIC has one NUMA domain only +#ifndef HPX_NATIVE_MIC // we know that the MIC has one NUMA domain only steals_in_numa_domain_(init.num_queues_), steals_outside_numa_domain_(init.num_queues_), #endif -#if !defined(HPX_HAVE_MORE_THAN_64_THREADS) || defined(HPX_MAX_CPU_COUNT) +#if !defined(HPX_WITH_MORE_THAN_64_THREADS) || defined(HPX_HAVE_MAX_CPU_COUNT) numa_domain_masks_(init.num_queues_), outside_numa_domain_masks_(init.num_queues_) #else - numa_domain_masks_(init.num_queues_, topology_.get_machine_affinity_mask()), - outside_numa_domain_masks_(init.num_queues_, topology_.get_machine_affinity_mask()) + numa_domain_masks_(init.num_queues_, + topology_.get_machine_affinity_mask()), + outside_numa_domain_masks_(init.num_queues_, + topology_.get_machine_affinity_mask()) #endif { std::cerr << "starting Throttling Scheduler\n" << std::endl; @@ -199,9 +202,9 @@ namespace hpx { namespace threads { namespace policies #endif #ifdef HPX_HAVE_THREAD_STEALING_COUNTS - std::size_t get_num_pending_misses(std::size_t num_thread, bool reset) + boost::int64_t get_num_pending_misses(std::size_t num_thread, bool reset) { - std::size_t num_pending_misses = 0; + boost::int64_t num_pending_misses = 0; if (num_thread == std::size_t(-1)) { for (std::size_t i = 0; i != queues_.size(); ++i) @@ -216,9 +219,9 @@ namespace hpx { namespace threads { namespace policies return num_pending_misses; } - std::size_t get_num_pending_accesses(std::size_t num_thread, bool reset) + boost::int64_t get_num_pending_accesses(std::size_t num_thread, bool reset) { - std::size_t num_pending_accesses = 0; + boost::int64_t num_pending_accesses = 0; if (num_thread == std::size_t(-1)) { for (std::size_t i = 0; i != queues_.size(); ++i) @@ -233,59 +236,67 @@ namespace hpx { namespace threads { namespace policies return num_pending_accesses; } - std::size_t get_num_stolen_from_pending(std::size_t num_thread, bool reset) + boost::int64_t get_num_stolen_from_pending(std::size_t num_thread, bool reset) { - std::size_t num_stolen_threads = 0; + boost::int64_t num_stolen_threads = 0; if (num_thread == std::size_t(-1)) { for (std::size_t i = 0; i != queues_.size(); ++i) - num_stolen_threads += queues_[i]->get_num_stolen_from_pending(reset); + num_stolen_threads += + queues_[i]->get_num_stolen_from_pending(reset); return num_stolen_threads; } - num_stolen_threads += queues_[num_thread]->get_num_stolen_from_pending(reset); + num_stolen_threads += queues_[num_thread]-> + get_num_stolen_from_pending(reset); return num_stolen_threads; } - std::size_t get_num_stolen_to_pending(std::size_t num_thread, bool reset) + boost::int64_t get_num_stolen_to_pending(std::size_t num_thread, bool reset) { - std::size_t num_stolen_threads = 0; + boost::int64_t num_stolen_threads = 0; if (num_thread == std::size_t(-1)) { for (std::size_t i = 0; i != queues_.size(); ++i) - num_stolen_threads += queues_[i]->get_num_stolen_to_pending(reset); + num_stolen_threads += + queues_[i]->get_num_stolen_to_pending(reset); return num_stolen_threads; } - num_stolen_threads += queues_[num_thread]->get_num_stolen_to_pending(reset); + num_stolen_threads += + queues_[num_thread]->get_num_stolen_to_pending(reset); return num_stolen_threads; } - std::size_t get_num_stolen_from_staged(std::size_t num_thread, bool reset) + boost::int64_t get_num_stolen_from_staged(std::size_t num_thread, bool reset) { - std::size_t num_stolen_threads = 0; + boost::int64_t num_stolen_threads = 0; if (num_thread == std::size_t(-1)) { for (std::size_t i = 0; i != queues_.size(); ++i) - num_stolen_threads += queues_[i]->get_num_stolen_from_staged(reset); + num_stolen_threads += + queues_[i]->get_num_stolen_from_staged(reset); return num_stolen_threads; } - num_stolen_threads += queues_[num_thread]->get_num_stolen_from_staged(reset); + num_stolen_threads += + queues_[num_thread]->get_num_stolen_from_staged(reset); return num_stolen_threads; } - std::size_t get_num_stolen_to_staged(std::size_t num_thread, bool reset) + boost::int64_t get_num_stolen_to_staged(std::size_t num_thread, bool reset) { - std::size_t num_stolen_threads = 0; + boost::int64_t num_stolen_threads = 0; if (num_thread == std::size_t(-1)) { for (std::size_t i = 0; i != queues_.size(); ++i) - num_stolen_threads += queues_[i]->get_num_stolen_to_staged(reset); + num_stolen_threads += + queues_[i]->get_num_stolen_to_staged(reset); return num_stolen_threads; } - num_stolen_threads += queues_[num_thread]->get_num_stolen_to_staged(reset); + num_stolen_threads += + queues_[num_thread]->get_num_stolen_to_staged(reset); return num_stolen_threads; } #endif @@ -337,15 +348,19 @@ namespace hpx { namespace threads { namespace policies } bool TTthrottle(std::size_t num_thread, int add_thread){ + /* Usage commented out, below */ + /* mask_cref_type this_numa_domain = numa_domain_masks_[num_thread]; std::size_t count_this_numa_domain = 0; std::size_t count_other_numa_domain = 0; std::size_t queues_size = queues_.size(); + */ #ifndef VALUE_THROTTLING if (HPX_UNLIKELY(apex_init == false)) { boost::unique_lock l{init_mutex}; - if(apex_init == true || apex::setup_power_cap_throttling() != APEX_NOERROR) { + if(apex_init == true || + apex::setup_power_cap_throttling() != APEX_NOERROR) { return true; // Don't throttle } else { apex_init = true; @@ -354,22 +369,27 @@ namespace hpx { namespace threads { namespace policies #else if (HPX_UNLIKELY(apex_init == false)) { boost::unique_lock l{init_mutex}; - if(apex_init == true || apex::setup_timer_throttling(VALUE_THROTTLING, APEX_MINIMIZE_ACCUMULATED, APEX_DISCRETE_HILL_CLIMBING, 1000000) != APEX_NOERROR) { + if(apex_init == true || + apex::setup_timer_throttling(VALUE_THROTTLING, + APEX_MINIMIZE_ACCUMULATED, APEX_DISCRETE_HILL_CLIMBING, + 1000000) != APEX_NOERROR) { return true; // Don't throttle } else { - std::cerr << "Thread " << num_thread << " initialized apex throttling." << std::endl; + std::cerr << "Thread " << num_thread << + " initialized apex throttling." << std::endl; apex_init = true; } } #endif // check if we should throttle - const int desired_active_threads = apex::get_thread_cap(); + std::size_t desired_active_threads = apex::get_thread_cap(); if(num_thread < desired_active_threads) { return true; } else { - // Sleep so that we don't continue using energy repeatedly checking for work. + // Sleep so that we don't continue using energy repeatedly + // checking for work. static const struct timespec tim{0, 100000}; nanosleep(&tim, nullptr); return false; @@ -378,7 +398,7 @@ namespace hpx { namespace threads { namespace policies /// Return the next thread to be executed, return false if none is /// available - virtual bool get_next_thread(std::size_t num_thread, bool running, + virtual bool get_next_thread(std::size_t num_thread, boost::int64_t& idle_loop_count, threads::thread_data_base*& thrd) { std::size_t queues_size = queues_.size(); @@ -386,7 +406,8 @@ namespace hpx { namespace threads { namespace policies { HPX_ASSERT(num_thread < queues_size); - bool ret = TTthrottle(num_thread, apex_current_threads < apex_current_desired_active_threads); // am I throttled? + bool ret = TTthrottle(num_thread, apex_current_threads < + apex_current_desired_active_threads); // am I throttled? if (!ret) return false; // throttled -- don't grap any work // grab work if available @@ -419,6 +440,7 @@ namespace hpx { namespace threads { namespace policies HPX_ASSERT(idx != num_thread); + //-V560 //-V600 //-V111 if (!test(this_numa_domain, idx) && !test(numa_domain, idx)) continue; @@ -466,7 +488,8 @@ namespace hpx { namespace threads { namespace policies queues_[num_thread]->schedule_thread(thrd); } - void schedule_thread_last(threads::thread_data_base* thrd, std::size_t num_thread, + void schedule_thread_last(threads::thread_data_base* thrd, + std::size_t num_thread, thread_priority priority = thread_priority_normal) { throttle_queue_scheduler::schedule_thread(thrd, num_thread, priority); @@ -521,6 +544,7 @@ namespace hpx { namespace threads { namespace policies case thread_priority_default: case thread_priority_low: case thread_priority_normal: + case thread_priority_boost: case thread_priority_critical: return queues_[num_thread]->get_thread_count(state); @@ -541,6 +565,7 @@ namespace hpx { namespace threads { namespace policies case thread_priority_default: case thread_priority_low: case thread_priority_normal: + case thread_priority_boost: case thread_priority_critical: { for (std::size_t i = 0; i != queues_.size(); ++i) @@ -634,7 +659,7 @@ namespace hpx { namespace threads { namespace policies // steal work items: first try to steal from other cores in // the same NUMA node #if !defined(HPX_NATIVE_MIC) // we know that the MIC has one NUMA domain only - if (test(steals_in_numa_domain_, num_thread)) + if (test(steals_in_numa_domain_, num_thread)) //-V600 //-V111 #endif { mask_cref_type numa_domain_mask = @@ -647,6 +672,7 @@ namespace hpx { namespace threads { namespace policies HPX_ASSERT(idx != num_thread); if (!test(numa_domain_mask, topology_.get_pu_number(idx))) + //-V600 continue; result = queues_[num_thread]->wait_or_add_new(running, @@ -660,9 +686,9 @@ namespace hpx { namespace threads { namespace policies } } -#if !defined(HPX_NATIVE_MIC) // we know that the MIC has one NUMA domain only +#ifndef HPX_NATIVE_MIC // we know that the MIC has one NUMA domain only // if nothing found, ask everybody else - if (test(steals_outside_numa_domain_, num_thread)) { + if (test(steals_outside_numa_domain_, num_thread)) { //-V600 //-V111 mask_cref_type numa_domain_mask = outside_numa_domain_masks_[num_thread]; for (std::size_t i = 1; i != queues_size; ++i) @@ -673,6 +699,7 @@ namespace hpx { namespace threads { namespace policies HPX_ASSERT(idx != num_thread); if (!test(numa_domain_mask, topology_.get_pu_number(idx))) + //-V600 continue; result = queues_[num_thread]->wait_or_add_new(running, @@ -726,7 +753,8 @@ namespace hpx { namespace threads { namespace policies << "no new work available, are we deadlocked?"; } else { - LHPX_CONSOLE_(hpx::util::logging::level::error) << " [TM] " //-V128 + LHPX_CONSOLE_(hpx::util::logging::level::error) + << " [TM] " //-V128 << "queue(" << num_thread << "): " << "no new work available, are we deadlocked?\n"; } @@ -799,7 +827,7 @@ namespace hpx { namespace threads { namespace policies bool apex_current_threads; bool numa_sensitive_; - //#if defined (HPX_THROTTLE_SCHEDULER) + //#if defined (HPX_HAVE_THROTTLE_SCHEDULER) mask_type active_; //#endif diff --git a/hpx/runtime/threads/resource_manager.hpp b/hpx/runtime/threads/resource_manager.hpp index 3e75f3d22b9d..634dace9db70 100644 --- a/hpx/runtime/threads/resource_manager.hpp +++ b/hpx/runtime/threads/resource_manager.hpp @@ -128,7 +128,8 @@ namespace hpx { namespace threads } boost::shared_ptr proxy_; // hold on to proxy - std::vector core_ids_; // map physical to logical puinit ids + std::vector core_ids_; + // map physical to logical puinit ids }; typedef std::map proxies_map_type; diff --git a/hpx/runtime/threads/thread_executor.hpp b/hpx/runtime/threads/thread_executor.hpp index 0e7ea1a8a7c3..1c7e499dd495 100644 --- a/hpx/runtime/threads/thread_executor.hpp +++ b/hpx/runtime/threads/thread_executor.hpp @@ -7,6 +7,7 @@ #define HPX_RUNTIME_THREADS_THREAD_EXECUTOR_JAN_11_2013_0700PM #include +#include #include #include #include @@ -17,6 +18,17 @@ #include +/////////////////////////////////////////////////////////////////////////////// +namespace hpx +{ + namespace threads + { + class HPX_EXPORT executor; + } + + HPX_EXPORT std::size_t get_os_thread_count(threads::executor const&); +} + namespace hpx { namespace threads { /// \brief Data structure which stores statistics collected by an @@ -165,7 +177,7 @@ namespace hpx { namespace threads // virtual size_t num_pending_closures() const = 0; // }; // - class HPX_EXPORT executor + class executor { friend std::size_t hpx::get_os_thread_count(threads::executor const&); diff --git a/hpx/runtime/threads/thread_helpers.hpp b/hpx/runtime/threads/thread_helpers.hpp index 7554a280408a..fea314096f19 100644 --- a/hpx/runtime/threads/thread_helpers.hpp +++ b/hpx/runtime/threads/thread_helpers.hpp @@ -9,6 +9,7 @@ #define HPX_THREAD_HELPERS_NOV_15_2008_0504PM #include +#include #include #include #include @@ -194,7 +195,8 @@ namespace hpx { namespace threads HPX_API_EXPORT util::backtrace const* get_thread_backtrace( thread_id_type const& id, error_code& ec = throws); HPX_API_EXPORT util::backtrace const* set_thread_backtrace( - thread_id_type const& id, util::backtrace const* bt = 0, error_code& ec = throws); + thread_id_type const& id, util::backtrace const* bt = 0, + error_code& ec = throws); #endif /////////////////////////////////////////////////////////////////////////// diff --git a/hpx/runtime/threads/threadmanager.hpp b/hpx/runtime/threads/threadmanager.hpp index 2d0f23d50c1e..5a99baffacef 100644 --- a/hpx/runtime/threads/threadmanager.hpp +++ b/hpx/runtime/threads/threadmanager.hpp @@ -208,10 +208,12 @@ namespace hpx { namespace threads /// thread is not known to the threadmanager the return /// value will be the string "". virtual char const* get_description(thread_id_type const& id) const = 0; - virtual char const* set_description(thread_id_type const& id, char const* desc = 0) = 0; + virtual char const* set_description(thread_id_type const& id, + char const* desc = 0) = 0; virtual char const* get_lco_description(thread_id_type const& id) const = 0; - virtual char const* set_lco_description(thread_id_type const& id, char const* desc = 0) = 0; + virtual char const* set_lco_description(thread_id_type const& id, + char const* desc = 0) = 0; /// The function get_thread_backtrace is part of the thread related API /// allows to query the currently stored thread back trace (which is @@ -228,10 +230,12 @@ namespace hpx { namespace threads /// thread-manager the return value will be the zero. #ifdef HPX_HAVE_THREAD_FULLBACKTRACE_ON_SUSPENSION virtual char const* get_backtrace(thread_id_type const& id) const = 0; - virtual char const* set_backtrace(thread_id_type const& id, char const* bt = 0) = 0; + virtual char const* set_backtrace(thread_id_type const& id, + char const* bt = 0) = 0; #else virtual util::backtrace const* get_backtrace(thread_id_type const& id) const = 0; - virtual util::backtrace const* set_backtrace(thread_id_type const& id, util::backtrace const* bt = 0) = 0; + virtual util::backtrace const* set_backtrace(thread_id_type const& id, + util::backtrace const* bt = 0) = 0; #endif /// The function \a register_work adds a new work item to the thread diff --git a/hpx/runtime/threads/topology.hpp b/hpx/runtime/threads/topology.hpp index dd95efc43e98..a1f150fe3c26 100644 --- a/hpx/runtime/threads/topology.hpp +++ b/hpx/runtime/threads/topology.hpp @@ -21,14 +21,16 @@ #include #include #include -#if defined(HPX_WITH_MORE_THAN_64_THREADS) || (defined(HPX_HAVE_MAX_CPU_COUNT) && HPX_HAVE_MAX_CPU_COUNT > 64) +#if defined(HPX_WITH_MORE_THAN_64_THREADS) || (defined(HPX_HAVE_MAX_CPU_COUNT) \ + && HPX_HAVE_MAX_CPU_COUNT > 64) #include #endif namespace hpx { namespace threads { /// \cond NOINTERNAL -#if !defined(HPX_WITH_MORE_THAN_64_THREADS) || (defined(HPX_HAVE_MAX_CPU_COUNT) && HPX_HAVE_MAX_CPU_COUNT <= 64) +#if !defined(HPX_WITH_MORE_THAN_64_THREADS) || (defined(HPX_HAVE_MAX_CPU_COUNT) \ + && HPX_HAVE_MAX_CPU_COUNT <= 64) typedef boost::uint64_t mask_type; typedef boost::uint64_t mask_cref_type; @@ -363,7 +365,8 @@ namespace hpx { namespace threads bool operator==(spec_type const& rhs) const { - if (type_ != rhs.type_ || index_bounds_.size() != rhs.index_bounds_.size()) + if (type_ != rhs.type_ || index_bounds_.size() != + rhs.index_bounds_.size()) return false; for (std::size_t i = 0; i < index_bounds_.size(); ++i) diff --git a/hpx/runtime/threads_fwd.hpp b/hpx/runtime/threads_fwd.hpp new file mode 100644 index 000000000000..612f4488966b --- /dev/null +++ b/hpx/runtime/threads_fwd.hpp @@ -0,0 +1,267 @@ +// Copyright (c) 2007-2014 Hartmut Kaiser +// Copyright (c) 2011 Bryce Lelbach +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/// \file threads_fwd.hpp + +#ifndef HPX_RUNTIME_THREADS_FWD_HPP +#define HPX_RUNTIME_THREADS_FWD_HPP + +#include +#include +#include +#include + +#include + +namespace hpx +{ + namespace util + { + namespace coroutines + { + namespace detail + { + template + class coroutine_self; + + template + struct coroutine_allocator; + template class Heap> + class coroutine_impl; + } + + template class Heap, + typename ContextImpl = detail::default_context_impl> + class coroutine; + } + } + + /// \namespace threads + /// + /// The namespace \a thread-manager contains all the definitions required + /// for the scheduling, execution and general management of \a + /// hpx#threadmanager#thread's. + namespace threads + { + namespace policies + { + struct scheduler_base; + + struct lockfree_fifo; + struct lockfree_lifo; + + // multi priority scheduler with work-stealing + template + class HPX_EXPORT local_priority_queue_scheduler; + + // single priority scheduler with work-stealing + template + class HPX_EXPORT local_queue_scheduler; + +#if defined(HPX_HAVE_PERIODIC_PRIORITY_SCHEDULER) + template + class HPX_EXPORT periodic_priority_queue_scheduler; +#endif + +#if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER) + // multi priority scheduler with no work-stealing + template + class HPX_EXPORT static_priority_queue_scheduler; +#endif + +#if defined(HPX_HAVE_STATIC_SCHEDULER) + // single priority scheduler with no work-stealing + template + class HPX_EXPORT static_queue_scheduler; +#endif + +#if defined(HPX_HAVE_THROTTLE_SCHEDULER) + // single priority scheduler with work-stealing and throttling + template + class HPX_EXPORT throttle_queue_scheduler; +#endif + +#if defined(HPX_HAVE_HIERARCHY_SCHEDULER) + template + class HPX_EXPORT hierarchy_scheduler; +#endif + + typedef local_priority_queue_scheduler< + boost::mutex, + lockfree_fifo, // FIFO pending queuing + lockfree_fifo, // FIFO staged queuing + lockfree_lifo // LIFO terminated queuing + > fifo_priority_queue_scheduler; + +#if defined(HPX_HAVE_ABP_SCHEDULER) + struct lockfree_abp_fifo; + struct lockfree_abp_lifo; + + typedef local_priority_queue_scheduler< + boost::mutex, + lockfree_abp_fifo, // FIFO + ABP pending queuing + lockfree_abp_fifo, // FIFO + ABP staged queuing + lockfree_lifo // LIFO terminated queuing + > abp_fifo_priority_queue_scheduler; +#endif + + // define the default scheduler to use + typedef fifo_priority_queue_scheduler queue_scheduler; + + class HPX_EXPORT callback_notifier; + } + + struct HPX_EXPORT threadmanager_base; + class HPX_EXPORT thread_data_base; + class HPX_EXPORT thread_data; + + template + class HPX_EXPORT threadmanager_impl; + + typedef thread_state_enum thread_function_sig(thread_state_ex_enum); + typedef util::unique_function_nonser + thread_function_type; + + class HPX_EXPORT executor; + + /////////////////////////////////////////////////////////////////////// + /// \ cond NODETAIL + namespace detail + { + template struct coroutine_allocator; + } + /// \ endcond + typedef util::coroutines::coroutine< + thread_function_sig, detail::coroutine_allocator> coroutine_type; + + typedef util::coroutines::detail::coroutine_self + thread_self; + typedef + util::coroutines::detail::coroutine_impl< + coroutine_type + , util::coroutines::detail::default_context_impl + , detail::coroutine_allocator + > + thread_self_impl_type; + typedef void * thread_id_repr_type; + + typedef boost::intrusive_ptr thread_id_type; + + HPX_EXPORT void intrusive_ptr_add_ref(thread_data_base* p); + HPX_EXPORT void intrusive_ptr_release(thread_data_base* p); + + /////////////////////////////////////////////////////////////////////// + /// \ cond NODETAIL + BOOST_CONSTEXPR_OR_CONST thread_id_repr_type invalid_thread_id_repr = 0; + thread_id_type const invalid_thread_id = thread_id_type(); + /// \ endcond + + /// The function \a get_self returns a reference to the (OS thread + /// specific) self reference to the current HPX thread. + HPX_API_EXPORT thread_self& get_self(); + + /// The function \a get_self_ptr returns a pointer to the (OS thread + /// specific) self reference to the current HPX thread. + HPX_API_EXPORT thread_self* get_self_ptr(); + + /// The function \a get_ctx_ptr returns a pointer to the internal data + /// associated with each coroutine. + HPX_API_EXPORT thread_self_impl_type* get_ctx_ptr(); + + /// The function \a get_self_ptr_checked returns a pointer to the (OS + /// thread specific) self reference to the current HPX thread. + HPX_API_EXPORT thread_self* get_self_ptr_checked(error_code& ec = throws); + + /// The function \a get_self_id returns the HPX thread id of the current + /// thread (or zero if the current thread is not a HPX thread). + HPX_API_EXPORT thread_id_type get_self_id(); + + /// The function \a get_parent_id returns the HPX thread id of the + /// current thread's parent (or zero if the current thread is not a + /// HPX thread). + /// + /// \note This function will return a meaningful value only if the + /// code was compiled with HPX_HAVE_THREAD_PARENT_REFERENCE + /// being defined. + HPX_API_EXPORT thread_id_repr_type get_parent_id(); + + /// The function \a get_parent_phase returns the HPX phase of the + /// current thread's parent (or zero if the current thread is not a + /// HPX thread). + /// + /// \note This function will return a meaningful value only if the + /// code was compiled with HPX_HAVE_THREAD_PARENT_REFERENCE + /// being defined. + HPX_API_EXPORT std::size_t get_parent_phase(); + + /// The function \a get_parent_locality_id returns the id of the locality of + /// the current thread's parent (or zero if the current thread is not a + /// HPX thread). + /// + /// \note This function will return a meaningful value only if the + /// code was compiled with HPX_HAVE_THREAD_PARENT_REFERENCE + /// being defined. + HPX_API_EXPORT boost::uint32_t get_parent_locality_id(); + + /// The function \a get_self_component_id returns the lva of the + /// component the current thread is acting on + /// + /// \note This function will return a meaningful value only if the + /// code was compiled with HPX_HAVE_THREAD_TARGET_ADDRESS + /// being defined. + HPX_API_EXPORT boost::uint64_t get_self_component_id(); + + /// The function \a get_thread_manager returns a reference to the + /// current thread manager. + HPX_API_EXPORT threadmanager_base& get_thread_manager(); + + /// The function \a get_thread_count returns the number of currently + /// known threads. + /// + /// \note If state == unknown this function will not only return the + /// number of currently existing threads, but will add the number + /// of registered task descriptions (which have not been + /// converted into threads yet). + HPX_API_EXPORT boost::int64_t get_thread_count( + thread_state_enum state = unknown); + + /// \copydoc get_thread_count(thread_state_enum state) + HPX_API_EXPORT boost::int64_t get_thread_count( + thread_priority priority, thread_state_enum state = unknown); + } +} + +#endif diff --git a/hpx/runtime/trigger_lco.hpp b/hpx/runtime/trigger_lco.hpp index d54098088976..f24704b7949f 100644 --- a/hpx/runtime/trigger_lco.hpp +++ b/hpx/runtime/trigger_lco.hpp @@ -75,7 +75,8 @@ namespace hpx HPX_API_EXPORT void set_lco_error(naming::id_type const& id, boost::exception_ptr const& e, bool move_credits = true); - /// \copydoc hpx::set_lco_error(naming::id_type const& id, boost::exception_ptr const& e, bool move_credits) + /// \copydoc hpx::set_lco_error(naming::id_type const& id, + /// boost::exception_ptr const& e, bool move_credits) HPX_API_EXPORT void set_lco_error(naming::id_type const& id, boost::exception_ptr && e, bool move_credits = true); @@ -93,7 +94,8 @@ namespace hpx boost::exception_ptr const& e, naming::id_type const& cont, bool move_credits = true); - /// \copydoc hpx::set_lco_error(naming::id_type const& id, boost::exception_ptr const& e, naming::id_type const& cont, bool move_credits) + /// \copydoc hpx::set_lco_error(naming::id_type const& id, + /// boost::exception_ptr const& e, naming::id_type const& cont, bool move_credits) HPX_API_EXPORT void set_lco_error(naming::id_type const& id, boost::exception_ptr && e, naming::id_type const& cont, bool move_credits = true); diff --git a/hpx/traits/is_action.hpp b/hpx/traits/is_action.hpp index a760cd75044a..9ba3e176631a 100644 --- a/hpx/traits/is_action.hpp +++ b/hpx/traits/is_action.hpp @@ -8,6 +8,7 @@ #include #include +#include #include namespace hpx { namespace traits diff --git a/hpx/traits/is_callable.hpp b/hpx/traits/is_callable.hpp index ea72e8f0b9b4..b0aee7bbe85e 100644 --- a/hpx/traits/is_callable.hpp +++ b/hpx/traits/is_callable.hpp @@ -27,7 +27,8 @@ #include // The technique implemented here was devised by Eric Niebler, see: -// http://www.boost.org/doc/libs/1_54_0/doc/html/proto/appendices.html#boost_proto.appendices.implementation.function_arity +// http://www.boost.org/doc/libs/1_54_0/doc/html/proto/appendices.html +// #boost_proto.appendices.implementation.function_arity namespace hpx { namespace traits { namespace detail diff --git a/hpx/traits/is_launch_policy.hpp b/hpx/traits/is_launch_policy.hpp index d407881c57da..ac82dd92285b 100644 --- a/hpx/traits/is_launch_policy.hpp +++ b/hpx/traits/is_launch_policy.hpp @@ -6,7 +6,7 @@ #if !defined(HPX_TRAITS_IS_LAUNCH_POLICY_APR_8_2014_0436PM) #define HPX_TRAITS_IS_LAUNCH_POLICY_APR_8_2014_0436PM -#include +#include #include #include diff --git a/hpx/util/any.hpp b/hpx/util/any.hpp index 04b73fd003ff..7f3f94e5c299 100644 --- a/hpx/util/any.hpp +++ b/hpx/util/any.hpp @@ -85,7 +85,8 @@ namespace hpx { namespace util void (*copy)(void* const*, void**); bool (*equal_to)(void* const*, void* const*); std::basic_istream& (*stream_in)(std::basic_istream&, void**); - std::basic_ostream& (*stream_out)(std::basic_ostream&, void* const*); + std::basic_ostream& (*stream_out)(std::basic_ostream&, + void* const*); virtual void save_object(void *const*, OArchive & ar, unsigned) = 0; virtual void load_object(void **, IArchive & ar, unsigned) = 0; @@ -110,7 +111,8 @@ namespace hpx { namespace util void (*copy)(void* const*, void**); bool (*equal_to)(void* const*, void* const*); std::basic_istream& (*stream_in)(std::basic_istream&, void**); - std::basic_ostream& (*stream_out)(std::basic_ostream&, void* const*); + std::basic_ostream& (*stream_out)(std::basic_ostream&, + void* const*); }; template - inline T const* any_cast(basic_any const* operand) BOOST_NOEXCEPT + inline T const* any_cast(basic_any const* operand) BOOST_NOEXCEPT { return any_cast(const_cast*>(operand)); } @@ -999,13 +1002,16 @@ namespace hpx { namespace util BOOST_STATIC_ASSERT(!is_reference::value); #endif - return any_cast(const_cast &>(operand)); + return any_cast(const_cast &>(operand)); } /////////////////////////////////////////////////////////////////////////////// // backwards compatibility - typedef basic_any any; - typedef basic_any wany; + typedef basic_any any; + typedef basic_any wany; typedef basic_any any_nonser; typedef basic_any wany_nonser; diff --git a/hpx/util/assert.hpp b/hpx/util/assert.hpp index 6385fc21e779..dabb16ca56d2 100644 --- a/hpx/util/assert.hpp +++ b/hpx/util/assert.hpp @@ -83,7 +83,8 @@ namespace hpx #define HPX_ASSERT_MSG(expr, msg) (HPX_LIKELY(!!(expr)) \ ? ((void)0) \ - : ::hpx::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) + : ::hpx::assertion_failed_msg \ + (#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__)) #else @@ -103,7 +104,8 @@ namespace hpx namespace hpx { namespace assertion { namespace detail { - // Note: The template is needed to make the function non-inline and avoid linking errors + // Note: The template is needed to make the function non-inline and + // avoid linking errors template< typename CharT > BOOST_NOINLINE void assertion_failed_msg(CharT const * expr, char const * msg, char const * function, char const * file, long line) @@ -135,8 +137,9 @@ namespace hpx { namespace assertion { namespace detail #undef HPX_VERIFY -#if defined(HPX_DISABLE_ASSERTS) || ( !defined(HPX_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) ) \ - || defined(BOOST_DISABLE_ASSERTS) || ( !defined(BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) ) +#if defined(HPX_DISABLE_ASSERTS) || ( !defined(HPX_ENABLE_ASSERT_HANDLER) \ + && defined(NDEBUG) ) || defined(BOOST_DISABLE_ASSERTS) \ + || ( !defined(BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) ) # define HPX_VERIFY(expr) ((void)(expr)) diff --git a/hpx/util/backtrace/backtrace.hpp b/hpx/util/backtrace/backtrace.hpp index a40d17655d99..0816d03284d7 100644 --- a/hpx/util/backtrace/backtrace.hpp +++ b/hpx/util/backtrace/backtrace.hpp @@ -41,9 +41,11 @@ namespace hpx { namespace util namespace stack_trace { HPX_BACKTRACE_DECL std::size_t trace(void **addresses, std::size_t size); - HPX_BACKTRACE_DECL void write_symbols(void *const *addresses, std::size_t size,std::ostream &); + HPX_BACKTRACE_DECL void write_symbols(void *const *addresses, + std::size_t size,std::ostream &); HPX_BACKTRACE_DECL std::string get_symbol(void *address); - HPX_BACKTRACE_DECL std::string get_symbols(void * const *address, std::size_t size); + HPX_BACKTRACE_DECL std::string get_symbols(void * const *address, + std::size_t size); } // stack_trace class backtrace { diff --git a/hpx/util/batch_environment.hpp b/hpx/util/batch_environment.hpp index 8e523ff84c89..347040487789 100644 --- a/hpx/util/batch_environment.hpp +++ b/hpx/util/batch_environment.hpp @@ -26,8 +26,8 @@ namespace hpx { namespace util // Try to retrieve default values from a batch environment struct HPX_EXPORT batch_environment { - // the constructor tries to read initial values from a batch environment, filling our - // map of nodes and thread counts + // the constructor tries to read initial values from a batch environment, + // filling our map of nodes and thread counts batch_environment(std::vector & nodelist, bool debug = false, bool enable = true); diff --git a/hpx/util/batch_environments/slurm_environment.hpp b/hpx/util/batch_environments/slurm_environment.hpp index cb203ddb3c83..bf4ca7025355 100644 --- a/hpx/util/batch_environments/slurm_environment.hpp +++ b/hpx/util/batch_environments/slurm_environment.hpp @@ -229,8 +229,10 @@ namespace hpx { namespace util { namespace batch_environments { else { using hpx::util::safe_lexical_cast; - std::size_t begin = safe_lexical_cast(range[0]); - std::size_t end = safe_lexical_cast(range[1]); + std::size_t begin = safe_lexical_cast + (range[0]); + std::size_t end = safe_lexical_cast + (range[1]); if(begin > end) std::swap(begin, end); std::vector vs; diff --git a/hpx/util/bind_action.hpp b/hpx/util/bind_action.hpp index 0dfb898e18b7..736b672439dc 100644 --- a/hpx/util/bind_action.hpp +++ b/hpx/util/bind_action.hpp @@ -110,13 +110,15 @@ namespace hpx { namespace util , BoundArgs& bound_args, UnboundArgs&& unbound_args ) { - return hpx::apply(std::forward(cont), bind_eval( + return hpx::apply(std::forward(cont), + bind_eval( util::get(bound_args), std::forward(unbound_args))...); } }; - template + template BOOST_FORCEINLINE typename boost::enable_if_c< traits::is_continuation::value, bool @@ -237,7 +239,8 @@ namespace hpx { namespace util >::type apply_c(Continuation && cont, Us&&... us) const { - return detail::bind_action_apply_cont2(std::forward(cont), + return detail::bind_action_apply_cont2 + (std::forward(cont), _bound_args, util::forward_as_tuple(std::forward(us)...)); } diff --git a/hpx/util/buffer_pool.hpp b/hpx/util/buffer_pool.hpp index 391abd418a84..976fe216a0ca 100644 --- a/hpx/util/buffer_pool.hpp +++ b/hpx/util/buffer_pool.hpp @@ -55,7 +55,8 @@ namespace hpx { namespace util { typename buffer_map_type::iterator it = buffers_.find(capacity); if(it == buffers_.end()) { - it = buffers_.insert(it, std::make_pair(capacity, std::list())); + it = buffers_.insert(it, std::make_pair(capacity, + std::list())); } it->second.push_back(buffer); } diff --git a/hpx/util/command_line_handling.hpp b/hpx/util/command_line_handling.hpp index ec3e410dc76d..c05a865d2d5d 100644 --- a/hpx/util/command_line_handling.hpp +++ b/hpx/util/command_line_handling.hpp @@ -20,7 +20,8 @@ namespace hpx { namespace util struct command_line_handling { command_line_handling(hpx::runtime_mode mode, - util::function_nonser const& f, + util::function_nonser + const& f, std::vector const& ini_config, char const* argv0) : rtcfg_(argv0), @@ -44,7 +45,8 @@ namespace hpx { namespace util hpx::runtime_mode mode_; std::vector ini_config_; - util::function_nonser hpx_main_f_; + util::function_nonser hpx_main_f_; std::size_t node_; std::size_t num_threads_; diff --git a/hpx/util/connection_cache.hpp b/hpx/util/connection_cache.hpp index 5c83ce6e6937..3c86929024b4 100644 --- a/hpx/util/connection_cache.hpp +++ b/hpx/util/connection_cache.hpp @@ -270,7 +270,8 @@ namespace hpx { namespace util // Otherwise, if we have less connections for this locality // than the maximum, try to reserve space in the cache for a new // connection. - if (num_existing_connections(it->second) < max_num_connections(it->second) || + if (num_existing_connections(it->second) < + max_num_connections(it->second) || force_insert) { // See if we have enough space or can make space available. @@ -366,7 +367,8 @@ namespace hpx { namespace util // Return the connection back to the cache only if the number // of connections does not need to be shrunk. - if (num_existing_connections(ct->second) <= max_num_connections(ct->second)) + if (num_existing_connections(ct->second) <= + max_num_connections(ct->second)) { // Add the connection to the entry. cached_connections(ct->second).push_back(conn); @@ -421,7 +423,8 @@ namespace hpx { namespace util typename cache_type::const_iterator ct = cache_.find(l); HPX_ASSERT(ct != cache_.end()); - return (num_existing_connections(ct->second) >= max_num_connections(ct->second)) + return (num_existing_connections(ct->second) >= + max_num_connections(ct->second)) || (connections_ >= max_connections_); } diff --git a/hpx/util/coroutine/coroutine.hpp b/hpx/util/coroutine/coroutine.hpp index 521936f0907b..0574524c95be 100644 --- a/hpx/util/coroutine/coroutine.hpp +++ b/hpx/util/coroutine/coroutine.hpp @@ -139,7 +139,8 @@ namespace hpx { namespace util { namespace coroutines template coroutine (Functor && f, naming::id_type && target, - thread_id_repr_type id = 0, std::ptrdiff_t stack_size = detail::default_stack_size) + thread_id_repr_type id = 0, std::ptrdiff_t stack_size = + detail::default_stack_size) : m_pimpl(impl_type::create(std::forward(f), std::move(target), id, stack_size)) { diff --git a/hpx/util/coroutine/detail/config.hpp b/hpx/util/coroutine/detail/config.hpp index 1ec4006f9722..47cc05d3a69b 100644 --- a/hpx/util/coroutine/detail/config.hpp +++ b/hpx/util/coroutine/detail/config.hpp @@ -12,7 +12,8 @@ #if defined(BOOST_WINDOWS) # define HPX_COROUTINE_SYMBOL_EXPORT __declspec(dllexport) # define HPX_COROUTINE_SYMBOL_IMPORT __declspec(dllimport) -#elif defined(HPX_HAVE_COROUTINE_GCC_HIDDEN_VISIBILITY) || defined(HPX_HAVE_ELF_HIDDEN_VISIBILITY) +#elif defined(HPX_HAVE_COROUTINE_GCC_HIDDEN_VISIBILITY) || defined \ + (HPX_HAVE_ELF_HIDDEN_VISIBILITY) # define HPX_COROUTINE_SYMBOL_EXPORT __attribute__((visibility("default"))) # define HPX_COROUTINE_SYMBOL_IMPORT __attribute__((visibility("default"))) #else diff --git a/hpx/util/coroutine/detail/context_generic_context.hpp b/hpx/util/coroutine/detail/context_generic_context.hpp index 677fb0d43a64..5d327ef67480 100644 --- a/hpx/util/coroutine/detail/context_generic_context.hpp +++ b/hpx/util/coroutine/detail/context_generic_context.hpp @@ -240,11 +240,13 @@ namespace hpx { namespace util { namespace coroutines typedef boost::atomic counter_type; HPX_COROUTINE_EXPORT static counter_type& get_stack_unbind_counter(); - HPX_COROUTINE_EXPORT static boost::uint64_t get_stack_unbind_count(bool reset); + HPX_COROUTINE_EXPORT static boost::uint64_t get_stack_unbind_count(bool + reset); HPX_COROUTINE_EXPORT static boost::uint64_t increment_stack_unbind_count(); HPX_COROUTINE_EXPORT static counter_type& get_stack_recycle_counter(); - HPX_COROUTINE_EXPORT static boost::uint64_t get_stack_recycle_count(bool reset); + HPX_COROUTINE_EXPORT static boost::uint64_t get_stack_recycle_count(bool + reset); HPX_COROUTINE_EXPORT static boost::uint64_t increment_stack_recycle_count(); private: diff --git a/hpx/util/coroutine/detail/context_linux_x86.hpp b/hpx/util/coroutine/detail/context_linux_x86.hpp index e396cf54a3fd..c3bf848b4719 100644 --- a/hpx/util/coroutine/detail/context_linux_x86.hpp +++ b/hpx/util/coroutine/detail/context_linux_x86.hpp @@ -170,7 +170,8 @@ namespace hpx { namespace util { namespace coroutines if (0 >= m_stack_size) { throw std::runtime_error( - boost::str(boost::format("stack size of %1% is invalid") % m_stack_size)); + boost::str(boost::format("stack size of %1% is invalid") % + m_stack_size)); } m_stack = posix::alloc_stack(static_cast(m_stack_size)); diff --git a/hpx/util/coroutine/detail/context_posix.hpp b/hpx/util/coroutine/detail/context_posix.hpp index 855e69f63839..ab21be9932fe 100644 --- a/hpx/util/coroutine/detail/context_posix.hpp +++ b/hpx/util/coroutine/detail/context_posix.hpp @@ -49,7 +49,8 @@ #include #include -#if defined(__FreeBSD__) || (defined(_XOPEN_UNIX) && defined(_XOPEN_VERSION) && _XOPEN_VERSION >= 500) +#if defined(__FreeBSD__) || (defined(_XOPEN_UNIX) && defined(_XOPEN_VERSION) \ + && _XOPEN_VERSION >= 500) // OS X 10.4 -- despite passing the test above -- doesn't support // swapcontext() et al. Use GNU Pth workalike functions. @@ -210,7 +211,8 @@ namespace hpx { namespace util { namespace coroutines { */ template explicit ucontext_context_impl(Functor & cb, std::ptrdiff_t stack_size) - : m_stack_size(stack_size == -1 ? (std::ptrdiff_t)default_stack_size : stack_size), + : m_stack_size(stack_size == -1 ? (std::ptrdiff_t)default_stack_size + : stack_size), m_stack(alloc_stack(m_stack_size)), cb_(&cb) { @@ -248,7 +250,8 @@ namespace hpx { namespace util { namespace coroutines { void rebind_stack() { if (m_stack) { - // just reset the context stack pointer to its initial value at the stack start + // just reset the context stack pointer to its initial value at + // the stack start increment_stack_recycle_count(); int error = HPX_COROUTINE_MAKE_CONTEXT( &m_ctx, m_stack, m_stack_size, funp_, cb_, NULL); diff --git a/hpx/util/coroutine/detail/context_windows_fibers.hpp b/hpx/util/coroutine/detail/context_windows_fibers.hpp index 661a5049b772..54234209c684 100644 --- a/hpx/util/coroutine/detail/context_windows_fibers.hpp +++ b/hpx/util/coroutine/detail/context_windows_fibers.hpp @@ -78,7 +78,8 @@ namespace hpx { namespace util { namespace coroutines #if _WIN32_WINNT < 0x0600 /* * This number (0x1E00) has been sighted in the wild (at least on windows XP systems) - * as return value from GetCurrentFiber() on non fibrous threads. This is somehow related + * as return value from GetCurrentFiber() on non fibrous threads. + * This is somehow related * to OS/2 where the current fiber pointer is overloaded as a version field. * On non-NT systems, 0 is returned. */ diff --git a/hpx/util/coroutine/detail/coroutine_impl.hpp b/hpx/util/coroutine/detail/coroutine_impl.hpp index c9707210aa5f..b4330af0b06e 100644 --- a/hpx/util/coroutine/detail/coroutine_impl.hpp +++ b/hpx/util/coroutine/detail/coroutine_impl.hpp @@ -374,14 +374,18 @@ namespace hpx { namespace util { namespace coroutines { namespace detail // default macro sizes if (stacksize > HPX_MEDIUM_STACK_SIZE) { if (stacksize > HPX_LARGE_STACK_SIZE) - return get_heap(i % (HPX_COROUTINE_NUM_HEAPS/4)); //-V112 + return get_heap(i % (HPX_COROUTINE_NUM_HEAPS/4)); //-V112 - return get_heap(i % (HPX_COROUTINE_NUM_HEAPS/4)); //-V112 + return get_heap(i % (HPX_COROUTINE_NUM_HEAPS/4)); //-V112 } if (stacksize > HPX_SMALL_STACK_SIZE) - return get_heap(i % (HPX_COROUTINE_NUM_HEAPS/2)); + return get_heap(i % (HPX_COROUTINE_NUM_HEAPS/2)); - return get_heap(i % HPX_COROUTINE_NUM_HEAPS); + return get_heap(i % HPX_COROUTINE_NUM_HEAPS); } public: diff --git a/hpx/util/coroutine/detail/default_context_impl.hpp b/hpx/util/coroutine/detail/default_context_impl.hpp index 4a6b780d50d9..a52eafeb275a 100644 --- a/hpx/util/coroutine/detail/default_context_impl.hpp +++ b/hpx/util/coroutine/detail/default_context_impl.hpp @@ -116,7 +116,8 @@ namespace hpx { namespace util { namespace coroutines { namespace detail #error Boost.Context is available only with Boost V1.51 or later #endif -#elif (defined(__linux) || defined(linux) || defined(__linux__)) && !defined(__bgq__) && !defined(__powerpc__) +#elif (defined(__linux) || defined(linux) || defined(__linux__)) \ + && !defined(__bgq__) && !defined(__powerpc__) #include namespace hpx { namespace util { namespace coroutines { namespace detail diff --git a/hpx/util/coroutine/detail/has_swap.hpp b/hpx/util/coroutine/detail/has_swap.hpp index 3aa76bc248de..d8eb61ea279c 100644 --- a/hpx/util/coroutine/detail/has_swap.hpp +++ b/hpx/util/coroutine/detail/has_swap.hpp @@ -54,7 +54,8 @@ namespace has_swap_ #if defined(BOOST_MSVC) # pragma warning(push) -# pragma warning(disable: 4675) // function found through argument dependent lookup -- duh! +# pragma warning(disable: 4675) +// function found through argument dependent lookup -- duh! #endif template struct has_swap_impl diff --git a/hpx/util/coroutine/detail/posix_utility.hpp b/hpx/util/coroutine/detail/posix_utility.hpp index d7ef58f04385..95902b055175 100644 --- a/hpx/util/coroutine/detail/posix_utility.hpp +++ b/hpx/util/coroutine/detail/posix_utility.hpp @@ -67,11 +67,13 @@ /** * Stack allocation routines and trampolines for setcontext */ -namespace hpx { namespace util { namespace coroutines { namespace detail { namespace posix { +namespace hpx { namespace util { namespace coroutines { namespace detail +{ namespace posix { HPX_EXPORT extern bool use_guard_pages; -#if defined(HPX_HAVE_THREAD_STACK_MMAP) && defined(_POSIX_MAPPED_FILES) && _POSIX_MAPPED_FILES > 0 +#if defined(HPX_HAVE_THREAD_STACK_MMAP) && defined(_POSIX_MAPPED_FILES) \ + && _POSIX_MAPPED_FILES > 0 inline void* @@ -103,7 +105,8 @@ HPX_EXPORT extern bool use_guard_pages; // Add a guard page. ::mprotect(real_stack, EXEC_PAGESIZE, PROT_NONE); - void** stack = static_cast(real_stack) + (EXEC_PAGESIZE / sizeof(void*)); + void** stack = static_cast(real_stack) + (EXEC_PAGESIZE + / sizeof(void*)); return static_cast(stack); } return real_stack; @@ -117,13 +120,15 @@ HPX_EXPORT extern bool use_guard_pages; HPX_ASSERT(size > EXEC_PAGESIZE); // Fill the bottom 8 bytes of the first page with 1s. - void** watermark = static_cast(stack) + ((size - EXEC_PAGESIZE) / sizeof(void*)); + void** watermark = static_cast(stack) + ((size - EXEC_PAGESIZE) + / sizeof(void*)); *watermark = reinterpret_cast(0xDEADBEEFDEADBEEFull); } inline bool reset_stack(void* stack, std::size_t size) { - void** watermark = static_cast(stack) + ((size - EXEC_PAGESIZE) / sizeof(void*)); + void** watermark = static_cast(stack) + ((size - EXEC_PAGESIZE) + / sizeof(void*)); // If the watermark has been overwritten, then we've gone past the first // page. @@ -253,7 +258,8 @@ HPX_EXPORT extern bool use_guard_pages; //# error "Anonymous mmap not available on this platform!" //#endif // -//namespace hpx { namespace util { namespace coroutines { namespace detail { namespace posix { +//namespace hpx { namespace util { namespace coroutines +// { namespace detail { namespace posix { // inline // void * // alloc_stack_mmap(std::size_t size) { diff --git a/hpx/util/detail/basic_function.hpp b/hpx/util/detail/basic_function.hpp index f0c5c4604420..a3a8c7f8c33c 100644 --- a/hpx/util/detail/basic_function.hpp +++ b/hpx/util/detail/basic_function.hpp @@ -139,7 +139,8 @@ namespace hpx { namespace util { namespace detail return !empty(); } # else - operator typename util::safe_bool::result_type() const BOOST_NOEXCEPT + operator typename util::safe_bool + ::result_type() const BOOST_NOEXCEPT { return util::safe_bool()(!empty()); } diff --git a/hpx/util/detail/function_registration.hpp b/hpx/util/detail/function_registration.hpp index ce3e537bb528..f6fcb46bd1c9 100644 --- a/hpx/util/detail/function_registration.hpp +++ b/hpx/util/detail/function_registration.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -81,7 +82,7 @@ namespace hpx { namespace util { namespace detail { hpx::serialization::detail::polymorphic_intrusive_factory::instance(). register_class( - detail::get_function_name >() + detail::get_function_name >() , &function_registration::create ); } @@ -109,8 +110,8 @@ namespace hpx { namespace util { namespace detail automatic_function_registration() { function_registration< - typename VTablePair::first_type - , typename VTablePair::second_type + typename util::tuple_element<0, VTablePair>::type + , typename util::tuple_element<1, VTablePair>::type > auto_register; } diff --git a/hpx/util/detail/function_template.hpp b/hpx/util/detail/function_template.hpp index a1e3a6a7d453..e83534cb8970 100644 --- a/hpx/util/detail/function_template.hpp +++ b/hpx/util/detail/function_template.hpp @@ -9,8 +9,9 @@ #define HPX_UTIL_DETAIL_FUNCTION_TEMPLATE_HPP #include -#include +#include #include +#include #include #include #include @@ -81,9 +82,9 @@ namespace hpx { namespace util { namespace detail , load_object(&serializable_vtable::template load_object) { if(!this->empty) - name = get_function_name >(); + name = get_function_name >(); init_registration< - std::pair + util::tuple >::g.register_function(); } }; @@ -92,21 +93,21 @@ namespace hpx { namespace util { namespace detail // registration code for serialization template struct init_registration< - std::pair, T> + util::tuple, T> > { - typedef std::pair, T> vtable_ptr; + typedef util::tuple, T> vtable_ptr; static automatic_function_registration g; }; template automatic_function_registration< - std::pair, T> + util::tuple, T> > init_registration< - std::pair, T> + util::tuple, T> >::g = automatic_function_registration< - std::pair, T> + util::tuple, T> >(); }}} @@ -319,7 +320,8 @@ namespace hpx { namespace util }; template - static bool is_empty_function(function const& f) BOOST_NOEXCEPT + static bool is_empty_function(function const& f) BOOST_NOEXCEPT { return f.empty(); } diff --git a/hpx/util/detail/pp_strip_parens.hpp b/hpx/util/detail/pp_strip_parens.hpp index 52d5e4694a41..9e21d5985f2b 100644 --- a/hpx/util/detail/pp_strip_parens.hpp +++ b/hpx/util/detail/pp_strip_parens.hpp @@ -21,13 +21,18 @@ #define HPX_UTIL_DETAILS_APPLY_I(macro, args) macro args #define HPX_UTIL_DETAILS_STRIP_PARENS_I(...) 1,1 #define HPX_UTIL_DETAILS_EVAL(test, x) HPX_UTIL_DETAILS_EVAL_I(test, x) -#define HPX_UTIL_DETAILS_EVAL_I(test, x) HPX_UTIL_DETAILS_MAYBE_STRIP_PARENS(HPX_UTIL_DETAILS_TEST_ARITY test, x) -#define HPX_UTIL_DETAILS_TEST_ARITY(...) HPX_UTIL_DETAILS_APPLY(HPX_UTIL_DETAILS_TEST_ARITY_I, (__VA_ARGS__, 2, 1, 0)) +#define HPX_UTIL_DETAILS_EVAL_I(test, x) \ + HPX_UTIL_DETAILS_MAYBE_STRIP_PARENS(HPX_UTIL_DETAILS_TEST_ARITY test, x) +#define HPX_UTIL_DETAILS_TEST_ARITY(...) \ + HPX_UTIL_DETAILS_APPLY(HPX_UTIL_DETAILS_TEST_ARITY_I, (__VA_ARGS__, 2, 1, 0)) #define HPX_UTIL_DETAILS_TEST_ARITY_I(a,b,c,...) c -#define HPX_UTIL_DETAILS_MAYBE_STRIP_PARENS(cond, x) HPX_UTIL_DETAILS_MAYBE_STRIP_PARENS_I(cond, x) -#define HPX_UTIL_DETAILS_MAYBE_STRIP_PARENS_I(cond, x) BOOST_PP_CAT(HPX_UTIL_DETAILS_MAYBE_STRIP_PARENS_, cond)(x) +#define HPX_UTIL_DETAILS_MAYBE_STRIP_PARENS(cond, x) \ + HPX_UTIL_DETAILS_MAYBE_STRIP_PARENS_I(cond, x) +#define HPX_UTIL_DETAILS_MAYBE_STRIP_PARENS_I(cond, x) \ + BOOST_PP_CAT(HPX_UTIL_DETAILS_MAYBE_STRIP_PARENS_, cond)(x) #define HPX_UTIL_DETAILS_MAYBE_STRIP_PARENS_1(x) x -#define HPX_UTIL_DETAILS_MAYBE_STRIP_PARENS_2(x) HPX_UTIL_DETAILS_APPLY(HPX_UTIL_DETAILS_MAYBE_STRIP_PARENS_2_I, x) +#define HPX_UTIL_DETAILS_MAYBE_STRIP_PARENS_2(x) \ + HPX_UTIL_DETAILS_APPLY(HPX_UTIL_DETAILS_MAYBE_STRIP_PARENS_2_I, x) #define HPX_UTIL_DETAILS_MAYBE_STRIP_PARENS_2_I(...) __VA_ARGS__ //============================================================================== diff --git a/hpx/util/detail/unique_function_template.hpp b/hpx/util/detail/unique_function_template.hpp index 76d9370789da..38bf0d5a2542 100644 --- a/hpx/util/detail/unique_function_template.hpp +++ b/hpx/util/detail/unique_function_template.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -71,12 +72,12 @@ namespace hpx { namespace util { namespace detail template unique_function_vtable_ptr(boost::mpl::identity) BOOST_NOEXCEPT : unique_function_vtable_ptr(boost::mpl::identity()) - , name(get_function_name >()) + , name(get_function_name >()) , save_object(&serializable_vtable::template save_object) , load_object(&serializable_vtable::template load_object) { init_registration< - std::pair + util::tuple >::g.register_function(); } }; @@ -85,21 +86,21 @@ namespace hpx { namespace util { namespace detail // registration code for serialization template struct init_registration< - std::pair, T> + util::tuple, T> > { - typedef std::pair, T> vtable_ptr; + typedef util::tuple, T> vtable_ptr; static automatic_function_registration g; }; template automatic_function_registration< - std::pair, T> + util::tuple, T> > init_registration< - std::pair, T> + util::tuple, T> >::g = automatic_function_registration< - std::pair, T> + util::tuple, T> >(); }}} @@ -253,7 +254,8 @@ namespace hpx { namespace util }; template - static bool is_empty_function(unique_function const& f) BOOST_NOEXCEPT + static bool is_empty_function(unique_function const& f) BOOST_NOEXCEPT { return f.empty(); } diff --git a/hpx/util/filesystem_compatibility.hpp b/hpx/util/filesystem_compatibility.hpp index 785020a9ef05..77babfa4f48d 100644 --- a/hpx/util/filesystem_compatibility.hpp +++ b/hpx/util/filesystem_compatibility.hpp @@ -40,7 +40,8 @@ namespace hpx { namespace util #if BOOST_FILESYSTEM_VERSION >= 3 return boost::filesystem::path(back == ':' ? p.substr(0, p.size()-1) : p); #else - return boost::filesystem::path(back == ':' ? p.substr(0, p.size()-1) : p, boost::filesystem::native); + return boost::filesystem::path(back == ':' ? p.substr(0, p.size()-1) + : p, boost::filesystem::native); #endif } diff --git a/hpx/util/function.hpp b/hpx/util/function.hpp index d76915a676e9..eb92741dfd5c 100644 --- a/hpx/util/function.hpp +++ b/hpx/util/function.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -21,10 +22,12 @@ /////////////////////////////////////////////////////////////////////////////// #define HPX_CONTINUATION_REGISTER_FUNCTION_FACTORY(VTable, Name) \ static ::hpx::util::detail::function_registration< \ - VTable::first_type, VTable::second_type \ + ::hpx::util::tuple_element<0, VTable>::type \ + , ::hpx::util::tuple_element<1, VTable>::type \ > const BOOST_PP_CAT(Name, _function_factory_registration) = \ ::hpx::util::detail::function_registration< \ - VTable::first_type, VTable::second_type \ + ::hpx::util::tuple_element<0, VTable>::type \ + , ::hpx::util::tuple_element<1, VTable>::type \ >(); \ /**/ @@ -38,7 +41,7 @@ #define HPX_UTIL_REGISTER_FUNCTION_DECLARATION(Sig, Functor, Name) \ namespace hpx { namespace util { namespace detail { \ typedef \ - std::pair< \ + hpx::util::tuple< \ function_vtable_ptr< \ Sig \ , ::hpx::serialization::input_archive \ diff --git a/hpx/util/functional/colocated_helpers.hpp b/hpx/util/functional/colocated_helpers.hpp index 32ee1e3d5a3c..5c11b7205e86 100644 --- a/hpx/util/functional/colocated_helpers.hpp +++ b/hpx/util/functional/colocated_helpers.hpp @@ -50,6 +50,8 @@ namespace hpx { namespace util { namespace functional template struct apply_continuation_impl { + HPX_MOVABLE_BUT_NOT_COPYABLE(apply_continuation_impl); + public: typedef typename util::decay::type bound_type; template @@ -70,7 +72,8 @@ namespace hpx { namespace util { namespace functional explicit apply_continuation_impl( Bound && bound, Continuation && c) : bound_(std::move(bound)), - cont_(new typename util::decay::type(std::forward(c))) + cont_(new typename + util::decay::type(std::forward(c))) {} apply_continuation_impl(apply_continuation_impl && o) @@ -155,6 +158,8 @@ namespace hpx { namespace util { namespace functional template struct async_continuation_impl { + HPX_MOVABLE_BUT_NOT_COPYABLE(async_continuation_impl); + public: typedef typename util::decay::type bound_type; template @@ -175,7 +180,8 @@ namespace hpx { namespace util { namespace functional explicit async_continuation_impl( Bound && bound, Continuation && c) : bound_(std::move(bound)), - cont_(new typename util::decay::type(std::forward(c))) + cont_(new typename util::decay + ::type(std::forward(c))) {} async_continuation_impl(async_continuation_impl && o) diff --git a/hpx/util/interval_timer.hpp b/hpx/util/interval_timer.hpp index 6cce960aca46..7f4e1854447f 100644 --- a/hpx/util/interval_timer.hpp +++ b/hpx/util/interval_timer.hpp @@ -88,7 +88,8 @@ namespace hpx { namespace util { namespace detail bool pre_shutdown_; ///< execute termination during pre-shutdown bool is_started_; ///< timer has been started (is running) - bool first_start_; ///< flag to distinguish first invocation of start() + bool first_start_; + ///^ flag to distinguish first invocation of start() bool is_terminated_; ///< The timer has been terminated bool is_stopped_; }; diff --git a/hpx/util/invoke.hpp b/hpx/util/invoke.hpp index 14b6c95305a2..c0f275dd470c 100644 --- a/hpx/util/invoke.hpp +++ b/hpx/util/invoke.hpp @@ -186,7 +186,8 @@ namespace hpx { namespace util template HPX_MAYBE_FORCEINLINE typename boost::disable_if_c< - boost::is_function::type>::type>::value + boost::is_function::type>::type>::value || boost::is_member_pointer::type>::value || boost::is_reference_wrapper::type>::value , R @@ -230,7 +231,8 @@ namespace hpx { namespace util template HPX_MAYBE_FORCEINLINE typename boost::disable_if_c< - boost::is_function::type>::type>::value + boost::is_function::type>::type>::value || boost::is_member_function_pointer::type>::value , typename invoke_result_of::type >::type diff --git a/hpx/util/io_service_pool.hpp b/hpx/util/io_service_pool.hpp index afcd639d97b7..710c4336765c 100644 --- a/hpx/util/io_service_pool.hpp +++ b/hpx/util/io_service_pool.hpp @@ -35,9 +35,11 @@ namespace hpx { namespace util /// \param start_thread /// [in] explicit io_service_pool(std::size_t pool_size = 2, - util::function_nonser const& on_start_thread = - util::function_nonser(), - util::function_nonser const& on_stop_thread = util::function_nonser(), + util::function_nonser + const& on_start_thread = util::function_nonser(), + util::function_nonser const& on_stop_thread = + util::function_nonser(), char const* pool_name = "", char const* name_postfix = ""); /// \brief Construct the io_service pool. @@ -45,7 +47,8 @@ namespace hpx { namespace util /// [in] explicit io_service_pool( util::function_nonser const& on_start_thread, - util::function_nonser const& on_stop_thread = util::function_nonser(), + util::function_nonser const& on_stop_thread = + util::function_nonser(), char const* pool_name = "", char const* name_postfix = ""); ~io_service_pool(); diff --git a/hpx/util/itt_notify.hpp b/hpx/util/itt_notify.hpp index 51cf79f05da3..b525587877c2 100644 --- a/hpx/util/itt_notify.hpp +++ b/hpx/util/itt_notify.hpp @@ -116,7 +116,8 @@ HPX_EXPORT void itt_heap_allocate_end(__itt_heap_function, void**, std::size_t, HPX_EXPORT void itt_heap_free_begin(__itt_heap_function, void*); HPX_EXPORT void itt_heap_free_end(__itt_heap_function, void*); HPX_EXPORT void itt_heap_reallocate_begin(__itt_heap_function, void*, std::size_t, int); -HPX_EXPORT void itt_heap_reallocate_end(__itt_heap_function, void*, void**, std::size_t, int); +HPX_EXPORT void itt_heap_reallocate_end(__itt_heap_function, void*, void**, + std::size_t, int); HPX_EXPORT void itt_heap_internal_access_begin(); HPX_EXPORT void itt_heap_internal_access_end(); @@ -284,7 +285,8 @@ namespace hpx { namespace util { namespace itt struct heap_allocate { template - heap_allocate(heap_function& heap_function, T**& addr, std::size_t size, int init) + heap_allocate(heap_function& heap_function, T**& addr, std::size_t size, + int init) : heap_function_(heap_function), addr_(reinterpret_cast(addr)), size_(size), init_(init) { @@ -293,7 +295,8 @@ namespace hpx { namespace util { namespace itt ~heap_allocate() { - HPX_ITT_HEAP_ALLOCATE_END(heap_function_.heap_function_, addr_, size_, init_); + HPX_ITT_HEAP_ALLOCATE_END(heap_function_.heap_function_, addr_, + size_, init_); } private: @@ -358,13 +361,15 @@ inline ___itt_id* itt_make_id(void*, unsigned long) { return 0; } inline void itt_id_create(___itt_domain const*, ___itt_id*) {} inline void itt_id_destroy(___itt_id*) {} -inline __itt_heap_function itt_heap_function_create(const char*, const char*) { return 0; } +inline __itt_heap_function itt_heap_function_create(const char*, + const char*) { return 0; } inline void itt_heap_allocate_begin(__itt_heap_function, std::size_t, int) {} inline void itt_heap_allocate_end(__itt_heap_function, void**, std::size_t, int) {} inline void itt_heap_free_begin(__itt_heap_function, void*) {} inline void itt_heap_free_end(__itt_heap_function, void*) {} inline void itt_heap_reallocate_begin(__itt_heap_function, void*, std::size_t, int) {} -inline void itt_heap_reallocate_end(__itt_heap_function, void*, void**, std::size_t, int) {} +inline void itt_heap_reallocate_end(__itt_heap_function, void*, void**, + std::size_t, int) {} inline void itt_heap_internal_access_begin() {} inline void itt_heap_internal_access_end() {} diff --git a/hpx/util/logging/defaults.hpp b/hpx/util/logging/defaults.hpp index ac3bb9eafda3..b9177cd5c922 100644 --- a/hpx/util/logging/defaults.hpp +++ b/hpx/util/logging/defaults.hpp @@ -35,12 +35,14 @@ The logging lib has a few default types, used throughout the lib. They are: - @c hold_string_type - the type used to hold a string; by default, it's @c std::string - @c filter_type - the default filter; by default, it's filter::no_ts - @c lock_resource - used to lock resources for access. See locker namespace. -- @c mutex - the mutex class used throughout the library. By default, it's mutex_win32 for Windows, or mutex_posix for POSIX +- @c mutex - the mutex class used throughout the library. By default, +- it's mutex_win32 for Windows, or mutex_posix for POSIX They are all present in @c default_types structure. If you want to override any of the above, you should do the following: -- before including anything from Boost Logging Library, \#include +- before including anything from Boost Logging Library, + \#include - override the types - do \#include @@ -108,9 +110,11 @@ If you want to override any of the above, you should do the following: template struct finder { //#if !defined( HPX_HAVE_LOG_NO_TSS) && defined(BOOST_WINDOWS) // on Windows, I've tested the threading -// typedef typename locker::tss_resource_with_cache type; +// typedef typename locker::tss_resource_with_cache type; //#else - typedef typename locker::ts_resource type; + typedef typename locker::ts_resource type; //#endif }; }; diff --git a/hpx/util/logging/detail/after_being_destroyed.hpp b/hpx/util/logging/detail/after_being_destroyed.hpp index 987ae59586a8..1194db474305 100644 --- a/hpx/util/logging/detail/after_being_destroyed.hpp +++ b/hpx/util/logging/detail/after_being_destroyed.hpp @@ -17,7 +17,8 @@ #ifndef JT28092007_after_being_destroyed_HPP_DEFINED #define JT28092007_after_being_destroyed_HPP_DEFINED -// see "Using the logger(s)/filter(s) after they've been destroyed" section in the documentation +// see "Using the logger(s)/filter(s) after they've been destroyed" section in +// the documentation #error this is obsolete #if defined(_MSC_VER) && (_MSC_VER >= 1020) @@ -26,7 +27,9 @@ #include -#if !defined(HPX_LOG_AFTER_BEING_DESTROYED_WRITE_TO_FUNCTION) && !defined(HPX_LOG_AFTER_BEING_DESTROYED_IGNORE) && !defined(HPX_LOG_AFTER_BEING_DESTROYED_LEAK_LOGGER) +#if !defined(HPX_LOG_AFTER_BEING_DESTROYED_WRITE_TO_FUNCTION) \ + && !defined(HPX_LOG_AFTER_BEING_DESTROYED_IGNORE) \ + && !defined(HPX_LOG_AFTER_BEING_DESTROYED_LEAK_LOGGER) // default #define HPX_LOG_AFTER_BEING_DESTROYED_WRITE_TO_FUNCTION #endif @@ -46,7 +49,8 @@ namespace destination { template struct msg_type; } deals with what to do with the logger, if used after it's been destroyed @remarks - we need to make this a template, in order to postpone figuring out the gather_msg msg_type + we need to make this a template, in order to postpone figuring + out the gather_msg msg_type (so that we can wait until the user has specified the msg_type */ @@ -63,7 +67,8 @@ namespace destination { template struct msg_type; } m_after_being_destroyed(msg); } - after_being_destroyed_defer_to_function () : m_is_destroyed(false), m_after_being_destroyed(¬hing) {} + after_being_destroyed_defer_to_function () : m_is_destroyed(false), + m_after_being_destroyed(¬hing) {} ~after_being_destroyed_defer_to_function () { m_is_destroyed = true; } diff --git a/hpx/util/logging/detail/cache_before_init.hpp b/hpx/util/logging/detail/cache_before_init.hpp index e5090841d472..7f5c1f521203 100644 --- a/hpx/util/logging/detail/cache_before_init.hpp +++ b/hpx/util/logging/detail/cache_before_init.hpp @@ -52,12 +52,14 @@ inline thread_id_type get_thread_id() #endif } -#if defined( HPX_LOG_BEFORE_INIT_USE_CACHE_FILTER) || defined( HPX_LOG_BEFORE_INIT_USE_LOG_ALL) +#if defined( HPX_LOG_BEFORE_INIT_USE_CACHE_FILTER) \ + || defined( HPX_LOG_BEFORE_INIT_USE_LOG_ALL) ////////////////////////////////////////////////////////////////// // Messages that were logged before initializing the log - Caching them /** - The library will make sure your logger derives from this in case you want to cache messages that are logged before logs are initialized. + The library will make sure your logger derives from this in case you want to + cache messages that are logged before logs are initialized. Note: - you should initialize your logs ASAP @@ -69,7 +71,8 @@ template struct cache_before_init { typedef bool (*is_enabled_func)(); struct message { - message(is_enabled_func is_enabled_, msg_type string_) : is_enabled(is_enabled_), string(string_) {} + message(is_enabled_func is_enabled_, msg_type string_) + : is_enabled(is_enabled_), string(string_) {} // function that sees if the filter is enabled or not is_enabled_func is_enabled; // the message itself @@ -122,7 +125,8 @@ template struct cache_before_init { mutex::scoped_lock lk(m_cs); std::swap( m_cache.msgs, msgs); } - for ( typename cache::message_array::iterator b = msgs.begin(), e = msgs.end(); b != e; ++b) { + for ( typename cache::message_array::iterator b = msgs.begin(), + e = msgs.end(); b != e; ++b) { if ( !(b->is_enabled) ) // no filter writer_( b->string ); @@ -134,7 +138,8 @@ template struct cache_before_init { void add_msg(const msg_type & msg) const { mutex::scoped_lock lk(m_cs); - // note : last_enabled can be null, if we don't want to use filters (HPX_LOG_BEFORE_INIT_USE_LOG_ALL) + // note : last_enabled can be null, if we don't want to use filters + // (HPX_LOG_BEFORE_INIT_USE_LOG_ALL) is_enabled_func func = m_cache.threads[ get_thread_id() ].last_enabled ; m_cache.msgs.push_back( message(func, msg) ); } @@ -149,15 +154,18 @@ template struct cache_before_init { mutable mutex m_cs; mutable cache m_cache; /** - IMPORTANT: to make sure we know when the cache is off as efficiently as possible, I have this mechanism: + IMPORTANT: to make sure we know when the cache is off as efficiently as possible, + I have this mechanism: - first, query m_is_enabled, which at the beginning is false - if this is true, it's clear that caching has been turned off - if this is false, we don't know for sure, thus, continue to ask - - second, use the thread-safe resource 'm_cache' (use a mutex, a bit slow, but that's life) + - second, use the thread-safe resource 'm_cache' (use a mutex, + a bit slow, but that's life) - if m_cache.is_using_cache is true, we're still using cache - if m_cache.is_using_cache is false, caching has been turned off - - set m_is_enabled to true, thus this will propagate to all threads soon (depending on your lock_resource) + - set m_is_enabled to true, thus this will propagate to all threads soon + (depending on your lock_resource) */ mutable bool m_is_caching_off; }; diff --git a/hpx/util/logging/detail/cache_before_init_macros.hpp b/hpx/util/logging/detail/cache_before_init_macros.hpp index be2ed42a34a9..dc494b4b1fe1 100644 --- a/hpx/util/logging/detail/cache_before_init_macros.hpp +++ b/hpx/util/logging/detail/cache_before_init_macros.hpp @@ -44,7 +44,7 @@ namespace hpx { namespace util { namespace logging { #if defined( HPX_LOG_BEFORE_INIT_USE_CACHE_FILTER) -///////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////// // Messages that were logged before initializing the log - cache the message & the filter #define HPX_LOG_USE_LOG(l, do_func, is_log_enabled) \ @@ -58,22 +58,27 @@ namespace hpx { namespace util { namespace logging { if ( ::hpx::util::logging::get_logger_base( l )->is_cache_turned_off() )\ ; \ else \ - ::hpx::util::logging::get_logger_base( l )->cache().set_callback( &is_enabled_callback ); \ + ::hpx::util::logging::get_logger_base( l )->cache().set_callback \ + ( &is_enabled_callback ); \ } \ - } param = ( !(is_log_enabled) ) ? (void*)0 : ::hpx::util::logging::get_logger_base( l )-> do_func + } param = ( !(is_log_enabled) ) ? (void*)0 : \ + ::hpx::util::logging::get_logger_base( l )-> do_func #elif defined( HPX_LOG_BEFORE_INIT_USE_LOG_ALL) -///////////////////////////////////////////////////////////////////////////////////////////// -// Messages that were logged before initializing the log - cache the message (and I'll write it even if the filter is turned off) +/////////////////////////////////////////////////////////////////////////////////// +// Messages that were logged before initializing the log +// - cache the message (and I'll write it even if the filter is turned off) -#define HPX_LOG_USE_LOG(l, do_func, is_log_enabled) if ( !(is_log_enabled) ) ; else ::hpx::util::logging::get_logger_base(l)-> do_func +#define HPX_LOG_USE_LOG(l, do_func, is_log_enabled) if ( !(is_log_enabled) ) ; \ + else ::hpx::util::logging::get_logger_base(l)-> do_func #elif defined( HPX_LOG_BEFORE_INIT_USE_IGNORE_BEFORE_INIT) -///////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////// // Messages that were logged before initializing the log - ignore them completely -#define HPX_LOG_USE_LOG(l, do_func, is_log_enabled) if ( !(is_log_enabled) ) ; else ::hpx::util::logging::get_logger_base(l)-> do_func +#define HPX_LOG_USE_LOG(l, do_func, is_log_enabled) if ( !(is_log_enabled) ) ; \ + else ::hpx::util::logging::get_logger_base(l)-> do_func #else #error Internal error. diff --git a/hpx/util/logging/detail/filter.hpp b/hpx/util/logging/detail/filter.hpp index cf301c9f076c..d42321c4e09c 100644 --- a/hpx/util/logging/detail/filter.hpp +++ b/hpx/util/logging/detail/filter.hpp @@ -28,13 +28,15 @@ namespace hpx { namespace util { /** - @brief Root namespace. All the logging lib is contained in this namespace, or sub-namespaces of this one. + @brief Root namespace. All the logging lib is contained in this namespace, + or sub-namespaces of this one. */ namespace logging { /** - @brief Contains filter implementations. A filter tells the logger if it's enabled or not. + @brief Contains filter implementations. A filter tells the logger if + it's enabled or not. The %filter namespace contains a few implementations of %filter classes. @@ -53,7 +55,8 @@ namespace logging { }; @endcode - In your logger, you can use any filter class that's already here, or implement your own. Implementing a filter is usually as easy as it gets: + In your logger, you can use any filter class that's already here, + or implement your own. Implementing a filter is usually as easy as it gets: @code struct filter_no_ts { @@ -168,13 +171,15 @@ struct ts { @remarks - Another implementation can be done, which could be faster - where you retrieve the "is_enabled" each X calls on a given thread + Another implementation can be done, which could be faster + - where you retrieve the "is_enabled" each X calls on a given thread (like, every 20 calls on a given thread) */ template struct use_tss_with_cache { typedef locker::tss_resource_with_cache data; - use_tss_with_cache(int cache_secs = default_cache_secs) : m_enabled(true, cache_secs) {} + use_tss_with_cache(int cache_secs = default_cache_secs) + : m_enabled(true, cache_secs) {} bool is_enabled() const { typename data::read enabled(m_enabled); return enabled.use(); @@ -188,7 +193,9 @@ template struct use_tss_with_cache { }; /** - @brief Uses TSS (Thread Specific Storage) to find out if a filter is enabled or not. Once the filter is initialized to a value, that value will always be used. + @brief Uses TSS (Thread Specific Storage) to find out if a filter is + enabled or not. Once the filter is initialized to a value, + that value will always be used. */ struct use_tss_once_init { diff --git a/hpx/util/logging/detail/find_format_writer.hpp b/hpx/util/logging/detail/find_format_writer.hpp index bdc20e0669bc..ec8d372a2ca5 100644 --- a/hpx/util/logging/detail/find_format_writer.hpp +++ b/hpx/util/logging/detail/find_format_writer.hpp @@ -37,14 +37,18 @@ namespace destination { } namespace msg_route { - template struct simple ; - template class with_route; + template struct simple ; + template class with_route; } namespace format_and_write { template struct simple ; - template struct use_cache ; + template struct use_cache ; } namespace array { template class shared_ptr_holder ; @@ -66,27 +70,40 @@ namespace writer { namespace detail { //////////// find_format_write_params - template struct find_format_write_params { - typedef typename ::hpx::util::logging::format_and_write::simple apply_format_and_write ; - typedef typename ::hpx::util::logging::msg_route::simple router_type; + template struct find_format_write_params { + typedef typename ::hpx::util::logging::format_and_write::simple + apply_format_and_write ; + typedef typename ::hpx::util::logging::msg_route::simple router_type; }; - template - struct find_format_write_params< typename hpx::util::logging::optimize::cache_string_several_str, formatter_base, destination_base, lock_resource> + template + struct find_format_write_params< typename hpx::util + ::logging::optimize::cache_string_several_str, + formatter_base, destination_base, lock_resource> { - typedef typename hpx::util::logging::optimize::cache_string_several_str cache_string; - typedef typename hpx::util::logging::format_and_write::use_cache apply_format_and_write ; - - typedef hpx::util::logging::array::shared_ptr_holder formatter_array ; - typedef hpx::util::logging::array::shared_ptr_holder destination_array ; - - typedef typename msg_route::with_route router_type; + typedef typename hpx::util::logging::optimize + ::cache_string_several_str cache_string; + typedef typename hpx::util::logging::format_and_write::use_cache apply_format_and_write ; + + typedef hpx::util::logging::array::shared_ptr_holder formatter_array ; + typedef hpx::util::logging::array::shared_ptr_holder destination_array ; + + typedef typename msg_route::with_route router_type; }; ///////////// find_writer_with_thread_safety - template struct find_writer_with_thread_safety { + template struct find_writer_with_thread_safety { // for default_ #ifndef HPX_HAVE_LOG_NO_TS // use ts_write @@ -96,15 +113,18 @@ namespace detail { #endif }; - template struct find_writer_with_thread_safety { + template struct find_writer_with_thread_safety { typedef format_write type; }; - template struct find_writer_with_thread_safety { + template struct find_writer_with_thread_safety { typedef writer::ts_write type; }; - template struct find_writer_with_thread_safety { + template struct find_writer_with_thread_safety { typedef typename detail::to_override::type override_; typedef typename formatter::msg_type::type msg_type; @@ -114,27 +134,41 @@ namespace detail { namespace detail { - template< class format_base_type , class destination_base_type , class lock_resource, class thread_safety > struct format_find_writer { + template< class format_base_type , class destination_base_type , + class lock_resource, class thread_safety > struct format_find_writer { typedef typename detail::to_override::type override_; - typedef typename ::hpx::util::logging::formatter::msg_type::type format_msg_type; - typedef typename ::hpx::util::logging::destination::msg_type::type destination_msg_type; - typedef typename ::hpx::util::logging::types::lock_resource default_lock_resource; - - typedef ::hpx::util::logging::formatter::base< default_, default_ > default_format_base; - typedef ::hpx::util::logging::destination::base< default_, default_ > default_destination_base; - - typedef typename use_default ::type format_base; - typedef typename use_default ::type destination_base; - typedef typename use_default ::type lock_resource_type; - - - - typedef typename detail::find_format_write_params::apply_format_and_write apply_format_and_write; - typedef typename detail::find_format_write_params::router_type router_type; - - typedef ::hpx::util::logging::array::shared_ptr_holder formatter_array ; - typedef ::hpx::util::logging::array::shared_ptr_holder destination_array ; + typedef typename ::hpx::util::logging::formatter::msg_type + ::type format_msg_type; + typedef typename ::hpx::util::logging::destination::msg_type + ::type destination_msg_type; + typedef typename ::hpx::util::logging::types + ::lock_resource default_lock_resource; + + typedef ::hpx::util::logging::formatter::base< default_, default_ > + default_format_base; + typedef ::hpx::util::logging::destination::base< default_, default_ > + default_destination_base; + + typedef typename use_default + ::type format_base; + typedef typename use_default + ::type destination_base; + typedef typename use_default + ::type lock_resource_type; + + + + typedef typename detail::find_format_write_params + ::apply_format_and_write apply_format_and_write; + typedef typename detail::find_format_write_params::router_type router_type; + + typedef ::hpx::util::logging::array::shared_ptr_holder formatter_array ; + typedef ::hpx::util::logging::array::shared_ptr_holder destination_array ; // now find the writer based on thread safety typedef writer::format_write< @@ -145,7 +179,8 @@ namespace detail { router_type, formatter_array, destination_array > format_write_type; - typedef typename find_writer_with_thread_safety::type type; + typedef typename find_writer_with_thread_safety::type type; }; } diff --git a/hpx/util/logging/detail/find_gather.hpp b/hpx/util/logging/detail/find_gather.hpp index 8acdf921cd6a..6ffc3355578b 100644 --- a/hpx/util/logging/detail/find_gather.hpp +++ b/hpx/util/logging/detail/find_gather.hpp @@ -25,7 +25,7 @@ namespace hpx { namespace util { namespace logging { - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////// // specialize logger for format_write class // namespace tag { @@ -60,23 +60,31 @@ namespace hpx { namespace util { namespace logging { template struct find_gather< stream, std::basic_string > { - typedef gather::ostream_like::return_str< std::basic_string, stream > type ; + typedef gather::ostream_like::return_str< std::basic_string, + stream > type ; }; template< class stream, class string_type> - struct find_gather< stream, hpx::util::logging::optimize::cache_string_one_str > { - typedef gather::ostream_like::return_str< hpx::util::logging::optimize::cache_string_one_str, stream > type; + struct find_gather< stream, hpx::util::logging::optimize + ::cache_string_one_str > { + typedef gather::ostream_like::return_str< hpx::util::logging::optimize + ::cache_string_one_str, stream > type; }; template< class stream, class string_type> - struct find_gather< stream, hpx::util::logging::optimize::cache_string_several_str > { - typedef gather::ostream_like::return_str< hpx::util::logging::optimize::cache_string_several_str, stream > type; + struct find_gather< stream, hpx::util::logging::optimize + ::cache_string_several_str > { + typedef gather::ostream_like::return_str< hpx::util::logging::optimize + ::cache_string_several_str, stream > type; }; - template - struct find_gather< stream, tag::holder > { - typedef gather::ostream_like::return_tag_holder< tag::holder , stream > type; + template + struct find_gather< stream, tag::holder > { + typedef gather::ostream_like::return_tag_holder< + tag::holder , stream > type; }; } diff --git a/hpx/util/logging/detail/format_fwd_detail.hpp b/hpx/util/logging/detail/format_fwd_detail.hpp index c2e4c0b23d2a..68cb274f7886 100644 --- a/hpx/util/logging/detail/format_fwd_detail.hpp +++ b/hpx/util/logging/detail/format_fwd_detail.hpp @@ -39,7 +39,8 @@ namespace writer { struct no_ts {}; /** @brief thread-safe write. All writes are protected by a lock */ struct ts_write {}; - /** @brief thread-safe write on a dedicated thread. Very efficient. Formatting & writing to destinations happens on the dedicated thread */ + /** @brief thread-safe write on a dedicated thread. Very efficient. + Formatting & writing to destinations happens on the dedicated thread */ struct on_dedicated_thread {}; } } @@ -92,7 +93,8 @@ template< /** dumps the default levels - Has a static function : dump, which dumps the level as string (works only for the default levels; for any other level, returns "") + Has a static function : dump, which dumps the level as string + (works only for the default levels; for any other level, returns "") */ struct dump_default_levels { static const char_type * dump(::hpx::util::logging::level::type lvl) { @@ -123,14 +125,17 @@ namespace detail { // FIXME in the future, I might provide gather as a specific class! typedef typename formatter::msg_type::type msg_type; - typedef typename ::hpx::util::logging::gather::find::template from_msg_type::type type; + typedef typename ::hpx::util::logging::gather::find + ::template from_msg_type::type type; }; } // specialize for logger_format_write -template - struct logger_to_gather< logger_format_write > { +template + struct logger_to_gather< logger_format_write > { typedef typename detail::format_find_gather::type gather_type; }; @@ -139,7 +144,8 @@ namespace writer { template struct named_write ; } -/** @brief named_logger<...>::type finds a logger that uses @ref writer::named_write<> "Named Formatters and Destinations" +/** @brief named_logger<...>::type finds a logger that uses @ref writer::named_write<> + "Named Formatters and Destinations" @code #include @@ -154,7 +160,8 @@ Setting the formatters and destinations to write to is extremely simple: @code // first param - the formatter(s) , second param : the destination(s) -g_l()->writer().write("%time%($hh:$mm.$ss.$mili) [%idx%] |\n", "cout file(out.txt) debug"); +g_l()->writer().write("%time%($hh:$mm.$ss.$mili) [%idx%] |\n", + "cout file(out.txt) debug"); @endcode To see the syntax, see writer::named_write diff --git a/hpx/util/logging/detail/format_msg_type.hpp b/hpx/util/logging/detail/format_msg_type.hpp index c54e9360dc9a..de9cb8608fa2 100644 --- a/hpx/util/logging/detail/format_msg_type.hpp +++ b/hpx/util/logging/detail/format_msg_type.hpp @@ -35,7 +35,8 @@ template struct logger ; namespace formatter { /** - @brief what is the default type of your string, in formatter_base ? See HPX_LOG_FORMAT_MSG + @brief what is the default type of your string, + in formatter_base ? See HPX_LOG_FORMAT_MSG */ template struct msg_type { typedef hold_string_type type; @@ -44,7 +45,8 @@ namespace formatter { namespace destination { /** - @brief what is the default type of your string, in destination_base ? See HPX_LOG_DESTINATION_MSG + @brief what is the default type of your string, + in destination_base ? See HPX_LOG_DESTINATION_MSG */ template struct msg_type { // by default - the default string @@ -55,7 +57,9 @@ namespace destination { namespace gather { template struct find { template struct from_msg_type { - typedef typename ::hpx::util::logging::detail::find_gather< std::basic_ostringstream, msg_type >::type type; + typedef typename ::hpx::util::logging::detail + ::find_gather< std::basic_ostringstream, + msg_type >::type type; }; }; } diff --git a/hpx/util/logging/detail/format_write_detail.hpp b/hpx/util/logging/detail/format_write_detail.hpp index b04c5413fda4..db45f408e3f5 100644 --- a/hpx/util/logging/detail/format_write_detail.hpp +++ b/hpx/util/logging/detail/format_write_detail.hpp @@ -43,14 +43,18 @@ The most important class is writer::format_write namespace writer { /** -@brief Allows custom formatting of the message before %logging it, and writing it to several destinations. +@brief Allows custom formatting of the message before %logging it, +and writing it to several destinations. -Once the message has been @ref hpx::util::logging::gather "gathered", it's time to write it. +Once the message has been @ref hpx::util::logging::gather "gathered", +it's time to write it. The current class defines the following concepts: - formatter - allows formatting the message before writing it -- destination - is a place where the message is to be written to (like, the console, a file, a socket, etc) +- destination - is a place where the message is to be written to (like, the console, +a file, a socket, etc) -You can add several formatters and destinations. Note that each formatter class and each destination class is a @c %manipulator. +You can add several formatters and destinations. Note that each formatter class and +each destination class is a @c %manipulator. Make sure you know what a manipulator is before using formatters and destinations. @@ -58,12 +62,16 @@ Make sure you know what a manipulator is before using formatters and destination \n\n @section object_router The router object -Once you've added the formatters and destinations, the @ref msg_route "router" comes into play. The @ref msg_route "router" -specifies how formatters and destinations are called. By default, all formatters are called first, in the order they were added, -and then all destinations are called, in the order they were added. You can easily access the router() instance. +Once you've added the formatters and destinations, +the @ref msg_route "router" comes into play. The @ref msg_route "router" +specifies how formatters and destinations are called. +By default, all formatters are called first, in the order they were added, +and then all destinations are called, in the order they were added. +You can easily access the router() instance. @code -typedef logger< gather::ostream_like::return_cache_str<> , format_write< ... > > logger_type; +typedef logger< gather::ostream_like::return_cache_str<> , +format_write< ... > > logger_type; HPX_DECLARE_LOG(g_l, logger_type) HPX_DECLARE_LOG_FILTER(g_log_filter, filter::no_ts ) #define L_ HPX_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() ) @@ -82,10 +90,12 @@ int i = 1; L_ << "testing " << i << i+1 << i+2; @endcode -In the above case, @c formatter::idx() is called, then @c formatter::time(), then @c formatter::append_newline(). Now, the destinations are called: +In the above case, @c formatter::idx() is called, then @c formatter::time(), +then @c formatter::append_newline(). Now, the destinations are called: @c destination::cout(), and then @c destination::file(). -Most of the time this is ok, and this is what the @ref msg_route::simple "default router" does. However, there are other routers +Most of the time this is ok, and this is what the @ref msg_route::simple "default router" +does. However, there are other routers in the msg_route namespace. For instance, take a look at msg_route::with_route class. @@ -93,37 +103,48 @@ in the msg_route namespace. For instance, take a look at msg_route::with_route c \n\n @section apply_format_and_write_object The apply_format_and_write object -Once the formatters and destinations are added, and you know the route, you have an extra object - the format_and_write - which +Once the formatters and destinations are added, and you know the route, you have an +extra object - the format_and_write - which contains the logic for calling the formatters and destinations. -The format_and_write class knows how to call the formatters and destinations @em objects. Usually you'll be happy with the -format_and_write::simple class - which simply calls @c operator() on the formatters , and @c operator() on the destinations. +The format_and_write class knows how to call the formatters and destinations @em objects. +Usually you'll be happy with the +format_and_write::simple class - which simply calls @c operator() on the formatters, +and @c operator() on the destinations. Otherwise, take a look at format_and_write namespace. An object of this type (apply_format_and_write) is created for each new logged message. \n\n -@note This class is not thread-safe. If you want thread-safety, check out the other writer classes: on_dedicated_thread and ts_write +@note This class is not thread-safe. If you want thread-safety, +check out the other writer classes: on_dedicated_thread and ts_write \n\n -@param format_base The base class for all formatter classes from your application. See manipulator. +@param format_base The base class for all formatter classes from your application. +See manipulator. -@param destination_base The base class for all destination classes from your application. See manipulator. +@param destination_base The base class for all destination classes from your application. +See manipulator. @param lock_resource How will we lock important resources - routing them (msg_route) -@param apply_format_and_write [optional] The class that knows how to call the formatters and destinations. See @ref apply_format_and_write_object +@param apply_format_and_write [optional] The class that knows how to call +the formatters and destinations. See @ref apply_format_and_write_object -@param router_type [optional] The class that knows when to call the formatters, and when to call the destinations. See @ref object_router. +@param router_type [optional] The class that knows when to call the formatters, +and when to call the destinations. See @ref object_router. \n\n -@remarks Normally the router could own the formatters and destination objects. However, then, it would need to own the objects, -which would mean needing to come up with a smart pointer strategy. This would complicate the router logic. -Also, iterating over formatters/destinations would be slower, if we were to keep smart pointers within the router itself. +@remarks Normally the router could own the formatters and destination objects. +However, then, it would need to own the objects, +which would mean needing to come up with a smart pointer strategy. +This would complicate the router logic. +Also, iterating over formatters/destinations would be slower, +if we were to keep smart pointers within the router itself. @@ -135,17 +156,23 @@ template< class destination_base, class lock_resource = default_ , class apply_format_and_write = default_ , - class router_type = msg_route::simple , + class router_type = msg_route::simple , class formatter_array = array::shared_ptr_holder , class destination_array = array::shared_ptr_holder > struct format_write { typedef typename formatter_base::ptr_type formatter_ptr; typedef typename destination_base::ptr_type destination_ptr; - typedef typename use_default > ::type apply_format_and_write_type; + typedef typename use_default > + ::type apply_format_and_write_type; - typedef typename hpx::util::logging::detail::to_override::type override_; - typedef typename use_default::lock_resource > ::type lock_resource_type; + typedef typename hpx::util::logging::detail::to_override + ::type override_; + typedef typename use_default::lock_resource > ::type lock_resource_type; typedef formatter_base formatter_base_type; typedef destination_base destination_base_type; @@ -157,52 +184,64 @@ struct format_write { private: // non-generic - template void add_formatter_impl(formatter fmt, const boost::false_type& ) { + template void add_formatter_impl(formatter fmt, + const boost::false_type& ) { formatter_ptr p = m_formatters.append(fmt); m_router.append_formatter(p); } // non-generic - template void del_formatter_impl(formatter fmt, const boost::false_type& ) { + template void del_formatter_impl(formatter fmt, + const boost::false_type& ) { formatter_ptr p = m_formatters.get_ptr(fmt); m_router.del_formatter(p); m_formatters.del(fmt); } // non-generic - template void add_destination_impl(destination dest, const boost::false_type& ) { + template void add_destination_impl(destination dest, + const boost::false_type& ) { destination_ptr p = m_destinations.append(dest); m_router.append_destination(p); } // non-generic - template void del_destination_impl(destination dest, const boost::false_type& ) { + template void del_destination_impl(destination dest, + const boost::false_type& ) { destination_ptr p = m_destinations.get_ptr(dest); m_router.del_destination(p); m_destinations.del(dest); } // generic manipulator - template void add_formatter_impl(formatter fmt, const boost::true_type& ) { - typedef hpx::util::logging::manipulator::detail::generic_holder holder; + template void add_formatter_impl(formatter fmt, + const boost::true_type& ) { + typedef hpx::util::logging::manipulator::detail + ::generic_holder holder; add_formatter_impl( holder(fmt), boost::false_type() ); } // generic manipulator - template void del_formatter_impl(formatter fmt, const boost::true_type& ) { - typedef hpx::util::logging::manipulator::detail::generic_holder holder; + template void del_formatter_impl(formatter fmt, + const boost::true_type& ) { + typedef hpx::util::logging::manipulator::detail + ::generic_holder holder; del_formatter_impl( holder(fmt), boost::false_type() ); } // generic manipulator - template void add_destination_impl(destination dest, const boost::true_type& ) { - typedef hpx::util::logging::manipulator::detail::generic_holder holder; + template void add_destination_impl(destination dest, + const boost::true_type& ) { + typedef hpx::util::logging::manipulator::detail + ::generic_holder holder; add_destination_impl( holder(dest), boost::false_type() ); } // generic manipulator - template void del_destination_impl(destination dest, const boost::true_type& ) { - typedef hpx::util::logging::manipulator::detail::generic_holder holder; + template void del_destination_impl(destination dest, + const boost::true_type& ) { + typedef hpx::util::logging::manipulator::detail + ::generic_holder holder; del_destination_impl( holder(dest), boost::false_type() ); } @@ -218,12 +257,15 @@ struct format_write { } /** - @brief Adds a formatter. Also, the second argument is the @ref hpx::util::logging::formatter::spacer_t "spacer" string + @brief Adds a formatter. Also, the second argument is the @ref + hpx::util::logging::formatter::spacer_t "spacer" string @param fmt The formatter - @param format_str The @ref hpx::util::logging::formatter::spacer_t "spacer" string + @param format_str The @ref hpx::util::logging::formatter::spacer_t + "spacer" string */ - template void add_formatter(formatter fmt, const char_type * format_str) { + template void add_formatter(formatter fmt, + const char_type * format_str) { add_formatter( spacer(fmt, format_str) ); } @@ -242,7 +284,8 @@ struct format_write { */ template void add_destination(destination dest) { typedef hpx::util::logging::manipulator::is_generic is_generic; - add_destination_impl( dest, boost::is_base_of() ); + add_destination_impl( dest, + boost::is_base_of() ); } /** @@ -250,7 +293,8 @@ struct format_write { */ template void del_destination(destination dest) { typedef hpx::util::logging::manipulator::is_generic is_generic; - del_destination_impl( dest, boost::is_base_of() ); + del_destination_impl( dest, + boost::is_base_of() ); } /** diff --git a/hpx/util/logging/detail/forward_constructor.hpp b/hpx/util/logging/detail/forward_constructor.hpp index ed266c95305e..00b57e935cd7 100644 --- a/hpx/util/logging/detail/forward_constructor.hpp +++ b/hpx/util/logging/detail/forward_constructor.hpp @@ -36,18 +36,30 @@ namespace hpx { namespace util { namespace logging { #define HPX_LOGGING_FORWARD_CONSTRUCTOR(class_name,forward_to) \ class_name() {} \ template class_name(const p1 & a1 ) : forward_to(a1) {} \ - template class_name(const p1 & a1 , const p2 & a2) : forward_to(a1,a2) {} \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3) : forward_to(a1,a2,a3) {} \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4) : forward_to(a1,a2,a3,a4) {} \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4, const p5 & a5) : forward_to(a1,a2,a3,a4,a5) {} + template class_name(const p1 & a1 , const p2 & a2)\ + : forward_to(a1,a2) {} \ + template class_name\ +(const p1 & a1 , const p2 & a2, const p3 & a3) : forward_to(a1,a2,a3) {} \ + template class_name\ +(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4)\ + : forward_to(a1,a2,a3,a4) {} \ + template class_name\ +(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4, const p5 & a5)\ + : forward_to(a1,a2,a3,a4,a5) {} #define HPX_LOGGING_FORWARD_CONSTRUCTOR_INIT(class_name,forward_to,init) \ class_name() { init (); } \ template class_name(const p1 & a1 ) : forward_to(a1) { init(); } \ - template class_name(const p1 & a1 , const p2 & a2) : forward_to(a1,a2) { init(); } \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3) : forward_to(a1,a2,a3) { init(); } \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4) : forward_to(a1,a2,a3,a4) { init(); } \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4, const p5 & a5) : forward_to(a1,a2,a3,a4,a5) { init(); } + template class_name(const p1 & a1 , const p2 & a2)\ + : forward_to(a1,a2) { init(); } \ + template class_name\ +(const p1 & a1 , const p2 & a2, const p3 & a3) : forward_to(a1,a2,a3) { init(); } \ + template class_name\ +(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4)\ + : forward_to(a1,a2,a3,a4) { init(); } \ + template\ + class_name(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4, const p5 & a5)\ + : forward_to(a1,a2,a3,a4,a5) { init(); } #ifdef BOOST_MSVC // workaround for VS - problem with copy constructor @@ -55,54 +67,90 @@ namespace hpx { namespace util { namespace logging { #define HPX_LOGGING_FORWARD_CONSTRUCTOR_WITH_NEW(class_name,forward_to,type) \ class_name() : forward_to(new type) {} \ template class_name(const p1 & a1 ) { \ - see_if_copy_constructor( a1, forward_to, boost::is_base_of() ); \ + see_if_copy_constructor\ +( a1, forward_to, boost::is_base_of() ); \ } \ - template void see_if_copy_constructor(const p1 & a1, forward_type&, const boost::true_type& ) { \ - forward_to = a1.forward_to; \ + template\ + void see_if_copy_constructor(const p1 & a1, forward_type&, const boost::true_type& )\ + { forward_to = a1.forward_to; \ } \ - template void see_if_copy_constructor(const p1 & a1, forward_type&, const boost::false_type& ) { \ + template void see_if_copy_constructor\ +(const p1 & a1, forward_type&, const boost::false_type& ) { \ forward_to = forward_type(new type(a1)); \ } \ - template class_name(const p1 & a1 , const p2 & a2) : forward_to(new type(a1,a2)) {} \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3) : forward_to(new type(a1,a2,a3)) {} \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4) : forward_to(new type(a1,a2,a3,a4)) {} \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4, const p5 & a5) : forward_to(new type(a1,a2,a3,a4,a5)) {} - -#define HPX_LOGGING_FORWARD_CONSTRUCTOR_WITH_NEW_AND_INIT(class_name,forward_to,type, init) \ + template class_name(const p1 & a1 , const p2 & a2)\ + : forward_to(new type(a1,a2)) {} \ + template\ + class_name(const p1 & a1 , const p2 & a2, const p3 & a3)\ + : forward_to(new type(a1,a2,a3)) {} \ + template class_name\ +(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4)\ + : forward_to(new type(a1,a2,a3,a4)) {} \ + template\ + class_name(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4, const p5 & a5)\ + : forward_to(new type(a1,a2,a3,a4,a5)) {} + +#define HPX_LOGGING_FORWARD_CONSTRUCTOR_WITH_NEW_AND_INIT\ +(class_name,forward_to,type, init) \ class_name() : forward_to(new type) { init (); } \ template class_name(const p1 & a1 ) { \ - see_if_copy_constructor( a1, forward_to, boost::is_base_of() ); \ + see_if_copy_constructor\ +( a1, forward_to, boost::is_base_of() ); \ } \ - template void see_if_copy_constructor(const p1 & a1, forward_type&, const boost::true_type& ) { \ - forward_to = a1.forward_to; \ + template\ + void see_if_copy_constructor(const p1 & a1, forward_type&, const boost::true_type& )\ + { forward_to = a1.forward_to; \ init (); \ } \ - template void see_if_copy_constructor(const p1 & a1, forward_type&, const boost::false_type& ) { \ - forward_to = forward_type(new type(a1)); \ + template\ + void see_if_copy_constructor(const p1 & a1, forward_type&, const boost::false_type& )\ + { forward_to = forward_type(new type(a1)); \ init (); \ } \ - template class_name(const p1 & a1 , const p2 & a2) : forward_to(new type(a1,a2)) { init (); } \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3) : forward_to(new type(a1,a2,a3)) { init (); } \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4) : forward_to(new type(a1,a2,a3,a4)) { init (); } \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4, const p5 & a5) : forward_to(new type(a1,a2,a3,a4,a5)) { init (); } + template class_name(const p1 & a1 , const p2 & a2)\ + : forward_to(new type(a1,a2)) { init (); } \ + template class_name\ +(const p1 & a1 , const p2 & a2, const p3 & a3) : forward_to(new type(a1,a2,a3))\ + { init (); } \ + template class_name\ +(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4)\ + : forward_to(new type(a1,a2,a3,a4)) { init (); } \ + template class_name\ +(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4, const p5 & a5)\ + : forward_to(new type(a1,a2,a3,a4,a5)) { init (); } #else #define HPX_LOGGING_FORWARD_CONSTRUCTOR_WITH_NEW(class_name,forward_to,type) \ class_name() : forward_to(new type) {} \ template class_name(const p1 & a1 ) : forward_to(new type(a1)) {} \ - template class_name(const p1 & a1 , const p2 & a2) : forward_to(new type(a1,a2)) {} \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3) : forward_to(new type(a1,a2,a3)) {} \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4) : forward_to(new type(a1,a2,a3,a4)) {} \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4, const p5 & a5) : forward_to(new type(a1,a2,a3,a4,a5)) {} - - -#define HPX_LOGGING_FORWARD_CONSTRUCTOR_WITH_NEW_AND_INIT(class_name,forward_to,type, init) \ + template class_name(const p1 & a1 , const p2 & a2)\ + : forward_to(new type(a1,a2)) {} \ + template class_name\ +(const p1 & a1 , const p2 & a2, const p3 & a3) : forward_to(new type(a1,a2,a3)) {} \ + template class_name\ +(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4)\ + : forward_to(new type(a1,a2,a3,a4)) {} \ + template\ + class_name(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4, const p5 & a5)\ + : forward_to(new type(a1,a2,a3,a4,a5)) {} + + +#define HPX_LOGGING_FORWARD_CONSTRUCTOR_WITH_NEW_AND_INIT\ +(class_name,forward_to,type, init) \ class_name() : forward_to(new type) { init (); } \ - template class_name(const p1 & a1 ) : forward_to(new type(a1)) { init (); } \ - template class_name(const p1 & a1 , const p2 & a2) : forward_to(new type(a1,a2)) { init (); } \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3) : forward_to(new type(a1,a2,a3)) { init (); } \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4) : forward_to(new type(a1,a2,a3,a4)) { init (); } \ - template class_name(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4, const p5 & a5) : forward_to(new type(a1,a2,a3,a4,a5)) { init (); } + template class_name(const p1 & a1 )\ + : forward_to(new type(a1)) { init (); } \ + template class_name\ +(const p1 & a1 , const p2 & a2) : forward_to(new type(a1,a2)) { init (); } \ + template class_name\ +(const p1 & a1 , const p2 & a2, const p3 & a3) : forward_to(new type(a1,a2,a3))\ + { init (); } \ + template class_name\ +(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4)\ + : forward_to(new type(a1,a2,a3,a4)) { init (); } \ + template\ + class_name(const p1 & a1 , const p2 & a2, const p3 & a3, const p4 & a4, const p5 & a5)\ + : forward_to(new type(a1,a2,a3,a4,a5)) { init (); } #endif diff --git a/hpx/util/logging/detail/fwd.hpp b/hpx/util/logging/detail/fwd.hpp index 04c21920980a..10945f5e0d0e 100644 --- a/hpx/util/logging/detail/fwd.hpp +++ b/hpx/util/logging/detail/fwd.hpp @@ -39,14 +39,19 @@ /* The following HPX_LOG_STR("this " "and that") still doesn't work. #define HPX_LOG_HOLDER2(x) x, L ## x #define HPX_LOG_HOLDER(x) HPX_LOG_HOLDER2(x) -#define HPX_LOG_STR(x) (const ::hpx::util::logging::char_type*)ansi_unicode_char_holder ( HPX_LOG_HOLDER(x) ) +#define HPX_LOG_STR(x) \ +(const ::hpx::util::logging::char_type*)ansi_unicode_char_holder \ +( HPX_LOG_HOLDER(x) ) */ -#define HPX_LOG_STR(x) static_cast(::hpx::util::logging::ansi_unicode_char_holder ( x, L ## x )) +#define HPX_LOG_STR(x) \ + static_cast \ + (::hpx::util::logging::ansi_unicode_char_holder ( x, L ## x )) /* Important: we define here only the things that are needed by ALL OF THE LIBRARY. - So be very careful when modifying this file - we don't want any circular dependencies! + So be very careful when modifying this file + - we don't want any circular dependencies! If unsure where to place something, place it logging.hpp! */ @@ -69,7 +74,8 @@ namespace hpx { namespace util { namespace logging { /** @page dealing_with_flags Dealing with flags. -Some classes have extra settings. You can specify these settings in the class'es constructor. +Some classes have extra settings. You can specify these settings in the +class'es constructor. When setting a certain value, there's a very simple pattern: @code @@ -88,7 +94,8 @@ file f("out.txt", file_settings.initial_overwrite(true).do_append(false) ); namespace detail { template struct flag_with_self_type { //-V690 - flag_with_self_type(self_type * self, const type& val = type() ) : m_val(val), m_self(self) {} + flag_with_self_type(self_type * self, const type& val = type() ) + : m_val(val), m_self(self) {} flag_with_self_type(const flag_with_self_type & other) : m_val(other.m_val) {} const type & operator()() const { return m_val; } @@ -111,7 +118,8 @@ namespace detail { template struct flag { template struct t : flag_with_self_type { typedef flag_with_self_type flag_base_type; - t(self_type * self, const val_type& val = val_type() ) : flag_base_type(self,val) {} + t(self_type * self, const val_type& val = val_type() ) + : flag_base_type(self,val) {} }; }; } diff --git a/hpx/util/logging/detail/level.hpp b/hpx/util/logging/detail/level.hpp index 235c914fcfb6..2aef9bb75719 100644 --- a/hpx/util/logging/detail/level.hpp +++ b/hpx/util/logging/detail/level.hpp @@ -27,7 +27,8 @@ namespace hpx { namespace util { namespace logging { /** - @brief Handling levels - classes that can hold and/or deal with levels - filters and level holders + @brief Handling levels - classes that can hold and/or deal with levels + - filters and level holders By default we have these levels: @@ -37,11 +38,13 @@ namespace hpx { namespace util { namespace logging { - error , - fatal (highest level) - Depending on which level is enabled for your application, some messages will reach the log: those + Depending on which level is enabled for your application, + some messages will reach the log: those messages having at least that level. For instance, if info level is enabled, all logged messages will reach the log. If warning level is enabled, all messages are logged, but the warnings. - If debug level is enabled, messages that have levels debug, error, fatal will be logged. + If debug level is enabled, messages that have levels debug, + error, fatal will be logged. */ namespace level { @@ -65,7 +68,8 @@ namespace level { Holds the level, and tells you if a specific level is enabled. It does this in a non-thread-safe way. - If you change set_enabled() while program is running, it can take a bit to propagate + If you change set_enabled() while program is running, + it can take a bit to propagate between threads. Most of the time, this should be acceptable. */ struct holder_no_ts { @@ -91,7 +95,8 @@ namespace level { typedef hpx::util::logging::threading::scoped_lock scoped_lock; typedef hpx::util::logging::threading::mutex mutex; - holder_ts(type default_level = enable_all) : m_level(default_level) {} + holder_ts(type default_level = enable_all) + : m_level(default_level) {} bool is_enabled(type level) const { scoped_lock lk(m_cs); return level >= m_level; @@ -106,7 +111,8 @@ namespace level { }; /** - @brief Filter - holds the level - and tells you at compile time if a filter is enabled or not. + @brief Filter - holds the level + - and tells you at compile time if a filter is enabled or not. Fix (compile time) holder */ @@ -124,13 +130,15 @@ namespace level { /** @brief Filter - holds the level, in a thread-safe way, using TLS. - Uses TLS (Thread Local Storage) to find out if a level is enabled or not. It caches the current "is_enabled" on each thread. + Uses TLS (Thread Local Storage) to find out if a level is enabled or not. + It caches the current "is_enabled" on each thread. Then, at a given period, it retrieves the real "level". */ template struct holder_tss_with_cache { typedef locker::tss_resource_with_cache data; - holder_tss_with_cache(int cache_secs = default_cache_secs, type default_level = enable_all) : m_level(default_level, cache_secs) {} + holder_tss_with_cache(int cache_secs = default_cache_secs, + type default_level = enable_all) : m_level(default_level, cache_secs) {} bool is_enabled(type test_level) const { typename data::read cur_level(m_level); return test_level >= cur_level.use(); diff --git a/hpx/util/logging/detail/log_keeper.hpp b/hpx/util/logging/detail/log_keeper.hpp index e70c0b392435..d8c90984e8c3 100644 --- a/hpx/util/logging/detail/log_keeper.hpp +++ b/hpx/util/logging/detail/log_keeper.hpp @@ -36,9 +36,11 @@ namespace detail { /** - @brief Allows using a log without knowing its full type yet. Even if the log is not fully @b defined, you can still use it. + @brief Allows using a log without knowing its full type yet. + Even if the log is not fully @b defined, you can still use it. - This will allow you to log messages even if you don't know the full type of the log (which can aid compilation time). + This will allow you to log messages even if you don't know the full type of the log + (which can aid compilation time). This is a base class. Use logger_holder_by_value or logger_holder_by_ptr instead */ @@ -68,7 +70,8 @@ template struct logger_holder { m_base = m_log->common_base(); } private: - // note: I have a pointer to the log, as opposed to having it by value, because the whole purpose of this class + // note: I have a pointer to the log, as opposed to having it by value, + // because the whole purpose of this class // is to be able to use a log without knowing its full type type *m_log; logger_base_type * m_base; @@ -77,12 +80,15 @@ template struct logger_holder { /** - @brief Allows using a log without knowing its full type yet. Even if the log is not fully @b defined, you can still use it. + @brief Allows using a log without knowing its full type yet. + Even if the log is not fully @b defined, you can still use it. - This will allow you to log messages even if you don't know the full type of the log (which can aid compilation time). + This will allow you to log messages even if you don't know the full type of the log + (which can aid compilation time). This keeps the logger by value, so that the after_being_destroyed stuff works. - More specifically, in case the logger is used after it's been destroyed, the logger_holder instances CAN ONLY BE GLOBAL. + More specifically, in case the logger is used after it's been destroyed, + the logger_holder instances CAN ONLY BE GLOBAL. */ template struct logger_holder_by_value : logger_holder { typedef logger_holder base_type; @@ -93,21 +99,26 @@ template struct logger_holder_by_value : logger_holder { base_type::init( &m_log_value); } private: - // VERY IMPORTANT: we keep this BY VALUE, because, at destruction, we don't want the memory to be freed - // (in order for the after_being_destroyed to work, for global instances of this type) + // VERY IMPORTANT: we keep this BY VALUE, because, + // at destruction, we don't want the memory to be freed + // (in order for the after_being_destroyed to work, + // for global instances of this type) type m_log_value; }; /** - @brief Allows using a log without knowing its full type yet. Even if the log is not fully @b defined, you can still use it. + @brief Allows using a log without knowing its full type yet. + Even if the log is not fully @b defined, you can still use it. - This will allow you to log messages even if you don't know the full type of the log (which can aid compilation time). + This will allow you to log messages even if you don't know the full type of + the log (which can aid compilation time). */ template struct logger_holder_by_ptr : logger_holder { typedef logger_holder base_type; - HPX_LOGGING_FORWARD_CONSTRUCTOR_WITH_NEW_AND_INIT(logger_holder_by_ptr, m_log_ptr, type, init) + HPX_LOGGING_FORWARD_CONSTRUCTOR_WITH_NEW_AND_INIT \ + (logger_holder_by_ptr, m_log_ptr, type, init) ~logger_holder_by_ptr() { delete m_log_ptr; } @@ -128,8 +139,10 @@ template struct logger_holder_by_ptr : logger_holder { /** @brief Ensures the log is created before main(), even if not used before main - We need this, so that we won't run into multi-threaded issues while the log is created - (in other words, if the log is created before main(), we can safely assume there's only one thread running, + We need this, so that we won't run into multi-threaded issues while + the log is created + (in other words, if the log is created before main(), + we can safely assume there's only one thread running, thus no multi-threaded issues) */ struct ensure_early_log_creation { @@ -143,7 +156,8 @@ struct ensure_early_log_creation { // we need to force the compiler to force creation of the log if ( time(0) < 0) if ( time(0) < (time_t)ignore) { - printf("LOGGING LIB internal error - should NEVER happen. Please report this to the author of the lib"); + printf("LOGGING LIB internal error - should NEVER happen. \ + Please report this to the author of the lib"); exit(0); } } @@ -153,24 +167,30 @@ struct ensure_early_log_creation { /** @brief Ensures the filter is created before main(), even if not used before main - We need this, so that we won't run into multi-threaded issues while the filter is created - (in other words, if the filter is created before main(), we can safely assume there's only one thread running, + We need this, so that we won't run into multi-threaded issues while + the filter is created + (in other words, if the filter is created before main(), + we can safely assume there's only one thread running, thus no multi-threaded issues) */ typedef ensure_early_log_creation ensure_early_filter_creation; /** - Useful for logger_holder - to get the logger' base (so that we can use it even without knowing the full log's definition). + Useful for logger_holder - to get the logger' base + (so that we can use it even without knowing the full log's definition). If used on a logger, it just returns it . */ template inline logger* get_logger_base(logger * l) { return l; } -template inline const logger* get_logger_base(const logger * l) { return l; } +template inline const logger* + get_logger_base(const logger * l) { return l; } -template inline typename logger_holder::logger_base_type* get_logger_base(logger_holder & l) { +template inline typename logger_holder::logger_base_type* + get_logger_base(logger_holder & l) { return l.base(); } -template inline const typename logger_holder::logger_base_type* get_logger_base(const logger_holder & l) { +template inline const typename logger_holder::logger_base_type* + get_logger_base(const logger_holder & l) { return l.base(); } diff --git a/hpx/util/logging/detail/logger.hpp b/hpx/util/logging/detail/logger.hpp index e14f2f775958..2c434f9fa8c2 100644 --- a/hpx/util/logging/detail/logger.hpp +++ b/hpx/util/logging/detail/logger.hpp @@ -13,7 +13,8 @@ // See http://www.boost.org for updates, documentation, and revision history. // See http://www.torjo.com/log2/ for more details -// IMPORTANT : the JT28092007_logger_HPP_DEFINED needs to remain constant - don't change the macro name! +// IMPORTANT : the JT28092007_logger_HPP_DEFINED needs to remain constant +// - don't change the macro name! #ifndef JT28092007_logger_HPP_DEFINED #define JT28092007_logger_HPP_DEFINED @@ -53,9 +54,12 @@ namespace hpx { namespace util { namespace logging { template struct logger ; - // specialize when write_msg is not set - in this case, you need to derive from this - template struct logger : logger_base { - typedef typename detail::find_gather_if_default::gather_type gather_type; + // specialize when write_msg is not set + // - in this case, you need to derive from this + template struct logger + : logger_base { + typedef typename detail::find_gather_if_default + ::gather_type gather_type; typedef typename gather_type::msg_type msg_type; typedef void_ write_type; @@ -65,17 +69,21 @@ namespace hpx { namespace util { namespace logging { typedef logger self_type; logger() {} - // we have virtual functions, lets have a virtual destructor as well - many thanks Martin Baeker! + // we have virtual functions, lets have a virtual destructor as well + // - many thanks Martin Baeker! virtual ~logger() { - // force writing all messages from cache, if cache hasn't been turned off yet + // force writing all messages from cache, + // if cache hasn't been turned off yet turn_cache_off(); } /** reads all data about a log message (gathers all the data about it) */ - gather_holder read_msg() const { return gather_holder(*this) ; } -// gather_holder read_msg() const { return gather_holder(*this) ; } + gather_holder read_msg() + const { return gather_holder(*this) ; } +// gather_holder read_msg() +// const { return gather_holder(*this) ; } write_type & writer() { return m_writer; } const write_type & writer() const { return m_writer; } @@ -119,12 +127,14 @@ namespace hpx { namespace util { namespace logging { template struct forward_to_logger : logger { - typedef typename detail::find_gather_if_default::gather_type gather_type; + typedef typename detail::find_gather_if_default + ::gather_type gather_type; typedef typename gather_type::msg_type msg_type; typedef logger log_base; typedef typename log_base::cache_type cache_type; - // ... might be called for a specialization of logger - for logger + // ... might be called for a specialization of logger + // - for logger typedef typename boost::remove_pointer::type write_type; typedef logger original_logger_type; @@ -147,8 +157,9 @@ namespace hpx { namespace util { namespace logging { (*m_writer)(a); } - virtual cache_type & cache() { return m_original_logger->cache(); } - virtual const cache_type & cache() const { return m_original_logger->cache(); } + virtual cache_type & cache() { return m_original_logger->cache(); } + virtual const cache_type & cache() const + { return m_original_logger->cache(); } private: write_type* m_writer; @@ -158,9 +169,11 @@ namespace hpx { namespace util { namespace logging { /** - @brief The logger class. Every log from your application is an instance of this (see @ref workflow_processing "workflow") + @brief The logger class. Every log from your application is an instance of + this (see @ref workflow_processing "workflow") - As described in @ref workflow_processing "workflow", processing the message is composed of 2 things: + As described in @ref workflow_processing "workflow", + processing the message is composed of 2 things: - @ref workflow_2a "Gathering the message" - @ref workflow_2b "Processing the message" @@ -169,26 +182,33 @@ namespace hpx { namespace util { namespace logging { @param gather_msg A new gather instance is created each time a message is written. The @c gather_msg class needs to be default-constructible. - The @c gather_msg must have a function called @c .msg() which contains all information about the written message. + The @c gather_msg must have a function called @c .msg() which + contains all information about the written message. It will be passed to the write_msg class. - You can implement your own @c gather_msg class, or use any from the gather namespace. + You can implement your own @c gather_msg class, + or use any from the gather namespace. - @param write_msg This is the object that does the @ref workflow_2b "second step" - the writing of the message. + @param write_msg This is the object that does + the @ref workflow_2b "second step" - the writing of the message. It can be a simple functor. - Or, it can be a more complex object that contains logic of how the message is to be further formatted, + Or, it can be a more complex object that contains + logic of how the message is to be further formatted, and written to multiple destinations. - You can implement your own @c write_msg class, or it can be any of the classes defined in writer namespace. + You can implement your own @c write_msg class, + or it can be any of the classes defined in writer namespace. Check out writer::format_write - which allows you to use several formatters to further format the message, and then write it to destinations. \n\n - You will seldom need to use the logger class directly. You can use @ref defining_your_logger "other wrapper classes". + You will seldom need to use the logger class directly. + You can use @ref defining_your_logger "other wrapper classes". \n\n The logger forwards - the gathering of the message to the @c gather_msg class. Once all message is gathered, it's passed on to the writer. + the gathering of the message to the @c gather_msg class. + Once all message is gathered, it's passed on to the writer. This is usually done through a @ref macros_use "macro". @code @@ -212,10 +232,12 @@ namespace hpx { namespace util { namespace logging { */ template struct logger - // note: default implementation - when gather_msg and write_msg are both known + // note: default implementation + //- when gather_msg and write_msg are both known : logger_base { - typedef typename detail::find_gather_if_default::gather_type gather_type; + typedef typename detail::find_gather_if_default + ::gather_type gather_type; typedef typename gather_type::msg_type msg_type; typedef write_msg write_type; typedef logger_base logger_base_type; @@ -226,14 +248,16 @@ namespace hpx { namespace util { namespace logging { HPX_LOGGING_FORWARD_CONSTRUCTOR_INIT(logger,m_writer, init) ~logger() { - // force writing all messages from cache, if cache hasn't been turned off yet + // force writing all messages from cache, + // if cache hasn't been turned off yet turn_cache_off(); } /** reads all data about a log message (gathers all the data about it) */ - gather_holder read_msg() const { return gather_holder(*this) ; } + gather_holder read_msg() + const { return gather_holder(*this) ; } write_msg & writer() { return m_writer; } const write_msg & writer() const { return m_writer; } @@ -256,13 +280,16 @@ namespace hpx { namespace util { namespace logging { private: write_msg m_writer; - // a base object - one that can be used to log messages, without having to know the full type of the log. + // a base object - one that can be used to log messages, + // without having to know the full type of the log. forward_to_logger m_base; }; // specialize for write_msg* pointer! - template struct logger : logger_base { - typedef typename detail::find_gather_if_default::gather_type gather_type; + template + struct logger : logger_base { + typedef typename detail::find_gather_if_default + ::gather_type gather_type; typedef typename gather_type::msg_type msg_type; typedef write_msg write_type; @@ -276,7 +303,8 @@ namespace hpx { namespace util { namespace logging { logger_base_type::m_base.forward_to(this); } ~logger() { - // force writing all messages from cache, if cache hasn't been turned off yet + // force writing all messages from cache, + // if cache hasn't been turned off yet turn_cache_off(); } @@ -287,7 +315,8 @@ namespace hpx { namespace util { namespace logging { /** reads all data about a log message (gathers all the data about it) */ - gather_holder read_msg() const { return gather_holder(*this) ; } + gather_holder read_msg() const + { return gather_holder(*this) ; } write_msg & writer() { return *m_writer; } const write_msg & writer() const { return *m_writer; } @@ -305,25 +334,30 @@ namespace hpx { namespace util { namespace logging { } private: write_msg *m_writer; - // a base object - one that can be used to log messages, without having to know the full type of the log. + // a base object - one that can be used to log messages, + // without having to know the full type of the log. forward_to_logger m_base; }; - /** @brief Given a logger class, finds its gather_msg , without needing to know the logger's definition (a typedef is enough) + /** @brief Given a logger class, finds its gather_msg, + without needing to know the logger's definition (a typedef is enough) */ template struct logger_to_gather {}; - template struct logger_to_gather< logger > { + template + struct logger_to_gather< logger > { typedef gather_msg gather_type; }; /** - @param write_msg the write message class. If a pointer, forwards to a pointer. If not a pointer, it holds it by value. + @param write_msg the write message class. If a pointer, forwards to a pointer. + If not a pointer, it holds it by value. */ - template struct implement_default_logger : logger { + template struct implement_default_logger + : logger { typedef typename gather_msg::msg_type msg_type; HPX_LOGGING_FORWARD_CONSTRUCTOR(implement_default_logger,m_writer) @@ -337,7 +371,9 @@ namespace hpx { namespace util { namespace logging { }; // specialization for pointers - template struct implement_default_logger : logger { + template + struct implement_default_logger + : logger { typedef typename gather_msg::msg_type msg_type; implement_default_logger(write_msg * writer = 0) : m_writer(writer) { diff --git a/hpx/util/logging/detail/logger_base.hpp b/hpx/util/logging/detail/logger_base.hpp index 4951ea72d81a..4bd615532f95 100644 --- a/hpx/util/logging/detail/logger_base.hpp +++ b/hpx/util/logging/detail/logger_base.hpp @@ -24,7 +24,8 @@ #include #include -// see "Using the logger(s)/filter(s) after they've been destroyed" section in the documentation +// see "Using the logger(s)/filter(s) after they've been destroyed" +// section in the documentation //#include #ifndef JT28092007_logger_HPP_DEFINED @@ -38,18 +39,22 @@ namespace hpx { namespace util { namespace logging { template struct forward_to_logger ; namespace detail { - template type& as_non_const(const type & t) { return const_cast(t); } + template type& as_non_const(const type & t) + { return const_cast(t); } template struct find_gather_if_default { typedef typename use_default, std::basic_ostringstream > > ::type gather_type; + gather::ostream_like::return_str< + std::basic_string, std::basic_ostringstream > > + ::type gather_type; typedef typename gather_type::msg_type msg_type; }; /** @brief default implementation of keeping cache - (note : you can override the cache() functions, to implement your own cache keeping strategy) + (note : you can override the cache() functions, + to implement your own cache keeping strategy) */ template struct default_cache_keeper { default_cache_keeper() : m_is_cache_turned_off(false) {} @@ -62,7 +67,8 @@ namespace hpx { namespace util { namespace logging { /** I've implemented this as a fast "is turned off" question. - that is, I want to avoid calling cache().is_cache_turned_off(), since calling cache() involves a virtual call + that is, I want to avoid calling cache().is_cache_turned_off(), + since calling cache() involves a virtual call */ bool is_cache_turned_off() const { if ( m_is_cache_turned_off) @@ -76,12 +82,15 @@ namespace hpx { namespace util { namespace logging { return false; } - /** note: this call does not need to be very efficient, since the cache is used seldom, - only at the beginning of the app, when the logging hasn't yet been initialized - thus, we can afford to make it virtual, and the code will become easier + /** note: this call does not need to be very efficient, + since the cache is used seldom, + only at the beginning of the app, when the logging hasn't + yet been initialized + thus, we can afford to make it virtual, + and the code will become easier */ - virtual cache_type & cache() { return m_cache; } - virtual const cache_type & cache() const { return m_cache; } + virtual cache_type & cache() { return m_cache; } + virtual const cache_type & cache() const { return m_cache; } private: cache_type m_cache; @@ -93,28 +102,34 @@ namespace hpx { namespace util { namespace logging { namespace detail { template struct common_base_holder { - typedef typename detail::find_gather_if_default::gather_type gather_type; + typedef typename detail::find_gather_if_default + ::gather_type gather_type; typedef logger common_base_type; /** - ... returns a base object - one that can be used to log messages, without having to know the full type of the log. - Thus, it can also be passed between a library and the application that uses it, and vice-versa. + ... returns a base object - one that can be used to log messages, + without having to know the full type of the log. + Thus, it can also be passed between a library and + the application that uses it, and vice-versa. */ const common_base_type* common_base() const { return &m_base; } common_base_type* common_base() { return &m_base; } protected: - // a base object - one that can be used to log messages, without having to know the full type of the log. + // a base object - one that can be used to log messages, + // without having to know the full type of the log. forward_to_logger m_base; }; // specialize - when write_msg is default, our common base is ourselves template struct common_base_holder { - typedef typename detail::find_gather_if_default::gather_type gather_type; + typedef typename detail::find_gather_if_default + ::gather_type gather_type; typedef logger subclass_type; - const subclass_type* common_base() const { return static_cast(this); } - subclass_type* common_base() { return static_cast(this); } + const subclass_type* common_base() const + { return static_cast(this); } + subclass_type* common_base() { return static_cast(this); } }; } @@ -123,10 +138,14 @@ namespace hpx { namespace util { namespace logging { @class logger_base */ - template struct logger_base - : detail::default_cache_keeper< detail::cache_before_init::msg_type > >, + template + struct logger_base + : detail::default_cache_keeper< detail + ::cache_before_init + ::msg_type > >, detail::common_base_holder { - typedef detail::cache_before_init::msg_type > cache_type; + typedef detail::cache_before_init::msg_type > cache_type; typedef detail::default_cache_keeper< cache_type > cache_base; using cache_base::cache; @@ -136,7 +155,8 @@ namespace hpx { namespace util { namespace logging { protected: logger_base() { #if defined(HPX_LOG_TSS_USE_INTERNAL) - // we need ALL loggers to depend on delete_array - this way, delete_array will be destroyed + // we need ALL loggers to depend on delete_array + // - this way, delete_array will be destroyed // after all loggers are destroyed detail::new_object_ensure_delete< default_ > (); #endif @@ -144,15 +164,17 @@ namespace hpx { namespace util { namespace logging { logger_base(const logger_base&) {} private: - subclass_type & self() { return static_cast(*this); } - const subclass_type & self() const { return static_cast(*this); } + subclass_type & self() { return static_cast(*this); } + const subclass_type & self() const + { return static_cast(*this); } public: /** @brief Marks this logger as initialized - You might log messages before the logger is initialized. In this case, they are cached, and will be written to the logger + You might log messages before the logger is initialized. + In this case, they are cached, and will be written to the logger only when you mark it as "initialized" Example: diff --git a/hpx/util/logging/detail/macros.hpp b/hpx/util/logging/detail/macros.hpp index 7ba29b23e24c..bd276b124032 100644 --- a/hpx/util/logging/detail/macros.hpp +++ b/hpx/util/logging/detail/macros.hpp @@ -15,7 +15,8 @@ // Make HPX inspect tool happy: hpxinspect:nounnamed -// IMPORTANT : the JT28092007_macros_HPP_DEFINED needs to remain constant - don't change the macro name! +// IMPORTANT : the JT28092007_macros_HPP_DEFINED needs to remain constant +// - don't change the macro name! #ifndef JT28092007_macros_HPP_DEFINED #define JT28092007_macros_HPP_DEFINED @@ -23,7 +24,8 @@ # pragma once #endif -#if !defined(HPX_LOG_TSS_USE_INTERNAL) && !defined(HPX_LOG_TSS_USE_BOOST) && !defined(HPX_LOG_TSS_USE_CUSTOM) && !defined(HPX_HAVE_LOG_NO_TSS) +#if !defined(HPX_LOG_TSS_USE_INTERNAL) && !defined(HPX_LOG_TSS_USE_BOOST) \ + && !defined(HPX_LOG_TSS_USE_CUSTOM) && !defined(HPX_HAVE_LOG_NO_TSS) // use has not specified what TSS strategy to use #define HPX_LOG_TSS_USE_INTERNAL @@ -79,10 +81,12 @@ Simply put, you need to use macros to make sure objects (logger(s) and filter(s) - are created before main - are always created before being used -The problem we want to avoid is using a logger object before it's initialized - this could happen +The problem we want to avoid is using a logger object before it's initialized +- this could happen if logging from the constructor of a global/static object. -Using macros makes sure logging happens efficiently. Basically what you want to achieve is something similar to: +Using macros makes sure logging happens efficiently. +Basically what you want to achieve is something similar to: @code if ( is_filter_enabled) @@ -96,13 +100,15 @@ if ( is_filter_enabled) When gathering the message, what the macros will achieve is this: @code -#define YOUR_COOL_MACRO_GOOD if ( !is_filter_enabled) ; else logger.gather_the_message_and_log_it(); +#define YOUR_COOL_MACRO_GOOD if ( !is_filter_enabled) \ +; else logger.gather_the_message_and_log_it(); @endcode The above is the correct way, instead of @code -#define YOUR_COOL_MACRO_BAD if ( is_filter_enabled) logger.gather_the_message_and_log_it(); +#define YOUR_COOL_MACRO_BAD if ( is_filter_enabled) \ +logger.gather_the_message_and_log_it(); @endcode because of @@ -114,7 +120,8 @@ else whatever(); @endcode -In this case, @c whatever() will be called if @c some_test is true, and if @c is_filter_enabled is false. +In this case, @c whatever() will be called if @c some_test is true, +and if @c is_filter_enabled is false. \n\n @@ -156,13 +163,15 @@ HPX_DEFINE_LOG(g_l, logger_type) @endcode -@subsubsection HPX_DEFINE_LOG_WITH_ARGS HPX_DEFINE_LOG_WITH_ARGS - defining a log with arguments +@subsubsection HPX_DEFINE_LOG_WITH_ARGS HPX_DEFINE_LOG_WITH_ARGS +- defining a log with arguments @code HPX_DEFINE_LOG_WITH_ARGS (log_name, logger_type, args) @endcode -This defines a log - and specifies some arguments to be used at its constructed. It should be used in a source file, to define the log. +This defines a log - and specifies some arguments to be used at its constructed. +It should be used in a source file, to define the log. Example: @code @@ -178,7 +187,8 @@ HPX_DEFINE_LOG_WITH_ARGS( g_log_err(), err_log_type, ("err.txt") ) HPX_DECLARE_LOG_FILTER(filter_name, filter_type) @endcode -This declares a log filter. It should be used in a header file, to declare the log filter. +This declares a log filter. +It should be used in a header file, to declare the log filter. Example: @code @@ -201,14 +211,16 @@ HPX_DEFINE_LOG_FILTER(g_log_filter, filter::no_ts ) -@subsubsection HPX_DEFINE_LOG_FILTER_WITH_ARGS HPX_DEFINE_LOG_FILTER_WITH_ARGS - defining a log filter with args +@subsubsection HPX_DEFINE_LOG_FILTER_WITH_ARGS HPX_DEFINE_LOG_FILTER_WITH_ARGS +- defining a log filter with args @code HPX_DEFINE_LOG_FILTER_WITH_ARGS(filter_name, filter_type, args) @endcode -This defines a log filter - and specifies some arguments to be used at its constructed. It should be used in a source file, to define the log filter. +This defines a log filter - and specifies some arguments to be used at its constructed. +It should be used in a source file, to define the log filter. Example: @code @@ -260,7 +272,8 @@ Uses a logger: HPX_LOG_USE_LOG(l, do_func, is_log_enabled) @endcode -Normally you don't use this directly. You use @ref HPX_LOG_USE_LOG_IF_FILTER or @ref HPX_LOG_USE_LOG_IF_LEVEL instead. +Normally you don't use this directly. +You use @ref HPX_LOG_USE_LOG_IF_FILTER or @ref HPX_LOG_USE_LOG_IF_LEVEL instead. See @ref defining_logger_macros for more details @@ -285,7 +298,8 @@ struct no_gather { typedef logger< no_gather, destination::cout > app_log_type; -#define LAPP_ HPX_LOG_USE_SIMPLE_LOG_IF_FILTER(g_log_app(), g_log_filter()->is_enabled() ) +#define LAPP_ HPX_LOG_USE_SIMPLE_LOG_IF_FILTER(g_log_app(), +g_log_filter()->is_enabled() ) @endcode See @ref defining_logger_macros for more details @@ -297,13 +311,15 @@ See @ref defining_logger_macros for more details @subsubsection HPX_LOG_FORMAT_MSG HPX_LOG_FORMAT_MSG -Sets the string class used by the formatter classes. By default, it's std::(w)string +Sets the string class used by the formatter classes. +By default, it's std::(w)string @code HPX_LOG_FORMAT_MSG( string_class ) @endcode -You can do this to optimize formatting the message - that is, use a string class optimized for appending and prepending messages +You can do this to optimize formatting the message +- that is, use a string class optimized for appending and prepending messages (which is basically what formatting is all about). Example: @@ -314,7 +330,8 @@ HPX_LOG_FORMAT_MSG( optimize::cache_string_one_str<> ) @subsubsection HPX_LOG_DESTINATION_MSG HPX_LOG_DESTINATION_MSG -Sets the string class used by the destination classes. By default, it's std::(w)string +Sets the string class used by the destination classes. By default, +it's std::(w)string @code HPX_LOG_DESTINATION_MSG( string_class ) @@ -325,7 +342,9 @@ HPX_LOG_DESTINATION_MSG( string_class ) HPX_LOG_DESTINATION_MSG( std::string ) @endcode -Usually you won't need to change this. The destination classes don't change the contets of the string - each class just writes the string +Usually you won't need to change this. +The destination classes don't change the contets of the string +- each class just writes the string to a given destination. @@ -337,7 +356,8 @@ to a given destination. @subsection macros_use_tags Using tags -Note that tags are only used when you create your own macros for logging. See the tag namespace. +Note that tags are only used when you create your own macros for logging. +See the tag namespace. @subsubsection HPX_LOG_TAG HPX_LOG_TAG @@ -346,13 +366,15 @@ HPX_LOG_TAG(tag_class) @endcode Adds a tag from the hpx::util::logging::tag namespace. -In other words, this is a shortcut for hpx::util::logging::tag::tag_class. Note that in case the @c tag_class has a custom constructor, +In other words, this is a shortcut for hpx::util::logging::tag::tag_class. +Note that in case the @c tag_class has a custom constructor, you need to pass the params as well, after the macro, like shown below. Example: @code -#define L_(module_name) HPX_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() ) .set_tag( HPX_LOG_TAG(module)(module_name) ) +#define L_(module_name) HPX_LOG_USE_LOG_IF_FILTER(g_l(), \ +g_log_filter()->is_enabled() ) .set_tag( HPX_LOG_TAG(module)(module_name) ) @endcode @subsubsection HPX_LOG_TAG_LEVEL HPX_LOG_TAG_LEVEL @@ -366,13 +388,16 @@ HPX_LOG_TAG(tag_level) Example: @code -#define LDBG_ HPX_LOG_USE_LOG_IF_LEVEL(g_log_dbg(), g_log_level(), debug ) .set_tag( HPX_LOG_TAG_LEVEL(debug) ) -#define LERR_ HPX_LOG_USE_LOG_IF_LEVEL(g_log_dbg(), g_log_level(), error ) .set_tag( HPX_LOG_TAG_LEVEL(error) ) +#define LDBG_ HPX_LOG_USE_LOG_IF_LEVEL(g_log_dbg(), g_log_level(), debug ) \ +.set_tag( HPX_LOG_TAG_LEVEL(debug) ) +#define LERR_ HPX_LOG_USE_LOG_IF_LEVEL(g_log_dbg(), g_log_level(), error ) \ +.set_tag( HPX_LOG_TAG_LEVEL(error) ) @endcode @subsubsection HPX_LOG_TAG_FILELINE HPX_LOG_TAG_FILELINE -Ads the file/line tag (that is, the current @c __FILE__ and @c __LINE__ will be appended, for each logged message). +Ads the file/line tag (that is, the current @c __FILE__ and @c __LINE__ will be appended, +for each logged message). @code HPX_LOG_TAG_FILELINE @@ -381,12 +406,14 @@ HPX_LOG_TAG_FILELINE Example: @code -#define L_ HPX_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() ) .set_tag( HPX_LOG_TAG_FILELINE) +#define L_ HPX_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() \ +) .set_tag( HPX_LOG_TAG_FILELINE) @endcode @subsubsection HPX_LOG_TAG_FUNCTION HPX_LOG_TAG_FUNCTION -Ads the function tag (that is, the @c BOOST_CURRENT_FUNCTION will be appended, for each logged message). +Ads the function tag (that is, the @c BOOST_CURRENT_FUNCTION will be appended, +for each logged message). @code HPX_LOG_TAG_FUNCTION @@ -395,7 +422,8 @@ HPX_LOG_TAG_FUNCTION Example: @code -#define L_ HPX_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() ) .set_tag( HPX_LOG_TAG_FUNCTION) +#define L_ HPX_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() ) / +.set_tag( HPX_LOG_TAG_FUNCTION) @endcode @@ -404,14 +432,20 @@ HPX_LOG_TAG_FUNCTION @subsection macros_compile_time Macros that treat compilation time Assume you're using formatters and destinations, and you -#include in every source file when you want to do logging. -This will increase compilation time quite a bit (30 to 50%, in my tests; depending on your application' complexity, this could go higher). +#include in every +source file when you want to do logging. +This will increase compilation time quite a bit +(30 to 50%, in my tests; depending on your application' complexity, +this could go higher). Thus, you can choose to: --# have fast compilation time, and a virtual function call per each logged message (default on debug mode) --# have everything inline (no virtual function calls), very fast, and slower compilation (default on release mode) +-# have fast compilation time, and a virtual function call per +each logged message (default on debug mode) +-# have everything inline (no virtual function calls), very fast, +and slower compilation (default on release mode) -In the former case, most of the time you won't notice the extra virtual function call, and the compilation time will be faster. +In the former case, most of the time you won't notice the extra virtual function call, +and the compilation time will be faster. \n @subsubsection macros_compile_time_fast Fast Compilation time @@ -419,7 +453,8 @@ In the former case, most of the time you won't notice the extra virtual function - this is turned on by default on debug mode - this is turned off by default on release mode - to force it, define HPX_LOG_COMPILE_FAST_ON directive -- applies only to logs that are @ref declare_define "declared/defined using HPX_DECLARE_LOG and HPX_DEFINE_LOG macros" +- applies only to logs that are @ref declare_define +"declared/defined using HPX_DECLARE_LOG and HPX_DEFINE_LOG macros" - this is @em transparent to you, the programmer - to see what headers you should include, @ref headers_to_include "click here" @@ -430,7 +465,8 @@ In the former case, most of the time you won't notice the extra virtual function - this is turned off by default on debug mode - this is turned on by default on release mode - to force it, define HPX_LOG_COMPILE_FAST_OFF directive -- applies only to logs that are @ref declare_define "declared/defined using HPX_DECLARE_LOG and HPX_DEFINE_LOG macros" +- applies only to logs that are @ref declare_define +"declared/defined using HPX_DECLARE_LOG and HPX_DEFINE_LOG macros" - this is @em transparent to you, the programmer - to see what headers you should include, @ref headers_to_include "click here" @@ -439,9 +475,12 @@ In the former case, most of the time you won't notice the extra virtual function \n @subsubsection HPX_LOG_compile_results Compile time sample (and results) -Recently I created a sample (compile_time) to test the effect of @c HPX_LOG_COMPILE_FAST_ON. -The results were not as promising as I had hoped. However, still, when @c HPX_LOG_COMPILE_FAST_ON is on, -will compile faster by 30-40%. Noting that this is just an simple example, the results might not be that conclusive. +Recently I created a sample (compile_time) to test the effect of +@c HPX_LOG_COMPILE_FAST_ON. +The results were not as promising as I had hoped. However, still, +when @c HPX_LOG_COMPILE_FAST_ON is on, +will compile faster by 30-40%. Noting that this is just an simple example, +the results might not be that conclusive. Anyway, here they are: @@ -460,7 +499,8 @@ Tested on 16 jan 2008/intel core duo 2.16Ghz machine, 5400Rpm HDD - Compile with HPX_LOG_COMPILE_FAST_ON (default) - 20.5 secs - Compile with HPX_LOG_COMPILE_FAST_OFF - 24 secs -If you have other results, or results from a big program using Boost Logging, please share them with me. Thanks! +If you have other results, or results from a big program using Boost Logging, +please share them with me. Thanks! @@ -472,16 +512,23 @@ If you have other results, or results from a big program using Boost Logging, pl @subsection macros_tss Macros that deal with Thread Specific Storage -These are the macros that specify what implementation of TSS (Thread Specific Storage) we will be using. -Note that I did my best to remove the dependency on boost::thread - the only dependence left is -when you use use a logger that writes everything @ref writer::on_dedicated_thread "on a dedicated thread". +These are the macros that specify what implementation of TSS (Thread Specific Storage) +we will be using. +Note that I did my best to remove the dependency on boost::thread +- the only dependence left is +when you use use a logger that writes everything @ref writer::on_dedicated_thread +"on a dedicated thread". By default, for TSS, we use the internal implementation (no dependency). The possibilities are: -- @ref HPX_LOG_TSS_USE_INTERNAL : use our internal implementation (no dependency on boost::thread) -- @ref HPX_LOG_TSS_USE_BOOST : use the implementation from boost::thread (dependency on boost::thread, of course). -- @ref HPX_LOG_TSS_USE_CUSTOM : uses a custom implementation. The interface of this implementation should match boost::thread's interface of @c thread_specific_ptr class +- @ref HPX_LOG_TSS_USE_INTERNAL : use our internal implementation + (no dependency on boost::thread) +- @ref HPX_LOG_TSS_USE_BOOST : use the implementation from boost::thread + (dependency on boost::thread, of course). +- @ref HPX_LOG_TSS_USE_CUSTOM : uses a custom implementation. + The interface of this implementation should match boost::thread's interface of + @c thread_specific_ptr class - @ref HPX_HAVE_LOG_NO_TSS : don't use TSS @@ -496,7 +543,8 @@ If defined, it uses the boost::thread's implementation for @ref macros_tss "TSS" @subsubsection HPX_LOG_TSS_USE_CUSTOM HPX_LOG_TSS_USE_CUSTOM If defined, it uses a custom implementation for @ref macros_tss "TSS". -The interface of this implementation should match boost::thread's interface of @c thread_specific_ptr class. +The interface of this implementation should match +boost::thread's interface of @c thread_specific_ptr class. Your class should have this interface: @code @@ -525,25 +573,31 @@ If defined, we don't use @ref macros_tss "TSS" as all. #define HPX_LOG_COMPILE_FAST #endif -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// // Defining filter Macros #ifdef HPX_LOG_COMPILE_FAST // ****** Fast compile ****** -#define HPX_DECLARE_LOG(name,type) ::hpx::util::logging::logger_holder< type > & name (); \ - namespace { hpx::util::logging::ensure_early_log_creation ensure_log_is_created_before_main ## name ( name () ); } +#define HPX_DECLARE_LOG(name,type) \ + ::hpx::util::logging::logger_holder< type > & name (); \ + namespace { hpx::util::logging::ensure_early_log_creation \ + ensure_log_is_created_before_main ## name ( name () ); } -#define HPX_DEFINE_LOG(name,type) ::hpx::util::logging::logger_holder< type > & name () \ +#define HPX_DEFINE_LOG(name,type) \ + ::hpx::util::logging::logger_holder< type > & name () \ { static ::hpx::util::logging::logger_holder_by_value< type > l; return l; } -#define HPX_DEFINE_LOG_WITH_ARGS(name,type, args) ::hpx::util::logging::logger_holder< type > & name () \ - { static ::hpx::util::logging::logger_holder_by_value< type > l ( args ); return l; } +#define HPX_DEFINE_LOG_WITH_ARGS(name,type, args) \ + ::hpx::util::logging::logger_holder< type > & name () \ + { static ::hpx::util::logging::logger_holder_by_value< type > l \ + ( args ); return l; } #else // don't compile fast #define HPX_DECLARE_LOG(name,type) type* name (); \ - namespace { hpx::util::logging::ensure_early_log_creation ensure_log_is_created_before_main ## name ( * name () ); } + namespace { hpx::util::logging::ensure_early_log_creation \ + ensure_log_is_created_before_main ## name ( * name () ); } #define HPX_DEFINE_LOG(name,type) type* name () \ { static type l; return &l; } @@ -558,11 +612,12 @@ If defined, we don't use @ref macros_tss "TSS" as all. -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// // Filter Macros #define HPX_DECLARE_LOG_FILTER(name,type) type* name (); \ - namespace { hpx::util::logging::ensure_early_log_creation ensure_log_is_created_before_main ## name ( * name () ); } + namespace { hpx::util::logging::ensure_early_log_creation \ + ensure_log_is_created_before_main ## name ( * name () ); } #define HPX_DEFINE_LOG_FILTER(name,type) type * name () \ { static type l; return &l; } @@ -581,29 +636,35 @@ If defined, we don't use @ref macros_tss "TSS" as all. -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// // Log Macros -#define HPX_LOG_USE_LOG_IF_LEVEL(l, holder, the_level) HPX_LOG_USE_LOG(l, read_msg().gather().out(), holder->is_enabled(::hpx::util::logging::level:: the_level) ) +#define HPX_LOG_USE_LOG_IF_LEVEL(l, holder, the_level) \ + HPX_LOG_USE_LOG(l, read_msg().gather().out(), \ + holder->is_enabled(::hpx::util::logging::level:: the_level) ) -#define HPX_LOG_USE_LOG_IF_FILTER(l, the_filter) HPX_LOG_USE_LOG(l, read_msg().gather().out(), the_filter) +#define HPX_LOG_USE_LOG_IF_FILTER(l, the_filter) \ + HPX_LOG_USE_LOG(l, read_msg().gather().out(), the_filter) -#define HPX_LOG_USE_SIMPLE_LOG_IF_FILTER(l, is_log_enabled) HPX_LOG_USE_LOG(l, read_msg().gather().out, is_log_enabled) +#define HPX_LOG_USE_SIMPLE_LOG_IF_FILTER(l, is_log_enabled) \ + HPX_LOG_USE_LOG(l, read_msg().gather().out, is_log_enabled) -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// // Format and Destination Macros /** @section HPX_LOG_FORMAT_MSG HPX_LOG_FORMAT_MSG @note - When using HPX_LOG_FORMAT_MSG or HPX_LOG_DESTINATION_MSG, you must not be within any namespace scope. + When using HPX_LOG_FORMAT_MSG or HPX_LOG_DESTINATION_MSG, + you must not be within any namespace scope. - This is because when using this macro, as @c msg_class, you can specify any of your class, or + This is because when using this macro, as @c msg_class, + you can specify any of your class, or something residing in @c hpx::util::logging namespace. */ #define HPX_LOG_FORMAT_MSG(msg_class) \ @@ -614,9 +675,11 @@ If defined, we don't use @ref macros_tss "TSS" as all. /** @section HPX_LOG_DESTINATION_MSG HPX_LOG_DESTINATION_MSG @note - When using HPX_LOG_FORMAT_MSG or HPX_LOG_DESTINATION_MSG, you must not be within any namespace scope. + When using HPX_LOG_FORMAT_MSG or HPX_LOG_DESTINATION_MSG, + you must not be within any namespace scope. - This is because when using this macro, as @c msg_class, you can specify any of your class, or + This is because when using this macro, as @c msg_class, + you can specify any of your class, or something residing in @c hpx::util::logging namespace. */ #define HPX_LOG_DESTINATION_MSG(msg_class) \ @@ -630,7 +693,7 @@ If defined, we don't use @ref macros_tss "TSS" as all. -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// // Tags #define HPX_LOG_STRINGIZE2(x) #x diff --git a/hpx/util/logging/detail/manipulator.hpp b/hpx/util/logging/detail/manipulator.hpp index 821be0f8bce0..a01af66bc19e 100644 --- a/hpx/util/logging/detail/manipulator.hpp +++ b/hpx/util/logging/detail/manipulator.hpp @@ -30,7 +30,8 @@ #include #include -#include // HPX_LOGGING_FORWARD_CONSTRUCTOR_WITH_NEW +#include +// HPX_LOGGING_FORWARD_CONSTRUCTOR_WITH_NEW #include @@ -53,19 +54,26 @@ namespace hpx { namespace util { namespace logging { \n\n\n @section manipulator_common Common base class -All formatters need to derive from a common %base class. Same goes for destinations. +All formatters need to derive from a common %base class. +Same goes for destinations. Remember: -- formatter - allows formatting the message before writing it (like, prepending extra information - an index, the time, thread id, etc) -- destination - is a place where the message is to be written to (like, the console, a file, a socket, etc) +- formatter - allows formatting the message before writing it +(like, prepending extra information - an index, the time, thread id, etc) +- destination - is a place where the message is to be written to +(like, the console, a file, a socket, etc) -In your @ref hpx::util::logging::writer::format_write "format_write" object, you can have several formatters and destinations. +In your @ref hpx::util::logging::writer::format_write "format_write" object, +you can have several formatters and destinations. Note that each formatter class and each destination class is a @c %manipulator. -Each formatter and destination classes implement operator()(arg_type msg);, which +Each formatter and destination classes implement +operator()(arg_type msg);, which processes the message: -- for a formatter, this formats the msg (like, prepends time to it, appends an enter, etc) -- for a destination, this writes the message to a destination (like, to console, a file, etc) +- for a formatter, this formats the msg + (like, prepends time to it, appends an enter, etc) +- for a destination, this writes the message to a destination (like, +to console, a file, etc) @@ -83,17 +91,20 @@ typedef destination::base< arg_type [,ptr_type] > destination_base; @endcode -The @c arg_type is the argument you receive in your operator(), to process the message. It can be as simple as this: +The @c arg_type is the argument you receive in your operator(), +to process the message. It can be as simple as this: @code // formatter - needs to modify the message typedef formatter::base< std::string&> formatter_base; -// destination - needs to write the message - usually, it doesn't need to modify the message +// destination - needs to write the message - usually, +it doesn't need to modify the message typedef destination::base destination_base; @endcode -Or, you can use a @ref customize_manipulator "custom string class", or, even an @ref customize_optimize "optimization string class". +Or, you can use a @ref customize_manipulator "custom string class", or, +even an @ref customize_optimize "optimization string class". So, it's not uncommon to do something like this: @code @@ -112,12 +123,14 @@ typedef destination::base destination_base; \n\n\n @section manipulator_default_base_class Default base classes -As shown above, you can do your own typedefs. But there's an easier way, to specify the default base classes: +As shown above, you can do your own typedefs. But there's an easier way, +to specify the default base classes: use the default formatter %base class and the default destination %base class. They are: formatter::base<> and destination::base<> . -The default formatter %base class is computed based on your usage of the @ref HPX_LOG_FORMAT_MSG macro: +The default formatter %base class is computed based on your usage of the +@ref HPX_LOG_FORMAT_MSG macro: - if you haven't used it, it's std::(w)string & - if you've used it, it's the type you specified there; see below @@ -132,7 +145,8 @@ formatter::base<> = formatter::base< optimize::cache_string_several_str<>& > -The default destination %base class is computed based on your usage of the @ref HPX_LOG_DESTINATION_MSG macro: +The default destination %base class is computed based on your usage of the +@ref HPX_LOG_DESTINATION_MSG macro: - if you haven't used it, it's const std::(w)string & - if you've used it, it's the type you specified there; see below @@ -152,7 +166,8 @@ destination::base<> = destination::base< const my_cool_string & > \n\n\n @section manipulator_generic Using manipulators that come with the library -Now, you will define your @ref logger "logger(s)", to use the @ref hpx::util::logging::writer::format_write "format_write" class: +Now, you will define your @ref logger "logger(s)", +to use the @ref hpx::util::logging::writer::format_write "format_write" class: @code HPX_DECLARE_LOG(g_l, logger_format_write< formatter_base,destination_base> > ); @@ -191,7 +206,8 @@ You can use the formatter and/or destination classes that come with the library: - formatters: in the formatter namespace. Here are a few examples: - formatter::idx - prepends an index - formatter::append_newline - appends an enter after the message - - formatter::append_newline_if_needed - appends an enter after the message, if not already there + - formatter::append_newline_if_needed - appends an enter after the message, + if not already there - formatter::time - prepends the time - formatter::thread_id - prepends the current thread id - destinations: in the destination namespace @@ -199,7 +215,8 @@ You can use the formatter and/or destination classes that come with the library: - destination::stream - writes to a stream - destination::file - writes to file - destination::rolling_file - writes to a rolling file - - destination::shared_memory - writes into shared memory (using @c hpx::util::shmem::named_shared_object) + - destination::shared_memory - writes into shared memory + (using @c hpx::util::shmem::named_shared_object) Or, you can create your own formatter and/or destination class. See below: @@ -208,12 +225,16 @@ Or, you can create your own formatter and/or destination class. See below: \n\n\n @section manipulator_create Creating your own formatter and/or destination class(es) -To create your formatter class, you need to derive from @ref class_ "formatter::class_". You will need to implement -operator()(arg_type)
(@c arg_type is the argument from your @ref manipulator_base_class "formatter base class") +To create your formatter class, you need to derive from +@ref class_ "formatter::class_". You will need to implement +operator()(arg_type)
+(@c arg_type is the argument from your +@ref manipulator_base_class "formatter base class") @code // milliseconds since start of the program -struct ms_since_start : formatter::class_ { +struct ms_since_start : formatter::class_ { time_t m_start; ms_since_start : m_start( time(0) ) {} @@ -228,11 +249,15 @@ struct ms_since_start : formatter::class_operator()(arg_type)
(@c arg_type is the argument from your @ref manipulator_base_class "destination base class") +To create your destination class, you need to derive from +@ref class_ "destination::class_". You will need to implement +operator()(arg_type)
+(@c arg_type is the argument from your @ref manipulator_base_class +"destination base class") @code -struct to_hwnd : destination::class_ { +struct to_hwnd +: destination::class_ { HWND h; to_hwnd(HWND h) : h(h) {} @@ -251,22 +276,30 @@ struct to_hwnd : destination::class_it needs to contain data as constant. -As long as data is constant, it's all ok - that is, no matter what functions get called, all the data in the formatter/destination -must remain constant. We need constant functors - just like in STL - because internally, we copy formatters/destinations: that is, we keep -several copies of a certain object - they all need to be syncronized. In case the objects' data is constant, that's no problem. +As long as data is constant, it's all ok - that is, no matter what functions get called, +all the data in the formatter/destination +must remain constant. We need constant functors - just like in STL - because internally, +we copy formatters/destinations: that is, we keep +several copies of a certain object - they all need to be syncronized. +In case the objects' data is constant, that's no problem. -In case the data needs to be changed - it needs to be shared. Several copies of the same instance must point to the same data. -I've already provided a class you can derive from , when this is the case: the non_const_context class. +In case the data needs to be changed - it needs to be shared. +Several copies of the same instance must point to the same data. +I've already provided a class you can derive from, +when this is the case: the non_const_context class. @code -struct my_file : destination::class_, destination::non_const_context { +struct my_file : destination::class_, +destination::non_const_context { std::string m_filename; bool operator==(const my_file & other) { return m_filename == other.m_filename; } - write_to_file(const std::string & filename) : m_filename(filename), non_const_context_base(filename.c_str()) {} + write_to_file(const std::string & filename) + : m_filename(filename), non_const_context_base(filename.c_str()) {} void operator()(param msg) const { context() << msg << std::endl ; } @@ -277,20 +310,27 @@ struct my_file : destination::class_constant. +In the former case, all the member functions the manipulator exposes +are constant. In the latter case, -- your manipulator class can have member functions that can change its state (non-const member functions). -- your manipulator class @b must use the non_const_context class to hold all its non-const state +- your manipulator class can have member functions that can change its state +(non-const member functions). +- your manipulator class @b must use the non_const_context class to hold +all its non-const state What this guarantees is @ref non_const_pointer_semantics "pointer-like semantics". -Assume that you have your logger that uses formatters and destinations. You've added a manipulator to your logger, -and at a later time, you want to modify it (the manipulator, that is). To achieve this, you'll create a copy, and modify that one (this will work +Assume that you have your logger that uses formatters and destinations. +You've added a manipulator to your logger, +and at a later time, you want to modify it (the manipulator, that is). +To achieve this, you'll create a copy, and modify that one (this will work because of the @ref non_const_pointer_semantics "pointer-like semantics"): Example 1: reusing the same %destination for 2 logs @@ -328,7 +368,8 @@ L_ << "hello world 3"; \n\n\n @section manipulator_use_it Using loggers in code -Now that you've @ref manipulator_generic "added" formatters and/or destinations, you'll @ref defining_logger_macros "define the macros through which you'll do logging", +Now that you've @ref manipulator_generic "added" formatters and/or destinations, +you'll @ref defining_logger_macros "define the macros through which you'll do logging", and then do logging in your code: @code @@ -386,7 +427,8 @@ template< /** @brief Override this if you want to allow configuration through scripting - That is, this allows configuration of your manipulator (formatter/destination) at run-time. + That is, this allows configuration of your manipulator (formatter/destination) + at run-time. */ virtual void configure(const hold_string_type& ) {} @@ -400,13 +442,17 @@ template< /** - @brief When you implement your manipulator class, how is operator== to be implemented? + @brief When you implement your manipulator class, + how is operator== to be implemented? */ struct implement_op_equal { enum type { - /// manipulator has no context - that is, any two values of this type are considered equal (operator== will automatically return true) + /// manipulator has no context + /// - that is, any two values of this type are considered equal + /// (operator== will automatically return true) no_context, - /// manipulator has context - that is, you have to implement operator== in your manipulator class + /// manipulator has context - that is, you have to implement operator== + /// in your manipulator class has_context }; }; @@ -420,7 +466,8 @@ namespace detail { } /** - @brief Use this when implementing your own formatter or destination class. Don't use this directly. Use formatter::class_ or destination::class_ + @brief Use this when implementing your own formatter or destination class. + Don't use this directly. Use formatter::class_ or destination::class_ */ template struct class_ : base_type, @@ -429,7 +476,8 @@ template struct clas /** @brief Override this if you want to allow configuration through scripting - That is, this allows configuration of your manipulator (formatter/destination) at run-time. + That is, this allows configuration of your manipulator + (formatter/destination) at run-time. */ virtual void configure(const hold_string_type& ) {} @@ -437,7 +485,8 @@ template struct clas -/** @brief In case your manipulator (formatter or destination) needs to hold non-const context information, it can to derive from this. +/** @brief In case your manipulator (formatter or destination) +needs to hold non-const context information, it can to derive from this. This automatically creates a shared pointer to the context information. Also, it provides the following operations: @@ -447,7 +496,8 @@ Also, it provides the following operations: Example: @code -struct write_to_file : destination_base, destination::non_const_context { +struct write_to_file : destination_base, +destination::non_const_context { write_to_file(const char* filename) : non_const_context_base(filename) {} void operator()(param msg) const { context() << msg ; @@ -457,7 +507,8 @@ void operator()(param msg) const { @section non_const_pointer_semantics non_const_context - Pointer-like semantics -Using non_const_context guarantees @em pointer-like semantics: if you copy-construct or copy-assign a value, both values will point to the same context: +Using non_const_context guarantees @em pointer-like semantics: +if you copy-construct or copy-assign a value, both values will point to the same context: @code write_to_file a, b = a; @@ -501,13 +552,18 @@ template struct non_const_context { //-V690 /** @brief Represents a generic manipulator (formatter or destination) -A generic manipulator is one that does not derive from any formatter_base or destination_base class (@ref manipulator_base_class). +A generic manipulator is one that does not derive from any formatter_base +or destination_base class (@ref manipulator_base_class). -Libraries, such as this one, can provide generic manipulators, and they can't rely on -any @ref manipulator_base_class "base class" - since it's you, the user, who can choose which is the base class. +Libraries, such as this one, can provide generic manipulators, +and they can't rely on +any @ref manipulator_base_class "base class" - since it's you, +the user, who can choose which is the base class. -A generic manipulator has no way of knowing the type of the @em msg you pass on operator(). -Thus, usually generic manipulators have a templated operator=, and do the best to convert what's in, to what they need. +A generic manipulator has no way of knowing the type of the +@em msg you pass on operator(). +Thus, usually generic manipulators have a templated operator=, +and do the best to convert what's in, to what they need. Example: @code @@ -518,9 +574,12 @@ template struct cout { }; @endcode -As long as exists a conversion function from your @c msg_type to what the manipulator needs, it all works. -Thus, no matter what your %formatter @ref manipulator_base_class "base class" or %destination @ref manipulator_base_class "base class" -is, the code will still work. You can add your %formatter/ %destination classes, and the generic %formatter/ %destination classes +As long as exists a conversion function from your @c msg_type to what +the manipulator needs, it all works. +Thus, no matter what your %formatter @ref manipulator_base_class "base class" or +%destination @ref manipulator_base_class "base class" +is, the code will still work. You can add your %formatter/ %destination classes, +and the generic %formatter/ %destination classes @code typedef ... formatter_base; @@ -542,7 +601,8 @@ struct is_generic { /** @brief Override this if you want to allow configuration through scripting - That is, this allows configuration of your manipulator (formatter/destination) at run-time. + That is, this allows configuration of your manipulator + (formatter/destination) at run-time. */ virtual void configure(const hold_string_type& ) {} }; @@ -589,9 +649,11 @@ namespace detail { } // namespace manipulator /** -@brief Formatter is a manipulator. It allows you to format the message before writing it to the destination(s) +@brief Formatter is a manipulator. +It allows you to format the message before writing it to the destination(s) -Examples of formatters are : @ref formatter::time_t "prepend the time", @ref formatter::high_precision_time_t "prepend high-precision time", +Examples of formatters are : @ref formatter::time_t "prepend the time", +@ref formatter::high_precision_time_t "prepend high-precision time", @ref formatter::idx_t "prepend the index of the message", etc. @@ -603,9 +665,13 @@ Examples of formatters are : @ref formatter::time_t "prepend the time", @ref for */ namespace formatter { namespace detail { - template struct format_base_finder { - typedef typename use_default::type > ::type arg_type; - typedef hpx::util::logging::manipulator::base< arg_type, arg_type &, ptr> type; + template + struct format_base_finder { + typedef typename use_default::type > + ::type arg_type; + typedef hpx::util::logging::manipulator::base< arg_type, arg_type &, ptr> + type; }; } @@ -631,11 +697,15 @@ namespace formatter { @brief Use this when implementing your own formatter class @param type Your own class name - @param op_e How will you @ref hpx::util::logging::manipulator::implement_op_equal "implement operator==" + @param op_e How will you @ref + hpx::util::logging::manipulator::implement_op_equal "implement operator==" - @param base_type (optional) The formatter base class. Unless you've specified your own formatter class, you'll be happy with the default + @param base_type (optional) The formatter base class. + Unless you've specified your own formatter class, + you'll be happy with the default */ - template > struct class_ + template > struct class_ : hpx::util::logging::manipulator::class_ {}; @@ -649,9 +719,11 @@ namespace formatter { } /** -@brief Destination is a manipulator. It contains a place where the message, after being formatted, is to be written to. +@brief Destination is a manipulator. It contains a place where the message, +after being formatted, is to be written to. -Some viable destinations are : @ref destination::cout_t "the console", @ref destination::file_t "a file", a socket, etc. +Some viable destinations are : @ref destination::cout_t "the console", +@ref destination::file_t "a file", a socket, etc. See: - @ref manipulator "The manipulator namespace" @@ -662,9 +734,13 @@ Some viable destinations are : @ref destination::cout_t "the console", @ref dest */ namespace destination { namespace detail { - template struct destination_base_finder { - typedef typename use_default::type > ::type arg_type; - typedef hpx::util::logging::manipulator::base< arg_type, const arg_type &, ptr> type; + template + struct destination_base_finder { + typedef typename use_default::type > + ::type arg_type; + typedef hpx::util::logging::manipulator::base< arg_type, + const arg_type &, ptr> type; }; } @@ -692,11 +768,15 @@ namespace destination { @brief Use this when implementing your own destination class @param type Your own class name - @param op_e How will you @ref hpx::util::logging::manipulator::implement_op_equal "implement operator==" + @param op_e How will you @ref + hpx::util::logging::manipulator::implement_op_equal "implement operator==" - @param base_type (optional) The destination base class. Unless you've specified your own destination class, you'll be happy with the default + @param base_type (optional) + The destination base class. Unless you've specified your own destination class, + you'll be happy with the default */ - template > struct class_ + template > struct class_ : hpx::util::logging::manipulator::class_ {}; /** diff --git a/hpx/util/logging/detail/old/macros_old.hpp b/hpx/util/logging/detail/old/macros_old.hpp index ca1899c9c9fd..d79c195ed161 100644 --- a/hpx/util/logging/detail/old/macros_old.hpp +++ b/hpx/util/logging/detail/old/macros_old.hpp @@ -15,7 +15,8 @@ // Make HPX inspect tool happy: hpxinspect:nounnamed -// IMPORTANT : the JT28092007_macros_HPP_DEFINED needs to remain constant - don't change the macro name! +// IMPORTANT : the JT28092007_macros_HPP_DEFINED needs to remain constant\ +- don't change the macro name! #ifndef JT28092007_macros_HPP_DEFINED #define JT28092007_macros_HPP_DEFINED @@ -43,11 +44,12 @@ namespace hpx { namespace util { namespace logging { #endif -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// // Defining filter Macros /* - when compile fast is "off", we always need HPX_LOG_MANIPULATE_LOGS, to get access to the logger class typedefs; + when compile fast is "off", we always need HPX_LOG_MANIPULATE_LOGS, + to get access to the logger class typedefs; */ #if !defined(HPX_LOG_COMPILE_FAST) #if !defined(HPX_LOG_MANIPULATE_LOGS) @@ -61,21 +63,25 @@ namespace hpx { namespace util { namespace logging { #ifdef HPX_LOG_COMPILE_FAST // ****** Fast compile ****** -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// // use log #define HPX_USE_LOG_FIND_GATHER(name,log_type,base_type) \ namespace hpx { namespace util { namespace logging { namespace log_define_ { \ - extern ::hpx::util::logging::detail::log_keeper< base_type, name ## _HPX_LOG_impl_, ::hpx::util::logging::detail::call_write_logger_finder< log_type, gather_msg > ::type > name ; \ + extern ::hpx::util::logging::detail::log_keeper< base_type, \ + name ## _HPX_LOG_impl_, ::hpx::util::logging::detail::call_write_logger_finder< \ + log_type, gather_msg > ::type > name ; \ }}}} \ using hpx { namespace util_log_define_:: name ; -#define HPX_USE_LOG(name,type) HPX_USE_LOG_FIND_GATHER(name, type, ::hpx::util::logging::detail::fast_compile_with_default_gather<>::log_type ) +#define HPX_USE_LOG(name,type) HPX_USE_LOG_FIND_GATHER(name, type, \ + ::hpx::util::logging::detail::fast_compile_with_default_gather<>::log_type ) #define HPX_DECLARE_LOG_KEEPER(name,log_type) \ namespace hpx { namespace util { namespace logging { namespace log_declare_ { \ - extern ::hpx::util::logging::detail::log_keeper< log_type, name ## _HPX_LOG_impl_ > name; \ + extern ::hpx::util::logging::detail::log_keeper< log_type, \ + name ## _HPX_LOG_impl_ > name; \ }}}} \ using hpx { namespace util_log_declare_ :: name ; @@ -98,34 +104,45 @@ namespace hpx { namespace util { namespace logging { #define HPX_DECLARE_LOG_FIND_GATHER(name) \ - HPX_DECLARE_LOG_WITH_LOG_TYPE(name, ::hpx::util::logging::detail::fast_compile_with_default_gather<>::log_type ) + HPX_DECLARE_LOG_WITH_LOG_TYPE(name, \ + ::hpx::util::logging::detail::fast_compile_with_default_gather<>::log_type ) #define HPX_DECLARE_LOG(name,type) HPX_DECLARE_LOG_FIND_GATHER(name) -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// // define log -#define HPX_DEFINE_LOG_FIND_GATHER(name, log_type, base_type, gather_msg) base_type & name ## _HPX_LOG_impl_() \ -{ typedef ::hpx::util::logging::detail::call_write_logger_finder< log_type, gather_msg > ::type logger_type; \ +#define HPX_DEFINE_LOG_FIND_GATHER(name, log_type, base_type, gather_msg) \ + base_type & name ## _HPX_LOG_impl_() \ +{ typedef ::hpx::util::logging::detail::call_write_logger_finder< log_type, \ + gather_msg > ::type logger_type; \ static logger_type i; return i; } \ - namespace { hpx::util::logging::detail::fake_using_log ensure_log_is_created_before_main ## name ( name ## _HPX_LOG_impl_() ); } \ + namespace { hpx::util::logging::detail::fake_using_log \ + ensure_log_is_created_before_main ## name ( name ## _HPX_LOG_impl_() ); } \ namespace hpx { namespace util_log_declare_ { \ - ::hpx::util::logging::detail::log_keeper< base_type, name ## _HPX_LOG_impl_ > name ; \ - } \ + ::hpx::util::logging::detail::log_keeper< base_type, name ## _HPX_LOG_impl_ > \ + name ; } \ namespace hpx { namespace util_log_define_ { \ - ::hpx::util::logging::detail::log_keeper< base_type, name ## _HPX_LOG_impl_, ::hpx::util::logging::detail::call_write_logger_finder< log_type, gather_msg > ::type > name ; \ + ::hpx::util::logging::detail::log_keeper< base_type, \ + name ## _HPX_LOG_impl_, ::hpx::util::logging::detail::call_write_logger_finder< \ + log_type, gather_msg > ::type > name ; \ } \ using hpx { namespace util_log_define_ :: name ; #define HPX_DEFINE_LOG(name,type) \ - HPX_DEFINE_LOG_FIND_GATHER(name, type, ::hpx::util::logging::detail::fast_compile_with_default_gather<>::log_type, ::hpx::util::logging::detail::fast_compile_with_default_gather<>::gather_msg ) + HPX_DEFINE_LOG_FIND_GATHER(name, type, \ + ::hpx::util::logging::detail::fast_compile_with_default_gather<>::log_type, \ + ::hpx::util::logging::detail::fast_compile_with_default_gather<>::gather_msg ) #else // don't compile fast -#define HPX_DECLARE_LOG(name,type) type& name ## _HPX_LOG_impl_(); extern hpx::util::logging::detail::log_keeper name; +#define HPX_DECLARE_LOG(name,type) type& name ## _HPX_LOG_impl_(); \ + extern hpx::util::logging::detail::log_keeper name; #define HPX_DEFINE_LOG(name,type) type& name ## _HPX_LOG_impl_() \ { static type i; return i; } \ - namespace { hpx::util::logging::detail::fake_using_log ensure_log_is_created_before_main ## name ( name ## _HPX_LOG_impl_() ); } \ + namespace { hpx::util::logging::detail::\ + fake_using_log ensure_log_is_created_before_main ## name \ + ( name ## _HPX_LOG_impl_() ); } \ hpx::util::logging::detail::log_keeper name; /** @@ -135,32 +152,45 @@ namespace hpx { namespace util { namespace logging { #endif -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// // Filter Macros -#define HPX_DECLARE_LOG_FILTER_NO_NAMESPACE_PREFIX(name,type) type& name ## _HPX_LOG_filter_impl_(); extern hpx::util::logging::detail::log_filter_keeper name; -#define HPX_DEFINE_LOG_FILTER_NO_NAMESPACE_PREFIX(name,type) type& name ## _HPX_LOG_filter_impl_() \ +#define HPX_DECLARE_LOG_FILTER_NO_NAMESPACE_PREFIX(name,type) \ + type& name ## _HPX_LOG_filter_impl_(); \ + extern hpx::util::logging::detail::log_filter_keeper name; +#define HPX_DEFINE_LOG_FILTER_NO_NAMESPACE_PREFIX(name,type) \ + type& name ## _HPX_LOG_filter_impl_() \ { static type i; return i; } \ - namespace { hpx::util::logging::detail::fake_using_log ensure_log_is_created_before_main ## name ( name ## _HPX_LOG_filter_impl_() ); } \ - hpx::util::logging::detail::log_filter_keeper name; + namespace { hpx::util::logging::detail::fake_using_log \ + ensure_log_is_created_before_main ## name ( name ## _HPX_LOG_filter_impl_() ); } \ + hpx::util::logging::detail::log_filter_keeper name; -#define HPX_DECLARE_LOG_FILTER(name,type) HPX_DECLARE_LOG_FILTER_NO_NAMESPACE_PREFIX(name, ::hpx::util::logging:: type) +#define HPX_DECLARE_LOG_FILTER(name,type) \ + HPX_DECLARE_LOG_FILTER_NO_NAMESPACE_PREFIX(name, ::hpx::util::logging:: type) -#define HPX_DEFINE_LOG_FILTER(name,type) HPX_DEFINE_LOG_FILTER_NO_NAMESPACE_PREFIX(name, ::hpx::util::logging:: type) +#define HPX_DEFINE_LOG_FILTER(name,type) \ + HPX_DEFINE_LOG_FILTER_NO_NAMESPACE_PREFIX(name, ::hpx::util::logging:: type) -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// // Log Macros -#define HPX_LOG_USE_LOG(l, do_func, is_log_enabled) if ( !(is_log_enabled) ) ; else l -> do_func +#define HPX_LOG_USE_LOG(l, do_func, is_log_enabled) \ + if ( !(is_log_enabled) ) ; else l -> do_func -#define HPX_LOG_USE_LOG_IF_LEVEL(l, holder, the_level) HPX_LOG_USE_LOG(l, read_msg().gather().out(), holder->is_enabled(::hpx::util::logging::level:: the_level) ) +#define HPX_LOG_USE_LOG_IF_LEVEL(l, holder, the_level) \ + HPX_LOG_USE_LOG(l, read_msg().gather().out(), \ + holder->is_enabled(::hpx::util::logging::level:: the_level) ) -#define HPX_LOG_USE_LOG_IF_FILTER(l, the_filter) HPX_LOG_USE_LOG(l, read_msg().gather().out(), the_filter) +#define HPX_LOG_USE_LOG_IF_FILTER(l, the_filter) \ + HPX_LOG_USE_LOG(l, read_msg().gather().out(), the_filter) -#define HPX_LOG_USE_SIMPLE_LOG_IF_FILTER(l, is_log_enabled) if ( !(is_log_enabled) ) ; else l ->operator() +#define HPX_LOG_USE_SIMPLE_LOG_IF_FILTER(l, is_log_enabled) \ + if ( !(is_log_enabled) ) ; else l ->operator() -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// // Format and Destination Macros #define HPX_LOG_FORMAT_MSG(msg_class) \ @@ -170,7 +200,8 @@ namespace hpx { namespace util { namespace logging { #define HPX_LOG_DESTINATION_MSG(msg_class) \ namespace hpx { namespace util { namespace logging { \ - template<> struct destination::msg_type { typedef const msg_class & type; }; \ + template<> struct destination::msg_type \ + { typedef const msg_class & type; }; \ }}} }}} diff --git a/hpx/util/logging/detail/scenario.hpp b/hpx/util/logging/detail/scenario.hpp index e2b7e5a8de3f..ff166d004244 100644 --- a/hpx/util/logging/detail/scenario.hpp +++ b/hpx/util/logging/detail/scenario.hpp @@ -36,7 +36,8 @@ Example 1: @code using namespace hpx::util::logging::scenario::usage; -typedef use< filter_::change::often<10>, filter_::level::use_levels, default_, logger_::favor::speed> finder; +typedef use< filter_::change::often<10>, filter_::level::use_levels, default_, +logger_::favor::speed> finder; HPX_DECLARE_LOG_FILTER(g_log_filter, finder::filter); HPX_DECLARE_LOG(g_l, finder::logger) @@ -51,7 +52,8 @@ Example 2: @code using namespace hpx::util::logging::scenario::usage; -typedef use< filter_::change::set_once_when_multiple_threads, filter_::level::no_levels, logger_::change::set_once_when_one_thread> finder; +typedef use< filter_::change::set_once_when_multiple_threads, +filter_::level::no_levels, logger_::change::set_once_when_one_thread> finder; HPX_DECLARE_LOG_FILTER(g_log_filter, finder::filter); HPX_DECLARE_LOG(g_l, finder::logger) @@ -85,7 +87,9 @@ namespace writer { } /** -@brief Use this when you have a specific scenario, and want the best logger/filter classes that fit that scenario. Check out scenario::usage and scenario::ts. +@brief Use this when you have a specific scenario, +and want the best logger/filter classes that fit that scenario. +Check out scenario::usage and scenario::ts. For example, if you want to specify a %scenario based on usage: @@ -95,7 +99,9 @@ For example, if you want to specify a %scenario based on usage: namespace scenario { /** -@brief If you want the library to choose the best logger/filter classes based on how your application will %use the loggers and filters, %use this namespace. +@brief If you want the library to choose the best logger/filter +classes based on how your application will %use the loggers and filters, +%use this namespace. First, don't forget to @@ -118,7 +124,8 @@ namespace usage { namespace filter_ { /** @brief When does the filter change? */ namespace change { - /** @brief Optimize for %often %change. Does per-thread caching. At a given period, it re-synchronizes. + /** @brief Optimize for %often %change. Does per-thread caching. + At a given period, it re-synchronizes. This is the default, for a multi-threaded application. @@ -126,24 +133,31 @@ namespace usage { */ template struct often {}; - /** @brief Set only once, when there's only one thread running - thus, you don't need to worry about thread-syncronizing */ + /** @brief Set only once, when there's only one thread running + - thus, you don't need to worry about thread-syncronizing */ struct set_once_when_one_thread {}; /** @brief Set only once, when there could be multiple thread running. - We automatically implement a strategy to check if the filter/logger has been initialized, and when it's done, we cache + We automatically implement a strategy to check if + the filter/logger has been initialized, and when it's done, we cache the result on every thread */ struct set_once_when_multiple_threads {}; - /** @brief This is always accurate. However, it's the slowest too. + /** @brief This is always accurate. + However, it's the slowest too. - In case of multiple threads, it always locks the logger/filter before accessing it. + In case of multiple threads, + it always locks the logger/filter before accessing it. - Not recommended, you should usually go with another strategy (often, set_once_when_one_thread or set_once_when_multiple_threads) + Not recommended, + you should usually go with another strategy + (often, set_once_when_one_thread or set_once_when_multiple_threads) */ struct always_accurate {}; - /** @brief Single threading. It doesn't matter when/how %often the filter/logger changes. + /** @brief Single threading. + It doesn't matter when/how %often the filter/logger changes. This is the default, for a single-threaded application. */ @@ -177,30 +191,38 @@ namespace usage { adding/removing formatters/destinations for instance. */ namespace change { - /** @brief Optimize for often change. Does per-thread caching. At a given period, it re-synchronizes. This is the default, for multi-threaded applications. + /** @brief Optimize for often change. Does per-thread caching. + At a given period, it re-synchronizes. + This is the default, for multi-threaded applications. @param cache_period_secs At what period should we re-syncronize */ template struct often {}; - /** @brief Set only once, when there's only one thread running - thus, you don't need to worry about thread-syncronizing */ + /** @brief Set only once, when there's only one thread running + - thus, you don't need to worry about thread-syncronizing */ struct set_once_when_one_thread {}; /** @brief Set only once, when there could be multiple thread running. - We automatically implement a strategy to check if the filter/logger has been initialized, and when it's done, we cache + We automatically implement a strategy to check if + the filter/logger has been initialized, and when it's done, we cache the result on every thread */ struct set_once_when_multiple_threads {}; /** @brief This is always accurate. However, it's the slowest too. - In case of multiple threads, it always locks the logger/filter before accessing it. + In case of multiple threads, + it always locks the logger/filter before accessing it. - Not recommended, you should usually go with another strategy (often, set_once_when_one_thread or set_once_when_multiple_threads) + Not recommended, you should usually go with another strategy + (often, set_once_when_one_thread or set_once_when_multiple_threads) */ struct always_accurate {}; - /** @brief Single threading. It doesn't matter when/how often the filter/logger changes. This is the default, for single-threaded applications. + /** @brief Single threading. + It doesn't matter when/how often the filter/logger changes. + This is the default, for single-threaded applications. */ struct single_thread {}; @@ -213,19 +235,24 @@ namespace usage { /** @brief When logging, what should we %favor? */ namespace favor { - /** @brief This will favor speed (logging will happen on a dedicated thread). The only problem you could have is if the application crashes. + /** @brief This will favor speed (logging will happen on a dedicated thread). + The only problem you could have is if the application crashes. - In this case, on Windows, the rest of the application will continue, and any non-flushed log message will be flushed. + In this case, on Windows, + the rest of the application will continue, + and any non-flushed log message will be flushed. On POSIX, this may not be the case. */ struct speed {}; - /** @brief All messages will be logged. This is the default for multi-threaded application + /** @brief All messages will be logged. + This is the default for multi-threaded application */ struct correctness {}; - /** @brief Single threading. It doesn't matter when/how often the filter/logger changes. This is the default, for single-threaded applications. + /** @brief Single threading. It doesn't matter when/how often the + filter/logger changes. This is the default, for single-threaded applications. */ struct single_thread {}; @@ -258,15 +285,18 @@ namespace usage { template struct find_filter_use_levels {}; - template struct find_filter_use_levels< change::often > { + template struct find_filter_use_levels + < change::often > { typedef ::hpx::util::logging::level::holder_tss_with_cache type; }; - template<> struct find_filter_use_levels< change::set_once_when_one_thread > { + template<> struct find_filter_use_levels + < change::set_once_when_one_thread > { typedef ::hpx::util::logging::level::holder_no_ts type; }; - template<> struct find_filter_use_levels< change::set_once_when_multiple_threads > { + template<> struct find_filter_use_levels + < change::set_once_when_multiple_threads > { typedef ::hpx::util::logging::level::holder_tss_once_init type; }; @@ -284,15 +314,18 @@ namespace usage { template struct find_filter_no_levels {}; - template struct find_filter_no_levels< change::often > { + template struct find_filter_no_levels + < change::often > { typedef ::hpx::util::logging::filter::use_tss_with_cache type; }; - template<> struct find_filter_no_levels< change::set_once_when_one_thread > { + template<> struct find_filter_no_levels + < change::set_once_when_one_thread > { typedef ::hpx::util::logging::filter::no_ts type; }; - template<> struct find_filter_no_levels< change::set_once_when_multiple_threads > { + template<> struct find_filter_no_levels + < change::set_once_when_multiple_threads >{ typedef ::hpx::util::logging::filter::use_tss_once_init type; }; @@ -325,62 +358,95 @@ namespace usage { namespace gather_usage = ::hpx::util::logging::scenario::usage::logger_::gather; template struct find_threading_from_favor {}; - template<> struct find_threading_from_favor { typedef th::on_dedicated_thread type; }; - template<> struct find_threading_from_favor { typedef th::ts_write type; }; - template<> struct find_threading_from_favor { typedef th::no_ts type; }; + template<> struct find_threading_from_favor + { typedef th::on_dedicated_thread type; }; + template<> struct find_threading_from_favor + { typedef th::ts_write type; }; + template<> struct find_threading_from_favor + { typedef th::no_ts type; }; template struct find_gather {}; - template<> struct find_gather { typedef ::hpx::util::logging::default_ type; }; - template struct find_gather > { typedef custom_gather type; }; + template<> struct find_gather + { typedef ::hpx::util::logging::default_ type; }; + template + struct find_gather > + { typedef custom_gather type; }; template struct find_logger {}; - template struct find_logger< favor_, change::often, gather > { + template + struct find_logger< favor_, change::often, gather > { typedef typename find_threading_from_favor::type threading_type; - template struct lock_resource : ::hpx::util::logging::lock_resource_finder::tss_with_cache {}; + template struct lock_resource : + ::hpx::util::logging::lock_resource_finder::tss_with_cache {}; - typedef ::hpx::util::logging::logger_format_write < default_, default_, threading_type, gather, lock_resource > type; + typedef ::hpx::util::logging::logger_format_write < default_, + default_, threading_type, gather, lock_resource > type; }; - template struct find_logger< favor_, change::set_once_when_one_thread, gather > { + template struct find_logger< favor_, + change::set_once_when_one_thread, gather > { typedef typename find_threading_from_favor::type threading_type; - typedef ::hpx::util::logging::lock_resource_finder::single_thread lock_resource; + typedef ::hpx::util::logging::lock_resource_finder + ::single_thread lock_resource; - typedef ::hpx::util::logging::logger_format_write< default_, default_, threading_type, gather, lock_resource> type; + typedef ::hpx::util::logging::logger_format_write< default_, + default_, threading_type, gather, lock_resource> type; }; - template struct find_logger< favor_, change::set_once_when_multiple_threads, gather > { - typedef typename find_threading_from_favor::type threading_type; - typedef ::hpx::util::logging::lock_resource_finder::tss_once_init<> lock_resource; + template struct find_logger< favor_, + change::set_once_when_multiple_threads, gather > { + typedef typename find_threading_from_favor + ::type threading_type; + typedef ::hpx::util::logging::lock_resource_finder + ::tss_once_init<> lock_resource; - typedef ::hpx::util::logging::logger_format_write< default_, default_, threading_type, gather, lock_resource> type; + typedef ::hpx::util::logging::logger_format_write< default_, default_, + threading_type, gather, lock_resource> type; }; - template struct find_logger< favor_, change::always_accurate, gather > { + template struct find_logger< favor_, + change::always_accurate, gather > { typedef typename find_threading_from_favor::type threading_type; typedef ::hpx::util::logging::lock_resource_finder::ts<> lock_resource; - typedef ::hpx::util::logging::logger_format_write< default_, default_, threading_type, gather, lock_resource> type; + typedef ::hpx::util::logging::logger_format_write< default_, default_, + threading_type, gather, lock_resource> type; }; - template struct find_logger< favor_, change::single_thread, gather > { - typedef typename find_threading_from_favor::type threading_type; - typedef ::hpx::util::logging::lock_resource_finder::single_thread lock_resource; + template + struct find_logger< favor_, change::single_thread, gather > { + typedef typename find_threading_from_favor + ::type threading_type; + typedef ::hpx::util::logging::lock_resource_finder + ::single_thread lock_resource; - typedef ::hpx::util::logging::logger_format_write< default_, default_, threading_type, gather, lock_resource> type; + typedef ::hpx::util::logging::logger_format_write< default_, default_, + threading_type, gather, lock_resource> type; }; } /** @brief Finds a filter class and a logger class that fit your application's needs - For this to happen, you will first need to specify your needs (the template parameters you'll pass to this class) - - @param filter_change @ref misc_use_defaults "(optional)" How does the %filter change? Any of the classes in the filter_::change namespace - @param filter_level_ @ref misc_use_defaults "(optional)" Does our %filter %use levels? Any of the classes in the filter_::level namespace - @param logger_change @ref misc_use_defaults "(optional)" How does our %logger change? Any of the classes in the logger_::change namespace - @param logger_favor @ref misc_use_defaults "(optional)" What does the %logger favor? Any of the classes in the logger_::favor namespace - @param logger_gather @ref misc_use_defaults "(optional)" What to %use as gather class. Any of the classes in the logger_::gather namespace + For this to happen, you will first need to specify your needs + (the template parameters you'll pass to this class) + + @param filter_change @ref misc_use_defaults + "(optional)" How does the %filter change? + Any of the classes in the filter_::change namespace + @param filter_level_ @ref misc_use_defaults + "(optional)" Does our %filter %use levels? + Any of the classes in the filter_::level namespace + @param logger_change @ref misc_use_defaults + "(optional)" How does our %logger change? + Any of the classes in the logger_::change namespace + @param logger_favor @ref misc_use_defaults + "(optional)" What does the %logger favor? + Any of the classes in the logger_::favor namespace + @param logger_gather @ref misc_use_defaults + "(optional)" What to %use as gather class. + Any of the classes in the logger_::gather namespace @copydoc your_scenario_examples */ @@ -393,18 +459,26 @@ namespace usage { struct use { private: - typedef typename use_default::type filter_change_type; - typedef typename use_default::type filter_level_type; + typedef typename use_default + ::type filter_change_type; + typedef typename use_default + ::type filter_level_type; - typedef typename use_default::type logger_change_type; - typedef typename use_default::type logger_favor_type; - typedef typename use_default::type gather_usage_type; + typedef typename use_default + ::type logger_change_type; + typedef typename use_default + ::type logger_favor_type; + typedef typename use_default + ::type gather_usage_type; - typedef typename detail_find_logger::find_gather ::type gather_type; + typedef typename detail_find_logger::find_gather + ::type gather_type; public: - typedef typename detail_find_filter::find_filter::type filter; - typedef typename detail_find_logger::find_logger< logger_favor_type, logger_change_type, gather_type>::type logger; + typedef typename detail_find_filter::find_filter::type filter; + typedef typename detail_find_logger::find_logger< logger_favor_type, + logger_change_type, gather_type>::type logger; }; } @@ -435,7 +509,8 @@ HPX_DECLARE_LOG(g_l, finder::logger) @endcode -To see how you can specify the logger/filter based on how you will %use them, see usage namespace. +To see how you can specify the logger/filter based on how you will %use them, +see usage namespace. */ namespace ts { // ... bring it in this namespace @@ -482,36 +557,49 @@ namespace ts { namespace th = ::hpx::util::logging::writer::threading; template struct find_filter {}; - template<> struct find_filter { typedef ::hpx::util::logging::filter::no_ts type; }; - template<> struct find_filter { typedef ::hpx::util::logging::filter::use_tss_with_cache<5> type; }; - template<> struct find_filter { typedef ::hpx::util::logging::filter::ts type; }; - - template<> struct find_filter { typedef ::hpx::util::logging::level::holder_no_ts type; }; - template<> struct find_filter { typedef ::hpx::util::logging::level::holder_tss_with_cache<5> type; }; - template<> struct find_filter { typedef ::hpx::util::logging::level::holder_ts type; }; + template<> struct find_filter + { typedef ::hpx::util::logging::filter::no_ts type; }; + template<> struct find_filter + { typedef ::hpx::util::logging::filter::use_tss_with_cache<5> type; }; + template<> struct find_filter + { typedef ::hpx::util::logging::filter::ts type; }; + + template<> struct find_filter + { typedef ::hpx::util::logging::level::holder_no_ts type; }; + template<> struct find_filter + { typedef ::hpx::util::logging::level::holder_tss_with_cache<5> type; }; + template<> struct find_filter + { typedef ::hpx::util::logging::level::holder_ts type; }; template struct find_logger {}; template<> struct find_logger { - typedef ::hpx::util::logging::lock_resource_finder::single_thread lock_resource; - typedef ::hpx::util::logging::logger_format_write< default_, default_, th::no_ts, default_, lock_resource > type ; + typedef ::hpx::util::logging::lock_resource_finder + ::single_thread lock_resource; + typedef ::hpx::util::logging::logger_format_write< default_, + default_, th::no_ts, default_, lock_resource > type ; }; template<> struct find_logger { - typedef ::hpx::util::logging::lock_resource_finder::tss_with_cache<> lock_resource; + typedef ::hpx::util::logging::lock_resource_finder::tss_with_cache<> + lock_resource; - typedef ::hpx::util::logging::logger_format_write< default_, default_, th::ts_write, default_, lock_resource > type ; + typedef ::hpx::util::logging::logger_format_write< default_, + default_, th::ts_write, default_, lock_resource > type ; }; template<> struct find_logger { typedef ::hpx::util::logging::lock_resource_finder::ts<> lock_resource; - typedef ::hpx::util::logging::logger_format_write< default_, default_, th::ts_write, default_, lock_resource > type ; + typedef ::hpx::util::logging::logger_format_write< default_, + default_, th::ts_write, default_, lock_resource > type ; }; } - /** @brief Find the right logger and filter, based on thread-safety: filter_::type, level_::type and logger_::type + /** @brief Find the right logger and filter, + based on thread-safety: filter_::type, level_::type and logger_::type @copydoc ts */ - template struct use { + template struct use { typedef typename detail::find_filter::type filter; typedef typename detail::find_logger::type logger; }; diff --git a/hpx/util/logging/detail/scoped_log.hpp b/hpx/util/logging/detail/scoped_log.hpp index 968f1d2fc6af..fc9062e52f06 100644 --- a/hpx/util/logging/detail/scoped_log.hpp +++ b/hpx/util/logging/detail/scoped_log.hpp @@ -36,7 +36,9 @@ struct class_name { \ ~class_name() { logger ( " end of " msg ) ; } \ } HPX_LOG_CONCATENATE(log_, __LINE__); -#define BOOST_SCOPED_LOG(logger, msg) BOOST_SCOPED_LOG_WITH_CLASS_NAME(logger, msg, HPX_LOG_CONCATENATE(boost_scoped_log,__LINE__) ) +#define BOOST_SCOPED_LOG(logger, msg) \ + BOOST_SCOPED_LOG_WITH_CLASS_NAME(logger, msg, \ + HPX_LOG_CONCATENATE(boost_scoped_log,__LINE__) ) #else // unicode @@ -46,31 +48,41 @@ struct class_name { \ ~class_name() { logger ( L" end of " msg ) ; } \ } HPX_LOG_CONCATENATE(log_, __LINE__); -#define BOOST_SCOPED_LOG(logger, msg) BOOST_SCOPED_LOG_WITH_CLASS_NAME(logger, msg, HPX_LOG_CONCATENATE(boost_scoped_log,__LINE__) ) +#define BOOST_SCOPED_LOG(logger, msg) \ + BOOST_SCOPED_LOG_WITH_CLASS_NAME(logger, msg, \ + HPX_LOG_CONCATENATE(boost_scoped_log,__LINE__) ) #endif -// default scoped write - in case your gather class .read_msg().out() returns an STL ostream -template inline void scoped_write_msg(const hold_string_type & str, std::basic_ostream & out) { +// default scoped write - in case your gather +// class .read_msg().out() returns an STL ostream +template +inline void scoped_write_msg(const hold_string_type & str, + std::basic_ostream & out) { out << str; } namespace detail { template struct scoped_gather_base { - typedef typename detail::find_gather_if_default::msg_type msg_type; + typedef typename detail::find_gather_if_default + ::msg_type msg_type; virtual void do_gather(const msg_type & ) = 0; }; /** - when doing scoped logging, we use this as a trick to find out if a logger is enabled. - That is, we want to do the overhead of gathering the message to happen only if logging is enabled + when doing scoped logging, we use this as a trick to find out if + a logger is enabled. + That is, we want to do the overhead of gathering the + message to happen only if logging is enabled */ - template , class gather_msg = default_ > struct scoped_logger { //-V690 + template , + class gather_msg = default_ > struct scoped_logger { //-V690 typedef scoped_gather_base scoped_gather; scoped_logger(scoped_gather & do_gather) : m_gather(do_gather) {} - scoped_logger(const scoped_logger & other) : m_out( other.m_out.str() ), m_gather( other.m_gather) {} + scoped_logger(const scoped_logger & other) : m_out( other.m_out.str() ), + m_gather( other.m_gather) {} template scoped_logger & operator<<(const type& val) { m_out << val; @@ -89,7 +101,8 @@ namespace detail { scoped_gather & m_gather; }; - template inline gather_type & operator,(gather_type & g, scoped_logger & val) { + template inline gather_type & operator, + (gather_type & g, scoped_logger & val) { scoped_write_msg( val.gathered_info(), g); return g; } @@ -100,18 +113,21 @@ namespace detail { #define BOOST_SCOPED_LOG_CTX_IMPL(logger_macro, operator_, class_name) \ struct class_name : ::hpx::util::logging::detail::scoped_gather_base<> { \ class_name() : m_is_enabled(false) { } \ - ~class_name() { if ( m_is_enabled) logger_macro operator_ HPX_LOG_STR(" end of ") operator_ m_str ; } \ + ~class_name() { if ( m_is_enabled) \ + logger_macro operator_ HPX_LOG_STR(" end of ") operator_ m_str ; } \ void do_gather(const msg_type & str) { m_str = str; m_is_enabled = true; } \ msg_type m_str; \ bool m_is_enabled; \ -} HPX_LOG_CONCATENATE(log_, __LINE__); \ - logger_macro , ::hpx::util::logging::detail::scoped_logger<>( HPX_LOG_CONCATENATE(log_, __LINE__) ) +} HPX_LOG_CONCATENATE(log_, __LINE__); logger_macro , \ + ::hpx::util::logging::detail::scoped_logger<>( HPX_LOG_CONCATENATE(log_, __LINE__) ) -// note: to use BOOST_SCOPED_LOG_CTX, you need to #include +// note: to use BOOST_SCOPED_LOG_CTX, you need to #include +// // This is included by default, in #include -#define BOOST_SCOPED_LOG_CTX(logger) BOOST_SCOPED_LOG_CTX_IMPL(logger, << , HPX_LOG_CONCATENATE(boost_scoped_log,__LINE__) ) +#define BOOST_SCOPED_LOG_CTX(logger) \ +BOOST_SCOPED_LOG_CTX_IMPL(logger, << , HPX_LOG_CONCATENATE(boost_scoped_log,__LINE__) ) }}} diff --git a/hpx/util/logging/detail/tags.hpp b/hpx/util/logging/detail/tags.hpp index 097fbf6ba723..def04251c7c8 100644 --- a/hpx/util/logging/detail/tags.hpp +++ b/hpx/util/logging/detail/tags.hpp @@ -56,7 +56,8 @@ namespace detail { } /** -@brief Allows you to use tags (extra information about the context of the logged message: file/line, function name, thread id, etc.), and log this information as well +@brief Allows you to use tags (extra information about the context of the logged message: +file/line, function name, thread id, etc.), and log this information as well - @ref tag_need - @ref tag_explained @@ -68,13 +69,16 @@ namespace detail { @section tag_need Do you need tags? -First of all, note that the easiest way to log some extra context is to simply append it, when definining your macro: +First of all, note that the easiest way to log some extra context is to simply append it, +when definining your macro: @code -#define LDBG_ HPX_LOG_USE_LOG_IF_LEVEL(g_l(), g_log_level(), debug ) << __FILE__ << ":" << __LINE__ << " [dbg] " +#define LDBG_ HPX_LOG_USE_LOG_IF_LEVEL(g_l(), g_log_level(), debug ) << __FILE__ \ +<< ":" << __LINE__ << " [dbg] " @endcode -In the above case, you appended file & line, and the level of the logged message. Usage is just the same: +In the above case, you appended file & line, and the level of the logged message. +Usage is just the same: @code std::string hello = "hello", world = "world"; @@ -89,20 +93,30 @@ my_cool_sample:234 [dbg] hello, world I can see a few issues with the above - The context formatting is fixed - - You can't choose at runtime - what if I want to see the level first, then the file & line? - - You can't choose at runtime if you want to ignore some of that context (to speed up the app in some cases, you might decide not to log the file & line) - - You can't mix the context formatting with the rest of the formatting. For example, what if I want to log info like this : \n + - You can't choose at runtime - what if I want to see the level first, + then the file & line? + - You can't choose at runtime if you want to ignore some of that context + (to speed up the app in some cases, you might decide not to log the file & line) + - You can't mix the context formatting with the rest of the formatting. + For example, what if I want to log info like this : \n [idx] file_and_line [time] message [level] ? - - You can't do extra formatting to any of the context. For example, when dumping file/line, - what if you want to strip some information from the file (the file name could be pretty big). Or, you might want to @em normalize + - You can't do extra formatting to any of the context. + For example, when dumping file/line, + what if you want to strip some information from the file + (the file name could be pretty big). Or, you might want to @em normalize the file/line (like, fix it at 50 chars - by stripping or padding information) -- If you want to be efficient and do the logging on a @ref hpx::util::logging::writer::on_dedicated_thread "dedicated thread" - - You can't use formatter::thread_id, because the thread_id is computed when being written (which when used on a dedicated thread, would always +- If you want to be efficient and do the logging on a + @ref hpx::util::logging::writer::on_dedicated_thread "dedicated thread" + - You can't use formatter::thread_id, because the thread_id is computed when + being written (which when used on a dedicated thread, would always return the same value) - - Logging the context takes time as well. For instance, " << __FILE__ << ":" << __LINE__ << " [dbg] " , in the above case, - takes time. It is much faster to only @em gather the context on the current thread, and then dump it on the dedicated thread. You can use tags for that. + - Logging the context takes time as well. For instance, " << __FILE__ + << ":" << __LINE__ << " [dbg] " , in the above case, + takes time. It is much faster to only @em gather the context on the current thread, + and then dump it on the dedicated thread. You can use tags for that. -If you're ok with the above issues, no need to delve into tags. You can dump context like shown above, and be fine with it. +If you're ok with the above issues, no need to delve into tags. +You can dump context like shown above, and be fine with it. Otherwise, welcome to the world of @b tags! @@ -116,7 +130,8 @@ Otherwise, welcome to the world of @b tags! @subsection tag_classes Tag classes -Each single context information you need to hold, is identified by a tag class. Tag classes are always found in the hpx::util::logging::tag namespace. +Each single context information you need to hold, is identified by a tag class. +Tag classes are always found in the hpx::util::logging::tag namespace. A tag class is deadly simple. Here are a few examples: @@ -132,7 +147,8 @@ struct time { }; @endcode -They only allow holding the context, and making sure you can get to it - when doing formatting. You can of course add your own tag clases. +They only allow holding the context, and making sure you can get to it +- when doing formatting. You can of course add your own tag clases. @@ -142,7 +158,8 @@ Now, you have to decide what tags you need. You will use templated class tag::ho - first param: the string class - the next params: the tags you need -You will replace your old HPX_LOG_FORMAT_MSG(string_class) usage, with tags. In case you don't have a HPX_LOG_FORMAT_MSG in your +You will replace your old HPX_LOG_FORMAT_MSG(string_class) usage, +with tags. In case you don't have a HPX_LOG_FORMAT_MSG in your application, the string_class is std::(w)string. @code @@ -152,7 +169,8 @@ HPX_LOG_FORMAT_MSG( optimize::cache_string_one_str<> ) // new - use tags // // In our case, time, file/line, function name -typedef tag::holder< optimize::cache_string_one_str<>, tag::time, tag::file_line, tag::function> string; +typedef tag::holder< optimize::cache_string_one_str<>, +tag::time, tag::file_line, tag::function> string; HPX_LOG_FORMAT_MSG( string ) @endcode @@ -160,12 +178,14 @@ HPX_LOG_FORMAT_MSG( string ) @subsection tag_adding_tags Adding tags to your LOG macros -Some tag classes compute their context automatically (for instance, the tag::time class). However, some tag classes need you to manually specify it, +Some tag classes compute their context automatically (for instance, the tag::time class). +However, some tag classes need you to manually specify it, in your LOG macros. This is the case for file/line, function, level, etc. In your LOG macros, you need to append the tags like this: - add .set_tag( tag_class( tag_init_values) ) -- if it's a tag class defined in the hpx::util::logging::tag namespace, you can use HPX_LOG_TAG(class_name) \n +- if it's a tag class defined in the hpx::util::logging::tag namespace, + you can use HPX_LOG_TAG(class_name) \n (which is just a shortcut for ::hpx::util::logging::tag::class_name) - some tags that come with the lib have shortcuts : - HPX_LOG_TAG_LEVEL(lvl) - append the level @@ -176,14 +196,17 @@ In your LOG macros, you need to append the tags like this: @code // add file/line and function tags -#define L_ HPX_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() ) .set_tag(HPX_LOG_TAG_FILELINE) .set_tag(HPX_LOG_TAG_FUNCTION) +#define L_ HPX_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() ) \ +.set_tag(HPX_LOG_TAG_FILELINE) .set_tag(HPX_LOG_TAG_FUNCTION) // add function and level -#define LDBG_ HPX_LOG_USE_LOG_IF_LEVEL(g_log_dbg(), g_log_level(), debug ) .set_tag(HPX_LOG_TAG_FUNCTION) .set_tag( HPX_LOG_TAG_LEVEL(debug) ) +#define LDBG_ HPX_LOG_USE_LOG_IF_LEVEL(g_log_dbg(), g_log_level(), debug ) \ +.set_tag(HPX_LOG_TAG_FUNCTION) .set_tag( HPX_LOG_TAG_LEVEL(debug) ) // add module information - you specify the module name whe using the L_ macro. Example: // L_("chart") << "Initializing environment"; -#define L_(module_name) HPX_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() ) .set_tag( HPX_LOG_TAG(module)(module_name) ) +#define L_(module_name) HPX_LOG_USE_LOG_IF_FILTER(g_l(), \ +g_log_filter()->is_enabled() ) .set_tag( HPX_LOG_TAG(module)(module_name) ) @endcode @@ -191,7 +214,9 @@ In your LOG macros, you need to append the tags like this: @subsection tag_process_tags Processing the tags -Now, you're ready to process these tags - where you're specifying your formatters and/or destinations, add the tag formatters that will process your tags. +Now, you're ready to process these tags +- where you're specifying your formatters and/or destinations, +add the tag formatters that will process your tags. Example: @code @@ -210,9 +235,11 @@ g_l()->writer().add_destination( destination::cout() ); g_l()->writer().add_destination( destination::dbg_window() ); @endcode -Note that the library comes with default formatters for each tag class. However, you can create your own formatter class, for a given tag class. +Note that the library comes with default formatters for each tag class. +However, you can create your own formatter class, for a given tag class. -The formatters that come with the library, have the same name as the tag class itself, only that they're in the @c formatter::tag namespace. +The formatters that come with the library, have the same name as the tag class itself, +only that they're in the @c formatter::tag namespace. Examples: - for tag::file_line, we have formatter::tag::file_line @@ -238,7 +265,8 @@ namespace tag { /** @brief Holds up to 10 @ref tag "tags". -@param string_ (required) The string class we use for holding logged messages. By default, std::(w)string. What you used to specify using HPX_LOG_FORMAT_MSG. +@param string_ (required) The string class we use for holding logged messages. +By default, std::(w)string. What you used to specify using HPX_LOG_FORMAT_MSG. @param param1 (optional) First tag @param param2 (optional) Second tag @@ -262,7 +290,8 @@ template< class param7 = detail::void_7, class param8 = detail::void_8, class param9 = detail::void_9, - class param10 = detail::void_10> struct holder : detail::tag_holder_base { + class param10 = detail::void_10> struct holder + : detail::tag_holder_base { typedef typename use_default::type string_type; typedef detail::tag_holder_base tag_base_type; diff --git a/hpx/util/logging/detail/time_format_holder.hpp b/hpx/util/logging/detail/time_format_holder.hpp index 9500f0a86dc4..16f0386918bf 100644 --- a/hpx/util/logging/detail/time_format_holder.hpp +++ b/hpx/util/logging/detail/time_format_holder.hpp @@ -60,7 +60,9 @@ struct time_format_holder { /** constructs a time format holder object */ - time_format_holder(const hold_string_type & format) : m_day(-1), m_month(-1), m_yy(-1), m_yyyy(-1), m_hour(-1), m_min(-1), m_sec(-1),m_millisec(-1),m_microsec(-1),m_nanosec(-1) { + time_format_holder(const hold_string_type & format) : m_day(-1), + m_month(-1), m_yy(-1), m_yyyy(-1), m_hour(-1), m_min(-1), + m_sec(-1),m_millisec(-1),m_microsec(-1),m_nanosec(-1) { set_format(format); } @@ -69,7 +71,8 @@ struct time_format_holder { HPX_ASSERT( format.size() < 64); m_format.clear(); - m_day = -1; m_month = -1; m_yy = -1; m_yyyy = -1; m_hour = -1; m_min = -1; m_sec = -1;m_millisec = -1;m_microsec = -1;m_nanosec = -1; + m_day = -1; m_month = -1; m_yy = -1; m_yyyy = -1; m_hour = -1; + m_min = -1; m_sec = -1;m_millisec = -1;m_microsec = -1;m_nanosec = -1; typedef hold_string_type::size_type uint; uint day_idx = format.find(HPX_LOG_STR("$dd")); @@ -104,7 +107,8 @@ struct time_format_holder { if ( sec_idx != hold_string_type::npos) indexes.push_back( index_info(sec_idx, &m_sec) ); if ( millisec_idx != hold_string_type::npos) - indexes.push_back( index_info(millisec_idx, &m_millisec, 4, 3) ); //-V112 //-V525 + indexes.push_back( index_info(millisec_idx, &m_millisec, 4, 3) ); + //-V112 //-V525 if ( microsec_idx != hold_string_type::npos) indexes.push_back( index_info(microsec_idx, &m_microsec, 5, 6) ); if ( nanosec_idx != hold_string_type::npos) @@ -115,20 +119,26 @@ struct time_format_holder { // create the format string, that we can actually pass to sprintf uint prev_idx = 0; int idx = 0; - for ( array::iterator begin = indexes.begin(), end = indexes.end(); begin != end; ++begin) { + for ( array::iterator begin = indexes.begin(), end = indexes.end(); + begin != end; ++begin) { m_format += format.substr( prev_idx, begin->src_idx - prev_idx); *begin->format_idx = idx; std::basic_ostringstream cur_sprintf_format; cur_sprintf_format << HPX_LOG_STR("%0") << begin->size << HPX_LOG_STR("d"); m_format += cur_sprintf_format.str(); - prev_idx = static_cast(begin->src_idx + static_cast(begin->advance_size) + 1ul); + prev_idx = static_cast(begin->src_idx + + static_cast(begin->advance_size) + 1ul); ++idx; } m_format += format.substr(prev_idx); } - void write_time(char_type buffer[], int day, int month, int year, int hour, int min, int sec, int millisec, int microsec, int nanosec) const { + void write_time(char_type buffer[], int day, int month, + int year, int hour, int min, int sec, int millisec, int microsec, + int nanosec) const { int vals[11]; vals[m_day + 1] = day; vals[m_month + 1] = month; @@ -141,15 +151,19 @@ struct time_format_holder { vals[m_microsec + 1] = microsec; vals[m_nanosec + 1] = nanosec; - // ignore value at index 0 - it's there so that I don't have to test for an index being -1 + // ignore value at index 0 + // - it's there so that I don't have to test for an index being -1 #ifdef HPX_LOG_USE_WCHAR_T - swprintf( buffer, m_format.c_str(), vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7], vals[8], vals[9], vals[10] ); + swprintf( buffer, m_format.c_str(), vals[1], vals[2], vals[3], + vals[4], vals[5], vals[6], vals[7], vals[8], vals[9], vals[10] ); #else - sprintf( buffer, m_format.c_str(), vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7], vals[8], vals[9], vals[10] ); + sprintf( buffer, m_format.c_str(), vals[1], vals[2], vals[3], + vals[4], vals[5], vals[6], vals[7], vals[8], vals[9], vals[10] ); #endif } - void write_time(char_type buffer[], int day, int month, int year, int hour, int min, int sec) const { + void write_time(char_type buffer[], int day, int month, int year, + int hour, int min, int sec) const { int vals[8]; vals[m_day + 1] = day; vals[m_month + 1] = month; @@ -159,17 +173,21 @@ struct time_format_holder { vals[m_min + 1] = min; vals[m_sec + 1] = sec; - // ignore value at index 0 - it's there so that I don't have to test for an index being -1 + // ignore value at index 0 + // - it's there so that I don't have to test for an index being -1 #ifdef HPX_LOG_USE_WCHAR_T - swprintf( buffer, m_format.c_str(), vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7]); + swprintf( buffer, m_format.c_str(), vals[1], vals[2], vals[3], + vals[4], vals[5], vals[6], vals[7]); #else - sprintf( buffer, m_format.c_str(), vals[1], vals[2], vals[3], vals[4], vals[5], vals[6], vals[7] ); + sprintf( buffer, m_format.c_str(), vals[1], vals[2], vals[3], + vals[4], vals[5], vals[6], vals[7] ); #endif } private: // the indexes of each escape sequence within the format string - int m_day, m_month, m_yy, m_yyyy, m_hour, m_min, m_sec, m_millisec, m_microsec, m_nanosec; + int m_day, m_month, m_yy, m_yyyy, m_hour, m_min, m_sec, m_millisec, + m_microsec, m_nanosec; hold_string_type m_format; }; diff --git a/hpx/util/logging/detail/ts/resource_finder.hpp b/hpx/util/logging/detail/ts/resource_finder.hpp index 9433122566b1..79a93d692e82 100644 --- a/hpx/util/logging/detail/ts/resource_finder.hpp +++ b/hpx/util/logging/detail/ts/resource_finder.hpp @@ -35,11 +35,13 @@ namespace hpx { namespace util { namespace logging { namespace lock_resource_finder { /** - @brief Locks a resource thread-safe - each time, at read/write (safe but rather inefficient) + @brief Locks a resource thread-safe - each time, + at read/write (safe but rather inefficient) */ template struct ts { template struct finder { - typedef typename hpx::util::logging::locker::ts_resource type; + typedef typename hpx::util::logging::locker + ::ts_resource type; }; }; @@ -48,26 +50,32 @@ namespace hpx { namespace util { namespace logging { */ struct single_thread { template struct finder { - typedef typename hpx::util::logging::locker::ts_resource_single_thread type; + typedef typename hpx::util::logging::locker + ::ts_resource_single_thread type; }; }; #if !defined( HPX_HAVE_LOG_NO_TSS) /** - @brief Caches the resource on each thread, and refreshes it at @c refresh_secs period + @brief Caches the resource on each thread, and refreshes it at + @c refresh_secs period */ - template struct tss_with_cache { + template + struct tss_with_cache { template struct finder { - typedef typename locker::tss_resource_with_cache type; + typedef typename locker::tss_resource_with_cache type; }; }; /** - @brief Allows you to initialize this resource once even if multiple threads are running. Then, all threads will use the initialized value + @brief Allows you to initialize this resource once even if + multiple threads are running. Then, all threads will use the initialized value */ template struct tss_once_init { template struct finder { - typedef typename hpx::util::logging::locker::tss_resource_once_init type; + typedef typename hpx::util::logging::locker::tss_resource_once_init + type; }; }; @@ -75,7 +83,8 @@ namespace hpx { namespace util { namespace logging { // Not using TSS at all - template struct tss_with_cache { + template + struct tss_with_cache { template struct finder { typedef typename locker::ts_resource_single_thread type; }; diff --git a/hpx/util/logging/detail/ts/ts_resource.hpp b/hpx/util/logging/detail/ts/ts_resource.hpp index 07a91dd1c537..09b4bf9a0e55 100644 --- a/hpx/util/logging/detail/ts/ts_resource.hpp +++ b/hpx/util/logging/detail/ts/ts_resource.hpp @@ -30,7 +30,8 @@ namespace hpx { namespace util { namespace logging { /** - @brief Contains implementations of locker objects. Such a locker can lock data for read or write. + @brief Contains implementations of locker objects. + Such a locker can lock data for read or write. Assume you have @code @@ -65,7 +66,8 @@ namespace locker { @sa locker */ - template struct ts_resource { + template + struct ts_resource { typedef ts_resource self_type; ts_resource(const type& val = type() ) : m_val(val) {} @@ -141,13 +143,17 @@ namespace locker { #ifndef HPX_HAVE_LOG_NO_TSS /** - Locks a resource, and uses TSS (Thread-specific storage). This holds the value, and each thread caches it. - Once at a given period (like, every 5 seconds), when used, the latest object is copied. + Locks a resource, and uses TSS (Thread-specific storage). + This holds the value, and each thread caches it. + Once at a given period (like, every 5 seconds), when used, + the latest object is copied. @sa locker @sa default_cache_millis how many secs to cache the data. By default, 5 */ - template struct tss_resource_with_cache { + template + struct tss_resource_with_cache { typedef tss_resource_with_cache self_type; private: @@ -161,7 +167,9 @@ namespace locker { }; public: - tss_resource_with_cache(const type& val = type() , int cache_secs = default_cache_secs ) : m_val(val), m_cache_secs(cache_secs) {} + tss_resource_with_cache(const type& val = type() , + int cache_secs = default_cache_secs ) : m_val(val), + m_cache_secs(cache_secs) {} struct read; struct write; @@ -224,14 +232,16 @@ namespace locker { Locks a resource, and uses TSS. The resource can be initialized once, at any time, no matter how many threads. - Once the resource is initialized (basically, someone used resource::write), that is the final value + Once the resource is initialized (basically, someone used resource::write), + that is the final value All other threads will use and cached the initialized value. @sa locker @sa default_cache_millis how many secs to cache the data. By default, 5 */ - template struct tss_resource_once_init { + template + struct tss_resource_once_init { typedef tss_resource_once_init self_type; private: @@ -242,7 +252,8 @@ namespace locker { }; public: - tss_resource_once_init(const type& val = type() ) : m_val(val), m_initialized(false) {} + tss_resource_once_init(const type& val = type() ) + : m_val(val), m_initialized(false) {} struct read; struct write; diff --git a/hpx/util/logging/detail/tss/tss.hpp b/hpx/util/logging/detail/tss/tss.hpp index a2dd6c3b4340..10a6aa97904a 100644 --- a/hpx/util/logging/detail/tss/tss.hpp +++ b/hpx/util/logging/detail/tss/tss.hpp @@ -44,7 +44,8 @@ namespace hpx { namespace util { namespace logging { -template class thread_specific_ptr_type HPX_LOG_TSS_DEFAULT_CLASS > struct tss_value { +template +class thread_specific_ptr_type HPX_LOG_TSS_DEFAULT_CLASS > struct tss_value { tss_value() {} type * get() const { @@ -69,7 +70,9 @@ template class thread_specific_ptr_type HPX_LOG_T -template class thread_specific_ptr_type HPX_LOG_TSS_DEFAULT_CLASS > struct tss_value_with_default { +template +class thread_specific_ptr_type HPX_LOG_TSS_DEFAULT_CLASS > +struct tss_value_with_default { tss_value_with_default(const type & default_ ) : m_default( default_) {} type * get() const { diff --git a/hpx/util/logging/detail/tss/tss_impl_pthread.hpp b/hpx/util/logging/detail/tss/tss_impl_pthread.hpp index 40c7b78d53ca..1783d7c72a82 100644 --- a/hpx/util/logging/detail/tss/tss_impl_pthread.hpp +++ b/hpx/util/logging/detail/tss/tss_impl_pthread.hpp @@ -69,7 +69,8 @@ inline unsigned int slot_idx() { mutex::scoped_lock lk(cs); - // note: if the Logging Lib is used with TLS, I'm guaranteed this will be called before main(), + // note: if the Logging Lib is used with TLS, + // I'm guaranteed this will be called before main(), // and that this will work if ( !idx) init_tss_data(); diff --git a/hpx/util/logging/detail/tss/tss_impl_win32.hpp b/hpx/util/logging/detail/tss/tss_impl_win32.hpp index 0aeee5d9c897..222e9cfff399 100644 --- a/hpx/util/logging/detail/tss/tss_impl_win32.hpp +++ b/hpx/util/logging/detail/tss/tss_impl_win32.hpp @@ -61,7 +61,8 @@ inline DWORD& tss_data_native_key () { inline void init_tss_data() { //Allocate tls slot - // if you get an assertion here, this function was called twice - should never happen! + // if you get an assertion here, this function was called twice + // - should never happen! HPX_ASSERT( tss_data_native_key() == TLS_OUT_OF_INDEXES); // now, allocate it tss_data_native_key() = TlsAlloc(); @@ -77,7 +78,8 @@ inline unsigned long slot_idx() { mutex::scoped_lock lk(cs); - // note: if the Logging Lib is used with TLS, I'm guaranteed this will be called before main(), + // note: if the Logging Lib is used with TLS, + // I'm guaranteed this will be called before main(), // and that this will work if ( !idx) init_tss_data(); diff --git a/hpx/util/logging/detail/tss/tss_ostringstream.hpp b/hpx/util/logging/detail/tss/tss_ostringstream.hpp index 3745cbaec965..7185370cf407 100644 --- a/hpx/util/logging/detail/tss/tss_ostringstream.hpp +++ b/hpx/util/logging/detail/tss/tss_ostringstream.hpp @@ -28,8 +28,10 @@ namespace hpx { namespace util { namespace logging { /** -@brief Represents an ostringstream that takes advantage of TSS (Thread Specific Storage). In other words, each thread has its - own copy of an ostringstream, thus when needed, we avoid the cost of re-creating it (it's created only once per thread). +@brief Represents an ostringstream that takes advantage of TSS (Thread Specific Storage). + In other words, each thread has its + own copy of an ostringstream, thus when needed, + we avoid the cost of re-creating it (it's created only once per thread). */ template< class stream = std::basic_ostringstream > struct tss_ostringstream { typedef stream stream_type; @@ -55,7 +57,8 @@ template< class stream = std::basic_ostringstream > struct tss_ostrin mutable tss_value m_cache; }; -template inline stream& operator<<( tss_ostringstream & out, const value_type & val) { +template inline stream& operator +<<( tss_ostringstream & out, const value_type & val) { stream & result = out.get(); result << val; return result; diff --git a/hpx/util/logging/detail/use_format_write.hpp b/hpx/util/logging/detail/use_format_write.hpp index 3217b18d40ce..a1e9e8a5e5fb 100644 --- a/hpx/util/logging/detail/use_format_write.hpp +++ b/hpx/util/logging/detail/use_format_write.hpp @@ -56,20 +56,27 @@ typedef logger_format_write< FIXME need to have more template params -@param format_base_type @ref misc_use_defaults "(optional)" Your formatter base class -@param destination_base @ref misc_use_defaults "(optional)" Your destination base class -@param thread_safety @ref misc_use_defaults "(optional)" Thread-safety. Any of the writer::threading classes. -@param gather @ref misc_use_defaults "(optional)" The class that @ref gather "gathers" the message +@param format_base_type @ref misc_use_defaults "(optional)" +Your formatter base class +@param destination_base @ref misc_use_defaults "(optional)" +Your destination base class +@param thread_safety @ref misc_use_defaults "(optional)" +Thread-safety. Any of the writer::threading classes. +@param gather @ref misc_use_defaults "(optional)" +The class that @ref gather "gathers" the message */ -template +template struct logger_format_write : logger< typename detail::format_find_gather::type , - typename detail::format_find_writer::type > + typename detail::format_find_writer::type > { typedef logger< typename detail::format_find_gather::type , - typename detail::format_find_writer::type > logger_base_type; + typename detail::format_find_writer::type > logger_base_type; HPX_LOGGING_FORWARD_CONSTRUCTOR(logger_format_write, logger_base_type) }; diff --git a/hpx/util/logging/detail/util.hpp b/hpx/util/logging/detail/util.hpp index 5b37bb48213c..f23b68d70768 100644 --- a/hpx/util/logging/detail/util.hpp +++ b/hpx/util/logging/detail/util.hpp @@ -33,14 +33,17 @@ namespace hpx { namespace util { namespace logging { struct override {}; struct default_ {}; - template struct use_default { typedef param type; }; - template struct use_default { typedef default_type type; }; + template struct use_default + { typedef param type; }; + template struct use_default + { typedef default_type type; }; struct void_ {}; namespace detail { - /** this is just a simple way to always return override; however, in this case we postpone the instantiation + /** this is just a simple way to always return override; however, + in this case we postpone the instantiation until our template parameter is known @@ -49,7 +52,8 @@ namespace hpx { namespace util { namespace logging { typedef typename formatter::msg_type::type msg_type; @endcode - would compute msg_type right now; however, we want the compiler to wait, until the user has actually set the msg_type, + would compute msg_type right now; however, we want the compiler to wait, + until the user has actually set the msg_type, for example, using the HPX_LOG_FORMAT_MSG macro. Thus, we do: @code diff --git a/hpx/util/logging/format.hpp b/hpx/util/logging/format.hpp index 447160142fb3..19f44b4576c0 100644 --- a/hpx/util/logging/format.hpp +++ b/hpx/util/logging/format.hpp @@ -44,26 +44,33 @@ and you want to define the logger classes, in a source file */ - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// // Format and write // /** - @brief The @c %format_and_write classes know how to call the formatter and destination @c objects. + @brief The @c %format_and_write classes know how to call + the formatter and destination @c objects. Usually you'll be happy with the - format_and_write::simple class - which simply calls @c operator() on the formatters , and @c operator() on the destinations. - - Note that usually the formatter and destination class just have an @c operator(), which when called, formats the message - or writes it to a destination. In case your formatters/destinations are more complex than that (for instance, more than - a member function needs to be called), you'll have to implement your own %format_and_write class. + format_and_write::simple class - which simply calls @c + operator() on the formatters , and @c operator() on the destinations. + + Note that usually the formatter and destination class just have an @c operator(), + which when called, formats the message + or writes it to a destination. In case your formatters/destinations are + more complex than that (for instance, more than + a member function needs to be called), + you'll have to implement your own %format_and_write class. */ namespace format_and_write { /** - @brief This uses a cache, when calling formatters/destinations - for writing a given message + @brief This uses a cache, when calling formatters/destinations + - for writing a given message - When a formatter is called, it caches its info. If it's called again, reuses that. + When a formatter is called, it caches its info. If it's called again, + reuses that. */ template struct use_cache { @@ -95,13 +102,18 @@ and you want to define the logger classes, in a source file /** - @brief Formats the message, and writes it to destinations - calls @c operator() on the formatters , and @c operator() on the destinations. Ignores @c clear_format() commands. - - @param msg_type The message to pass to the formatter. This is the type that is passed to the formatter objects and to the destination objects. - Thus, it needs to be convertible to the argument to be sent to the formatter objects and to the argument to be sent to the destination objects. + @brief Formats the message, and writes it to destinations + - calls @c operator() on the formatters , and @c operator() on the destinations. + Ignores @c clear_format() commands. + + @param msg_type The message to pass to the formatter. This is the + type that is passed to the formatter objects and to the destination objects. + Thus, it needs to be convertible to the argument to be sent to the + formatter objects and to the argument to be sent to the destination objects. Usually, it's the argument you pass on to your destination classes. - If you derive from @c destination::base, this type can be @c destination::base::raw_param (see below). + If you derive from @c destination::base, this type can be + @c destination::base::raw_param (see below). Example: @@ -142,17 +154,22 @@ and you want to define the logger classes, in a source file /** - @brief Formats the message, and writes it to destinations - calls @c operator() on the formatters , and @c operator() on the destinations. + @brief Formats the message, and writes it to destinations + - calls @c operator() on the formatters , and @c operator() on the destinations. Cares for the @c clear_format() commands. - @param msg_type The message to pass to the formatter. This is the type that is passed to the formatter objects and to the destination objects. - Thus, it needs to be convertible to the argument to be sent to the formatter objects and to the argument to be sent to the destination objects. + @param msg_type The message to pass to the formatter. This is the + type that is passed to the formatter objects and to the destination objects. + Thus, it needs to be convertible to the argument to be sent to the + formatter objects and to the argument to be sent to the destination objects. Usually, it's the argument you pass on to your destination classes. - If you derive from @c destination::base, this type can be @c destination::base::raw_param (see below). + If you derive from @c destination::base, this type can be + @c destination::base::raw_param (see below). - @param string_type [optional] A class that can hold a string (that is, a copy of the message) + @param string_type [optional] A class that can hold a string + (that is, a copy of the message) Example: @@ -181,7 +198,8 @@ and you want to define the logger classes, in a source file struct simple_care_for_clear_format : simple { typedef simple simple_base_type; - simple_care_for_clear_format( msg_type & msg) : simple_base_type(msg), m_original_msg( msg ) {} + simple_care_for_clear_format( msg_type & msg) : simple_base_type(msg), + m_original_msg( msg ) {} void clear_format() { simple_base_type::m_msg = m_original_msg; @@ -194,7 +212,7 @@ and you want to define the logger classes, in a source file - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// // Message routing // @@ -209,7 +227,8 @@ and you want to define the logger classes, in a source file namespace msg_route { /** - @brief Recomended base class for message routers that need access to the underlying formatter and/or destination array. + @brief Recomended base class for message routers that + need access to the underlying formatter and/or destination array. */ template struct formatter_and_destination_array_holder { @@ -227,7 +246,8 @@ and you want to define the logger classes, in a source file }; /** -@brief Represents a simple router - first calls all formatters - in the order they were added, then all destinations - in the order they were added +@brief Represents a simple router - first calls all formatters +- in the order they were added, then all destinations - in the order they were added Example: @@ -252,16 +272,20 @@ L_ << "testing " << i << i+1 << i+2; @endcode In the above case: -- First, the formatters are called: @c write_idx() is called, then @c write_time(), then @c append_newline(). +- First, the formatters are called: @c write_idx() is called, then @c write_time(), +then @c append_newline(). - Then, the destinations are called: @c write_to_cout(), and then @c write_to_file(). -@param format_base The base class for all formatter classes from your application. See manipulator. +@param format_base The base class for all formatter classes from your application. +See manipulator. -@param destination_base The base class for all destination classes from your application. See manipulator. +@param destination_base The base class for all destination classes from your application. +See manipulator. -@param lock_resource_type What class you use to do allow thread-safe access to an instance of this clas (used internally). +@param lock_resource_type What class you use to do allow +thread-safe access to an instance of this clas (used internally). */ template< @@ -273,7 +297,9 @@ In the above case: typedef typename destination_base::ptr_type destination_ptr; typedef typename detail::to_override::type override_; - typedef typename use_default::lock_resource > ::type lock_resource_type; + typedef typename use_default::lock_resource > + ::type lock_resource_type; typedef std::vector f_array; typedef std::vector d_array; @@ -284,7 +310,8 @@ In the above case: typedef typename lock_resource_type::template finder::type data; - template simple(const formatter_array&, const destination_array&) {} + template + simple(const formatter_array&, const destination_array&) {} void append_formatter(formatter_ptr fmt) { typename data::write to_write(m_to_write); @@ -292,7 +319,8 @@ In the above case: } void del_formatter(formatter_ptr fmt) { typename data::write to_write(m_to_write); - typename f_array::iterator del = std::remove(to_write->formats.begin(), to_write->formats.end(), fmt); + typename f_array::iterator del = std::remove(to_write->formats.begin(), + to_write->formats.end(), fmt); to_write->formats.erase(del, to_write->formats.end()); } @@ -303,19 +331,24 @@ In the above case: void del_destination(destination_ptr dest) { typename data::write to_write(m_to_write); - typename d_array::iterator del = std::remove(to_write->destinations.begin(), to_write->destinations.end(), dest); + typename d_array::iterator del = + std::remove(to_write->destinations.begin(), + to_write->destinations.end(), dest); to_write->destinations.erase(del, to_write->destinations.end()); } - template void write(msg_type & msg) const { + template void write(msg_type & msg) const { format_and_write m(msg); // note: here, we're reading (data::read)! typename data::read to_write(m_to_write); - for ( typename f_array::const_iterator b_f = to_write->formats.begin(), e_f = to_write->formats.end(); b_f != e_f; ++b_f) + for ( typename f_array::const_iterator b_f = to_write->formats.begin(), + e_f = to_write->formats.end(); b_f != e_f; ++b_f) m.format(*b_f); - for ( typename d_array::const_iterator b_d = to_write->destinations.begin(), e_d = to_write->destinations.end(); b_d != e_d; ++b_d) + for ( typename d_array::const_iterator b_d = to_write->destinations.begin(), + e_d = to_write->destinations.end(); b_d != e_d; ++b_d) m.write(*b_d); } @@ -325,15 +358,18 @@ In the above case: /** - @brief. Represents a router - by default, first calls all formatters, then all destinations. However you can overwrite this route + @brief. Represents a router - by default, first calls all formatters, + then all destinations. However you can overwrite this route - You can append a route - with append_route(), or set the route with set_route(). + You can append a route - with append_route(), + or set the route with set_route(). Example: @code typedef logger< default_, - writer::format_write< format_base, destination_base, format_and_write::simple, + writer::format_write< format_base, destination_base, + format_and_write::simple, msg_route::with_route > > logger_type; logger_type g_l(); @@ -350,9 +386,11 @@ In the above case: ; @endcode - @param format_base The base class for all formatter classes from your application. See manipulator. + @param format_base The base class for all + formatter classes from your application. See manipulator. - @param destination_base The base class for all destination classes from your application. See manipulator. + @param destination_base The base class for all + destination classes from your application. See manipulator. @remarks In the router - we don't own the objects - the array holder does that */ @@ -361,19 +399,26 @@ In the above case: class destination_base, class lock_resource = default_ , // note: we're counting on these defaults in format_find_writer - class formatter_array = hpx::util::logging::array::shared_ptr_holder, - class destination_array = hpx::util::logging::array::shared_ptr_holder + class formatter_array = + hpx::util::logging::array::shared_ptr_holder, + class destination_array = + hpx::util::logging::array::shared_ptr_holder > - class with_route : protected formatter_and_destination_array_holder { + class with_route : protected formatter_and_destination_array_holder { typedef typename formatter_base::ptr_type formatter_ptr; typedef typename destination_base::ptr_type destination_ptr; typedef typename detail::to_override::type override_; - typedef typename use_default::lock_resource > ::type lock_resource_type; + typedef typename use_default::lock_resource > + ::type lock_resource_type; - typedef formatter_and_destination_array_holder holder_base_type; + typedef formatter_and_destination_array_holder holder_base_type; - typedef with_route self_type; + typedef with_route self_type; typedef std::vector f_array; typedef std::vector d_array; @@ -389,7 +434,9 @@ In the above case: typedef typename lock_resource_type::template finder::type data; public: - with_route(const formatter_array& formatters, const destination_array & destinations) : holder_base_type(formatters, destinations) {} + with_route(const formatter_array& formatters, + const destination_array & destinations) : holder_base_type(formatters, + destinations) {} class route; friend class route; @@ -422,11 +469,13 @@ In the above case: public: template route & fmt(formatter f) { - fmt_impl(f, boost::is_base_of() ); + fmt_impl(f, boost::is_base_of() ); return *this; } template route & dest(destination d) { - dest_impl(d, boost::is_base_of() ); + dest_impl(d, boost::is_base_of() ); return *this; } route & clear() { @@ -436,22 +485,28 @@ In the above case: private: // not generic - template void fmt_impl(formatter f, const boost::false_type& ) { + template void fmt_impl(formatter f, + const boost::false_type& ) { m_items.push_back( item().fmt( m_self.formats().get_ptr(f) )) ; } // not generic - template void dest_impl(destination d, const boost::false_type&) { + template void dest_impl(destination d, + const boost::false_type&) { m_items.push_back( item().dest( m_self.destinations().get_ptr(d) )); } // generic - template void fmt_impl(formatter f, const boost::true_type& ) { - typedef hpx::util::logging::manipulator::detail::generic_holder holder; + template void fmt_impl(formatter f, + const boost::true_type& ) { + typedef hpx::util::logging::manipulator::detail + ::generic_holder holder; fmt_impl( holder(f) , boost::false_type() ); } // generic - template void dest_impl(destination d, const boost::true_type&) { - typedef hpx::util::logging::manipulator::detail::generic_holder holder; + template void dest_impl(destination d, + const boost::true_type&) { + typedef hpx::util::logging::manipulator::detail + ::generic_holder holder; dest_impl( holder(d) , boost::false_type() ); } protected: @@ -503,8 +558,10 @@ In the above case: void del_formatter(formatter_ptr fmt) { typename data::write to_write(m_to_write); - for ( typename write_array::const_iterator b = to_write->begin(), e = to_write->end(); b != e; ++b) { - typename f_array::iterator del = std::remove( b->formats.begin(), b->formats.end(), fmt); //-V807 + for ( typename write_array::const_iterator b = to_write->begin(), + e = to_write->end(); b != e; ++b) { + typename f_array::iterator del = std::remove( b->formats.begin(), + b->formats.end(), fmt); //-V807 b->formats.erase(del, b->formats.end()); } } @@ -525,11 +582,14 @@ In the above case: void del_destination(destination_ptr dest) { typename data::write to_write(m_to_write); - for ( typename write_array::const_iterator b = to_write->begin(), e = to_write->end(); b != e; ++b) { - typename d_array::iterator del = std::remove( b->destinations.begin(), b->destinations.end(), dest); //-V807 + for ( typename write_array::const_iterator b = to_write->begin(), + e = to_write->end(); b != e; ++b) { + typename d_array::iterator del = std::remove( b->destinations.begin(), + b->destinations.end(), dest); //-V807 b->destinations.erase(del, b->destinations.end()); - // if from a write_once - all destinations are gone, don't clear_afterwards + // if from a write_once - all destinations are gone, + // don't clear_afterwards if ( b->destinations.empty() ) b->do_clear_afterwards = false; } @@ -545,16 +605,21 @@ In the above case: } - template void write(msg_type & msg) const { + template + void write(msg_type & msg) const { format_and_write m(msg); // note: here, we're reading (data::read)! typename data::read to_write(m_to_write); - for ( typename write_array::const_iterator b = to_write->begin(), e = to_write->end(); b != e; ++b) { - for ( typename f_array::const_iterator b_f = b->formats.begin(), e_f = b->formats.end(); b_f != e_f; ++b_f) + for ( typename write_array::const_iterator b = to_write->begin(), + e = to_write->end(); b != e; ++b) { + for ( typename f_array::const_iterator b_f = b->formats.begin(), + e_f = b->formats.end(); b_f != e_f; ++b_f) m.format(*b_f); - for ( typename d_array::const_iterator b_d = b->destinations.begin(), e_d = b->destinations.end(); b_d != e_d; ++b_d) + for ( typename d_array::const_iterator + b_d = b->destinations.begin(), e_d = b->destinations.end(); + b_d != e_d; ++b_d) m.write(*b_d); if ( b->do_clear_afterwards) @@ -568,7 +633,8 @@ In the above case: return; // no route to add typedef typename route::array array; - for ( typename array::const_iterator b = r.m_items.begin(), e = r.m_items.end(); b != e; ++b) { + for ( typename array::const_iterator b = r.m_items.begin(), + e = r.m_items.end(); b != e; ++b) { switch ( b->m_type) { case route::is_fmt: append_formatter( b->m_fmt); break; case route::is_dest: append_destination( b->m_dest); break; diff --git a/hpx/util/logging/format/array.hpp b/hpx/util/logging/format/array.hpp index 55c81137f9e9..92acd4bbf7f9 100644 --- a/hpx/util/logging/format/array.hpp +++ b/hpx/util/logging/format/array.hpp @@ -26,12 +26,13 @@ namespace hpx { namespace util { namespace logging { - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// // array holder class namespace array { /** - Holds an array of manipulators (formatters or destinations). It owns them, holding them internally as smart pointers + Holds an array of manipulators (formatters or destinations). It owns them, + holding them internally as smart pointers Each function call is locked. The base_type must implement operator== @@ -39,7 +40,8 @@ namespace hpx { namespace util { namespace logging { When you call get_ptr() or del(), the type you provide, must implement operator==(const type& , const base_type&) */ - template class shared_ptr_holder { + template + class shared_ptr_holder { typedef typename mutex::scoped_lock scoped_lock; public: typedef base_type value_type; @@ -56,7 +58,8 @@ namespace hpx { namespace util { namespace logging { template base_type * get_ptr(derived val) const { scoped_lock lk(m_cs); - for ( typename array_type::const_iterator b = m_array.begin(), e = m_array.end(); b != e; ++b) + for ( typename array_type::const_iterator b = m_array.begin(), + e = m_array.end(); b != e; ++b) if ( val == (*(b->get())) ) return b->get(); @@ -71,7 +74,8 @@ namespace hpx { namespace util { namespace logging { void del(base_type * p) { scoped_lock lk(m_cs); - for ( typename array_type::iterator b = m_array.begin(), e = m_array.end(); b != e; ++b) + for ( typename array_type::iterator b = m_array.begin(), + e = m_array.end(); b != e; ++b) if ( b->get() == p) { m_array.erase(b); return ; diff --git a/hpx/util/logging/format/destination/convert_destination.hpp b/hpx/util/logging/format/destination/convert_destination.hpp index 6973d2ba799d..cf543af75af0 100644 --- a/hpx/util/logging/format/destination/convert_destination.hpp +++ b/hpx/util/logging/format/destination/convert_destination.hpp @@ -37,18 +37,24 @@ It has 2 function overloads: FIXME */ namespace convert { - template void write(const obj & m, std::basic_ostream & out) { + template void write(const obj & m, + std::basic_ostream & out) { out << m; } - template void write(const char_type* m, std::basic_ostream & out) { + template void write(const char_type* m, + std::basic_ostream & out) { out << m; } - inline const char_type * do_convert(const char_type * c, const into &) { return c; } - inline const char_type * do_convert(const std::basic_string & s, const into &) { return s.c_str(); } + inline const char_type * do_convert(const char_type * c, + const into &) { return c; } + inline const char_type * do_convert(const std::basic_string & s, + const into &) { return s.c_str(); } - inline const std::basic_string & do_convert(const std::basic_string & s, const into< std::basic_string > &) { + inline const std::basic_string & + do_convert(const std::basic_string & s, + const into< std::basic_string > &) { return s; } } @@ -58,7 +64,8 @@ struct do_convert_destination { convert::write(m, d); } - template static dest do_convert(const msg & m, const into &) { + template static dest do_convert(const msg & m, + const into &) { return convert::do_convert(m, into() ); } diff --git a/hpx/util/logging/format/destination/defaults.hpp b/hpx/util/logging/format/destination/defaults.hpp index c69905bd5932..5d859ea1315b 100644 --- a/hpx/util/logging/format/destination/defaults.hpp +++ b/hpx/util/logging/format/destination/defaults.hpp @@ -33,7 +33,8 @@ namespace hpx { namespace util { namespace logging { namespace destination { /** @brief Writes the string to console */ -template struct cout_t : is_generic, hpx::util::logging::op_equal::always_equal { +template struct cout_t : is_generic, +hpx::util::logging::op_equal::always_equal { template void operator()(const msg_type & msg) const { #ifndef HPX_LOG_USE_WCHAR_T @@ -48,7 +49,8 @@ template struct cout_t : is_generi /** @brief Writes the string to cerr */ -template struct cerr_t : is_generic, hpx::util::logging::op_equal::always_equal { +template struct cerr_t : is_generic, +hpx::util::logging::op_equal::always_equal { template void operator()(const msg_type & msg) const { #ifndef HPX_LOG_USE_WCHAR_T @@ -65,9 +67,11 @@ template struct cerr_t : is_generi @brief writes to stream. @note: - The stream must outlive this object! Or, clear() the stream, before the stream is deleted. + The stream must outlive this object! Or, clear() the stream, + before the stream is deleted. */ -template struct stream_t : is_generic, non_const_context< std::basic_ostream * > { +template struct stream_t : is_generic, +non_const_context< std::basic_ostream * > { typedef std::basic_ostream stream_type; typedef non_const_context< stream_type* > non_const_context_base; @@ -82,7 +86,8 @@ template struct stream_t : is_gene } bool operator==(const stream_t & other) const { - return non_const_context_base::context() != other.non_const_context_base::context(); + return non_const_context_base::context() != + other.non_const_context_base::context(); } /** @@ -104,7 +109,8 @@ template struct stream_t : is_gene For non-Windows systems, this is the console. */ -template struct dbg_window_t : is_generic, hpx::util::logging::op_equal::always_equal { +template struct dbg_window_t : is_generic, +hpx::util::logging::op_equal::always_equal { template void operator()(const msg_type & msg) const { #ifdef BOOST_WINDOWS diff --git a/hpx/util/logging/format/destination/file.hpp b/hpx/util/logging/format/destination/file.hpp index 7505b0843208..1132cc7aeb45 100644 --- a/hpx/util/logging/format/destination/file.hpp +++ b/hpx/util/logging/format/destination/file.hpp @@ -38,7 +38,8 @@ namespace hpx { namespace util { namespace logging { namespace destination { /** - @brief settings for when constructing a file class. To see how it's used, see @ref dealing_with_flags. + @brief settings for when constructing a file class. To see how it's used, + see @ref dealing_with_flags. */ struct file_settings { typedef ::hpx::util::logging::detail::flag flag; @@ -80,7 +81,8 @@ namespace detail { settings(settings_) {} void open() { - out.reset( new std::basic_ofstream( name.c_str(), open_flags(settings) ) ); + out.reset( new std::basic_ofstream( name.c_str(), + open_flags(settings) ) ); } void close() { @@ -106,7 +108,8 @@ struct file_t : is_generic, non_const_context @brief constructs the file destination @param file_name name of the file - @param set [optional] file settings - see file_settings class, and @ref dealing_with_flags + @param set [optional] file settings - see file_settings class, + and @ref dealing_with_flags */ file_t(const std::string & file_name, file_settings set = file_settings() ) : non_const_context_base(file_name,set) diff --git a/hpx/util/logging/format/destination/named.hpp b/hpx/util/logging/format/destination/named.hpp index a0ceb6692eb3..af09a653a87c 100644 --- a/hpx/util/logging/format/destination/named.hpp +++ b/hpx/util/logging/format/destination/named.hpp @@ -41,9 +41,13 @@ namespace hpx { namespace util { namespace logging { namespace destination { namespace detail { template struct named_context { - typedef typename use_default >::type lock_resource_type; - typedef typename use_default >::type destination_base_type; - typedef ::hpx::util::logging::array::shared_ptr_holder array; + typedef typename use_default > + ::type lock_resource_type; + typedef typename use_default > + ::type destination_base_type; + typedef ::hpx::util::logging::array::shared_ptr_holder array; typedef hold_string_type string_type; struct write_info { @@ -58,10 +62,12 @@ namespace detail { typedef typename lock_resource_type::template finder::type data; data m_data; - template void add(const string_type & name, destination_type dest) { + template void add(const string_type & name, + destination_type dest) { // care about if generic or not typedef hpx::util::logging::manipulator::is_generic is_generic; - add_impl( name, dest, boost::is_base_of() ); + add_impl( name, dest, + boost::is_base_of() ); compute_write_steps(); } @@ -75,7 +81,8 @@ namespace detail { compute_write_steps(); } - void configure(const string_type & name, const string_type & configure_str) { + void configure(const string_type & name, + const string_type & configure_str) { typename data::write info(m_data); destination_base_type * p = info->name_to_destination[name]; if ( p) @@ -91,25 +98,30 @@ namespace detail { template void write(msg_type & msg) const { typename data::read info(m_data); - for ( typename write_info::step_array::const_iterator b = info->write_steps.begin(), e = info->write_steps.end(); b != e ; ++b) + for ( typename write_info::step_array::const_iterator b = + info->write_steps.begin(), e = info->write_steps.end(); b != e ; ++b) (**b)(msg); } private: // non-generic - template void add_impl(const string_type & name, destination_type dest, const boost::false_type& ) { + template void add_impl(const string_type & name, + destination_type dest, const boost::false_type& ) { typename data::write info(m_data); destination_base_type * p = info->destinations.append(dest); info->name_to_destination[name] = p; } // generic manipulator - template void add_impl(const string_type & name, destination_type dest, const boost::true_type& ) { - typedef hpx::util::logging::manipulator::detail::generic_holder holder; + template void add_impl(const string_type & name, + destination_type dest, const boost::true_type& ) { + typedef hpx::util::logging::manipulator::detail + ::generic_holder holder; add_impl( name, holder(dest), boost::false_type() ); } // recomputes the write steps - note taht this takes place after each operation - // for instance, the user might have first set the string and later added the formatters + // for instance, the user might have first set the string and + // later added the formatters void compute_write_steps() { typename data::write info(m_data); info->write_steps.clear(); @@ -123,8 +135,10 @@ namespace detail { // ignore this word continue; - if ( info->name_to_destination.find(word) != info->name_to_destination.end()) - info->write_steps.push_back( info->name_to_destination.find(word)->second); + if ( info->name_to_destination.find(word) != + info->name_to_destination.end()) + info->write_steps.push_back( info-> + name_to_destination.find(word)->second); } } @@ -133,16 +147,22 @@ namespace detail { } /** -@brief Allows you to contain multiple destinations, give each such destination a name. Then, at run-time, you can specify a format string which will specify which destinations to be called, and on what order. +@brief Allows you to contain multiple destinations, +give each such destination a name. +Then, at run-time, you can specify a format string which will specify which +destinations to be called, and on what order. This allows you: - to hold multiple destinations -- each destination is given a name, when being added. The name must not contain spaces and must not start with '+'/'-' signs -- you have a %format string, which contains what destinations to be called, and on which order +- each destination is given a name, when being added. +The name must not contain spaces and must not start with '+'/'-' signs +- you have a %format string, which contains what destinations to be called, +and on which order The %format string contains destination names, separated by space. -When a message is written to this destination, I parse the format string. When a name is encountered, if there's a destination +When a message is written to this destination, +I parse the format string. When a name is encountered, if there's a destination corresponding to this name, I will call it. Example: @@ -169,26 +189,32 @@ As an extra feature: - if a name starts with '-' is ignored - if a name starts with '+', is included. -This is useful if you want to set this format string in a config file. The good thing is that this way you can easily turn on/off +This is useful if you want to set this format string in a config file. +The good thing is that this way you can easily turn on/off certain destinations, while seing all the available destinations as well. Example: \n +out_file -debug_window +console \n -In the above example, I know that the available destinations are @c out_file, @c debug_window and @c console, but I'm not writing to @c debug_window. +In the above example, I know that the available destinations are @c out_file, +@c debug_window and @c console, but I'm not writing to @c debug_window. @code #include @endcode */ -template struct named_t : is_generic, non_const_context > { - typedef non_const_context< detail::named_context > non_const_context_base; +template +struct named_t : is_generic, non_const_context > { + typedef non_const_context< detail::named_context + > non_const_context_base; typedef hold_string_type string_type; /** @brief constructs the named destination @param named_name name of the named - @param set [optional] named settings - see named_settings class, and @ref dealing_with_flags + @param set [optional] named settings - see named_settings class, + and @ref dealing_with_flags */ named_t(const string_type & format_string = string_type() ) { non_const_context_base::context().format_string( format_string); @@ -203,7 +229,8 @@ template str return *this; } - template named_t & add(const string_type & name, destination dest) { + template named_t & add(const string_type & name, + destination dest) { non_const_context_base::context().add(name, dest); return *this; } @@ -217,7 +244,8 @@ template str } bool operator==(const named_t & other) const { - return &( non_const_context_base::context()) == &( other.non_const_context_base::context()); + return &( non_const_context_base::context()) == + &( other.non_const_context_base::context()); } }; diff --git a/hpx/util/logging/format/destination/rolling_file.hpp b/hpx/util/logging/format/destination/rolling_file.hpp index 1dbf5de7d73f..ea0697aa4842 100644 --- a/hpx/util/logging/format/destination/rolling_file.hpp +++ b/hpx/util/logging/format/destination/rolling_file.hpp @@ -39,7 +39,8 @@ namespace hpx { namespace util { namespace logging { namespace destination { /** - @brief Settings you can pass to the rolling file. To see how it's used, see @ref dealing_with_flags. + @brief Settings you can pass to the rolling file. + To see how it's used, see @ref dealing_with_flags. */ struct rolling_file_settings { typedef ::hpx::util::logging::detail::flag flag; @@ -104,7 +105,8 @@ namespace detail { for ( m_cur_idx = 0; m_cur_idx < m_flags.file_count(); ++m_cur_idx ) { boost::system::error_code ec; if ( fs::exists( file_name(m_cur_idx), ec) && !ec) { - if ( fs::file_size( file_name(m_cur_idx)) < m_flags.max_size_bytes() ) + if ( fs::file_size( file_name(m_cur_idx)) + < m_flags.max_size_bytes() ) // file hasn't reached max size break; } @@ -133,11 +135,13 @@ namespace detail { void recreate_file() { // many thanks to Benjamin de Dardel! namespace fs = boost::filesystem; - m_out = boost::shared_ptr< std::basic_ofstream >(new std::basic_ofstream( file_name(m_cur_idx).c_str(), + m_out = boost::shared_ptr< std::basic_ofstream > + (new std::basic_ofstream( file_name(m_cur_idx).c_str(), m_flags.extra_flags() | std::ios_base::out | std::ios_base::app)); if ( fs::file_size( file_name(m_cur_idx)) > m_flags.max_size_bytes()) { // this file is already full - clear it first - m_out = boost::shared_ptr< std::basic_ofstream >(new std::basic_ofstream( file_name(m_cur_idx).c_str(), + m_out = boost::shared_ptr< std::basic_ofstream + >(new std::basic_ofstream( file_name(m_cur_idx).c_str(), m_flags.extra_flags() | std::ios_base::out | std::ios_base::trunc)); } } @@ -166,31 +170,39 @@ namespace detail { } /** - @brief Writes to multiple files: name_prefix.1, name_prefix.2, ... name_prefix.N, and then restarts from 1. + @brief Writes to multiple files: name_prefix.1, name_prefix.2, ... name_prefix.N, + and then restarts from 1. We first write to name_prefix.1. - The log has a max_size. When max_size is reached, we start writing to name_prefix.2. When max_size is reached, we start writing to name_prefix.3. - And so on, until we reach name_prefix.N (N = file_count). When that gets fool, we start over, with name_prefix.1. + The log has a max_size. When max_size is reached, we start writing to name_prefix.2. + When max_size is reached, we start writing to name_prefix.3. + And so on, until we reach name_prefix.N (N = file_count). When that gets fool, + we start over, with name_prefix.1. */ -template struct rolling_file_t : is_generic, non_const_context > { - typedef non_const_context< detail::rolling_file_info > non_const_context_base; +template struct rolling_file_t + : is_generic, non_const_context > { + typedef non_const_context< detail::rolling_file_info > + non_const_context_base; /** Constructs a rolling file @param name_prefix the name to be used as prefix for the files - @param flags [optional] extra settings to pass to the rolling file. See rolling_file_settings and @ref dealing_with_flags. + @param flags [optional] extra settings to pass to the rolling file. + See rolling_file_settings and @ref dealing_with_flags. */ - rolling_file_t(const std::string & name_prefix, rolling_file_settings flags = rolling_file_settings() ) : non_const_context_base(name_prefix, flags) {} + rolling_file_t(const std::string & name_prefix, rolling_file_settings flags = + rolling_file_settings() ) : non_const_context_base(name_prefix, flags) {} template void operator()( const msg_type & msg) const { non_const_context_base::context().write(msg); } bool operator==(const rolling_file_t & other) const { - return non_const_context_base::context().m_name_prefix == other.context().m_name_prefix; + return non_const_context_base::context().m_name_prefix == + other.context().m_name_prefix; } /** diff --git a/hpx/util/logging/format/destination/shared_memory.hpp b/hpx/util/logging/format/destination/shared_memory.hpp index 0772927358d3..817bc087e618 100644 --- a/hpx/util/logging/format/destination/shared_memory.hpp +++ b/hpx/util/logging/format/destination/shared_memory.hpp @@ -33,8 +33,10 @@ namespace hpx { namespace util { namespace logging { namespace destination { namespace detail { struct shared_memory_context { shared_memory_context() : occupied_size(0), memory(0), mem_size(0) { - // note: we don't want to destroy this segment, since we want it to outlive our - // application. In the case of a problem, we need to have another program that will + // note: we don't want to destroy this segment, since we want + // it to outlive our + // application. In the case of a problem, we need to have + // another program that will // take a look at what we just logged. } @@ -51,35 +53,44 @@ namespace detail { /** @brief Logs the information in shared memory */ -template struct shared_memory_t : non_const_context { +template +struct shared_memory_t : non_const_context { enum { just_in_case = 8192 }; - shared_memory_t(const std::string & name, std::size_t mem_size = 2 * 1024 * 1024 * sizeof(char_type) ) : m_name(name), m_mem_size(mem_size) { + shared_memory_t(const std::string & name, std::size_t mem_size = + 2 * 1024 * 1024 * sizeof(char_type) ) : m_name(name), m_mem_size(mem_size) { non_const_context_base::context().mem_size = mem_size; // this segment might have been previously created... - non_const_context_base::context().segment.open_or_create(name.c_str(), non_const_context_base::context().mem_size + just_in_case); + non_const_context_base::context().segment.open_or_create(name.c_str(), + non_const_context_base::context().mem_size + just_in_case); // the string { typedef std::pair pair; - pair res = non_const_context_base::context().segment.find("shared_log_object"); + pair res = non_const_context_base::context().segment.find + ("shared_log_object"); if ( !res.first) // we're creating it right now - non_const_context_base::context().segment.construct("shared_log_object")[mem_size](0); + non_const_context_base::context().segment.construct + ("shared_log_object")[mem_size](0); - res = non_const_context_base::context().segment.find("shared_log_object"); + res = non_const_context_base::context().segment.find + ("shared_log_object"); HPX_ASSERT( res.first); // should be created by now non_const_context_base::context().memory = res.first; } // the occupied size { typedef std::pair pair; - pair res = non_const_context_base::context().segment.find("shared_occupied_size"); + pair res = non_const_context_base::context().segment.find + ("shared_occupied_size"); if ( !res.first) // we're creating it right now - non_const_context_base::context().segment.construct("shared_occupied_size")[1](0); + non_const_context_base::context().segment.construct + ("shared_occupied_size")[1](0); - res = non_const_context_base::context().segment.find("shared_occupied_size"); + res = non_const_context_base::context().segment.find + ("shared_occupied_size"); HPX_ASSERT( res.first); // should be created by now non_const_context_base::context().occupied_size = res.first; } @@ -88,9 +99,11 @@ template struct shared_memory_t : template void operator () (const msg_type& msg_arg) const { const string_type & msg = do_convert::do_convert(msg_arg, into() ); - bool can_fit = *(non_const_context_base::context().occupied_size) + msg.size() < non_const_context_base::context().mem_size; + bool can_fit = *(non_const_context_base::context().occupied_size) + + msg.size() < non_const_context_base::context().mem_size; if ( can_fit) { - std::copy(msg.begin(), msg.end(), non_const_context_base::context().memory + *non_const_context_base::context().occupied_size); + std::copy(msg.begin(), msg.end(), non_const_context_base::context().memory + + *non_const_context_base::context().occupied_size); *non_const_context_base::context().occupied_size += (long)msg.size(); } else { @@ -98,18 +111,26 @@ template struct shared_memory_t : if ( msg.size() < non_const_context_base::context().mem_size) { // move what was previously written, to the left, to make room std::size_t keep = non_const_context_base::context().mem_size / 2; - if ( keep + msg.size() > non_const_context_base::context().mem_size) keep = non_const_context_base::context().mem_size - msg.size(); + if ( keep + msg.size() > non_const_context_base::context().mem_size) + keep = non_const_context_base::context().mem_size - msg.size(); std::copy_backward( - non_const_context_base::context().memory + *non_const_context_base::context().occupied_size - keep, - non_const_context_base::context().memory + *non_const_context_base::context().occupied_size, + non_const_context_base::context().memory + + *non_const_context_base::context().occupied_size - keep, + non_const_context_base::context().memory + + *non_const_context_base::context().occupied_size, non_const_context_base::context().memory + keep); - std::copy( msg.begin(), msg.end(), non_const_context_base::context().memory + keep); - *non_const_context_base::context().occupied_size = (long)(keep + msg.size()); + std::copy( msg.begin(), msg.end(), + non_const_context_base::context().memory + keep); + *non_const_context_base::context().occupied_size = + (long)(keep + msg.size()); } else { // message too big - std::copy(msg.begin(), msg.begin() + non_const_context_base::context().mem_size, non_const_context_base::context().memory); - *non_const_context_base::context().occupied_size = (long)non_const_context_base::context().mem_size; + std::copy(msg.begin(), msg.begin() + + non_const_context_base::context().mem_size, + non_const_context_base::context().memory); + *non_const_context_base::context().occupied_size = + (long)non_const_context_base::context().mem_size; } } } diff --git a/hpx/util/logging/format/formatter/convert_format.hpp b/hpx/util/logging/format/formatter/convert_format.hpp index c254bea0c07c..3bbe7fb7660d 100644 --- a/hpx/util/logging/format/formatter/convert_format.hpp +++ b/hpx/util/logging/format/formatter/convert_format.hpp @@ -45,10 +45,13 @@ namespace formatter { /** - @brief Allows format convertions - In case you're using a formatter that does not match your string type + @brief Allows format convertions + - In case you're using a formatter that does not match your string type - In case you want to use a formatter developed by someone else (for instance, a formatter provided by this lib), - perhaps you're using another type of string to hold the message - thus, you need to provide a conversion function + In case you want to use a formatter developed by someone else + (for instance, a formatter provided by this lib), + perhaps you're using another type of string to hold the message + - thus, you need to provide a conversion function Example: FIXME @@ -56,7 +59,8 @@ namespace formatter { --> convert_format::prepend explain that you can extend the following - since they're namespaces!!! - so that you can "inject" your own write function in the convert_format::prepend/orwhatever namespace, and + so that you can "inject" your own write function + in the convert_format::prepend/orwhatever namespace, and then it'll be automatically used! */ namespace convert { @@ -69,20 +73,27 @@ namespace convert { typedef string original_type ; static const type& get(const original_type & str) { return str; } }; - template struct string_finder< ::hpx::util::logging::optimize::cache_string_one_str > { + template struct string_finder< + ::hpx::util::logging::optimize::cache_string_one_str > { typedef string type; - typedef ::hpx::util::logging::optimize::cache_string_one_str original_type ; + typedef ::hpx::util::logging::optimize::cache_string_one_str + original_type ; static const type& get(const original_type & str) { return str; } }; - template struct string_finder< ::hpx::util::logging::optimize::cache_string_several_str > { + template struct string_finder< + ::hpx::util::logging::optimize::cache_string_several_str > { typedef string type; - typedef ::hpx::util::logging::optimize::cache_string_several_str original_type; + typedef ::hpx::util::logging::optimize::cache_string_several_str + original_type; static const type& get(const original_type & str) { return str; } }; - template - struct string_finder< ::hpx::util::logging::tag::holder > { + template + struct string_finder< ::hpx::util::logging::tag::holder > { typedef typename string_finder< string>::type type; - typedef ::hpx::util::logging::tag::holder original_type; + typedef ::hpx::util::logging::tag::holder original_type; // note: this needs 2 conversions - to string, and then to cache string static const type& get(const original_type & str) { return str; } @@ -101,28 +112,38 @@ namespace convert { inline void write(const string_type & src, string_type & dest) { dest.insert( dest.begin(), src.begin(), src.end() ); } - template void write(const string_type & src, hpx::util::logging::optimize::cache_string_one_str & dest) { + template void write(const string_type & src, + hpx::util::logging::optimize::cache_string_one_str & dest) { dest.prepend_string(src); } - template void write(const string_type & src, hpx::util::logging::optimize::cache_string_several_str & dest) { + template void write(const string_type & src, + hpx::util::logging::optimize::cache_string_several_str & dest) { dest.prepend_string(src); } - template void write(const string_type & src, ::hpx::util::logging::tag::holder & dest) { + template void write(const string_type + & src, ::hpx::util::logging::tag::holder & dest) { typedef typename use_default::type string; write(src, static_cast(dest) ); } - template void write(char_array src, hpx::util::logging::optimize::cache_string_one_str & dest) { + template void write(char_array src, + hpx::util::logging::optimize::cache_string_one_str & dest) { dest.prepend_string(src); } - template void write(char_array src, hpx::util::logging::optimize::cache_string_several_str & dest) { + template void write(char_array src, + hpx::util::logging::optimize::cache_string_several_str & dest) { dest.prepend_string(src); } - template void write(char_array src, ::hpx::util::logging::tag::holder & dest) { + template void write(char_array src, + ::hpx::util::logging::tag::holder + & dest) { typedef typename use_default::type string; write(src, static_cast(dest) ); } @@ -134,13 +155,19 @@ namespace convert { inline void write(const string_type & src, string_type & dest) { dest += src; } - template void write(const string_type & src, hpx::util::logging::optimize::cache_string_one_str & dest) { + template void write(const string_type & src, + hpx::util::logging::optimize::cache_string_one_str & dest) { dest.append_string(src); } - template void write(const string_type & src, hpx::util::logging::optimize::cache_string_several_str & dest) { + template void write(const string_type & src, + hpx::util::logging::optimize::cache_string_several_str & dest) { dest.append_string(src); } - template void write(const string_type & src, ::hpx::util::logging::tag::holder & dest) { + template + void write(const string_type & src, + ::hpx::util::logging::tag::holder + & dest) { typedef typename use_default::type string; write(src, static_cast(dest) ); } @@ -149,13 +176,18 @@ namespace convert { inline void write(char_array src, string_type & dest ) { dest += src; } - template void write(char_array src, hpx::util::logging::optimize::cache_string_one_str & dest) { + template void write(char_array src, + hpx::util::logging::optimize::cache_string_one_str & dest) { dest.append_string(src); } - template void write(char_array src, hpx::util::logging::optimize::cache_string_several_str & dest) { + template void write(char_array src, + hpx::util::logging::optimize::cache_string_several_str & dest) { dest.append_string(src); } - template void write(char_array src, ::hpx::util::logging::tag::holder & dest) { + template void write(char_array src, + ::hpx::util::logging::tag::holder + & dest) { typedef typename use_default::type string; write(src, static_cast(dest) ); } @@ -168,16 +200,22 @@ namespace convert { inline void write(const string_type & src, string_type & dest) { dest = src; } - template void write(const string_type & src, hpx::util::logging::optimize::cache_string_one_str & dest) { + template void write(const string_type & src, + hpx::util::logging::optimize::cache_string_one_str & dest) { dest.set_string(src); } - template void write(const string_type & src, hpx::util::logging::optimize::cache_string_several_str & dest) { + template void write(const string_type & src, + hpx::util::logging::optimize::cache_string_several_str & dest) { dest.set_string(src); } - template void write(string_type & src, hpx::util::logging::optimize::cache_string_one_str & dest) { + template void write(string_type & src, + hpx::util::logging::optimize::cache_string_one_str & dest) { dest.set_string_swap(src); } - template void write(const string_type & src, ::hpx::util::logging::tag::holder & dest) { + template void write(const string_type + & src, ::hpx::util::logging::tag::holder & dest) { typedef typename use_default::type string; write(src, static_cast(dest) ); } @@ -187,13 +225,18 @@ namespace convert { inline void write(char_array src, string_type & dest ) { dest = src; } - template void write(char_array src, hpx::util::logging::optimize::cache_string_one_str & dest) { + template void write(char_array src, + hpx::util::logging::optimize::cache_string_one_str & dest) { dest.set_string(src); } - template void write(char_array src, hpx::util::logging::optimize::cache_string_several_str & dest) { + template void write(char_array src, + hpx::util::logging::optimize::cache_string_several_str & dest) { dest.set_string(src); } - template void write(char_array src, ::hpx::util::logging::tag::holder & dest) { + template void write(char_array src, + ::hpx::util::logging::tag::holder + & dest) { typedef typename use_default::type string; write(src, static_cast(dest) ); } @@ -206,7 +249,8 @@ struct do_convert_format { struct prepend { template - static inline const typename convert::string_finder::type & get_underlying_string(const string & str) { + static inline const typename convert::string_finder + ::type & get_underlying_string(const string & str) { return convert::string_finder::get(str); } @@ -214,17 +258,20 @@ struct do_convert_format { convert::prepend::write(src, dest); } - template static void write(const src_type & src, string & dest) { + template static void write(const src_type & src, + string & dest) { convert::prepend::write(src, dest); } - template static void write(src_type & src, string & dest) { + template static void write(src_type & src, + string & dest) { convert::prepend::write(src, dest); } }; struct append { template - static inline const typename convert::string_finder::type & get_underlying_string(const string & str) { + static inline const typename convert::string_finder + ::type & get_underlying_string(const string & str) { return convert::string_finder::get(str); } @@ -232,17 +279,20 @@ struct do_convert_format { convert::append::write(src, dest); } - template static void write(const src_type & src, string & dest) { + template static void write(const src_type & src, + string & dest) { convert::append::write(src, dest); } - template static void write(src_type & src, string & dest) { + template static void write(src_type & src, + string & dest) { convert::append::write(src, dest); } }; struct modify { template - static inline const typename convert::string_finder::type & get_underlying_string(const string & str) { + static inline const typename convert::string_finder + ::type & get_underlying_string(const string & str) { return convert::string_finder::get(str); } @@ -250,10 +300,12 @@ struct do_convert_format { convert::modify::write(src, dest); } - template static void write(const src_type & src, string & dest) { + template static void write(const src_type & src, + string & dest) { convert::modify::write(src, dest); } - template static void write(src_type & src, string & dest) { + template static void write(src_type & src, + string & dest) { convert::modify::write(src, dest); } }; diff --git a/hpx/util/logging/format/formatter/defaults.hpp b/hpx/util/logging/format/formatter/defaults.hpp index 305efa7f22ff..f9fdf9c4c504 100644 --- a/hpx/util/logging/format/formatter/defaults.hpp +++ b/hpx/util/logging/format/formatter/defaults.hpp @@ -55,18 +55,22 @@ This will output something similar to: @endcode -@param convert [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. -For instance, you might use @ref hpx::util::logging::optimize::cache_string_one_str "a cached_string class" (see @ref hpx::util::logging::optimize "optimize namespace"). +@param convert [optional] In case there needs to be a conversion between +std::(w)string and the string that holds your logged message. See convert_format. +For instance, you might use @ref hpx::util::logging::optimize::cache_string_one_str +"a cached_string class" (see @ref hpx::util::logging::optimize "optimize namespace"). */ template -struct idx_t : is_generic, formatter::non_const_context, hpx::util::logging::op_equal::always_equal { +struct idx_t : is_generic, formatter::non_const_context, + hpx::util::logging::op_equal::always_equal { typedef formatter::non_const_context non_const_context_base; typedef convert convert_type; idx_t() : non_const_context_base(0ull) {} template void operator()(msg_type & str) const { std::basic_ostringstream idx; - idx << std::hex << std::setw(sizeof(boost::uint64_t)*2) << std::setfill('0') << ++context(); + idx << std::hex << std::setw(sizeof(boost::uint64_t)*2) + << std::setfill('0') << ++context(); convert::write( idx.str(), str ); } @@ -76,10 +80,13 @@ struct idx_t : is_generic, formatter::non_const_context, hpx::u /** @brief Appends a new line -@param convert [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. -For instance, you might use @ref hpx::util::logging::optimize::cache_string_one_str "a cached_string class" (see @ref hpx::util::logging::optimize "optimize namespace"). +@param convert [optional] In case there needs to be a conversion between +std::(w)string and the string that holds your logged message. See convert_format. +For instance, you might use @ref hpx::util::logging::optimize::cache_string_one_str +"a cached_string class" (see @ref hpx::util::logging::optimize "optimize namespace"). */ -template struct append_newline_t : is_generic, hpx::util::logging::op_equal::always_equal { +template struct append_newline_t + : is_generic, hpx::util::logging::op_equal::always_equal { typedef convert convert_type; template void operator()(msg_type & str) const { convert::write( HPX_LOG_STR("\n"), str ); @@ -90,10 +97,13 @@ template struct append_newline_t : is /** @brief Appends a new line, if not already there -@param convert [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. -For instance, you might use @ref hpx::util::logging::optimize::cache_string_one_str "a cached_string class" (see @ref hpx::util::logging::optimize "optimize namespace"). +@param convert [optional] In case there needs to be a conversion between +std::(w)string and the string that holds your logged message. See convert_format. +For instance, you might use @ref hpx::util::logging::optimize::cache_string_one_str +"a cached_string class" (see @ref hpx::util::logging::optimize "optimize namespace"). */ -template struct append_newline_if_needed_t : is_generic, hpx::util::logging::op_equal::always_equal { +template struct append_newline_if_needed_t + : is_generic, hpx::util::logging::op_equal::always_equal { typedef convert convert_type; template void operator()(msg_type & str) const { diff --git a/hpx/util/logging/format/formatter/high_precision_time.hpp b/hpx/util/logging/format/formatter/high_precision_time.hpp index 3a2e7591413f..9c1088401709 100644 --- a/hpx/util/logging/format/formatter/high_precision_time.hpp +++ b/hpx/util/logging/format/formatter/high_precision_time.hpp @@ -36,13 +36,15 @@ namespace hpx { namespace util { namespace logging { namespace formatter { /** -@brief Prefixes the message with a high-precision time (. You pass the format string at construction. +@brief Prefixes the message with a high-precision time (. +You pass the format string at construction. @code #include @endcode -Internally, it uses hpx::util::date_time::microsec_time_clock. So, our precision matches this class. +Internally, it uses hpx::util::date_time::microsec_time_clock. +So, our precision matches this class. The format can contain escape sequences: $dd - day, 2 digits @@ -63,20 +65,26 @@ The format can contain escape sequences: high_precision_time("$mm:$ss:$micro"); @endcode -@param convert [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. -For instance, you might use @ref hpx::util::logging::optimize::cache_string_one_str "a cached_string class" (see @ref hpx::util::logging::optimize "optimize namespace"). +@param convert [optional] In case there needs to be a conversion between +std::(w)string and the string that holds your logged message. See convert_format. +For instance, you might use @ref hpx::util::logging::optimize::cache_string_one_str +"a cached_string class" (see @ref hpx::util::logging::optimize "optimize namespace"). */ -template struct high_precision_time_t : is_generic, non_const_context { +template struct high_precision_time_t + : is_generic, non_const_context { typedef convert convert_type; - typedef non_const_context non_const_context_base; + typedef non_const_context + non_const_context_base; /** constructs a high_precision_time object */ - high_precision_time_t(const hold_string_type & format) : non_const_context_base(format) {} + high_precision_time_t(const hold_string_type & format) + : non_const_context_base(format) {} template - void write_high_precision_time(msg_type & msg, ::boost::posix_time::ptime val) const { + void write_high_precision_time(msg_type & msg, ::boost::posix_time::ptime val) + const { char_type buffer[64]; int nanosecs = static_cast(val.time_of_day().fractional_seconds()); //-V807 @@ -115,11 +123,13 @@ template struct high_precision_time_ } template void operator()(msg_type & msg) const { - write_high_precision_time(msg, ::boost::posix_time::microsec_clock::local_time() ); + write_high_precision_time(msg, + ::boost::posix_time::microsec_clock::local_time() ); } bool operator==(const high_precision_time_t & other) const { - return non_const_context_base::context() == other.non_const_context_base::context() ; + return non_const_context_base::context() == + other.non_const_context_base::context() ; } /** @brief configure through script diff --git a/hpx/util/logging/format/formatter/named_spacer.hpp b/hpx/util/logging/format/formatter/named_spacer.hpp index 83fb0d82c0e7..348044793d37 100644 --- a/hpx/util/logging/format/formatter/named_spacer.hpp +++ b/hpx/util/logging/format/formatter/named_spacer.hpp @@ -33,11 +33,18 @@ namespace hpx { namespace util { namespace logging { namespace formatter { namespace detail { - template struct named_spacer_context { - typedef typename use_default >::type lock_resource_type; - typedef typename use_default >::type format_base_type; - typedef typename use_default ::type convert_type; - typedef ::hpx::util::logging::array::shared_ptr_holder array; + template + struct named_spacer_context { + typedef typename use_default > + ::type lock_resource_type; + typedef typename use_default > + ::type format_base_type; + typedef typename use_default + ::type convert_type; + typedef ::hpx::util::logging::array::shared_ptr_holder array; typedef hold_string_type string_type; struct write_step { @@ -99,11 +106,14 @@ namespace detail { } private: - template void write_with_convert(msg_type & msg, ::hpx::util::logging::formatter::do_convert_format::prepend*) const { + template void write_with_convert(msg_type & msg, + ::hpx::util::logging::formatter::do_convert_format::prepend*) const { // prepend typename data::read info(m_data); typedef typename write_info::write_step_array array_; - for ( typename array_::const_reverse_iterator b = info->write_steps.rbegin(), e = info->write_steps.rend(); b != e; ++b) { + for ( typename array_::const_reverse_iterator b = + info->write_steps.rbegin(), + e = info->write_steps.rend(); b != e; ++b) { if ( b->fmt) (*(b->fmt))(msg); convert_type::write( b->prefix, msg); @@ -113,7 +123,8 @@ namespace detail { // append typename data::read info(m_data); typedef typename write_info::write_step_array array_; - for ( typename array_::const_iterator b = info->write_steps.begin(), e = info->write_steps.end(); b != e; ++b) { + for ( typename array_::const_iterator b = info->write_steps.begin(), + e = info->write_steps.end(); b != e; ++b) { convert_type::write( b->prefix, msg); if ( b->fmt) (*(b->fmt))(msg); @@ -126,7 +137,8 @@ namespace detail { while ( true) { size_type found = escaped.find( HPX_LOG_STR("%%"), idx_start ); if ( found != string_type::npos) { - escaped.erase( escaped.begin() + static_cast(found)); + escaped.erase( escaped.begin() + + static_cast(found)); ++idx_start; } else @@ -136,7 +148,8 @@ namespace detail { } // recomputes the write steps - note taht this takes place after each operation - // for instance, the user might have first set the string and later added the formatters + // for instance, the user might have first set the string and + // later added the formatters void compute_write_steps() { typedef typename string_type::size_type size_type; @@ -179,18 +192,23 @@ namespace detail { private: // non-generic - template void add_impl(const string_type & name, formatter fmt, const boost::false_type& ) { + template void add_impl(const string_type & name, + formatter fmt, const boost::false_type& ) { typename data::write info(m_data); format_base_type * p = info->formatters.append(fmt); info->name_to_formatter[name] = p; } // generic manipulator - template void add_impl(const string_type & name, formatter fmt, const boost::true_type& ) { - typedef hpx::util::logging::manipulator::detail::generic_holder holder; + template void add_impl(const string_type & name, + formatter fmt, const boost::true_type& ) { + typedef hpx::util::logging::manipulator::detail::generic_holder holder; typedef typename formatter::convert_type formatter_convert_type; - // they must share the same type of conversion - otherwise when trying to prepend we could end up appending or vice versa - BOOST_STATIC_ASSERT( (boost::is_same::value) ); + // they must share the same type of conversion + // - otherwise when trying to prepend we could end up appending or vice versa + BOOST_STATIC_ASSERT( (boost::is_same::value) ); add_impl( name, holder(fmt), boost::false_type() ); } @@ -200,7 +218,9 @@ namespace detail { } /** -@brief Allows you to contain multiple formatters, and specify a %spacer between them. You have a %spacer string, and within it, you can escape your contained formatters. +@brief Allows you to contain multiple formatters, +and specify a %spacer between them. You have a %spacer string, and within it, +you can escape your contained formatters. @code #include @@ -209,9 +229,11 @@ namespace detail { This allows you: - to hold multiple formatters - each formatter is given a name, when being added -- you have a %spacer string, which contains what is to be prepended or appended to the string (by default, prepended) +- you have a %spacer string, which contains what is to be prepended or +appended to the string (by default, prepended) - a formatter is escaped with @c '\%' chars, like this @c "%name%" -- if you want to write the @c '\%', just double it, like this: "this %% gets written" +- if you want to write the @c '\%', just double it, +like this: "this %% gets written" Example: @@ -239,13 +261,18 @@ You could have an output like this: @endcode -@bug Use_tags.cpp example when on dedicated thread, fails with named_spacer. If using the old code, it works. +@bug Use_tags.cpp example when on dedicated thread, +fails with named_spacer. If using the old code, it works. */ -template< class convert = default_, class format_base = default_, class lock_resource = default_ > - struct named_spacer_t : is_generic, non_const_context< detail::named_spacer_context > { - - typedef non_const_context< detail::named_spacer_context > context_base; +template< class convert = default_, class format_base = default_, +class lock_resource = default_ > + struct named_spacer_t : is_generic, + non_const_context< detail::named_spacer_context > { + + typedef non_const_context< detail::named_spacer_context > context_base; typedef hold_string_type string_type; named_spacer_t(const string_type & str = string_type() ) { @@ -258,7 +285,8 @@ template< class convert = default_, class format_base = default_, class lock_res return *this; } - template named_spacer_t & add(const string_type & name, formatter fmt) { + template named_spacer_t & add(const string_type & name, + formatter fmt) { context_base::context().add(name, fmt); return *this; } diff --git a/hpx/util/logging/format/formatter/spacer.hpp b/hpx/util/logging/format/formatter/spacer.hpp index d859627b4de2..af6cf3bd66ae 100644 --- a/hpx/util/logging/format/formatter/spacer.hpp +++ b/hpx/util/logging/format/formatter/spacer.hpp @@ -30,34 +30,49 @@ namespace hpx { namespace util { namespace logging { namespace formatter { namespace detail { - template inline void spacer_write_with_convert(msg_type & msg, const original_formatter & fmt, const string_type & prefix, const string_type & suffix, const do_convert_format::prepend*) { + template inline void spacer_write_with_convert(msg_type & msg, + const original_formatter & fmt, const string_type & prefix, + const string_type & suffix, const do_convert_format::prepend*) { // prepend do_convert_format::prepend::write(suffix, msg); fmt(msg); do_convert_format::prepend::write(prefix, msg); } - template inline void spacer_write_with_convert(msg_type & msg, const original_formatter & fmt, const string_type & prefix, const string_type & suffix, const do_convert_format::append*) { + template inline void spacer_write_with_convert(msg_type & msg, + const original_formatter & fmt, const string_type & prefix, + const string_type & suffix, const do_convert_format::append*) { // append do_convert_format::append::write(prefix, msg); fmt(msg); do_convert_format::append::write(suffix, msg); } - template inline void spacer_write_with_convert(msg_type & msg, const original_formatter & fmt, const string_type & prefix, const string_type & suffix, const convert*) { + template inline + void spacer_write_with_convert(msg_type & msg, const original_formatter & fmt, + const string_type & prefix, const string_type & suffix, const convert*) { // custom conversion - prefix before suffix convert::write(prefix, msg); fmt(msg); convert::write(suffix, msg); } - // note: pass original_formatter here - so that original_formatter::operator() gets called, not the spacer_t's operator() - template inline void spacer_write(msg_type & msg, const original_formatter & fmt, const string_type & prefix, const string_type & suffix) { + // note: pass original_formatter here + // - so that original_formatter::operator() gets called, + // not the spacer_t's operator() + template inline void spacer_write(msg_type & msg, + const original_formatter & fmt, const string_type & prefix, + const string_type & suffix) { spacer_write_with_convert(msg, fmt, prefix, suffix, 0); } } /** @brief Prepends some info, and appends some info to an existing formatter -The syntax is simple: construct a spacer by passing the original formatter, and the text to space (prepend and append). +The syntax is simple: construct a spacer by passing the original formatter, +and the text to space (prepend and append). Use: - @c % to mean the original formatter text - anything before @c "%" is prepended before @@ -88,18 +103,21 @@ g_l()->writer().add_formatter( formatter::idx(), "[%] " ); */ -template struct spacer_t : original_formatter { +template struct spacer_t : original_formatter { // "fixed" formatter - it has a msg_type typedef typedef typename original_formatter::param param; typedef original_formatter spacer_base; typedef hold_string_type string_type; - spacer_t(const original_formatter & fmt, const char_type * format_str) : spacer_base(fmt) { + spacer_t(const original_formatter & fmt, const char_type * format_str) + : spacer_base(fmt) { parse_format( format_str); } void operator()(param msg) const { - detail::spacer_write(msg, *this, m_prefix, m_suffix); + detail::spacer_write(msg, + *this, m_prefix, m_suffix); } private: void parse_format(const string_type & format_str) { @@ -119,12 +137,14 @@ template str }; // specialize for generic formatters -template struct spacer_t : original_formatter { +template +struct spacer_t : original_formatter { // generic formatter typedef original_formatter spacer_base; typedef hold_string_type string_type; - spacer_t(const original_formatter & fmt, const char_type * format_str) : spacer_base(fmt) { + spacer_t(const original_formatter & fmt, const char_type * format_str) + : spacer_base(fmt) { parse_format( format_str); } @@ -155,21 +175,25 @@ namespace detail { typedef typename original_formatter::convert_type convert; typedef spacer_t type; }; - template struct find_spacer_generic { + template + struct find_spacer_generic { // not generic typedef do_convert_format::prepend convert ; typedef spacer_t type; }; template - struct find_spacer : find_spacer_generic::value> { + struct find_spacer : find_spacer_generic::value> { }; } /** @copydoc spacer_t */ -template typename detail::find_spacer::type spacer(const original_formatter & fmt, const char_type* format_str) { +template +typename detail::find_spacer +::type spacer(const original_formatter & fmt, const char_type* format_str) { typedef typename detail::find_spacer::type spacer_type; return spacer_type(fmt, format_str); } diff --git a/hpx/util/logging/format/formatter/tags.hpp b/hpx/util/logging/format/formatter/tags.hpp index c531098623cd..05a0da42e495 100644 --- a/hpx/util/logging/format/formatter/tags.hpp +++ b/hpx/util/logging/format/formatter/tags.hpp @@ -48,32 +48,41 @@ template struct uses_tag { } }; -/** @brief Classes that process the @ref hpx::util::logging::tag "tags" coming with the library +/** @brief Classes that process the @ref hpx::util::logging::tag "tags" +coming with the library See @ref hpx::util::logging::tag "how to use tags". */ namespace tag { -/** @brief Dumps file/line information (corresponds to hpx::util::logging::tag::file_line tag class) +/** @brief Dumps file/line information (corresponds to +hpx::util::logging::tag::file_line tag class) See @ref hpx::util::logging::tag "how to use tags". */ -template struct file_line_t : is_generic, uses_tag< file_line_t, ::hpx::util::logging::tag::file_line >, hpx::util::logging::op_equal::always_equal { +template +struct file_line_t : is_generic, uses_tag< file_line_t, + ::hpx::util::logging::tag::file_line >, hpx::util::logging::op_equal::always_equal { typedef convert convert_type; - template void write_tag(msg_type & str, const tag_type & tag) const { + template void write_tag(msg_type & str, + const tag_type & tag) const { convert::write( tag.val, str); } }; -/** @brief Dumps function name information (corresponds to hpx::util::logging::tag::function tag class) +/** @brief Dumps function name information +(corresponds to hpx::util::logging::tag::function tag class) See @ref hpx::util::logging::tag "how to use tags". */ -template struct function_t : is_generic, uses_tag< function_t, ::hpx::util::logging::tag::function >, hpx::util::logging::op_equal::always_equal { +template struct function_t : is_generic, +uses_tag< function_t, ::hpx::util::logging::tag::function >, +hpx::util::logging::op_equal::always_equal { typedef convert convert_type; - template void write_tag(msg_type & str, const tag_type & tag) const { + template void write_tag(msg_type & str, + const tag_type & tag) const { convert::write( tag.val, str); } }; @@ -84,9 +93,12 @@ template struct function_t : is_gene See @ref hpx::util::logging::tag "how to use tags". */ -template struct level_t : is_generic, uses_tag< level_t, ::hpx::util::logging::tag::level >, hpx::util::logging::op_equal::always_equal { +template +struct level_t : is_generic, uses_tag< level_t, + ::hpx::util::logging::tag::level >, hpx::util::logging::op_equal::always_equal { typedef convert convert_type; - template void write_tag(msg_type & str, const tag_type & tag) const { + template void write_tag(msg_type & str, + const tag_type & tag) const { typedef typename hpx::util::logging::dump_level<>::type dump_type; convert::write( dump_type::dump(tag.val) , str); } @@ -94,20 +106,23 @@ template struct level_t : is_generic -/** @brief Dumps current time information (corresponds to hpx::util::logging::tag::time tag class) +/** @brief Dumps current time information +(corresponds to hpx::util::logging::tag::time tag class) Similar to hpx::util::logging::formatter::time_t class - only that this one uses tags. See @ref hpx::util::logging::tag "how to use tags". */ -template struct time_t : is_generic, uses_tag< time_t, ::hpx::util::logging::tag::time > { +template struct time_t + : is_generic, uses_tag< time_t, ::hpx::util::logging::tag::time > { typedef convert convert_type; typedef hpx::util::logging::formatter::time_t time_write_type; time_write_type m_writer; time_t(const hold_string_type & format) : m_writer(format) {} - template void write_tag(msg_type & str, const tag_type & tag) const { + template + void write_tag(msg_type & str, const tag_type & tag) const { m_writer.write_time(str, tag.val); } @@ -120,28 +135,37 @@ template struct time_t : is_generic, -/** @brief Dumps module information (corresponds to hpx::util::logging::tag::module tag class) +/** @brief Dumps module information +(corresponds to hpx::util::logging::tag::module tag class) See @ref hpx::util::logging::tag "how to use tags". */ -template struct module_t : is_generic, uses_tag< module_t, ::hpx::util::logging::tag::module >, hpx::util::logging::op_equal::always_equal { +template struct module_t + : is_generic, uses_tag< module_t, ::hpx::util::logging::tag::module >, + hpx::util::logging::op_equal::always_equal { typedef convert convert_type; - template void write_tag(msg_type & str, const tag_type & tag) const { + template void write_tag(msg_type & str, + const tag_type & tag) const { convert::write( tag.val, str); } }; -/** @brief Dumps thread id information (corresponds to hpx::util::logging::tag::thread_id tag class) +/** @brief Dumps thread id information +(corresponds to hpx::util::logging::tag::thread_id tag class) See @ref hpx::util::logging::tag "how to use tags". */ -template , class convert = do_convert_format::prepend> struct thread_id_t - : is_generic, uses_tag< thread_id_t< ::std::basic_ostringstream, convert>, ::hpx::util::logging::tag::thread_id >, hpx::util::logging::op_equal::always_equal { +template , +class convert = do_convert_format::prepend> struct thread_id_t + : is_generic, uses_tag< thread_id_t< ::std::basic_ostringstream, + convert>, ::hpx::util::logging::tag::thread_id >, + hpx::util::logging::op_equal::always_equal { typedef convert convert_type; - template void write_tag(msg_type & str, const tag_type & tag) const { + template void write_tag(msg_type & str, + const tag_type & tag) const { stream_type out; out << tag.val ; convert::write( out.str(), str); diff --git a/hpx/util/logging/format/formatter/thread_id.hpp b/hpx/util/logging/format/formatter/thread_id.hpp index 32d641a5d33a..c5a670bf30cd 100644 --- a/hpx/util/logging/format/formatter/thread_id.hpp +++ b/hpx/util/logging/format/formatter/thread_id.hpp @@ -31,10 +31,13 @@ namespace hpx { namespace util { namespace logging { namespace formatter { /** @brief Writes the thread_id to the log -@param convert [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. -For instance, you might use @ref hpx::util::logging::optimize::cache_string_one_str "a cached_string class" (see @ref hpx::util::logging::optimize "optimize namespace"). +@param convert [optional] In case there needs to be a conversion between +std::(w)string and the string that holds your logged message. See convert_format. +For instance, you might use @ref hpx::util::logging::optimize::cache_string_one_str +"a cached_string class" (see @ref hpx::util::logging::optimize "optimize namespace"). */ -template struct thread_id_t : is_generic, hpx::util::logging::op_equal::always_equal { +template struct thread_id_t : is_generic, +hpx::util::logging::op_equal::always_equal { typedef convert convert_type; template void operator()(msg_type & msg) const { diff --git a/hpx/util/logging/format/formatter/time.hpp b/hpx/util/logging/format/formatter/time.hpp index 27d035426584..306258d6e3ac 100644 --- a/hpx/util/logging/format/formatter/time.hpp +++ b/hpx/util/logging/format/formatter/time.hpp @@ -48,12 +48,16 @@ Example: time("Today is $dd/$MM/$yyyy"); Note: for a high precision clock, try high_precision_time (uses hpx::util::date_time) -@param convert [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. -For instance, you might use @ref hpx::util::logging::optimize::cache_string_one_str "a cached_string class" (see @ref hpx::util::logging::optimize "optimize namespace"). +@param convert [optional] In case there needs to be a conversion between +std::(w)string and the string that holds your logged message. See convert_format. +For instance, you might use @ref hpx::util::logging::optimize::cache_string_one_str +"a cached_string class" (see @ref hpx::util::logging::optimize "optimize namespace"). */ -template struct time_t : is_generic, non_const_context { +template struct time_t + : is_generic, non_const_context { typedef convert convert_type; - typedef non_const_context non_const_context_base; + typedef non_const_context + non_const_context_base; /** constructs a time object @@ -64,7 +68,9 @@ template struct time_t : is_generic, char_type buffer[64]; tm details = *localtime( &val); - non_const_context_base::context().write_time( buffer, details.tm_mday, details.tm_mon + 1, details.tm_year + 1900, details.tm_hour, details.tm_min, details.tm_sec); + non_const_context_base::context().write_time( buffer, + details.tm_mday, details.tm_mon + 1, details.tm_year + 1900, + details.tm_hour, details.tm_min, details.tm_sec); convert::write(buffer, msg); } @@ -75,7 +81,8 @@ template struct time_t : is_generic, } bool operator==(const time_t & other) const { - return non_const_context_base::context() == other.non_const_context_base::context(); + return non_const_context_base::context() == + other.non_const_context_base::context(); } /** @brief configure through script diff --git a/hpx/util/logging/format/formatter/time_strf.hpp b/hpx/util/logging/format/formatter/time_strf.hpp index 7408417dd89a..229df59cd94d 100644 --- a/hpx/util/logging/format/formatter/time_strf.hpp +++ b/hpx/util/logging/format/formatter/time_strf.hpp @@ -31,12 +31,15 @@ namespace hpx { namespace util { namespace logging { namespace formatter { /** -@brief Prefixes the message with the time, by using strftime function. You pass the format string at construction. +@brief Prefixes the message with the time, by using strftime function. +You pass the format string at construction. @param msg_type The type that holds your logged message. -@param convert [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. -For instance, you might use @ref hpx::util::logging::optimize::cache_string_one_str "a cached_string class" (see @ref hpx::util::logging::optimize "optimize namespace"). +@param convert [optional] In case there needs to be a conversion between +std::(w)string and the string that holds your logged message. See convert_format. +For instance, you might use @ref hpx::util::logging::optimize::cache_string_one_str +"a cached_string class" (see @ref hpx::util::logging::optimize "optimize namespace"). */ template struct time_strf_t : is_generic { typedef convert convert_type; diff --git a/hpx/util/logging/format/op_equal.hpp b/hpx/util/logging/format/op_equal.hpp index 1b43cd4e96e3..1745a124b6ef 100644 --- a/hpx/util/logging/format/op_equal.hpp +++ b/hpx/util/logging/format/op_equal.hpp @@ -41,10 +41,12 @@ namespace op_equal { virtual ~same_type_op_equal_top() {} same_type_op_equal_top(const same_type_op_equal_top&) {} }; - inline bool operator ==(const same_type_op_equal_top& a, const same_type_op_equal_top&b) { return a.equals(b); } + inline bool operator ==(const same_type_op_equal_top& a, + const same_type_op_equal_top&b) { return a.equals(b); } /** - @brief Base class when you want to implement operator== that will compare based on type and member operator== + @brief Base class when you want to implement operator== + that will compare based on type and member operator== @sa same_type_op_equal */ @@ -55,7 +57,9 @@ namespace op_equal { }; /** - @brief Implements operator==, which compares two objects. If they have the same type, it will compare them using the type's member operator==. + @brief Implements operator==, which compares two objects. + If they have the same type, it will compare them using the type's member + operator==. The only constraint is that operator== must be a *member* function */ diff --git a/hpx/util/logging/format/optimize.hpp b/hpx/util/logging/format/optimize.hpp index 8eacc261ae82..a8329948ef33 100644 --- a/hpx/util/logging/format/optimize.hpp +++ b/hpx/util/logging/format/optimize.hpp @@ -32,51 +32,68 @@ namespace hpx { namespace util { namespace logging { /** - @brief Gathering the message: contains optimizers for formatting and/or destinations: for example, caching techniques + @brief Gathering the message: contains optimizers for formatting and/or destinations: + for example, caching techniques */ namespace optimize { /** - @brief Optimizes the formatting for prepending and/or appending strings to the original message + @brief Optimizes the formatting for prepending and/or appending strings to + the original message - It keeps all the modified message in one string. Useful if some formatter needs to access the whole + It keeps all the modified message in one string. + Useful if some formatter needs to access the whole string at once. - reserve_prepend() - the size that is reserved for prepending (similar to string::reserve function) - reserve_append() - the size that is reserved for appending (similar to string::reserve function) + reserve_prepend() - the size that is reserved for prepending + (similar to string::reserve function) + reserve_append() - the size that is reserved for appending + (similar to string::reserve function) - Note : as strings are prepended, reserve_prepend() shrinks. Same goes for append. + Note : as strings are prepended, reserve_prepend() shrinks. + Same goes for append. */ - template struct cache_string_one_str { + template + struct cache_string_one_str { typedef cache_string_one_str self_type; typedef string_type_ string_type; /** @param reserve_prepend - how many chars to have space to prepend by default @param reserve_append - how many chars to have space to append by default - @param grow_size - in case we add a string and there's no room for it, with how much should we grow? We'll - grow this much in addition to the added string - in the needed direction + @param grow_size - in case we add a string and there's no room for it, + with how much should we grow? We'll + grow this much in addition to the added string + - in the needed direction */ - cache_string_one_str(std::size_t reserve_prepend_, std::size_t reserve_append_, std::size_t grow_size_ = 10) - : m_reserve_prepend(reserve_prepend_), m_reserve_append(reserve_append_), m_grow_size(grow_size_), m_full_msg_computed(false) {} + cache_string_one_str(std::size_t reserve_prepend_, std::size_t reserve_append_, + std::size_t grow_size_ = 10) + : m_reserve_prepend(reserve_prepend_), m_reserve_append(reserve_append_), + m_grow_size(grow_size_), m_full_msg_computed(false) {} /** @param msg - the message that is originally cached @param reserve_prepend - how many chars to have space to prepend by default @param reserve_append - how many chars to have space to append by default - @param grow_size - in case we add a string and there's no room for it, with how much should we grow? We'll - grow this much in addition to the added string - in the needed direction + @param grow_size - in case we add a string and there's no room for it, + with how much should we grow? We'll + grow this much in addition to the added string + - in the needed direction */ - cache_string_one_str(const string_type & msg, std::size_t reserve_prepend_ = 10, std::size_t reserve_append_ = 10, std::size_t grow_size_ = 10) - : m_reserve_prepend(reserve_prepend_), m_reserve_append(reserve_append_), m_grow_size(grow_size_), m_full_msg_computed(false) { + cache_string_one_str(const string_type & msg, std::size_t reserve_prepend_ = 10, + std::size_t reserve_append_ = 10, std::size_t grow_size_ = 10) + : m_reserve_prepend(reserve_prepend_), m_reserve_append(reserve_append_), + m_grow_size(grow_size_), m_full_msg_computed(false) { set_string(msg); } - cache_string_one_str() : m_reserve_prepend(10), m_reserve_append(10), m_grow_size(10), m_full_msg_computed(false) {} + cache_string_one_str() : m_reserve_prepend(10), m_reserve_append(10), + m_grow_size(10), m_full_msg_computed(false) {} void set_string(const string_type & str) { m_str.resize(str.size() + m_reserve_prepend + m_reserve_append); - std::copy( str.begin(), str.end(), m_str.begin() + static_cast(m_reserve_prepend)); + std::copy( str.begin(), str.end(), m_str.begin() + + static_cast(m_reserve_prepend)); m_full_msg_computed = false; } @@ -97,8 +114,10 @@ namespace optimize { } private: - static std::size_t str_len(const char* str) { return strlen(str); } - static std::size_t str_len(const wchar_t* str) { return wcslen(str); } + static std::size_t str_len(const char* str) + { return strlen(str); } + static std::size_t str_len(const wchar_t* str) + { return wcslen(str); } public: void prepend_string(const char_type* str) { @@ -110,7 +129,9 @@ namespace optimize { HPX_ASSERT(m_reserve_prepend >= len ); - typename string_type::difference_type start_idx = static_cast(m_reserve_prepend - len); + typename string_type::difference_type start_idx = + static_cast(m_reserve_prepend + - len); m_reserve_prepend -= len; std::copy(str, str + len, m_str.begin() + start_idx); @@ -125,7 +146,9 @@ namespace optimize { HPX_ASSERT(m_reserve_append >= len ); - typename string_type::difference_type start_idx = static_cast(m_str.size() - m_reserve_append); + typename string_type::difference_type start_idx = + static_cast(m_str.size() + - m_reserve_append); std::copy(str, str + len, m_str.begin() + start_idx); m_reserve_append -= len; @@ -145,7 +168,9 @@ namespace optimize { HPX_ASSERT(m_reserve_prepend >= str.size() ); - typename string_type::difference_type start_idx = static_cast(m_reserve_prepend - str.size()); + typename string_type::difference_type start_idx = + static_cast(m_reserve_prepend + - str.size()); m_reserve_prepend -= str.size(); std::copy(str.begin(), str.end(), m_str.begin() + start_idx); @@ -163,7 +188,9 @@ namespace optimize { HPX_ASSERT(m_reserve_append >= str.size()); - typename string_type::difference_type start_idx = static_cast(m_str.size() - m_reserve_append); + typename string_type::difference_type start_idx = + static_cast(m_str.size() + - m_reserve_append); std::copy(str.begin(), str.end(), m_str.begin() + start_idx); m_reserve_append -= str.size(); @@ -174,7 +201,8 @@ namespace optimize { writes the current cached contents to a stream */ template void to_stream(stream_type & stream) const { - stream.write( m_str.begin() + m_reserve_prepend, m_str.size() - m_reserve_prepend - m_reserve_append); + stream.write( m_str.begin() + m_reserve_prepend, m_str.size() + - m_reserve_prepend - m_reserve_append); } /** @@ -183,7 +211,8 @@ namespace optimize { const string_type & full_string() const { if ( !m_full_msg_computed) { m_full_msg_computed = true; - m_full_msg = m_str.substr(m_reserve_prepend, m_str.size() - m_reserve_prepend - m_reserve_append ); + m_full_msg = m_str.substr(m_reserve_prepend, m_str.size() + - m_reserve_prepend - m_reserve_append ); } return m_full_msg; } @@ -193,16 +222,20 @@ namespace optimize { private: void resize_string(std::size_t reserve_prepend_, std::size_t reserve_append_) { if ( is_string_set() ) { - std::size_t to_add = reserve_prepend_ + reserve_append_ - m_reserve_prepend - m_reserve_append ; + std::size_t to_add = reserve_prepend_ + reserve_append_ + - m_reserve_prepend - m_reserve_append ; std::size_t new_size = m_str.size() + to_add; // I'm creating a new string instead of resizing the existing one // this is because the new string could be of lower size string_type new_str(reserve_prepend_, 0); - std::size_t used_size = m_str.size() - m_reserve_prepend - m_reserve_append; + std::size_t used_size = m_str.size() - m_reserve_prepend + - m_reserve_append; new_str.insert( new_str.end(), m_str.begin() + - static_cast(m_reserve_prepend), m_str.begin() + - static_cast(m_reserve_prepend + used_size)); + static_cast + (m_reserve_prepend), m_str.begin() + + static_cast + (m_reserve_prepend + used_size)); HPX_ASSERT(new_size == reserve_prepend_ + used_size + reserve_append_); @@ -230,7 +263,8 @@ namespace optimize { }; - template inline stream& operator <<(stream & out, const cache_string_one_str & val) { + template inline stream& operator <<(stream & out, + const cache_string_one_str & val) { out << val.full_string(); return out; } @@ -238,15 +272,19 @@ namespace optimize { /** - @brief This holds 3 strings - one for prepend, one for modification, and one for appending + @brief This holds 3 strings - one for prepend, one for modification, + and one for appending - When you prepend or append, you can also specify an extra argument - an identifier. + When you prepend or append, you can also specify an extra argument + - an identifier. This identifier uniquely identifies the prepended or appended message. - Afterwards, you can prepend/append only by specifying an identifier - which will identify a previously + Afterwards, you can prepend/append only by specifying an identifier + - which will identify a previously appended or prepended message */ - template struct cache_string_several_str { + template struct cache_string_several_str { private: typedef string_type_ string_type; typedef boost::shared_ptr string_ptr; @@ -254,7 +292,8 @@ namespace optimize { struct cached_msg { cached_msg() : prepended(true), id( ptr_type() ), is_new(true) {} cached_msg(const string_type & str, bool prepended_) - : msg(new string_type(str)), prepended(prepended_), id( ptr_type() ), is_new(true) {} + : msg(new string_type(str)), prepended(prepended_), id( ptr_type() ), + is_new(true) {} // when within the collection - it can never be null // when within the array - if null, use it from the collection @@ -272,23 +311,28 @@ namespace optimize { /** constructs an object - @param reserve_ [optional, default = 512] When creating the full msg, how much should we reserve? + @param reserve_ [optional, default = 512] When creating the full msg, + how much should we reserve? */ - cache_string_several_str(int reserve_ = 512) : m_full_msg_computed(false) { + cache_string_several_str(int reserve_ = 512) + : m_full_msg_computed(false) { m_full_msg.reserve(reserve_); } /** constructs an object - @param reserve_ [optional, default = 512] When creating the full msg, how much should we reserve? + @param reserve_ [optional, default = 512] When creating the full msg, + how much should we reserve? */ - cache_string_several_str(const string_type& msg, int reserve_ = 512) : m_msg(msg), m_full_msg_computed(false) { + cache_string_several_str(const string_type& msg, int reserve_ = 512) + : m_msg(msg), m_full_msg_computed(false) { m_full_msg.reserve(reserve_); } /** - sets the string with a swap (that is, you pass a non-const refererence, and we do a swap) + sets the string with a swap (that is, you pass a non-const refererence, + and we do a swap) */ void set_string_swap(string_type & msg) { std::swap(msg, m_msg); @@ -331,7 +375,8 @@ namespace optimize { */ void reuse(ptr_type id ) { // make sure you first call restart() before reusing a formatter. - // In your code - this means calling set_route(). .... .clear(), and the writing to destinations + // In your code - this means calling set_route(). .... .clear(), + // and the writing to destinations HPX_ASSERT( m_cached.find(id) != m_cached.end() ); m_cur_msg.push_back( m_cached[id] ); @@ -347,13 +392,15 @@ namespace optimize { m_full_msg_computed = true; m_full_msg.erase(); - for ( typename array::const_iterator b = m_cur_msg.begin(), e = m_cur_msg.end(); b != e; ++b) + for ( typename array::const_iterator b = m_cur_msg.begin(), + e = m_cur_msg.end(); b != e; ++b) if ( b->prepended) m_full_msg += *(b->msg); m_full_msg += m_msg; - for ( typename array::const_iterator b = m_cur_msg.begin(), e = m_cur_msg.end(); b != e; ++b) + for ( typename array::const_iterator b = m_cur_msg.begin(), + e = m_cur_msg.end(); b != e; ++b) if ( !b->prepended) m_full_msg += *(b->msg); } @@ -367,12 +414,14 @@ namespace optimize { /** - @brief This restarts writing the messages. Whatever is cached can be used again + @brief This restarts writing the messages. + Whatever is cached can be used again */ void restart() { m_full_msg_computed = false; - for ( typename array::const_iterator b = m_cur_msg.begin(), e = m_cur_msg.end(); b != e; ++b) + for ( typename array::const_iterator b = m_cur_msg.begin(), + e = m_cur_msg.end(); b != e; ++b) if ( b->is_new) m_cached[ b->id ] = *b; m_cur_msg.clear(); @@ -390,7 +439,8 @@ namespace optimize { }; template - inline stream& operator <<(stream & out, const cache_string_several_str & val) + inline stream& operator <<(stream & out, + const cache_string_several_str & val) { out << val.full_string(); return out; diff --git a/hpx/util/logging/gather/ostream_like.hpp b/hpx/util/logging/gather/ostream_like.hpp index 118b52754718..5dc5dc08b3a5 100644 --- a/hpx/util/logging/gather/ostream_like.hpp +++ b/hpx/util/logging/gather/ostream_like.hpp @@ -32,9 +32,12 @@ namespace hpx { namespace util { namespace logging { A class that implements gathering the message needs 2 things: - a function that will gather the data - called .out() -- define a function called .msg() that will return the gathered data (once all data has been gathered). +- define a function called .msg() that will return the gathered data +(once all data has been gathered). - have a public type named "msg_type" - be it a class or a typedef - - this contains what the gather_msg class returns, as non-reference, non-const (that is, msg_type != const msg_type, "msg_type&" is a not a reference-to-reference) + - this contains what the gather_msg class returns, as non-reference, + non-const (that is, msg_type != const msg_type, + "msg_type&" is a not a reference-to-reference) */ @@ -66,12 +69,16 @@ namespace optimize { namespace gather { /** - @brief In case your gather class returns anything else than a std::basic_ostream, that returned class @b must derive from this. + @brief In case your gather class returns anything else than a std::basic_ostream, + that returned class @b must derive from this. This is needed when : - - in your application, you could have messages logged before your logs are initialized - - you want filters to work even "in advance" - that is, if a message was logged before your log was initialized, - and when you initialize the log, its corresponding filter is turned on, that message will be logged. + - in your application, you could have messages logged before your logs are + initialized + - you want filters to work even "in advance" - that is, + if a message was logged before your log was initialized, + and when you initialize the log, its corresponding filter is turned on, + that message will be logged. Otherwise, it will @b not be logged. */ struct out_base { @@ -80,7 +87,8 @@ struct out_base { /** - @brief Gathering the message: Allows you to write to a log using the cool "<<" operator. + @brief Gathering the message: Allows you to write to a log using + the cool "<<" operator. The .msg() function returns the gathered message. @@ -90,7 +98,8 @@ struct out_base { namespace ostream_like { /** - @brief Allows you to write to a log using the cool "<<" operator. The @c .msg() returns the stream itself. + @brief Allows you to write to a log using the cool "<<" operator. + The @c .msg() returns the stream itself. Note that this is a very simple class - meant only as an example. @@ -101,7 +110,8 @@ namespace ostream_like { - ostream_like */ -template > struct return_raw_stream { //-V690 +template > +struct return_raw_stream { //-V690 // what does the gather_msg class return? typedef stream_type msg_type; @@ -109,7 +119,8 @@ template > struct return return_raw_stream(const return_raw_stream& other) : m_out( other.m_out.str() ) {} /** - note: we return the whole stream - we don't return out().str() , because the user might use a better ostream class, + note: we return the whole stream - we don't return out().str() , + because the user might use a better ostream class, which could have better access to its buffer/internals */ stream_type & msg() { return m_out; } @@ -122,9 +133,11 @@ template > struct return /** - @brief Allows you to write to a log using the cool "<<" operator. The .msg() returns a string - whatever you set as first template param. + @brief Allows you to write to a log using the cool "<<" operator. + The .msg() returns a string - whatever you set as first template param. - By default, it's @ref hpx::util::logging::optimize::cache_string_one_str "cache_string". + By default, it's @ref hpx::util::logging::optimize::cache_string_one_str + "cache_string". @copydoc gather_the_message @@ -133,11 +146,15 @@ template > struct return - ostream_like - @bug right now prepend_size and append_size are ignored; because we can also return a cache_string_several_str<>. When fixing, watch the find_gather class! + @bug right now prepend_size and append_size are ignored; + because we can also return a cache_string_several_str<>. + When fixing, watch the find_gather class! */ template< - class string = hpx::util::logging::optimize::cache_string_one_str , - class stream_type = std::basic_ostringstream > struct return_str { //-V690 + class string = hpx::util::logging::optimize + ::cache_string_one_str , + class stream_type = std::basic_ostringstream +> struct return_str { //-V690 // what does the gather_msg class return? typedef string msg_type; @@ -159,12 +176,14 @@ template< See @ref hpx::util::logging::tag namespace */ -template struct return_tag_holder : out_base { //-V690 +template struct return_tag_holder + : out_base { //-V690 // what does the gather_msg class return? typedef holder_type msg_type; return_tag_holder() {} - return_tag_holder(const return_tag_holder& other) : m_out(other.m_out.str()), m_val(other.m_val) {} + return_tag_holder(const return_tag_holder& other) : m_out(other.m_out.str()), + m_val(other.m_val) {} return_tag_holder & out() { return *this; } @@ -173,7 +192,8 @@ template struct return_tag_holder : out_ba return *this; } - template stream_type & operator<<(const val_type& val) { m_out << val; return m_out; } + template stream_type & operator<<(const val_type& val) + { m_out << val; return m_out; } /** @brief returns the holder */ holder_type & msg() { m_val.set_string( m_out.str() ); return m_val; } diff --git a/hpx/util/logging/logging.hpp b/hpx/util/logging/logging.hpp index cbc1110168c9..5c2eb8635999 100644 --- a/hpx/util/logging/logging.hpp +++ b/hpx/util/logging/logging.hpp @@ -38,8 +38,10 @@ namespace hpx { namespace util { namespace logging { /** @file hpx/util/logging/logging.hpp -Include this file when you're using the logging lib, but don't necessarily want to use @ref manipulator "formatters and destinations". -If you want to use @ref manipulator "formatters and destinations", then you can include this one instead: +Include this file when you're using the logging lib, but don't necessarily want to +use @ref manipulator "formatters and destinations". +If you want to use @ref manipulator "formatters and destinations", +then you can include this one instead: @code #include diff --git a/hpx/util/logging/profile.hpp b/hpx/util/logging/profile.hpp index ff0214d9e91c..e49731154408 100644 --- a/hpx/util/logging/profile.hpp +++ b/hpx/util/logging/profile.hpp @@ -46,8 +46,10 @@ namespace writer { /** @brief Allows profiling your application -If you want to profile your application (find out how much time is spent logging), all you need to do is to surround your logger and filter class(es) -by profile::compute_for_logger and with profile::compute_for_filter, like shown below: +If you want to profile your application (find out how much time is spent logging), +all you need to do is to surround your logger and filter class(es) +by profile::compute_for_logger and with profile::compute_for_filter, +like shown below: Your code: @code @@ -69,8 +71,10 @@ typedef bl::filter::no_ts raw_filter_type; typedef bl::profile::compute_for_filter::type filter_type; @endcode -In addition to the above, you'll need to set a place where to dump the profile information (which will be dumped at end of the program). -This is just a functor that takes a const std::string& argument. Thus, it can be any destination class. For instance: +In addition to the above, you'll need to set a place where to dump +the profile information (which will be dumped at end of the program). +This is just a functor that takes a const std::string& argument. +Thus, it can be any destination class. For instance: @code // where shall the profile results be outputted? @@ -117,7 +121,8 @@ struct compute { } void add_period(const ::boost::int64_t & mcs, type t) { - // note : this will work even after this object has been destroyed (since it's a global) + // note : this will work even after this object has been destroyed + // (since it's a global) m_cpu_times[t] += mcs; } @@ -135,13 +140,17 @@ struct compute { void dump_results() { std::ostringstream out; out << "gather time: " - << (m_cpu_times[gather] / 1000000) << "." << (m_cpu_times[gather] % 1000000) << " seconds " << std::endl; + << (m_cpu_times[gather] / 1000000) << "." + << (m_cpu_times[gather] % 1000000) << " seconds " << std::endl; out << "write time: " - << (m_cpu_times[writer] / 1000000) << "." << (m_cpu_times[writer] % 1000000) << " seconds " << std::endl; + << (m_cpu_times[writer] / 1000000) << "." + << (m_cpu_times[writer] % 1000000) << " seconds " << std::endl; out << "filter time: " - << (m_cpu_times[filter] / 1000000) << "." << (m_cpu_times[filter] % 1000000) << " seconds " << std::endl; + << (m_cpu_times[filter] / 1000000) << "." + << (m_cpu_times[filter] % 1000000) << " seconds " << std::endl; out << "otherthread time: " - << (m_cpu_times[on_other_thread] / 1000000) << "." << (m_cpu_times[on_other_thread] % 1000000) << " seconds " << std::endl; + << (m_cpu_times[on_other_thread] / 1000000) << "." + << (m_cpu_times[on_other_thread] % 1000000) << " seconds " << std::endl; m_log( out.str() ); } @@ -152,7 +161,8 @@ struct compute { private: // the CPU time taken for each activity // - // note: we don't use std::vector; we want this to be available even after destruction + // note: we don't use std::vector; + // we want this to be available even after destruction // (if logs are used after they've been destroyed boost::int64_t m_cpu_times[ last_ + 1]; @@ -182,7 +192,8 @@ struct scoped_compute { template struct compute_gather : gather_msg { compute_gather() : m_lk( get_compute(), compute::gather) {} - compute_gather(const compute_gather& other) : m_lk( get_compute(), compute::gather), gather_msg(other) {} + compute_gather(const compute_gather& other) : m_lk( get_compute(), compute::gather), + gather_msg(other) {} compute& get_compute() const { return compute::inst(); } private: @@ -203,7 +214,8 @@ template struct compute_write : writer_msg { write_array_impl( this); } private: - template void write_array_impl(const ::hpx::util::logging::writer::on_dedicated_thread *) const { + template void write_array_impl(const + ::hpx::util::logging::writer::on_dedicated_thread *) const { // call base class's implementation writer_msg::write_array(); } @@ -233,15 +245,19 @@ template struct compute_filter : filter_msg { scoped_compute lk( get_compute(), compute::filter ); return filter_msg::is_enabled(v1, v2); } - template bool is_enabled(const p1 & v1, const p2 &v2, const p3 & v3) const { + template bool is_enabled(const p1 & v1, const p2 &v2, + const p3 & v3) const { scoped_compute lk( get_compute(), compute::filter ); return filter_msg::is_enabled(v1, v2, v3); } - template bool is_enabled(const p1 & v1, const p2 &v2, const p3 & v3, const p4 & v4) const { + template bool is_enabled(const p1 & v1, + const p2 &v2, const p3 & v3, const p4 & v4) const { scoped_compute lk( get_compute(), compute::filter ); return filter_msg::is_enabled(v1, v2, v3, v4); } - template bool is_enabled(const p1 & v1, const p2 &v2, const p3 & v3, const p4 & v4, const p5 & v5) const { + template + bool is_enabled(const p1 & v1, const p2 &v2, const p3 & v3, + const p4 & v4, const p5 & v5) const { scoped_compute lk( get_compute(), compute::filter ); return filter_msg::is_enabled(v1, v2, v3, v4, v5); } @@ -251,20 +267,25 @@ template struct compute_filter : filter_msg { -/** @brief given the logger type, gets the write_msg part, without needing to know the logger's definition (a typedef is enough) +/** @brief given the logger type, gets the write_msg part, +without needing to know the logger's definition (a typedef is enough) */ template struct logger_to_write {}; -template struct logger_to_write< logger > { +template +struct logger_to_write< logger > { // ... the easy part typedef write_msg write_type; }; // specialize for logger_format_write -template - struct logger_to_write< logger_format_write > { +template + struct logger_to_write< logger_format_write > { - typedef typename detail::format_find_writer::type write_type; + typedef typename detail::format_find_writer::type write_type; }; diff --git a/hpx/util/logging/tag/defaults.hpp b/hpx/util/logging/tag/defaults.hpp index d115a5a816db..670c39a10cad 100644 --- a/hpx/util/logging/tag/defaults.hpp +++ b/hpx/util/logging/tag/defaults.hpp @@ -67,7 +67,8 @@ struct time { -/** @brief tag that holds module context information (note: you need to specify the module yourself) +/** @brief tag that holds module context information +(note: you need to specify the module yourself) See @ref hpx::util::logging::tag "how to use tags". */ diff --git a/hpx/util/logging/tag/high_precision_time.hpp b/hpx/util/logging/tag/high_precision_time.hpp index 6a0ba73edbb0..0305e233fb31 100644 --- a/hpx/util/logging/tag/high_precision_time.hpp +++ b/hpx/util/logging/tag/high_precision_time.hpp @@ -28,8 +28,10 @@ #include // is_generic #include // uses_tag -#include // high_precision_time_t -#include // do_convert_format +#include +// high_precision_time_t +#include +// do_convert_format namespace hpx { namespace util { namespace logging { @@ -54,24 +56,30 @@ struct high_precision_time { namespace formatter { namespace tag { -/** @brief Dumps current high_precision_time information (corresponds to hpx::util::logging::tag::high_precision_time tag class) +/** @brief Dumps current high_precision_time information +(corresponds to hpx::util::logging::tag::high_precision_time tag class) @code #include @endcode -Similar to hpx::util::logging::formatter::high_precision_time_t class - only that this one uses tags. +Similar to hpx::util::logging::formatter::high_precision_time_t class +- only that this one uses tags. See @ref hpx::util::logging::tag "how to use tags". */ -template struct high_precision_time_t : is_generic, uses_tag< high_precision_time_t, ::hpx::util::logging::tag::high_precision_time > { +template +struct high_precision_time_t : is_generic, uses_tag< high_precision_time_t, + ::hpx::util::logging::tag::high_precision_time > { typedef convert convert_type; - typedef hpx::util::logging::formatter::high_precision_time_t high_precision_time_write_type; + typedef hpx::util::logging::formatter::high_precision_time_t + high_precision_time_write_type; high_precision_time_write_type m_writer; high_precision_time_t(const hold_string_type & format) : m_writer(format) {} - template void write_tag(msg_type & str, const tag_type & tag) const { + template + void write_tag(msg_type & str, const tag_type & tag) const { m_writer.write_high_precision_time(str, tag.val); } diff --git a/hpx/util/logging/writer/named_write.hpp b/hpx/util/logging/writer/named_write.hpp index 13cce9472b2f..11fa448f59a8 100644 --- a/hpx/util/logging/writer/named_write.hpp +++ b/hpx/util/logging/writer/named_write.hpp @@ -37,13 +37,15 @@ #include namespace hpx { namespace util { namespace logging { namespace detail { typedef formatter::high_precision_time formatter_time_type ; - typedef formatter::high_precision_time_t formatter_time_type_append ; + typedef formatter::high_precision_time_t + formatter_time_type_append ; }}}} // #else // #include // namespace hpx { namespace util { namespace logging { namespace detail { // typedef formatter::time formatter_time_type ; -// typedef formatter::time_t formatter_time_type_append ; +// typedef formatter::time_t +// formatter_time_type_append ; // }}}} // #endif @@ -51,7 +53,8 @@ namespace hpx { namespace util { namespace logging { namespace detail { namespace hpx { namespace util { namespace logging { namespace writer { /** -@brief Composed of a named formatter and a named destinations. Thus, you can specify the formatting and destinations as strings +@brief Composed of a named formatter and a named destinations. +Thus, you can specify the formatting and destinations as strings @code #include @@ -61,11 +64,13 @@ namespace hpx { namespace util { namespace logging { namespace writer { Contains a very easy interface for using @ref manipulator "formatters and destinations": - at construction, specify 2 params: the %formatter string and the destinations string -Setting the @ref manipulator "formatters and destinations" to write to is extremely simple: +Setting the @ref manipulator "formatters and destinations" to +write to is extremely simple: @code // Set the formatters (first param) and destinatins (second step) in one step -g_l()->writer().write("%time%($hh:$mm.$ss.$mili) [%idx%] |\n", "cout file(out.txt) debug"); +g_l()->writer().write("%time%($hh:$mm.$ss.$mili) [%idx%] |\n", +"cout file(out.txt) debug"); // set the formatter(s) g_l()->writer().format("%time%($hh:$mm.$ss.$mili) [%idx%] |\n"); @@ -84,9 +89,11 @@ g_l()->writer().destination("cout file(out.txt) debug"); - "%time%" - writes the time (formatter::high_precision_time) - "%thread_id%" - writes the thread id (formatter::thread_id) - if you want to write @c "%", double it, like this: @c "%%" -- @c "|" is used to specify the original message. What is before it, is prepended to the message, what is after, is appended to the message +- @c "|" is used to specify the original message. What is before it, +is prepended to the message, what is after, is appended to the message - If a formatter is configurable, append @em (params) to it - - For now, only @c "%time%" is configurable. For instance, @c "%time%($hh:$mm.$ss.$mili)" writes time like @c "21:14.24.674" + - For now, only @c "%time%" is configurable. For instance, + @c "%time%($hh:$mm.$ss.$mili)" writes time like @c "21:14.24.674" Example: @code @@ -110,34 +117,41 @@ The output can look like: - Available destinations - "cout" - writes to std::cout (destination::cout) - "cerr" - writes to std::cerr (destination::cerr) - - "debug" - writes to the debug window: OutputDebugString in Windows, console on Linux (destination::dbg_window) + - "debug" - writes to the debug window: OutputDebugString in Windows, + console on Linux (destination::dbg_window) - "file" - writes to a file (destination::file) - "file2" - writes to a second file (destination::file) - "rol_file" - writes to a rolling file (destination::rolling_file) - "rol_file2" - writes to a second rolling file (destination::rolling_file) - If a destination is configurable, append @em (params) to it - Right now, @c "file", @c "file2", @c "rol_file" and @c "rol_file2" are configurable - - Append (filename) to them to specify the file name. Example: @c "file(out.txt)" will write to the out.txt file + - Append (filename) to them to specify the file name. + Example: @c "file(out.txt)" will write to the out.txt file Examples: - "file(out.txt) cout" - will write to a file called out.txt and to cout - "cout debug" - will write to cout and debug window (see above) -- "cout file(out.txt) file2(dbg.txt)" - will write to cout, and to 2 files - out.txt and dbg.txt -- "cout rol_file(r.txt)" - will write to cout and to a @ref destination::rolling_file "rolling_file" called r.txt +- "cout file(out.txt) file2(dbg.txt)" - will write to cout, and to 2 files +- out.txt and dbg.txt +- "cout rol_file(r.txt)" - will write to cout and to a +@ref destination::rolling_file "rolling_file" called r.txt @note -If you want to output to 2 files, don't use "file(one.txt) file(two.txt)". This will just configure "file" twice, ending up with writing only to "two.txt" file. +If you want to output to 2 files, don't use "file(one.txt) file(two.txt)". +This will just configure "file" twice, ending up with writing only to "two.txt" file. Use "file(one.txt) file2(two.txt)" instead! @note -At this time, named_write does not support tags. However, it's a high priority on my TODO list, so it'll be here soon! +At this time, named_write does not support tags. However, +it's a high priority on my TODO list, so it'll be here soon! @param format_write_ the underlying format writer */ template struct named_write { - typedef typename use_default< format_write_, format_write< formatter::base<> , destination::base<> > >::type format_write_type; + typedef typename use_default< format_write_, format_write< formatter::base<> , + destination::base<> > >::type format_write_type; typedef typename format_write_type::formatter_base_type formatter_base_type; typedef typename format_write_type::destination_base_type destination_base_type; @@ -153,10 +167,12 @@ template struct named_write { init(); } - /** @brief sets the format string: what should be before, and what after the original message, separated by "|" + /** @brief sets the format string: what should be before, + and what after the original message, separated by "|" Example: \n - "[%idx%] |\n" - this writes "[%idx%] " before the message, and "\n" after the message + "[%idx%] |\n" - this writes "[%idx%] " before the message, + and "\n" after the message If "|" is not present, the whole message is prepended to the message */ @@ -175,9 +191,11 @@ template struct named_write { format( before, after); }; - /** @brief sets the format strings (what should be before, and what after the original message) + /** @brief sets the format strings (what should be before, + and what after the original message) */ - void format(const string_type & format_before_str, const string_type & format_after_str) { + void format(const string_type & format_before_str, + const string_type & format_after_str) { m_format_before_str = format_before_str; m_format_after_str = format_after_str; @@ -208,18 +226,22 @@ template struct named_write { /** @brief Replaces a destination from the named destination. - You can use this, for instance, when you want to share a destination between multiple named writers. + You can use this, for instance, when you want to share a + destination between multiple named writers. */ - template void replace_destination(const string_type & name, destination d) { + template void replace_destination(const string_type & name, + destination d) { m_destination.del(name); m_destination.add(name, d); } /** @brief Replaces a formatter from the named formatter. - You can use this, for instance, when you want to share a formatter between multiple named writers. + You can use this, for instance, when you want to share + a formatter between multiple named writers. */ - template void replace_formatter(const string_type & name, formatter d) { + template void replace_formatter(const string_type & name, + formatter d) { if ( m_format_before_str.find(name) != string_type::npos) { m_format_before.del(name); } @@ -235,7 +257,8 @@ template struct named_write { m_writer.add_formatter(fmt); } - template void add_destination(const string_type & name, destination d) { + template void add_destination(const string_type & name, + destination d) { m_destination.add(name, d); } @@ -306,12 +329,15 @@ template struct named_write { }; - template void set_and_configure(manipulator & manip, const string_type & name, parser_type parser) { + template + void set_and_configure(manipulator & manip, const string_type & name, + parser_type parser) { // need to parse string bool parsing_params = false; string_type params; string_type stripped_str; - for ( typename string_type::const_iterator b = name.begin(), e = name.end(); b != e; ++b) { + for ( typename string_type::const_iterator b = name.begin(), + e = name.end(); b != e; ++b) { if ( (*b == '(') && !parsing_params) { if ( parser.has_manipulator_name() ) { parsing_params = true; @@ -343,14 +369,22 @@ template struct named_write { private: void init() { m_format_before - .add( HPX_LOG_STR("idx"), formatter::idx() ) - .add( HPX_LOG_STR("time"), ::hpx::util::logging::detail::formatter_time_type( HPX_LOG_STR("$hh:$mm:$ss") ) ) - .add( HPX_LOG_STR("thread_id"), formatter::thread_id() ); + .add( HPX_LOG_STR("idx"), + formatter::idx() ) + .add( HPX_LOG_STR("time"), + ::hpx::util::logging::detail::formatter_time_type( + HPX_LOG_STR("$hh:$mm:$ss") ) ) + .add( HPX_LOG_STR("thread_id"), + formatter::thread_id() ); m_format_after - .add( HPX_LOG_STR("idx"), formatter::idx_t() ) - .add( HPX_LOG_STR("time"), ::hpx::util::logging::detail::formatter_time_type_append( HPX_LOG_STR("$hh:$mm:$ss") ) ) - .add( HPX_LOG_STR("thread_id"), formatter::thread_id_t() ); + .add( HPX_LOG_STR("idx"), + formatter::idx_t() ) + .add( HPX_LOG_STR("time"), + ::hpx::util::logging::detail::formatter_time_type_append( + HPX_LOG_STR("$hh:$mm:$ss") ) ) + .add( HPX_LOG_STR("thread_id"), + formatter::thread_id_t() ); m_destination .add( HPX_LOG_STR("file"), destination::file("") ) @@ -363,8 +397,10 @@ template struct named_write { } private: - formatter::named_spacer_t< formatter::do_convert_format::prepend, formatter_base_type, lock_resource_type > m_format_before; - formatter::named_spacer_t< formatter::do_convert_format::append, formatter_base_type, lock_resource_type > m_format_after; + formatter::named_spacer_t< formatter::do_convert_format::prepend, + formatter_base_type, lock_resource_type > m_format_before; + formatter::named_spacer_t< formatter::do_convert_format::append, + formatter_base_type, lock_resource_type > m_format_after; destination::named_t< destination_base_type, lock_resource_type > m_destination; format_write_type m_writer; diff --git a/hpx/util/logging/writer/on_dedicated_thread.hpp b/hpx/util/logging/writer/on_dedicated_thread.hpp index 6f61e40665cf..972fb7517e96 100644 --- a/hpx/util/logging/writer/on_dedicated_thread.hpp +++ b/hpx/util/logging/writer/on_dedicated_thread.hpp @@ -37,7 +37,8 @@ namespace hpx { namespace util { namespace logging { namespace writer { namespace detail { template struct dedicated_thread_context { - dedicated_thread_context() : is_working(true), write_period_ms(100), is_paused(false), pause_acknowledged (false) {} + dedicated_thread_context() : is_working(true), write_period_ms(100), + is_paused(false), pause_acknowledged (false) {} bool is_working; int write_period_ms; @@ -63,23 +64,30 @@ namespace detail { } /** -@brief Performs all writes on a dedicated thread - very efficient and thread-safe. +@brief Performs all writes on a dedicated thread +- very efficient and thread-safe. \#include Keeps locks in the worker threads to a minimum: -whenever a message is logged, is put into a queue (this is how long the lock lasts). -Then, a dedicated thread reads the queue, and processes the messages (applying formatters and destinations if needed). +whenever a message is logged, is put into a queue +(this is how long the lock lasts). +Then, a dedicated thread reads the queue, and processes the messages +(applying formatters and destinations if needed). -@section on_dedicated_thread_logger Transforming a logger into on-dedicated-thread writer +@section on_dedicated_thread_logger Transforming a logger into +on-dedicated-thread writer -To transform a @b logger into on-dedicated-thread (thread-safe) writer, simply specify @c on_dedicated_thread as the thread safety: +To transform a @b logger into on-dedicated-thread (thread-safe) writer, +simply specify @c on_dedicated_thread as the thread safety: @code -typedef logger_format_write< default_, default_, writer::threading::on_dedicated_thread > logger_type; +typedef logger_format_write< default_, default_, +writer::threading::on_dedicated_thread > logger_type; @endcode -Of if you're using @ref hpx::util::logging::scenario::usage scenarios, specify @c speed for the @c logger::favor_ : +Of if you're using @ref hpx::util::logging::scenario::usage scenarios, +specify @c speed for the @c logger::favor_ : @code using namespace hpx::util::logging::scenario::usage; typedef use< ..., ..., ..., logger_::favor::speed> finder; @@ -90,7 +98,8 @@ typedef use< ..., ..., ..., logger_::favor::speed> finder; \n\n @section on_dedicated_thread_writer Transforming a writer into on-dedicated-thread writer -To transform a @b writer into on-dedicated-thread thread-safe writer, simply surround the writer with @c on_dedicated_thread: +To transform a @b writer into on-dedicated-thread thread-safe writer, +simply surround the writer with @c on_dedicated_thread: Example: @@ -104,20 +113,27 @@ logger< string, write_to_cout> g_l(); logger< string, on_dedicated_thread > g_l(); @endcode -You should note that a @b writer is not necessary a %logger. It can be a destination, for instance. For example, you might have a destination -where writing is time consuming, while writing to the rest of the destinations is very fast. -You can choose to write to all but that destination on the current thread, and to that destination on a dedicated thread. -(If you want to write to all destinations on a different thread, we can go back to @ref on_dedicated_thread_logger "transforming a logger...") +You should note that a @b writer is not necessary a %logger. It can be a destination, +for instance. For example, you might have a destination +where writing is time consuming, while writing to the rest of the destinations +is very fast. +You can choose to write to all but that destination on the current thread, +and to that destination on a dedicated thread. +(If you want to write to all destinations on a different thread, +we can go back to @ref on_dedicated_thread_logger "transforming a logger...") */ template struct on_dedicated_thread : base_type, - hpx::util::logging::manipulator::non_const_context > { + hpx::util::logging::manipulator::non_const_context > { typedef on_dedicated_thread self_type; typedef typename detail::dedicated_thread_context context_type; - typedef typename hpx::util::logging::manipulator::non_const_context > non_const_context_base; + typedef typename hpx::util::logging::manipulator + ::non_const_context > + non_const_context_base; typedef hpx::util::logging::threading::mutex::scoped_lock scoped_lock; @@ -154,7 +170,8 @@ struct on_dedicated_thread scoped_lock lk( non_const_context_base::context().cs); if ( !non_const_context_base::context().writer) - non_const_context_base::context().writer = thread_ptr( new boost::thread( boost::bind(&self_type::do_write,this) )); + non_const_context_base::context().writer = thread_ptr( + new boost::thread( boost::bind(&self_type::do_write,this) )); non_const_context_base::context().msgs.push_back(new_msg); } @@ -166,10 +183,13 @@ struct on_dedicated_thread non_const_context_base::context().is_paused = false; } - /** @brief Pauses the writes, so that you can manipulate the base object (the formatters/destinations, for instance) + /** @brief Pauses the writes, so that you can manipulate the base object + (the formatters/destinations, for instance) - After this function has been called, you can be @b sure that the other (dedicated) thread is not writing any messagges. - In other words, the other thread is not manipulating the base object (formatters/destinations, for instance), but you can do it. + After this function has been called, you can be @b sure that the other + (dedicated) thread is not writing any messagges. + In other words, the other thread is not manipulating the base object + (formatters/destinations, for instance), but you can do it. FIXME allow a timeout as well */ @@ -214,7 +234,8 @@ struct on_dedicated_thread scoped_lock lk( non_const_context_base::context().cs); if ( non_const_context_base::context().is_paused) - // this way we wake up early after we've been pause()d, even if sleep_ms has a high value + // this way we wake up early after we've been pause()d, + // even if sleep_ms has a high value break; } } @@ -247,7 +268,8 @@ struct on_dedicated_thread } protected: - // note: this is virtual, so that if you want to do profiling, you can (that is, you can override this as well + // note: this is virtual, so that if you want to do profiling, + // you can (that is, you can override this as well virtual void write_array() const { typedef typename context_type::array array; diff --git a/hpx/util/logging/writer/ts_write.hpp b/hpx/util/logging/writer/ts_write.hpp index e7dde92c97dd..91ce856534d4 100644 --- a/hpx/util/logging/writer/ts_write.hpp +++ b/hpx/util/logging/writer/ts_write.hpp @@ -39,7 +39,8 @@ namespace hpx { namespace util { namespace logging { namespace writer { \#include Performs all writes in a thread-safe manner. -In other words, makes sure that all operator() calls of base_type are called in a thread-safe manner. +In other words, makes sure that all operator() calls of base_type are called +in a thread-safe manner. To transform a writer into thread-safe writer, simply surround the writer with ts_write: @@ -68,8 +69,10 @@ Depending on your scenario, you could prefer on_dedicated_thread class. @sa on_dedicated_thread */ - template struct ts_write : base_type, ::hpx::util::logging::manipulator::non_const_context { - typedef ::hpx::util::logging::manipulator::non_const_context non_const_context_base; + template struct ts_write : base_type, + ::hpx::util::logging::manipulator::non_const_context { + typedef ::hpx::util::logging::manipulator::non_const_context non_const_context_base; HPX_LOGGING_FORWARD_CONSTRUCTOR(ts_write,base_type) diff --git a/hpx/util/plugin/concrete_factory.hpp b/hpx/util/plugin/concrete_factory.hpp index eae2d1663308..5d4c958768ea 100644 --- a/hpx/util/plugin/concrete_factory.hpp +++ b/hpx/util/plugin/concrete_factory.hpp @@ -46,13 +46,16 @@ namespace hpx { namespace util { namespace plugin { } }; - template - struct concrete_factory_item > + template + struct concrete_factory_item > : public Base { BasePlugin* create(dll_handle dll, A1 a1, A2 a2) { - return new plugin_wrapper >(dll, a1, a2); + return new plugin_wrapper >(dll, a1, a2); } }; } diff --git a/hpx/util/plugin/detail/dll_dlopen.hpp b/hpx/util/plugin/detail/dll_dlopen.hpp index 07d352ba7072..df4a7971e626 100644 --- a/hpx/util/plugin/detail/dll_dlopen.hpp +++ b/hpx/util/plugin/detail/dll_dlopen.hpp @@ -56,7 +56,8 @@ typedef struct HINSTANCE__* HMODULE; /////////////////////////////////////////////////////////////////////////////// #define MyFreeLibrary(x) dlclose (x) -#define MyLoadLibrary(x) reinterpret_cast(dlopen(x, RTLD_GLOBAL | RTLD_LAZY)) +#define MyLoadLibrary(x) \ + reinterpret_cast(dlopen(x, RTLD_GLOBAL | RTLD_LAZY)) #define MyGetProcAddress(x,y) dlsym (x, y) /////////////////////////////////////////////////////////////////////////////// @@ -204,7 +205,8 @@ namespace hpx { namespace util { namespace plugin { std::pair get(std::string const& symbol_name, error_code& ec = throws) const { - const_cast(*this).LoadLibrary(ec); // make sure everything is initialized + const_cast(*this).LoadLibrary(ec); + // make sure everything is initialized if (ec) return std::pair(); initialize_mutex(); @@ -330,7 +332,8 @@ namespace hpx { namespace util { namespace plugin { // If the handle is the same as what was passed in // (modulo mode bits), return this image name - if (((intptr_t)dll_handle & (-4)) == ((intptr_t)probe_handle & (-4))) + if (((intptr_t)dll_handle & (-4)) == + ((intptr_t)probe_handle & (-4))) { result = path(image_name).parent_path().string(); std::cout << "found directory: " << result << std::endl; diff --git a/hpx/util/plugin/detail/dll_windows.hpp b/hpx/util/plugin/detail/dll_windows.hpp index 55a6944f8aba..f53194d30726 100644 --- a/hpx/util/plugin/detail/dll_windows.hpp +++ b/hpx/util/plugin/detail/dll_windows.hpp @@ -130,13 +130,15 @@ namespace hpx { namespace util { namespace plugin { std::pair get(std::string const& symbol_name, error_code& ec = throws) const { - const_cast(*this).LoadLibrary(ec); // make sure everything is initialized + const_cast(*this).LoadLibrary(ec); + // make sure everything is initialized if (ec) return std::pair(); BOOST_STATIC_ASSERT(boost::is_pointer::value); // Cast the to right type. - SymbolType address = (SymbolType)GetProcAddress(dll_handle, symbol_name.c_str()); + SymbolType address = (SymbolType)GetProcAddress + (dll_handle, symbol_name.c_str()); if (NULL == address) { std::ostringstream str; @@ -209,7 +211,8 @@ namespace hpx { namespace util { namespace plugin { { char buffer[_MAX_PATH] = { '\0' }; - const_cast(*this).LoadLibrary(ec); // make sure everything is initialized + const_cast(*this).LoadLibrary(ec); + // make sure everything is initialized if (ec) return buffer; DWORD name_length = diff --git a/hpx/util/plugin/detail/plugin_factory_impl.hpp b/hpx/util/plugin/detail/plugin_factory_impl.hpp index 2dc20e630486..8ac41e6d8da2 100644 --- a/hpx/util/plugin/detail/plugin_factory_impl.hpp +++ b/hpx/util/plugin/detail/plugin_factory_impl.hpp @@ -62,7 +62,8 @@ namespace detail { BOOST_PP_ENUM_BINARY_PARAMS(N, A, a)) { std::pair *, dll_handle> r = - get_abstract_factory(this->m_dll, name, this->m_basename, ec); + get_abstract_factory + (this->m_dll, name, this->m_basename, ec); if (ec) return 0; return r.first->create(r.second, BOOST_PP_ENUM_PARAMS(N, a)); diff --git a/hpx/util/plugin/plugin_factory.hpp b/hpx/util/plugin/plugin_factory.hpp index e3725edc31d7..2090ee764dc7 100644 --- a/hpx/util/plugin/plugin_factory.hpp +++ b/hpx/util/plugin/plugin_factory.hpp @@ -36,7 +36,8 @@ namespace hpx { namespace util { namespace plugin { std::string const &class_name, std::string const& libname = "", error_code& ec = throws) { - typedef typename boost::remove_pointer::type PointedType; + typedef typename boost::remove_pointer + ::type PointedType; exported_plugins_type& e = *f(); std::string clsname(class_name); @@ -45,7 +46,8 @@ namespace hpx { namespace util { namespace plugin { typename exported_plugins_type::iterator it = e.find(clsname); if (it != e.end()) { abstract_factory** xw = - boost::unsafe_any_cast *>(&(*it).second); + boost::unsafe_any_cast *> + (&(*it).second); if (!xw) { HPX_THROWS_IF(ec, filesystem_error, @@ -155,7 +157,8 @@ namespace hpx { namespace util { namespace plugin { void create(int******) const; - void get_names(std::vector& names, error_code& ec = throws) const + void get_names(std::vector& names, + error_code& ec = throws) const { get_abstract_factory_names(this->m_dll, this->m_basename, names, ec); } @@ -180,7 +183,8 @@ namespace hpx { namespace util { namespace plugin { BasePlugin* create(std::string const& name, error_code& ec = throws) const { std::pair *, dll_handle> r = - get_abstract_factory(this->m_dll, name, this->m_basename, ec); + get_abstract_factory(this->m_dll, name, + this->m_basename, ec); if (ec) return 0; return r.first->create(r.second); @@ -199,14 +203,16 @@ namespace hpx { namespace util { namespace plugin { BasePlugin* create(std::string const& name, A1 a1) const { std::pair *, dll_handle> r = - get_abstract_factory(this->m_dll, name, this->m_basename); + get_abstract_factory(this->m_dll, name, + this->m_basename); return r.first->create(r.second, a1); } BasePlugin* create(std::string const& name, error_code& ec, A1 a1) const { std::pair *, dll_handle> r = - get_abstract_factory(this->m_dll, name, this->m_basename, ec); + get_abstract_factory(this->m_dll, name, + this->m_basename, ec); if (ec) return 0; return r.first->create(r.second, a1); @@ -225,14 +231,17 @@ namespace hpx { namespace util { namespace plugin { BasePlugin* create(std::string const& name, A1 a1, A2 a2) const { std::pair *, dll_handle> r = - get_abstract_factory(this->m_dll, name, this->m_basename); + get_abstract_factory(this->m_dll, name, + this->m_basename); return r.first->create(r.second, a1, a2); } - BasePlugin* create(std::string const& name, error_code& ec, A1 a1, A2 a2) const + BasePlugin* create(std::string const& name, error_code& ec, + A1 a1, A2 a2) const { std::pair *, dll_handle> r = - get_abstract_factory(this->m_dll, name, this->m_basename, ec); + get_abstract_factory(this->m_dll, name, + this->m_basename, ec); if (ec) return 0; return r.first->create(r.second, a1, a2); @@ -253,7 +262,8 @@ namespace hpx { namespace util { namespace plugin { void create(int******) const; - void get_names(std::vector& names, error_code& ec = throws) const + void get_names(std::vector& names, + error_code& ec = throws) const { get_abstract_factory_names_static(f, names, ec); } @@ -330,7 +340,8 @@ namespace hpx { namespace util { namespace plugin { return r.first->create(r.second, a1, a2); } - BasePlugin* create(std::string const& name, error_code& ec, A1 a1, A2 a2) const + BasePlugin* create(std::string const& name, + error_code& ec, A1 a1, A2 a2) const { std::pair *, dll_handle> r = get_abstract_factory_static( diff --git a/hpx/util/safe_lexical_cast.hpp b/hpx/util/safe_lexical_cast.hpp index e03f2caafd98..43f74bf7d1c3 100644 --- a/hpx/util/safe_lexical_cast.hpp +++ b/hpx/util/safe_lexical_cast.hpp @@ -35,9 +35,11 @@ namespace hpx { namespace util } template - DestType get_entry_as(const Config& config, const std::string& key, const std::string& dflt) + DestType get_entry_as(const Config& config, const std::string& key, + const std::string& dflt) { - return safe_lexical_cast(config.get_entry(key, dflt), safe_lexical_cast(dflt)); + return safe_lexical_cast(config.get_entry(key, dflt), + safe_lexical_cast(dflt)); } }} diff --git a/hpx/util/unique_function.hpp b/hpx/util/unique_function.hpp index 7dfe29c75cce..37dedf74e142 100644 --- a/hpx/util/unique_function.hpp +++ b/hpx/util/unique_function.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -21,10 +22,12 @@ /////////////////////////////////////////////////////////////////////////////// #define HPX_CONTINUATION_REGISTER_UNIQUE_FUNCTION_FACTORY(VTable, Name) \ static ::hpx::util::detail::function_registration< \ - VTable::first_type, VTable::second_type \ + ::hpx::util::tuple_element<0, VTable>::type \ + , ::hpx::util::tuple_element<1, VTable>::type \ > const BOOST_PP_CAT(Name, _unique_function_factory_registration) = \ ::hpx::util::detail::function_registration< \ - VTable::first_type, VTable::second_type \ + ::hpx::util::tuple_element<0, VTable>::type \ + , ::hpx::util::tuple_element<1, VTable>::type \ >(); \ /**/ @@ -38,7 +41,7 @@ #define HPX_UTIL_REGISTER_UNIQUE_FUNCTION_DECLARATION(Sig, Functor, Name) \ namespace hpx { namespace util { namespace detail { \ typedef \ - std::pair< \ + hpx::util::tuple< \ unique_function_vtable_ptr< \ Sig \ , serialization::input_archive \ diff --git a/hpx/util/unwrapped.hpp b/hpx/util/unwrapped.hpp index 3e678dbb319f..f6eefc8555f4 100644 --- a/hpx/util/unwrapped.hpp +++ b/hpx/util/unwrapped.hpp @@ -268,6 +268,26 @@ namespace hpx { namespace util : f_(std::move(f)) {} + unwrapped_impl(unwrapped_impl && other) + : f_(std::move(other.f_)) + {} + + unwrapped_impl(unwrapped_impl const & other) + : f_(other.f_) + {} + + unwrapped_impl &operator=(unwrapped_impl && other) + { + f_ = std::move(other.f_); + return *this; + } + + unwrapped_impl &operator=(unwrapped_impl const & other) + { + f_ = other.f_; + return *this; + } + template struct result; diff --git a/hpx/util/zip_iterator.hpp b/hpx/util/zip_iterator.hpp index 69278a130ddc..89b0e9b685e3 100644 --- a/hpx/util/zip_iterator.hpp +++ b/hpx/util/zip_iterator.hpp @@ -604,7 +604,8 @@ namespace hpx { namespace traits util::zip_iterator, typename std::enable_if< util::detail::all_of< - typename segmented_local_iterator_traits::is_segmented_local_iterator... + typename segmented_local_iterator_traits + ::is_segmented_local_iterator... >::value >::type> { diff --git a/plugins/parcelport/ibverbs/connection_handler_ibverbs.cpp b/plugins/parcelport/ibverbs/connection_handler_ibverbs.cpp index 359fda82de4d..018692e88df0 100644 --- a/plugins/parcelport/ibverbs/connection_handler_ibverbs.cpp +++ b/plugins/parcelport/ibverbs/connection_handler_ibverbs.cpp @@ -123,16 +123,20 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs ); } - std::size_t connection_handler::memory_chunk_size(util::runtime_configuration const& ini) + std::size_t connection_handler + ::memory_chunk_size(util::runtime_configuration const& ini) { return hpx::util::get_entry_as( - ini, "hpx.parcel.ibverbs.memory_chunk_size", HPX_HAVE_PARCELPORT_IBVERBS_MEMORY_CHUNK_SIZE); + ini, "hpx.parcel.ibverbs.memory_chunk_size", + HPX_HAVE_PARCELPORT_IBVERBS_MEMORY_CHUNK_SIZE); } - std::size_t connection_handler::max_memory_chunks(util::runtime_configuration const& ini) + std::size_t connection_handler + ::max_memory_chunks(util::runtime_configuration const& ini) { return hpx::util::get_entry_as( - ini, "hpx.parcel.ibverbs.max_memory_chunks", HPX_HAVE_PARCELPORT_IBVERBS_MAX_MEMORY_CHUNKS); + ini, "hpx.parcel.ibverbs.max_memory_chunks", + HPX_HAVE_PARCELPORT_IBVERBS_MAX_MEMORY_CHUNKS); } connection_handler::connection_handler(util::runtime_configuration const& ini, @@ -194,7 +198,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs exception_list errors; util::endpoint_iterator_type end = util::accept_end(); for (util::endpoint_iterator_type it = - util::accept_begin(here_.get(), io_service_pool_.get_io_service(0)); + util::accept_begin(here_.get(), + io_service_pool_.get_io_service(0)); it != end; ++it, ++tried) { try { @@ -278,7 +283,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs parcelset::locality const& l, error_code& ec) { boost::asio::io_service& io_service = io_service_pool_.get_io_service(0); - boost::shared_ptr sender_connection(new sender(*this, memory_pool_, l, parcels_sent_)); + boost::shared_ptr sender_connection(new sender(*this, memory_pool_, + l, parcels_sent_)); // Connect to the target locality, retry if needed boost::system::error_code error = boost::asio::error::try_again; @@ -368,7 +374,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs handler.add_sender(sender_connection); } - ibv_pd *connection_handler::get_pd(ibv_context *context, boost::system::error_code & ec) + ibv_pd *connection_handler::get_pd(ibv_context *context, + boost::system::error_code & ec) { boost::lock_guard l(pd_map_mtx_); typedef pd_map_type::iterator iterator; @@ -458,7 +465,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ibverbs hpx::util::high_resolution_timer t; // We let the message handling loop spin for another 2 seconds to avoid the // costs involved with posting it to asio - while(bootstrapping || (!stopped_ && has_work) || (!has_work && t.elapsed() < 2.0)) + while(bootstrapping || (!stopped_ && has_work) + || (!has_work && t.elapsed() < 2.0)) { // handle all sends ... has_work = do_sends(); diff --git a/plugins/parcelport/ibverbs/parcelport_ibverbs.cpp b/plugins/parcelport/ibverbs/parcelport_ibverbs.cpp index be30300b55ae..a6428ecba583 100644 --- a/plugins/parcelport/ibverbs/parcelport_ibverbs.cpp +++ b/plugins/parcelport/ibverbs/parcelport_ibverbs.cpp @@ -34,11 +34,14 @@ namespace hpx { namespace traits static char const* call() { return - "ifname = ${HPX_HAVE_PARCEL_IBVERBS_IFNAME:" HPX_HAVE_PARCELPORT_IBVERBS_IFNAME "}\n" + "ifname = ${HPX_HAVE_PARCEL_IBVERBS_IFNAME:" + HPX_HAVE_PARCELPORT_IBVERBS_IFNAME "}\n" "memory_chunk_size = ${HPX_HAVE_PARCEL_IBVERBS_MEMORY_CHUNK_SIZE:" - BOOST_PP_STRINGIZE(HPX_HAVE_PARCELPORT_IBVERBS_MEMORY_CHUNK_SIZE) "}\n" + BOOST_PP_STRINGIZE(HPX_HAVE_PARCELPORT_IBVERBS_MEMORY_CHUNK_SIZE) + "}\n" "max_memory_chunks = ${HPX_HAVE_PARCEL_IBVERBS_MAX_MEMORY_CHUNKS:" - BOOST_PP_STRINGIZE(HPX_HAVE_PARCELPORT_IBVERBS_MAX_MEMORY_CHUNKS) "}\n" + BOOST_PP_STRINGIZE(HPX_HAVE_PARCELPORT_IBVERBS_MAX_MEMORY_CHUNKS) + "}\n" "zero_copy_optimization = 0\n" "io_pool_size = 2\n" "use_io_pool = 1\n" diff --git a/plugins/parcelport/ipc/connection_handler_ipc.cpp b/plugins/parcelport/ipc/connection_handler_ipc.cpp index be6fddc66a68..fc2222aa059c 100644 --- a/plugins/parcelport/ipc/connection_handler_ipc.cpp +++ b/plugins/parcelport/ipc/connection_handler_ipc.cpp @@ -81,7 +81,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ipc } } - bool connection_handler::can_connect(parcelset::locality const & dest, bool use_alternative) + bool connection_handler::can_connect(parcelset::locality const & dest, + bool use_alternative) { if(use_alternative) { @@ -100,7 +101,8 @@ namespace hpx { namespace parcelset { namespace policies { namespace ipc exception_list errors; util::endpoint_iterator_type end = util::accept_end(); for (util::endpoint_iterator_type it = - util::accept_begin(here_.get(), io_service_pool_.get_io_service(0)); + util::accept_begin(here_.get(), + io_service_pool_.get_io_service(0)); it != end; ++it, ++tried) { try { diff --git a/plugins/parcelport/mpi/parcelport_mpi.cpp b/plugins/parcelport/mpi/parcelport_mpi.cpp index b0f25e06ae48..a1089846f60e 100644 --- a/plugins/parcelport/mpi/parcelport_mpi.cpp +++ b/plugins/parcelport/mpi/parcelport_mpi.cpp @@ -5,6 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #if defined(HPX_HAVE_PARCELPORT_MPI) #include @@ -18,9 +19,8 @@ // parcelport #include -#include -#include -#include +#include +#include #include #include @@ -41,334 +41,254 @@ namespace hpx bool is_starting(); } -namespace hpx { namespace parcelset { namespace policies { namespace mpi +namespace hpx { namespace parcelset { - class parcelport - : public parcelset::parcelport + namespace policies { namespace mpi { - private: - static parcelset::locality here() - { - return - parcelset::locality( - locality( - util::mpi_environment::rank() - ) - ); - } - - static std::size_t max_connections(util::runtime_configuration const& ini) - { - return hpx::util::get_entry_as( - ini, "hpx.parcel.mpi.max_connections", HPX_PARCEL_MAX_CONNECTIONS); - } - public: - parcelport(util::runtime_configuration const& ini, - util::function_nonser const& on_start_thread, - util::function_nonser const& on_stop_thread) - : parcelset::parcelport(ini, here(), "mpi") - , archive_flags_(boost::archive::no_header) - , stopped_(false) - , bootstrapping_(true) - , max_connections_(max_connections(ini)) - , chunk_pool_(4096, max_connections_) - , sender_(max_connections_) - , receiver_(*this, chunk_pool_, max_connections_) - , enable_parcel_handling_(true) - , handles_parcels_(0) - { -#ifdef BOOST_BIG_ENDIAN - std::string endian_out = get_config_entry("hpx.parcel.endian_out", "big"); -#else - std::string endian_out = get_config_entry("hpx.parcel.endian_out", "little"); -#endif - if (endian_out == "little") - archive_flags_ |= serialization::endian_little; - else if (endian_out == "big") - archive_flags_ |= serialization::endian_big; - else { - HPX_ASSERT(endian_out =="little" || endian_out == "big"); - } + class HPX_EXPORT parcelport; + }} - if (!this->allow_array_optimizations()) { - archive_flags_ |= serialization::disable_array_optimization; - archive_flags_ |= serialization::disable_data_chunking; - } - else { - if (!this->allow_zero_copy_optimizations()) - archive_flags_ |= serialization::disable_data_chunking; - } - } + template <> + struct connection_handler_traits + { + typedef policies::mpi::sender_connection connection_type; + typedef boost::mpl::true_ send_early_parcel; + typedef boost::mpl::true_ do_background_work; + typedef boost::mpl::true_ do_enable_parcel_handling; - ~parcelport() + static const char * type() { - if(receive_early_parcels_thread_.joinable()) - receive_early_parcels_thread_.join(); - util::mpi_environment::finalize(); + return "mpi"; } - bool can_bootstrap() const + static const char * pool_name() { - return true; + return "parcel-pool-mpi"; } - /// Return the name of this locality - std::string get_locality_name() const + static const char * pool_name_postfix() { - return util::mpi_environment::get_processor_name(); + return "-mpi"; } + }; - parcelset::locality - agas_locality(util::runtime_configuration const & ini) const + namespace policies { namespace mpi + { + int acquire_tag(sender * s) { - return - parcelset::locality( - locality( - util::mpi_environment::enabled() ? 0 : -1 - ) - ); + return s->acquire_tag(); } - parcelset::locality create_locality() const + void add_connection(sender * s, boost::shared_ptr const &ptr) { - return parcelset::locality(locality()); + s->add(ptr); } - void put_parcels(std::vector dests, - std::vector parcels, - std::vector handlers) + class HPX_EXPORT parcelport + : public parcelport_impl { - HPX_ASSERT(dests.size() == parcels.size()); - HPX_ASSERT(dests.size() == handlers.size()); - for(std::size_t i = 0; i != dests.size(); ++i) + typedef parcelport_impl base_type; + + static parcelset::locality here() { - put_parcel(dests[i], std::move(parcels[i]), std::move(handlers[i])); + return + parcelset::locality( + locality( + util::mpi_environment::rank() + ) + ); } - } - - void send_early_parcel(parcelset::locality const & dest, parcel p) - { - put_parcel(dest, std::move(p) - , util::bind( - &parcelport::early_write_handler - , this - , util::placeholders::_1 - , util::placeholders::_2 - ) - ); - } - util::io_service_pool* get_thread_pool(char const* name) - { - return 0; - } - - // This parcelport doesn't maintain a connection cache - boost::int64_t get_connection_cache_statistics( - connection_cache_statistics_type, bool reset) - { - return 0; - } - - void remove_from_connection_cache(parcelset::locality const& loc) - {} - - bool run(bool blocking = true) - { - receiver_.run(); - sender_.run(); - receive_early_parcels_thread_ = - boost::thread(&parcelport::receive_early_parcels, this, - hpx::get_runtime_ptr()); - return true; - } - - void stop(bool blocking = true) - { - stopped_ = true; - while(handles_parcels_ != 0) + static std::size_t max_connections(util::runtime_configuration const& ini) { - if(threads::get_self_ptr()) - hpx::this_thread::suspend(hpx::threads::pending, - "mpi::parcelport::enable"); + return hpx::util::get_entry_as( + ini, "hpx.parcel.mpi.max_connections", HPX_PARCEL_MAX_CONNECTIONS); } - if(blocking) + public: + parcelport(util::runtime_configuration const& ini, + util::function_nonser const& on_start, + util::function_nonser const& on_stop) + : base_type(ini, here(), on_start, on_stop) + , stopped_(false) + , chunk_pool_(4096, max_connections(ini)) + , sender_(chunk_pool_) + , receiver_(*this, chunk_pool_) + , handles_parcels_(0) + {} + + ~parcelport() { - MPI_Barrier(util::mpi_environment::communicator()); + if(receive_early_parcels_thread_.joinable()) + receive_early_parcels_thread_.join(); + util::mpi_environment::finalize(); } - } - void enable(bool new_state) - { - enable_parcel_handling_ = new_state; - if(!new_state) + /// Start the handling of connections. + bool do_run() + { + receiver_.run(); + sender_.run(); + receive_early_parcels_thread_ = + boost::thread(&parcelport::receive_early_parcels, this, + hpx::get_runtime_ptr()); + return true; + } + + /// Stop the handling of connectons. + void do_stop() { + while(do_background_work(0)) + { + if(threads::get_self_ptr()) + hpx::this_thread::suspend(hpx::threads::pending, + "mpi::parcelport::do_stop"); + } + stopped_ = true; while(handles_parcels_ != 0) { if(threads::get_self_ptr()) hpx::this_thread::suspend(hpx::threads::pending, - "mpi::parcelport::enable"); + "mpi::parcelport::do_stop"); } + MPI_Barrier(util::mpi_environment::communicator()); } - } - void put_parcel(parcelset::locality const & dest, parcel p, - write_handler_type f) - { - if(hpx::is_running()) + void enable_parcel_handling(bool new_state) { - std::size_t thread_num = get_worker_thread_num(); - hpx::applier::register_thread_nullary( - util::bind( - util::one_shot(&parcelport::put_parcel_async) - , this - , dest - , std::move(p) - , std::move(f) - ) - , "mpi::parcelport::put_parcel" - , threads::pending, true, threads::thread_priority_boost, - thread_num, threads::thread_stacksize_default - ); + if(!new_state) + { + while(handles_parcels_ != 0) + { + if(threads::get_self_ptr()) + hpx::this_thread::suspend(hpx::threads::pending, + "mpi::parcelport::enable"); + } + } } - else + + /// Return the name of this locality + std::string get_locality_name() const { - put_parcel_async(dest, std::move(p), f); + return util::mpi_environment::get_processor_name(); } - } - void put_parcel_async(parcelset::locality const & dest, parcel p, - write_handler_type f) - { - while(!enable_parcel_handling_) + boost::shared_ptr create_connection( + parcelset::locality const& l, error_code& ec) { - if(threads::get_self_ptr()) - hpx::this_thread::suspend(hpx::threads::pending, - "mpi::parcelport::put_parcel"); + int dest_rank = l.get().rank(); + return sender_.create_connection( + dest_rank, enable_parcel_handling_, parcels_sent_); } - { - handles_parcels h(this); - - allocator_type alloc(chunk_pool_); - snd_buffer_type buffer(alloc); - encode_parcels(&p, std::size_t(-1), buffer, archive_flags_, - this->get_max_outbound_message_size()); - - buffer.data_point_.time_ = util::high_resolution_clock::now(); - - int dest_rank = dest.get().rank(); - HPX_ASSERT(dest_rank != util::mpi_environment::rank()); - - sender_.send( - dest_rank - , std::move(p) - , std::move(f) - , std::move(buffer) - , parcels_sent_ - ); - std::size_t num_thread(0); - if(threads::get_self_ptr()) - num_thread = hpx::get_worker_thread_num(); + parcelset::locality agas_locality( + util::runtime_configuration const & ini) const + { + return + parcelset::locality( + locality( + util::mpi_environment::enabled() ? 0 : -1 + ) + ); + } - do_background_work(num_thread); + parcelset::locality create_locality() const + { + return parcelset::locality(locality()); } - } - bool do_background_work(std::size_t num_thread) - { - if (stopped_) - return false; - handles_parcels h(this); + bool background_work(std::size_t num_thread) + { + if (stopped_) + return false; - if(!enable_parcel_handling_) - return false; + handles_parcels h(this); - bool has_work = sender_.background_work(num_thread); - has_work = receiver_.background_work(num_thread) || has_work; - return has_work; - } + if(!enable_parcel_handling_) + return false; - private: - typedef util::memory_chunk_pool<> memory_pool_type; - typedef util::detail::memory_chunk_pool_allocator> allocator_type; - typedef - std::vector - data_type; - typedef parcel_buffer snd_buffer_type; - typedef parcel_buffer rcv_buffer_type; - typedef lcos::local::spinlock mutex_type; + bool has_work = sender_.background_work(num_thread); + has_work = receiver_.background_work(num_thread) || has_work; + return has_work; + } - int archive_flags_; + private: + typedef util::memory_chunk_pool<> memory_pool_type; + typedef + util::detail::memory_chunk_pool_allocator< + char, util::memory_chunk_pool<> + > allocator_type; + typedef + std::vector + data_type; + typedef lcos::local::spinlock mutex_type; - boost::atomic stopped_; - boost::atomic bootstrapping_; - std::size_t const max_connections_; + boost::atomic stopped_; - memory_pool_type chunk_pool_; + memory_pool_type chunk_pool_; - mutex_type connections_mtx_; - lcos::local::detail::condition_variable connections_cond_; - sender sender_; - receiver receiver_; + sender sender_; + receiver receiver_; - boost::thread receive_early_parcels_thread_; + boost::thread receive_early_parcels_thread_; - boost::atomic enable_parcel_handling_; - boost::atomic handles_parcels_; + boost::atomic handles_parcels_; - struct handles_parcels - { - handles_parcels(parcelport *pp) - : this_(pp) + struct handles_parcels { - ++this_->handles_parcels_; - } + handles_parcels(parcelport *pp) + : this_(pp) + { + ++this_->handles_parcels_; + } - ~handles_parcels() - { - --this_->handles_parcels_; - } + ~handles_parcels() + { + --this_->handles_parcels_; + } - parcelport *this_; - }; + parcelport *this_; + }; - void receive_early_parcels(hpx::runtime * rt) - { - rt->register_thread("receive_early_parcel"); - try + void receive_early_parcels(hpx::runtime * rt) { - while(rt->get_state() <= state_startup) + rt->register_thread("receive_early_parcel"); + try { - do_background_work(0); + while(rt->get_state() <= state_startup) + { + do_background_work(0); + } + } + catch(...) + { + rt->unregister_thread(); + throw; } - } - catch(...) - { rt->unregister_thread(); - throw; } - rt->unregister_thread(); - } - void early_write_handler( - boost::system::error_code const& ec, parcel const & p) - { - if (ec) { - // all errors during early parcel handling are fatal - boost::exception_ptr exception = - hpx::detail::get_exception(hpx::exception(ec), - "mpi::early_write_handler", __FILE__, __LINE__, - "error while handling early parcel: " + - ec.message() + "(" + - boost::lexical_cast(ec.value()) + - ")" + parcelset::dump_parcel(p)); - - hpx::report_error(exception); + void early_write_handler( + boost::system::error_code const& ec, parcel const & p) + { + if (ec) { + // all errors during early parcel handling are fatal + boost::exception_ptr exception = + hpx::detail::get_exception(hpx::exception(ec), + "mpi::early_write_handler", __FILE__, __LINE__, + "error while handling early parcel: " + + ec.message() + "(" + + boost::lexical_cast(ec.value()) + + ")" + parcelset::dump_parcel(p)); + + hpx::report_error(exception); + } } - } - }; -}}}} + + }; + }} +}} + +#include namespace hpx { namespace traits { diff --git a/src/components/papi_counters/papi_startup.cpp b/src/components/papi_counters/papi_startup.cpp index 3ac30990ffae..703bdea87590 100644 --- a/src/components/papi_counters/papi_startup.cpp +++ b/src/components/papi_counters/papi_startup.cpp @@ -197,7 +197,8 @@ namespace hpx { namespace performance_counters { namespace papi !p.countername_.empty()) { // validate specific PAPI event int code; - if (PAPI_event_name_to_code(const_cast(p.countername_.c_str()), &code) != PAPI_OK) + if (PAPI_event_name_to_code(const_cast + (p.countername_.c_str()), &code) != PAPI_OK) return false; hpx::performance_counters::counter_status status = get_counter_name(p, cnt_info.fullname_, ec); diff --git a/src/components/security/server/root_certificate_authority_server.cpp b/src/components/security/server/root_certificate_authority_server.cpp index 2ae5c2ccc31f..e6ee6918c46c 100644 --- a/src/components/security/server/root_certificate_authority_server.cpp +++ b/src/components/security/server/root_certificate_authority_server.cpp @@ -67,7 +67,8 @@ namespace hpx { namespace components { namespace security { namespace server hpx::security_error , "subordinate_certificate_authority::sign_certificate_signing_request" , boost::str(boost::format( - "The certificate signing request its capabilities can't be delegated: %1% %2%") % + "The certificate signing request its capabilities can't be\ + delegated: %1% %2%") % issuer_capability % csr.get_capability()) ) } diff --git a/src/components/security/server/subordinate_certificate_authority_server.cpp b/src/components/security/server/subordinate_certificate_authority_server.cpp index 1cf63951b430..33192b558cc3 100644 --- a/src/components/security/server/subordinate_certificate_authority_server.cpp +++ b/src/components/security/server/subordinate_certificate_authority_server.cpp @@ -96,7 +96,8 @@ namespace hpx { namespace components { namespace security { namespace server hpx::security_error , "subordinate_certificate_authority::sign_certificate_signing_request" , boost::str(boost::format( - "The certificate signing request its capabilities can't be delegated: %1% %2%") % + "The certificate signing request its capabilities can't be\ + delegated: %1% %2%") % issuer_capability % csr.get_capability()) ) } diff --git a/src/exception.cpp b/src/exception.cpp index db1ce25f3fc1..43d218812384 100644 --- a/src/exception.cpp +++ b/src/exception.cpp @@ -86,7 +86,8 @@ namespace hpx { namespace detail std::size_t len = get_arraylen(_environ); env.reserve(len); std::copy(&_environ[0], &_environ[len], std::back_inserter(env)); -#elif defined(linux) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__AIX__) +#elif defined(linux) || defined(__linux) || defined(__linux__) \ + || defined(__FreeBSD__) || defined(__AIX__) std::size_t len = get_arraylen(environ); env.reserve(len); std::copy(&environ[0], &environ[len], std::back_inserter(env)); diff --git a/src/hpx_init.cpp b/src/hpx_init.cpp index a0781c083d14..41b66365c6ad 100644 --- a/src/hpx_init.cpp +++ b/src/hpx_init.cpp @@ -650,7 +650,8 @@ namespace hpx /////////////////////////////////////////////////////////////////////// int run(hpx::runtime& rt, - util::function_nonser const& f, + util::function_nonser + const& f, boost::program_options::variables_map& vm, runtime_mode mode, startup_function_type const& startup, shutdown_function_type const& shutdown) @@ -666,7 +667,8 @@ namespace hpx } int start(hpx::runtime& rt, - util::function_nonser const& f, + util::function_nonser + const& f, boost::program_options::variables_map& vm, runtime_mode mode, startup_function_type const& startup, shutdown_function_type const& shutdown) @@ -738,6 +740,112 @@ namespace hpx #endif } + /////////////////////////////////////////////////////////////////////// + // local scheduler (one queue for each OS threads) + int run_throttle(startup_function_type const& startup, + shutdown_function_type const& shutdown, + util::command_line_handling& cfg, bool blocking) + { +#if defined(HPX_HAVE_THROTTLE_SCHEDULER) + ensure_high_priority_compatibility(cfg.vm_); + ensure_hierarchy_arity_compatibility(cfg.vm_); + + bool numa_sensitive = false; + if (cfg.vm_.count("hpx:numa-sensitive")) + numa_sensitive = true; + + std::size_t pu_offset = std::size_t(-1); + std::size_t pu_step = 1; + std::string affinity_domain("pu"); + std::string affinity_desc; + +#if defined(HPX_HAVE_HWLOC) || defined(BOOST_WINDOWS) + if (cfg.vm_.count("hpx:pu-offset")) { + pu_offset = cfg.vm_["hpx:pu-offset"].as(); + if (pu_offset >= hpx::threads::hardware_concurrency()) { + throw std::logic_error("Invalid command line option " + "--hpx:pu-offset, value must be smaller than number of " + "available processing units."); + } + } + + if (cfg.vm_.count("hpx:pu-step")) { + pu_step = cfg.vm_["hpx:pu-step"].as(); + if (pu_step == 0 || pu_step >= hpx::threads::hardware_concurrency()) { + throw std::logic_error("Invalid command line option " + "--hpx:pu-step, value must be non-zero smaller than number of " + "available processing units."); + } + } +#endif +#if defined(HPX_HAVE_HWLOC) + if (cfg.vm_.count("hpx:affinity")) { + affinity_domain = cfg.vm_["hpx:affinity"].as(); + if (0 != std::string("pu").find(affinity_domain) && + 0 != std::string("core").find(affinity_domain) && + 0 != std::string("numa").find(affinity_domain) && + 0 != std::string("machine").find(affinity_domain)) + { + throw std::logic_error("Invalid command line option " + "--hpx:affinity, value must be one of: pu, core, numa, " + "or machine."); + } + } + if (cfg.vm_.count("hpx:bind")) { + if (cfg.vm_.count("hpx:pu-offset") || + cfg.vm_.count("hpx:pu-step") || + cfg.vm_.count("hpx:affinity")) + { + throw std::logic_error("Command line option --hpx:bind " + "should not be used with --hpx:pu-step, --hpx:pu-offset, " + "or --hpx:affinity."); + } + + std::vector bind_affinity = + cfg.vm_["hpx:bind"].as >(); + for(std::string const& s: bind_affinity) + { + if (!affinity_desc.empty()) + affinity_desc += ";"; + affinity_desc += s; + } + + numa_sensitive = true; + } +#endif + + // scheduling policy + typedef hpx::threads::policies::throttle_queue_scheduler<> + throttle_queue_policy; + throttle_queue_policy::init_parameter_type init( + cfg.num_threads_, 1000, numa_sensitive); + threads::policies::init_affinity_data affinity_init( + pu_offset, pu_step, affinity_domain, affinity_desc); + + // Build and configure this runtime instance. + typedef hpx::runtime_impl runtime_type; + std::unique_ptr rt( + new runtime_type(cfg.rtcfg_, cfg.mode_, cfg.num_threads_, init, + affinity_init)); + + if (blocking) { + return run(*rt, cfg.hpx_main_f_, cfg.vm_, cfg.mode_, startup, + shutdown); + } + + // non-blocking version + start(*rt, cfg.hpx_main_f_, cfg.vm_, cfg.mode_, startup, shutdown); + + rt.release(); // pointer to runtime is stored in TLS + return 0; +#else + throw detail::command_line_error("Command line option " + "--hpx:queuing=throttle " + "is not configured in this build. Please rebuild with " + "'cmake -DHPX_THREAD_SCHEDULERS=throttle'."); +#endif + } + /////////////////////////////////////////////////////////////////////// // local static scheduler with priority queue (one queue for each OS // threads plus one separate queue for high priority HPX-threads). Doesn't @@ -969,7 +1077,8 @@ namespace hpx /////////////////////////////////////////////////////////////////////// HPX_EXPORT int run_or_start( - util::function_nonser const& f, + util::function_nonser + const& f, boost::program_options::options_description const& desc_cmdline, int argc, char** argv, std::vector const& ini_config, startup_function_type const& startup, @@ -997,6 +1106,14 @@ namespace hpx #endif try { + // make sure the runtime system is not active yet + if (get_runtime_ptr() != 0) + { + std::cerr << "hpx::init: can't initialize runtime system " + "more than once! Exiting...\n"; + return -1; + } + // handle all common command line switches util::command_line_handling cfg(mode, f, ini_config, argv[0]); @@ -1054,17 +1171,23 @@ namespace hpx cfg.queuing_ = "periodic-priority"; result = run_periodic(startup, shutdown, cfg, blocking); } - else - { + else if (0 == std::string("throttle").find(cfg.queuing_)) { + cfg.queuing_ = "throttle"; + result = run_throttle(startup, shutdown, cfg, blocking); + } + else { throw detail::command_line_error( "Bad value for command line option --hpx:queuing"); } } catch (detail::command_line_error const& e) { std::cerr << "{env}: " << hpx::detail::get_execution_environment(); - std::cerr << "hpx::init: std::exception caught: " << e.what() - << "\n"; + std::cerr << "hpx::init: std::exception caught: " << e.what() << "\n"; return -1; + //} catch (...) { + // std::cerr << "{env}: " << hpx::detail::get_execution_environment(); + // std::cerr << "hpx::init: unexpected exception caught\n"; + // return -1; } return result; } @@ -1125,7 +1248,7 @@ namespace hpx apply( hpx::find_root_locality(), shutdown_timeout); - util::apex_finalize(); + //util::apex_finalize(); return 0; } @@ -1163,7 +1286,7 @@ namespace hpx if (std::abs(shutdown_timeout + 1.0) < 1e-16) shutdown_timeout = detail::get_option("hpx.shutdown_timeout", -1.0); - util::apex_finalize(); + //util::apex_finalize(); components::server::runtime_support* p = reinterpret_cast( diff --git a/src/lcos/future.cpp b/src/lcos/future.cpp index a3b955876eaf..6a326b287fc1 100644 --- a/src/lcos/future.cpp +++ b/src/lcos/future.cpp @@ -4,6 +4,7 @@ // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include #include HPX_REGISTER_TYPED_CONTINUATION( diff --git a/src/performance_counters/counters.cpp b/src/performance_counters/counters.cpp index 5528e8ee0f8b..6dcb7990950f 100644 --- a/src/performance_counters/counters.cpp +++ b/src/performance_counters/counters.cpp @@ -35,19 +35,23 @@ /////////////////////////////////////////////////////////////////////////////// // Initialization support for the performance counter actions HPX_REGISTER_ACTION_ID( - hpx::performance_counters::server::base_performance_counter::get_counter_info_action, + hpx::performance_counters::server + ::base_performance_counter::get_counter_info_action, performance_counter_get_counter_info_action, hpx::actions::performance_counter_get_counter_info_action_id) HPX_REGISTER_ACTION_ID( - hpx::performance_counters::server::base_performance_counter::get_counter_value_action, + hpx::performance_counters::server + ::base_performance_counter::get_counter_value_action, performance_counter_get_counter_value_action, hpx::actions::performance_counter_get_counter_value_action_id) HPX_REGISTER_ACTION_ID( - hpx::performance_counters::server::base_performance_counter::set_counter_value_action, + hpx::performance_counters::server + ::base_performance_counter::set_counter_value_action, performance_counter_set_counter_value_action, hpx::actions::performance_counter_set_counter_value_action_id) HPX_REGISTER_ACTION_ID( - hpx::performance_counters::server::base_performance_counter::reset_counter_value_action, + hpx::performance_counters::server + ::base_performance_counter::reset_counter_value_action, performance_counter_reset_counter_value_action, hpx::actions::performance_counter_reset_counter_value_action_id) HPX_REGISTER_ACTION_ID( @@ -97,7 +101,8 @@ namespace hpx { namespace performance_counters if (-1 != path.parentinstanceindex_) { result += "#"; - result += boost::lexical_cast(path.parentinstanceindex_); + result += boost::lexical_cast + (path.parentinstanceindex_); } if (!path.instancename_.empty()) result += "/"; @@ -260,7 +265,8 @@ BOOST_FUSION_ADAPT_STRUCT( namespace hpx { namespace performance_counters { /// - /// /objectname{parentinstancename#parentindex/instancename#instanceindex}/countername#parameters + /// /objectname{parentinstancename#parentindex/instancename#instanceindex} + /// /countername#parameters /// /objectname{parentinstancename#*/instancename#*}/countername#parameters /// /objectname{/basecounter}/countername,parameters /// @@ -277,7 +283,8 @@ namespace hpx { namespace performance_counters >> -('/' >> +~qi::char_("#}@")) >> -('@' >> +qi::char_); instance = '{' >> parent >> -('/' >> child) >> '}'; parent = - &qi::lit('/') >> qi::raw[start] >> qi::attr(-1) >> qi::attr(true) // base counter + &qi::lit('/') >> qi::raw[start] >> qi::attr(-1) >> qi::attr(true) + // base counter | +~qi::char_("#/}") >> ( '#' >> raw_uint // counter parentinstance name | -qi::string("#*") // counter parentinstance skeleton name @@ -304,7 +311,8 @@ namespace hpx { namespace performance_counters /// \brief Fill the given \a counter_path_elements instance from the given /// full name of a counter /// - /// /objectname{parentinstancename#parentindex/instancename#instanceindex}/countername + /// /objectname{parentinstancename#parentindex + /// /instancename#instanceindex}/countername /// counter_status get_counter_path_elements(std::string const& name, counter_path_elements& path, error_code& ec) @@ -338,7 +346,8 @@ namespace hpx { namespace performance_counters } else if (!elements.instance_.parent_.index_.empty()) { path.parentinstanceindex_ = - hpx::util::safe_lexical_cast(elements.instance_.parent_.index_); + hpx::util::safe_lexical_cast + (elements.instance_.parent_.index_); } if (elements.instance_.child_.index_ == "#*") { @@ -346,7 +355,8 @@ namespace hpx { namespace performance_counters } else if (!elements.instance_.child_.index_.empty()) { path.instanceindex_ = - hpx::util::safe_lexical_cast(elements.instance_.child_.index_); + hpx::util::safe_lexical_cast + (elements.instance_.child_.index_); } } @@ -867,7 +877,8 @@ namespace hpx { namespace performance_counters complement_counter_info(complemented_info, ec); if (ec) result_type(); - ensure_counter_prefix(complemented_info.fullname_); // pre-pend prefix, if necessary + ensure_counter_prefix(complemented_info.fullname_); + // pre-pend prefix, if necessary // ask AGAS for the id of the given counter naming::id_type id; @@ -889,7 +900,8 @@ namespace hpx { namespace performance_counters if (p.parentinstancename_ == "locality" && ( p.parentinstanceindex_ < 0 || - p.parentinstanceindex_ >= static_cast(get_num_localities_sync()) + p.parentinstanceindex_ >= static_cast + (get_num_localities_sync()) ) ) { @@ -914,7 +926,8 @@ namespace hpx { namespace performance_counters } // attach the function which registers the id_type with AGAS - return f.then(hpx::util::bind(®ister_with_agas, hpx::util::placeholders::_1, + return f.then(hpx::util::bind(®ister_with_agas, + hpx::util::placeholders::_1, complemented_info.fullname_)); } catch (hpx::exception const& e) { diff --git a/src/performance_counters/registry.cpp b/src/performance_counters/registry.cpp index f822145c6cde..e69a7f0bd9ef 100644 --- a/src/performance_counters/registry.cpp +++ b/src/performance_counters/registry.cpp @@ -525,7 +525,8 @@ namespace hpx { namespace performance_counters switch (complemented_info.type_) { case counter_elapsed_time: { - typedef components::managed_component counter_t; + typedef components::managed_component + counter_t; id = components::server::construct(complemented_info); } break; @@ -584,7 +585,8 @@ namespace hpx { namespace performance_counters counter_aggregating != info.type_) { HPX_THROWS_IF(ec, bad_parameter, "registry::create_statistics_counter", - "invalid counter type requested (only counter_aggregating is supported)"); + "invalid counter type requested \ + (only counter_aggregating is supported)"); return status_counter_type_unknown; } @@ -710,7 +712,8 @@ namespace hpx { namespace performance_counters counter_aggregating != info.type_) { HPX_THROWS_IF(ec, bad_parameter, "registry::create_arithmetics_counter", - "invalid counter type requested (only counter_aggregating is supported)"); + "invalid counter type requested \ + (only counter_aggregating is supported)"); return status_counter_type_unknown; } diff --git a/src/performance_counters/server/arithmetics_counter.cpp b/src/performance_counters/server/arithmetics_counter.cpp index 122993d6b5d5..f149ac09d3d5 100644 --- a/src/performance_counters/server/arithmetics_counter.cpp +++ b/src/performance_counters/server/arithmetics_counter.cpp @@ -82,7 +82,8 @@ namespace hpx { namespace performance_counters { namespace server { // gather current base values counter_value value; - if (!evaluate_base_counter(base_counter_ids_[i], base_counter_names_[i], value)) + if (!evaluate_base_counter(base_counter_ids_[i], + base_counter_names_[i], value)) { return value; } @@ -354,7 +355,8 @@ namespace hpx { namespace performance_counters { namespace detail { HPX_THROWS_IF(ec, bad_parameter, "arithmetics_counter_creator", - "the given (expanded) counter name is not a validly formed " + "the given (expanded) counter name is not \ + a validly formed " "performance counter name: " + name); return naming::invalid_gid; } diff --git a/src/performance_counters/server/statistics_counter.cpp b/src/performance_counters/server/statistics_counter.cpp index 632fd51652c5..b870b2188629 100644 --- a/src/performance_counters/server/statistics_counter.cpp +++ b/src/performance_counters/server/statistics_counter.cpp @@ -60,7 +60,8 @@ namespace hpx { namespace performance_counters { namespace server hpx::performance_counters::counter_value value; - prev_value_.value_ = detail::counter_type_from_statistic::call(*value_); + prev_value_.value_ = + detail::counter_type_from_statistic::call(*value_); prev_value_.status_ = status_new_data; prev_value_.time_ = static_cast(hpx::get_system_uptime()); prev_value_.count_ = ++invocation_count_; @@ -70,7 +71,8 @@ namespace hpx { namespace performance_counters { namespace server { value_.reset(detail::counter_type_from_statistic::create( parameter2_)); // reset accumulator - (*value_)(static_cast(prev_value_.value_)); // start off with last base value + (*value_)(static_cast(prev_value_.value_)); + // start off with last base value } return value; @@ -98,7 +100,8 @@ namespace hpx { namespace performance_counters { namespace server } else { boost::lock_guard l(mtx_); - (*value_)(static_cast(base_value.value_)); // accumulate new value + (*value_)(static_cast(base_value.value_)); + // accumulate new value } return true; } @@ -192,7 +195,8 @@ namespace hpx { namespace performance_counters { namespace server value_.reset(detail::counter_type_from_statistic::create( parameter2_)); // reset accumulator - (*value_)(static_cast(prev_value_.value_)); // start off with last base value + (*value_)(static_cast(prev_value_.value_)); + // start off with last base value } }}} diff --git a/src/pre_main.cpp b/src/pre_main.cpp index 3607e4a61c28..22031f09b322 100644 --- a/src/pre_main.cpp +++ b/src/pre_main.cpp @@ -187,7 +187,8 @@ int pre_main(runtime_mode mode) startup_barrier = create_barrier(num_localities, startup_barrier_name); } - LBT_(info) << "(2nd stage) pre_main: created 2nd and 3rd stage boot barriers"; + LBT_(info) << "(2nd stage) pre_main: created \ + 2nd and 3rd stage boot barriers"; } else // Hosted. { diff --git a/src/runtime.cpp b/src/runtime.cpp index 2e19dea39f03..f024b21952b6 100644 --- a/src/runtime.cpp +++ b/src/runtime.cpp @@ -219,7 +219,8 @@ namespace hpx { // manage certificates for root-CA and sub-CA util::security::root_certificate_authority root_certificate_authority_; - util::security::subordinate_certificate_authority subordinate_certificate_authority_; + util::security::subordinate_certificate_authority + subordinate_certificate_authority_; // certificate store std::unique_ptr cert_store_; @@ -227,7 +228,8 @@ namespace hpx }; } - components::security::certificate_store const * runtime::cert_store(error_code& ec) const + components::security::certificate_store const * runtime::cert_store(error_code& ec) + const { HPX_ASSERT(security_data_.get() != 0); if (0 == security_data_->cert_store_.get()) // should have been created @@ -362,7 +364,8 @@ namespace hpx // finish initializing our sub-CA boost::lock_guard l(security_mtx_); security_data_->locality_certificate_ = subca_cert; - security_data_->subordinate_certificate_authority_.set_certificate(subca_cert); + security_data_ + ->subordinate_certificate_authority_.set_certificate(subca_cert); } // add the certificates of the root's sub-CA and our own @@ -408,7 +411,8 @@ namespace hpx "certificate: %2%") % here() % cert); boost::lock_guard l(security_mtx_); - HPX_ASSERT(0 != security_data_->cert_store_.get()); // should have been created + HPX_ASSERT(0 != security_data_->cert_store_.get()); + // should have been created security_data_->cert_store_->insert(cert); } @@ -538,7 +542,8 @@ namespace hpx boost::uint64_t runtime::get_system_uptime() { - boost::int64_t diff = util::high_resolution_clock::now() - *runtime::uptime_.get(); + boost::int64_t diff = + util::high_resolution_clock::now() - *runtime::uptime_.get(); return diff < 0LL ? 0ULL : static_cast(diff); } @@ -1103,7 +1108,8 @@ namespace hpx return false; bool numa_sensitive = false; - if (std::size_t(-1) != rt->get_thread_manager().get_worker_thread_num(&numa_sensitive)) + if (std::size_t(-1) != + rt->get_thread_manager().get_worker_thread_num(&numa_sensitive)) return numa_sensitive; return false; } @@ -1419,7 +1425,8 @@ namespace hpx { runtime* rt = get_runtime_ptr(); if (NULL != rt) - return rt->create_binary_filter(binary_filter_type, compress, next_filter, ec); + return rt->create_binary_filter + (binary_filter_type, compress, next_filter, ec); HPX_THROWS_IF(ec, invalid_status, "create_binary_filter", "the runtime system is not available at this time"); diff --git a/src/runtime/agas/addressing_service.cpp b/src/runtime/agas/addressing_service.cpp index 94ae4049f730..0693c451e990 100644 --- a/src/runtime/agas/addressing_service.cpp +++ b/src/runtime/agas/addressing_service.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -575,7 +576,8 @@ parcelset::endpoints_type const & addressing_service::resolve_locality( if (0 == threads::get_self_ptr()) { // this should happen only during bootstrap - // FIXME: Disabled this assert cause it fires. It should not, but doesn't do any harm + // FIXME: Disabled this assert cause it fires. + // It should not, but doesn't do any harm //HPX_ASSERT(hpx::is_starting()); while(!endpoints_future.is_ready()) @@ -1804,7 +1806,8 @@ void addressing_service::route( , action_type(), action_priority_, std::move(p)); // send to the main AGAS instance for routing - hpx::applier::get_applier().get_parcel_handler().put_parcel(std::move(route_p), f); + hpx::applier::get_applier().get_parcel_handler() + .put_parcel(std::move(route_p), f); return; } } @@ -2055,7 +2058,7 @@ lcos::future addressing_service::register_name_async( { // {{{ // We need to modify the reference count. naming::gid_type& mutable_gid = const_cast(id).get_gid(); - naming::gid_type new_gid = naming::detail::split_gid_if_needed(mutable_gid); + naming::gid_type new_gid = naming::detail::split_gid_if_needed(mutable_gid).get(); request req(symbol_ns_bind, name, new_gid); @@ -2822,7 +2825,8 @@ void addressing_service::register_counter_types() boost::uint32_t locality_id = naming::get_locality_id_from_gid(get_local_locality()); - std::string str("locality#" + boost::lexical_cast(locality_id) + "/"); + std::string str("locality#" + + boost::lexical_cast(locality_id) + "/"); hosted->register_server_instance(str.c_str(), locality_id); } } // }}} @@ -3147,12 +3151,16 @@ namespace hpx { namespace detail { - inline std::string name_from_basename(char const* basename, std::size_t idx) + inline std::string + name_from_basename(std::string const& basename, std::size_t idx) { + HPX_ASSERT(!basename.empty()); + std::string name; if (basename[0] != '/') name += '/'; + name += basename; if (name[name.size()-1] != '/') name += '/'; @@ -3164,12 +3172,12 @@ namespace hpx /////////////////////////////////////////////////////////////////////////// std::vector > - find_all_ids_from_basename(char const* basename, std::size_t num_ids) + find_all_from_basename(std::string basename, std::size_t num_ids) { - if (0 == basename) + if (basename.empty()) { HPX_THROW_EXCEPTION(bad_parameter, - "hpx::find_all_ids_from_basename", + "hpx::find_all_from_basename", "no basename specified"); } @@ -3178,19 +3186,19 @@ namespace hpx { std::string name = detail::name_from_basename(basename, i); results.push_back(agas::on_symbol_namespace_event( - name, agas::symbol_ns_bind, true)); + std::move(name), agas::symbol_ns_bind, true)); } return results; } std::vector > - find_ids_from_basename(char const* basename, + find_from_basename(std::string basename, std::vector const& ids) { - if (0 == basename) + if (basename.empty()) { HPX_THROW_EXCEPTION(bad_parameter, - "hpx::find_ids_from_basename", + "hpx::find_from_basename", "no basename specified"); } @@ -3199,18 +3207,18 @@ namespace hpx { std::string name = detail::name_from_basename(basename, i); results.push_back(agas::on_symbol_namespace_event( - name, agas::symbol_ns_bind, true)); + std::move(name), agas::symbol_ns_bind, true)); } return results; } - hpx::future find_id_from_basename(char const* basename, + hpx::future find_from_basename(std::string basename, std::size_t sequence_nr) { - if (0 == basename) + if (basename.empty()) { HPX_THROW_EXCEPTION(bad_parameter, - "hpx::find_id_from_basename", + "hpx::find_from_basename", "no basename specified"); } @@ -3218,16 +3226,17 @@ namespace hpx sequence_nr = std::size_t(naming::get_locality_id_from_id(find_here())); std::string name = detail::name_from_basename(basename, sequence_nr); - return agas::on_symbol_namespace_event(name, agas::symbol_ns_bind, true); + return agas::on_symbol_namespace_event(std::move(name), + agas::symbol_ns_bind, true); } - hpx::future register_id_with_basename(char const* basename, + hpx::future register_with_basename(std::string basename, hpx::id_type id, std::size_t sequence_nr) { - if (0 == basename) + if (basename.empty()) { HPX_THROW_EXCEPTION(bad_parameter, - "hpx::register_id_with_basename", + "hpx::register_with_basename", "no basename specified"); } @@ -3235,16 +3244,16 @@ namespace hpx sequence_nr = std::size_t(naming::get_locality_id_from_id(find_here())); std::string name = detail::name_from_basename(basename, sequence_nr); - return agas::register_name(name, id); + return agas::register_name(std::move(name), id); } - hpx::future unregister_id_with_basename( - char const* basename, std::size_t sequence_nr) + hpx::future unregister_with_basename( + std::string basename, std::size_t sequence_nr) { - if (0 == basename) + if (basename.empty()) { HPX_THROW_EXCEPTION(bad_parameter, - "hpx::unregister_id_with_basename", + "hpx::unregister_with_basename", "no basename specified"); } @@ -3252,6 +3261,6 @@ namespace hpx sequence_nr = std::size_t(naming::get_locality_id_from_id(find_here())); std::string name = detail::name_from_basename(basename, sequence_nr); - return agas::unregister_name(name); + return agas::unregister_name(std::move(name)); } } diff --git a/src/runtime/agas/big_boot_barrier.cpp b/src/runtime/agas/big_boot_barrier.cpp index de4a85173354..c4197bcf8a76 100644 --- a/src/runtime/agas/big_boot_barrier.cpp +++ b/src/runtime/agas/big_boot_barrier.cpp @@ -755,7 +755,8 @@ void register_worker_security(registration_header_security const& header) { // AGAS is starting up; this locality is participating in startup // synchronization. - util::unique_function_nonser* thunk = new util::unique_function_nonser( + util::unique_function_nonser* thunk = + new util::unique_function_nonser( util::bind( util::one_shot(&big_boot_barrier::apply) , boost::ref(get_big_boot_barrier()) diff --git a/src/runtime/agas/interface.cpp b/src/runtime/agas/interface.cpp index e23605e2b251..a726523407f1 100644 --- a/src/runtime/agas/interface.cpp +++ b/src/runtime/agas/interface.cpp @@ -243,7 +243,8 @@ boost::uint32_t get_num_overall_threads_sync( // std::transform(ids.begin(), ids.end(), std::back_inserter(gids), convert_to_gid); // // addrs.resize(count); -// return naming::get_agas_client().is_local_address(gids.data(), addrs.data(), count, locals, ec); +// return naming::get_agas_client().is_local_address(gids.data(), +// addrs.data(), count, locals, ec); // } bool is_local_address_cached( diff --git a/src/runtime/agas/request.cpp b/src/runtime/agas/request.cpp index cba5c57ead12..f54e08ce0256 100644 --- a/src/runtime/agas/request.cpp +++ b/src/runtime/agas/request.cpp @@ -292,7 +292,8 @@ namespace hpx { namespace agas , naming::gid_type prefix_ ) : mc(type_) - , data(new request_data(util::make_tuple(endpoints_, count_, num_threads_, prefix_))) + , data(new request_data(util::make_tuple(endpoints_, + count_, num_threads_, prefix_))) { // TODO: verification of namespace_action_code } @@ -376,7 +377,8 @@ namespace hpx { namespace agas , hpx::id_type result_lco ) : mc(type_) - , data(new request_data(util::make_tuple(name, evt, call_for_past_events, result_lco))) + , data(new request_data(util::make_tuple(name, + evt, call_for_past_events, result_lco))) { HPX_ASSERT(type_ == symbol_ns_on_event); } diff --git a/src/runtime/agas/server/component_namespace_server.cpp b/src/runtime/agas/server/component_namespace_server.cpp index 77e50620c64e..e833d2ba54cf 100644 --- a/src/runtime/agas/server/component_namespace_server.cpp +++ b/src/runtime/agas/server/component_namespace_server.cpp @@ -180,7 +180,8 @@ void component_namespace::register_counter_types( ++i) { // global counters are handled elsewhere - if (detail::component_namespace_services[i].code_ == component_ns_statistics_counter) + if (detail::component_namespace_services[i].code_ == + component_ns_statistics_counter) continue; std::string name(detail::component_namespace_services[i].name_); @@ -188,7 +189,8 @@ void component_namespace::register_counter_types( std::string::size_type p = name.find_last_of('/'); HPX_ASSERT(p != std::string::npos); - if (detail::component_namespace_services[i].target_ == detail::counter_target_count) + if (detail::component_namespace_services[i].target_ == + detail::counter_target_count) help = boost::str(help_count % name.substr(p+1)); else help = boost::str(help_time % name.substr(p+1)); @@ -220,12 +222,15 @@ void component_namespace::register_global_counter_types( ++i) { // local counters are handled elsewhere - if (detail::component_namespace_services[i].code_ != component_ns_statistics_counter) + if (detail::component_namespace_services[i].code_ != + component_ns_statistics_counter) continue; std::string help; - if (detail::component_namespace_services[i].target_ == detail::counter_target_count) - help = "returns the overall number of invocations of all component AGAS services"; + if (detail::component_namespace_services[i].target_ == + detail::counter_target_count) + help = "returns the overall number of invocations of all \ + component AGAS services"; else help = "returns the overall execution time of all component AGAS services"; @@ -592,16 +597,20 @@ response component_namespace::get_component_type_name( result = get_component_name(component_ids_.right, t); } else if (components::get_derived_type(t) != 0) { - result = get_component_name(component_ids_.right, components::get_derived_type(t)); + result = get_component_name(component_ids_.right, + components::get_derived_type(t)); result += "/"; - result += get_component_name(component_ids_.right, components::get_base_type(t)); + result += get_component_name(component_ids_.right, + components::get_base_type(t)); } if (result.empty()) { LAGAS_(info) << (boost::format( - "component_namespace::get_component_typename, key(%1%/%2%), response(no_success)") - % int(components::get_derived_type(t)) % int(components::get_base_type(t))); + "component_namespace::get_component_typename, \ + key(%1%/%2%), response(no_success)") + % int(components::get_derived_type(t)) % + int(components::get_base_type(t))); if (&ec != &throws) ec = make_success_code(); @@ -611,7 +620,8 @@ response component_namespace::get_component_type_name( LAGAS_(info) << (boost::format( "component_namespace::get_component_typename, key(%1%/%2%), response(%3%)") - % int(components::get_derived_type(t)) % int(components::get_base_type(t)) % result); + % int(components::get_derived_type(t)) % int(components::get_base_type(t)) + % result); if (&ec != &throws) ec = make_success_code(); @@ -709,28 +719,36 @@ response component_namespace::statistics_counter( { switch (code) { case component_ns_bind_prefix: - get_data_func = boost::bind(&cd::get_bind_prefix_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_bind_prefix_count, + &counter_data_, ::_1); break; case component_ns_bind_name: - get_data_func = boost::bind(&cd::get_bind_name_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_bind_name_count, + &counter_data_, ::_1); break; case component_ns_resolve_id: - get_data_func = boost::bind(&cd::get_resolve_id_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_resolve_id_count, + &counter_data_, ::_1); break; case component_ns_unbind_name: - get_data_func = boost::bind(&cd::get_unbind_name_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_unbind_name_count, + &counter_data_, ::_1); break; case component_ns_iterate_types: - get_data_func = boost::bind(&cd::get_iterate_types_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_iterate_types_count, + &counter_data_, ::_1); break; case component_ns_get_component_type_name: - get_data_func = boost::bind(&cd::get_component_type_name_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_component_type_name_count, + &counter_data_, ::_1); break; case component_ns_num_localities: - get_data_func = boost::bind(&cd::get_num_localities_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_num_localities_count, + &counter_data_, ::_1); break; case component_ns_statistics_counter: - get_data_func = boost::bind(&cd::get_overall_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_overall_count, + &counter_data_, ::_1); break; default: HPX_THROWS_IF(ec, bad_parameter @@ -743,7 +761,8 @@ response component_namespace::statistics_counter( HPX_ASSERT(detail::counter_target_time == target); switch (code) { case component_ns_bind_prefix: - get_data_func = boost::bind(&cd::get_bind_prefix_time, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_bind_prefix_time, + &counter_data_, ::_1); break; case component_ns_bind_name: get_data_func = boost::bind(&cd::get_bind_name_time, &counter_data_, ::_1); @@ -755,13 +774,16 @@ response component_namespace::statistics_counter( get_data_func = boost::bind(&cd::get_unbind_name_time, &counter_data_, ::_1); break; case component_ns_iterate_types: - get_data_func = boost::bind(&cd::get_iterate_types_time, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_iterate_types_time, + &counter_data_, ::_1); break; case component_ns_get_component_type_name: - get_data_func = boost::bind(&cd::get_component_type_name_time, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_component_type_name_time, + &counter_data_, ::_1); break; case component_ns_num_localities: - get_data_func = boost::bind(&cd::get_num_localities_time, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_num_localities_time, + &counter_data_, ::_1); break; case component_ns_statistics_counter: get_data_func = boost::bind(&cd::get_overall_time, &counter_data_, ::_1); @@ -817,7 +839,8 @@ boost::int64_t component_namespace::counter_data::get_iterate_types_count(bool r return util::get_and_reset_value(iterate_types_.count_, reset); } -boost::int64_t component_namespace::counter_data::get_component_type_name_count(bool reset) +boost::int64_t component_namespace::counter_data + ::get_component_type_name_count(bool reset) { return util::get_and_reset_value(get_component_type_name_.count_, reset); } @@ -864,7 +887,8 @@ boost::int64_t component_namespace::counter_data::get_iterate_types_time(bool re return util::get_and_reset_value(iterate_types_.time_, reset); } -boost::int64_t component_namespace::counter_data::get_component_type_name_time(bool reset) +boost::int64_t component_namespace::counter_data + ::get_component_type_name_time(bool reset) { return util::get_and_reset_value(get_component_type_name_.time_, reset); } diff --git a/src/runtime/agas/server/locality_namespace_server.cpp b/src/runtime/agas/server/locality_namespace_server.cpp index 2e40fdc01715..c617261920fe 100644 --- a/src/runtime/agas/server/locality_namespace_server.cpp +++ b/src/runtime/agas/server/locality_namespace_server.cpp @@ -184,7 +184,8 @@ void locality_namespace::register_counter_types( ++i) { // global counters are handled elsewhere - if (detail::locality_namespace_services[i].code_ == locality_ns_statistics_counter) + if (detail::locality_namespace_services[i].code_ == + locality_ns_statistics_counter) continue; std::string name(detail::locality_namespace_services[i].name_); @@ -192,7 +193,8 @@ void locality_namespace::register_counter_types( std::string::size_type p = name.find_last_of('/'); HPX_ASSERT(p != std::string::npos); - if (detail::locality_namespace_services[i].target_ == detail::counter_target_count) + if (detail::locality_namespace_services[i].target_ == + detail::counter_target_count) help = boost::str(help_count % name.substr(p+1)); else help = boost::str(help_time % name.substr(p+1)); @@ -224,12 +226,15 @@ void locality_namespace::register_global_counter_types( ++i) { // local counters are handled elsewhere - if (detail::locality_namespace_services[i].code_ != locality_ns_statistics_counter) + if (detail::locality_namespace_services[i].code_ != + locality_ns_statistics_counter) continue; std::string help; - if (detail::locality_namespace_services[i].target_ == detail::counter_target_count) - help = "returns the overall number of invocations of all locality AGAS services"; + if (detail::locality_namespace_services[i].target_ == + detail::counter_target_count) + help = "returns the overall number of invocations \ + of all locality AGAS services"; else help = "returns the overall execution time of all locality AGAS services"; @@ -647,25 +652,32 @@ response locality_namespace::statistics_counter( { switch (code) { case locality_ns_allocate: - get_data_func = boost::bind(&cd::get_allocate_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_allocate_count, + &counter_data_, ::_1); break; case locality_ns_resolve_locality: - get_data_func = boost::bind(&cd::get_resolve_locality_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_resolve_locality_count, + &counter_data_, ::_1); break; case locality_ns_free: - get_data_func = boost::bind(&cd::get_free_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_free_count, + &counter_data_, ::_1); break; case locality_ns_localities: - get_data_func = boost::bind(&cd::get_localities_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_localities_count, + &counter_data_, ::_1); break; case locality_ns_resolved_localities: - get_data_func = boost::bind(&cd::get_resolved_localities_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_resolved_localities_count, + &counter_data_, ::_1); break; case locality_ns_num_localities: - get_data_func = boost::bind(&cd::get_num_localities_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_num_localities_count, + &counter_data_, ::_1); break; case locality_ns_num_threads: - get_data_func = boost::bind(&cd::get_num_threads_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_num_threads_count, + &counter_data_, ::_1); break; case locality_ns_statistics_counter: get_data_func = boost::bind(&cd::get_overall_count, &counter_data_, ::_1); @@ -681,22 +693,27 @@ response locality_namespace::statistics_counter( HPX_ASSERT(detail::counter_target_time == target); switch (code) { case locality_ns_allocate: - get_data_func = boost::bind(&cd::get_allocate_time, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_allocate_time, + &counter_data_, ::_1); break; case locality_ns_resolve_locality: - get_data_func = boost::bind(&cd::get_resolve_locality_time, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_resolve_locality_time, + &counter_data_, ::_1); break; case locality_ns_free: get_data_func = boost::bind(&cd::get_free_time, &counter_data_, ::_1); break; case locality_ns_localities: - get_data_func = boost::bind(&cd::get_localities_time, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_localities_time, + &counter_data_, ::_1); break; case locality_ns_resolved_localities: - get_data_func = boost::bind(&cd::get_resolved_localities_time, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_resolved_localities_time, + &counter_data_, ::_1); break; case locality_ns_num_localities: - get_data_func = boost::bind(&cd::get_num_localities_time, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_num_localities_time, + &counter_data_, ::_1); break; case locality_ns_num_threads: get_data_func = boost::bind(&cd::get_num_threads_time, &counter_data_, ::_1); @@ -760,7 +777,8 @@ boost::int64_t locality_namespace::counter_data::get_num_threads_count(bool rese return util::get_and_reset_value(num_threads_.count_, reset); } -boost::int64_t locality_namespace::counter_data::get_resolved_localities_count(bool reset) +boost::int64_t locality_namespace::counter_data + ::get_resolved_localities_count(bool reset) { return util::get_and_reset_value(resolved_localities_.count_, reset); } diff --git a/src/runtime/agas/server/primary_namespace_server.cpp b/src/runtime/agas/server/primary_namespace_server.cpp index 1b6029caba03..59329dcf659a 100644 --- a/src/runtime/agas/server/primary_namespace_server.cpp +++ b/src/runtime/agas/server/primary_namespace_server.cpp @@ -210,7 +210,8 @@ void primary_namespace::register_counter_types( std::string::size_type p = name.find_last_of('/'); HPX_ASSERT(p != std::string::npos); - if (detail::primary_namespace_services[i].target_ == detail::counter_target_count) + if (detail::primary_namespace_services[i].target_ + == detail::counter_target_count) help = boost::str(help_count % name.substr(p+1)); else help = boost::str(help_time % name.substr(p+1)); @@ -242,12 +243,15 @@ void primary_namespace::register_global_counter_types( ++i) { // local counters are handled elsewhere - if (detail::primary_namespace_services[i].code_ != primary_ns_statistics_counter) + if (detail::primary_namespace_services[i].code_ + != primary_ns_statistics_counter) continue; std::string help; - if (detail::primary_namespace_services[i].target_ == detail::counter_target_count) - help = "returns the overall number of invocations of all primary AGAS services"; + if (detail::primary_namespace_services[i].target_ + == detail::counter_target_count) + help = "returns the overall number of invocations \ + of all primary AGAS services"; else help = "returns the overall execution time of all primary AGAS services"; @@ -1112,7 +1116,8 @@ void primary_namespace::decrement_sweep( refcnt_table_type::iterator it = refcnts_.find(raw); if (it == refcnts_.end()) { - boost::int64_t count = boost::int64_t(HPX_GLOBALCREDIT_INITIAL) - credits; + boost::int64_t count = boost::int64_t(HPX_GLOBALCREDIT_INITIAL) + - credits; std::pair p = refcnts_.insert(refcnt_table_type::value_type(raw, count)); if (!p.second) @@ -1362,28 +1367,36 @@ response primary_namespace::statistics_counter( get_data_func = boost::bind(&cd::get_bind_gid_count, &counter_data_, ::_1); break; case primary_ns_resolve_gid: - get_data_func = boost::bind(&cd::get_resolve_gid_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_resolve_gid_count, + &counter_data_, ::_1); break; case primary_ns_unbind_gid: - get_data_func = boost::bind(&cd::get_unbind_gid_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_unbind_gid_count, + &counter_data_, ::_1); break; case primary_ns_increment_credit: - get_data_func = boost::bind(&cd::get_increment_credit_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_increment_credit_count, + &counter_data_, ::_1); break; case primary_ns_decrement_credit: - get_data_func = boost::bind(&cd::get_decrement_credit_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_decrement_credit_count, + &counter_data_, ::_1); break; case primary_ns_allocate: - get_data_func = boost::bind(&cd::get_allocate_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_allocate_count, + &counter_data_, ::_1); break; case primary_ns_begin_migration: - get_data_func = boost::bind(&cd::get_begin_migration_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_begin_migration_count, + &counter_data_, ::_1); break; case primary_ns_end_migration: - get_data_func = boost::bind(&cd::get_end_migration_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_end_migration_count, + &counter_data_, ::_1); break; case primary_ns_statistics_counter: - get_data_func = boost::bind(&cd::get_overall_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_overall_count, + &counter_data_, ::_1); break; default: HPX_THROWS_IF(ec, bad_parameter @@ -1408,22 +1421,27 @@ response primary_namespace::statistics_counter( get_data_func = boost::bind(&cd::get_unbind_gid_time, &counter_data_, ::_1); break; case primary_ns_increment_credit: - get_data_func = boost::bind(&cd::get_increment_credit_time, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_increment_credit_time, + &counter_data_, ::_1); break; case primary_ns_decrement_credit: - get_data_func = boost::bind(&cd::get_decrement_credit_time, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_decrement_credit_time, + &counter_data_, ::_1); break; case primary_ns_allocate: get_data_func = boost::bind(&cd::get_allocate_time, &counter_data_, ::_1); break; case primary_ns_begin_migration: - get_data_func = boost::bind(&cd::get_begin_migration_time, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_begin_migration_time, + &counter_data_, ::_1); break; case primary_ns_end_migration: - get_data_func = boost::bind(&cd::get_end_migration_time, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_end_migration_time, + &counter_data_, ::_1); break; case primary_ns_statistics_counter: - get_data_func = boost::bind(&cd::get_overall_time, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_overall_time, + &counter_data_, ::_1); break; default: HPX_THROWS_IF(ec, bad_parameter diff --git a/src/runtime/agas/server/symbol_namespace_server.cpp b/src/runtime/agas/server/symbol_namespace_server.cpp index 287541612a6b..e0fdba651962 100644 --- a/src/runtime/agas/server/symbol_namespace_server.cpp +++ b/src/runtime/agas/server/symbol_namespace_server.cpp @@ -212,7 +212,8 @@ void symbol_namespace::register_global_counter_types( std::string help; if (detail::symbol_namespace_services[i].target_ == detail::counter_target_count) - help = "returns the overall number of invocations of all symbol AGAS services"; + help = "returns the overall number of invocations \ + of all symbol AGAS services"; else help = "returns the overall execution time of all symbol AGAS services"; @@ -398,7 +399,7 @@ response symbol_namespace::bind( // split the credit as the receiving end will expect to keep the // object alive naming::gid_type new_gid = - naming::detail::split_gid_if_needed(*current_gid); + naming::detail::split_gid_if_needed(*current_gid).get(); // trigger the lco set_lco_value(id, new_gid); @@ -452,7 +453,7 @@ response symbol_namespace::resolve( boost::shared_ptr current_gid(it->second); l.unlock(); - naming::gid_type gid = naming::detail::split_gid_if_needed(*current_gid); + naming::gid_type gid = naming::detail::split_gid_if_needed(*current_gid).get(); LAGAS_(info) << (boost::format( "symbol_namespace::resolve, key(%1%), gid(%2%)") @@ -566,7 +567,7 @@ response symbol_namespace::on_event( { util::unlock_guard > ul(l); naming::gid_type new_gid = naming::detail::split_gid_if_needed( - *current_gid); + *current_gid).get(); // trigger the lco handled = true; @@ -669,7 +670,8 @@ response symbol_namespace::statistics_counter( get_data_func = boost::bind(&cd::get_unbind_count, &counter_data_, ::_1); break; case symbol_ns_iterate_names: - get_data_func = boost::bind(&cd::get_iterate_names_count, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_iterate_names_count, + &counter_data_, ::_1); break; case symbol_ns_on_event: get_data_func = boost::bind(&cd::get_on_event_count, &counter_data_, ::_1); @@ -697,7 +699,8 @@ response symbol_namespace::statistics_counter( get_data_func = boost::bind(&cd::get_unbind_time, &counter_data_, ::_1); break; case symbol_ns_iterate_names: - get_data_func = boost::bind(&cd::get_iterate_names_time, &counter_data_, ::_1); + get_data_func = boost::bind(&cd::get_iterate_names_time, + &counter_data_, ::_1); break; case symbol_ns_on_event: get_data_func = boost::bind(&cd::get_on_event_time, &counter_data_, ::_1); diff --git a/src/runtime/agas/stubs/component_namespace_stubs.cpp b/src/runtime/agas/stubs/component_namespace_stubs.cpp index b6d33ae2d74d..e8d64d686b9f 100644 --- a/src/runtime/agas/stubs/component_namespace_stubs.cpp +++ b/src/runtime/agas/stubs/component_namespace_stubs.cpp @@ -34,7 +34,8 @@ template lcos::future component_namespace::service_async( , threads::thread_priority priority ); -template lcos::future component_namespace::service_async( +template lcos::future +component_namespace::service_async( naming::id_type const& gid , request const& req , threads::thread_priority priority diff --git a/src/runtime/agas/stubs/locality_namespace_stubs.cpp b/src/runtime/agas/stubs/locality_namespace_stubs.cpp index 4bb235717efc..9c03cd7ec9bd 100644 --- a/src/runtime/agas/stubs/locality_namespace_stubs.cpp +++ b/src/runtime/agas/stubs/locality_namespace_stubs.cpp @@ -32,7 +32,8 @@ template lcos::future locality_namespace::service_async( ); template lcos::future > -locality_namespace::service_async >( +locality_namespace::service_async >( naming::id_type const& gid , request const& req , threads::thread_priority priority @@ -45,13 +46,15 @@ locality_namespace::service_async( , threads::thread_priority priority ); -template lcos::future > locality_namespace::service_async >( +template lcos::future > +locality_namespace::service_async >( naming::id_type const& gid , request const& req , threads::thread_priority priority ); -template lcos::future locality_namespace::service_async( +template lcos::future +locality_namespace::service_async( naming::id_type const& gid , request const& req , threads::thread_priority priority diff --git a/src/runtime/applier/applier.cpp b/src/runtime/applier/applier.cpp index b04f3196ec6d..0b9d20046531 100644 --- a/src/runtime/applier/applier.cpp +++ b/src/runtime/applier/applier.cpp @@ -381,7 +381,8 @@ namespace hpx { namespace applier error_code& ec) const { std::vector raw_prefixes; - if (!parcel_handler_.get_raw_localities(raw_prefixes, components::component_invalid, ec)) + if (!parcel_handler_.get_raw_localities(raw_prefixes, + components::component_invalid, ec)) return false; for (naming::gid_type& gid : raw_prefixes) @@ -449,7 +450,8 @@ namespace hpx { namespace applier if (client.was_object_migrated(ids, size)) { client.route(std::move(p), util::bind(&detail::parcel_sent_handler, - std::ref(parcel_handler_), util::placeholders::_1, util::placeholders::_2)); + std::ref(parcel_handler_), util::placeholders::_1, + util::placeholders::_2)); return; } diff --git a/src/runtime/components/component_type.cpp b/src/runtime/components/component_type.cpp index acfe3b75bef7..6a4698ba6acf 100644 --- a/src/runtime/components/component_type.cpp +++ b/src/runtime/components/component_type.cpp @@ -48,7 +48,8 @@ namespace hpx { namespace components result = "component_invalid"; else if ((type < component_last) && (get_derived_type(type) == 0)) result = components::detail::names[type]; - else if (get_derived_type(type) < component_last && (get_derived_type(type) != 0)) + else if (get_derived_type(type) < + component_last && (get_derived_type(type) != 0)) result = components::detail::names[get_derived_type(type)]; else result = "component"; diff --git a/src/runtime/components/server/console_error_sink_singleton.cpp b/src/runtime/components/server/console_error_sink_singleton.cpp index 77254255dafd..40f3f21e11ad 100644 --- a/src/runtime/components/server/console_error_sink_singleton.cpp +++ b/src/runtime/components/server/console_error_sink_singleton.cpp @@ -14,7 +14,8 @@ namespace hpx { namespace components { namespace server console_error_dispatcher& get_error_dispatcher() { - util::reinitializable_static disp; + util::reinitializable_static disp; return disp.get(); } }}} diff --git a/src/runtime/components/server/runtime_support_server.cpp b/src/runtime/components/server/runtime_support_server.cpp index 91220d87f13b..37b7bd8279cb 100644 --- a/src/runtime/components/server/runtime_support_server.cpp +++ b/src/runtime/components/server/runtime_support_server.cpp @@ -427,7 +427,8 @@ namespace hpx { namespace components { namespace server strm << "list of registered components: \n"; component_map_type::iterator end = components_.end(); - for (component_map_type::iterator cit = components_.begin(); cit!= end; ++cit) + for (component_map_type::iterator cit = components_.begin(); + cit!= end; ++cit) { strm << " " << components::get_component_type_name((*cit).first) @@ -981,7 +982,8 @@ namespace hpx { namespace components { namespace server /////////////////////////////////////////////////////////////////////////// /// \brief Remove the given locality from our connection cache - void runtime_support::remove_from_connection_cache(parcelset::endpoints_type const& eps) + void runtime_support::remove_from_connection_cache(parcelset::endpoints_type + const& eps) { runtime* rt = get_runtime_ptr(); if (rt == 0) return; @@ -1056,7 +1058,8 @@ namespace hpx { namespace components { namespace server cleanup_threads(tm, l); // obey timeout - if ((std::abs(timeout - 1.) < 1e-16) && timeout < (t.elapsed() - start_time)) { + if ((std::abs(timeout - 1.) < 1e-16) && timeout < + (t.elapsed() - start_time)) { // we waited long enough timed_out = true; break; @@ -1573,7 +1576,8 @@ namespace hpx { namespace components { namespace server boost::program_options::variables_map vm; util::commandline_error_mode mode = util::rethrow_on_error; - std::string allow_unknown(ini.get_entry("hpx.commandline.allow_unknown", "0")); + std::string allow_unknown(ini.get_entry("hpx.commandline.allow_unknown", + "0")); if (allow_unknown != "0") mode = util::allow_unregistered; util::parse_commandline(ini, options, unknown_cmd_line, vm, diff --git a/src/runtime/naming/name.cpp b/src/runtime/naming/name.cpp index 1190aac92945..c99b0c82ea8a 100644 --- a/src/runtime/naming/name.cpp +++ b/src/runtime/naming/name.cpp @@ -215,38 +215,85 @@ namespace hpx { namespace naming /////////////////////////////////////////////////////////////////////// // prepare the given id, note: this function modifies the passed id - naming::gid_type id_type_impl::preprocess_gid() const + void id_type_impl::preprocess_gid(serialization::output_archive& ar) const { + typedef gid_type::mutex_type::scoped_lock scoped_lock; // unmanaged gids do not require any special handling if (unmanaged == type_) - return *this; + { + return; + } HPX_ASSERT(has_credits(*this)); // Request new credits from AGAS if needed (i.e. the remainder // of the credit splitting is equal to one). if (managed == type_) - return split_gid_if_needed(const_cast(*this)); + { + ar.await_future( + split_gid_if_needed(const_cast(*this)).then( + [&ar, this](hpx::future && gid_future) + { + ar.add_gid(*this, gid_future.get()); + } + ) + ); + return; + } - // all credits will be moved to the returned gid - HPX_ASSERT(managed_move_credit == type_); - return move_gid(const_cast(*this)); } /////////////////////////////////////////////////////////////////////// - gid_type split_gid_if_needed(gid_type& gid) + hpx::future split_gid_if_needed(gid_type& gid) { - typedef gid_type::mutex_type::scoped_try_lock scoped_lock; + typedef gid_type::mutex_type::scoped_lock scoped_lock; scoped_lock l(gid.get_mutex()); - if(l) - return split_gid_if_needed_locked(l, gid); + return split_gid_if_needed_locked(l, gid); + } + + gid_type postprocess_incref(gid_type &gid) + { + typedef gid_type::mutex_type::scoped_lock scoped_lock; + scoped_lock ll(gid.get_mutex()); + gid_type new_gid = gid; + HPX_ASSERT(new_gid != invalid_gid); + // Mark the gids as being split + set_credit_split_mask_for_gid(gid); + set_credit_split_mask_for_gid(new_gid); + + // Fill the new gid with our new credit + naming::detail::set_log2credit_for_gid( + new_gid, gid_type::credit_base_mask); + + // Another concurrent split operation might have happened, we + // need to add the new split credits to the old and account + // for overflow + // Get the current credit for our new gid + boost::int64_t src_credit = get_credit_from_gid(gid); + boost::int64_t split_credit = HPX_GLOBALCREDIT_INITIAL - 2; + boost::int64_t new_credit = src_credit + split_credit; + boost::int64_t overflow_credit = new_credit - HPX_GLOBALCREDIT_INITIAL; + + new_credit + = (std::min)( + static_cast(HPX_GLOBALCREDIT_INITIAL), new_credit); + naming::detail::set_credit_for_gid(gid, new_credit); + // Account for a possible overflow ... + if(overflow_credit > 0) + { + HPX_ASSERT( + overflow_credit <= HPX_GLOBALCREDIT_INITIAL-1); + util::unlock_guard ul(ll); + agas::decref(new_gid, overflow_credit); + } - return replenish_new_gid_if_needed(gid); + return new_gid; } - gid_type split_gid_if_needed_locked(gid_type::mutex_type::scoped_try_lock &l, gid_type& gid) + hpx::future split_gid_if_needed_locked( + gid_type::mutex_type::scoped_lock &l, gid_type& gid) { - typedef gid_type::mutex_type::scoped_try_lock scoped_lock; + typedef gid_type::mutex_type::scoped_lock scoped_lock; naming::gid_type new_gid; if (naming::detail::has_credits(gid)) @@ -260,12 +307,13 @@ namespace hpx { namespace naming // Scenario that might happen: // An id_type which needs to splitted is being split concurrently while // we unlock the lock to ask for more credit: - // This might lead to an overlow in the credit mask and needs to be accounted with + // This might lead to an overlow in the credit mask and + // needs to be accounted with // by sending a decref with the excessive credit. // - // An early decref can't happen as the id_type with the new credit is garuanteed to + // An early decref can't happen as the id_type with the new credit + // is garuanteed to // arrive only after we incremented the credit successfully in agas. - new_gid = gid; boost::int16_t src_log2credits = get_log2credit_from_gid(gid); HPX_ASSERT(get_log2credit_from_gid(gid) > 0); @@ -275,50 +323,29 @@ namespace hpx { namespace naming util::unlock_guard ul(l); boost::int64_t new_credit = (HPX_GLOBALCREDIT_INITIAL - 1) * 2; - agas::incref(new_gid, new_credit); + new_gid = gid; + HPX_ASSERT(new_gid != invalid_gid); + return agas::incref_async(new_gid, new_credit).then( + hpx::util::bind(postprocess_incref, boost::ref(gid)) + ); } + HPX_ASSERT(src_log2credits > 1); + + + new_gid = gid; // Mark the gids as being split set_credit_split_mask_for_gid(gid); set_credit_split_mask_for_gid(new_gid); - if(HPX_LIKELY(src_log2credits > 1)) - { - boost::int16_t split_log2credits = src_log2credits - 1; - // Fill the new gid with our new credit - naming::detail::set_log2credit_for_gid(new_gid, split_log2credits); - - HPX_ASSERT(get_log2credit_from_gid(gid) == src_log2credits); - // No incref operation was done, it's safe to just fill - // the credits with the splitted credits. - naming::detail::set_log2credit_for_gid(gid, split_log2credits); - } - else - { - // Fill the new gid with our new credit - naming::detail::set_log2credit_for_gid(new_gid, gid_type::credit_base_mask); - - // Another concurrent split operation might have happened, we need - // to add the new split credits to the old and account - // for overflow - // Get the current credit for our new gid - boost::int64_t src_credit = get_credit_from_gid(gid); - boost::int64_t split_credit = HPX_GLOBALCREDIT_INITIAL - 2; - boost::int64_t new_credit = src_credit + split_credit; - boost::int64_t overflow_credit = new_credit - HPX_GLOBALCREDIT_INITIAL; - - new_credit - = (std::min)(static_cast(HPX_GLOBALCREDIT_INITIAL) - , new_credit); - naming::detail::set_credit_for_gid(gid, new_credit); - // Account for a possible overflow ... - if(overflow_credit > 0) - { - HPX_ASSERT(overflow_credit <= HPX_GLOBALCREDIT_INITIAL-1); - util::unlock_guard ul(l); - agas::decref(new_gid, overflow_credit); - } - } + boost::int16_t split_log2credits = src_log2credits - 1; + // Fill the new gid with our new credit + naming::detail::set_log2credit_for_gid(new_gid, split_log2credits); + + HPX_ASSERT(get_log2credit_from_gid(gid) == src_log2credits); + // No incref operation was done, it's safe to just fill + // the credits with the splitted credits. + naming::detail::set_log2credit_for_gid(gid, split_log2credits); HPX_ASSERT(detail::has_credits(gid)); HPX_ASSERT(detail::has_credits(new_gid)); @@ -328,10 +355,10 @@ namespace hpx { namespace naming new_gid = gid; // strips lock-bit } - return new_gid; + return hpx::make_ready_future(new_gid); } - gid_type replenish_new_gid_if_needed(gid_type const& gid) + hpx::future replenish_new_gid_if_needed(gid_type const& gid) { naming::gid_type new_gid = gid; // strips lock bit @@ -341,26 +368,25 @@ namespace hpx { namespace naming boost::int64_t added_credit = naming::detail::fill_credit_for_gid(new_gid); naming::detail::set_credit_split_mask_for_gid(new_gid); - agas::incref(new_gid, added_credit); + HPX_ASSERT(new_gid != invalid_gid); + return + agas::incref_async(new_gid, added_credit).then( + [new_gid](future&&) -> gid_type + { + HPX_ASSERT(new_gid != invalid_gid); + return new_gid; + } + ); } - return new_gid; + return hpx::make_ready_future(new_gid); } /////////////////////////////////////////////////////////////////////// gid_type move_gid(gid_type& gid) { - gid_type::mutex_type::scoped_try_lock l(gid.get_mutex()); - if(l) - { - // move credit normally - return move_gid_locked(gid); - } - - // Just replenish the credit of the new gid and don't touch the - // local gid instance. This is less efficient than necessary but - // avoids deadlocks during serialization. - return replenish_new_gid_if_needed(gid); + gid_type::mutex_type::scoped_lock l(gid.get_mutex()); + return move_gid_locked(gid); } gid_type move_gid_locked(gid_type& gid) @@ -411,6 +437,11 @@ namespace hpx { namespace naming // serialization void id_type_impl::save(serialization::output_archive& ar) const { + if(ar.is_future_awaiting()) + { + preprocess_gid(ar); + return; + } // Avoid performing side effects if the archive is not saving the // data. if (ar.is_saving()) @@ -418,8 +449,23 @@ namespace hpx { namespace naming id_type_management type = type_; if (managed_move_credit == type) type = managed; + gid_type new_gid; + if (unmanaged == type_) + { + new_gid = *this; + } + else if(managed_move_credit == type_) + { + // all credits will be moved to the returned gid + new_gid = move_gid(const_cast(*this)); + } + else + { + new_gid = ar.get_new_gid(*this); + HPX_ASSERT(new_gid != invalid_gid); + } - gid_serialization_data data { preprocess_gid(), type }; + gid_serialization_data data { new_gid, type }; ar << data; } else diff --git a/src/runtime/parcelset/parcel.cpp b/src/runtime/parcelset/parcel.cpp index 9e76028b2d69..1dddc09b4c89 100644 --- a/src/runtime/parcelset/parcel.cpp +++ b/src/runtime/parcelset/parcel.cpp @@ -4,7 +4,7 @@ // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#include +#include #include #include diff --git a/src/runtime/parcelset/parcelhandler.cpp b/src/runtime/parcelset/parcelhandler.cpp index b05095df011a..bfdda5b229a3 100644 --- a/src/runtime/parcelset/parcelhandler.cpp +++ b/src/runtime/parcelset/parcelhandler.cpp @@ -122,7 +122,8 @@ namespace hpx { namespace parcelset } - void parcelhandler::initialize(naming::resolver_client &resolver, applier::applier *applier) + void parcelhandler::initialize(naming::resolver_client &resolver, + applier::applier *applier) { resolver_ = &resolver; @@ -344,12 +345,14 @@ namespace hpx { namespace parcelset void parcel_sent_handler(parcelhandler::write_handler_type f, boost::system::error_code const & ec, parcel const & p) { - // invoke the original handler - f(ec, p); - // inform termination detection of a sent message if (!p.does_termination_detection()) + { hpx::detail::dijkstra_make_black(); + } + + // invoke the original handler + f(ec, p); } } @@ -814,9 +817,11 @@ namespace hpx { namespace parcelset util::bind(&parcelhandler::get_receiving_time, this, pp_type, _1)); util::function_nonser sending_serialization_time( - util::bind(&parcelhandler::get_sending_serialization_time, this, pp_type, _1)); + util::bind(&parcelhandler::get_sending_serialization_time, + this, pp_type, _1)); util::function_nonser receiving_serialization_time( - util::bind(&parcelhandler::get_receiving_serialization_time, this, pp_type, _1)); + util::bind(&parcelhandler::get_receiving_serialization_time, + this, pp_type, _1)); #if defined(HPX_HAVE_SECURITY) util::function_nonser sending_security_time( @@ -835,15 +840,18 @@ namespace hpx { namespace parcelset util::bind(&parcelhandler::get_raw_data_received, this, pp_type, _1)); util::function_nonser buffer_allocate_time_sent( - util::bind(&parcelhandler::get_buffer_allocate_time_sent, this, pp_type, _1)); + util::bind(&parcelhandler::get_buffer_allocate_time_sent, + this, pp_type, _1)); util::function_nonser buffer_allocate_time_received( - util::bind(&parcelhandler::get_buffer_allocate_time_received, this, pp_type, _1)); + util::bind(&parcelhandler::get_buffer_allocate_time_received, + this, pp_type, _1)); performance_counters::generic_counter_type_data const counter_types[] = { { boost::str(boost::format("/parcels/count/%s/sent") % pp_type), performance_counters::counter_raw, - boost::str(boost::format("returns the number of parcels sent using the %s " + boost::str(boost::format("returns the number of \ + parcels sent using the %s " "connection type for the referenced locality") % pp_type), HPX_PERFORMANCE_COUNTER_V1, util::bind(&performance_counters::locality_raw_counter_creator, @@ -853,7 +861,8 @@ namespace hpx { namespace parcelset }, { boost::str(boost::format("/parcels/count/%s/received") % pp_type), performance_counters::counter_raw, - boost::str(boost::format("returns the number of parcels received using the %s " + boost::str(boost::format("returns the number of \ + parcels received using the %s " "connection type for the referenced locality") % pp_type), HPX_PERFORMANCE_COUNTER_V1, util::bind(&performance_counters::locality_raw_counter_creator, @@ -863,7 +872,8 @@ namespace hpx { namespace parcelset }, { boost::str(boost::format("/messages/count/%s/sent") % pp_type), performance_counters::counter_raw, - boost::str(boost::format("returns the number of messages sent using the %s " + boost::str(boost::format("returns the number of messages sent using \ + the %s " "connection type for the referenced locality") % pp_type), HPX_PERFORMANCE_COUNTER_V1, util::bind(&performance_counters::locality_raw_counter_creator, @@ -873,7 +883,8 @@ namespace hpx { namespace parcelset }, { boost::str(boost::format("/messages/count/%s/received") % pp_type), performance_counters::counter_raw, - boost::str(boost::format("returns the number of messages received using the %s " + boost::str(boost::format("returns the number of messages received using \ + the %s " "connection type for the referenced locality") % pp_type), HPX_PERFORMANCE_COUNTER_V1, util::bind(&performance_counters::locality_raw_counter_creator, @@ -945,7 +956,8 @@ namespace hpx { namespace parcelset { boost::str(boost::format("/security/time/%s/received") % pp_type), performance_counters::counter_raw, boost::str(boost::format("returns the total time required to perform " - "tasks related to security in the parcel layer for all received parcels " + "tasks related to security in the parcel layer for \ + all received parcels " "using the %s connection type for the referenced locality") % pp_type), HPX_PERFORMANCE_COUNTER_V1, @@ -969,7 +981,8 @@ namespace hpx { namespace parcelset { boost::str(boost::format("/data/count/%s/received") % pp_type), performance_counters::counter_raw, boost::str(boost::format("returns the amount of (uncompressed) parcel " - "argument data received using the %s connection type by the referenced " + "argument data received using the \ + %s connection type by the referenced " "locality") % pp_type), HPX_PERFORMANCE_COUNTER_V1, util::bind(&performance_counters::locality_raw_counter_creator, @@ -999,7 +1012,8 @@ namespace hpx { namespace parcelset &performance_counters::locality_counter_discoverer, "bytes" }, - { boost::str(boost::format("/parcels/time/%s/buffer_allocate/received") % pp_type), + { boost::str(boost::format("/parcels/time/%s/buffer_allocate/received") + % pp_type), performance_counters::counter_raw, boost::str(boost::format("returns the time needed to allocate the " "buffers for serializing using the %s connection type") % pp_type), @@ -1009,7 +1023,8 @@ namespace hpx { namespace parcelset &performance_counters::locality_counter_discoverer, "ns" }, - { boost::str(boost::format("/parcels/time/%s/buffer_allocate/sent") % pp_type), + { boost::str(boost::format("/parcels/time/%s/buffer_allocate/sent") + % pp_type), performance_counters::counter_raw, boost::str(boost::format("returns the time needed to allocate the " "buffers for serializing using the %s connection type") % pp_type), @@ -1043,9 +1058,11 @@ namespace hpx { namespace parcelset performance_counters::generic_counter_type_data const connection_cache_types[] = { - { boost::str(boost::format("/parcelport/count/%s/cache-insertions") % pp_type), + { boost::str(boost::format("/parcelport/count/%s/cache-insertions") + % pp_type), performance_counters::counter_raw, - boost::str(boost::format("returns the number of cache insertions while accessing " + boost::str(boost::format("returns the number of \ + cache insertions while accessing " "the connection cache for the %s connection type on the referenced " "locality") % pp_type), HPX_PERFORMANCE_COUNTER_V1, @@ -1054,9 +1071,11 @@ namespace hpx { namespace parcelset &performance_counters::locality_counter_discoverer, "" }, - { boost::str(boost::format("/parcelport/count/%s/cache-evictions") % pp_type), + { boost::str(boost::format("/parcelport/count/%s/cache-evictions") + % pp_type), performance_counters::counter_raw, - boost::str(boost::format("returns the number of cache evictions while accessing " + boost::str(boost::format("returns the number of \ + cache evictions while accessing " "the connection cache for the %s connection type on the referenced " "locality") % pp_type), HPX_PERFORMANCE_COUNTER_V1, @@ -1067,7 +1086,8 @@ namespace hpx { namespace parcelset }, { boost::str(boost::format("/parcelport/count/%s/cache-hits") % pp_type), performance_counters::counter_raw, - boost::str(boost::format("returns the number of cache hits while accessing " + boost::str(boost::format("returns the number of \ + cache hits while accessing " "the connection cache for the %s connection type on the referenced " "locality") % pp_type), HPX_PERFORMANCE_COUNTER_V1, @@ -1078,7 +1098,8 @@ namespace hpx { namespace parcelset }, { boost::str(boost::format("/parcelport/count/%s/cache-misses") % pp_type), performance_counters::counter_raw, - boost::str(boost::format("returns the number of cache misses while accessing " + boost::str(boost::format("returns the number of cache misses while \ + accessing " "the connection cache for the %s connection type on the referenced " "locality") % pp_type), HPX_PERFORMANCE_COUNTER_V1, @@ -1089,7 +1110,8 @@ namespace hpx { namespace parcelset }, { boost::str(boost::format("/parcelport/count/%s/cache-reclaims") % pp_type), performance_counters::counter_raw, - boost::str(boost::format("returns the number of cache reclaims while accessing " + boost::str(boost::format("returns the number of cache reclaims \ + while accessing " "the connection cache for the %s connection type on the referenced " "locality") % pp_type), HPX_PERFORMANCE_COUNTER_V1, diff --git a/src/runtime/parcelset/parcelport.cpp b/src/runtime/parcelset/parcelport.cpp index 4c1eebf11fed..09b3a99a6ae3 100644 --- a/src/runtime/parcelset/parcelport.cpp +++ b/src/runtime/parcelset/parcelport.cpp @@ -7,7 +7,7 @@ // This is needed to make everything work with the Intel MPI library header #include -#include +#include #include #include @@ -18,9 +18,6 @@ #include #include -#include -#include - namespace hpx { namespace parcelset { /////////////////////////////////////////////////////////////////////////// @@ -35,7 +32,8 @@ namespace hpx { namespace parcelset enable_security_(false), async_serialization_(false), enable_parcel_handling_(true), - priority_(hpx::util::get_entry_as(ini, "hpx.parcel." + type + ".priority", "0")), + priority_(hpx::util::get_entry_as(ini, "hpx.parcel." + type + ".priority", + "0")), type_(type) { std::string key("hpx.parcel."); @@ -46,7 +44,8 @@ namespace hpx { namespace parcelset allow_zero_copy_optimizations_ = false; } else { - if (hpx::util::get_entry_as(ini, key + ".zero_copy_optimization", "1") == 0) + if (hpx::util::get_entry_as(ini, key + ".zero_copy_optimization", + "1") == 0) allow_zero_copy_optimizations_ = false; } diff --git a/src/runtime/serialization/output_archive.cpp b/src/runtime/serialization/output_archive.cpp new file mode 100644 index 000000000000..b01e96c4e01c --- /dev/null +++ b/src/runtime/serialization/output_archive.cpp @@ -0,0 +1,34 @@ +// Copyright (c) 2015 Thomas Heller +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include +#include + +namespace hpx { namespace serialization +{ + void output_archive::add_gid( + naming::gid_type const & gid, + naming::gid_type const & splitted_gid) + { + if(new_gids_) + (*new_gids_)[gid].push_back(splitted_gid); + } + + naming::gid_type output_archive::get_new_gid(naming::gid_type const & gid) + { + if(!new_gids_) return naming::gid_type(); + + new_gids_map::iterator it = new_gids_->find(gid); + if(it == new_gids_->end() || it->second.empty()) + { + return gid; + } + + naming::gid_type new_gid = it->second.front(); + it->second.pop_front(); + return new_gid; + } + +}} diff --git a/src/runtime/threads/detail/thread_pool.cpp b/src/runtime/threads/detail/thread_pool.cpp index 4e7d0cc8330e..1ffa7e3c3bb1 100644 --- a/src/runtime/threads/detail/thread_pool.cpp +++ b/src/runtime/threads/detail/thread_pool.cpp @@ -980,6 +980,12 @@ namespace hpx { namespace threads { namespace detail /////////////////////////////////////////////////////////////////////////////// /// explicit template instantiation for the thread manager of our choice +#if defined(HPX_HAVE_THROTTLE_SCHEDULER) +#include +template class HPX_EXPORT hpx::threads::detail::thread_pool< + hpx::threads::policies::throttle_queue_scheduler<> >; +#endif + #if defined(HPX_HAVE_LOCAL_SCHEDULER) #include template class HPX_EXPORT hpx::threads::detail::thread_pool< diff --git a/src/runtime/threads/executors/thread_pool_executors.cpp b/src/runtime/threads/executors/thread_pool_executors.cpp index bcdcda328402..c565335ee057 100644 --- a/src/runtime/threads/executors/thread_pool_executors.cpp +++ b/src/runtime/threads/executors/thread_pool_executors.cpp @@ -12,6 +12,9 @@ #include #endif #include +#if defined(HPX_HAVE_THROTTLE_SCHEDULER) +#include +#endif #if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER) #include #endif @@ -434,6 +437,22 @@ namespace hpx { namespace threads { namespace executors {} #endif +#if defined(HPX_HAVE_THROTTLE_SCHEDULER) + /////////////////////////////////////////////////////////////////////////// + throttle_queue_executor::throttle_queue_executor() + : scheduled_executor(new detail::thread_pool_executor< + policies::throttle_queue_scheduler<> >( + get_os_thread_count(), 1)) + {} + + throttle_queue_executor::throttle_queue_executor( + std::size_t max_punits, std::size_t min_punits) + : scheduled_executor(new detail::thread_pool_executor< + policies::throttle_queue_scheduler<> >( + max_punits, min_punits)) + {} +#endif + /////////////////////////////////////////////////////////////////////////// local_priority_queue_executor::local_priority_queue_executor() : scheduled_executor(new detail::thread_pool_executor< diff --git a/src/runtime/threads/policies/hwloc_topology.cpp b/src/runtime/threads/policies/hwloc_topology.cpp index b868d51fcabc..fb816e639f79 100644 --- a/src/runtime/threads/policies/hwloc_topology.cpp +++ b/src/runtime/threads/policies/hwloc_topology.cpp @@ -1012,7 +1012,8 @@ namespace hpx { namespace threads return mask; } - mask_type hwloc_topology::get_cpubind_mask(boost::thread & handle, error_code& ec) const + mask_type hwloc_topology::get_cpubind_mask(boost::thread & handle, + error_code& ec) const { hwloc_cpuset_t cpuset = hwloc_bitmap_alloc(); diff --git a/src/runtime/threads/policies/parse_affinity_options.cpp b/src/runtime/threads/policies/parse_affinity_options.cpp index 15877abec39c..f41dc55ecf7b 100644 --- a/src/runtime/threads/policies/parse_affinity_options.cpp +++ b/src/runtime/threads/policies/parse_affinity_options.cpp @@ -319,7 +319,8 @@ namespace hpx { namespace threads { namespace detail resize(core_mask, size); std::size_t core_index = 0; - for (bounds_type::const_iterator it = b.begin(); it != b.end(); ++it, ++core_index) + for (bounds_type::const_iterator it = b.begin(); it != b.end(); + ++it, ++core_index) { if (index == std::size_t(-1) || core_index == index) { @@ -392,7 +393,8 @@ namespace hpx { namespace threads { namespace detail resize(mask, size); std::size_t socket_index = 0; - for (bounds_type::const_iterator it = b.begin(); it != b.end(); ++it, ++socket_index) + for (bounds_type::const_iterator it = b.begin(); it != b.end(); + ++it, ++socket_index) { if (index == std::size_t(-1) || socket_index == index) mask |= t.init_socket_affinity_mask_from_socket(std::size_t(*it)); @@ -429,7 +431,8 @@ namespace hpx { namespace threads { namespace detail resize(mask, size); std::size_t node_index = 0; - for (bounds_type::const_iterator it = b.begin(); it != b.end(); ++it, ++node_index) + for (bounds_type::const_iterator it = b.begin(); it != b.end(); + ++it, ++node_index) { if (index == std::size_t(-1) || node_index == index) mask |= t.init_numa_node_affinity_mask_from_numa_node(std::size_t(*it)); @@ -622,7 +625,8 @@ namespace hpx { namespace threads { namespace detail return; } - num_pus[num_thread] = t.get_pu_number(num_core + used_cores, num_pus_cores[num_core]); + num_pus[num_thread] = t.get_pu_number(num_core + used_cores, + num_pus_cores[num_core]); affinities[num_thread] = t.init_thread_affinity_mask( num_core + used_cores, num_pus_cores[num_core]++); diff --git a/src/runtime/threads/thread_data.cpp b/src/runtime/threads/thread_data.cpp index 52d4835fc3ac..f1ccc320028c 100644 --- a/src/runtime/threads/thread_data.cpp +++ b/src/runtime/threads/thread_data.cpp @@ -104,7 +104,8 @@ namespace hpx { namespace threads ran_exit_funcs_ = true; } - bool thread_data_base::add_thread_exit_callback(util::function_nonser const& f) + bool thread_data_base::add_thread_exit_callback(util + ::function_nonser const& f) { mutex_type::scoped_lock l(this); if (ran_exit_funcs_ || get_state() == terminated) diff --git a/src/runtime/threads/thread_helpers.cpp b/src/runtime/threads/thread_helpers.cpp index add8f7d5dca3..30bf1bb8c9cc 100644 --- a/src/runtime/threads/thread_helpers.cpp +++ b/src/runtime/threads/thread_helpers.cpp @@ -100,7 +100,8 @@ namespace hpx { namespace threads } /////////////////////////////////////////////////////////////////////////// - threads::thread_priority get_thread_priority(thread_id_type const& id, error_code& ec) + threads::thread_priority get_thread_priority(thread_id_type const& id, + error_code& ec) { hpx::applier::applier* app = hpx::applier::get_applier_ptr(); if (NULL == app) diff --git a/src/runtime/threads/threadmanager.cpp b/src/runtime/threads/threadmanager.cpp index 6f0432f2dde3..1a42940acf6b 100644 --- a/src/runtime/threads/threadmanager.cpp +++ b/src/runtime/threads/threadmanager.cpp @@ -1189,7 +1189,8 @@ namespace hpx { namespace threads #ifdef HPX_HAVE_THREAD_QUEUE_WAITTIME // average thread wait time for queue(s) { "/threads/wait-time/pending", performance_counters::counter_raw, - "returns the average wait time of pending threads for the referenced queue", + "returns the average wait time of \ + pending threads for the referenced queue", HPX_PERFORMANCE_COUNTER_V1, boost::bind(&ti::thread_wait_time_counter_creator, this, _1, _2), &performance_counters::locality_thread_counter_discoverer, @@ -1289,25 +1290,31 @@ namespace hpx { namespace threads "" }, { "/threads/count/instantaneous/active", performance_counters::counter_raw, - "returns the current number of active HPX-threads at the referenced locality", + "returns the current number of active \ + HPX-threads at the referenced locality", HPX_PERFORMANCE_COUNTER_V1, counts_creator, &performance_counters::locality_thread_counter_discoverer, "" }, { "/threads/count/instantaneous/pending", performance_counters::counter_raw, - "returns the current number of pending HPX-threads at the referenced locality", + "returns the current number of pending \ + HPX-threads at the referenced locality", HPX_PERFORMANCE_COUNTER_V1, counts_creator, &performance_counters::locality_thread_counter_discoverer, "" }, - { "/threads/count/instantaneous/suspended", performance_counters::counter_raw, - "returns the current number of suspended HPX-threads at the referenced locality", + { "/threads/count/instantaneous/suspended", + performance_counters::counter_raw, + "returns the current number of suspended \ + HPX-threads at the referenced locality", HPX_PERFORMANCE_COUNTER_V1, counts_creator, &performance_counters::locality_thread_counter_discoverer, "" }, - { "/threads/count/instantaneous/terminated", performance_counters::counter_raw, - "returns the current number of terminated HPX-threads at the referenced locality", + { "/threads/count/instantaneous/terminated", + performance_counters::counter_raw, + "returns the current number of terminated \ + HPX-threads at the referenced locality", HPX_PERFORMANCE_COUNTER_V1, counts_creator, &performance_counters::locality_thread_counter_discoverer, "" @@ -1544,6 +1551,12 @@ template class HPX_EXPORT hpx::threads::threadmanager_impl< hpx::threads::policies::static_queue_scheduler<> >; #endif +#if defined(HPX_HAVE_THROTTLE_SCHEDULER) +#include +template class HPX_EXPORT hpx::threads::threadmanager_impl< + hpx::threads::policies::throttle_queue_scheduler<> >; +#endif + #if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER) #include template class HPX_EXPORT hpx::threads::threadmanager_impl< diff --git a/src/runtime/threads/topology.cpp b/src/runtime/threads/topology.cpp index cbb527307a5f..05c3caa192d9 100644 --- a/src/runtime/threads/topology.cpp +++ b/src/runtime/threads/topology.cpp @@ -27,7 +27,8 @@ namespace hpx { namespace threads { - mask_type noop_topology::empty_mask = mask_type(noop_topology::hardware_concurrency()); + mask_type noop_topology::empty_mask = + mask_type(noop_topology::hardware_concurrency()); }} #else diff --git a/src/runtime_impl.cpp b/src/runtime_impl.cpp index ed3a78b47c41..aeacffb5f9ab 100644 --- a/src/runtime_impl.cpp +++ b/src/runtime_impl.cpp @@ -125,13 +125,16 @@ namespace hpx { : runtime(rtcfg, init_affinity), mode_(locality_mode), result_(0), num_threads_(num_threads), main_pool_(1, - boost::bind(&runtime_impl::init_tss, This(), "main-thread", ::_1, ::_2, false), + boost::bind(&runtime_impl::init_tss, This(), + "main-thread", ::_1, ::_2, false), boost::bind(&runtime_impl::deinit_tss, This()), "main_pool"), io_pool_(rtcfg.get_thread_pool_size("io_pool"), - boost::bind(&runtime_impl::init_tss, This(), "io-thread", ::_1, ::_2, true), + boost::bind(&runtime_impl::init_tss, This(), "io-thread", + ::_1, ::_2, true), boost::bind(&runtime_impl::deinit_tss, This()), "io_pool"), timer_pool_(rtcfg.get_thread_pool_size("timer_pool"), - boost::bind(&runtime_impl::init_tss, This(), "timer-thread", ::_1, ::_2, true), + boost::bind(&runtime_impl::init_tss, This(), "timer-thread", + ::_1, ::_2, true), boost::bind(&runtime_impl::deinit_tss, This()), "timer_pool"), scheduler_(init), notifier_(runtime_impl:: @@ -140,7 +143,8 @@ namespace hpx { new hpx::threads::threadmanager_impl( timer_pool_, scheduler_, notifier_, num_threads)), parcel_handler_(rtcfg, thread_manager_.get(), - boost::bind(&runtime_impl::init_tss, This(), "parcel-thread", ::_1, ::_2, true), + boost::bind(&runtime_impl::init_tss, This(), "parcel-thread", + ::_1, ::_2, true), boost::bind(&runtime_impl::deinit_tss, This())), agas_client_(parcel_handler_, ini_, mode_), init_logging_(ini_, mode_ == runtime_mode_console, agas_client_), @@ -343,6 +347,9 @@ namespace hpx { // set thread name as shown in Visual Studio util::set_thread_name("main-thread#wait_helper"); +#if defined(HPX_HAVE_APEX) + apex::register_thread("main-thread#wait_helper"); +#endif // wait for termination runtime_support_->wait(); @@ -597,6 +604,10 @@ namespace hpx { // set thread name as shown in Visual Studio util::set_thread_name(name); + +#if defined(HPX_HAVE_APEX) + apex::register_thread(name); +#endif } // if this is a service thread, set its service affinity @@ -742,6 +753,12 @@ template class HPX_EXPORT hpx::runtime_impl< hpx::threads::policies::static_queue_scheduler<> >; #endif +#if defined(HPX_HAVE_THROTTLE_SCHEDULER) +#include +template class HPX_EXPORT hpx::runtime_impl< + hpx::threads::policies::throttle_queue_scheduler<> >; +#endif + #if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER) #include template class HPX_EXPORT hpx::runtime_impl< diff --git a/src/util/asio_util.cpp b/src/util/asio_util.cpp index cbc96ecce944..6324dd96f4cc 100644 --- a/src/util/asio_util.cpp +++ b/src/util/asio_util.cpp @@ -156,7 +156,8 @@ namespace hpx { namespace util } - endpoint_iterator_type connect_begin(std::string const & address, boost::uint16_t port, + endpoint_iterator_type connect_begin(std::string const & address, + boost::uint16_t port, boost::asio::io_service& io_service) { using boost::asio::ip::tcp; @@ -206,7 +207,8 @@ namespace hpx { namespace util return endpoint_iterator_type(); } - endpoint_iterator_type accept_begin(std::string const & address, boost::uint16_t port, + endpoint_iterator_type accept_begin(std::string const & address, + boost::uint16_t port, boost::asio::io_service& io_service) { using boost::asio::ip::tcp; diff --git a/src/util/backtrace/backtrace.cpp b/src/util/backtrace/backtrace.cpp index 870a33fedd6d..846f7df0c27e 100644 --- a/src/util/backtrace/backtrace.cpp +++ b/src/util/backtrace/backtrace.cpp @@ -20,7 +20,8 @@ #include -#if (defined(__linux) || defined(__APPLE__) || defined(__sun)) && (!defined(__ANDROID__) || !defined(ANDROID)) +#if (defined(__linux) || defined(__APPLE__) || defined(__sun)) \ + && (!defined(__ANDROID__) || !defined(ANDROID)) #define BOOST_HAVE_EXECINFO #define BOOST_HAVE_DLFCN #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) && !defined(__clang__) @@ -64,7 +65,8 @@ namespace hpx { namespace util { namespace stack_trace { -#if defined(BOOST_HAVE_EXECINFO) && defined(BOOST_HAVE_UNWIND) && defined(BOOST_HAVE_EXECINFO) +#if defined(BOOST_HAVE_EXECINFO) && defined(BOOST_HAVE_UNWIND) && \ + defined(BOOST_HAVE_EXECINFO) struct trace_data { @@ -161,7 +163,8 @@ namespace hpx { namespace util { return std::string(); std::ostringstream res; res.imbue(std::locale::classic()); - res << std::left << std::setw(sizeof(void*)*2) << std::setfill(' ') << ptr <<": "; + res << std::left << std::setw(sizeof(void*)*2) << std::setfill(' ') + << ptr <<": "; Dl_info info = {0, 0, 0, 0}; if(dladdr(ptr,&info) == 0) { res << "???"; @@ -182,7 +185,8 @@ namespace hpx { namespace util { res << "???"; } - std::ptrdiff_t offset = reinterpret_cast(ptr) - reinterpret_cast(info.dli_saddr); + std::ptrdiff_t offset = reinterpret_cast(ptr) + - reinterpret_cast(info.dli_saddr); res << std::hex <<" + 0x" << offset ; if(info.dli_fname) @@ -191,9 +195,11 @@ namespace hpx { namespace util { return res.str(); } - HPX_BACKTRACE_DECL std::string get_symbols(void *const *addresses,std::size_t size) + HPX_BACKTRACE_DECL std::string get_symbols(void *const *addresses, + std::size_t size) { - std::string res = boost::lexical_cast(size) + ((1==size)?" frame:":" frames:"); + std::string res = boost::lexical_cast(size) + + ((1==size)?" frame:":" frames:"); for(std::size_t i=0;i(size) + ((1==size)?" frame:":" frames:"); + std::string res = boost::lexical_cast(size) + + ((1==size)?" frame:":" frames:"); for(std::size_t i=0;i(size) + ((1==size)?" frame:":" frames:"); + std::string res = boost::lexical_cast(size) + + ((1==size)?" frame:":" frames:"); for(std::size_t i=0;i("hpx.cores", num_threads); + std::size_t num_cores = cfgmap.get_value("hpx.cores", + num_threads); if (vm.count("hpx:cores")) { cores_str = vm["hpx:cores"].as(); if ("all" == cores_str) diff --git a/src/util/coroutine/detail/context_generic_context.cpp b/src/util/coroutine/detail/context_generic_context.cpp index 79015fbd860c..6aa5f73e07fc 100644 --- a/src/util/coroutine/detail/context_generic_context.cpp +++ b/src/util/coroutine/detail/context_generic_context.cpp @@ -56,7 +56,8 @@ namespace hpx { namespace util { namespace coroutines } } - fcontext_context_impl::counter_type& fcontext_context_impl::get_stack_unbind_counter() + fcontext_context_impl::counter_type& fcontext_context_impl + ::get_stack_unbind_counter() { static counter_type counter(0); return counter; @@ -70,7 +71,8 @@ namespace hpx { namespace util { namespace coroutines return ++get_stack_unbind_counter(); } - fcontext_context_impl::counter_type& fcontext_context_impl::get_stack_recycle_counter() + fcontext_context_impl::counter_type& fcontext_context_impl + ::get_stack_recycle_counter() { static counter_type counter(0); return counter; diff --git a/src/util/coroutine/swapcontext.cpp b/src/util/coroutine/swapcontext.cpp index b62f371239ba..7d111a2e51a0 100644 --- a/src/util/coroutine/swapcontext.cpp +++ b/src/util/coroutine/swapcontext.cpp @@ -8,7 +8,8 @@ #if !defined(HPX_HAVE_GENERIC_CONTEXT_COROUTINES) -#if (defined(__linux) || defined(linux) || defined(__linux__)) && !defined(__bgq__) && !defined(__powerpc__) +#if (defined(__linux) || defined(linux) || defined(__linux__)) \ + && !defined(__bgq__) && !defined(__powerpc__) #if defined(__x86_64__) || defined(__amd64__) #include "swapcontext64.ipp" diff --git a/src/util/ini.cpp b/src/util/ini.cpp index 084f0a6fc388..0250890bc30d 100644 --- a/src/util/ini.cpp +++ b/src/util/ini.cpp @@ -52,7 +52,8 @@ const char pattern_comment[] = "^([^#]*)(#.*)$"; const char pattern_section[] = "^\\[([^\\]]+)\\]$"; // example uses ini line: sec.ssec.key = val -const char pattern_qualified_entry[] = "^([^\\s=]+)\\.([^\\s=\\.]+)\\s*=\\s*(.*[^\\s]?)\\s*$"; +const char pattern_qualified_entry[] = +"^([^\\s=]+)\\.([^\\s=\\.]+)\\s*=\\s*(.*[^\\s]?)\\s*$"; // example uses ini line: key = val const char pattern_entry[] = "^([^\\s=]+)\\s*=\\s*(.*[^\\s]?)\\s*$"; @@ -210,8 +211,10 @@ void section::parse (std::string const& sourcename, int linenum = 0; section* current = this; - boost::regex regex_comment (pattern_comment, boost::regex::perl | boost::regex::icase); - boost::regex regex_section (pattern_section, boost::regex::perl | boost::regex::icase); + boost::regex regex_comment (pattern_comment, boost::regex::perl + | boost::regex::icase); + boost::regex regex_section (pattern_section, boost::regex::perl + | boost::regex::icase); boost::regex regex_qualified_entry (pattern_qualified_entry, boost::regex::perl | boost::regex::icase); boost::regex regex_entry (pattern_entry, boost::regex::perl | boost::regex::icase); @@ -662,7 +665,8 @@ void section::expand_bracket(std::string& value, std::string::size_type begin) c std::string to_expand = value.substr(begin+2, end-begin-2); std::string::size_type colon = find_next(":", to_expand); if (colon == std::string::npos) { - value.replace(begin, end-begin+1, root_->get_entry(to_expand, std::string(""))); + value.replace(begin, end-begin+1, root_->get_entry(to_expand, + std::string(""))); } else { value.replace(begin, end-begin+1, diff --git a/src/util/init_ini_data.cpp b/src/util/init_ini_data.cpp index 3234c6389c58..fbe372a0e0a1 100644 --- a/src/util/init_ini_data.cpp +++ b/src/util/init_ini_data.cpp @@ -92,7 +92,8 @@ namespace hpx { namespace util bool result = false; for (tokenizer_type::iterator it = tok_paths.begin (); it != end_paths; ++it) { std::string path = *it; - for (tokenizer_type::iterator jt = tok_suffixes.begin (); jt != end_suffixes; ++jt) { + for (tokenizer_type::iterator jt = tok_suffixes.begin (); + jt != end_suffixes; ++jt) { path += *jt; bool result2 = handle_ini_file (ini, path + "/hpx.ini"); if (result2) { diff --git a/src/util/itt_notify.cpp b/src/util/itt_notify.cpp index 94166d578c68..b2e9de18c062 100644 --- a/src/util/itt_notify.cpp +++ b/src/util/itt_notify.cpp @@ -169,12 +169,18 @@ bool use_ittnotify_api = false; #endif /////////////////////////////////////////////////////////////////////////////// -#define HPX_INTERNAL_ITT_SYNC_PREPARE(obj) HPX_INTERNAL_ITT_SYNC(sync_prepare, obj) -#define HPX_INTERNAL_ITT_SYNC_CANCEL(obj) HPX_INTERNAL_ITT_SYNC(sync_cancel, obj) -#define HPX_INTERNAL_ITT_SYNC_ACQUIRED(obj) HPX_INTERNAL_ITT_SYNC(sync_acquired, obj) -#define HPX_INTERNAL_ITT_SYNC_RELEASING(obj) HPX_INTERNAL_ITT_SYNC(sync_releasing, obj) -#define HPX_INTERNAL_ITT_SYNC_RELEASED(obj) ((void)0) //HPX_INTERNAL_ITT_SYNC(sync_released, obj) -#define HPX_INTERNAL_ITT_SYNC_DESTROY(obj) HPX_INTERNAL_ITT_SYNC(sync_destroy, obj) +#define HPX_INTERNAL_ITT_SYNC_PREPARE(obj)\ + HPX_INTERNAL_ITT_SYNC(sync_prepare, obj) +#define HPX_INTERNAL_ITT_SYNC_CANCEL(obj)\ + HPX_INTERNAL_ITT_SYNC(sync_cancel, obj) +#define HPX_INTERNAL_ITT_SYNC_ACQUIRED(obj)\ + HPX_INTERNAL_ITT_SYNC(sync_acquired, obj) +#define HPX_INTERNAL_ITT_SYNC_RELEASING(obj)\ + HPX_INTERNAL_ITT_SYNC(sync_releasing, obj) +#define HPX_INTERNAL_ITT_SYNC_RELEASED(obj)\ + ((void)0) //HPX_INTERNAL_ITT_SYNC(sync_released, obj) +#define HPX_INTERNAL_ITT_SYNC_DESTROY(obj)\ + HPX_INTERNAL_ITT_SYNC(sync_destroy, obj) /////////////////////////////////////////////////////////////////////////////// void itt_sync_create(void *addr, const char* objtype, const char* objname) @@ -325,7 +331,8 @@ void itt_heap_allocate_begin(__itt_heap_function f, std::size_t size, int init) HPX_INTERNAL_HEAP_ALLOCATE_BEGIN(f, size, init); } -void itt_heap_allocate_end(__itt_heap_function f, void** addr, std::size_t size, int init) +void itt_heap_allocate_end(__itt_heap_function f, void** addr, + std::size_t size, int init) { HPX_INTERNAL_HEAP_ALLOCATE_END(f, addr, size, init); } @@ -340,12 +347,14 @@ void itt_heap_free_end(__itt_heap_function f, void* addr) HPX_INTERNAL_HEAP_FREE_END(f, addr); } -void itt_heap_reallocate_begin(__itt_heap_function f, void* addr, std::size_t new_size, int init) +void itt_heap_reallocate_begin(__itt_heap_function f, void* addr, + std::size_t new_size, int init) { HPX_INTERNAL_HEAP_REALLOCATE_BEGIN(f, addr, new_size, init); } -void itt_heap_reallocate_end(__itt_heap_function f, void* addr, void** new_addr, std::size_t new_size, int init) +void itt_heap_reallocate_end(__itt_heap_function f, void* addr, + void** new_addr, std::size_t new_size, int init) { HPX_INTERNAL_HEAP_REALLOCATE_END(f, addr, new_addr, new_size, init); } diff --git a/src/util/lightweight_test.cpp b/src/util/lightweight_test.cpp index fa600a9cc293..fb962fbba140 100644 --- a/src/util/lightweight_test.cpp +++ b/src/util/lightweight_test.cpp @@ -3,8 +3,8 @@ // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#include #include +#include namespace hpx { namespace util { namespace detail { diff --git a/src/util/logging.cpp b/src/util/logging.cpp index 5e8ade404a52..424b0ad79164 100644 --- a/src/util/logging.cpp +++ b/src/util/logging.cpp @@ -323,7 +323,8 @@ namespace hpx { namespace util if (0 != component_id) { // called from inside a HPX thread std::stringstream out; - out << std::hex << std::setw(sizeof(boost::uint64_t)*2) << std::setfill('0') + out << std::hex << std::setw(sizeof(boost::uint64_t)*2) + << std::setfill('0') << component_id; str.prepend_string(out.str()); } @@ -608,7 +609,8 @@ namespace hpx { namespace util hpx_level()->set_enabled(lvl); // errors are logged to the given destination and to cerr - error_writer.add_destination("console", console(lvl, destination_hpx)); //-V106 + error_writer.add_destination("console", console(lvl, destination_hpx)); + //-V106 #if !defined(ANDROID) && !defined(__ANDROID__) if (logdest != "cerr") error_writer.write(logformat, logdest + " cerr"); @@ -621,7 +623,8 @@ namespace hpx { namespace util else { // errors are always logged to cerr if (!isconsole) { - error_writer.add_destination("console", console(lvl, destination_hpx)); //-V106 + error_writer.add_destination("console", console(lvl, + destination_hpx)); //-V106 error_writer.write(logformat, "console"); } else { @@ -736,7 +739,8 @@ namespace hpx { namespace util if (logformat.empty()) logformat = "|\\n"; - writer.add_destination("console", console(lvl, destination_debuglog)); //-V106 + writer.add_destination("console", console(lvl, destination_debuglog)); + //-V106 writer.write(logformat, logdest); detail::define_formatters(writer); @@ -948,7 +952,8 @@ namespace hpx { namespace util std::string loglevel, logdest, logformat; if (ini.has_section("hpx.logging.console.application")) { - util::section const* logini = ini.get_section("hpx.logging.console.application"); + util::section const* logini = + ini.get_section("hpx.logging.console.application"); HPX_ASSERT(NULL != logini); std::string empty; @@ -996,7 +1001,8 @@ namespace hpx { namespace util std::string loglevel, logdest, logformat; if (ini.has_section("hpx.logging.console.debuglog")) { - util::section const* logini = ini.get_section("hpx.logging.console.debuglog"); + util::section const* logini = + ini.get_section("hpx.logging.console.debuglog"); HPX_ASSERT(NULL != logini); std::string empty; @@ -1070,7 +1076,8 @@ namespace hpx { namespace util { namespace detail #if defined(ANDROID) || defined(__ANDROID__) "destination = ${HPX_CONSOLE_LOGDESTINATION:android_log}", #else - "destination = ${HPX_CONSOLE_LOGDESTINATION:file(hpx.$[system.pid].log)}", + "destination = ${HPX_CONSOLE_LOGDESTINATION:\ + file(hpx.$[system.pid].log)}", #endif "format = ${HPX_CONSOLE_LOGFORMAT:|}", @@ -1089,7 +1096,8 @@ namespace hpx { namespace util { namespace detail #if defined(ANDROID) || defined(__ANDROID__) "destination = ${HPX_CONSOLE_TIMING_LOGDESTINATION:android_log}", #else - "destination = ${HPX_CONSOLE_TIMING_LOGDESTINATION:file(hpx.timing.$[system.pid].log)}", + "destination = \ + ${HPX_CONSOLE_TIMING_LOGDESTINATION:file(hpx.timing.$[system.pid].log)}", #endif "format = ${HPX_CONSOLE_TIMING_LOGFORMAT:|}", @@ -1097,7 +1105,8 @@ namespace hpx { namespace util { namespace detail "[hpx.logging.agas]", "level = ${HPX_AGAS_LOGLEVEL:-1}", // "destination = ${HPX_AGAS_LOGDESTINATION:console}", - "destination = ${HPX_AGAS_LOGDESTINATION:file(hpx.agas.$[system.pid].log)}", + "destination = \ + ${HPX_AGAS_LOGDESTINATION:file(hpx.agas.$[system.pid].log)}", "format = ${HPX_AGAS_LOGFORMAT:" "(T%locality%/%hpxthread%.%hpxphase%/%hpxcomponent%) " "P%parentloc%/%hpxparent%.%hpxparentphase% %time%(" HPX_TIMEFORMAT @@ -1109,14 +1118,16 @@ namespace hpx { namespace util { namespace detail #if defined(ANDROID) || defined(__ANDROID__) "destination = ${HPX_CONSOLE_AGAS_LOGDESTINATION:android_log}", #else - "destination = ${HPX_CONSOLE_AGAS_LOGDESTINATION:file(hpx.agas.$[system.pid].log)}", + "destination = ${HPX_CONSOLE_AGAS_LOGDESTINATION:file\ + (hpx.agas.$[system.pid].log)}", #endif "format = ${HPX_CONSOLE_AGAS_LOGFORMAT:|}", // logging related to the parcel transport "[hpx.logging.parcel]", "level = ${HPX_PARCEL_LOGLEVEL:-1}", - "destination = ${HPX_PARCEL_LOGDESTINATION:file(hpx.parcel.$[system.pid].log)}", + "destination = ${HPX_PARCEL_LOGDESTINATION:file\ + (hpx.parcel.$[system.pid].log)}", "format = ${HPX_PARCEL_LOGFORMAT:" "(T%locality%/%hpxthread%.%hpxphase%/%hpxcomponent%) " "P%parentloc%/%hpxparent%.%hpxparentphase% %time%(" HPX_TIMEFORMAT @@ -1128,7 +1139,8 @@ namespace hpx { namespace util { namespace detail #if defined(ANDROID) || defined(__ANDROID__) "destination = ${HPX_CONSOLE_PARCEL_LOGDESTINATION:android_log}", #else - "destination = ${HPX_CONSOLE_PARCEL_LOGDESTINATION:file(hpx.parcel.$[system.pid].log)}", + "destination = ${HPX_CONSOLE_PARCEL_LOGDESTINATION:file\ + (hpx.parcel.$[system.pid].log)}", #endif "format = ${HPX_CONSOLE_PARCEL_LOGFORMAT:|}", @@ -1147,7 +1159,8 @@ namespace hpx { namespace util { namespace detail #if defined(ANDROID) || defined(__ANDROID__) "destination = ${HPX_CONSOLE_APP_LOGDESTINATION:android_log}", #else - "destination = ${HPX_CONSOLE_APP_LOGDESTINATION:file(hpx.application.$[system.pid].log)}", + "destination = ${HPX_CONSOLE_APP_LOGDESTINATION:file\ + (hpx.application.$[system.pid].log)}", #endif "format = ${HPX_CONSOLE_APP_LOGFORMAT:|}", @@ -1165,7 +1178,8 @@ namespace hpx { namespace util { namespace detail #if defined(ANDROID) || defined(__ANDROID__) "destination = ${HPX_CONSOLE_DEB_LOGDESTINATION:android_log}", #else - "destination = ${HPX_CONSOLE_DEB_LOGDESTINATION:file(hpx.debuglog.$[system.pid].log)}", + "destination = ${HPX_CONSOLE_DEB_LOGDESTINATION:file\ + (hpx.debuglog.$[system.pid].log)}", #endif "format = ${HPX_CONSOLE_DEB_LOGFORMAT:|}" ; diff --git a/src/util/parse_command_line.cpp b/src/util/parse_command_line.cpp index 358c46f3bc76..4009b3f65c08 100644 --- a/src/util/parse_command_line.cpp +++ b/src/util/parse_command_line.cpp @@ -342,7 +342,8 @@ namespace hpx { namespace util hpx_options.add_options() ("hpx:worker", "run this instance in worker mode") ("hpx:console", "run this instance in console mode") - ("hpx:connect", "run this instance in worker mode, but connecting late") + ("hpx:connect", "run this instance in worker mode,\ + but connecting late") ; break; @@ -355,7 +356,8 @@ namespace hpx { namespace util hidden_options.add_options() ("hpx:worker", "run this instance in worker mode") ("hpx:console", "run this instance in console mode") - ("hpx:connect", "run this instance in worker mode, but connecting late") + ("hpx:connect", "run this instance in worker mode,\ + but connecting late") ; break; @@ -506,7 +508,8 @@ namespace hpx { namespace util counter_options.add_options() ("hpx:print-counter", value >()->composing(), "print the specified performance counter either repeatedly or " - "before shutting down the system (see option --hpx:print-counter-interval)") + "before shutting down the system \ + (see option --hpx:print-counter-interval)") ("hpx:print-counter-interval", value(), "print the performance counter(s) specified with --hpx:print-counter " "repeatedly after the time interval (specified in milliseconds) " @@ -519,7 +522,8 @@ namespace hpx { namespace util "possible values:\n" " 'minimal' (prints counter name skeletons)\n" " 'full' (prints all available counter names)") - ("hpx:list-counter-infos", value()->implicit_value("minimal"), + ("hpx:list-counter-infos", + value()->implicit_value("minimal"), "list the description of all registered performance counters, " "possible values:\n" " 'minimal' (prints infos for counter name skeletons)\n" @@ -689,7 +693,8 @@ namespace hpx { namespace util if (cfg.has_entry("hpx.cmd_line")) cmdline = cfg.get_entry("hpx.cmd_line"); if (cfg.has_entry("hpx.locality")) - node = hpx::util::safe_lexical_cast(cfg.get_entry("hpx.locality")); + node = hpx::util::safe_lexical_cast + (cfg.get_entry("hpx.locality")); return parse_commandline(cfg, app_options, cmdline, vm, node, allow_unregistered); diff --git a/src/util/query_counters.cpp b/src/util/query_counters.cpp index 681824ff489d..7d47f1a6e268 100644 --- a/src/util/query_counters.cpp +++ b/src/util/query_counters.cpp @@ -27,7 +27,8 @@ namespace hpx { namespace util query_counters::query_counters(std::vector const& names, boost::int64_t interval, std::string const& dest, std::string const& form, std::vector const& shortnames, bool csv_header) - : names_(names), destination_(dest), format_(form), counter_shortnames_(shortnames), csv_header_(csv_header), + : names_(names), destination_(dest), format_(form), + counter_shortnames_(shortnames), csv_header_(csv_header), timer_(boost::bind(&query_counters::evaluate, this_()), boost::bind(&query_counters::terminate, this_()), interval*1000, "query_counters", true) diff --git a/src/util/register_locks_globally.cpp b/src/util/register_locks_globally.cpp index 8874c810cd02..b40fe72953f7 100644 --- a/src/util/register_locks_globally.cpp +++ b/src/util/register_locks_globally.cpp @@ -80,7 +80,8 @@ namespace hpx { namespace util { using detail::register_locks_globally; - if (register_locks_globally::lock_detection_enabled_ && 0 != threads::get_self_ptr()) + if (register_locks_globally::lock_detection_enabled_ + && 0 != threads::get_self_ptr()) { register_locks_globally::held_locks_map& held_locks = register_locks_globally::get_lock_map(); @@ -106,7 +107,8 @@ namespace hpx { namespace util { using detail::register_locks_globally; - if (register_locks_globally::lock_detection_enabled_ && 0 != threads::get_self_ptr()) + if (register_locks_globally::lock_detection_enabled_ + && 0 != threads::get_self_ptr()) { register_locks_globally::held_locks_map& held_locks = register_locks_globally::get_lock_map(); diff --git a/src/util/runtime_configuration.cpp b/src/util/runtime_configuration.cpp index 2237d4ab3f8c..200be07340cf 100644 --- a/src/util/runtime_configuration.cpp +++ b/src/util/runtime_configuration.cpp @@ -55,8 +55,10 @@ #endif /////////////////////////////////////////////////////////////////////////////// -#if defined(__linux) || defined(linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) -namespace hpx { namespace util { namespace coroutines { namespace detail { namespace posix +#if defined(__linux) || defined(linux) || defined(__linux__)\ + || defined(__FreeBSD__) || defined(__APPLE__) +namespace hpx { namespace util { namespace coroutines +{ namespace detail { namespace posix { /////////////////////////////////////////////////////////////////////////// // this global (urghhh) variable is used to control whether guard pages @@ -497,7 +499,8 @@ namespace hpx { namespace util if(NULL != sec) { return hpx::util::get_entry_as( - *sec, "data_buffer_cache_size", HPX_PARCEL_IPC_DATA_BUFFER_CACHE_SIZE); + *sec, "data_buffer_cache_size", + HPX_PARCEL_IPC_DATA_BUFFER_CACHE_SIZE); } } return HPX_PARCEL_IPC_DATA_BUFFER_CACHE_SIZE; @@ -600,7 +603,8 @@ namespace hpx { namespace util return cache_size; } - std::size_t runtime_configuration::get_agas_local_cache_size_per_thread(std::size_t dflt) const + std::size_t runtime_configuration + ::get_agas_local_cache_size_per_thread(std::size_t dflt) const { std::size_t cache_size = dflt; @@ -648,7 +652,8 @@ namespace hpx { namespace util util::section const* sec = get_section("hpx.agas"); if (NULL != sec) { return hpx::util::get_entry_as( - *sec, "max_pending_refcnt_requests", HPX_INITIAL_AGAS_MAX_PENDING_REFCNT_REQUESTS); + *sec, "max_pending_refcnt_requests", + HPX_INITIAL_AGAS_MAX_PENDING_REFCNT_REQUESTS); } } return HPX_INITIAL_AGAS_MAX_PENDING_REFCNT_REQUESTS; diff --git a/src/util/security/root_certificate_authority.cpp b/src/util/security/root_certificate_authority.cpp index 0db0d07ef9ba..d09422b62041 100644 --- a/src/util/security/root_certificate_authority.cpp +++ b/src/util/security/root_certificate_authority.cpp @@ -51,11 +51,13 @@ namespace hpx { namespace util { namespace security components::security::signed_certificate root_certificate_authority::sign_certificate_signing_request( - components::security::signed_certificate_signing_request const & signed_csr) const + components::security::signed_certificate_signing_request + const & signed_csr) const { HPX_ASSERT(0 != root_certificate_authority_); - // Bind the certificate_authority_sign_certificate_signing_request symbol dynamically and invoke it. + // Bind the certificate_authority_sign_certificate_signing_request + // symbol dynamically and invoke it. typedef void (*function_type)( components::security::server::certificate_authority_base* , components::security::signed_certificate_signing_request const & @@ -90,7 +92,8 @@ namespace hpx { namespace util { namespace security return components::security::signed_certificate::invalid_signed_type; } - // Bind the certificate_authority_get_certificate symbol dynamically and invoke it. + // Bind the certificate_authority_get_certificate symbol dynamically and + // invoke it. typedef void (*function_type)( components::security::server::certificate_authority_base* , components::security::signed_certificate*); diff --git a/src/util/security/subordinate_certificate_authority.cpp b/src/util/security/subordinate_certificate_authority.cpp index 3cb204f33368..2b4a9984f840 100644 --- a/src/util/security/subordinate_certificate_authority.cpp +++ b/src/util/security/subordinate_certificate_authority.cpp @@ -18,7 +18,8 @@ namespace hpx { namespace util { namespace security { subordinate_certificate_authority::~subordinate_certificate_authority() { - // Bind the delete_subordinate_certificate_authority symbol dynamically and invoke it. + // Bind the delete_subordinate_certificate_authority symbol dynamically + // and invoke it. typedef void (*function_type)(certificate_authority_type*); typedef boost::function deleter_type; @@ -33,7 +34,8 @@ namespace hpx { namespace util { namespace security void subordinate_certificate_authority::initialize() { - // Bind the new_subordinate_certificate_authority symbol dynamically and invoke it. + // Bind the new_subordinate_certificate_authority symbol dynamically + // and invoke it. typedef certificate_authority_type* (*function_type)( components::security::key_pair const&); typedef boost::function deleter_type; @@ -53,7 +55,8 @@ namespace hpx { namespace util { namespace security { HPX_ASSERT(0 != subordinate_certificate_authority_); - // Bind the certificate_authority_sign_certificate_signing_request symbol dynamically and invoke it. + // Bind the certificate_authority_sign_certificate_signing_request + // symbol dynamically and invoke it. typedef void (*function_type)( components::security::server::subordinate_certificate_authority* , components::security::signed_certificate_signing_request*); @@ -75,11 +78,13 @@ namespace hpx { namespace util { namespace security components::security::signed_certificate subordinate_certificate_authority::sign_certificate_signing_request( - components::security::signed_certificate_signing_request const & signed_csr) const + components::security::signed_certificate_signing_request const & signed_csr) + const { HPX_ASSERT(0 != subordinate_certificate_authority_); - // Bind the certificate_authority_sign_certificate_signing_request symbol dynamically and invoke it. + // Bind the certificate_authority_sign_certificate_signing_request + // symbol dynamically and invoke it. typedef void (*function_type)( components::security::server::certificate_authority_base* , components::security::signed_certificate_signing_request const & @@ -108,7 +113,8 @@ namespace hpx { namespace util { namespace security { HPX_ASSERT(0 != subordinate_certificate_authority_); - // Bind the subordinate_certificate_authority_set_certificate symbol dynamically and invoke it. + // Bind the subordinate_certificate_authority_set_certificate symbol + // dynamically and invoke it. typedef void (*function_type)( components::security::server::subordinate_certificate_authority* , components::security::signed_certificate const &); @@ -136,7 +142,8 @@ namespace hpx { namespace util { namespace security return components::security::signed_certificate::invalid_signed_type; } - // Bind the certificate_authority_get_certificate symbol dynamically and invoke it. + // Bind the certificate_authority_get_certificate symbol dynamically + // and invoke it. typedef void (*function_type)( components::security::server::certificate_authority_base* , components::security::signed_certificate*); diff --git a/src/util/set_thread_name.cpp b/src/util/set_thread_name.cpp index 182ecb3aded2..bc06efb5c090 100644 --- a/src/util/set_thread_name.cpp +++ b/src/util/set_thread_name.cpp @@ -37,7 +37,8 @@ namespace hpx { namespace util __try { - RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info); + RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), + (ULONG_PTR*)&info); } __except(EXCEPTION_EXECUTE_HANDLER) { diff --git a/src/util/thread_mapper.cpp b/src/util/thread_mapper.cpp index 1f53120198f8..99698c18d291 100644 --- a/src/util/thread_mapper.cpp +++ b/src/util/thread_mapper.cpp @@ -110,7 +110,8 @@ namespace hpx { namespace util { boost::lock_guard m(mtx_); - return (tix < thread_info_.size())? thread_info_[tix].tid_: invalid_tid; //-V104 //-V108 + return (tix < thread_info_.size())? thread_info_[tix].tid_: + invalid_tid; //-V104 //-V108 } std::string const& thread_mapper::get_thread_label(boost::uint32_t tix) const diff --git a/src/version.cpp b/src/version.cpp index 76610eb6eccd..41af07f51473 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -95,11 +95,13 @@ namespace hpx { char const* const copyright = "HPX - High Performance ParalleX\n" - "A general purpose parallel C++ runtime system for distributed applications\n" + "A general purpose parallel C++ runtime system for\ + distributed applications\n" "of any scale.\n\n" "Copyright (c) 2007-2015, The STE||AR Group,\n" "http://stellar-group.org, email:hpx-users@stellar.cct.lsu.edu\n\n" - "Distributed under the Boost Software License, Version 1.0. (See accompanying\n" + "Distributed under the Boost Software License, \ + Version 1.0. (See accompanying\n" "file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n"; return copyright; } diff --git a/tests/performance/local/foreach_scaling.cpp b/tests/performance/local/foreach_scaling.cpp index a767f48e211f..2e40323b7e46 100644 --- a/tests/performance/local/foreach_scaling.cpp +++ b/tests/performance/local/foreach_scaling.cpp @@ -181,7 +181,8 @@ int hpx_main(boost::program_options::variables_map& vm) << std::left << "Average task execution time : " << std::right << std::setw(8) << task_time/1e9 << "\n" << std::left << "Average sequential execution time: " - << std::right << std::setw(8) << seq_time/1e9 << "\n" << hpx::flush; + << std::right << std::setw(8) << seq_time/1e9 << "\n" + << hpx::flush; hpx::cout << "---------Execution Time Difference---------\n" << std::left << "Parallel Scale: " << std::right << std::setw(27) diff --git a/tests/performance/local/hpx_homogeneous_timed_task_spawn_executors.cpp b/tests/performance/local/hpx_homogeneous_timed_task_spawn_executors.cpp index 0029939cac9d..b914001b7631 100644 --- a/tests/performance/local/hpx_homogeneous_timed_task_spawn_executors.cpp +++ b/tests/performance/local/hpx_homogeneous_timed_task_spawn_executors.cpp @@ -76,12 +76,14 @@ int hpx_main( throw std::invalid_argument("number of executors to use must be larger than 0"); if (std::size_t(num_executors) > num_os_threads) - throw std::invalid_argument("number of executors to use must be smaller than number of OS threads"); + throw std::invalid_argument("number of executors to use must be \ + smaller than number of OS threads"); std::size_t num_cores_per_executor = vm["cores"].as(); if ((num_executors - 1) * num_cores_per_executor > num_os_threads) - throw std::invalid_argument("number of cores per executor should not cause oversubscription"); + throw std::invalid_argument("number of cores per executor should not \ + cause oversubscription"); if (0 == tasks) throw std::invalid_argument("count of 0 tasks specified\n"); diff --git a/tests/performance/local/spinlock_overhead1.cpp b/tests/performance/local/spinlock_overhead1.cpp index 3af205a10316..15f294f72f5e 100644 --- a/tests/performance/local/spinlock_overhead1.cpp +++ b/tests/performance/local/spinlock_overhead1.cpp @@ -234,7 +234,8 @@ int hpx_main( ) << flush; else - cout << ( boost::format("invoked %1% futures in %2% seconds (k1 = %3%, k2 = %4%)\n") + cout << ( boost::format("invoked %1% futures in %2% seconds \ + (k1 = %3%, k2 = %4%)\n") % count % duration % k1 diff --git a/tests/performance/local/spinlock_overhead2.cpp b/tests/performance/local/spinlock_overhead2.cpp index c45513c120a7..fd0a14cbdb98 100644 --- a/tests/performance/local/spinlock_overhead2.cpp +++ b/tests/performance/local/spinlock_overhead2.cpp @@ -262,7 +262,8 @@ int hpx_main( ) << flush; else - cout << ( boost::format("invoked %1% futures in %2% seconds (k1 = %3%, k2 = %4%, k3 = %5%)\n") + cout << ( boost::format("invoked %1% futures in %2% seconds \ + (k1 = %3%, k2 = %4%, k3 = %5%)\n") % count % duration % k1 diff --git a/tests/performance/network/network_storage/network_storage.cpp b/tests/performance/network/network_storage/network_storage.cpp index 8f03b9e35f6d..c6705646b568 100644 --- a/tests/performance/network/network_storage/network_storage.cpp +++ b/tests/performance/network/network_storage/network_storage.cpp @@ -239,7 +239,8 @@ typedef hpx::serialization::serialize_buffer general_buffer_type; // copying of data by providing a receive buffer with a fixed data pointer // so that data is placed directly into it. typedef pointer_allocator PointerAllocator; -typedef hpx::serialization::serialize_buffer transfer_buffer_type; +typedef hpx::serialization::serialize_buffer transfer_buffer_type; //---------------------------------------------------------------------------- // @@ -274,13 +275,16 @@ namespace Storage { { // we must allocate a temporary buffer to copy from storage into // we can't use the remote buffer supplied because it is a handle to memory on - // the (possibly) remote node. We allocate here using a NULL deleter so the array will + // the (possibly) remote node. We allocate here using + // a NULL deleter so the array will // not be released by the shared_pointer std::allocator local_allocator; - boost::shared_array local_buffer(local_allocator.allocate(length), [](char*){}); + boost::shared_array local_buffer(local_allocator.allocate(length), + [](char*){}); // allow the storage class to asynchronously copy the data into buffer - hpx::future fut = copy_from_local_storage(local_buffer.get(), address, length); + hpx::future fut = copy_from_local_storage(local_buffer.get(), + address, length); // wrap the remote buffer pointer in an allocator for return pointer_allocator return_allocator( @@ -440,9 +444,11 @@ void test_write( hpx::id_type locality = hpx::naming::get_id_from_locality_id(send_rank); // pick a random slot to write our data into int memory_slot = random_slot(gen); - uint32_t memory_offset = static_cast(memory_slot*options.transfer_size_B); + uint32_t memory_offset = static_cast + (memory_slot*options.transfer_size_B); DEBUG_OUTPUT(5, - std::cout << "Rank " << rank << " sending block " << i << " to rank " << send_rank << std::endl; + std::cout << "Rank " << rank << " sending block " + << i << " to rank " << send_rank << std::endl; ); // Execute a PUT on whatever locality we chose @@ -451,7 +457,8 @@ void test_write( // background thread removing completed futures doesn't collide { DEBUG_OUTPUT(5, - std::cout << "Put from rank " << rank << " on rank " << send_rank << std::endl; + std::cout << "Put from rank " << rank << " on rank " + << send_rank << std::endl; ); #ifdef USE_CLEANING_THREAD ++FuturesWaiting[send_rank]; @@ -482,7 +489,8 @@ void test_write( // wait for cleanup thread to terminate before we reduce any remaining futures removed = cleaner.get(); DEBUG_OUTPUT(2, - std::cout << "Cleaning thread rank " << rank << " removed " << removed << std::endl; + std::cout << "Cleaning thread rank " << rank << " removed " + << removed << std::endl; ); #endif // @@ -503,13 +511,15 @@ void test_write( result.get(); int total = numwait+removed; DEBUG_OUTPUT(3, - std::cout << "Future timer, rank " << rank << " waiting on " << numwait << " total " << total << " " + std::cout << "Future timer, rank " << rank + << " waiting on " << numwait << " total " << total << " " << futuretimer.elapsed() << " Move time " << movetime << std::endl; ); } barrier_wait(); // - double writeMB = static_cast(nranks*options.local_storage_MB*options.iterations); + double writeMB = static_cast + (nranks*options.local_storage_MB*options.iterations); double writeTime = timerWrite.elapsed(); double writeBW = writeMB / writeTime; double IOPS = static_cast(options.iterations*num_transfer_slots); @@ -521,8 +531,11 @@ void test_write( std::cout << "IOPs/s : " << IOPs_s << "\n"; std::cout << "Aggregate BW Write : " << writeBW << "MB/s" << std::endl; // a complete set of results that our python matplotlib script will ingest - char const* msg = "CSVData, write, network, %1%, ranks, %2%, threads, %3%, Memory, %4%, IOPsize, %5%, IOPS/s, %6%, BW(MB/s), %7%, "; - std::cout << (boost::format(msg) % options.network % nranks % options.threads % writeMB % options.transfer_size_B + char const* msg = "CSVData, write, network, \ + %1%, ranks, %2%, threads, %3%, Memory, %4%, IOPsize, %5%, \ + IOPS/s, %6%, BW(MB/s), %7%, "; + std::cout << (boost::format(msg) % options.network + % nranks % options.threads % writeMB % options.transfer_size_B % IOPs_s % writeBW ) << std::endl; } } @@ -605,7 +618,8 @@ void test_read( // pick a random slot to write our data into int memory_slot = random_slot(gen); - uint32_t memory_offset = static_cast(memory_slot*options.transfer_size_B); + uint32_t memory_offset = + static_cast(memory_slot*options.transfer_size_B); // create a transfer buffer object to receive the data being returned to us @@ -623,11 +637,13 @@ void test_read( boost::lock_guard lk(FuturesMutex); #endif using hpx::util::placeholders::_1; - std::size_t buffer_address = reinterpret_cast(general_buffer.data()); + std::size_t buffer_address = + reinterpret_cast(general_buffer.data()); // ActiveFutures[send_rank].push_back( hpx::async( - actRead, locality, memory_offset, options.transfer_size_B, buffer_address + actRead, locality, memory_offset, + options.transfer_size_B, buffer_address ).then( hpx::launch::sync, hpx::util::bind(&transfer_data, general_buffer, _1) @@ -652,7 +668,8 @@ void test_read( // futures int removed = cleaner.get(); DEBUG_OUTPUT(2, - std::cout << "Cleaning thread rank " << rank << " removed " << removed << std::endl; + std::cout << "Cleaning thread rank " << rank << " removed " + << removed << std::endl; ); #endif // @@ -673,13 +690,15 @@ void test_read( result.get(); int total = numwait+removed; DEBUG_OUTPUT(3, - std::cout << "Future timer, rank " << rank << " waiting on " << numwait << " total " << total << " " + std::cout << "Future timer, rank " << rank << " waiting on " + << numwait << " total " << total << " " << futuretimer.elapsed() << " Move time " << movetime << std::endl; ); } barrier_wait(); // - double readMB = static_cast(nranks*options.local_storage_MB*options.iterations); + double readMB = static_cast + (nranks*options.local_storage_MB*options.iterations); double readTime = timerRead.elapsed(); double readBW = readMB / readTime; double IOPS = static_cast(options.iterations*num_transfer_slots); @@ -691,8 +710,11 @@ void test_read( std::cout << "IOPs/s : " << IOPs_s << "\n"; std::cout << "Aggregate BW Read : " << readBW << "MB/s" << std::endl; // a complete set of results that our python matplotlib script will ingest - char const* msg = "CSVData, read, network, %1%, ranks, %2%, threads, %3%, Memory, %4%, IOPsize, %5%, IOPS/s, %6%, BW(MB/s), %7%, "; - std::cout << (boost::format(msg) % options.network % nranks % options.threads % readMB % options.transfer_size_B + char const* msg = "CSVData, read, network, %1%, ranks, \ + %2%, threads, %3%, Memory, %4%, IOPsize, %5%, IOPS/s, %6%, \ + BW(MB/s), %7%, "; + std::cout << (boost::format(msg) % options.network % nranks + % options.threads % readMB % options.transfer_size_B % IOPs_s % readBW ) << std::endl; } } @@ -739,12 +761,15 @@ int hpx_main(boost::program_options::variables_map& vm) // if (nranks>MAX_RANKS) { std::cerr << "This test can only be run using " << MAX_RANKS - << " nodes, please recompile this test with the MAX_RANKS set to a higher number " << std::endl; + << " nodes, please recompile this test with the \ + MAX_RANKS set to a higher number " << std::endl; return 1; } - char const* msg = "hello world from OS-thread %1% on locality %2% rank %3% hostname %4%"; - std::cout << (boost::format(msg) % current % hpx::get_locality_id() % rank % name.c_str()) << std::endl; + char const* msg = "hello world from OS-thread %1% on locality \ + %2% rank %3% hostname %4%"; + std::cout << (boost::format(msg) % current % hpx::get_locality_id() + % rank % name.c_str()) << std::endl; // // extract command line argument test_options options; @@ -763,14 +788,17 @@ int hpx_main(boost::program_options::variables_map& vm) } allocate_local_storage(options.local_storage_MB*1024*1024); // - uint64_t num_transfer_slots = 1024*1024*options.local_storage_MB / options.transfer_size_B; + uint64_t num_transfer_slots = 1024*1024*options.local_storage_MB + / options.transfer_size_B; DEBUG_OUTPUT(1, - std::cout << "num ranks " << nranks << ", num_transfer_slots " << num_transfer_slots << " on rank " << rank << std::endl; + std::cout << "num ranks " << nranks << ", num_transfer_slots " + << num_transfer_slots << " on rank " << rank << std::endl; ); // boost::random::mt19937 gen; boost::random::uniform_int_distribution<> random_rank(0, (int)nranks - 1); - boost::random::uniform_int_distribution<> random_slot(0, (int)num_transfer_slots - 1); + boost::random::uniform_int_distribution<> random_slot(0, + (int)num_transfer_slots - 1); // ActiveFutures.reserve(nranks); for(uint64_t i = 0; i < nranks; i++) { @@ -838,7 +866,8 @@ int main(int argc, char* argv[]) desc_commandline.add_options() ( "all-to-all", boost::program_options::value()->default_value(true), - "When set, all ranks send to all others, when off, only rank 0 send to the others.\n") + "When set, all ranks send to all others, when off, \ + only rank 0 send to the others.\n") ; // if the user does not set parceltype on the command line, @@ -848,15 +877,18 @@ int main(int argc, char* argv[]) boost::program_options::value()->default_value("unknown"), "Pass in the parcelport network type being tested," "this value has no effect on the code and is used only in output " - "so that plotting scripts know what network type was active during the test.\n") + "so that plotting scripts know what network type was active during \ + the test.\n") ; desc_commandline.add_options() ( "distribution", boost::program_options::value()->default_value(1), "Specify the distribution of data blocks to send/receive,\n" - "in random mode, blocks of data are sent from one rank to any other rank (including itself)," - "in block-cyclic mode, blocks of data are sent from one rank to other ranks in block-cyclic order," + "in random mode, blocks of data are sent from one rank to \ + any other rank (including itself)," + "in block-cyclic mode, blocks of data are sent from one rank to \ + other ranks in block-cyclic order," "0 : random \n" "1 : block cyclic") ; diff --git a/tests/performance/network/osu/broadcast.hpp b/tests/performance/network/osu/broadcast.hpp index 5d95bc0b5498..a4df184a481a 100644 --- a/tests/performance/network/osu/broadcast.hpp +++ b/tests/performance/network/osu/broadcast.hpp @@ -69,7 +69,8 @@ namespace hpx { namespace lcos if(bcast_ids.size() > 0) { - hpx::id_type locality = hpx::naming::get_locality_from_id(bcast_ids[0]); + hpx::id_type locality = + hpx::naming::get_locality_from_id(bcast_ids[0]); Action act; bcast_future = @@ -92,7 +93,8 @@ namespace hpx { namespace lcos ready_promise = hpx::lcos::local::promise(); } - return bcast_future.then(hpx::util::bind(&broadcast::when_dst, this)); + return bcast_future.then(hpx::util::bind(&broadcast::when_dst, + this)); } } @@ -155,10 +157,12 @@ namespace hpx { namespace lcos hpx::id_type dst = hpx::naming::get_locality_from_id(next[0]); broadcast_futures.push_back( - hpx::async(dst, std::move(next), fun, fan_out) + hpx::async(dst, std::move(next), + fun, fan_out) ); /* - hpx::apply(dst, std::move(next), fun, fan_out); + hpx::apply(dst, std::move(next), + fun, fan_out); */ } diff --git a/tests/performance/network/osu/osu_bcast.cpp b/tests/performance/network/osu/osu_bcast.cpp index bd5b7d3bf619..97d82dc22f79 100644 --- a/tests/performance/network/osu/osu_bcast.cpp +++ b/tests/performance/network/osu/osu_bcast.cpp @@ -28,7 +28,8 @@ struct broadcast_component broadcast_component() {} - void init(std::vector const & id, std::size_t max_msg_size, std::size_t fan_out) + void init(std::vector const & id, std::size_t max_msg_size, + std::size_t fan_out) { bcast.this_id = this->get_id(); bcast.fan_out = fan_out; @@ -47,7 +48,8 @@ struct broadcast_component { hpx::util::high_resolution_timer t; - recv_buffer = bcast(ids, 0, buffer_type(&send_buffer[0], size, buffer_type::reference)).get(); + recv_buffer = bcast(ids, 0, buffer_type(&send_buffer[0], size, + buffer_type::reference)).get(); double t_elapsed = t.elapsed(); if(i >= skip) @@ -83,7 +85,8 @@ void run_benchmark(params const & p) if(ids.size() < 2) { - hpx::cout << "This benchmark must be run with at least 2 threads" << hpx::endl << hpx::flush; + hpx::cout << "This benchmark must be run with at least 2 threads" + << hpx::endl << hpx::flush; return; } @@ -93,7 +96,8 @@ void run_benchmark(params const & p) for (hpx::id_type const& id : ids) { init_futures.push_back( - hpx::async(id, ids, p.max_msg_size, p.fan_out) + hpx::async(id, ids, + p.max_msg_size, p.fan_out) ); } hpx::wait_all(init_futures); @@ -124,7 +128,8 @@ void run_benchmark(params const & p) times.push_back(f.get()); } - double avg_latency = std::accumulate(times.begin(), times.end(), 0.0) / ids.size(); + double avg_latency = std::accumulate(times.begin(), times.end(), 0.0) + / ids.size(); print_data(avg_latency, size, iterations); } diff --git a/tests/performance/network/osu/osu_bibw.cpp b/tests/performance/network/osu/osu_bibw.cpp index cf569d8d528e..233e83004082 100644 --- a/tests/performance/network/osu/osu_bibw.cpp +++ b/tests/performance/network/osu/osu_bibw.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2013 Hartmut Kaiser +// Copyright (c) 2013-2015 Hartmut Kaiser // Copyright (c) 2013 Thomas Heller // // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -8,10 +8,10 @@ #include #include -#include +#include +#include -#include -#include +#include /////////////////////////////////////////////////////////////////////////////// #define LOOP_SMALL 100 @@ -35,23 +35,27 @@ void isend(hpx::serialization::serialize_buffer const& receive_buffer) {} HPX_PLAIN_ACTION(isend); /////////////////////////////////////////////////////////////////////////////// -std::vector > +hpx::future send_async(hpx::naming::id_type dest, std::size_t size, std::size_t window_size) { - std::vector > lazy_results; - lazy_results.reserve(window_size); + typedef hpx::serialization::serialize_buffer buffer_type; - isend_action send; - for (std::size_t j = 0; j < window_size; ++j) - { - typedef hpx::serialization::serialize_buffer buffer_type; + using hpx::parallel::for_each; + using hpx::parallel::par; + using hpx::parallel::task; - // Note: The original benchmark uses MPI_Isend which does not - // create a copy of the passed buffer. - lazy_results.push_back(hpx::async(send, dest, - buffer_type(send_buffer, size, buffer_type::reference))); - } - return lazy_results; + std::size_t const start = 0; + + auto range = boost::irange(start, window_size); + return for_each( + par(task), boost::begin(range), boost::end(range), + [=](boost::uint64_t j) + { + // Note: The original benchmark uses MPI_Isend which does not + // create a copy of the passed buffer. + isend_action send; + send(dest, buffer_type(send_buffer, size, buffer_type::reference)); + }); } /////////////////////////////////////////////////////////////////////////////// @@ -63,26 +67,33 @@ hpx::serialization::serialize_buffer irecv(std::size_t size) HPX_PLAIN_ACTION(irecv); /////////////////////////////////////////////////////////////////////////////// -std::vector > > +hpx::future recv_async(hpx::naming::id_type dest, std::size_t size, std::size_t window_size) { typedef hpx::serialization::serialize_buffer buffer_type; - std::vector > lazy_results; - lazy_results.reserve(window_size); - irecv_action recv; - for (std::size_t j = 0; j < window_size; ++j) - { - lazy_results.push_back(hpx::async(recv, dest, size)); - } - return lazy_results; + + using hpx::parallel::for_each; + using hpx::parallel::par; + using hpx::parallel::task; + + std::size_t const start = 0; + + auto range = boost::irange(start, window_size); + return for_each( + par(task), boost::begin(range), boost::end(range), + [=](boost::uint64_t j) + { + irecv_action recv; + recv(dest, size); + }); } /////////////////////////////////////////////////////////////////////////////// -void print_header () +void print_header() { hpx::cout << "# OSU HPX Bi-Directional Test\n" - << "# Size Bandwidth (MB/s)\n" - << hpx::flush; + << "# Size Bandwidth (MB/s)" + << std::endl; } /////////////////////////////////////////////////////////////////////////////// @@ -110,26 +121,22 @@ void run_benchmark(boost::program_options::variables_map & vm) } hpx::util::high_resolution_timer t; + for(std::size_t i = 0; i < loop + skip; ++i) { - if(i == skip) t.restart(); + if (i == skip) // don't measure during warm-up phase + t.restart(); - typedef hpx::serialization::serialize_buffer buffer_type; - hpx::future > >recv_futures - = hpx::async(&recv_async, there, size, window_size); + hpx::future recv = + hpx::async(recv_async, there, size, window_size); - hpx::future > > send_futures - = hpx::async(&send_async, there, size, window_size); + send_async(there, size, window_size); - /* - std::vector recv_results; - recv_results.reserve(window_size); - */ - hpx::wait_all(recv_futures.get());//, recv_results); - hpx::wait_all(send_futures.get()); + recv.wait(); } - double bw = (size / 1e6 * loop * window_size * 2)/ t.elapsed(); - hpx::cout << std::left << std::setw(10) << size << bw << hpx::endl << hpx::flush; + double bw = (size / 1e6 * loop * window_size * 2) / t.elapsed(); + + hpx::cout << std::left << std::setw(10) << size << bw << std::endl; } } diff --git a/tests/performance/network/osu/osu_bw.cpp b/tests/performance/network/osu/osu_bw.cpp index 3f42410f1502..f1b938ac9faa 100644 --- a/tests/performance/network/osu/osu_bw.cpp +++ b/tests/performance/network/osu/osu_bw.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2013 Hartmut Kaiser +// Copyright (c) 2013-2015 Hartmut Kaiser // Copyright (c) 2013 Thomas Heller // // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -6,14 +6,13 @@ // Unidirectional network bandwidth test -#include #include #include -#include -#include +#include +#include +#include -#include -#include +#include #include /////////////////////////////////////////////////////////////////////////////// @@ -32,7 +31,6 @@ unsigned long getpagesize() #endif /////////////////////////////////////////////////////////////////////////////// - #define LOOP_SMALL_MULTIPLIER 5 #define SKIP 2 @@ -62,10 +60,10 @@ double ireceive(hpx::naming::id_type dest, std::size_t loop, // align used buffers on page boundaries unsigned long align_size = getpagesize(); (void)align_size; - BOOST_ASSERT(align_size <= MAX_ALIGNMENT); + HPX_ASSERT(align_size <= MAX_ALIGNMENT); - char *send_buffer = new char[size]; - std::memset(send_buffer, 'a', size); + boost::scoped_array send_buffer(new char[size]); + std::memset(send_buffer.get(), 'a', size); hpx::util::high_resolution_timer t; @@ -80,30 +78,26 @@ double ireceive(hpx::naming::id_type dest, std::size_t loop, std::size_t const start = 0; - // Fill the original matrix, set transpose to known garbage value. auto range = boost::irange(start, window_size); for_each(par, boost::begin(range), boost::end(range), [&](boost::uint64_t j) { - send(dest, - buffer_type(send_buffer, size, buffer_type::reference)); + send(dest, buffer_type( + send_buffer.get(), size, buffer_type::reference)); } ); } double elapsed = t.elapsed(); - - delete[] send_buffer; - return (size / 1e6 * loop * window_size) / elapsed; } /////////////////////////////////////////////////////////////////////////////// -void print_header () +void print_header() { hpx::cout << "# OSU HPX Bandwidth Test\n" - << "# Size Bandwidth (MB/s)\n" - << hpx::flush; + << "# Size Bandwidth (MB/s)" + << std::endl; } void run_benchmark(boost::program_options::variables_map & vm) diff --git a/tests/performance/network/osu/osu_coll.hpp b/tests/performance/network/osu/osu_coll.hpp index f3a25958ec5e..37ac91f49318 100644 --- a/tests/performance/network/osu/osu_coll.hpp +++ b/tests/performance/network/osu/osu_coll.hpp @@ -70,12 +70,14 @@ void print_data(double elapsed, std::size_t size, std::size_t iterations) } inline std::pair > -distribute_component(std::vector localities, hpx::components::component_type type); +distribute_component(std::vector localities, + hpx::components::component_type type); HPX_PLAIN_ACTION(distribute_component); inline std::pair > -distribute_component(std::vector localities, hpx::components::component_type type) +distribute_component(std::vector localities, + hpx::components::component_type type) { typedef hpx::util::remote_locality_result value_type; typedef std::pair > result_type; @@ -106,8 +108,10 @@ distribute_component(std::vector localities, hpx::components::comp if(localities.size() > 1) { std::size_t half = (localities.size() / 2) + 1; - std::vector locs_first(localities.begin() + 1, localities.begin() + half); - std::vector locs_second(localities.begin() + half, localities.end()); + std::vector locs_first(localities.begin() + + 1, localities.begin() + half); + std::vector locs_second(localities.begin() + half, + localities.end()); if(locs_first.size() > 0) diff --git a/tests/performance/network/osu/osu_latency.cpp b/tests/performance/network/osu/osu_latency.cpp index 110b3acd13d3..08657625a367 100644 --- a/tests/performance/network/osu/osu_latency.cpp +++ b/tests/performance/network/osu/osu_latency.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2013 Hartmut Kaiser +// Copyright (c) 2013-2015 Hartmut Kaiser // Copyright (c) 2013 Thomas Heller // // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -6,14 +6,12 @@ // Bidirectional network bandwidth test -#include #include #include -#include -#include +#include +#include -#include -#include +#include #include /////////////////////////////////////////////////////////////////////////////// @@ -25,9 +23,6 @@ #define LOOP_LARGE 100 #define SKIP_LARGE 10 - -char *send_buffer_orig; - /////////////////////////////////////////////////////////////////////////////// char* align_buffer (char* ptr, unsigned long align_size) { @@ -56,7 +51,6 @@ HPX_REGISTER_BASE_LCO_WITH_VALUE_DECLARATION( HPX_REGISTER_BASE_LCO_WITH_VALUE( hpx::serialization::serialize_buffer, serialization_buffer_char); - /////////////////////////////////////////////////////////////////////////////// double receive( hpx::naming::id_type dest, @@ -83,7 +77,6 @@ double receive( std::size_t const start = 0; - // Fill the original matrix, set transpose to known garbage value. auto range = boost::irange(start, window_size); for_each(par, boost::begin(range), boost::end(range), [&](boost::uint64_t j) @@ -99,11 +92,11 @@ double receive( } /////////////////////////////////////////////////////////////////////////////// -void print_header () +void print_header() { hpx::cout << "# OSU HPX Latency Test\n" - << "# Size Latency (microsec)\n" - << hpx::flush; + << "# Size Latency (microsec)" + << std::endl; } /////////////////////////////////////////////////////////////////////////////// @@ -126,19 +119,18 @@ void run_benchmark(boost::program_options::variables_map & vm) // align used buffers on page boundaries unsigned long align_size = getpagesize(); - //BOOST_ASSERT(align_size <= MAX_ALIGNMENT); - send_buffer_orig = new char[max_size + align_size]; - char* send_buffer = align_buffer(send_buffer_orig, align_size); + boost::scoped_array send_buffer_orig(new char[max_size + align_size]); + char* send_buffer = align_buffer(send_buffer_orig.get(), align_size); - hpx::util::high_resolution_timer timer; // perform actual measurements + hpx::util::high_resolution_timer timer; + for (std::size_t size = min_size; size <= max_size; size *= 2) { double latency = receive(there, send_buffer, size, loop, window_size); hpx::cout << std::left << std::setw(10) << size << latency << hpx::endl << hpx::flush; } - hpx::cout << "Total time: " << timer.elapsed_nanoseconds() << "\n" << hpx::flush; - delete[] send_buffer_orig; + hpx::cout << "Total time: " << timer.elapsed_nanoseconds() << std::endl; } diff --git a/tests/performance/network/osu/osu_multi_lat.cpp b/tests/performance/network/osu/osu_multi_lat.cpp index 8b1416e531fa..5bafe0dd9b66 100644 --- a/tests/performance/network/osu/osu_multi_lat.cpp +++ b/tests/performance/network/osu/osu_multi_lat.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2013 Hartmut Kaiser +// Copyright (c) 2013-2015 Hartmut Kaiser // Copyright (c) 2013 Thomas Heller // // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -6,13 +6,15 @@ // Multi latency network test -#include #include #include -#include +#include +#include +#include -#include -#include +#include + +#include /////////////////////////////////////////////////////////////////////////////// #define LOOP_SMALL 10000 @@ -65,7 +67,7 @@ double ireceive(hpx::naming::id_type dest, std::size_t size, std::size_t window_ // align used buffers on page boundaries unsigned long align_size = getpagesize(); - BOOST_ASSERT(align_size <= MAX_ALIGNMENT); + HPX_ASSERT(align_size <= MAX_ALIGNMENT); char* aligned_send_buffer = align_buffer(send_buffer, align_size); std::memset(aligned_send_buffer, 'a', size); @@ -79,16 +81,19 @@ double ireceive(hpx::naming::id_type dest, std::size_t size, std::size_t window_ t.restart(); typedef hpx::serialization::serialize_buffer buffer_type; - std::vector > send_futures; - send_futures.reserve(window_size); - for(std::size_t j = 0; j < window_size; ++j) - { - send_futures.push_back( - hpx::async(send, dest, buffer_type(aligned_send_buffer, size, - buffer_type::reference)) - ); - } - hpx::wait_all(send_futures); + + using hpx::parallel::for_each; + using hpx::parallel::par; + + std::size_t const start = 0; + + auto range = boost::irange(start, window_size); + for_each(par, boost::begin(range), boost::end(range), + [&](boost::uint64_t j) + { + send(dest, buffer_type(aligned_send_buffer, size, + buffer_type::reference)); + }); } double elapsed = t.elapsed(); @@ -100,22 +105,23 @@ HPX_PLAIN_ACTION(ireceive); void print_header() { hpx::cout << "# OSU HPX Multi Latency Test\n" - << "# Size Latency (microsec)\n" - << hpx::flush; + << "# Size Latency (microsec)" + << std::endl; } /////////////////////////////////////////////////////////////////////////////// void run_benchmark(boost::program_options::variables_map & vm) { std::vector localities = hpx::find_all_localities(); - + std::size_t window_size = vm["window-size"].as(); std::size_t pairs = localities.size() / 2; for (std::size_t size = 1; size <= MAX_MSG_SIZE; size *= 2) { std::vector > benchmarks; - for (boost::uint32_t locality_id = 0; locality_id != localities.size(); ++locality_id) + for (boost::uint32_t locality_id = 0; locality_id != + localities.size(); ++locality_id) { ireceive_action receive; @@ -126,16 +132,16 @@ void run_benchmark(boost::program_options::variables_map & vm) partner = locality_id - pairs; benchmarks.push_back(hpx::async(receive, - localities[locality_id], localities[partner], size, vm["window-size"].as())); + localities[locality_id], localities[partner], size, + window_size)); } - double total_latency = 0; - - hpx::wait_all(benchmarks); - for (hpx::future& f : benchmarks) - { - total_latency += f.get(); - } + double total_latency = std::accumulate( + benchmarks.begin(), benchmarks.end(), 0.0, + [](double sum, hpx::future& f) + { + return sum + f.get(); + }); hpx::cout << std::left << std::setw(10) << size << total_latency / (2. * pairs) diff --git a/tests/performance/network/osu/osu_scatter.cpp b/tests/performance/network/osu/osu_scatter.cpp index 399a631ccbd2..f3cf52c992db 100644 --- a/tests/performance/network/osu/osu_scatter.cpp +++ b/tests/performance/network/osu/osu_scatter.cpp @@ -15,10 +15,12 @@ #include -void scatter(std::vector const & localities, hpx::serialization::serialize_buffer buffer, std::size_t chunk_size); +void scatter(std::vector const & localities, + hpx::serialization::serialize_buffer buffer, std::size_t chunk_size); HPX_PLAIN_ACTION(scatter); -void scatter(std::vector const & localities, hpx::serialization::serialize_buffer buffer, std::size_t chunk_size) +void scatter(std::vector const & localities, + hpx::serialization::serialize_buffer buffer, std::size_t chunk_size) { std::vector > scatter_futures; scatter_futures.reserve(localities.size() / chunk_size); @@ -66,7 +68,8 @@ void run_benchmark(params const & p) if(localities.size() < 2) { - hpx::cout << "This benchmark must be run with at least 2 localities" << hpx::endl << hpx::flush; + hpx::cout << "This benchmark must be run with at least 2 localities" + << hpx::endl << hpx::flush; return; } @@ -87,7 +90,8 @@ void run_benchmark(params const & p) hpx::util::high_resolution_timer t; typedef hpx::serialization::serialize_buffer buffer_type; hpx::id_type dst = localities[0]; - scatter_action()(dst, localities, buffer_type(&send_buffer[0], size, buffer_type::reference), p.chunk_size); + scatter_action()(dst, localities, buffer_type(&send_buffer[0], + size, buffer_type::reference), p.chunk_size); double t_elapsed = t.elapsed(); if(i >= skip) elapsed += t_elapsed; diff --git a/tests/regressions/actions/component_action_move_semantics.cpp b/tests/regressions/actions/component_action_move_semantics.cpp index 30b0d4af62c6..01015cf5e8af 100644 --- a/tests/regressions/actions/component_action_move_semantics.cpp +++ b/tests/regressions/actions/component_action_move_semantics.cpp @@ -158,14 +158,16 @@ void test_actions() //FIXME: bumped number for intel compiler HPX_TEST_RANGE(( return_object< - action_move_semantics::return_test_non_movable_action, non_movable_object + action_move_semantics::return_test_non_movable_action, + non_movable_object >(id) ), 1u, 5u); // ?call + set_value + ?return } else { //FIXME: bumped number for intel compiler HPX_TEST_RANGE(( return_object< - action_move_semantics::return_test_non_movable_action, non_movable_object + action_move_semantics::return_test_non_movable_action, + non_movable_object >(id) ), 4u, 8u); // transfer_action + bind + function + ?call + // set_value + ?return @@ -216,25 +218,29 @@ void test_direct_actions() { HPX_TEST_EQ(( pass_object< - action_move_semantics::test_non_movable_direct_action, non_movable_object + action_move_semantics::test_non_movable_direct_action, + non_movable_object >(id) ), 0u); HPX_TEST_EQ(( move_object< - action_move_semantics::test_non_movable_direct_action, non_movable_object + action_move_semantics::test_non_movable_direct_action, + non_movable_object >(id) ), 0u); } else { HPX_TEST_EQ(( pass_object< - action_move_semantics::test_non_movable_direct_action, non_movable_object + action_move_semantics::test_non_movable_direct_action, + non_movable_object >(id) ), 3u); // transfer_action + bind + function HPX_TEST_EQ(( move_object< - action_move_semantics::test_non_movable_direct_action, non_movable_object + action_move_semantics::test_non_movable_direct_action, + non_movable_object >(id) ), 3u); // transfer_action + bind + function } @@ -244,13 +250,15 @@ void test_direct_actions() { HPX_TEST_EQ(( return_object< - action_move_semantics::return_test_movable_direct_action, movable_object + action_move_semantics::return_test_movable_direct_action, + movable_object >(id) ), 0u); } else { HPX_TEST_EQ(( return_object< - action_move_semantics::return_test_movable_direct_action, movable_object + action_move_semantics::return_test_movable_direct_action, + movable_object >(id) ), 0u); } @@ -260,14 +268,16 @@ void test_direct_actions() { HPX_TEST_RANGE(( return_object< - action_move_semantics::return_test_non_movable_direct_action, non_movable_object + action_move_semantics::return_test_non_movable_direct_action, + non_movable_object >(id) ), 1u, 3u); // ?call + set_value + ?return } else { //FIXME: bumped number for intel compiler HPX_TEST_RANGE(( return_object< - action_move_semantics::return_test_non_movable_direct_action, non_movable_object + action_move_semantics::return_test_non_movable_direct_action, + non_movable_object >(id) ), 4u, 8u); // transfer_action + bind + function + ?call + // set_value + ?return diff --git a/tests/regressions/actions/components/server/action_move_semantics.hpp b/tests/regressions/actions/components/server/action_move_semantics.hpp index 16f026712066..c5976024f37b 100644 --- a/tests/regressions/actions/components/server/action_move_semantics.hpp +++ b/tests/regressions/actions/components/server/action_move_semantics.hpp @@ -39,15 +39,23 @@ namespace hpx { namespace test { namespace server } /////////////////////////////////////////////////////////////////////// - HPX_DEFINE_COMPONENT_ACTION(action_move_semantics, test_movable, test_movable_action); - HPX_DEFINE_COMPONENT_ACTION(action_move_semantics, test_non_movable, test_non_movable_action); - HPX_DEFINE_COMPONENT_DIRECT_ACTION(action_move_semantics, test_movable, test_movable_direct_action); - HPX_DEFINE_COMPONENT_DIRECT_ACTION(action_move_semantics, test_non_movable, test_non_movable_direct_action); + HPX_DEFINE_COMPONENT_ACTION(action_move_semantics, + test_movable, test_movable_action); + HPX_DEFINE_COMPONENT_ACTION(action_move_semantics, + test_non_movable, test_non_movable_action); + HPX_DEFINE_COMPONENT_DIRECT_ACTION(action_move_semantics, + test_movable, test_movable_direct_action); + HPX_DEFINE_COMPONENT_DIRECT_ACTION(action_move_semantics, + test_non_movable, test_non_movable_direct_action); - HPX_DEFINE_COMPONENT_ACTION(action_move_semantics, return_test_movable, return_test_movable_action); - HPX_DEFINE_COMPONENT_ACTION(action_move_semantics, return_test_non_movable, return_test_non_movable_action); - HPX_DEFINE_COMPONENT_DIRECT_ACTION(action_move_semantics, return_test_movable, return_test_movable_direct_action); - HPX_DEFINE_COMPONENT_DIRECT_ACTION(action_move_semantics, return_test_non_movable, return_test_non_movable_direct_action); + HPX_DEFINE_COMPONENT_ACTION(action_move_semantics, + return_test_movable, return_test_movable_action); + HPX_DEFINE_COMPONENT_ACTION(action_move_semantics, + return_test_non_movable, return_test_non_movable_action); + HPX_DEFINE_COMPONENT_DIRECT_ACTION(action_move_semantics, + return_test_movable, return_test_movable_direct_action); + HPX_DEFINE_COMPONENT_DIRECT_ACTION(action_move_semantics, + return_test_non_movable, return_test_non_movable_direct_action); }; }}} diff --git a/tests/regressions/actions/plain_action_move_semantics.cpp b/tests/regressions/actions/plain_action_move_semantics.cpp index 6fb0b1a5b81a..fec250784242 100644 --- a/tests/regressions/actions/plain_action_move_semantics.cpp +++ b/tests/regressions/actions/plain_action_move_semantics.cpp @@ -469,19 +469,23 @@ void test_object_direct_actions() if (is_local) { HPX_TEST_EQ(( - pass_object(id) + pass_object(id) ), 0u); HPX_TEST_EQ(( - move_object(id) + move_object(id) ), 0u); } else { HPX_TEST_EQ(( - pass_object(id) + pass_object(id) ), 3u); // transfer_action + bind + function HPX_TEST_EQ(( - move_object(id) + move_object(id) ), 3u); // transfer_action + bind + function } @@ -509,19 +513,23 @@ void test_object_direct_actions() if (is_local) { HPX_TEST_EQ(( - pass_object(id) + pass_object(id) ), 1u); // call HPX_TEST_EQ(( - move_object(id) + move_object(id) ), 1u); // call } else { HPX_TEST_EQ(( - pass_object(id) + pass_object(id) ), 4u); // transfer_action + bind + function + call HPX_TEST_EQ(( - move_object(id) + move_object(id) ), 4u); // transfer_action + bind + function + call } diff --git a/tests/regressions/agas/duplicate_id_registration_1596.cpp b/tests/regressions/agas/duplicate_id_registration_1596.cpp index ceda711cd544..ae955fe3bab9 100644 --- a/tests/regressions/agas/duplicate_id_registration_1596.cpp +++ b/tests/regressions/agas/duplicate_id_registration_1596.cpp @@ -100,7 +100,7 @@ int hpx_main() { auto id = hpx::new_( hpx::find_here(), string("A")).get(); - bool result = hpx::register_id_with_basename("Listener", id).get(); + bool result = hpx::register_with_basename("Listener", id).get(); HPX_TEST(result); if (result) ++num_expected_ids; @@ -109,7 +109,7 @@ int hpx_main() { auto id = hpx::new_( hpx::find_here(), string("B")).get(); - bool result = hpx::register_id_with_basename("Listener", id).get(); + bool result = hpx::register_with_basename("Listener", id).get(); HPX_TEST(!result); if (result) ++num_expected_ids; @@ -118,14 +118,14 @@ int hpx_main() { auto id = hpx::new_( hpx::find_here(), string("C")).get(); - bool result = hpx::register_id_with_basename("Listener", id).get(); + bool result = hpx::register_with_basename("Listener", id).get(); HPX_TEST(!result); if (result) ++num_expected_ids; } { - auto ids = hpx::find_all_ids_from_basename("Listener", num_expected_ids); + auto ids = hpx::find_all_from_basename("Listener", num_expected_ids); for (auto &f : ids) { diff --git a/tests/regressions/lcos/after_588.cpp b/tests/regressions/lcos/after_588.cpp index cec7ebafab1f..8e3b2885686c 100644 --- a/tests/regressions/lcos/after_588.cpp +++ b/tests/regressions/lcos/after_588.cpp @@ -64,8 +64,10 @@ int hpx_main(boost::program_options::variables_map & vm) hpx::id_type id0 = hpx::components::new_(localities[0]).get(); hpx::id_type id1 = hpx::components::new_(there).get(); - hpx::future f0 = hpx::async(test::ping_action(), id0, id1, vm["iterations"].as()); - hpx::future f1 = hpx::async(test::ping_action(), id1, id0, vm["iterations"].as()); + hpx::future f0 = hpx::async(test::ping_action(), id0, id1, + vm["iterations"].as()); + hpx::future f1 = hpx::async(test::ping_action(), id1, id0, + vm["iterations"].as()); hpx::wait_all(f0, f1); } hpx::finalize(); diff --git a/tests/regressions/lcos/dataflow_791.cpp b/tests/regressions/lcos/dataflow_791.cpp index 46e3fa730377..9542afff0014 100644 --- a/tests/regressions/lcos/dataflow_791.cpp +++ b/tests/regressions/lcos/dataflow_791.cpp @@ -32,7 +32,8 @@ struct block { int size; int start; int height; - block(int size, int startAddress, int H) : size(size), start(startAddress), height(H){} + block(int size, int startAddress, int H) : size(size), + start(startAddress), height(H){} block() : size(0), start(0), height(0){} }; void LU(int numBlocks); @@ -130,27 +131,35 @@ void LU( int numBlocks) dfArray[0][0][0] = async( ProcessDiagonalBlock, blockList[0][0] ); diag_block = &dfArray[0][0][0]; for(int i = 1; i < numBlocks; i++) { - dfArray[0][0][i] = dataflow( unwrapped( &ProcessBlockOnRow ), hpx::make_ready_future( blockList[0][i] ), *diag_block); + dfArray[0][0][i] = dataflow( unwrapped( &ProcessBlockOnRow ), + hpx::make_ready_future( blockList[0][i] ), *diag_block); } for(int i = 1; i < numBlocks; i++) { - dfArray[0][i][0] = dataflow( unwrapped( &ProcessBlockOnColumn ), hpx::make_ready_future( blockList[i][0] ), *diag_block); + dfArray[0][i][0] = dataflow( unwrapped( &ProcessBlockOnColumn ), + hpx::make_ready_future( blockList[i][0] ), *diag_block); first_col = &dfArray[0][i][0]; for(int j = 1; j < numBlocks; j++) { - dfArray[0][i][j] = dataflow( unwrapped( &ProcessInnerBlock ), hpx::make_ready_future( blockList[i][j]), dfArray[0][0][j], *first_col ); + dfArray[0][i][j] = dataflow( unwrapped( &ProcessInnerBlock ), + hpx::make_ready_future( blockList[i][j]), dfArray[0][0][j], *first_col ); } } - //all calculation after initialization. Each iteration, the number of tasks/blocks spawned is decreased. + //all calculation after initialization. Each iteration, + //the number of tasks/blocks spawned is decreased. for(int i = 1; i < numBlocks; i++) { - dfArray[i][i][i] = dataflow( unwrapped( &ProcessDiagonalBlock ), dfArray[i-1][i][i]); + dfArray[i][i][i] = dataflow( unwrapped( &ProcessDiagonalBlock ), + dfArray[i-1][i][i]); diag_block = &dfArray[i][i][i]; for(int j = i + 1; j < numBlocks; j++){ - dfArray[i][i][j] = dataflow( unwrapped(&ProcessBlockOnRow), dfArray[i-1][i][j], *diag_block); + dfArray[i][i][j] = dataflow( unwrapped(&ProcessBlockOnRow), + dfArray[i-1][i][j], *diag_block); } for(int j = i + 1; j < numBlocks; j++){ - dfArray[i][j][i] = dataflow( unwrapped( &ProcessBlockOnColumn ), dfArray[i-1][j][i], *diag_block); + dfArray[i][j][i] = dataflow( unwrapped( &ProcessBlockOnColumn ), + dfArray[i-1][j][i], *diag_block); first_col = &dfArray[i][j][i]; for(int k = i + 1; k < numBlocks; k++) { - dfArray[i][j][k] = dataflow( unwrapped( &ProcessInnerBlock ), dfArray[i-1][j][k], dfArray[i][i][k], *first_col ); + dfArray[i][j][k] = dataflow( unwrapped( &ProcessInnerBlock ), + dfArray[i-1][j][k], dfArray[i][i][k], *first_col ); } } } @@ -172,7 +181,8 @@ void getBlockList(vector > &blockList, int numBlocks) start = (size/numBlocks+1)*i; } else { blockSize = size/numBlocks; - start = (size/numBlocks+1)*(size%numBlocks) + (size/numBlocks)*(i-size%numBlocks); + start = (size/numBlocks+1)*(size%numBlocks) + + (size/numBlocks)*(i-size%numBlocks); } blockList[0].push_back( block( blockSize, start, height)); } @@ -250,7 +260,8 @@ void checkResult( vector &originalA ) temp2=0; for(int k=0;k 0.1 || (originalA[i*size+j]-temp2) / originalA[i*size+j] < -0.1 ){ + if( (originalA[i*size+j]-temp2) / originalA[i*size+j] > 0.1 + || (originalA[i*size+j]-temp2) / originalA[i*size+j] < -0.1 ){ printf("error:[%d][%d] ", i, j); errors++; } diff --git a/tests/regressions/lcos/dataflow_future_swap2.cpp b/tests/regressions/lcos/dataflow_future_swap2.cpp index 30b70841003b..8cc9ed01dd8b 100644 --- a/tests/regressions/lcos/dataflow_future_swap2.cpp +++ b/tests/regressions/lcos/dataflow_future_swap2.cpp @@ -43,12 +43,13 @@ struct divide void future_swap( future_type &f1 , future_type &f2 ) { - //future_type tmp = hpx::lcos::local::dataflow( unwrapped( []( double x ){ return x; } ) , f1 ); + //future_type tmp = hpx::lcos::local::dataflow( + // unwrapped( []( double x ){ return x; } ) , f1 ); future_type tmp = f1; - f1 = hpx::lcos::local::dataflow( unwrapped( []( double x , double sync ){ return x; } ) , - f2 , f1 ); - f2 = hpx::lcos::local::dataflow( unwrapped( []( double x , double sync ){ return x; } ) , - tmp , f1 ); + f1 = hpx::lcos::local::dataflow( unwrapped( []( double x , + double sync ){ return x; } ) , f2 , f1 ); + f2 = hpx::lcos::local::dataflow( unwrapped( []( double x , + double sync ){ return x; } ) , tmp , f1 ); } int main() @@ -58,8 +59,10 @@ int main() for( int n=0 ; n<20 ; ++n ) { - f1 = hpx::lcos::local::dataflow( hpx::launch::async , unwrapped(mul()) , f1 , f2 ); - f2 = hpx::lcos::local::dataflow( hpx::launch::async , unwrapped(divide()) , f1 , f2 ); + f1 = hpx::lcos::local::dataflow( hpx::launch::async , unwrapped(mul()) , + f1 , f2 ); + f2 = hpx::lcos::local::dataflow( hpx::launch::async , unwrapped(divide()) , + f1 , f2 ); future_swap( f1 , f2 ); } diff --git a/tests/regressions/lcos/dataflow_using_774.cpp b/tests/regressions/lcos/dataflow_using_774.cpp index 20f5fea07d04..3cd6ad735e09 100644 --- a/tests/regressions/lcos/dataflow_using_774.cpp +++ b/tests/regressions/lcos/dataflow_using_774.cpp @@ -40,7 +40,8 @@ int main() // compile error even when using full namespace future_type f2 = dataflow( functor , f1 , f1 ); - future_type f3 = hpx::lcos::local::dataflow( hpx::util::unwrapped(mul( 2.0 )) , f1 , f1 ); + future_type f3 = hpx::lcos::local::dataflow( + hpx::util::unwrapped(mul( 2.0 )) , f1 , f1 ); hpx::wait_all(f1, f2, f3); diff --git a/tests/regressions/lcos/future_hang_on_then_629.cpp b/tests/regressions/lcos/future_hang_on_then_629.cpp index 9dfb6a778613..de7253f371f7 100644 --- a/tests/regressions/lcos/future_hang_on_then_629.cpp +++ b/tests/regressions/lcos/future_hang_on_then_629.cpp @@ -134,7 +134,8 @@ double null_tree( ); futures.push_back(f.then - (hpx::util::bind(&null_callback, boost::ref(dd), j, hpx::util::placeholders::_1))); + (hpx::util::bind(&null_callback, boost::ref(dd), j, + hpx::util::placeholders::_1))); } null_function(seed, delay_iterations); diff --git a/tests/regressions/lcos/set_hpx_limit_798.cpp b/tests/regressions/lcos/set_hpx_limit_798.cpp index 5a94e3f8d237..67f5b81f0875 100644 --- a/tests/regressions/lcos/set_hpx_limit_798.cpp +++ b/tests/regressions/lcos/set_hpx_limit_798.cpp @@ -21,7 +21,8 @@ using hpx::lcos::make_ready_future; using hpx::util::unwrapped; // define large action -double func(double x1 , double x2 , double x3 , double x4 , double x5 , double x6 , double x7) +double func(double x1 , double x2 , double x3 , double x4 , + double x5 , double x6 , double x7) { return x1; } diff --git a/tests/regressions/performance_counters/papi_counters_active_interface.cpp b/tests/regressions/performance_counters/papi_counters_active_interface.cpp index 6fc8b64cfd74..8dab33084c57 100644 --- a/tests/regressions/performance_counters/papi_counters_active_interface.cpp +++ b/tests/regressions/performance_counters/papi_counters_active_interface.cpp @@ -77,7 +77,8 @@ int check(int fd) { // this is complete line; extract counter value size_t cpos = out.rfind(',', pos); std::cerr << out.substr(0, pos+1); - cnt.push_back(boost::lexical_cast(out.substr(cpos+1, pos-cpos-1))); + cnt.push_back(boost::lexical_cast + (out.substr(cpos+1, pos-cpos-1))); if (cnt.size() == 5) break; out.erase(0, pos+1); } diff --git a/tests/regressions/performance_counters/papi_counters_basic_functions.cpp b/tests/regressions/performance_counters/papi_counters_basic_functions.cpp index 7542ebcfbcab..3134a390a981 100644 --- a/tests/regressions/performance_counters/papi_counters_basic_functions.cpp +++ b/tests/regressions/performance_counters/papi_counters_basic_functions.cpp @@ -70,7 +70,8 @@ int hpx_main(boost::program_options::variables_map&) boost::uint64_t cnt4 = value4.get_value(); std::cout << n << " counted fp instructions, result: " << cnt1 << std::endl - << n << " uncounted fp instructions, result: " << cnt2-cnt1 << std::endl + << n << " uncounted fp instructions, result: " + << cnt2-cnt1 << std::endl << 2*n << " fp instructions, count after reset: " << cnt3 << std::endl << n << " fp instructions, count after explicit reset: " << cnt4 << std::endl; diff --git a/tests/regressions/traits/is_callable_1179.cpp b/tests/regressions/traits/is_callable_1179.cpp index cb652c910382..3cbcc20d689c 100644 --- a/tests/regressions/traits/is_callable_1179.cpp +++ b/tests/regressions/traits/is_callable_1179.cpp @@ -29,7 +29,8 @@ int main(int argc, char* argv[]) HPX_TEST_MSG((is_callable::value == false), "mem-fun-ptr"); typedef int (s::*const_mem_fun_ptr)() const; - HPX_TEST_MSG((is_callable::value == true), "const-mem-fun-ptr"); + HPX_TEST_MSG((is_callable::value == true), + "const-mem-fun-ptr"); HPX_TEST(invoke(&s::f, p()) == 42); diff --git a/tests/regressions/util/iarchive_1237.cpp b/tests/regressions/util/iarchive_1237.cpp index 6088a2d022ac..4c6980b31b77 100644 --- a/tests/regressions/util/iarchive_1237.cpp +++ b/tests/regressions/util/iarchive_1237.cpp @@ -3,7 +3,8 @@ // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// This test verifies that issue #1001 is resolved (Zero copy serialization raises assert). +// This test verifies that issue #1001 is resolved +// (Zero copy serialization raises assert). #include #include diff --git a/tests/regressions/util/unwrapped_1528.cpp b/tests/regressions/util/unwrapped_1528.cpp index 49f70b0077a8..15b0b15c156d 100644 --- a/tests/regressions/util/unwrapped_1528.cpp +++ b/tests/regressions/util/unwrapped_1528.cpp @@ -3,6 +3,7 @@ // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#include #include #include diff --git a/tests/regressions/util/zero_copy_parcels_1001.cpp b/tests/regressions/util/zero_copy_parcels_1001.cpp index 50f0e24ef74a..8d56a7230f64 100644 --- a/tests/regressions/util/zero_copy_parcels_1001.cpp +++ b/tests/regressions/util/zero_copy_parcels_1001.cpp @@ -3,7 +3,8 @@ // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// This test verifies that issue #1001 is resolved (Zero copy serialization raises assert). +// This test verifies that issue #1001 is resolved +// (Zero copy serialization raises assert). #include #include @@ -16,7 +17,8 @@ #include /////////////////////////////////////////////////////////////////////////////// -hpx::serialization::serialize_buffer test(hpx::serialization::serialize_buffer const& b) +hpx::serialization::serialize_buffer test(hpx::serialization + ::serialize_buffer const& b) { return b; } @@ -41,7 +43,8 @@ int hpx_main() if (localities.empty()) { - HPX_TEST_MSG(!localities.empty(), "This test must be run on more than one locality"); + HPX_TEST_MSG(!localities.empty(), + "This test must be run on more than one locality"); } else { @@ -58,7 +61,8 @@ int hpx_main() hpx::serialization::serialize_buffer buffer(data.data(), data.size(), hpx::serialization::serialize_buffer::reference); - hpx::serialization::serialize_buffer result = act(localities[0], buffer); + hpx::serialization::serialize_buffer result = + act(localities[0], buffer); HPX_TEST(std::equal(data.begin(), data.end(), result.data())); } diff --git a/tests/unit/agas/CMakeLists.txt b/tests/unit/agas/CMakeLists.txt index 931a0a5dde97..976ed2ba353c 100644 --- a/tests/unit/agas/CMakeLists.txt +++ b/tests/unit/agas/CMakeLists.txt @@ -7,6 +7,7 @@ add_subdirectory(components) set(tests credit_exhaustion + find_clients_from_prefix find_ids_from_prefix get_colocation_id gid_type @@ -24,8 +25,8 @@ set(tests uncounted_symbol_to_remote_object ) -set(find_ids_from_prefix_PARAMETERS - LOCALITIES 2) +set(find_ids_from_prefix_PARAMETERS LOCALITIES 2) +set(find_clients_from_prefix_PARAMETERS LOCALITIES 2) set(get_colocation_id_PARAMETERS LOCALITIES 2) diff --git a/tests/unit/agas/find_clients_from_prefix.cpp b/tests/unit/agas/find_clients_from_prefix.cpp new file mode 100644 index 000000000000..0a53ecedcf8c --- /dev/null +++ b/tests/unit/agas/find_clients_from_prefix.cpp @@ -0,0 +1,187 @@ +// Copyright (c) 2007-2014 Hartmut Kaiser +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +struct test_server + : hpx::components::simple_component_base +{ + test_server() + {} + + hpx::id_type call() const + { + return hpx::find_here(); + } + HPX_DEFINE_COMPONENT_ACTION(test_server, call, call_action); +}; + +typedef hpx::components::simple_component server_type; +HPX_REGISTER_COMPONENT(server_type, test_server); + +typedef test_server::call_action call_action; +HPX_REGISTER_ACTION(call_action); + +struct test_client + : hpx::components::client_base +{ + typedef hpx::components::client_base + base_type; + + test_client() {} + test_client(hpx::id_type const& id) : base_type(id) {} + test_client(hpx::future && f) : base_type(std::move(f)) {} + + hpx::id_type call() const { return call_action()(this->get_id()); } +}; + +/////////////////////////////////////////////////////////////////////////////// +void test_find_all_clients_from_basename() +{ + char const* basename = "/find_all_clients_from_prefix_test/"; + + test_client t1 = test_client::create(hpx::find_here()); + + // register our component with AGAS + HPX_TEST((hpx::register_with_basename(basename, t1).get())); + + // wait for all localities to register their component + std::vector localities = hpx::find_all_localities(); + + std::vector all_clients = + hpx::find_all_from_basename(basename, localities.size()); + HPX_TEST_EQ(all_clients.size(), localities.size()); + + // retrieve all component ids + std::set component_localities; + for (test_client& c : all_clients) + { + hpx::id_type locality = c.call(); + std::pair::iterator, bool> p = + component_localities.insert(locality); + + HPX_TEST(p.second); // every id should be unique + } + HPX_TEST_EQ(component_localities.size(), localities.size()); + + // make sure that components are on all localities + for (hpx::id_type const& id : localities) + { + HPX_TEST(component_localities.find(id) != component_localities.end()); + } +} + +void test_find_clients_from_basename() +{ + char const* basename = "/find_clients_from_prefix_test/"; + + test_client t1 = test_client::create(hpx::find_here()); + + // register our component with AGAS + HPX_TEST((hpx::register_with_basename(basename, t1).get())); + + // wait for all localities to register their component + std::vector localities = hpx::find_all_localities(); + + std::vector sequence_nrs; + sequence_nrs.reserve(localities.size()); + for (hpx::id_type const& locality : localities) + { + sequence_nrs.push_back(hpx::naming::get_locality_id_from_id(locality)); + } + + std::vector clients = + hpx::find_from_basename(basename, sequence_nrs); + HPX_TEST_EQ(clients.size(), sequence_nrs.size()); + + // retrieve all component ids + std::set component_localities; + for (test_client& c : clients) + { + hpx::id_type locality = c.call(); + std::pair::iterator, bool> p = + component_localities.insert(locality); + + HPX_TEST(p.second); // every id should be unique + } + HPX_TEST_EQ(component_localities.size(), localities.size()); + + // make sure that components are on all localities + for (hpx::id_type const& id : localities) + { + HPX_TEST(component_localities.find(id) != component_localities.end()); + } +} + +void test_find_client_from_basename() +{ + char const* basename = "/find_client_from_prefix_test/"; + + test_client t1 = test_client::create(hpx::find_here()); + + // register our component with AGAS + HPX_TEST((hpx::register_with_basename(basename, t1).get())); + + // wait for all localities to register their component + std::vector localities = hpx::find_all_localities(); + + std::vector sequence_nrs; + std::vector clients; + sequence_nrs.reserve(localities.size()); + clients.reserve(localities.size()); + + for (hpx::id_type const& locality : localities) + { + std::size_t nr = hpx::naming::get_locality_id_from_id(locality); + sequence_nrs.push_back(nr); + clients.push_back(hpx::find_from_basename(basename, nr)); + } + + HPX_TEST_EQ(clients.size(), sequence_nrs.size()); + + // retrieve all component ids + std::set component_localities; + for (test_client& c : clients) + { + hpx::id_type locality = c.call(); + std::pair::iterator, bool> p = + component_localities.insert(locality); + + HPX_TEST(p.second); // every id should be unique + } + HPX_TEST_EQ(component_localities.size(), localities.size()); + + // make sure that components are on all localities + for (hpx::id_type const& id : localities) + { + HPX_TEST(component_localities.find(id) != component_localities.end()); + } +} + +int hpx_main() +{ + test_find_client_from_basename(); + test_find_clients_from_basename(); + test_find_all_clients_from_basename(); + return hpx::finalize(); +} + +int main(int argc, char* argv[]) +{ + std::vector cfg; + cfg.push_back("hpx.run_hpx_main!=1"); + + // Initialize and run HPX + HPX_TEST_EQ_MSG(hpx::init(argc, argv, cfg), 0, + "HPX main exited with non-zero status"); + + return hpx::util::report_errors(); +} + diff --git a/tests/unit/agas/find_ids_from_prefix.cpp b/tests/unit/agas/find_ids_from_prefix.cpp index baaaa415dc9e..2e4201c2a9bd 100644 --- a/tests/unit/agas/find_ids_from_prefix.cpp +++ b/tests/unit/agas/find_ids_from_prefix.cpp @@ -53,13 +53,13 @@ void test_find_all_ids_from_basename() HPX_TEST_NEQ(hpx::naming::invalid_id, client_id); // register our component with AGAS - HPX_TEST((hpx::register_id_with_basename(basename, client_id).get())); + HPX_TEST((hpx::register_with_basename(basename, client_id).get())); // wait for all localities to register their component std::vector localities = hpx::find_all_localities(); std::vector > all_ids = - hpx::find_all_ids_from_basename(basename, localities.size()); + hpx::find_all_from_basename(basename, localities.size()); HPX_TEST_EQ(all_ids.size(), localities.size()); // retrieve all component ids @@ -92,7 +92,7 @@ void test_find_ids_from_basename() HPX_TEST_NEQ(hpx::naming::invalid_id, client_id); // register our component with AGAS - HPX_TEST((hpx::register_id_with_basename(basename, client_id).get())); + HPX_TEST((hpx::register_with_basename(basename, client_id).get())); // wait for all localities to register their component std::vector localities = hpx::find_all_localities(); @@ -105,7 +105,7 @@ void test_find_ids_from_basename() } std::vector > ids = - hpx::find_ids_from_basename(basename, sequence_nrs); + hpx::find_from_basename(basename, sequence_nrs); HPX_TEST_EQ(ids.size(), sequence_nrs.size()); // retrieve all component ids @@ -139,7 +139,7 @@ void test_find_id_from_basename() HPX_TEST_NEQ(hpx::naming::invalid_id, client_id); // register our component with AGAS - HPX_TEST((hpx::register_id_with_basename(basename, client_id).get())); + HPX_TEST((hpx::register_with_basename(basename, client_id).get())); // wait for all localities to register their component std::vector localities = hpx::find_all_localities(); @@ -153,7 +153,7 @@ void test_find_id_from_basename() { std::size_t nr = hpx::naming::get_locality_id_from_id(locality); sequence_nrs.push_back(nr); - ids.push_back(hpx::find_id_from_basename(basename, nr)); + ids.push_back(hpx::find_from_basename(basename, nr)); } HPX_TEST_EQ(ids.size(), sequence_nrs.size()); diff --git a/tests/unit/agas/gid_type.cpp b/tests/unit/agas/gid_type.cpp index 651e00857212..44b66fdc2398 100644 --- a/tests/unit/agas/gid_type.cpp +++ b/tests/unit/agas/gid_type.cpp @@ -605,7 +605,8 @@ int main() // ------------------------------------ // 0xfffffffffffffffffffffffffffffffe HPX_TEST_EQ((gid + gid).get_lsb(), 0xfffffffffffffffeULL); - HPX_TEST_EQ((gid + gid).get_msb() & ~special_bits_mask, ~0x0ULL & ~special_bits_mask); + HPX_TEST_EQ((gid + gid).get_msb() & ~special_bits_mask, + ~0x0ULL & ~special_bits_mask); // addition should not mutate the originals HPX_TEST_EQ(gid.get_lsb(), ~0x0ULL); diff --git a/tests/unit/component/vector_iter.cpp b/tests/unit/component/vector_iter.cpp index 45ff91c84c38..82e3f17ad85e 100644 --- a/tests/unit/component/vector_iter.cpp +++ b/tests/unit/component/vector_iter.cpp @@ -159,7 +159,8 @@ void test_segmented_iteration(hpx::vector& v, std::size_t size, { std::size_t i = 42; const_local_iterator loc_end = const_traits::end(const_traits::segment(it)); - for (const_local_iterator lcit = const_traits::begin(const_traits::segment(it)); + for (const_local_iterator lcit = + const_traits::begin(const_traits::segment(it)); lcit != loc_end; ++lcit, ++i) { HPX_TEST_EQ(*lcit, T(i)); @@ -357,7 +358,8 @@ void trivial_tests() trivial_test_with_policy(length, 1, hpx::container_layout, "test1"); trivial_test_with_policy(length, 3, hpx::container_layout(3), "test2"); - trivial_test_with_policy(length, 3, hpx::container_layout(3, localities), "test3"); + trivial_test_with_policy(length, 3, + hpx::container_layout(3, localities), "test3"); trivial_test_with_policy(length, localities.size(), hpx::container_layout(localities), "test4"); } diff --git a/tests/unit/lcos/apply_remote.cpp b/tests/unit/lcos/apply_remote.cpp index 3072bbf22238..b060e70cd4ac 100644 --- a/tests/unit/lcos/apply_remote.cpp +++ b/tests/unit/lcos/apply_remote.cpp @@ -34,7 +34,8 @@ void increment(hpx::id_type const& there, boost::int32_t i) } HPX_PLAIN_ACTION(increment); -void increment_with_future(hpx::id_type const& there, hpx::shared_future fi) +void increment_with_future(hpx::id_type const& there, + hpx::shared_future fi) { accumulator += fi.get(); hpx::apply(receive_result_action(), there, accumulator.load()); diff --git a/tests/unit/lcos/async_continue.cpp b/tests/unit/lcos/async_continue.cpp index fd499a11ef6e..40949ecb52bb 100644 --- a/tests/unit/lcos/async_continue.cpp +++ b/tests/unit/lcos/async_continue.cpp @@ -87,7 +87,8 @@ int hpx_main() HPX_TEST_EQ(f.get(), 87); f = hpx::async_continue(inc, - make_continuation(mult, make_continuation(inc, make_continuation())), hpx::find_here(), 42); + make_continuation(mult, make_continuation(inc, make_continuation())), + hpx::find_here(), 42); HPX_TEST_EQ(f.get(), 87); } @@ -99,7 +100,8 @@ int hpx_main() HPX_TEST_EQ(f.get(), 86); f = hpx::async_continue(inc, - make_continuation(mult, localities[0], make_continuation()), localities[0], 42); + make_continuation(mult, localities[0], make_continuation()), + localities[0], 42); HPX_TEST_EQ(f.get(), 86); f = hpx::async_continue(inc, @@ -119,7 +121,8 @@ int hpx_main() f = hpx::async_continue(inc, make_continuation(mult, localities[0], - make_continuation(inc, localities[0], make_continuation())), localities[0], 42); + make_continuation(inc, localities[0], make_continuation())), + localities[0], 42); HPX_TEST_EQ(f.get(), 87); f = hpx::async_continue(inc, diff --git a/tests/unit/lcos/broadcast.cpp b/tests/unit/lcos/broadcast.cpp index 13f280f20143..956053aec81e 100644 --- a/tests/unit/lcos/broadcast.cpp +++ b/tests/unit/lcos/broadcast.cpp @@ -101,7 +101,8 @@ int hpx_main() HPX_TEST_EQ(f3_res.size(), localities.size()); for(std::size_t i = 0; i < f3_res.size(); ++i) { - HPX_TEST_EQ(f3_res[i], hpx::naming::get_locality_id_from_id(localities[i]) + 1); + HPX_TEST_EQ(f3_res[i], + hpx::naming::get_locality_id_from_id(localities[i]) + 1); } hpx::lcos::broadcast(localities, 0).get(); @@ -124,7 +125,8 @@ int hpx_main() HPX_TEST_EQ(f3_res.size(), localities.size()); for(std::size_t i = 0; i < f3_res.size(); ++i) { - HPX_TEST_EQ(f3_res[i], hpx::naming::get_locality_id_from_id(localities[i]) + 1); + HPX_TEST_EQ(f3_res[i], + hpx::naming::get_locality_id_from_id(localities[i]) + 1); } hpx::lcos::broadcast_with_index(localities, 0).get(); diff --git a/tests/unit/lcos/condition_variable.cpp b/tests/unit/lcos/condition_variable.cpp index b93c980f0e03..cc7f1d02000a 100644 --- a/tests/unit/lcos/condition_variable.cpp +++ b/tests/unit/lcos/condition_variable.cpp @@ -119,7 +119,8 @@ struct wait_for_flag void relative_wait_until_with_predicate() { boost::unique_lock lock(mutex); - if(cond_var.wait_for(lock,boost::chrono::milliseconds(5),check_flag(flag)) && flag) + if(cond_var.wait_for(lock,boost::chrono::milliseconds(5), + check_flag(flag)) && flag) { ++woken; } @@ -194,7 +195,8 @@ void test_condition_notify_one_wakes_from_relative_wait_until_with_predicate() { wait_for_flag data; - hpx::thread thread(&wait_for_flag::relative_wait_until_with_predicate, boost::ref(data)); + hpx::thread thread(&wait_for_flag::relative_wait_until_with_predicate, + boost::ref(data)); { boost::unique_lock lock(data.mutex); @@ -245,7 +247,8 @@ void test_condition_notify_all_wakes_from_wait() { for(unsigned i=0;i<5;++i) { - group.push_back(hpx::thread(&wait_for_flag::wait_without_predicate, boost::ref(data))); + group.push_back(hpx::thread(&wait_for_flag::wait_without_predicate, + boost::ref(data))); } { @@ -274,7 +277,8 @@ void test_condition_notify_all_wakes_from_wait_with_predicate() { for(unsigned i=0;i<5;++i) { - group.push_back(hpx::thread(&wait_for_flag::wait_with_predicate, boost::ref(data))); + group.push_back(hpx::thread(&wait_for_flag::wait_with_predicate, + boost::ref(data))); } { @@ -303,7 +307,8 @@ void test_condition_notify_all_wakes_from_wait_until() { for(unsigned i=0;i<5;++i) { - group.push_back(hpx::thread(&wait_for_flag::wait_until_without_predicate, boost::ref(data))); + group.push_back(hpx::thread(&wait_for_flag::wait_until_without_predicate, + boost::ref(data))); } { @@ -332,7 +337,8 @@ void test_condition_notify_all_wakes_from_wait_until_with_predicate() { for(unsigned i=0;i<5;++i) { - group.push_back(hpx::thread(&wait_for_flag::wait_until_with_predicate, boost::ref(data))); + group.push_back(hpx::thread(&wait_for_flag::wait_until_with_predicate, + boost::ref(data))); } { @@ -361,7 +367,8 @@ void test_condition_notify_all_wakes_from_relative_wait_until_with_predicate() { for(unsigned i=0;i<5;++i) { - group.push_back(hpx::thread(&wait_for_flag::relative_wait_until_with_predicate, boost::ref(data))); + group.push_back(hpx::thread(&wait_for_flag + ::relative_wait_until_with_predicate, boost::ref(data))); } { diff --git a/tests/unit/lcos/local_dataflow.cpp b/tests/unit/lcos/local_dataflow.cpp index 10b0bab83441..71ae926d3ee1 100644 --- a/tests/unit/lcos/local_dataflow.cpp +++ b/tests/unit/lcos/local_dataflow.cpp @@ -123,14 +123,18 @@ void function_pointers() boost::atomic future_void_f1_count; boost::atomic future_void_f2_count; -void future_void_f1(future f1) { HPX_TEST(f1.is_ready()); ++future_void_f1_count;} -void future_void_sf1(shared_future f1) { HPX_TEST(f1.is_ready()); ++future_void_f1_count;} -void future_void_f2(future f1, future f2) { HPX_TEST(f1.is_ready()); HPX_TEST(f2.is_ready()); ++future_void_f2_count;} +void future_void_f1(future f1) + { HPX_TEST(f1.is_ready()); ++future_void_f1_count;} +void future_void_sf1(shared_future f1) + { HPX_TEST(f1.is_ready());++future_void_f1_count;} +void future_void_f2(future f1, future f2) + { HPX_TEST(f1.is_ready()); HPX_TEST(f2.is_ready()); ++future_void_f2_count;} boost::atomic future_int_f1_count; boost::atomic future_int_f2_count; -int future_int_f1(future f1) { HPX_TEST(f1.is_ready()); ++future_int_f1_count; return 1;} +int future_int_f1(future f1) { HPX_TEST(f1.is_ready()); + ++future_int_f1_count; return 1;} int future_int_f2(future f1, future f2) { HPX_TEST(f1.is_ready()); HPX_TEST(f2.is_ready()); @@ -158,7 +162,8 @@ void future_function_pointers() future f1 = dataflow( - &future_void_f1, async(&future_void_sf1, shared_future(make_ready_future())) + &future_void_f1, async(&future_void_sf1, + shared_future(make_ready_future())) ); f1.wait(); diff --git a/tests/unit/lcos/shared_future.cpp b/tests/unit/lcos/shared_future.cpp index feb8b1af4a69..56af8b068106 100644 --- a/tests/unit/lcos/shared_future.cpp +++ b/tests/unit/lcos/shared_future.cpp @@ -1251,14 +1251,16 @@ void test_wait_for_either_of_five_futures_5() // hpx::lcos::shared_future futures[count]; // for(unsigned j = 0; j < count; ++j) // { -// tasks[j] = std::move(hpx::lcos::local::packaged_task(make_int_slowly)); +// tasks[j] = +// std::move(hpx::lcos::local::packaged_task(make_int_slowly)); // futures[j] = tasks[j].get_future(); // } // hpx::thread t(std::move(tasks[i])); // // hpx::lcos::wait_any(futures, futures); // -// hpx::lcos::shared_future* const future = boost::wait_for_any(futures, futures+count); +// hpx::lcos::shared_future* const future = +// boost::wait_for_any(futures, futures+count); // // HPX_TEST(future == (futures + i)); // for(unsigned j = 0; j < count; ++j) diff --git a/tests/unit/lcos/when_any.cpp b/tests/unit/lcos/when_any.cpp index 7cb3d7187f56..d8c3cbd93143 100644 --- a/tests/unit/lcos/when_any.cpp +++ b/tests/unit/lcos/when_any.cpp @@ -655,14 +655,16 @@ void test_wait_for_either_of_five_futures_5() // hpx::lcos::future futures[count]; // for(unsigned j = 0; j < count; ++j) // { -// tasks[j] = std::move(hpx::lcos::local::packaged_task(make_int_slowly)); +// tasks[j] = +// std::move(hpx::lcos::local::packaged_task(make_int_slowly)); // futures[j] = tasks[j].get_future(); // } // hpx::thread t(std::move(tasks[i])); // // hpx::lcos::wait_any(futures, futures); // -// hpx::lcos::future* const future = boost::wait_for_any(futures, futures+count); +// hpx::lcos::future* const future = +// boost::wait_for_any(futures, futures+count); // // HPX_TEST(future == (futures + i)); // for(unsigned j = 0; j < count; ++j) diff --git a/tests/unit/parallel/algorithms/exclusive_scan.cpp b/tests/unit/parallel/algorithms/exclusive_scan.cpp index 76404783caa4..cb04ad07f70e 100644 --- a/tests/unit/parallel/algorithms/exclusive_scan.cpp +++ b/tests/unit/parallel/algorithms/exclusive_scan.cpp @@ -418,7 +418,8 @@ void test_exclusive_scan_validate(ExPolicy p, std::vector &a, std::vector(0), boost::counting_iterator(ARRAY_SIZE), std::back_inserter(a)); + std::copy(boost::counting_iterator(0), + boost::counting_iterator(ARRAY_SIZE), std::back_inserter(a)); #ifdef DUMP_VALUES std::cout << "\nValidating counting from 0 " << "\nInput : "; std::copy(a.begin(), a.begin()+DISPLAY, std::ostream_iterator(std::cout, ", ")); @@ -444,7 +445,8 @@ void test_exclusive_scan_validate(ExPolicy p, std::vector &a, std::vector(1), boost::counting_iterator(ARRAY_SIZE), std::back_inserter(a)); + std::copy(boost::counting_iterator(1), + boost::counting_iterator(ARRAY_SIZE), std::back_inserter(a)); #ifdef DUMP_VALUES std::cout << "\nValidating counting from 1 " << "\nInput : "; std::copy(a.begin(), a.begin()+DISPLAY, std::ostream_iterator(std::cout, ", ")); diff --git a/tests/unit/parallel/algorithms/is_sorted_until.cpp b/tests/unit/parallel/algorithms/is_sorted_until.cpp index 1525f1483da8..164ddd8985dd 100644 --- a/tests/unit/parallel/algorithms/is_sorted_until.cpp +++ b/tests/unit/parallel/algorithms/is_sorted_until.cpp @@ -65,11 +65,16 @@ void test_sorted_until1() test_sorted_until1_async(seq(task), IteratorTag());//calls sequential and gets future test_sorted_until1_async(par(task), IteratorTag());//calls parallel and gets future - test_sorted_until1(execution_policy(seq), IteratorTag());//calls sequential and gets iter - test_sorted_until1(execution_policy(par), IteratorTag());//calls parallel and gets iter - test_sorted_until1(execution_policy(par_vec), IteratorTag());//calls parallel and gets iter - test_sorted_until1(execution_policy(seq(task)), IteratorTag());//calls sequential and gets iter - test_sorted_until1(execution_policy(par(task)), IteratorTag());//calls parallel and gets iter + test_sorted_until1(execution_policy(seq), IteratorTag()); + //calls sequential and gets iter + test_sorted_until1(execution_policy(par), IteratorTag()); + //calls parallel and gets iter + test_sorted_until1(execution_policy(par_vec), IteratorTag()); + //calls parallel and gets iter + test_sorted_until1(execution_policy(seq(task)), IteratorTag()); + //calls sequential and gets iter + test_sorted_until1(execution_policy(par(task)), IteratorTag()); + //calls parallel and gets iter } void sorted_until_test1() diff --git a/tests/unit/parallel/algorithms/mismatch.cpp b/tests/unit/parallel/algorithms/mismatch.cpp index 51ab8a81d7f4..a93c27bb4ce4 100644 --- a/tests/unit/parallel/algorithms/mismatch.cpp +++ b/tests/unit/parallel/algorithms/mismatch.cpp @@ -40,7 +40,8 @@ void test_mismatch1(ExPolicy policy, IteratorTag) // verify values HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), c1.size()); - HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), c2.size()); + HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), + result.second)), c2.size()); } { @@ -52,7 +53,8 @@ void test_mismatch1(ExPolicy policy, IteratorTag) // verify values HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), changed_idx); - HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), changed_idx); + HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), + result.second)), changed_idx); } } @@ -84,7 +86,8 @@ void test_mismatch1_async(ExPolicy p, IteratorTag) // verify values return_type result = f.get(); HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), c1.size()); - HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), c2.size()); + HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), + result.second)), c2.size()); } { @@ -99,7 +102,8 @@ void test_mismatch1_async(ExPolicy p, IteratorTag) // verify values return_type result = f.get(); HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), changed_idx); - HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), changed_idx); + HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), + changed_idx); } } @@ -158,7 +162,8 @@ void test_mismatch2(ExPolicy policy, IteratorTag) // verify values HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), c1.size()); - HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), c2.size()); + HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), + result.second)), c2.size()); } { @@ -170,7 +175,8 @@ void test_mismatch2(ExPolicy policy, IteratorTag) // verify values HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), changed_idx); - HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), changed_idx); + HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), + result.second)), changed_idx); } } @@ -202,7 +208,8 @@ void test_mismatch2_async(ExPolicy p, IteratorTag) // verify values return_type result = f.get(); HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), c1.size()); - HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), c2.size()); + HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), + result.second)), c2.size()); } { @@ -217,7 +224,8 @@ void test_mismatch2_async(ExPolicy p, IteratorTag) // verify values return_type result = f.get(); HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), changed_idx); - HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), changed_idx); + HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), + result.second)), changed_idx); } } diff --git a/tests/unit/parallel/algorithms/mismatch_binary.cpp b/tests/unit/parallel/algorithms/mismatch_binary.cpp index 9001187a147a..7d923970e7e9 100644 --- a/tests/unit/parallel/algorithms/mismatch_binary.cpp +++ b/tests/unit/parallel/algorithms/mismatch_binary.cpp @@ -40,7 +40,8 @@ void test_mismatch_binary1(ExPolicy policy, IteratorTag) // verify values HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), c1.size()); - HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), c2.size()); + HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), + c2.size()); } { @@ -52,7 +53,8 @@ void test_mismatch_binary1(ExPolicy policy, IteratorTag) // verify values HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), changed_idx); - HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), changed_idx); + HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), + changed_idx); } } @@ -83,8 +85,10 @@ void test_mismatch_binary1_async(ExPolicy p, IteratorTag) // verify values return_type result = f.get(); - HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), c1.size()); - HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), c2.size()); + HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), + c1.size()); + HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), + result.second)), c2.size()); } { @@ -98,8 +102,10 @@ void test_mismatch_binary1_async(ExPolicy p, IteratorTag) // verify values return_type result = f.get(); - HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), changed_idx); - HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), changed_idx); + HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), + changed_idx); + HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), + result.second)), changed_idx); } } @@ -158,8 +164,10 @@ void test_mismatch_binary2(ExPolicy policy, IteratorTag) std::equal_to()); // verify values - HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), c1.size()); - HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), c2.size()); + HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), + c1.size()); + HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), + result.second)), c2.size()); } { @@ -172,7 +180,8 @@ void test_mismatch_binary2(ExPolicy policy, IteratorTag) // verify values HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), changed_idx); - HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), changed_idx); + HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), + changed_idx); } } @@ -205,7 +214,8 @@ void test_mismatch_binary2_async(ExPolicy p, IteratorTag) // verify values return_type result = f.get(); HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), c1.size()); - HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), c2.size()); + HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), + result.second)), c2.size()); } { @@ -221,7 +231,8 @@ void test_mismatch_binary2_async(ExPolicy p, IteratorTag) // verify values return_type result = f.get(); HPX_TEST_EQ(std::size_t(std::distance(begin1, result.first)), changed_idx); - HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), result.second)), changed_idx); + HPX_TEST_EQ(std::size_t(std::distance(boost::begin(c2), + result.second)), changed_idx); } } diff --git a/tests/unit/parallel/executors/minimal_sync_executor.cpp b/tests/unit/parallel/executors/minimal_sync_executor.cpp index fc121ab7ec7c..fb2470c7044e 100644 --- a/tests/unit/parallel/executors/minimal_sync_executor.cpp +++ b/tests/unit/parallel/executors/minimal_sync_executor.cpp @@ -128,7 +128,7 @@ struct test_sync_executor2 : hpx::parallel::executor_tag return hpx::async(hpx::launch::sync, std::forward(f)); } - std::size_t os_thread_count() + std::size_t processing_units_count() { return 1; } diff --git a/tests/unit/parallel/executors/minimal_timed_sync_executor.cpp b/tests/unit/parallel/executors/minimal_timed_sync_executor.cpp index a0cdada10912..13398abb6fe1 100644 --- a/tests/unit/parallel/executors/minimal_timed_sync_executor.cpp +++ b/tests/unit/parallel/executors/minimal_timed_sync_executor.cpp @@ -129,7 +129,7 @@ struct test_timed_async_executor2 : hpx::parallel::timed_executor_tag return hpx::async(hpx::launch::sync, std::forward(f)); } - std::size_t os_thread_count() + std::size_t processing_units_count() { return 1; } diff --git a/tests/unit/parcelset/enable.cpp b/tests/unit/parcelset/enable.cpp index 36ffc718fbdb..b6c5e1df8212 100644 --- a/tests/unit/parcelset/enable.cpp +++ b/tests/unit/parcelset/enable.cpp @@ -69,7 +69,8 @@ void test_disable_enable(std::vector const & localities) hpx::this_thread::yield(); HPX_TEST_EQ(sent, send_count()); - // Decoding might have taken a little longer which increases the receive count ... + // Decoding might have taken a little longer which increases the + // receive count ... // ... so we don't check for equality here //HPX_TEST(received == receive_count() || received + 1 == receive_count()); @@ -110,7 +111,8 @@ void test_disable(std::vector const & localities) hpx::this_thread::yield(); HPX_TEST_EQ(sent, send_count()); - // Decoding might have taken a little longer which increases the receive count ... + // Decoding might have taken a little longer which increases the + // receive count ... // ... so we don't check for equality here //HPX_TEST(received == receive_count() || received + 1 == receive_count()); diff --git a/tests/unit/performance_counter/path_elements.cpp b/tests/unit/performance_counter/path_elements.cpp index 5da8cc75adec..6d7b921dcadb 100644 --- a/tests/unit/performance_counter/path_elements.cpp +++ b/tests/unit/performance_counter/path_elements.cpp @@ -53,7 +53,7 @@ namespace test }, { "/objectname{parentinstancename#*/instancename#*}/countername@parameter", "/objectname/countername", - hpx::performance_counters::counter_path_elements( + hpx::performance_counters::counter_path_elements( "objectname", "countername", "parameter", @@ -61,7 +61,8 @@ namespace test "instancename#*", -1, -1, false) }, - { "/objectname{/objectname{parentinstancename#2/instancename#1}/countername}/countername", + { "/objectname{/objectname{parentinstancename#2/instancename#1}" + "/countername}/countername", "/objectname/countername", hpx::performance_counters::counter_path_elements( "objectname", @@ -71,7 +72,8 @@ namespace test "", -1, -1, true) }, - { "/objectname{/objectname{parentinstancename#2/instancename#1}/countername}/countername@parameter", + { "/objectname{/objectname{parentinstancename#2/instancename#1}" + "/countername}/countername@parameter", "/objectname/countername", hpx::performance_counters::counter_path_elements( "objectname", @@ -81,7 +83,8 @@ namespace test "", -1, -1, false) }, - { "/objectname{parentinstancename#2/instancename#1}/countername/morecountername", + { "/objectname{parentinstancename#2/instancename#1}" + "/countername/morecountername", "/objectname/countername/morecountername", hpx::performance_counters::counter_path_elements( "objectname", @@ -91,7 +94,8 @@ namespace test "instancename", 2, 1, false) }, - { "/objectname{parentinstancename#*/instancename#*}/countername/morecountername", + { "/objectname{parentinstancename#*/instancename#*}" + "/countername/morecountername", "/objectname/countername/morecountername", hpx::performance_counters::counter_path_elements( "objectname", @@ -101,7 +105,8 @@ namespace test "instancename#*", -1, -1, false) }, - { "/objectname{parentinstancename#2/instancename#1}/countername/morecountername@parameter", + { "/objectname{parentinstancename#2/instancename#1}" + "/countername/morecountername@parameter", "/objectname/countername/morecountername", hpx::performance_counters::counter_path_elements( "objectname", @@ -111,7 +116,8 @@ namespace test "instancename", 2, 1, false) }, - { "/objectname{parentinstancename#*/instancename#*}/countername/morecountername@parameter", + { "/objectname{parentinstancename#*/instancename#*}" + "/countername/morecountername@parameter", "/objectname/countername/morecountername", hpx::performance_counters::counter_path_elements( "objectname", @@ -161,7 +167,8 @@ namespace test "moreparent/instancename#*", -1, -1, false) }, - { "/objectname{parentinstancename/moreparent/instancename#1}/countername@parameter", + { "/objectname{parentinstancename/moreparent/instancename#1}" + "/countername@parameter", "/objectname/countername", hpx::performance_counters::counter_path_elements( "objectname", @@ -171,7 +178,8 @@ namespace test "moreparent/instancename", -1, 1, false) }, - { "/objectname{parentinstancename/moreparent/instancename#*}/countername@parameter", + { "/objectname{parentinstancename/moreparent/instancename#*}" + "/countername@parameter", "/objectname/countername", hpx::performance_counters::counter_path_elements( "objectname", @@ -191,7 +199,8 @@ namespace test "instancename", -1, -1, false) }, - { "/objectname{parentinstancename/instancename}/countername@parameter", + { "/objectname{parentinstancename/instancename}" + "/countername@parameter", "/objectname/countername", hpx::performance_counters::counter_path_elements( "objectname", @@ -201,7 +210,8 @@ namespace test "instancename", -1, -1, false) }, - { "/objectname{parentinstancename/moreparent/instancename}/countername", + { "/objectname{parentinstancename/moreparent" + "/instancename}/countername", "/objectname/countername", hpx::performance_counters::counter_path_elements( "objectname", @@ -211,7 +221,8 @@ namespace test "moreparent/instancename", -1, -1, false) }, - { "/objectname{parentinstancename/moreparent/instancename}/countername@parameter", + { "/objectname{parentinstancename/moreparent/instancename}" + "/countername@parameter", "/objectname/countername", hpx::performance_counters::counter_path_elements( "objectname", @@ -317,13 +328,15 @@ namespace test HPX_TEST(fullname == t->fullname_); std::string type_name; - HPX_TEST(status_valid_data == get_counter_type_name(t->path_, type_name, ec)); + HPX_TEST(status_valid_data == + get_counter_type_name(t->path_, type_name, ec)); HPX_TEST(ec.value() == hpx::success); HPX_TEST(type_name == t->typename_); counter_path_elements p; - HPX_TEST(status_valid_data == get_counter_path_elements(t->fullname_, p, ec)); + HPX_TEST(status_valid_data == + get_counter_path_elements(t->fullname_, p, ec)); HPX_TEST(ec.value() == hpx::success); HPX_TEST(p.objectname_ == t->path_.objectname_); HPX_TEST(p.parentinstancename_ == t->path_.parentinstancename_); @@ -338,7 +351,8 @@ namespace test counter_type_path_elements tp1, tp2; - HPX_TEST(status_valid_data == get_counter_type_path_elements(t->fullname_, tp1, ec)); + HPX_TEST(status_valid_data == + get_counter_type_path_elements(t->fullname_, tp1, ec)); HPX_TEST(ec.value() == hpx::success); HPX_TEST(tp1.objectname_ == t->path_.objectname_); HPX_TEST(tp1.countername_ == t->path_.countername_); @@ -349,7 +363,8 @@ namespace test HPX_TEST(type_name == t->typename_); type_name.erase(); - HPX_TEST(status_valid_data == get_full_counter_type_name(tp1, type_name, ec)); + HPX_TEST(status_valid_data == + get_full_counter_type_name(tp1, type_name, ec)); HPX_TEST(ec.value() == hpx::success); if (t->path_.parameters_.empty()) { HPX_TEST(type_name == t->typename_); @@ -358,7 +373,8 @@ namespace test HPX_TEST(type_name == t->typename_ + '@' + t->path_.parameters_); } - HPX_TEST(status_valid_data == get_counter_type_path_elements(t->typename_, tp2, ec)); + HPX_TEST(status_valid_data == + get_counter_type_path_elements(t->typename_, tp2, ec)); HPX_TEST(ec.value() == hpx::success); HPX_TEST(tp2.objectname_ == t->path_.objectname_); HPX_TEST(tp2.countername_ == t->path_.countername_); diff --git a/tests/unit/serialization/polymorphic/polymorphic_nonintrusive.cpp b/tests/unit/serialization/polymorphic/polymorphic_nonintrusive.cpp index 653db24aed14..9cecbf203906 100644 --- a/tests/unit/serialization/polymorphic/polymorphic_nonintrusive.cpp +++ b/tests/unit/serialization/polymorphic/polymorphic_nonintrusive.cpp @@ -98,7 +98,8 @@ C *c_factory(hpx::serialization::input_archive& ar, C */*unused*/) HPX_TRAITS_NONINTRUSIVE_POLYMORPHIC_TEMPLATE((template ), C) HPX_SERIALIZATION_REGISTER_CLASS_TEMPLATE(template, C) -HPX_SERIALIZATION_WITH_CUSTOM_CONSTRUCTOR_TEMPLATE((template), (C), c_factory); +HPX_SERIALIZATION_WITH_CUSTOM_CONSTRUCTOR_TEMPLATE((template), + (C), c_factory); template struct E : public A @@ -134,7 +135,8 @@ E *e_factory(hpx::serialization::input_archive& ar, E */*unused*/) HPX_TRAITS_NONINTRUSIVE_POLYMORPHIC_TEMPLATE((template ), E) HPX_SERIALIZATION_REGISTER_CLASS_TEMPLATE(template, E) -HPX_SERIALIZATION_WITH_CUSTOM_CONSTRUCTOR_TEMPLATE((template), (E), e_factory); +HPX_SERIALIZATION_WITH_CUSTOM_CONSTRUCTOR_TEMPLATE((template), + (E), e_factory); void test_basic() { diff --git a/tests/unit/serialization/serialization_array.cpp b/tests/unit/serialization/serialization_array.cpp index 92360eaac062..7c04769c6d87 100644 --- a/tests/unit/serialization/serialization_array.cpp +++ b/tests/unit/serialization/serialization_array.cpp @@ -230,20 +230,31 @@ void test_array_of_vectors() int main() { - test((std::numeric_limits::min)(), (std::numeric_limits::max)()); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); test(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); test(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); - test_fp((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); + test_fp((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); test_fp(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); test(-100, 100); test_boost_array('\0'); diff --git a/tests/unit/serialization/serialization_builtins.cpp b/tests/unit/serialization/serialization_builtins.cpp index b49aa4d3c01e..daed73db2da3 100644 --- a/tests/unit/serialization/serialization_builtins.cpp +++ b/tests/unit/serialization/serialization_builtins.cpp @@ -164,24 +164,37 @@ void test_fp(T min, T max) int main() { test_bool(); - test((std::numeric_limits::min)(), (std::numeric_limits::max)()); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); test(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); test(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); #if defined(BOOST_HAS_INT128) - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); + test((std::numeric_limits::max)() - 100,\ + (std::numeric_limits::max)()); + test((std::numeric_limits::max)() - 100,\ + (std::numeric_limits::max)()); #endif - test_fp((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); + test_fp((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); test_fp(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); test(-100, 100); return hpx::util::report_errors(); diff --git a/tests/unit/serialization/serialization_custom_constructor.cpp b/tests/unit/serialization/serialization_custom_constructor.cpp index e1b2d219df03..63eccaa70791 100644 --- a/tests/unit/serialization/serialization_custom_constructor.cpp +++ b/tests/unit/serialization/serialization_custom_constructor.cpp @@ -107,7 +107,8 @@ C *c_factory(hpx::serialization::input_archive& ar, C */*unused*/) return c; } -HPX_SERIALIZATION_WITH_CUSTOM_CONSTRUCTOR_TEMPLATE((template), (C), c_factory); +HPX_SERIALIZATION_WITH_CUSTOM_CONSTRUCTOR_TEMPLATE((template), + (C), c_factory); void test_delegate() { diff --git a/tests/unit/serialization/serialization_list.cpp b/tests/unit/serialization/serialization_list.cpp index d6819363c6b0..bf7efae1394b 100644 --- a/tests/unit/serialization/serialization_list.cpp +++ b/tests/unit/serialization/serialization_list.cpp @@ -169,23 +169,37 @@ void test_fp(T min, T max) int main() { test_bool(); - test((std::numeric_limits::min)(), (std::numeric_limits::max)()); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); test(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); test(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); - test_fp((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test_fp((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); //it's incorrect - // because floatmax() - 100 causes cancellations error, digits are not affected + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); + test_fp((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test_fp((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); //it's incorrect + // because floatmax() - 100 causes cancellations error, + // digits are not affected test_fp(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); //it's the same + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); //it's the same test(-100, 100); return hpx::util::report_errors(); diff --git a/tests/unit/serialization/serialization_map.cpp b/tests/unit/serialization/serialization_map.cpp index ae356b15b77f..d66140d5c8e6 100644 --- a/tests/unit/serialization/serialization_map.cpp +++ b/tests/unit/serialization/serialization_map.cpp @@ -121,20 +121,31 @@ void test_vector_as_value() int main() { - test((std::numeric_limits::min)(), (std::numeric_limits::max)()); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); test(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); test(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); - test_fp((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); + test_fp((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); test_fp(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); test(-100, 100); test_vector_as_value(); diff --git a/tests/unit/serialization/serialization_set.cpp b/tests/unit/serialization/serialization_set.cpp index 86f532665fec..947b53e6e381 100644 --- a/tests/unit/serialization/serialization_set.cpp +++ b/tests/unit/serialization/serialization_set.cpp @@ -103,7 +103,8 @@ void test(T min, T max) HPX_TEST_EQ(os.size(), is.size()); typename std::set >::iterator j = is.begin(); - for(typename std::set >::iterator i = os.begin(); i != os.end(); ++i) + for(typename std::set >::iterator i = os.begin(); + i != os.end(); ++i) { HPX_TEST_EQ(i->cargo, j->cargo); ++j; @@ -150,7 +151,8 @@ void test_fp(T min, T max) HPX_TEST_EQ(os.size(), is.size()); typename std::set >::iterator j = is.begin(); - for(typename std::set >::iterator i = os.begin(); i != os.end(); ++i) + for(typename std::set >::iterator i = + os.begin(); i != os.end(); ++i) { HPX_TEST_EQ(i->cargo, j->cargo); ++j; @@ -161,23 +163,36 @@ void test_fp(T min, T max) int main() { test_int(); - test((std::numeric_limits::min)(), (std::numeric_limits::max)()); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); test(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); test(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); - test_fp((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test_fp((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); //it's incorrect + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); + test_fp((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test_fp((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); //it's incorrect // because floatmax() - 100 causes cancellations error, digits are not affected test_fp(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); //it's the same + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); //it's the same test(-100, 100); return hpx::util::report_errors(); diff --git a/tests/unit/serialization/serialization_vector.cpp b/tests/unit/serialization/serialization_vector.cpp index 7917209e64e7..ec04cae7a567 100644 --- a/tests/unit/serialization/serialization_vector.cpp +++ b/tests/unit/serialization/serialization_vector.cpp @@ -157,23 +157,36 @@ void test_fp(T min, T max) int main() { test_bool(); - test((std::numeric_limits::min)(), (std::numeric_limits::max)()); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); test(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); test(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); - test_fp((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test_fp((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); //it's incorrect + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); + test_fp((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test_fp((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); //it's incorrect // because floatmax() - 100 causes cancellations error, digits are not affected test_fp(-100, 100); - test((std::numeric_limits::min)(), (std::numeric_limits::min)() + 100); - test((std::numeric_limits::max)() - 100, (std::numeric_limits::max)()); //it's the same + test((std::numeric_limits::min)(), + (std::numeric_limits::min)() + 100); + test((std::numeric_limits::max)() - 100, + (std::numeric_limits::max)()); //it's the same test(-100, 100); return hpx::util::report_errors(); diff --git a/tests/unit/serialization/serialize_buffer.cpp b/tests/unit/serialization/serialize_buffer.cpp index 881274abd2b2..6dfb22b4f81c 100644 --- a/tests/unit/serialization/serialize_buffer.cpp +++ b/tests/unit/serialization/serialize_buffer.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2014 Hartmut Kaiser +// Copyright (c) 2015 Andreas Schaefer // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -24,21 +25,6 @@ HPX_REGISTER_BASE_LCO_WITH_VALUE_DECLARATION( HPX_REGISTER_BASE_LCO_WITH_VALUE( buffer_plain_type, serialization_buffer_char); -/////////////////////////////////////////////////////////////////////////////// -typedef hpx::serialization::serialize_buffer > - buffer_allocator_type; - -buffer_allocator_type bounce_allocator(buffer_allocator_type const& receive_buffer) -{ - return receive_buffer; -} -HPX_PLAIN_ACTION(bounce_allocator); - -HPX_REGISTER_BASE_LCO_WITH_VALUE_DECLARATION( - buffer_allocator_type, serialization_buffer_char_allocator); -HPX_REGISTER_BASE_LCO_WITH_VALUE( - buffer_allocator_type, serialization_buffer_char_allocator); - /////////////////////////////////////////////////////////////////////////////// template void test(hpx::id_type dest, char* send_buffer, std::size_t size) @@ -69,13 +55,13 @@ template void test_stateful_allocator(hpx::id_type dest, char* send_buffer, std::size_t size, Allocator const& alloc) { - typedef buffer_allocator_type buffer_type; + typedef buffer_plain_type buffer_type; buffer_type recv_buffer; std::vector > recv_buffers; recv_buffers.reserve(10); - bounce_allocator_action act; + bounce_plain_action act; for(std::size_t j = 0; j != 10; ++j) { recv_buffers.push_back(hpx::async(act, dest, @@ -91,6 +77,51 @@ void test_stateful_allocator(hpx::id_type dest, char* send_buffer, } } +template +void test_fixed_size_initialization_for_persistent_buffers(std::size_t max_size) +{ + for (std::size_t size = 1; size <= max_size; size *= 2) + { + std::vector send_vec; + std::vector recv_vec; + send_vec.reserve(size); + for (std::size_t i = 0; i < size; ++i) { + send_vec.push_back(size - i); + } + + hpx::serialization::serialize_buffer send_buffer(size); + hpx::serialization::serialize_buffer recv_buffer; + std::copy(send_vec.begin(), send_vec.end(), send_buffer.begin()); + recv_buffer = send_buffer; + + std::copy(recv_buffer.begin(), recv_buffer.end(), std::back_inserter(recv_vec)); + HPX_TEST(send_vec == recv_vec); + } +} + +template +void test_initialization_from_vector(std::size_t max_size) +{ + for (std::size_t size = 1; size <= max_size; size *= 2) + { + std::vector send_vec; + std::vector recv_vec; + send_vec.reserve(size); + for (std::size_t i = 0; i < size; ++i) { + send_vec.push_back(size - i); + } + + // default init mode is "copy" + hpx::serialization::serialize_buffer send_buffer(send_vec[0], send_vec.size()); + hpx::serialization::serialize_buffer recv_buffer; + std::copy(send_vec.begin(), send_vec.end(), send_buffer.begin()); + recv_buffer = send_buffer; + + std::copy(recv_buffer.begin(), recv_buffer.end(), std::back_inserter(recv_vec)); + HPX_TEST(send_vec == recv_vec); + } +} + /////////////////////////////////////////////////////////////////////////////// int hpx_main(int argc, char* argv[]) { @@ -103,13 +134,19 @@ int hpx_main(int argc, char* argv[]) { test( loc, send_buffer.get(), size); - test( - loc, send_buffer.get(), size); test_stateful_allocator( loc, send_buffer.get(), size, std::allocator()); } } + for (std::size_t size = 1; size <= max_size; size *= 2) + { + test_fixed_size_initialization_for_persistent_buffers(size); + test_fixed_size_initialization_for_persistent_buffers(size); + test_fixed_size_initialization_for_persistent_buffers(size); + test_fixed_size_initialization_for_persistent_buffers(size); + } + return hpx::finalize(); } diff --git a/tests/unit/threads/lockfree_fifo.cpp b/tests/unit/threads/lockfree_fifo.cpp index f5f9edbe9614..8a0297dec417 100644 --- a/tests/unit/threads/lockfree_fifo.cpp +++ b/tests/unit/threads/lockfree_fifo.cpp @@ -76,7 +76,8 @@ int main(int argc, char** argv) ; store( - command_line_parser(argc, argv).options(desc_cmdline).allow_unregistered().run(), vm); + command_line_parser(argc, + argv).options(desc_cmdline).allow_unregistered().run(),vm); notify(vm); diff --git a/tests/unit/threads/thread.cpp b/tests/unit/threads/thread.cpp index df9a02e14b9e..dbb0158e5147 100644 --- a/tests/unit/threads/thread.cpp +++ b/tests/unit/threads/thread.cpp @@ -193,8 +193,10 @@ void do_test_thread_no_interrupt_if_interrupts_disabled_at_interruption_point() void test_thread_no_interrupt_if_interrupts_disabled_at_interruption_point() { - set_description("test_thread_no_interrupt_if_interrupts_disabled_at_interruption_point"); - timed_test(&do_test_thread_no_interrupt_if_interrupts_disabled_at_interruption_point, 1); + set_description("test_thread_no_interrupt_if_interrupts_disabled_at\ + _interruption_point"); + timed_test + (&do_test_thread_no_interrupt_if_interrupts_disabled_at_interruption_point,1); } /////////////////////////////////////////////////////////////////////////////// diff --git a/tests/unit/threads/thread_affinity.cpp b/tests/unit/threads/thread_affinity.cpp index 4975917228b5..0ab8c73403b3 100644 --- a/tests/unit/threads/thread_affinity.cpp +++ b/tests/unit/threads/thread_affinity.cpp @@ -42,7 +42,8 @@ std::size_t thread_affinity_worker(std::size_t desired) // extract the desired affinity mask hpx::threads::topology const& t = hpx::get_runtime().get_topology(); - hpx::threads::mask_type desired_mask = t.get_thread_affinity_mask(current, numa_sensitive); + hpx::threads::mask_type desired_mask = t.get_thread_affinity_mask(current, + numa_sensitive); std::size_t idx = hpx::threads::find_first(desired_mask); @@ -63,7 +64,8 @@ std::size_t thread_affinity_worker(std::size_t desired) } else { - HPX_TEST(false && "hwloc_get_cpubind(topo, cpuset, HWLOC_CPUBIND_THREAD) failed!"); + HPX_TEST(false && "hwloc_get_cpubind(topo, cpuset, \ + HWLOC_CPUBIND_THREAD) failed!"); } hwloc_bitmap_free(cpuset); diff --git a/tests/unit/threads/thread_mf.cpp b/tests/unit/threads/thread_mf.cpp index 815a3905bdad..e653011af634 100644 --- a/tests/unit/threads/thread_mf.cpp +++ b/tests/unit/threads/thread_mf.cpp @@ -39,20 +39,30 @@ struct X int f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; } int g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; } - int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } - int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } - - int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } - int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } - - int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } - int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } - - int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } - int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } - - int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } - int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } + int f4(int a1, int a2, int a3, int a4) + { f3(a1, a2, a3); f1(a4); return 0; } + int g4(int a1, int a2, int a3, int a4) + const { g3(a1, a2, a3); g1(a4); return 0; } + + int f5(int a1, int a2, int a3, int a4, int a5) + { f4(a1, a2, a3, a4); f1(a5); return 0; } + int g5(int a1, int a2, int a3, int a4, int a5) + const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int f6(int a1, int a2, int a3, int a4, int a5, int a6) + { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int g6(int a1, int a2, int a3, int a4, int a5, int a6) + const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } }; /////////////////////////////////////////////////////////////////////////////// diff --git a/tests/unit/traits/is_callable.cpp b/tests/unit/traits/is_callable.cpp index 7d3fd0a58dd4..486f12bb12f9 100644 --- a/tests/unit/traits/is_callable.cpp +++ b/tests/unit/traits/is_callable.cpp @@ -46,9 +46,11 @@ void functions_byval_params() typedef void (*fc)(int const); HPX_TEST_MSG((is_callable::value == true), "fun-const-value/value"); HPX_TEST_MSG((is_callable::value == true), "fun-const-value/lvref"); - HPX_TEST_MSG((is_callable::value == true), "fun-const-value/const-lvref"); + HPX_TEST_MSG((is_callable::value == true), + "fun-const-value/const-lvref"); HPX_TEST_MSG((is_callable::value == true), "fun-const-value/rvref"); - HPX_TEST_MSG((is_callable::value == true), "fun-const-value/const-rvref"); + HPX_TEST_MSG((is_callable::value == true), + "fun-const-value/const-rvref"); } void functions_bylvref_params() @@ -60,14 +62,17 @@ void functions_bylvref_params() HPX_TEST_MSG((is_callable::value == true), "fun-lvref/lvref"); HPX_TEST_MSG((is_callable::value == false), "fun-lvref/const-lvref"); HPX_TEST_MSG((is_callable::value == false), "fun-lvref/rvref"); - HPX_TEST_MSG((is_callable::value == false), "fun-lvref/const-rvref"); + HPX_TEST_MSG((is_callable::value == false), + "fun-lvref/const-rvref"); typedef void (*fc)(int const&); HPX_TEST_MSG((is_callable::value == true), "fun-const-lvref/value"); HPX_TEST_MSG((is_callable::value == true), "fun-const-lvref/lvref"); - HPX_TEST_MSG((is_callable::value == true), "fun-const-lvref/const-lvref"); + HPX_TEST_MSG((is_callable::value == true), + "fun-const-lvref/const-lvref"); HPX_TEST_MSG((is_callable::value == true), "fun-const-lvref/rvref"); - HPX_TEST_MSG((is_callable::value == true), "fun-const-lvref/const-rvref"); + HPX_TEST_MSG((is_callable::value == true), + "fun-const-lvref/const-rvref"); } void functions_byrvref_params() @@ -80,15 +85,18 @@ void functions_byrvref_params() HPX_TEST_MSG((is_callable::value == false), "fun-rvref/const-lvref"); HPX_TEST_MSG((is_callable::value == true), "fun-rvref/rvref"); #if !defined(BOOST_INTEL) - HPX_TEST_MSG((is_callable::value == false), "fun-rvref/const-rvref"); + HPX_TEST_MSG((is_callable::value == false), + "fun-rvref/const-rvref"); #endif typedef void (*fc)(int const&&); HPX_TEST_MSG((is_callable::value == true), "fun-const-rvref/value"); HPX_TEST_MSG((is_callable::value == false), "fun-const-rvref/lvref"); - HPX_TEST_MSG((is_callable::value == false), "fun-const-rvref/const-lvref"); + HPX_TEST_MSG((is_callable::value == false), + "fun-const-rvref/const-lvref"); HPX_TEST_MSG((is_callable::value == true), "fun-const-rvref/rvref"); - HPX_TEST_MSG((is_callable::value == true), "fun-const-rvref/const-rvref"); + HPX_TEST_MSG((is_callable::value == true), + "fun-const-rvref/const-rvref"); } void member_function_pointers() @@ -97,19 +105,27 @@ void member_function_pointers() typedef int (X::*f)(double); HPX_TEST_MSG((is_callable::value == true), "mem-fun-ptr/ptr"); - HPX_TEST_MSG((is_callable::value == false), "mem-fun-ptr/const-ptr"); + HPX_TEST_MSG((is_callable::value == false), + "mem-fun-ptr/const-ptr"); HPX_TEST_MSG((is_callable::value == true), "mem-fun-ptr/lvref"); - HPX_TEST_MSG((is_callable::value == false), "mem-fun-ptr/const-lvref"); + HPX_TEST_MSG((is_callable::value == false), + "mem-fun-ptr/const-lvref"); HPX_TEST_MSG((is_callable::value == true), "mem-fun-ptr/rvref"); - HPX_TEST_MSG((is_callable::value == false), "mem-fun-ptr/const-rvref"); + HPX_TEST_MSG((is_callable::value == false), + "mem-fun-ptr/const-rvref"); typedef int (X::*fc)(double) const; HPX_TEST_MSG((is_callable::value == true), "const-mem-fun-ptr/ptr"); - HPX_TEST_MSG((is_callable::value == true), "const-mem-fun-ptr/const-ptr"); - HPX_TEST_MSG((is_callable::value == true), "const-mem-fun-ptr/lvref"); - HPX_TEST_MSG((is_callable::value == true), "const-mem-fun-ptr/const-lvref"); - HPX_TEST_MSG((is_callable::value == true), "const-mem-fun-ptr/rvref"); - HPX_TEST_MSG((is_callable::value == true), "const-mem-fun-ptr/const-rvref"); + HPX_TEST_MSG((is_callable::value == true), + "const-mem-fun-ptr/const-ptr"); + HPX_TEST_MSG((is_callable::value == true), + "const-mem-fun-ptr/lvref"); + HPX_TEST_MSG((is_callable::value == true), + "const-mem-fun-ptr/const-lvref"); + HPX_TEST_MSG((is_callable::value == true), + "const-mem-fun-ptr/rvref"); + HPX_TEST_MSG((is_callable::value == true), + "const-mem-fun-ptr/const-rvref"); } void member_object_pointers() @@ -120,32 +136,50 @@ void member_object_pointers() HPX_TEST_MSG((is_callable::value == true), "mem-obj-ptr/ptr"); HPX_TEST_MSG((is_callable::value == true), "mem-obj-ptr/const-ptr"); HPX_TEST_MSG((is_callable::value == true), "mem-obj-ptr/lvref"); - HPX_TEST_MSG((is_callable::value == true), "mem-obj-ptr/const-lvref"); + HPX_TEST_MSG((is_callable::value == true), + "mem-obj-ptr/const-lvref"); HPX_TEST_MSG((is_callable::value == true), "mem-obj-ptr/rvref"); - HPX_TEST_MSG((is_callable::value == true), "mem-obj-ptr/const-rvref"); + HPX_TEST_MSG((is_callable::value == true), + "mem-obj-ptr/const-rvref"); } void function_objects() { using hpx::traits::is_callable; - HPX_TEST_MSG((is_callable::value == true), "fun-obj/value"); - HPX_TEST_MSG((is_callable::value == false), "fun-obj/const-value"); - HPX_TEST_MSG((is_callable::value == false), "fun-obj/ptr"); - HPX_TEST_MSG((is_callable::value == false), "fun-obj/const-ptr"); - HPX_TEST_MSG((is_callable::value == true), "fun-obj/lvref"); - HPX_TEST_MSG((is_callable::value == false), "fun-obj/const-lvref"); - HPX_TEST_MSG((is_callable::value == true), "fun-obj/rvref"); - HPX_TEST_MSG((is_callable::value == false), "fun-obj/const-rvref"); - - HPX_TEST_MSG((is_callable::value == true), "const-fun-obj/value"); - HPX_TEST_MSG((is_callable::value == true), "const-fun-obj/const-value"); - HPX_TEST_MSG((is_callable::value == false), "const-fun-obj/ptr"); - HPX_TEST_MSG((is_callable::value == false), "const-fun-obj/const-ptr"); - HPX_TEST_MSG((is_callable::value == true), "const-fun-obj/lvref"); - HPX_TEST_MSG((is_callable::value == true), "const-fun-obj/const-lvref"); - HPX_TEST_MSG((is_callable::value == true), "const-fun-obj/rvref"); - HPX_TEST_MSG((is_callable::value == true), "const-fun-obj/const-rvref"); + HPX_TEST_MSG((is_callable::value == true), + "fun-obj/value"); + HPX_TEST_MSG((is_callable::value == false), + "fun-obj/const-value"); + HPX_TEST_MSG((is_callable::value == false), + "fun-obj/ptr"); + HPX_TEST_MSG((is_callable::value == false), + "fun-obj/const-ptr"); + HPX_TEST_MSG((is_callable::value == true), + "fun-obj/lvref"); + HPX_TEST_MSG((is_callable::value == false), + "fun-obj/const-lvref"); + HPX_TEST_MSG((is_callable::value == true), + "fun-obj/rvref"); + HPX_TEST_MSG((is_callable::value == false), + "fun-obj/const-rvref"); + + HPX_TEST_MSG((is_callable::value == true), + "const-fun-obj/value"); + HPX_TEST_MSG((is_callable::value == true), + "const-fun-obj/const-value"); + HPX_TEST_MSG((is_callable::value == false), + "const-fun-obj/ptr"); + HPX_TEST_MSG((is_callable::value == false), + "const-fun-obj/const-ptr"); + HPX_TEST_MSG((is_callable::value == true), + "const-fun-obj/lvref"); + HPX_TEST_MSG((is_callable::value == true), + "const-fun-obj/const-lvref"); + HPX_TEST_MSG((is_callable::value == true), + "const-fun-obj/rvref"); + HPX_TEST_MSG((is_callable::value == true), + "const-fun-obj/const-rvref"); } /////////////////////////////////////////////////////////////////////////////// diff --git a/tests/unit/util/any.cpp b/tests/unit/util/any.cpp index 18676a888d50..53f060f42cdd 100644 --- a/tests/unit/util/any.cpp +++ b/tests/unit/util/any.cpp @@ -44,7 +44,8 @@ int hpx_main(variables_map& vm) typedef hpx::util::any elem_type; typedef hpx::util::hash_any hash_elem_functor; - typedef boost::unordered_multimap field_index_map_type; + typedef boost::unordered_multimap field_index_map_type; typedef field_index_map_type::iterator field_index_map_iterator_type; field_index_map_type field_index_map_; @@ -144,7 +145,8 @@ int hpx_main(variables_map& vm) { // test equality { - any_nonser any1_nonser(7), any2_nonser(7), any3_nonser(10), any4_nonser(std::string("seven")); + any_nonser any1_nonser(7), any2_nonser(7), any3_nonser(10), + any4_nonser(std::string("seven")); HPX_TEST_EQ(any1_nonser, 7); HPX_TEST_NEQ(any1_nonser, 10); diff --git a/tests/unit/util/bind/bind_and_or_test.cpp b/tests/unit/util/bind/bind_and_or_test.cpp index e7306a8c72bc..1144ef64cf77 100644 --- a/tests/unit/util/bind/bind_and_or_test.cpp +++ b/tests/unit/util/bind/bind_and_or_test.cpp @@ -52,27 +52,39 @@ int main() { // && - test( hpx::util::bind( f, true ) && hpx::util::bind( g, true ), false, false, f( true ) && g( true ) ); - test( hpx::util::bind( f, true ) && hpx::util::bind( g, false ), false, false, f( true ) && g( false ) ); + test( hpx::util::bind( f, true ) && hpx::util::bind( g, true ), + false, false, f( true ) && g( true ) ); + test( hpx::util::bind( f, true ) && hpx::util::bind( g, false ), + false, false, f( true ) && g( false ) ); - test( hpx::util::bind( f, false ) && hpx::util::bind( h ), false, false, f( false ) && h() ); + test( hpx::util::bind( f, false ) && hpx::util::bind( h ), + false, false, f( false ) && h() ); - test( hpx::util::bind( f, placeholders::_1 ) && hpx::util::bind( g, placeholders::_2 ), true, true, f( true ) && g( true ) ); - test( hpx::util::bind( f, placeholders::_1 ) && hpx::util::bind( g, placeholders::_2 ), true, false, f( true ) && g( false ) ); + test( hpx::util::bind( f, placeholders::_1 ) && hpx::util::bind( g, + placeholders::_2 ), true, true, f( true ) && g( true ) ); + test( hpx::util::bind( f, placeholders::_1 ) && hpx::util::bind( g, + placeholders::_2 ), true, false, f( true ) && g( false ) ); - test( hpx::util::bind( f, placeholders::_1 ) && hpx::util::bind( h ), false, false, f( false ) && h() ); + test( hpx::util::bind( f, placeholders::_1 ) && hpx::util::bind( h ), + false, false, f( false ) && h() ); // || - test( hpx::util::bind( f, false ) || hpx::util::bind( g, true ), false, false, f( false ) || g( true ) ); - test( hpx::util::bind( f, false ) || hpx::util::bind( g, false ), false, false, f( false ) || g( false ) ); + test( hpx::util::bind( f, false ) || hpx::util::bind( g, true ), + false, false, f( false ) || g( true ) ); + test( hpx::util::bind( f, false ) || hpx::util::bind( g, false ), + false, false, f( false ) || g( false ) ); - test( hpx::util::bind( f, true ) || hpx::util::bind( h ), false, false, f( true ) || h() ); + test( hpx::util::bind( f, true ) || hpx::util::bind( h ), + false, false, f( true ) || h() ); - test( hpx::util::bind( f, placeholders::_1 ) || hpx::util::bind( g, placeholders::_2 ), false, true, f( false ) || g( true ) ); - test( hpx::util::bind( f, placeholders::_1 ) || hpx::util::bind( g, placeholders::_2 ), false, false, f( false ) || g( false ) ); + test( hpx::util::bind( f, placeholders::_1 ) || hpx::util::bind( g, + placeholders::_2 ), false, true, f( false ) || g( true ) ); + test( hpx::util::bind( f, placeholders::_1 ) || hpx::util::bind( g, + placeholders::_2 ), false, false, f( false ) || g( false ) ); - test( hpx::util::bind( f, placeholders::_1 ) || hpx::util::bind( h ), true, false, f( true ) || h() ); + test( hpx::util::bind( f, placeholders::_1 ) || hpx::util::bind( h ), + true, false, f( true ) || h() ); // diff --git a/tests/unit/util/bind/bind_cdecl_mf_test.cpp b/tests/unit/util/bind/bind_cdecl_mf_test.cpp index 0c9c40db5219..7df759cf63e1 100644 --- a/tests/unit/util/bind/bind_cdecl_mf_test.cpp +++ b/tests/unit/util/bind/bind_cdecl_mf_test.cpp @@ -47,20 +47,30 @@ struct X int __cdecl f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; } int __cdecl g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; } - int __cdecl f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } - int __cdecl g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } - - int __cdecl f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } - int __cdecl g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } - - int __cdecl f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } - int __cdecl g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } - - int __cdecl f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } - int __cdecl g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } - - int __cdecl f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } - int __cdecl g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } + int __cdecl f4(int a1, int a2, int a3, int a4) + { f3(a1, a2, a3); f1(a4); return 0; } + int __cdecl g4(int a1, int a2, int a3, int a4) + const { g3(a1, a2, a3); g1(a4); return 0; } + + int __cdecl f5(int a1, int a2, int a3, int a4, int a5) + { f4(a1, a2, a3, a4); f1(a5); return 0; } + int __cdecl g5(int a1, int a2, int a3, int a4, int a5) + const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int __cdecl f6(int a1, int a2, int a3, int a4, int a5, int a6) + { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int __cdecl g6(int a1, int a2, int a3, int a4, int a5, int a6) + const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int __cdecl f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int __cdecl g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int __cdecl f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int __cdecl g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } }; void member_function_test() diff --git a/tests/unit/util/bind/bind_const_test.cpp b/tests/unit/util/bind/bind_const_test.cpp index beda4810d864..8b7b91c2cb8e 100644 --- a/tests/unit/util/bind/bind_const_test.cpp +++ b/tests/unit/util/bind/bind_const_test.cpp @@ -73,12 +73,14 @@ long f_7(long a, long b, long c, long d, long e, long f, long g) long f_8(long a, long b, long c, long d, long e, long f, long g, long h) { - return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + + 100000 * f + 1000000 * g + 10000000 * h; } long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) { - return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; } long global_result; @@ -120,17 +122,20 @@ void fv_6(long a, long b, long c, long d, long e, long f) void fv_7(long a, long b, long c, long d, long e, long f, long g) { - global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + + 100000 * f + 1000000 * g; } void fv_8(long a, long b, long c, long d, long e, long f, long g, long h) { - global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + + 100000 * f + 1000000 * g + 10000000 * h; } void fv_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) { - global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; } template long test(F const & f, A const & a) @@ -154,21 +159,30 @@ void function_test() HPX_TEST( test( hpx::util::bind(f_3, placeholders::_1, 2, 3), i ) == 321L ); HPX_TEST( test( hpx::util::bind(f_4, placeholders::_1, 2, 3, 4), i ) == 4321L ); HPX_TEST( test( hpx::util::bind(f_5, placeholders::_1, 2, 3, 4, 5), i ) == 54321L ); - HPX_TEST( test( hpx::util::bind(f_6, placeholders::_1, 2, 3, 4, 5, 6), i ) == 654321L ); - HPX_TEST( test( hpx::util::bind(f_7, placeholders::_1, 2, 3, 4, 5, 6, 7), i ) == 7654321L ); - HPX_TEST( test( hpx::util::bind(f_8, placeholders::_1, 2, 3, 4, 5, 6, 7, 8), i ) == 87654321L ); - HPX_TEST( test( hpx::util::bind(f_9, placeholders::_1, 2, 3, 4, 5, 6, 7, 8, 9), i ) == 987654321L ); + HPX_TEST( test( hpx::util::bind(f_6, placeholders::_1, 2, 3, 4, 5, + 6), i ) == 654321L ); + HPX_TEST( test( hpx::util::bind(f_7, placeholders::_1, 2, 3, 4, 5, + 6, 7), i ) == 7654321L ); + HPX_TEST( test( hpx::util::bind(f_8, placeholders::_1, 2, 3, 4, 5, + 6, 7, 8), i ) == 87654321L ); + HPX_TEST( test( hpx::util::bind(f_9, placeholders::_1, 2, 3, 4, 5, + 6, 7, 8, 9), i ) == 987654321L ); HPX_TEST( testv( hpx::util::bind(fv_0), i ) == 17041L ); HPX_TEST( testv( hpx::util::bind(fv_1, placeholders::_1), i ) == 1L ); HPX_TEST( testv( hpx::util::bind(fv_2, placeholders::_1, 2), i ) == 21L ); HPX_TEST( testv( hpx::util::bind(fv_3, placeholders::_1, 2, 3), i ) == 321L ); HPX_TEST( testv( hpx::util::bind(fv_4, placeholders::_1, 2, 3, 4), i ) == 4321L ); - HPX_TEST( testv( hpx::util::bind(fv_5, placeholders::_1, 2, 3, 4, 5), i ) == 54321L ); - HPX_TEST( testv( hpx::util::bind(fv_6, placeholders::_1, 2, 3, 4, 5, 6), i ) == 654321L ); - HPX_TEST( testv( hpx::util::bind(fv_7, placeholders::_1, 2, 3, 4, 5, 6, 7), i ) == 7654321L ); - HPX_TEST( testv( hpx::util::bind(fv_8, placeholders::_1, 2, 3, 4, 5, 6, 7, 8), i ) == 87654321L ); - HPX_TEST( testv( hpx::util::bind(fv_9, placeholders::_1, 2, 3, 4, 5, 6, 7, 8, 9), i ) == 987654321L ); + HPX_TEST( testv( hpx::util::bind(fv_5, placeholders::_1, 2, 3, 4, 5), + i ) == 54321L ); + HPX_TEST( testv( hpx::util::bind(fv_6, placeholders::_1, 2, 3, 4, 5, + 6), i ) == 654321L ); + HPX_TEST( testv( hpx::util::bind(fv_7, placeholders::_1, 2, 3, 4, 5, + 6, 7), i ) == 7654321L ); + HPX_TEST( testv( hpx::util::bind(fv_8, placeholders::_1, 2, 3, 4, 5, + 6, 7, 8), i ) == 87654321L ); + HPX_TEST( testv( hpx::util::bind(fv_9, placeholders::_1, 2, 3, 4, 5, + 6, 7, 8, 9), i ) == 987654321L ); } int main() diff --git a/tests/unit/util/bind/bind_cv_test.cpp b/tests/unit/util/bind/bind_cv_test.cpp index 899caf2bbc74..ef47dcb20608 100644 --- a/tests/unit/util/bind/bind_cv_test.cpp +++ b/tests/unit/util/bind/bind_cv_test.cpp @@ -95,42 +95,50 @@ struct X return -(x1+x2+x3+x4+x5); } - int operator()(int x1, int x2, int x3, int x4, int x5, int x6) + int operator()(int x1, int x2, int x3, int x4, int x5, + int x6) { return x1+x2+x3+x4+x5+x6; } - int operator()(int x1, int x2, int x3, int x4, int x5, int x6) const + int operator()(int x1, int x2, int x3, int x4, int x5, + int x6) const { return -(x1+x2+x3+x4+x5+x6); } - int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7) + int operator()(int x1, int x2, int x3, int x4, int x5, + int x6, int x7) { return x1+x2+x3+x4+x5+x6+x7; } - int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7) const + int operator()(int x1, int x2, int x3, int x4, int x5, + int x6, int x7) const { return -(x1+x2+x3+x4+x5+x6+x7); } - int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8) + int operator()(int x1, int x2, int x3, int x4, int x5, + int x6, int x7, int x8) { return x1+x2+x3+x4+x5+x6+x7+x8; } - int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8) const + int operator()(int x1, int x2, int x3, int x4, int x5, + int x6, int x7, int x8) const { return -(x1+x2+x3+x4+x5+x6+x7+x8); } - int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9) + int operator()(int x1, int x2, int x3, int x4, int x5, + int x6, int x7, int x8, int x9) { return x1+x2+x3+x4+x5+x6+x7+x8+x9; } - int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9) const + int operator()(int x1, int x2, int x3, int x4, int x5, + int x6, int x7, int x8, int x9) const { return -(x1+x2+x3+x4+x5+x6+x7+x8+x9); } diff --git a/tests/unit/util/bind/bind_dm_test.cpp b/tests/unit/util/bind/bind_dm_test.cpp index b46526d18d6f..793c64c9f478 100644 --- a/tests/unit/util/bind/bind_dm_test.cpp +++ b/tests/unit/util/bind/bind_dm_test.cpp @@ -63,7 +63,8 @@ int main() int const v = 42; - HPX_TEST( hpx::util::bind( &X::m, hpx::util::bind( f, placeholders::_1 ) )( v ) == v ); + HPX_TEST( hpx::util::bind( &X::m, hpx::util::bind( f, + placeholders::_1 ) )( v ) == v ); return hpx::util::report_errors(); } diff --git a/tests/unit/util/bind/bind_eq_test.cpp b/tests/unit/util/bind/bind_eq_test.cpp index e23b8bbb1070..f3512fe8ab3e 100644 --- a/tests/unit/util/bind/bind_eq_test.cpp +++ b/tests/unit/util/bind/bind_eq_test.cpp @@ -179,7 +179,8 @@ template void test_1_(F f, V v1, V v2) template void test_1(F f) { - test_eq( hpx::util::bind(f, placeholders::_1), hpx::util::bind(f, placeholders::_1) ); + test_eq( hpx::util::bind(f, placeholders::_1), + hpx::util::bind(f, placeholders::_1) ); test_1_( f, X(1), X(2) ); @@ -198,7 +199,8 @@ template void test_2_(F f, V v1, V v2) template void test_2(F f) { - test_eq( hpx::util::bind(f, placeholders::_1, placeholders::_2), hpx::util::bind(f, placeholders::_1, placeholders::_2) ); + test_eq( hpx::util::bind(f, placeholders::_1, placeholders::_2), + hpx::util::bind(f, placeholders::_1, placeholders::_2) ); test_2_( f, X(1), X(2) ); @@ -218,7 +220,9 @@ template void test_3_(F f, V v1, V v2) template void test_3(F f) { - test_eq( hpx::util::bind(f, placeholders::_1, placeholders::_2, placeholders::_3), hpx::util::bind(f, placeholders::_1, placeholders::_2, placeholders::_3) ); + test_eq( hpx::util::bind(f, placeholders::_1, placeholders::_2, + placeholders::_3), hpx::util::bind(f, placeholders::_1, placeholders::_2, + placeholders::_3) ); test_3_( f, X(1), X(2) ); @@ -230,16 +234,23 @@ template void test_3(F f) template void test_4_(F f, V v1, V v2) { - test_eq( hpx::util::bind(f, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v2) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v2, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1), hpx::util::bind(f, v1, v2, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1), hpx::util::bind(f, v2, v1, v1, v1) ); + test_eq( hpx::util::bind(f, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v2) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v2, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1), + hpx::util::bind(f, v1, v2, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1), + hpx::util::bind(f, v2, v1, v1, v1) ); } template void test_4(F f) { - test_eq( hpx::util::bind(f, placeholders::_1, placeholders::_2, placeholders::_3, placeholders::_4), hpx::util::bind(f, placeholders::_1, placeholders::_2, placeholders::_3, placeholders::_4) ); + test_eq( hpx::util::bind(f, placeholders::_1, placeholders::_2, + placeholders::_3, placeholders::_4), hpx::util::bind(f, placeholders::_1, + placeholders::_2, placeholders::_3, placeholders::_4) ); test_4_( f, X(1), X(2) ); @@ -251,17 +262,26 @@ template void test_4(F f) template void test_5_(F f, V v1, V v2) { - test_eq( hpx::util::bind(f, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v2) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v2, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v2, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v2, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1), hpx::util::bind(f, v2, v1, v1, v1, v1) ); + test_eq( hpx::util::bind(f, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v2) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v2, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v2, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v2, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1), + hpx::util::bind(f, v2, v1, v1, v1, v1) ); } template void test_5(F f) { - test_eq( hpx::util::bind(f, placeholders::_1, placeholders::_2, placeholders::_3, placeholders::_4, placeholders::_5), hpx::util::bind(f, placeholders::_1, placeholders::_2, placeholders::_3, placeholders::_4, placeholders::_5) ); + test_eq( hpx::util::bind(f, placeholders::_1, placeholders::_2, + placeholders::_3, placeholders::_4, placeholders::_5), + hpx::util::bind(f, placeholders::_1, placeholders::_2, placeholders::_3, + placeholders::_4, placeholders::_5) ); test_5_( f, X(1), X(2) ); @@ -273,18 +293,28 @@ template void test_5(F f) template void test_6_(F f, V v1, V v2) { - test_eq( hpx::util::bind(f, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v1, v2) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v2, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v2, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v2, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v2, v1, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v2, v1, v1, v1, v1, v1) ); + test_eq( hpx::util::bind(f, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v1, v2) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v2, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v2, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v2, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v2, v1, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v2, v1, v1, v1, v1, v1) ); } template void test_6(F f) { - test_eq( hpx::util::bind(f, placeholders::_1, placeholders::_2, placeholders::_3, placeholders::_4, placeholders::_5, placeholders::_6), hpx::util::bind(f, placeholders::_1, placeholders::_2, placeholders::_3, placeholders::_4, placeholders::_5, placeholders::_6) ); + test_eq( hpx::util::bind(f, placeholders::_1, placeholders::_2, + placeholders::_3, placeholders::_4, placeholders::_5, + placeholders::_6), hpx::util::bind(f, placeholders::_1, placeholders::_2, + placeholders::_3, placeholders::_4, placeholders::_5, placeholders::_6) ); test_6_( f, X(1), X(2) ); @@ -296,19 +326,31 @@ template void test_6(F f) template void test_7_(F f, V v1, V v2) { - test_eq( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v2) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v1, v2, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v2, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v2, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v2, v1, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v2, v1, v1, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v2, v1, v1, v1, v1, v1, v1) ); + test_eq( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v2) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v1, v2, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v2, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v2, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v2, v1, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v2, v1, v1, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v2, v1, v1, v1, v1, v1, v1) ); } template void test_7(F f) { - test_eq( hpx::util::bind(f, placeholders::_1, placeholders::_2, placeholders::_3, placeholders::_4, placeholders::_5, placeholders::_6, placeholders::_7), hpx::util::bind(f, placeholders::_1, placeholders::_2, placeholders::_3, placeholders::_4, placeholders::_5, placeholders::_6, placeholders::_7) ); + test_eq( hpx::util::bind(f, placeholders::_1, placeholders::_2, + placeholders::_3, placeholders::_4, placeholders::_5, placeholders::_6, + placeholders::_7), hpx::util::bind(f, placeholders::_1, placeholders::_2, + placeholders::_3, placeholders::_4, placeholders::_5, placeholders::_6, + placeholders::_7) ); test_7_( f, X(1), X(2) ); @@ -320,20 +362,34 @@ template void test_7(F f) template void test_8_(F f, V v1, V v2) { - test_eq( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v2) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v2, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v1, v2, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v2, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v2, v1, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v2, v1, v1, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v2, v1, v1, v1, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v2, v1, v1, v1, v1, v1, v1, v1) ); + test_eq( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v2) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v2, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v1, v2, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v2, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v2, v1, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v2, v1, v1, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v2, v1, v1, v1, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v2, v1, v1, v1, v1, v1, v1, v1) ); } template void test_8(F f) { - test_eq( hpx::util::bind(f, placeholders::_1, placeholders::_2, placeholders::_3, placeholders::_4, placeholders::_5, placeholders::_6, placeholders::_7, placeholders::_8), hpx::util::bind(f, placeholders::_1, placeholders::_2, placeholders::_3, placeholders::_4, placeholders::_5, placeholders::_6, placeholders::_7, placeholders::_8) ); + test_eq( hpx::util::bind(f, placeholders::_1, placeholders::_2, + placeholders::_3, placeholders::_4, placeholders::_5, + placeholders::_6, placeholders::_7, placeholders::_8), + hpx::util::bind(f, placeholders::_1, placeholders::_2, + placeholders::_3, placeholders::_4, placeholders::_5, + placeholders::_6, placeholders::_7, placeholders::_8) ); test_8_( f, X(1), X(2) ); @@ -345,21 +401,36 @@ template void test_8(F f) template void test_9_(F f, V v1, V v2) { - test_eq( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v2) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v2, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v2, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v1, v2, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v1, v2, v1, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v1, v2, v1, v1, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v1, v2, v1, v1, v1, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v1, v2, v1, v1, v1, v1, v1, v1, v1) ); - test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), hpx::util::bind(f, v2, v1, v1, v1, v1, v1, v1, v1, v1) ); + test_eq( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v2) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v2, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v2, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v1, v2, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v1, v2, v1, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v1, v2, v1, v1, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v1, v2, v1, v1, v1, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v1, v2, v1, v1, v1, v1, v1, v1, v1) ); + test_ne( hpx::util::bind(f, v1, v1, v1, v1, v1, v1, v1, v1, v1), + hpx::util::bind(f, v2, v1, v1, v1, v1, v1, v1, v1, v1) ); } template void test_9(F f) { - test_eq( hpx::util::bind(f, placeholders::_1, placeholders::_2, placeholders::_3, placeholders::_4, placeholders::_5, placeholders::_6, placeholders::_7, placeholders::_8, placeholders::_9), hpx::util::bind(f, placeholders::_1, placeholders::_2, placeholders::_3, placeholders::_4, placeholders::_5, placeholders::_6, placeholders::_7, placeholders::_8, placeholders::_9) ); + test_eq( hpx::util::bind(f, placeholders::_1, placeholders::_2, + placeholders::_3, placeholders::_4, placeholders::_5, placeholders::_6, + placeholders::_7, placeholders::_8, placeholders::_9), + hpx::util::bind(f, placeholders::_1, placeholders::_2, + placeholders::_3, placeholders::_4, placeholders::_5, + placeholders::_6, placeholders::_7, placeholders::_8, placeholders::_9) ); test_9_( f, X(1), X(2) ); diff --git a/tests/unit/util/bind/bind_fastcall_mf_test.cpp b/tests/unit/util/bind/bind_fastcall_mf_test.cpp index 1303d3caaf5f..0421ac9e9641 100644 --- a/tests/unit/util/bind/bind_fastcall_mf_test.cpp +++ b/tests/unit/util/bind/bind_fastcall_mf_test.cpp @@ -47,20 +47,30 @@ struct X void __fastcall f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); } void __fastcall g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); } - void __fastcall f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); } - void __fastcall g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); } - - void __fastcall f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); } - void __fastcall g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); } - - void __fastcall f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); } - void __fastcall g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); } - - void __fastcall f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); } - void __fastcall g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); } - - void __fastcall f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); } - void __fastcall g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); } + void __fastcall f4(int a1, int a2, int a3, int a4) + { f3(a1, a2, a3); f1(a4); } + void __fastcall g4(int a1, int a2, int a3, int a4) + const { g3(a1, a2, a3); g1(a4); } + + void __fastcall f5(int a1, int a2, int a3, int a4, int a5) + { f4(a1, a2, a3, a4); f1(a5); } + void __fastcall g5(int a1, int a2, int a3, int a4, int a5) + const { g4(a1, a2, a3, a4); g1(a5); } + + void __fastcall f6(int a1, int a2, int a3, int a4, int a5, int a6) + { f5(a1, a2, a3, a4, a5); f1(a6); } + void __fastcall g6(int a1, int a2, int a3, int a4, int a5, int a6) + const { g5(a1, a2, a3, a4, a5); g1(a6); } + + void __fastcall f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + { f6(a1, a2, a3, a4, a5, a6); f1(a7); } + void __fastcall g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + const { g6(a1, a2, a3, a4, a5, a6); g1(a7); } + + void __fastcall f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); } + void __fastcall g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); } }; void member_function_test() diff --git a/tests/unit/util/bind/bind_fastcall_test.cpp b/tests/unit/util/bind/bind_fastcall_test.cpp index 6fde6819ada5..768441f13080 100644 --- a/tests/unit/util/bind/bind_fastcall_test.cpp +++ b/tests/unit/util/bind/bind_fastcall_test.cpp @@ -73,12 +73,15 @@ long __fastcall f_7(long a, long b, long c, long d, long e, long f, long g) long __fastcall f_8(long a, long b, long c, long d, long e, long f, long g, long h) { - return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + + 100000 * f + 1000000 * g + 10000000 * h; } -long __fastcall f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +long __fastcall f_9(long a, long b, long c, long d, long e, + long f, long g, long h, long i) { - return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; } void function_test() @@ -94,9 +97,12 @@ void function_test() HPX_TEST( hpx::util::bind(f_4, placeholders::_1, 2, 3, 4)(i) == 4321L ); HPX_TEST( hpx::util::bind(f_5, placeholders::_1, 2, 3, 4, 5)(i) == 54321L ); HPX_TEST( hpx::util::bind(f_6, placeholders::_1, 2, 3, 4, 5, 6)(i) == 654321L ); - HPX_TEST( hpx::util::bind(f_7, placeholders::_1, 2, 3, 4, 5, 6, 7)(i) == 7654321L ); - HPX_TEST( hpx::util::bind(f_8, placeholders::_1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L ); - HPX_TEST( hpx::util::bind(f_9, placeholders::_1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L ); + HPX_TEST( hpx::util::bind(f_7, placeholders::_1, 2, 3, 4, 5, + 6, 7)(i) == 7654321L ); + HPX_TEST( hpx::util::bind(f_8, placeholders::_1, 2, 3, 4, 5, + 6, 7, 8)(i) == 87654321L ); + HPX_TEST( hpx::util::bind(f_9, placeholders::_1, 2, 3, 4, 5, + 6, 7, 8, 9)(i) == 987654321L ); } int main() diff --git a/tests/unit/util/bind/bind_not_test.cpp b/tests/unit/util/bind/bind_not_test.cpp index ca4e39c489eb..0ae57824868e 100644 --- a/tests/unit/util/bind/bind_not_test.cpp +++ b/tests/unit/util/bind/bind_not_test.cpp @@ -47,7 +47,8 @@ int main() test( !hpx::util::bind( f, true ), 0, !f( true ) ); test( !hpx::util::bind( g, placeholders::_1 ), 5, !g( 5 ) ); test( hpx::util::bind( f, !hpx::util::bind( f, true ) ), 0, f( !f( true ) ) ); - test( hpx::util::bind( f, !hpx::util::bind( f, placeholders::_1 ) ), true, f( !f( true ) ) ); + test( hpx::util::bind( f, !hpx::util::bind( f, placeholders::_1 ) ), + true, f( !f( true ) ) ); return hpx::util::report_errors(); } diff --git a/tests/unit/util/bind/bind_placeholder_test.cpp b/tests/unit/util/bind/bind_placeholder_test.cpp index 1e26f3d7132f..6e80d277fdc9 100644 --- a/tests/unit/util/bind/bind_placeholder_test.cpp +++ b/tests/unit/util/bind/bind_placeholder_test.cpp @@ -33,7 +33,8 @@ namespace placeholders = hpx::util::placeholders; long f( long a, long b, long c, long d, long e, long f, long g, long h, long i ) { - return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; } template< int I > struct custom_placeholder diff --git a/tests/unit/util/bind/bind_rel_test.cpp b/tests/unit/util/bind/bind_rel_test.cpp index a4c1be564f4d..9659b5bd1249 100644 --- a/tests/unit/util/bind/bind_rel_test.cpp +++ b/tests/unit/util/bind/bind_rel_test.cpp @@ -73,21 +73,31 @@ int main() // bind op placeholder HPX_TEST( ( hpx::util::bind( f, placeholders::_1 ) == placeholders::_2 )( x, y ) ); - HPX_TEST( !( ( hpx::util::bind( f, placeholders::_1 ) != placeholders::_2 )( x, y ) ) ); - HPX_TEST( !( ( hpx::util::bind( f, placeholders::_1 ) < placeholders::_2 )( x, y ) ) ); - HPX_TEST( !( ( hpx::util::bind( f, placeholders::_1 ) > placeholders::_2 )( x, y ) ) ); + HPX_TEST( !( ( hpx::util::bind( f, placeholders::_1 ) != + placeholders::_2 )( x, y ) ) ); + HPX_TEST( !( ( hpx::util::bind( f, placeholders::_1 ) < + placeholders::_2 )( x, y ) ) ); + HPX_TEST( !( ( hpx::util::bind( f, placeholders::_1 ) > + placeholders::_2 )( x, y ) ) ); HPX_TEST( ( hpx::util::bind( f, placeholders::_1 ) <= placeholders::_2 )( x, y ) ); HPX_TEST( ( hpx::util::bind( f, placeholders::_1 ) >= placeholders::_2 )( x, y ) ); // bind op bind - // important: hpx::util::bind( f, placeholders::_1 ) and hpx::util::bind( g, placeholders::_1 ) have the same type - HPX_TEST( ( hpx::util::bind( f, placeholders::_1 ) == hpx::util::bind( g, placeholders::_1 ) )( x ) ); - HPX_TEST( !( ( hpx::util::bind( f, placeholders::_1 ) != hpx::util::bind( g, placeholders::_1 ) )( x ) ) ); - HPX_TEST( !( ( hpx::util::bind( f, placeholders::_1 ) < hpx::util::bind( g, placeholders::_1 ) )( x ) ) ); - HPX_TEST( ( hpx::util::bind( f, placeholders::_1 ) <= hpx::util::bind( g, placeholders::_1 ) )( x ) ); - HPX_TEST( !( ( hpx::util::bind( f, placeholders::_1 ) > hpx::util::bind( g, placeholders::_1 ) )( x ) ) ); - HPX_TEST( ( hpx::util::bind( f, placeholders::_1 ) >= hpx::util::bind( g, placeholders::_1 ) )( x ) ); + // important: hpx::util::bind( f, placeholders::_1 ) and + // hpx::util::bind( g, placeholders::_1 ) have the same type + HPX_TEST( ( hpx::util::bind( f, placeholders::_1 ) == + hpx::util::bind( g, placeholders::_1 ) )( x ) ); + HPX_TEST( !( ( hpx::util::bind( f, placeholders::_1 ) != + hpx::util::bind( g, placeholders::_1 ) )( x ) ) ); + HPX_TEST( !( ( hpx::util::bind( f, placeholders::_1 ) < + hpx::util::bind( g, placeholders::_1 ) )( x ) ) ); + HPX_TEST( ( hpx::util::bind( f, placeholders::_1 ) <= + hpx::util::bind( g, placeholders::_1 ) )( x ) ); + HPX_TEST( !( ( hpx::util::bind( f, placeholders::_1 ) > + hpx::util::bind( g, placeholders::_1 ) )( x ) ) ); + HPX_TEST( ( hpx::util::bind( f, placeholders::_1 ) >= + hpx::util::bind( g, placeholders::_1 ) )( x ) ); return hpx::util::report_errors(); } diff --git a/tests/unit/util/bind/bind_stateful_test.cpp b/tests/unit/util/bind/bind_stateful_test.cpp index 942b27dffbb8..cf40add1eedf 100644 --- a/tests/unit/util/bind/bind_stateful_test.cpp +++ b/tests/unit/util/bind/bind_stateful_test.cpp @@ -94,7 +94,8 @@ class X return state_ += x1+x2+x3+x4+x5+x6+x7+x8; } - int operator()(int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8, int x9) + int operator()(int x1, int x2, int x3, int x4, int x5, + int x6, int x7, int x8, int x9) { return state_ += x1+x2+x3+x4+x5+x6+x7+x8+x9; } @@ -193,10 +194,12 @@ void stateful_function_object_test() test( hpx::util::bind( boost::ref(x), 1, 2, 3, 4, 5, 6, 7 ), n, 1+2+3+4+5+6+7 ); n += 3*(1+2+3+4+5+6+7); - test( hpx::util::bind( boost::ref(x), 1, 2, 3, 4, 5, 6, 7, 8 ), n, 1+2+3+4+5+6+7+8 ); + test( hpx::util::bind( boost::ref(x), 1, 2, 3, 4, 5, + 6, 7, 8 ), n, 1+2+3+4+5+6+7+8 ); n += 3*(1+2+3+4+5+6+7+8); - test( hpx::util::bind( boost::ref(x), 1, 2, 3, 4, 5, 6, 7, 8, 9 ), n, 1+2+3+4+5+6+7+8+9 ); + test( hpx::util::bind( boost::ref(x), 1, 2, 3, 4, 5, + 6, 7, 8, 9 ), n, 1+2+3+4+5+6+7+8+9 ); n += 3*(1+2+3+4+5+6+7+8+9); HPX_TEST( x.state() == n ); diff --git a/tests/unit/util/bind/bind_stdcall_mf_test.cpp b/tests/unit/util/bind/bind_stdcall_mf_test.cpp index 26d163e6ab18..444424d481bb 100644 --- a/tests/unit/util/bind/bind_stdcall_mf_test.cpp +++ b/tests/unit/util/bind/bind_stdcall_mf_test.cpp @@ -47,20 +47,30 @@ struct X int __stdcall f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; } int __stdcall g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; } - int __stdcall f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } - int __stdcall g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } - - int __stdcall f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } - int __stdcall g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } - - int __stdcall f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } - int __stdcall g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } - - int __stdcall f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } - int __stdcall g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } - - int __stdcall f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } - int __stdcall g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } + int __stdcall f4(int a1, int a2, int a3, int a4) + { f3(a1, a2, a3); f1(a4); return 0; } + int __stdcall g4(int a1, int a2, int a3, int a4) + const { g3(a1, a2, a3); g1(a4); return 0; } + + int __stdcall f5(int a1, int a2, int a3, int a4, int a5) + { f4(a1, a2, a3, a4); f1(a5); return 0; } + int __stdcall g5(int a1, int a2, int a3, int a4, int a5) + const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int __stdcall f6(int a1, int a2, int a3, int a4, int a5, int a6) + { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int __stdcall g6(int a1, int a2, int a3, int a4, int a5, int a6) + const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int __stdcall f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int __stdcall g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int __stdcall f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int __stdcall g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } }; void member_function_test() diff --git a/tests/unit/util/bind/bind_stdcall_test.cpp b/tests/unit/util/bind/bind_stdcall_test.cpp index a3eeba9354bc..4551b6c8fcf8 100644 --- a/tests/unit/util/bind/bind_stdcall_test.cpp +++ b/tests/unit/util/bind/bind_stdcall_test.cpp @@ -73,12 +73,15 @@ long __stdcall f_7(long a, long b, long c, long d, long e, long f, long g) long __stdcall f_8(long a, long b, long c, long d, long e, long f, long g, long h) { - return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + + 100000 * f + 1000000 * g + 10000000 * h; } -long __stdcall f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) +long __stdcall f_9(long a, long b, long c, long d, long e, + long f, long g, long h, long i) { - return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; } void function_test() @@ -95,8 +98,10 @@ void function_test() HPX_TEST( hpx::util::bind(f_5, placeholders::_1, 2, 3, 4, 5)(i) == 54321L ); HPX_TEST( hpx::util::bind(f_6, placeholders::_1, 2, 3, 4, 5, 6)(i) == 654321L ); HPX_TEST( hpx::util::bind(f_7, placeholders::_1, 2, 3, 4, 5, 6, 7)(i) == 7654321L ); - HPX_TEST( hpx::util::bind(f_8, placeholders::_1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L ); - HPX_TEST( hpx::util::bind(f_9, placeholders::_1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L ); + HPX_TEST( hpx::util::bind(f_8, placeholders::_1, 2, 3, 4, 5, + 6, 7, 8)(i) == 87654321L ); + HPX_TEST( hpx::util::bind(f_9, placeholders::_1, 2, 3, 4, 5, + 6, 7, 8, 9)(i) == 987654321L ); } int main() diff --git a/tests/unit/util/bind/bind_test.cpp b/tests/unit/util/bind/bind_test.cpp index 51e2d16a39d5..0fd97b737d4a 100644 --- a/tests/unit/util/bind/bind_test.cpp +++ b/tests/unit/util/bind/bind_test.cpp @@ -73,12 +73,14 @@ long f_7(long a, long b, long c, long d, long e, long f, long g) long f_8(long a, long b, long c, long d, long e, long f, long g, long h) { - return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + + 100000 * f + 1000000 * g + 10000000 * h; } long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) { - return a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; + return a + 10 * b + 100 * c + 1000 * d + 10000 * e + + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; } long global_result; @@ -120,17 +122,20 @@ void fv_6(long a, long b, long c, long d, long e, long f) void fv_7(long a, long b, long c, long d, long e, long f, long g) { - global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g; + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + + 100000 * f + 1000000 * g; } void fv_8(long a, long b, long c, long d, long e, long f, long g, long h) { - global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h; + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + + 100000 * f + 1000000 * g + 10000000 * h; } void fv_9(long a, long b, long c, long d, long e, long f, long g, long h, long i) { - global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; + global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i; } void function_test() @@ -143,23 +148,39 @@ void function_test() HPX_TEST( hpx::util::bind(f_1, placeholders::_1)(i) == 1L ); HPX_TEST( hpx::util::bind(f_2, placeholders::_1, 2)(i) == 21L ); HPX_TEST( hpx::util::bind(f_3, placeholders::_1, 2, 3)(i) == 321L ); - HPX_TEST( hpx::util::bind(f_4, placeholders::_1, 2, 3, 4)(i) == 4321L ); - HPX_TEST( hpx::util::bind(f_5, placeholders::_1, 2, 3, 4, 5)(i) == 54321L ); - HPX_TEST( hpx::util::bind(f_6, placeholders::_1, 2, 3, 4, 5, 6)(i) == 654321L ); - HPX_TEST( hpx::util::bind(f_7, placeholders::_1, 2, 3, 4, 5, 6, 7)(i) == 7654321L ); - HPX_TEST( hpx::util::bind(f_8, placeholders::_1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L ); - HPX_TEST( hpx::util::bind(f_9, placeholders::_1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L ); + HPX_TEST( hpx::util::bind(f_4, + placeholders::_1, 2, 3, 4)(i) == 4321L ); + HPX_TEST( hpx::util::bind(f_5, + placeholders::_1, 2, 3, 4, 5)(i) == 54321L ); + HPX_TEST( hpx::util::bind(f_6, + placeholders::_1, 2, 3, 4, 5, 6)(i) == 654321L ); + HPX_TEST( hpx::util::bind(f_7, + placeholders::_1, 2, 3, 4, 5, 6, 7)(i) == 7654321L ); + HPX_TEST( hpx::util::bind(f_8, + placeholders::_1, 2, 3, 4, 5, 6, 7, 8)(i) == 87654321L ); + HPX_TEST( hpx::util::bind(f_9, + placeholders::_1, 2, 3, 4, 5, 6, 7, 8, 9)(i) == 987654321L ); HPX_TEST( (hpx::util::bind(fv_0)(i), (global_result == 17041L)) ); - HPX_TEST( (hpx::util::bind(fv_1, placeholders::_1)(i), (global_result == 1L)) ); - HPX_TEST( (hpx::util::bind(fv_2, placeholders::_1, 2)(i), (global_result == 21L)) ); - HPX_TEST( (hpx::util::bind(fv_3, placeholders::_1, 2, 3)(i), (global_result == 321L)) ); - HPX_TEST( (hpx::util::bind(fv_4, placeholders::_1, 2, 3, 4)(i), (global_result == 4321L)) ); - HPX_TEST( (hpx::util::bind(fv_5, placeholders::_1, 2, 3, 4, 5)(i), (global_result == 54321L)) ); - HPX_TEST( (hpx::util::bind(fv_6, placeholders::_1, 2, 3, 4, 5, 6)(i), (global_result == 654321L)) ); - HPX_TEST( (hpx::util::bind(fv_7, placeholders::_1, 2, 3, 4, 5, 6, 7)(i), (global_result == 7654321L)) ); - HPX_TEST( (hpx::util::bind(fv_8, placeholders::_1, 2, 3, 4, 5, 6, 7, 8)(i), (global_result == 87654321L)) ); - HPX_TEST( (hpx::util::bind(fv_9, placeholders::_1, 2, 3, 4, 5, 6, 7, 8, 9)(i), (global_result == 987654321L)) ); + HPX_TEST( (hpx::util::bind(fv_1, + placeholders::_1)(i), (global_result == 1L)) ); + HPX_TEST( (hpx::util::bind(fv_2, + placeholders::_1, 2)(i), (global_result == 21L)) ); + HPX_TEST( (hpx::util::bind(fv_3, + placeholders::_1, 2, 3)(i), (global_result == 321L)) ); + HPX_TEST( (hpx::util::bind(fv_4, + placeholders::_1, 2, 3, 4)(i), (global_result == 4321L)) ); + HPX_TEST( (hpx::util::bind(fv_5, + placeholders::_1, 2, 3, 4, 5)(i), (global_result == 54321L)) ); + HPX_TEST( (hpx::util::bind(fv_6, + placeholders::_1, 2, 3, 4, 5, 6)(i), (global_result == 654321L)) ); + HPX_TEST( (hpx::util::bind(fv_7, + placeholders::_1, 2, 3, 4, 5, 6, 7)(i), (global_result == 7654321L)) ); + HPX_TEST( (hpx::util::bind(fv_8, + placeholders::_1, 2, 3, 4, 5, 6, 7, 8)(i), (global_result == 87654321L)) ); + HPX_TEST( (hpx::util::bind(fv_9, + placeholders::_1, 2, 3, 4, 5, 6, 7, 8, 9)(i), + (global_result == 987654321L)) ); } // @@ -169,7 +190,8 @@ struct Y short operator()(short & r) const { return ++r; } int operator()(int a, int b) const { return a + 10 * b; } long operator() (long a, long b, long c) const { return a + 10 * b + 100 * c; } - void operator() (long a, long b, long c, long d) const { global_result = a + 10 * b + 100 * c + 1000 * d; } + void operator() (long a, long b, long c, long d) + const { global_result = a + 10 * b + 100 * c + 1000 * d; } }; void function_object_test() @@ -185,7 +207,8 @@ void function_object_test() HPX_TEST( hpx::util::bind(Y(), i, placeholders::_1)(k) == 38 ); HPX_TEST( hpx::util::bind(Y(), i, placeholders::_1, 9)(k) == 938 ); -#if !defined(__MWERKS__) || (__MWERKS__ > 0x2407) // Fails for this version of the compiler. +#if !defined(__MWERKS__) || (__MWERKS__ > 0x2407) + // Fails for this version of the compiler. global_result = 0; hpx::util::bind(Y(), i, placeholders::_1, 9, 4)(k); @@ -214,7 +237,8 @@ void function_object_test2() // -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ + && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) struct Z { @@ -246,23 +270,35 @@ struct X int f2(int a1, int a2) { f1(a1); f1(a2); return 0; } int g2(int a1, int a2) const { g1(a1); g1(a2); return 0; } - int f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); return 0; } - int g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); return 0; } - - int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } - int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } - - int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } - int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } - - int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } - int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } - - int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } - int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } - - int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } - int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } + int f3(int a1, int a2, int a3) + { f2(a1, a2); f1(a3); return 0; } + int g3(int a1, int a2, int a3) + const { g2(a1, a2); g1(a3); return 0; } + + int f4(int a1, int a2, int a3, int a4) + { f3(a1, a2, a3); f1(a4); return 0; } + int g4(int a1, int a2, int a3, int a4) + const { g3(a1, a2, a3); g1(a4); return 0; } + + int f5(int a1, int a2, int a3, int a4, int a5) + { f4(a1, a2, a3, a4); f1(a5); return 0; } + int g5(int a1, int a2, int a3, int a4, int a5) + const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int f6(int a1, int a2, int a3, int a4, int a5, int a6) + { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int g6(int a1, int a2, int a3, int a4, int a5, int a6) + const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } }; struct V @@ -280,23 +316,35 @@ struct V void f2(int a1, int a2) { f1(a1); f1(a2); } void g2(int a1, int a2) const { g1(a1); g1(a2); } - void f3(int a1, int a2, int a3) { f2(a1, a2); f1(a3); } - void g3(int a1, int a2, int a3) const { g2(a1, a2); g1(a3); } - - void f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); } - void g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); } - - void f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); } - void g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); } - - void f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); } - void g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); } - - void f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); } - void g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); } - - void f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); } - void g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); } + void f3(int a1, int a2, int a3) + { f2(a1, a2); f1(a3); } + void g3(int a1, int a2, int a3) + const { g2(a1, a2); g1(a3); } + + void f4(int a1, int a2, int a3, int a4) + { f3(a1, a2, a3); f1(a4); } + void g4(int a1, int a2, int a3, int a4) + const { g3(a1, a2, a3); g1(a4); } + + void f5(int a1, int a2, int a3, int a4, int a5) + { f4(a1, a2, a3, a4); f1(a5); } + void g5(int a1, int a2, int a3, int a4, int a5) + const { g4(a1, a2, a3, a4); g1(a5); } + + void f6(int a1, int a2, int a3, int a4, int a5, + int a6) { f5(a1, a2, a3, a4, a5); f1(a6); } + void g6(int a1, int a2, int a3, int a4, int a5, + int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); } + + void f7(int a1, int a2, int a3, int a4, int a5, + int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); } + void g7(int a1, int a2, int a3, int a4, int a5, + int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); } + + void f8(int a1, int a2, int a3, int a4, int a5, + int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); } + void g8(int a1, int a2, int a3, int a4, int a5, + int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); } }; void member_function_test() @@ -486,17 +534,32 @@ void nested_bind_test() int const x = 1; int const y = 2; - HPX_TEST( hpx::util::bind(f_1, hpx::util::bind(f_1, placeholders::_1))(x) == 1L ); - HPX_TEST( hpx::util::bind(f_1, hpx::util::bind(f_2, placeholders::_1, placeholders::_2))(x, y) == 21L ); - HPX_TEST( hpx::util::bind(f_2, hpx::util::bind(f_1, placeholders::_1), hpx::util::bind(f_1, placeholders::_1))(x) == 11L ); - HPX_TEST( hpx::util::bind(f_2, hpx::util::bind(f_1, placeholders::_1), hpx::util::bind(f_1, placeholders::_2))(x, y) == 21L ); - HPX_TEST( hpx::util::bind(f_1, hpx::util::bind(f_0))() == 17041L ); - - HPX_TEST( (hpx::util::bind(fv_1, hpx::util::bind(f_1, placeholders::_1))(x), (global_result == 1L)) ); - HPX_TEST( (hpx::util::bind(fv_1, hpx::util::bind(f_2, placeholders::_1, placeholders::_2))(x, y), (global_result == 21L)) ); - HPX_TEST( (hpx::util::bind(fv_2, hpx::util::bind(f_1, placeholders::_1), hpx::util::bind(f_1, placeholders::_1))(x), (global_result == 11L)) ); - HPX_TEST( (hpx::util::bind(fv_2, hpx::util::bind(f_1, placeholders::_1), hpx::util::bind(f_1, placeholders::_2))(x, y), (global_result == 21L)) ); - HPX_TEST( (hpx::util::bind(fv_1, hpx::util::bind(f_0))(), (global_result == 17041L)) ); + HPX_TEST( hpx::util::bind(f_1, + hpx::util::bind(f_1, placeholders::_1))(x) == 1L ); + HPX_TEST( hpx::util::bind(f_1, + hpx::util::bind(f_2, placeholders::_1, placeholders::_2))(x, y) == 21L ); + HPX_TEST( hpx::util::bind(f_2, + hpx::util::bind(f_1, placeholders::_1), + hpx::util::bind(f_1, placeholders::_1))(x) == 11L ); + HPX_TEST( hpx::util::bind(f_2, + hpx::util::bind(f_1, placeholders::_1), + hpx::util::bind(f_1, placeholders::_2))(x, y) == 21L ); + HPX_TEST( hpx::util::bind(f_1, + hpx::util::bind(f_0))() == 17041L ); + + HPX_TEST( (hpx::util::bind(fv_1, + hpx::util::bind(f_1, placeholders::_1))(x), (global_result == 1L)) ); + HPX_TEST( (hpx::util::bind(fv_1, + hpx::util::bind(f_2, placeholders::_1, placeholders::_2))(x, y), + (global_result == 21L)) ); + HPX_TEST( (hpx::util::bind(fv_2, + hpx::util::bind(f_1, placeholders::_1), + hpx::util::bind(f_1, placeholders::_1))(x), (global_result == 11L)) ); + HPX_TEST( (hpx::util::bind(fv_2, + hpx::util::bind(f_1, placeholders::_1), + hpx::util::bind(f_1, placeholders::_2))(x, y), (global_result == 21L)) ); + HPX_TEST( (hpx::util::bind(fv_1, + hpx::util::bind(f_0))(), (global_result == 17041L)) ); } int main() diff --git a/tests/unit/util/bind/protect_test.cpp b/tests/unit/util/bind/protect_test.cpp index 1f2c2f67391c..b24f5fa46ce4 100644 --- a/tests/unit/util/bind/protect_test.cpp +++ b/tests/unit/util/bind/protect_test.cpp @@ -44,115 +44,204 @@ int main() // test lvalues - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_1))(i[0]), &i[0]); - - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_1))(i[0], i[1]), &i[0]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_2))(i[0], i[1]), &i[1]); - - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_1))(i[0], i[1], i[2]), &i[0]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_2))(i[0], i[1], i[2]), &i[1]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_3))(i[0], i[1], i[2]), &i[2]); - - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_1))(i[0], i[1], i[2], i[3]), &i[0]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_2))(i[0], i[1], i[2], i[3]), &i[1]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_3))(i[0], i[1], i[2], i[3]), &i[2]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_4))(i[0], i[1], i[2], i[3]), &i[3]); - - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_1))(i[0], i[1], i[2], i[3], i[4]), &i[0]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_2))(i[0], i[1], i[2], i[3], i[4]), &i[1]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_3))(i[0], i[1], i[2], i[3], i[4]), &i[2]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_4))(i[0], i[1], i[2], i[3], i[4]), &i[3]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_5))(i[0], i[1], i[2], i[3], i[4]), &i[4]); - - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_1))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[0]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_2))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[1]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_3))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[2]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_4))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[3]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_5))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[4]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_6))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[5]); - - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_1))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[0]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_2))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[1]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_3))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[2]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_4))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[3]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_5))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[4]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_6))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[5]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_7))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[6]); - - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_1))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[0]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_2))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[1]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_3))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[2]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_4))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[3]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_5))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[4]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_6))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[5]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_7))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[6]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_8))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[7]); - - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_1))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[0]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_2))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[1]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_3))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[2]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_4))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[3]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_5))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[4]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_6))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[5]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_7))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[6]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_8))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[7]); - HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, placeholders::_9))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[8]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_1))(i[0]), &i[0]); + + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_1))(i[0], i[1]), &i[0]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_2))(i[0], i[1]), &i[1]); + + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_1))(i[0], i[1], i[2]), &i[0]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_2))(i[0], i[1], i[2]), &i[1]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_3))(i[0], i[1], i[2]), &i[2]); + + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_1))(i[0], i[1], i[2], i[3]), &i[0]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_2))(i[0], i[1], i[2], i[3]), &i[1]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_3))(i[0], i[1], i[2], i[3]), &i[2]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_4))(i[0], i[1], i[2], i[3]), &i[3]); + + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_1))(i[0], i[1], i[2], i[3], i[4]), &i[0]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_2))(i[0], i[1], i[2], i[3], i[4]), &i[1]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_3))(i[0], i[1], i[2], i[3], i[4]), &i[2]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_4))(i[0], i[1], i[2], i[3], i[4]), &i[3]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_5))(i[0], i[1], i[2], i[3], i[4]), &i[4]); + + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_1))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[0]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_2))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[1]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_3))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[2]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_4))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[3]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_5))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[4]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_6))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[5]); + + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_1))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[0]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_2))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[1]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_3))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[2]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_4))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[3]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_5))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[4]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_6))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[5]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_7))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[6]); + + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_1))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[0]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_2))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[1]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_3))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[2]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_4))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[3]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_5))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[4]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_6))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[5]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_7))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[6]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_8))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[7]); + + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_1))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[0]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_2))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[1]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_3))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[2]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_4))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[3]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_5))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[4]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_6))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[5]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_7))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[6]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_8))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[7]); + HPX_TEST_EQ(&hpx::util::protect(hpx::util::bind(g, + placeholders::_9))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[8]); // test rvalues HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_1))(0), 0); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_1))(0, 1), 0); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_2))(0, 1), 1); - - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_1))(0, 1, 2), 0); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_2))(0, 1, 2), 1); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_3))(0, 1, 2), 2); - - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_1))(0, 1, 2, 3), 0); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_2))(0, 1, 2, 3), 1); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_3))(0, 1, 2, 3), 2); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_4))(0, 1, 2, 3), 3); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_1))(0, 1), 0); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_2))(0, 1), 1); + + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_1))(0, 1, 2), 0); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_2))(0, 1, 2), 1); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_3))(0, 1, 2), 2); + + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_1))(0, 1, 2, 3), 0); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_2))(0, 1, 2, 3), 1); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_3))(0, 1, 2, 3), 2); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_4))(0, 1, 2, 3), 3); // - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_1))(0, 1, 2, 3, 4), 0); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_2))(0, 1, 2, 3, 4), 1); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_3))(0, 1, 2, 3, 4), 2); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_4))(0, 1, 2, 3, 4), 3); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_5))(0, 1, 2, 3, 4), 4); - - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_1))(0, 1, 2, 3, 4, 5), 0); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_2))(0, 1, 2, 3, 4, 5), 1); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_3))(0, 1, 2, 3, 4, 5), 2); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_4))(0, 1, 2, 3, 4, 5), 3); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_5))(0, 1, 2, 3, 4, 5), 4); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_6))(0, 1, 2, 3, 4, 5), 5); - - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_1))(0, 1, 2, 3, 4, 5, 6), 0); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_2))(0, 1, 2, 3, 4, 5, 6), 1); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_3))(0, 1, 2, 3, 4, 5, 6), 2); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_4))(0, 1, 2, 3, 4, 5, 6), 3); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_5))(0, 1, 2, 3, 4, 5, 6), 4); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_6))(0, 1, 2, 3, 4, 5, 6), 5); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_7))(0, 1, 2, 3, 4, 5, 6), 6); - - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_1))(0, 1, 2, 3, 4, 5, 6, 7), 0); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_2))(0, 1, 2, 3, 4, 5, 6, 7), 1); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_3))(0, 1, 2, 3, 4, 5, 6, 7), 2); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_4))(0, 1, 2, 3, 4, 5, 6, 7), 3); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_5))(0, 1, 2, 3, 4, 5, 6, 7), 4); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_6))(0, 1, 2, 3, 4, 5, 6, 7), 5); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_7))(0, 1, 2, 3, 4, 5, 6, 7), 6); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_8))(0, 1, 2, 3, 4, 5, 6, 7), 7); - - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_1))(0, 1, 2, 3, 4, 5, 6, 7, 8), 0); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_2))(0, 1, 2, 3, 4, 5, 6, 7, 8), 1); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_3))(0, 1, 2, 3, 4, 5, 6, 7, 8), 2); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_4))(0, 1, 2, 3, 4, 5, 6, 7, 8), 3); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_5))(0, 1, 2, 3, 4, 5, 6, 7, 8), 4); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_6))(0, 1, 2, 3, 4, 5, 6, 7, 8), 5); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_7))(0, 1, 2, 3, 4, 5, 6, 7, 8), 6); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_8))(0, 1, 2, 3, 4, 5, 6, 7, 8), 7); - HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_9))(0, 1, 2, 3, 4, 5, 6, 7, 8), 8); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_1))(0, 1, 2, 3, 4), 0); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_2))(0, 1, 2, 3, 4), 1); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_3))(0, 1, 2, 3, 4), 2); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_4))(0, 1, 2, 3, 4), 3); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_5))(0, 1, 2, 3, 4), 4); + + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_1))(0, 1, 2, 3, 4, 5), 0); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_2))(0, 1, 2, 3, 4, 5), 1); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_3))(0, 1, 2, 3, 4, 5), 2); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_4))(0, 1, 2, 3, 4, 5), 3); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_5))(0, 1, 2, 3, 4, 5), 4); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_6))(0, 1, 2, 3, 4, 5), 5); + + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_1))(0, 1, 2, 3, 4, 5, 6), 0); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_2))(0, 1, 2, 3, 4, 5, 6), 1); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_3))(0, 1, 2, 3, 4, 5, 6), 2); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_4))(0, 1, 2, 3, 4, 5, 6), 3); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_5))(0, 1, 2, 3, 4, 5, 6), 4); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_6))(0, 1, 2, 3, 4, 5, 6), 5); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_7))(0, 1, 2, 3, 4, 5, 6), 6); + + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_1))(0, 1, 2, 3, 4, 5, 6, 7), 0); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_2))(0, 1, 2, 3, 4, 5, 6, 7), 1); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_3))(0, 1, 2, 3, 4, 5, 6, 7), 2); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_4))(0, 1, 2, 3, 4, 5, 6, 7), 3); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_5))(0, 1, 2, 3, 4, 5, 6, 7), 4); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_6))(0, 1, 2, 3, 4, 5, 6, 7), 5); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_7))(0, 1, 2, 3, 4, 5, 6, 7), 6); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_8))(0, 1, 2, 3, 4, 5, 6, 7), 7); + + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_1))(0, 1, 2, 3, 4, 5, 6, 7, 8), 0); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_2))(0, 1, 2, 3, 4, 5, 6, 7, 8), 1); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_3))(0, 1, 2, 3, 4, 5, 6, 7, 8), 2); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_4))(0, 1, 2, 3, 4, 5, 6, 7, 8), 3); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_5))(0, 1, 2, 3, 4, 5, 6, 7, 8), 4); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_6))(0, 1, 2, 3, 4, 5, 6, 7, 8), 5); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_7))(0, 1, 2, 3, 4, 5, 6, 7, 8), 6); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_8))(0, 1, 2, 3, 4, 5, 6, 7, 8), 7); + HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, + placeholders::_9))(0, 1, 2, 3, 4, 5, 6, 7, 8), 8); // test mixed perfect forwarding HPX_TEST_EQ(hpx::util::protect(hpx::util::bind(f, placeholders::_1))(i[0], 1), 0); @@ -166,121 +255,232 @@ int main() HPX_TEST_EQ(constify(constify(hpx::util::protect(hpx::util::bind(f, 1))))(), 1); // test lvalues - HPX_TEST_EQ(&constify(constify(hpx::util::protect(hpx::util::bind(g, placeholders::_1))))(i[0]), &i[0]); - - HPX_TEST_EQ(&constify(constify(hpx::util::protect(hpx::util::bind(g, placeholders::_1))))(i[0], i[1]), &i[0]); - HPX_TEST_EQ(&constify(constify(hpx::util::protect(hpx::util::bind(g, placeholders::_2))))(i[0], i[1]), &i[1]); - - HPX_TEST_EQ(&constify(constify(hpx::util::protect(hpx::util::bind(g, placeholders::_1))))(i[0], i[1], i[2]), &i[0]); - HPX_TEST_EQ(&constify(constify(hpx::util::protect(hpx::util::bind(g, placeholders::_2))))(i[0], i[1], i[2]), &i[1]); - HPX_TEST_EQ(&constify(constify(hpx::util::protect(hpx::util::bind(g, placeholders::_3))))(i[0], i[1], i[2]), &i[2]); - - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_1)))(i[0], i[1], i[2], i[3]), &i[0]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_2)))(i[0], i[1], i[2], i[3]), &i[1]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_3)))(i[0], i[1], i[2], i[3]), &i[2]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_4)))(i[0], i[1], i[2], i[3]), &i[3]); - - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_1)))(i[0], i[1], i[2], i[3], i[4]), &i[0]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_2)))(i[0], i[1], i[2], i[3], i[4]), &i[1]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_3)))(i[0], i[1], i[2], i[3], i[4]), &i[2]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_4)))(i[0], i[1], i[2], i[3], i[4]), &i[3]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_5)))(i[0], i[1], i[2], i[3], i[4]), &i[4]); - - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_1)))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[0]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_2)))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[1]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_3)))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[2]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_4)))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[3]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_5)))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[4]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_6)))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[5]); - - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_1)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[0]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_2)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[1]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_3)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[2]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_4)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[3]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_5)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[4]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_6)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[5]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_7)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[6]); - - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_1)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[0]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_2)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[1]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_3)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[2]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_4)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[3]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_5)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[4]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_6)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[5]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_7)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[6]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_8)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7]), &i[7]); - - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_1)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[0]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_2)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[1]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_3)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[2]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_4)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[3]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_5)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[4]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_6)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[5]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_7)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[6]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_8)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[7]); - HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, placeholders::_9)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7], i[8]), &i[8]); + HPX_TEST_EQ(&constify(constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_1))))(i[0]), &i[0]); + + HPX_TEST_EQ(&constify(constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_1))))(i[0], i[1]), &i[0]); + HPX_TEST_EQ(&constify(constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_2))))(i[0], i[1]), &i[1]); + + HPX_TEST_EQ(&constify(constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_1))))(i[0], i[1], i[2]), &i[0]); + HPX_TEST_EQ(&constify(constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_2))))(i[0], i[1], i[2]), &i[1]); + HPX_TEST_EQ(&constify(constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_3))))(i[0], i[1], i[2]), &i[2]); + + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_1)))(i[0], i[1], i[2], i[3]), &i[0]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_2)))(i[0], i[1], i[2], i[3]), &i[1]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_3)))(i[0], i[1], i[2], i[3]), &i[2]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_4)))(i[0], i[1], i[2], i[3]), &i[3]); + + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_1)))(i[0], i[1], i[2], i[3], i[4]), &i[0]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_2)))(i[0], i[1], i[2], i[3], i[4]), &i[1]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_3)))(i[0], i[1], i[2], i[3], i[4]), &i[2]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_4)))(i[0], i[1], i[2], i[3], i[4]), &i[3]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_5)))(i[0], i[1], i[2], i[3], i[4]), &i[4]); + + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_1)))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[0]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_2)))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[1]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_3)))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[2]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_4)))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[3]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_5)))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[4]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_6)))(i[0], i[1], i[2], i[3], i[4], i[5]), &i[5]); + + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_1)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[0]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_2)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[1]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_3)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[2]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_4)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[3]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_5)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[4]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_6)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[5]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_7)))(i[0], i[1], i[2], i[3], i[4], i[5], i[6]), &i[6]); + + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_1)))(i[0], i[1], i[2], i[3], i[4], i[5], + i[6], i[7]), &i[0]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_2)))(i[0], i[1], i[2], i[3], i[4], i[5], + i[6], i[7]), &i[1]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_3)))(i[0], i[1], i[2], i[3], i[4], i[5], + i[6], i[7]), &i[2]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_4)))(i[0], i[1], i[2], i[3], i[4], i[5], + i[6], i[7]), &i[3]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_5)))(i[0], i[1], i[2], i[3], i[4], i[5], + i[6], i[7]), &i[4]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_6)))(i[0], i[1], i[2], i[3], i[4], i[5], + i[6], i[7]), &i[5]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_7)))(i[0], i[1], i[2], i[3], i[4], i[5], + i[6], i[7]), &i[6]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_8)))(i[0], i[1], i[2], i[3], i[4], i[5], + i[6], i[7]), &i[7]); + + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_1)))(i[0], i[1], i[2], i[3], i[4], i[5], + i[6], i[7], i[8]), &i[0]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_2)))(i[0], i[1], i[2], i[3], i[4], i[5], + i[6], i[7], i[8]), &i[1]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_3)))(i[0], i[1], i[2], i[3], i[4], i[5], + i[6], i[7], i[8]), &i[2]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_4)))(i[0], i[1], i[2], i[3], i[4], i[5], + i[6], i[7], i[8]), &i[3]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_5)))(i[0], i[1], i[2], i[3], i[4], i[5], + i[6], i[7], i[8]), &i[4]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_6)))(i[0], i[1], i[2], i[3], i[4], i[5], + i[6], i[7], i[8]), &i[5]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_7)))(i[0], i[1], i[2], i[3], i[4], i[5], + i[6], i[7], i[8]), &i[6]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_8)))(i[0], i[1], i[2], i[3], i[4], i[5], + i[6], i[7], i[8]), &i[7]); + HPX_TEST_EQ(&constify(hpx::util::protect(hpx::util::bind(g, + placeholders::_9)))(i[0], i[1], i[2], i[3], i[4], i[5], + i[6], i[7], i[8]), &i[8]); // test rvalues - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_1)))(0), 0); - - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_1)))(0, 1), 0); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_2)))(0, 1), 1); - - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_1)))(0, 1, 2), 0); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_2)))(0, 1, 2), 1); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_3)))(0, 1, 2), 2); - - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_1)))(0, 1, 2, 3), 0); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_2)))(0, 1, 2, 3), 1); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_3)))(0, 1, 2, 3), 2); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_4)))(0, 1, 2, 3), 3); - - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_1)))(0, 1, 2, 3, 4), 0); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_2)))(0, 1, 2, 3, 4), 1); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_3)))(0, 1, 2, 3, 4), 2); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_4)))(0, 1, 2, 3, 4), 3); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_5)))(0, 1, 2, 3, 4), 4); - - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_1)))(0, 1, 2, 3, 4, 5), 0); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_2)))(0, 1, 2, 3, 4, 5), 1); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_3)))(0, 1, 2, 3, 4, 5), 2); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_4)))(0, 1, 2, 3, 4, 5), 3); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_5)))(0, 1, 2, 3, 4, 5), 4); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_6)))(0, 1, 2, 3, 4, 5), 5); - - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_1)))(0, 1, 2, 3, 4, 5, 6), 0); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_2)))(0, 1, 2, 3, 4, 5, 6), 1); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_3)))(0, 1, 2, 3, 4, 5, 6), 2); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_4)))(0, 1, 2, 3, 4, 5, 6), 3); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_5)))(0, 1, 2, 3, 4, 5, 6), 4); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_6)))(0, 1, 2, 3, 4, 5, 6), 5); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_7)))(0, 1, 2, 3, 4, 5, 6), 6); - - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_1)))(0, 1, 2, 3, 4, 5, 6, 7), 0); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_2)))(0, 1, 2, 3, 4, 5, 6, 7), 1); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_3)))(0, 1, 2, 3, 4, 5, 6, 7), 2); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_4)))(0, 1, 2, 3, 4, 5, 6, 7), 3); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_5)))(0, 1, 2, 3, 4, 5, 6, 7), 4); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_6)))(0, 1, 2, 3, 4, 5, 6, 7), 5); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_7)))(0, 1, 2, 3, 4, 5, 6, 7), 6); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_8)))(0, 1, 2, 3, 4, 5, 6, 7), 7); - - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_1)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 0); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_2)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 1); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_3)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 2); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_4)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 3); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_5)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 4); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_6)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 5); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_7)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 6); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_8)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 7); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_9)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 8); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_1)))(0), 0); + + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_1)))(0, 1), 0); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_2)))(0, 1), 1); + + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_1)))(0, 1, 2), 0); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_2)))(0, 1, 2), 1); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_3)))(0, 1, 2), 2); + + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_1)))(0, 1, 2, 3), 0); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_2)))(0, 1, 2, 3), 1); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_3)))(0, 1, 2, 3), 2); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_4)))(0, 1, 2, 3), 3); + + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_1)))(0, 1, 2, 3, 4), 0); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_2)))(0, 1, 2, 3, 4), 1); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_3)))(0, 1, 2, 3, 4), 2); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_4)))(0, 1, 2, 3, 4), 3); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_5)))(0, 1, 2, 3, 4), 4); + + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_1)))(0, 1, 2, 3, 4, 5), 0); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_2)))(0, 1, 2, 3, 4, 5), 1); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_3)))(0, 1, 2, 3, 4, 5), 2); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_4)))(0, 1, 2, 3, 4, 5), 3); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_5)))(0, 1, 2, 3, 4, 5), 4); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_6)))(0, 1, 2, 3, 4, 5), 5); + + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_1)))(0, 1, 2, 3, 4, 5, 6), 0); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_2)))(0, 1, 2, 3, 4, 5, 6), 1); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_3)))(0, 1, 2, 3, 4, 5, 6), 2); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_4)))(0, 1, 2, 3, 4, 5, 6), 3); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_5)))(0, 1, 2, 3, 4, 5, 6), 4); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_6)))(0, 1, 2, 3, 4, 5, 6), 5); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_7)))(0, 1, 2, 3, 4, 5, 6), 6); + + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_1)))(0, 1, 2, 3, 4, 5, 6, 7), 0); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_2)))(0, 1, 2, 3, 4, 5, 6, 7), 1); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_3)))(0, 1, 2, 3, 4, 5, 6, 7), 2); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_4)))(0, 1, 2, 3, 4, 5, 6, 7), 3); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_5)))(0, 1, 2, 3, 4, 5, 6, 7), 4); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_6)))(0, 1, 2, 3, 4, 5, 6, 7), 5); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_7)))(0, 1, 2, 3, 4, 5, 6, 7), 6); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_8)))(0, 1, 2, 3, 4, 5, 6, 7), 7); + + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_1)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 0); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_2)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 1); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_3)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 2); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_4)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 3); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_5)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 4); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_6)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 5); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_7)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 6); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_8)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 7); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_9)))(0, 1, 2, 3, 4, 5, 6, 7, 8), 8); // test mixed perfect forwarding - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_1)))(i[0], 1), 0); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_2)))(i[0], 1), 1); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_1)))(0, i[1]), 0); - HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, placeholders::_2)))(0, i[1]), 1); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_1)))(i[0], 1), 0); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_2)))(i[0], 1), 1); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_1)))(0, i[1]), 0); + HPX_TEST_EQ(constify(hpx::util::protect(hpx::util::bind(f, + placeholders::_2)))(0, i[1]), 1); return hpx::util::report_errors(); } diff --git a/tests/unit/util/boost_any.cpp b/tests/unit/util/boost_any.cpp index eba20721520a..3274b8342150 100644 --- a/tests/unit/util/boost_any.cpp +++ b/tests/unit/util/boost_any.cpp @@ -104,7 +104,8 @@ namespace any_tests // test definitions HPX_TEST_MSG(value.empty(), "empty"); HPX_TEST_EQ_MSG((void*)0, any_cast(&value), "any_cast"); - HPX_TEST_EQ_MSG(value.type(), BOOST_SP_TYPEID(hpx::util::detail::any::empty), "type"); + HPX_TEST_EQ_MSG(value.type(), BOOST_SP_TYPEID(hpx::util::detail::any::empty), + "type"); } void test_converting_ctor() @@ -115,7 +116,8 @@ namespace any_tests // test definitions HPX_TEST_EQ_MSG(false, value.empty(), "empty"); HPX_TEST_EQ_MSG(value.type(), typeid(std::string), "type"); HPX_TEST_EQ_MSG((void*)0, any_cast(&value), "any_cast"); - HPX_TEST_NEQ_MSG((void*)0, any_cast(&value), "any_cast"); + HPX_TEST_NEQ_MSG((void*)0, any_cast(&value), + "any_cast"); HPX_TEST_EQ_MSG( any_cast(value), text, "comparing cast copy against original text"); @@ -173,7 +175,8 @@ namespace any_tests // test definitions HPX_TEST_EQ_MSG(false, value.empty(), "type"); HPX_TEST_EQ_MSG(value.type(), typeid(std::string), "type"); HPX_TEST_EQ_MSG((void*)0, any_cast(&value), "any_cast"); - HPX_TEST_NEQ_MSG((void*)0, any_cast(&value), "any_cast"); + HPX_TEST_NEQ_MSG((void*)0, any_cast(&value), + "any_cast"); HPX_TEST_EQ_MSG( any_cast(value), text, "comparing cast copy against original text"); @@ -233,7 +236,8 @@ namespace any_tests // test definitions any copy2 = any(copy_counter()); int count = copy_counter::get_count(); swap(copy1, copy2); - HPX_TEST_EQ_MSG(count, copy_counter::get_count(), "checking that free swap doesn't make any copies."); + HPX_TEST_EQ_MSG(count, copy_counter::get_count(), + "checking that free swap doesn't make any copies."); } void test_swap_big() @@ -265,7 +269,8 @@ namespace any_tests // test definitions any copy2 = any(copy_counter()); int count = copy_counter::get_count(); swap(copy1, copy2); - HPX_TEST_EQ_MSG(count, copy_counter::get_count(), "checking that free swap doesn't make any copies."); + HPX_TEST_EQ_MSG(count, copy_counter::get_count(), + "checking that free swap doesn't make any copies."); } void test_null_copying() diff --git a/tests/unit/util/function.cpp b/tests/unit/util/function.cpp index a02c71b5e6e8..14ace0bb9f61 100644 --- a/tests/unit/util/function.cpp +++ b/tests/unit/util/function.cpp @@ -201,9 +201,11 @@ int hpx_main(variables_map& vm) big_object const f(5, 12); - function f0(f); + function + f0(f); - function f1(f0); + function + f1(f0); function f2; @@ -245,11 +247,14 @@ int hpx_main(variables_map& vm) big_object const f(5, 12); - function f0(f); + function f0(f); - function f1(f0); + function f1(f0); - function f2; + function f2; f2 = f0; diff --git a/tests/unit/util/function/allocator_test.cpp b/tests/unit/util/function/allocator_test.cpp index 327af8a658f4..c7c5b4de3e9d 100644 --- a/tests/unit/util/function/allocator_test.cpp +++ b/tests/unit/util/function/allocator_test.cpp @@ -104,13 +104,15 @@ int hpx::util::function_nonser fv; alloc_count = 0; dealloc_count = 0; - fv.assign( DoNothing(), counting_allocator() ); + fv.assign( DoNothing(), + counting_allocator() ); fv.clear(); HPX_CHECK(alloc_count == 1); HPX_CHECK(dealloc_count == 1); alloc_count = 0; dealloc_count = 0; - fv.assign( DoNothing(), counting_allocator() ); + fv.assign( DoNothing(), + counting_allocator() ); fv.clear(); HPX_CHECK(alloc_count == 0); HPX_CHECK(dealloc_count == 0); diff --git a/tests/unit/util/mem_fn/mem_fn_derived_test.cpp b/tests/unit/util/mem_fn/mem_fn_derived_test.cpp index 3691f649099b..279ad630df4a 100644 --- a/tests/unit/util/mem_fn/mem_fn_derived_test.cpp +++ b/tests/unit/util/mem_fn/mem_fn_derived_test.cpp @@ -48,17 +48,25 @@ struct B int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } - int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } - int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } - - int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } - int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } - - int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } - int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } - - int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } - int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } + int f5(int a1, int a2, int a3, int a4, int a5) + { f4(a1, a2, a3, a4); f1(a5); return 0; } + int g5(int a1, int a2, int a3, int a4, int a5) + const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int f6(int a1, int a2, int a3, int a4, int a5, int a6) + { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int g6(int a1, int a2, int a3, int a4, int a5, int a6) + const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } }; struct X: public B diff --git a/tests/unit/util/mem_fn/mem_fn_rv_test.cpp b/tests/unit/util/mem_fn/mem_fn_rv_test.cpp index d2c8e305e786..93b0cdff3598 100644 --- a/tests/unit/util/mem_fn/mem_fn_rv_test.cpp +++ b/tests/unit/util/mem_fn/mem_fn_rv_test.cpp @@ -47,17 +47,25 @@ struct X int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } - int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } - int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } - - int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } - int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } - - int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } - int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } - - int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } - int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } + int f5(int a1, int a2, int a3, int a4, int a5) + { f4(a1, a2, a3, a4); f1(a5); return 0; } + int g5(int a1, int a2, int a3, int a4, int a5) + const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int f6(int a1, int a2, int a3, int a4, int a5, int a6) + { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int g6(int a1, int a2, int a3, int a4, int a5, int a6) + const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } }; boost::shared_ptr make() diff --git a/tests/unit/util/mem_fn/mem_fn_test.cpp b/tests/unit/util/mem_fn/mem_fn_test.cpp index 519ffe15cc92..df1679731d87 100644 --- a/tests/unit/util/mem_fn/mem_fn_test.cpp +++ b/tests/unit/util/mem_fn/mem_fn_test.cpp @@ -48,17 +48,25 @@ struct X int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } - int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } - int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } - - int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } - int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } - - int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } - int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } - - int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } - int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } + int f5(int a1, int a2, int a3, int a4, int a5) + { f4(a1, a2, a3, a4); f1(a5); return 0; } + int g5(int a1, int a2, int a3, int a4, int a5) + const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int f6(int a1, int a2, int a3, int a4, int a5, int a6) + { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int g6(int a1, int a2, int a3, int a4, int a5, int a6) + const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } }; int main() diff --git a/tests/unit/util/mem_fn/mem_fn_unary_addr_test.cpp b/tests/unit/util/mem_fn/mem_fn_unary_addr_test.cpp index a2341b0bceca..b63febca784d 100644 --- a/tests/unit/util/mem_fn/mem_fn_unary_addr_test.cpp +++ b/tests/unit/util/mem_fn/mem_fn_unary_addr_test.cpp @@ -46,17 +46,25 @@ struct X int f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); return 0; } int g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); return 0; } - int f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); return 0; } - int g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); return 0; } - - int f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } - int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } - - int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } - int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } - - int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } - int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } + int f5(int a1, int a2, int a3, int a4, int a5) + { f4(a1, a2, a3, a4); f1(a5); return 0; } + int g5(int a1, int a2, int a3, int a4, int a5) + const { g4(a1, a2, a3, a4); g1(a5); return 0; } + + int f6(int a1, int a2, int a3, int a4, int a5, int a6) + { f5(a1, a2, a3, a4, a5); f1(a6); return 0; } + int g6(int a1, int a2, int a3, int a4, int a5, int a6) + const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; } + + int f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + { f6(a1, a2, a3, a4, a5, a6); f1(a7); return 0; } + int g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + const { g6(a1, a2, a3, a4, a5, a6); g1(a7); return 0; } + + int f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); return 0; } + int g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); return 0; } }; template class Y diff --git a/tests/unit/util/mem_fn/mem_fn_void_test.cpp b/tests/unit/util/mem_fn/mem_fn_void_test.cpp index 7d7323ec7e2c..0b386b124338 100644 --- a/tests/unit/util/mem_fn/mem_fn_void_test.cpp +++ b/tests/unit/util/mem_fn/mem_fn_void_test.cpp @@ -48,17 +48,25 @@ struct X void f4(int a1, int a2, int a3, int a4) { f3(a1, a2, a3); f1(a4); } void g4(int a1, int a2, int a3, int a4) const { g3(a1, a2, a3); g1(a4); } - void f5(int a1, int a2, int a3, int a4, int a5) { f4(a1, a2, a3, a4); f1(a5); } - void g5(int a1, int a2, int a3, int a4, int a5) const { g4(a1, a2, a3, a4); g1(a5); } - - void f6(int a1, int a2, int a3, int a4, int a5, int a6) { f5(a1, a2, a3, a4, a5); f1(a6); } - void g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); } - - void f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) { f6(a1, a2, a3, a4, a5, a6); f1(a7); } - void g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) const { g6(a1, a2, a3, a4, a5, a6); g1(a7); } - - void f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); } - void g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); } + void f5(int a1, int a2, int a3, int a4, int a5) + { f4(a1, a2, a3, a4); f1(a5); } + void g5(int a1, int a2, int a3, int a4, int a5) + const { g4(a1, a2, a3, a4); g1(a5); } + + void f6(int a1, int a2, int a3, int a4, int a5, int a6) + { f5(a1, a2, a3, a4, a5); f1(a6); } + void g6(int a1, int a2, int a3, int a4, int a5, int a6) + const { g5(a1, a2, a3, a4, a5); g1(a6); } + + void f7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + { f6(a1, a2, a3, a4, a5, a6); f1(a7); } + void g7(int a1, int a2, int a3, int a4, int a5, int a6, int a7) + const { g6(a1, a2, a3, a4, a5, a6); g1(a7); } + + void f8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + { f7(a1, a2, a3, a4, a5, a6, a7); f1(a8); } + void g8(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) + const { g7(a1, a2, a3, a4, a5, a6, a7); g1(a8); } }; int main() diff --git a/tests/unit/util/tuple.cpp b/tests/unit/util/tuple.cpp index 91f6ae1a11a1..4a1058479110 100644 --- a/tests/unit/util/tuple.cpp +++ b/tests/unit/util/tuple.cpp @@ -69,7 +69,8 @@ class no_copy { // ---------------------------------------------------------------------------- typedef hpx::util::tuple t1; -typedef hpx::util::tuple t2; +typedef hpx::util::tuple t2; typedef hpx::util::tuple t3; typedef hpx::util::tuple > t4; typedef hpx::util::tuple, bool, void*> t5; @@ -178,11 +179,15 @@ void element_access_test() ++hpx::util::get<0>(t); HPX_TEST(hpx::util::get<0>(t) == 6); - HPX_TEST((boost::is_const >::type>::value != true)); - HPX_TEST((boost::is_const >::type>::value)); + HPX_TEST((boost::is_const >::type>::value != true)); + HPX_TEST((boost::is_const >::type>::value)); - HPX_TEST((boost::is_const >::type>::value != true)); - HPX_TEST((boost::is_const >::type>::value)); + HPX_TEST((boost::is_const >::type>::value != true)); + HPX_TEST((boost::is_const >::type>::value)); dummy(i); dummy(i2); dummy(j); dummy(e); // avoid warns for unused variables } @@ -295,7 +300,8 @@ void tie_test() HPX_TEST(b == 'a'); HPX_TEST(c == foo(3)); - hpx::util::tie(a, hpx::util::ignore, c) = hpx::util::make_tuple((short int)5, false, foo(5)); + hpx::util::tie(a, hpx::util::ignore, c) = hpx::util::make_tuple((short int)5, + false, foo(5)); HPX_TEST(a == 5); HPX_TEST(b == 'a'); HPX_TEST(c == foo(5)); diff --git a/tools/inspect/endline_whitespace_check.hpp b/tools/inspect/endline_whitespace_check.hpp index ad7ece0f9dd3..68672b146b8c 100644 --- a/tools/inspect/endline_whitespace_check.hpp +++ b/tools/inspect/endline_whitespace_check.hpp @@ -22,7 +22,7 @@ namespace boost whitespace_check(); std::string a = "*Endline Whitespace*"; - std::string b = "Unnecessary whitespace at end of file"; + std::string b = "Unnecessary whitespace at end of line"; virtual const char * name() const { return a.c_str(); } virtual const char * desc() const { return b.c_str(); } diff --git a/tools/inspect/inspect.cpp b/tools/inspect/inspect.cpp index 8e92db525a1e..d3e937fcaef2 100644 --- a/tools/inspect/inspect.cpp +++ b/tools/inspect/inspect.cpp @@ -27,6 +27,7 @@ const char* hpx_no_inspect = "hpx-" "no-inspect"; #include #include #include +#include #include "boost/shared_ptr.hpp" #include "boost/lexical_cast.hpp" @@ -62,6 +63,7 @@ const char* hpx_no_inspect = "hpx-" "no-inspect"; #include "minmax_check.hpp" #include "unnamed_namespace_check.hpp" #include "endline_whitespace_check.hpp" +#include "length_check.hpp" //#include "cvs_iterator.hpp" @@ -816,6 +818,7 @@ int cpp_main( int argc_param, char * argv_param[] ) bool minmax_ck = false; bool unnamed_ck = false; bool whitespace_ck = false; + bool length_ck = false; desc_commandline.add_options() ("help,h", "print some command line help") @@ -823,6 +826,7 @@ int cpp_main( int argc_param, char * argv_param[] ) "the filename to write the output to (default: stdout)") ("text,t", "write a text file (default: html)") ("brief,b", "write a short report only (default: comprehensive)") + ("limit,l", value(), "set limit to the length check tool (default: 90)") ("license", value(&license_ck)->implicit_value(false), "check for Boost license violations (default: off)") @@ -853,6 +857,8 @@ int cpp_main( int argc_param, char * argv_param[] ) "check for unnamed namespace usage violations (default: off)") ("whitespace", value(&whitespace_ck)->implicit_value(false), "check for endline whitespace violations (default: off)") + ("length", value(&length_ck)->implicit_value(false), + "check for exceeding character limit (default: off)") ("all,a", "check for all violations (default: no checks are performed)") ; @@ -877,6 +883,17 @@ int cpp_main( int argc_param, char * argv_param[] ) ); store(opts, vm); + std::size_t limit; + + if (vm.count("limit")) + { + limit = vm["limit"].as(); + } + else + { + limit = 90; + } + if (vm.count("help")) { std::clog << desc_commandline << std::endl; @@ -916,6 +933,7 @@ int cpp_main( int argc_param, char * argv_param[] ) minmax_ck = true; unnamed_ck = true; whitespace_ck = true; + length_ck = true; } std::string output_path("-"); @@ -955,6 +973,8 @@ int cpp_main( int argc_param, char * argv_param[] ) inspectors.push_back( inspector_element( new boost::inspect::unnamed_namespace_check ) ); if ( whitespace_ck ) inspectors.push_back( inspector_element( new boost::inspect::whitespace_check) ); + if ( length_ck) + inspectors.push_back(inspector_element ( new boost::inspect::length_check(limit)) ); //// perform the actual inspection, using the requested type of iteration for(auto const& search_root: search_roots) diff --git a/tools/inspect/length_check.cpp b/tools/inspect/length_check.cpp new file mode 100644 index 000000000000..56e10c9ba4e3 --- /dev/null +++ b/tools/inspect/length_check.cpp @@ -0,0 +1,129 @@ +// character_length_check implementation ----------------------------------// + +// Copyright (c) 2015 Brandon Cordes +// Based on the apple_macro_check checker by Marshall Clow +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include "length_check.hpp" +#include +#include +#include +#include +#include +#include "boost/regex.hpp" +#include "boost/lexical_cast.hpp" +#include "boost/filesystem/operations.hpp" + +using namespace std; +namespace fs = boost::filesystem; + +namespace boost +{ + namespace inspect + { + size_t limit; + + length_check::length_check(size_t setting) + : m_files_with_errors(0) + + { + register_signature(".c"); + register_signature(".cpp"); + register_signature(".css"); + register_signature(".cxx"); + register_signature(".h"); + register_signature(".hpp"); + register_signature(".hxx"); + register_signature(".inc"); + register_signature(".ipp"); + register_signature(".txt"); + + limit = setting; + } + + void length_check::inspect( + const string & library_name, + const path & full_path, // ex: c:/foo/boost/filesystem/path.hpp + const string & contents) // contents of file to be inspected + { + if (contents.find("hpxinspect:" "length") != string::npos) + return; + string pathname = full_path.string(); + if (pathname.find("CMakeLists.txt") != string::npos) + return; + //Temporary, until we are ready to format documentation files in this limitation. + if (library_name.find(".qbk") != string::npos) + return; + + string total, linenum; + long errors = 0, currline = 0; + size_t p = 0; + vector someline, lineorder; + + char_separator sep("\n", "", boost::keep_empty_tokens); + tokenizer> tokens(contents, sep); + for (const auto& t : tokens) { + size_t rend = t.find_first_of("\r"), size = t.size(); + if (rend == size - 1) + { + someline.push_back(t); + } + else + { + char_separator sep2("\r", "", boost::keep_empty_tokens); + tokenizer> tokens2(t, sep2); + for (const auto& u : tokens2) { + someline.push_back(u); + } + } + } + while (p < someline.size()) + { + currline++; + size_t rend = someline[p].find_last_of("\r"); + bool check_not = 0; + boost::regex error_note, http_note; + error_note = "\\s*#\\s*error"; + http_note = "https?://"; + boost::smatch m; + if (boost::regex_search(someline[p], m, error_note)) //#error + { + if (m.position() == 0) + { + check_not = 1; + } + } + else if (boost::regex_search(someline[p], m, http_note)) //http::// + { + check_not = 1; + } + size_t size = someline[p].size(); + if (size > limit && check_not == 0) + { + errors++; + linenum = to_string(currline); + lineorder.push_back(linenum); + } + p++; + } + p = 0; + while (p < lineorder.size()) + { + total += lineorder[p]; + if (p < lineorder.size() - 1) + { + total += ", "; + } + p++; + } + if (errors > 0) + { + string errored = "Character Limit*: " + total; + error(library_name, full_path, errored); + ++m_files_with_errors; + } + } + } // namespace inspect +} // namespace boost diff --git a/tools/inspect/length_check.hpp b/tools/inspect/length_check.hpp new file mode 100644 index 000000000000..8c8998ee2d55 --- /dev/null +++ b/tools/inspect/length_check.hpp @@ -0,0 +1,46 @@ +// character_length_check header ------------------------------------------// + +// Copyright (c) 2015 Brandon Cordes +// Based on the apple_macro_check checker by Marshall Clow +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_EIGHTY_CHECK_HPP +#define BOOST_EIGHTY_CHECK_HPP + +#include "inspector.hpp" + +namespace boost +{ + namespace inspect + { + class length_check : public inspector + { + long m_files_with_errors; + public: + + length_check(size_t setting); + + std::string a = "*Character Limit*"; + std::string b = "The line is larger than the character limit"; + virtual const char * name() const { return a.c_str(); } + virtual const char * desc() const { return b.c_str(); } + + virtual void inspect( + const std::string & library_name, + const path & full_path, + const std::string & contents); + + virtual void print_summary(std::ostream& out) + { + string c = " files exceeding the character limit"; + out << " " << m_files_with_errors << c << line_break(); + } + + virtual ~length_check() {} + }; + } +} + +#endif // BOOST_EXTRA_WHITESPACE_CHECK_HPP