timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
weak.cpp File Reference
#include "timemory/backends/process.hpp"
#include "timemory/compat/library.h"
#include "timemory/components/ompt/types.hpp"
#include "timemory/environment.hpp"
#include "timemory/library.h"
#include "timemory/settings.hpp"
#include <cstdint>
#include <limits>
#include <numeric>
#include <dlfcn.h>
+ Include dependency graph for weak.cpp:

Go to the source code of this file.

Macros

#define TIMEMORY_LIBRARY_SOURCE   1
 
#define DLSYM_FUNCTION(VARNAME, HANDLE, FUNCNAME)
 
#define OS_DYNAMIC_LIBRARY_EXT   "so"
 
#define TOOL_DLSYM_SPECIALIZAITON(INDEX, ID, ENV_VAR)
 
#define TOOL_INDEX(NAME)   NAME##_idx
 
#define TOOL_DLSYM(NAME)   get_tool_stubs<TOOL_INDEX(NAME)>()
 
#define TOOL_PREFIX   TIMEMORY_WEAK_PREFIX
 
#define TOOL_SUFFIX   TIMEMORY_WEAK_POSTFIX TIMEMORY_VISIBILITY("default")
 
#define TOOL_STUBS(NAME)
 

Enumerations

enum  TOOL_STUB_IDS {
  mpip_idx = 0 ,
  ompt_idx ,
  ncclp_idx ,
  mallocp_idx
}
 

Functions

template<int Idx>
tools_stubs_dlsym * get_tool_stubs ()
 
template<>
tools_stubs_dlsym * get_tool_stubs< mpip_idx > ()
 
template<>
tools_stubs_dlsym * get_tool_stubs< ompt_idx > ()
 
template<>
tools_stubs_dlsym * get_tool_stubs< ncclp_idx > ()
 
template<>
tools_stubs_dlsym * get_tool_stubs< mallocp_idx > ()
 
TIMEMORY_WEAK_PREFIX void timemory_mpip_library_ctor () TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX void timemory_register_mpip () TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX void timemory_deregister_mpip () TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX uint64_t timemory_start_mpip () TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX uint64_t timemory_stop_mpip (uint64_t) TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX void timemory_ompt_library_ctor () TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX void timemory_register_ompt () TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX void timemory_deregister_ompt () TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX uint64_t timemory_start_ompt () TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX uint64_t timemory_stop_ompt (uint64_t) TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX void timemory_ncclp_library_ctor () TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX void timemory_register_ncclp () TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX void timemory_deregister_ncclp () TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX uint64_t timemory_start_ncclp () TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX uint64_t timemory_stop_ncclp (uint64_t) TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX void timemory_mallocp_library_ctor () TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX void timemory_register_mallocp () TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX void timemory_deregister_mallocp () TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX uint64_t timemory_start_mallocp () TIMEMORY_WEAK_POSTFIX
 
TIMEMORY_WEAK_PREFIX uint64_t timemory_stop_mallocp (uint64_t) TIMEMORY_WEAK_POSTFIX
 

Macro Definition Documentation

◆ DLSYM_FUNCTION

#define DLSYM_FUNCTION (   VARNAME,
  HANDLE,
  FUNCNAME 
)
Value:
if(HANDLE) \
{ \
*(void**) (&VARNAME) = dlsym(HANDLE, FUNCNAME.c_str()); \
if(VARNAME == nullptr) \
{ \
fprintf(stderr, "[%s][pid=%i]> %s\n", FUNCNAME.c_str(), \
tim::process::get_id(), dlerror()); \
} \
} \
else \
{ \
VARNAME = nullptr; \
}

Definition at line 48 of file weak.cpp.

◆ OS_DYNAMIC_LIBRARY_EXT

#define OS_DYNAMIC_LIBRARY_EXT   "so"

Definition at line 70 of file weak.cpp.

◆ TIMEMORY_LIBRARY_SOURCE

#define TIMEMORY_LIBRARY_SOURCE   1

Definition at line 26 of file weak.cpp.

◆ TOOL_DLSYM

