Commit eb36802b authored by Andrew Gaspar's avatar Andrew Gaspar
Browse files

tau plugin skeleton

parents
ColumnLimit: 100
IndentWidth: 4
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortIfStatementsOnASingleLine: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
\ No newline at end of file
build
.vscode
\ No newline at end of file
cmake_minimum_required(VERSION 3.13)
project(tau-sdskeyval LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(sdskeyval REQUIRED)
find_package(tau REQUIRED)
find_package(OpenMP REQUIRED)
enable_testing()
add_library(
tausdskvplugin
SHARED
src/lib.cpp
src/plugin.cpp
)
target_include_directories(
tausdskvplugin
PUBLIC
include
PRIVATE
internal
)
target_link_libraries(
tausdskvplugin
PRIVATE
tau::tau
sdskeyval::client
)
target_compile_features(
tausdskvplugin
PRIVATE
cxx_std_17
)
add_subdirectory(example)
\ No newline at end of file
include(FindPackageHandleStandardArgs)
find_library(sdskeyval_client_LIBRARY sdskv-client)
find_library(sdskeyval_server_LIBRARY sdskv-server)
find_path(sdskeyval_INCLUDE_DIR sdskv-client.h)
find_package_handle_standard_args(
sdskeyval
FOUND_VAR sdskeyval_FOUND
REQUIRED_VARS
sdskeyval_client_LIBRARY
sdskeyval_server_LIBRARY
sdskeyval_INCLUDE_DIR)
if (sdskeyval_FOUND)
add_library(sdskeyval::client UNKNOWN IMPORTED)
set_target_properties(
sdskeyval::client
PROPERTIES
IMPORTED_LOCATION "${sdskeyval_client_LIBRARY}"
IMPORTED_LINK_INTERFACE_LANGUAGES CXX
INTERFACE_INCLUDE_DIRECTORIES "${sdskeyval_INCLUDE_DIR}"
INTERFACE_COMPILE_FEATURES cxx_std_14)
add_library(sdskeyval::server UNKNOWN IMPORTED)
set_target_properties(
sdskeyval::server
PROPERTIES
IMPORTED_LOCATION "${sdskeyval_server_LIBRARY}"
IMPORTED_LINK_INTERFACE_LANGUAGES CXX
INTERFACE_INCLUDE_DIRECTORIES "${sdskeyval_INCLUDE_DIR}"
INTERFACE_COMPILE_FEATURES cxx_std_14)
endif()
\ No newline at end of file
include(FindPackageHandleStandardArgs)
find_library(tau_LIBRARY TAU)
find_path(tau_INCLUDE_DIR TAU.h)
find_package_handle_standard_args(
tau
FOUND_VAR tau_FOUND
REQUIRED_VARS
tau_LIBRARY
tau_INCLUDE_DIR)
if (tau_FOUND)
add_library(tau::tau UNKNOWN IMPORTED)
set_target_properties(
tau::tau
PROPERTIES
IMPORTED_LOCATION "${tau_LIBRARY}"
IMPORTED_LINK_INTERFACE_LANGUAGES CXX
INTERFACE_INCLUDE_DIRECTORIES "${tau_INCLUDE_DIR}"
INTERFACE_COMPILE_DEFINITIONS "TAU_STDCXXLIB;TAU_BFD"
INTERFACE_COMPILE_FEATURES cxx_std_14)
endif()
\ No newline at end of file
include(FindPackageHandleStandardArgs)
find_library(unwind_LIBRARY unwind)
find_path(unwind_INCLUDE_DIR unwind.h)
find_package_handle_standard_args(
unwind
FOUND_VAR unwind_FOUND
REQUIRED_VARS
unwind_LIBRARY
unwind_INCLUDE_DIR)
if (unwind_FOUND)
add_library(unwind::unwind UNKNOWN IMPORTED)
set_target_properties(
unwind::unwind
PROPERTIES
IMPORTED_LOCATION "${unwind_LIBRARY}"
IMPORTED_LINK_INTERFACE_LANGUAGES CXX
INTERFACE_INCLUDE_DIRECTORIES "${unwind_INCLUDE_DIR}"
INTERFACE_COMPILE_FEATURES cxx_std_14)
endif()
\ No newline at end of file
project(tau-sdskeyval-example LANGUAGES CXX)
# find_package(MPI 3.0 REQUIRED)
add_executable(
tautest
src/main.cpp
)
target_link_libraries(
tautest
PRIVATE
tau::tau
OpenMP::OpenMP_CXX
# MPI::MPI_CXX
)
target_compile_definitions(
tautest
PRIVATE
PROFILING_ON
)
target_compile_features(
tautest
PRIVATE
cxx_std_14
)
find_program(TAUEXEC tau_exec)
add_test(
NAME tausdskv-test
COMMAND ${TAUEXEC} -T serial,openmp -ompt "$<TARGET_FILE:tautest>")
set_tests_properties(
tausdskv-test
PROPERTIES
ENVIRONMENT "TAU_PLUGINS_PATH=;TAU_PLUGINS=$<TARGET_FILE:tausdskvplugin>"
)
\ No newline at end of file
// STL Includes
#include <iostream>
#include <numeric>
#include <vector>
// Third Party Includes
#include <TAU.h>
#include <omp.h>
int main(int argc, char **argv) {
Tau_init(argc, argv);
TAU_REGISTER_THREAD();
#pragma omp parallel
{ TAU_REGISTER_THREAD(); }
{
TAU_PROFILE("openmp_outer", "void()", TAU_DEFAULT);
#pragma omp parallel
{
TAU_PROFILE("openmp_inner", "void()", TAU_DEFAULT);
int volatile N = 1000000;
std::vector<int> my_stuff(N);
std::iota(my_stuff.begin(), my_stuff.end(), 0);
#pragma omp barrier
std::cout << "Hi from thread " << omp_get_thread_num() << "!" << std::endl;
#pragma omp barrier
}
}
Tau_dump();
return 0;
}
\ No newline at end of file
#ifndef TAUSDSKVPLUGIN_CONTROL_H_
#define TAUSDSKVPLUGIN_CONTROL_H_
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
int tausdskv_set_dump_name(char const *dump_name);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // TAUSDSKVPLUGIN_CONTROL_H_
\ No newline at end of file
/**
* @file plugin.hpp
* @author Andrew Gaspar (agaspar@lanl.gov)
* @brief
* @date 2019-05-01
*
* @copyright Copyright (c) 2019 Triad National Security, LLC
*
*/
#ifndef TAUSDSKVPLUGIN_PLUGIN_HPP_
#define TAUSDSKVPLUGIN_PLUGIN_HPP_
// Third Party Includes
#include <Profile/TauPlugin.h>
enum class PluginStatus { Success = 0, Fail = 1 };
namespace tausdskv {
class Plugin {
public:
static Plugin *GetInstance();
template <typename EventData>
using Callback = int (*)(EventData *);
template <typename EventData, PluginStatus (Plugin::*MemberFunction)(EventData const &)>
static Callback<EventData> Bind() {
return [](EventData *data) -> int {
return static_cast<int>((Plugin::GetInstance()->*MemberFunction)(*data));
};
}
PluginStatus Dump(Tau_plugin_event_dump_data_t const &data);
PluginStatus Mpit(Tau_plugin_event_mpit_data_t const &data);
PluginStatus
MetadataRegistrationComplete(Tau_plugin_event_metadata_registration_data_t const &data);
PluginStatus PostInit(Tau_plugin_event_post_init_data_t const &data);
PluginStatus PreEndOfExecution(Tau_plugin_event_pre_end_of_execution_data_t const &data);
PluginStatus EndOfExecution(Tau_plugin_event_end_of_execution_data_t const &data);
PluginStatus Send(Tau_plugin_event_send_data_t const &data);
PluginStatus Recv(Tau_plugin_event_recv_data_t const &data);
PluginStatus FunctionEntry(Tau_plugin_event_function_entry_data_t const &data);
PluginStatus FunctionExit(Tau_plugin_event_function_exit_data_t const &data);
PluginStatus AtomicEventTrigger(Tau_plugin_event_atomic_event_trigger_data_t const &data);
private:
Plugin() = default;
};
} // namespace tausdskv
#endif // TAUSDSKVPLUGIN_PLUGIN_HPP_
\ No newline at end of file
// STL Includes
#include <cstring>
#include <memory>
// Third Party Includes
#include <Profile/TauPlugin.h>
#include <TAU.h>
// Local Includes
#include <plugin.hpp>
#include <tau-sdskv/control.h>
using namespace tausdskv;
extern "C" int Tau_plugin_init_func(int argc, char **argv) {
// TAU_SoS
Tau_plugin_callbacks_t cb;
Tau_util_init_tau_plugin_callbacks(&cb);
cb.Dump = Plugin::Bind<Tau_plugin_event_dump_data_t, &Plugin::Dump>();
cb.Mpit = Plugin::Bind<Tau_plugin_event_mpit_data_t, &Plugin::Mpit>();
cb.MetadataRegistrationComplete = Plugin::Bind<Tau_plugin_event_metadata_registration_data_t,
&Plugin::MetadataRegistrationComplete>();
cb.PostInit = Plugin::Bind<Tau_plugin_event_post_init_data_t, &Plugin::PostInit>();
cb.PreEndOfExecution =
Plugin::Bind<Tau_plugin_event_pre_end_of_execution_data_t, &Plugin::PreEndOfExecution>();
cb.EndOfExecution =
Plugin::Bind<Tau_plugin_event_end_of_execution_data_t, &Plugin::EndOfExecution>();
cb.Send = Plugin::Bind<Tau_plugin_event_send_data_t, &Plugin::Send>();
cb.Recv = Plugin::Bind<Tau_plugin_event_recv_data_t, &Plugin::Recv>();
cb.FunctionEntry =
Plugin::Bind<Tau_plugin_event_function_entry_data_t, &Plugin::FunctionEntry>();
cb.FunctionExit = Plugin::Bind<Tau_plugin_event_function_exit_data_t, &Plugin::FunctionExit>();
cb.AtomicEventTrigger =
Plugin::Bind<Tau_plugin_event_atomic_event_trigger_data_t, &Plugin::AtomicEventTrigger>();
Tau_util_plugin_register_callbacks(&cb);
return 0;
}
extern "C" int tausdskv_set_dump_name(char const *dump_name) { return 0; }
\ No newline at end of file
/**
* @file plugin.cpp
* @author Andrew Gaspar (agaspar@lanl.gov)
* @brief Implementation of tau-sdskv plugin
* @date 2019-05-01
*
* @copyright Copyright (c) 2019 Triad National Security, LLC
*
*/
// Self Include
#include <plugin.hpp>
// STL Includes
#include <iostream>
using namespace tausdskv;
Plugin *Plugin::GetInstance() {
static Plugin instance;
return &instance;
}
PluginStatus Plugin::Dump(Tau_plugin_event_dump_data_t const &data) {
std::cout << "tausdskv: Thread " << data.tid << ", Hello from " << __PRETTY_FUNCTION__
<< std::endl;
return PluginStatus::Success;
}
PluginStatus Plugin::Mpit(Tau_plugin_event_mpit_data_t const &data) {
std::cout << "Hello from " << __PRETTY_FUNCTION__ << std::endl;
return PluginStatus::Success;
}
PluginStatus
Plugin::MetadataRegistrationComplete(Tau_plugin_event_metadata_registration_data_t const &data) {
std::cout << "tausdskv: Registering " << data.name << std::endl;
return PluginStatus::Success;
}
PluginStatus Plugin::PostInit(Tau_plugin_event_post_init_data_t const &data) {
return PluginStatus::Success;
}
PluginStatus Plugin::PreEndOfExecution(Tau_plugin_event_pre_end_of_execution_data_t const &data) {
std::cout << "tausdskv: Thread " << data.tid << ", Hello from " << __PRETTY_FUNCTION__
<< std::endl;
return PluginStatus::Success;
}
PluginStatus Plugin::EndOfExecution(Tau_plugin_event_end_of_execution_data_t const &data) {
std::cout << "tausdskv: Thread " << data.tid << ", Hello from " << __PRETTY_FUNCTION__
<< std::endl;
return PluginStatus::Success;
}
PluginStatus Plugin::Send(Tau_plugin_event_send_data_t const &data) {
std::cout << "Hello from " << __PRETTY_FUNCTION__ << std::endl;
return PluginStatus::Success;
}
PluginStatus Plugin::Recv(Tau_plugin_event_recv_data_t const &data) {
std::cout << "Hello from " << __PRETTY_FUNCTION__ << std::endl;
return PluginStatus::Success;
}
PluginStatus Plugin::FunctionEntry(Tau_plugin_event_function_entry_data_t const &data) {
std::cout << "tausdskv: Thread " << data.tid << ", Entering " << data.timer_name
<< ", Timestamp " << data.timestamp << std::endl;
return PluginStatus::Success;
}
PluginStatus Plugin::FunctionExit(Tau_plugin_event_function_exit_data_t const &data) {
std::cout << "tausdskv: Thread " << data.tid << ", Exiting " << data.timer_name
<< ", Timestamp " << data.timestamp << std::endl;
return PluginStatus::Success;
}
PluginStatus Plugin::AtomicEventTrigger(Tau_plugin_event_atomic_event_trigger_data_t const &data) {
std::cout << "Hello from " << __PRETTY_FUNCTION__ << std::endl;
return PluginStatus::Success;
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment