Skip to content

Commit

Permalink
Adding Google Chrome trace event support
Browse files Browse the repository at this point in the history
  • Loading branch information
khuck committed Jul 25, 2020
1 parent b308cd8 commit c00a3a6
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,11 @@ if(USE_PLUGINS)
message(INFO " apex will be built with plugin support.")
set(LIBS ${LIBS} ${CMAKE_DL_LIBS})
add_definitions("-DAPEX_USE_PLUGINS")
endif()

################################################################################
# Need JSON for writing trace events
################################################################################

git_external(rapidjson
https://github.com/miloyip/rapidjson.git
Expand All @@ -699,7 +704,6 @@ if(USE_PLUGINS)
message(FATAL_ERROR " rapidjson not found. This should have been checked out automatically. "
"Try manually check out https://github.com/miloyip/rapidjson.git to ${PROJECT_SOURCE_DIR}")
endif()
endif()

################################################################################
# Standard Library configuration
Expand Down
1 change: 1 addition & 0 deletions src/apex/CMakeLists.standalone
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ ${SENSOR_SOURCE}
task_identifier.cpp
${tau_SOURCE}
thread_instance.cpp
trace_event_listener.cpp
utils.cpp
)

Expand Down
5 changes: 5 additions & 0 deletions src/apex/apex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

#include "tau_listener.hpp"
#include "profiler_listener.hpp"
#include "trace_event_listener.hpp"
#if defined(APEX_DEBUG) || defined(APEX_ERROR_HANDLING)
// #define APEX_DEBUG_disabled
#include "apex_error_handling.hpp"
Expand Down Expand Up @@ -260,6 +261,10 @@ void apex::_initialize()
listeners.push_back(new otf2_listener());
}
#endif
if (apex_options::use_trace_event())
{
listeners.push_back(new trace_event_listener());
}

/* For the Jupyter support, always enable the concurrency handler. */
#ifndef APEX_WITH_JUPYTER_SUPPORT
Expand Down
1 change: 1 addition & 0 deletions src/apex/apex_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ inline unsigned int sc_nprocessors_onln()
macro (APEX_OTF2, use_otf2, bool, false) \
macro (APEX_OTF2_TESTING, otf2_testing, bool, false) \
macro (APEX_OTF2_COLLECTIVE_SIZE, otf2_collective_size, int, 1) \
macro (APEX_TRACE_EVENT, use_trace_event, bool, false) \
macro (APEX_POLICY, use_policy, bool, true) \
macro (APEX_MEASURE_CONCURRENCY, use_concurrency, int, 0) \
macro (APEX_MEASURE_CONCURRENCY_PERIOD, concurrency_period, int, 1000000) \
Expand Down
136 changes: 136 additions & 0 deletions src/apex/trace_event_listener.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// Copyright (c) 2014 University of Oregon
//
// 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 "trace_event_listener.hpp"
#include "thread_instance.hpp"
#include <iostream>
#include <fstream>
#include <memory>

using namespace std;