#define TOOL_DLSYM (   NAME)    get_tool_stubs<TOOL_INDEX(NAME)>()

Definition at line 197 of file weak.cpp.

◆ TOOL_DLSYM_SPECIALIZAITON

#define TOOL_DLSYM_SPECIALIZAITON (   INDEX,
  ID,
  ENV_VAR 
)
Value:
template <> \
tools_stubs_dlsym* get_tool_stubs<INDEX>() \
{ \
static auto _instance = std::unique_ptr<tools_stubs_dlsym>{}; \
if(!_instance) \
{ \
auto _env = tim::get_env<std::string>(ENV_VAR, ""); \
_instance = std::make_unique<tools_stubs_dlsym>(ID, _env); \
} \
return _instance.get(); \
}

Definition at line 178 of file weak.cpp.

◆ TOOL_INDEX

#define TOOL_INDEX (   NAME)    NAME##_idx

Definition at line 196 of file weak.cpp.

◆ TOOL_PREFIX

#define TOOL_PREFIX   TIMEMORY_WEAK_PREFIX

Definition at line 198 of file weak.cpp.

◆ TOOL_STUBS

#define TOOL_STUBS (   NAME)
Value:
TOOL_PREFIX \
void timemory_##NAME##_library_ctor() TOOL_SUFFIX; \
void timemory_register_##NAME() TOOL_SUFFIX; \
TOOL_PREFIX \
void timemory_deregister_##NAME() TOOL_SUFFIX; \
TOOL_PREFIX \
uint64_t timemory_start_##NAME() TOOL_SUFFIX; \
TOOL_PREFIX \
uint64_t timemory_stop_##NAME(uint64_t) TOOL_SUFFIX; \
\
void timemory_##NAME##_library_ctor() { TOOL_DLSYM(NAME)->invoke_ctor(); } \
void timemory_register_##NAME() { TOOL_DLSYM(NAME)->invoke_register(); } \
void timemory_deregister_##NAME() { TOOL_DLSYM(NAME)->invoke_deregister(); } \
uint64_t timemory_start_##NAME() { return TOOL_DLSYM(NAME)->invoke_start(); } \
uint64_t timemory_stop_##NAME(uint64_t v) { return TOOL_DLSYM(NAME)->invoke_stop(v); }
#define TOOL_SUFFIX
Definition: weak.cpp:199
#define TOOL_PREFIX
Definition: weak.cpp:198

Definition at line 200 of file weak.cpp.

◆ TOOL_SUFFIX

#define TOOL_SUFFIX   TIMEMORY_WEAK_POSTFIX TIMEMORY_VISIBILITY("default")

Definition at line 199 of file weak.cpp.

Enumeration Type Documentation

◆ TOOL_STUB_IDS

Enumerator
mpip_idx 
ompt_idx 
ncclp_idx 
mallocp_idx 

Definition at line 166 of file weak.cpp.

167{
168 mpip_idx = 0,
169 ompt_idx,
170 ncclp_idx,
172};
@ mpip_idx
Definition: weak.cpp:168
@ ncclp_idx
Definition: weak.cpp:170
@ ompt_idx
Definition: weak.cpp:169
@ mallocp_idx
Definition: weak.cpp:171

Function Documentation

◆ get_tool_stubs()

template<int Idx>
tools_stubs_dlsym * get_tool_stubs ( )

◆ get_tool_stubs< mallocp_idx >()

template<>
tools_stubs_dlsym * get_tool_stubs< mallocp_idx > ( )

Definition at line 194 of file weak.cpp.

212{ TOOL_DLSYM(NAME)->invoke_ctor(); } \
#define TOOL_DLSYM(NAME)
Definition: weak.cpp:197

◆ get_tool_stubs< mpip_idx >()

template<>
tools_stubs_dlsym * get_tool_stubs< mpip_idx > ( )

Definition at line 191 of file weak.cpp.

212{ TOOL_DLSYM(NAME)->invoke_ctor(); } \

◆ get_tool_stubs< ncclp_idx >()

