Skip to content

Commit

Permalink
Merge pull request #1410 from philip-davis/profiling-enable
Browse files Browse the repository at this point in the history
Add cmake option to disable profiling stubs
  • Loading branch information
philip-davis authored May 14, 2019
2 parents f98f4a2 + ec3d8c1 commit a7d0ab9
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ adios_option(HDF5 "Enable support for the HDF5 engine" AUTO)
adios_option(Python "Enable support for Python bindings" AUTO)
adios_option(Fortran "Enable support for Fortran bindings" AUTO)
adios_option(SysVShMem "Enable support for SysV Shared Memory IPC on *NIX" AUTO)
adios_option(Profiling "Enable support for profiling" AUTO)
adios_option(Endian_Reverse "Enable support for Little/Big Endian Interoprability" AUTO)
include(${PROJECT_SOURCE_DIR}/cmake/DetectOptions.cmake)

Expand All @@ -151,6 +152,7 @@ if(APPLE AND ADIOS2_HAVE_Fortran AND ADIOS2_HAVE_MPI)
endif()

set(ADIOS2_CONFIG_OPTS
BZip2 ZFP SZ MGARD MPI DataMan SSC SST ZeroMQ HDF5 Python Fortran SysVShMem Profiling Endian_Reverse
BZip2 ZFP SZ MGARD MPI DataMan SSC SST ZeroMQ HDF5 Python Fortran SysVShMem Endian_Reverse
)
GenerateADIOSHeaderConfig(${ADIOS2_CONFIG_OPTS})
Expand Down
6 changes: 6 additions & 0 deletions cmake/DetectOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ else()
set(ADIOS2_HAVE_SysVShMem OFF)
endif()

if(ADIOS2_USE_Profiling STREQUAL AUTO AND SHARED_LIBS_SUPPORTED)
set(ADIOS2_HAVE_Profiling ON)
elseif(ADIOS2_USE_Profiling)
set(ADIOS2_HAVE_Profiling ON)
endif()

if(ADIOS2_USE_Endian_Reverse STREQUAL ON)
set(ADIOS2_HAVE_Endian_Reverse TRUE)
endif()
Expand Down
4 changes: 4 additions & 0 deletions source/adios2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ add_library(taustubs
toolkit/profiling/taustubs/taustubs.h
)

target_include_directories(taustubs PRIVATE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/source>
)

add_library(adios2
core/Attribute.cpp
core/AttributeBase.cpp
Expand Down
4 changes: 1 addition & 3 deletions source/adios2/toolkit/profiling/taustubs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ _Note:_ This library in ADIOS is a stub wrapper library for the TAU performance
- [ ] Replace TAU-specific symbols with generic versions that will be implemented by interested measurement libraries (i.e. Score-P).
- [ ] New environment variable specifying location of library containing function implementations.

- [ ] Add a CMake option to disable the API entirely.

- [ ] Add CMake support for linking in measurement libraries when static linking.

- [ ] Investigate API call to trigger writing of performance data to the ADIOS2 archive (performance data stored with the science data).

## Overview

These files contain a thin stub interface for instrumenting ADIOS2 code. The interface can be compiled away entirely (that feature will eventually be configurable). The function calls are "stubs" in the form of function pointers, initialized to ```nullptr```. The functions are optionally assigned at runtime using dlopen() (if necessary) and dlsym() calls, as is typical with plugin implementations. If the function pointers have the value ```nullptr```, then this library is a few more instructions than a no-op. If the function pointers are assigned, the measurement library functions are called to perform the timing measurement. The symbols are made available to the environment either through ```LD_PRELOAD``` settings or by linking in the measurement library.
These files contain a thin stub interface for instrumenting ADIOS2 code. The interface can be compiled away entirely by setting the `-DADIOS2_USE_Profiling=False` option when running cmake. The function calls are "stubs" in the form of function pointers, initialized to ```nullptr```. The functions are optionally assigned at runtime using dlopen() (if necessary) and dlsym() calls, as is typical with plugin implementations. If the function pointers have the value ```nullptr```, then this library is a few more instructions than a no-op. If the function pointers are assigned, the measurement library functions are called to perform the timing measurement. The symbols are made available to the environment either through ```LD_PRELOAD``` settings or by linking in the measurement library.

Convenience macros are provided for constructing descriptive timer names using pre-processor definitions such as ```__FILE__```, ```__LINE__```, and ```__func__```. For C++ codes, there are also scoped timers to minimize instrumentation text and ensure timers are stopped in functions with multiple return locations or exceptions that throw outside of scope.

Expand Down
7 changes: 5 additions & 2 deletions source/adios2/toolkit/profiling/taustubs/taustubs.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
#ifndef TAUSTUBS_H
#define TAUSTUBS_H

#include "adios2/ADIOSConfig.h"

/* This code won't compile on windows. Disable it */
#if !defined(_WIN32) && !defined(_WIN64)
/* DISABLE ENTIRELY BY DEFAULT */
// #define TAU_USE_STUBS
#ifdef ADIOS2_HAVE_PROFILING
#define TAU_USE_STUBS
#endif
#endif

#if defined(TAU_USE_STUBS)
Expand Down
13 changes: 11 additions & 2 deletions source/adios2/toolkit/profiling/taustubs/tautimer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@

#pragma once

#include "adios2/ADIOSConfig.h"

/* This code won't compile on windows. Disable it */
#if !defined(_WIN32) && !defined(_WIN64)
/* DISABLE ENTIRELY BY DEFAULT */
// #define TAU_USE_STUBS
#ifdef ADIOS2_HAVE_PROFILING
#define TAU_USE_STUBS
#endif
#endif

#if defined(TAU_USE_STUBS)
Expand Down Expand Up @@ -65,6 +68,12 @@ class scoped_timer
#define TAU_REGISTER_THREAD() taustubs::TauTimer::RegisterThread();
#define TAU_START(_timer_name) taustubs::TauTimer::Start(_timer_name);
#define TAU_STOP(_timer_name) taustubs::TauTimer::Stop(_timer_name);
#define TAU_START_FUNC() \
std::stringstream __ss##finfo; \
__ss##finfo << __func__ << " [{" << __FILE__ << "} {" << __LINE__ \
<< ",0}]"; \
taustubs::TauTimer::Start(__ss##finfo.str());
#define TAU_STOP_FUNC() taustubs::TauTimer::Stop(__ss##finfo.str())
#define TAU_SAMPLE_COUNTER(_name, _value) \
taustubs::TauTimer::SampleCounter(_name, _value);
#define TAU_METADATA(_name, _value) taustubs::TauTimer::MetaData(_name, _value);
Expand Down

0 comments on commit a7d0ab9

Please sign in to comment.