namespace apex {

bool trace_event_listener::_initialized(false);

trace_event_listener::trace_event_listener (void) : _terminate(false) {
_initialized = true;
}

void trace_event_listener::on_startup(startup_event_data &data) {
APEX_UNUSED(data);
return;
}

void trace_event_listener::on_dump(dump_event_data &data) {
APEX_UNUSED(data);
if (!_terminate) {
}
return;
}

void trace_event_listener::on_shutdown(shutdown_event_data &data) {
APEX_UNUSED(data);
if (!_terminate) {
_terminate = true;
}
return;
}

void trace_event_listener::on_new_node(node_event_data &data) {
APEX_UNUSED(data);
if (!_terminate) {
// set node id
}
return;
}

void trace_event_listener::on_new_thread(new_thread_event_data &data) {
APEX_UNUSED(data);
if (!_terminate) {
}
return;
}

void trace_event_listener::on_exit_thread(event_data &data) {
APEX_UNUSED(data);
if (!_terminate) {
}
return;
}

inline bool trace_event_listener::_common_start(std::shared_ptr<task_wrapper> &tt_ptr) {
APEX_UNUSED(tt_ptr);
if (!_terminate) {
} else {
return false;
}
return true;
}

bool trace_event_listener::on_start(std::shared_ptr<task_wrapper> &tt_ptr) {
return _common_start(tt_ptr);
}

bool trace_event_listener::on_resume(std::shared_ptr<task_wrapper> &tt_ptr) {
return _common_start(tt_ptr);
}

inline void trace_event_listener::_common_stop(std::shared_ptr<profiler> &p) {
APEX_UNUSED(p);
if (!_terminate) {
}
return;
}

void trace_event_listener::on_stop(std::shared_ptr<profiler> &p) {
return _common_stop(p);
}

void trace_event_listener::on_yield(std::shared_ptr<profiler> &p) {
return _common_stop(p);
}

void trace_event_listener::on_sample_value(sample_value_event_data &data) {
APEX_UNUSED(data);
if (!_terminate) {
}
return;
}

void trace_event_listener::on_periodic(periodic_event_data &data) {
APEX_UNUSED(data);
if (!_terminate) {
}
return;
}

void trace_event_listener::on_custom_event(custom_event_data &data) {
APEX_UNUSED(data);
if (!_terminate) {
}
return;
}

void trace_event_listener::set_node_id(int node_id, int node_count) {
APEX_UNUSED(node_id);
APEX_UNUSED(node_count);
}

void trace_event_listener::set_metadata(const char * name, const char * value) {
APEX_UNUSED(name);
APEX_UNUSED(value);
}

/* This function is used by APEX threads so that TAU knows about them. */
int initialize_worker_thread_for_trace_event(void) {
if (trace_event_listener::initialized())
{
}
return 0;
}

}// end namespace

55 changes: 55 additions & 0 deletions src/apex/trace_event_listener.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) 2014 University of Oregon
//
// 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)

#pragma once

#include "event_listener.hpp"
#include <memory>

namespace apex {

class trace_event_listener : public event_listener {
private:
void _init(void);
bool _terminate;
bool _common_start(std::shared_ptr<task_wrapper> &tt_ptr);
void _common_stop(std::shared_ptr<profiler> &p);
static bool _initialized;
public:
trace_event_listener (void);
~trace_event_listener (void) { };
static bool initialize_tau(int argc, char** avgv);
inline static bool initialized(void) { return _initialized; }
void on_startup(startup_event_data &data);
void on_dump(dump_event_data &data);
void on_reset(task_identifier * id)
{ APEX_UNUSED(id); };
void on_shutdown(shutdown_event_data &data);
void on_new_node(node_event_data &data);
void on_new_thread(new_thread_event_data &data);
void on_exit_thread(event_data &data);
bool on_start(std::shared_ptr<task_wrapper> &tt_ptr);
void on_stop(std::shared_ptr<profiler> &p);
void on_yield(std::shared_ptr<profiler> &p);
bool on_resume(std::shared_ptr<task_wrapper> &tt_ptr);
void on_task_complete(std::shared_ptr<task_wrapper> &tt_ptr) {
APEX_UNUSED(tt_ptr);
};
void on_sample_value(sample_value_event_data &data);
void on_periodic(periodic_event_data &data);
void on_custom_event(custom_event_data &data);
void on_send(message_event_data &data) { APEX_UNUSED(data); };
void on_recv(message_event_data &data) { APEX_UNUSED(data); };
void set_node_id(int node_id, int node_count);
void set_metadata(const char * name, const char * value);

static void Tau_start_wrapper(const char * name);
static void Tau_stop_wrapper(const char * name);
};

int initialize_worker_thread_for_tau(void);

}

0 comments on commit c00a3a6

Please sign in to comment.