Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing 1890 #1893

Merged
merged 5 commits into from Dec 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions hpx/components/papi/server/papi.hpp
Expand Up @@ -14,6 +14,7 @@
#include <hpx/hpx_fwd.hpp>
#include <hpx/util/interval_timer.hpp>
#include <hpx/performance_counters/server/base_performance_counter.hpp>
#include <hpx/runtime/components/server/component_base.hpp>

#include <vector>
#include <map>
Expand Down Expand Up @@ -153,7 +154,7 @@ namespace hpx { namespace performance_counters { namespace papi { namespace serv
///////////////////////////////////////////////////////////////////////////
class HPX_COMPONENT_EXPORT papi_counter:
public hpx::performance_counters::server::base_performance_counter,
public hpx::components::managed_component_base<papi_counter>,
public hpx::components::component_base<papi_counter>,
protected papi_counter_base
{
friend struct thread_counters;
Expand All @@ -172,8 +173,8 @@ namespace hpx { namespace performance_counters { namespace papi { namespace serv
thread_counters *counters_;

public:
typedef hpx::components::managed_component_base<papi_counter> base_type;
typedef hpx::components::managed_component<papi_counter> wrapping_type;
typedef hpx::components::component_base<papi_counter> base_type;
typedef hpx::components::component<papi_counter> wrapping_type;
typedef papi_counter type_holder;
typedef hpx::performance_counters::server::base_performance_counter
base_type_holder;
Expand Down
2 changes: 1 addition & 1 deletion src/components/papi_counters/papi_startup.cpp
Expand Up @@ -26,7 +26,7 @@
HPX_REGISTER_COMPONENT_MODULE_DYNAMIC();

///////////////////////////////////////////////////////////////////////////////
typedef hpx::components::managed_component<
typedef hpx::components::component<
hpx::performance_counters::papi::server::papi_counter
> papi_counter_type;

Expand Down
3 changes: 2 additions & 1 deletion src/components/papi_counters/server/papi.cpp
Expand Up @@ -9,6 +9,7 @@
#if defined(HPX_HAVE_PAPI)

#include <hpx/hpx_fwd.hpp>
#include <hpx/runtime/components/server/component.hpp>
#include <hpx/runtime/components/derived_component_factory.hpp>
#include <hpx/runtime/actions/continuation.hpp>
#include <hpx/util/thread_mapper.hpp>
Expand All @@ -26,7 +27,7 @@
///////////////////////////////////////////////////////////////////////////////
namespace papi_ns = hpx::performance_counters::papi;

typedef hpx::components::managed_component<
typedef hpx::components::component<
papi_ns::server::papi_counter
> papi_counter_type;

Expand Down
3 changes: 2 additions & 1 deletion tests/regressions/performance_counters/CMakeLists.txt
Expand Up @@ -10,8 +10,9 @@ set(tests

if(PAPI_FOUND)
set(tests ${tests}
papi_counters_active_interface
papi_counters_basic_functions
papi_counters_active_interface)
papi_counters_segfault_1890)
endif()

foreach(test ${tests})
Expand Down
@@ -0,0 +1,37 @@
// Copyright (c) 2015 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)
//
// Demonstrating #1890: Invoking papi counters give segfault

#include <hpx/hpx.hpp>
#include <hpx/hpx_init.hpp>
#include <hpx/include/performance_counters.hpp>
#include <hpx/util/lightweight_test.hpp>

int hpx_main(int argc, char ** argv)
{
#if defined(HPX_HAVE_PAPI)
using hpx::performance_counters::performance_counter;

performance_counter total_cycles(
"/arithmetics/add@/papi{locality#0/worker-thread#*}/PAPI_TOT_CYC");
performance_counter cycles(
"/papi{locality#0/worker-thread#0}/PAPI_TOT_CYC");

boost::int64_t val1 = total_cycles.get_value_sync<boost::int64_t>();
boost::int64_t val2 = cycles.get_value_sync<boost::int64_t>();

HPX_TEST(val1 != 0);
HPX_TEST(val2 != 0);
#endif

return hpx::finalize();
}

int main(int argc, char **argv)
{
HPX_TEST_EQ(hpx::init(argc, argv), 0);
return hpx::util::report_errors();
}