template<>
tools_stubs_dlsym * get_tool_stubs< ncclp_idx > ( )

Definition at line 193 of file weak.cpp.

212{ TOOL_DLSYM(NAME)->invoke_ctor(); } \

◆ get_tool_stubs< ompt_idx >()

template<>
tools_stubs_dlsym * get_tool_stubs< ompt_idx > ( )

Definition at line 192 of file weak.cpp.

212{ TOOL_DLSYM(NAME)->invoke_ctor(); } \

◆ timemory_deregister_mallocp()

TIMEMORY_WEAK_PREFIX void timemory_deregister_mallocp ( )

Definition at line 226 of file weak.cpp.

◆ timemory_deregister_mpip()

TIMEMORY_WEAK_PREFIX void timemory_deregister_mpip ( )

Definition at line 223 of file weak.cpp.

◆ timemory_deregister_ncclp()

TIMEMORY_WEAK_PREFIX void timemory_deregister_ncclp ( )

Definition at line 225 of file weak.cpp.

◆ timemory_deregister_ompt()

TIMEMORY_WEAK_PREFIX void timemory_deregister_ompt ( )

Definition at line 224 of file weak.cpp.

◆ timemory_mallocp_library_ctor()

TIMEMORY_WEAK_PREFIX void timemory_mallocp_library_ctor ( )

Definition at line 226 of file weak.cpp.

◆ timemory_mpip_library_ctor()

TIMEMORY_WEAK_PREFIX void timemory_mpip_library_ctor ( )

Definition at line 223 of file weak.cpp.

◆ timemory_ncclp_library_ctor()

TIMEMORY_WEAK_PREFIX void timemory_ncclp_library_ctor ( )

Definition at line 225 of file weak.cpp.

◆ timemory_ompt_library_ctor()

TIMEMORY_WEAK_PREFIX void timemory_ompt_library_ctor ( )

Definition at line 224 of file weak.cpp.

◆ timemory_register_mallocp()

TIMEMORY_WEAK_PREFIX void timemory_register_mallocp ( )

Definition at line 226 of file weak.cpp.

◆ timemory_register_mpip()

TIMEMORY_WEAK_PREFIX void timemory_register_mpip ( )

Definition at line 223 of file weak.cpp.

◆ timemory_register_ncclp()

TIMEMORY_WEAK_PREFIX void timemory_register_ncclp ( )

Definition at line 225 of file weak.cpp.

◆ timemory_register_ompt()

TIMEMORY_WEAK_PREFIX void timemory_register_ompt ( )

Definition at line 224 of file weak.cpp.

◆ timemory_start_mallocp()

TIMEMORY_WEAK_PREFIX uint64_t timemory_start_mallocp ( )

Definition at line 226 of file weak.cpp.

◆ timemory_start_mpip()

TIMEMORY_WEAK_PREFIX uint64_t timemory_start_mpip ( )

Definition at line 223 of file weak.cpp.

◆ timemory_start_ncclp()

TIMEMORY_WEAK_PREFIX uint64_t timemory_start_ncclp ( )

Definition at line 225 of file weak.cpp.

◆ timemory_start_ompt()

TIMEMORY_WEAK_PREFIX uint64_t timemory_start_ompt ( )

Definition at line 224 of file weak.cpp.

◆ timemory_stop_mallocp()

TIMEMORY_WEAK_PREFIX uint64_t timemory_stop_mallocp ( uint64_t  v)

Definition at line 226 of file weak.cpp.

◆ timemory_stop_mpip()

TIMEMORY_WEAK_PREFIX uint64_t timemory_stop_mpip ( uint64_t  v)

Definition at line 223 of file weak.cpp.

◆ timemory_stop_ncclp()

TIMEMORY_WEAK_PREFIX uint64_t timemory_stop_ncclp ( uint64_t  v)

Definition at line 225 of file weak.cpp.

◆ timemory_stop_ompt()

TIMEMORY_WEAK_PREFIX uint64_t timemory_stop_ompt ( uint64_t  v)

Definition at line 224 of file weak.cpp.