Skip to content

Commit

Permalink
Miscellaneous code cleanup (#544)
Browse files Browse the repository at this point in the history
* Save region count entry in event service

* Deprecate CALI_ATTR_NOMERGE property

* Remove CALI_ATTR_NOMERGE from callpath attributes

* Remove PGI constexpr hack

* Remove SoSFlow

* Enable region.count in spot by default

* CMake cleanup

* Remove datatracker alloc functions
  • Loading branch information
daboehme authored Mar 15, 2024
1 parent e9e9d79 commit 7b83cc5
Show file tree
Hide file tree
Showing 19 changed files with 67 additions and 436 deletions.
44 changes: 11 additions & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,22 @@ option(CALIPER_OPTION_PREFIX "Option names are prefixed with 'CALIPER_'" OFF)
mark_as_advanced(CALIPER_OPTION_PREFIX)

macro(ADD_CALIPER_OPTION NAME)
if(CALIPER_OPTION_PREFIX)
option(CALIPER_${NAME} ${ARGN})
# set the option locally for this project
set(${NAME} ${CALIPER_${NAME}})
else()
option(${NAME} ${ARGN})
endif()
if(CALIPER_OPTION_PREFIX)
option(CALIPER_${NAME} ${ARGN})
# set the option locally for this project
set(${NAME} ${CALIPER_${NAME}})
else()
option(${NAME} ${ARGN})
endif()
endmacro()

# Optional Fortran
add_caliper_option(WITH_FORTRAN "Install Fortran interface")

# Shared libs option
option(BUILD_SHARED_LIBS "Build shared libraries" TRUE)

# RPATH setup. By default, rpath everything.
option(CMAKE_INSTALL_RPATH_USE_LINK_PATH "Add rpath for all dependencies" TRUE)

# Optional Fortran
add_caliper_option(WITH_FORTRAN "Install Fortran interface" FALSE)
add_caliper_option(WITH_TOOLS "Build Caliper tools" TRUE)

add_caliper_option(WITH_NVTX "Enable NVidia nvtx bindings for NVprof and NSight (requires CUDA)" FALSE)
Expand All @@ -69,7 +67,6 @@ add_caliper_option(WITH_GOTCHA "Enable GOTCHA wrapping" ${CALIPER_HAVE_LINUX}
add_caliper_option(WITH_ROCTX "Enable AMD RocTX support" FALSE)
add_caliper_option(WITH_ROCTRACER "Enable AMD RocTracer support" FALSE)
add_caliper_option(WITH_ROCM "Enable AMD RocTracer and RocTX support" FALSE)
#add_caliper_option(WITH_SOS "Enable SOSFlow data management" FALSE)
add_caliper_option(WITH_TAU "Enable TAU service (TAU Performance System)" FALSE)
add_caliper_option(WITH_VTUNE "Enable Intel(R) VTune(tm) annotation bindings" FALSE)
add_caliper_option(WITH_ADIAK "Enable adiak support" FALSE)
Expand Down Expand Up @@ -313,16 +310,6 @@ if (WITH_ADIAK)
endif()
endif()

if (WITH_SOS)
include(FindSOSFlow)
if (SOSFlow_FOUND)
message(STATUS "Found sosflow in " ${SOSFlow_LIBRARY})
list(APPEND CALIPER_EXTERNAL_LIBS ${SOSFlow_LIBRARY})
set(CALIPER_HAVE_SOS TRUE)
set(CALIPER_SOSFlow_CMAKE_MSG "Yes, using ${SOSFlow_LIBRARY}")
endif()
endif()

if (WITH_KOKKOS)
set(CALIPER_HAVE_KOKKOS TRUE)
set(CALIPER_Kokkos_CMAKE_MSG "Yes")
Expand All @@ -333,8 +320,8 @@ set(THREADS_PREFER_PTHREAD_FLAG On)
find_package(Threads REQUIRED)

if (WITH_OMPT)
set(CALIPER_HAVE_OMPT TRUE)
set(CALIPER_OMPT_CMAKE_MSG "Yes")
set(CALIPER_HAVE_OMPT TRUE)
set(CALIPER_OMPT_CMAKE_MSG "Yes")
endif()

# Find MPI
Expand Down Expand Up @@ -473,13 +460,6 @@ if (WITH_LDMS)
endif()
endif()

# PGI 17.x has issues with some constexpr constructors
if(CMAKE_CXX_COMPILER_ID MATCHES PGI)
set(CALIPER_REDUCED_CONSTEXPR_USAGE TRUE)
else()
set(CALIPER_REDUCED_CONSTEXPR_USAGE FALSE)
endif()

if (BUILD_TESTING)
set(CALIPER_BUILD_TESTING TRUE)
endif()
Expand Down Expand Up @@ -579,10 +559,8 @@ set(CALIPER_MODULES
Libpfm
Libunwind
Sampler
SOSFlow
MPI
MPIWRAP
MPIT
OMPT
Nvtx
CUpti
Expand Down
6 changes: 0 additions & 6 deletions caliper-config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@

#cmakedefine CALIPER_BUILD_TESTING

#ifdef CALIPER_REDUCED_CONSTEXPR_USAGE
#define CONSTEXPR_UNLESS_PGI
#else
#define CONSTEXPR_UNLESS_PGI constexpr
#endif

// Version information -- numerical and a version string
#define CALIPER_MAJOR_VERSION @CALIPER_MAJOR_VERSION@
#define CALIPER_MINOR_VERSION @CALIPER_MINOR_VERSION@
Expand Down
42 changes: 0 additions & 42 deletions cmake/FindSOSFlow.cmake

This file was deleted.

81 changes: 13 additions & 68 deletions include/caliper/cali_datatracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* See top-level LICENSE file for details.
*/

/**
* \file cali_datatracker.h
/**
* \file cali_datatracker.h
* \brief C API for Caliper datatracking.
*/

Expand All @@ -20,80 +20,34 @@ extern "C" {
* --- Data tracking functions ------------------------------------------------
*/

/**
* \addtogroup AnnotationAPI
* \{
*/

/**
* Allocate and track the resulting allocation in Caliper.
*
* \note Tracking information will be automatically removed if the allocation is freed
*
* \param label The unique label with which to track the allocation requested
* \param size The total size of the allocation requested
* \return A new allocation of size `size`
*/

void*
cali_datatracker_allocate(const char *label,
size_t size);

/**
* Allocate and track the resulting allocation, with dimensions, in Caliper.
*
* \note Tracking information will be automatically removed if the allocation is freed
*
* \param label The unique label with which to track the allocation requested
* \param elem_size The size of an individual element in the allocation requested
* \param dimensions An array of the dimensions of the allocation requested
* \param num_dimensions The number of dimensions in `dimensions`
* \return A new allocation of size `product(dimensions)*elem_size`
*/

void*
cali_datatracker_allocate_dimensional(const char *label,
size_t elem_size,
const size_t *dimensions,
size_t num_dimensions);

/**
* Free and untrack an allocation in Caliper.
*
* \param ptr The pointer to the beginning of the allocation to free/untrack
*/

void
cali_datatracker_free(void *ptr);

/**
* Track an existing allocation in Caliper.
*
* \note This will track the entire allocation pointed to by ptr.
* \note This will track the entire allocation pointed to by ptr.
* To track a subset of a larger allocation, use `cali_datatracker_track_dimensional`.
*
* \param ptr The pointer to the beginning of the allocation to track
* \param label The unique label with which to track the allocation
* \param label The unique label with which to track the allocation
* \param size Size of the allocation
*/

void
cali_datatracker_track(const void *ptr,
void
cali_datatracker_track(const void *ptr,
const char *label,
size_t size);

/**
* Track an existing allocation in Caliper.
*
* \param ptr The pointer to the beginning of the allocation to track
* \param label The unique label with which to track the allocation
* \param elem_size The size of an individual element in the allocation
* \param dimensions An array of the dimensions of the allocation
* \param label The unique label with which to track the allocation
* \param elem_size The size of an individual element in the allocation
* \param dimensions An array of the dimensions of the allocation
* \param num_dimensions The number of dimensions in `dimensions`
*/

void
cali_datatracker_track_dimensional(const void *ptr,
void
cali_datatracker_track_dimensional(const void *ptr,
const char *label,
size_t elem_size,
const size_t *dimensions,
Expand All @@ -105,7 +59,7 @@ cali_datatracker_track_dimensional(const void *ptr,
* \param ptr The pointer to the beginning of the allocation to untrack
*/

void
void
cali_datatracker_untrack(const void *ptr);

/**
Expand All @@ -116,15 +70,6 @@ cali_datatracker_untrack(const void *ptr);
} // extern "C"
#endif

/* Include high-level annotation macros.
*/

#define CALI_DATATRACKER_ALLOCATE(label, elem_size, dimensions, num_dimensions) \
cali_datatracker_allocate(label, elem_size, dimensions, num_dimensions)

#define CALI_DATATRACKER_FREE(ptr) \
cali_datatracker_free(ptr)

/**
* \addtogroup AnnotationAPI
* \{
Expand All @@ -144,7 +89,7 @@ cali_datatracker_untrack(const void *ptr);
/**
* \brief Label and track a multi-dimensional array.
*
* Labels a multi-dimensional array with with the variable name of
* Labels a multi-dimensional array with with the variable name of
* \a ptr. The array can then be tracked and resolved with the alloc service.
*
* \param elem_size Size of the array elements in bytes
Expand Down
2 changes: 1 addition & 1 deletion include/caliper/common/Entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Entry

constexpr static size_t MAX_PACKED_SIZE = 30;

CONSTEXPR_UNLESS_PGI Entry()
constexpr Entry()
: m_node(nullptr)
{ }

Expand Down
2 changes: 1 addition & 1 deletion include/caliper/common/Variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Variant

public:

CONSTEXPR_UNLESS_PGI Variant()
constexpr Variant()
: m_v { CALI_TYPE_INV, { static_cast<uint64_t>(0) } } { }

Variant(const cali_variant_t& v)
Expand Down
4 changes: 2 additions & 2 deletions include/caliper/common/cali_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ typedef enum {
*/
CALI_ATTR_ASVALUE = 1,

/** \brief Create a separate context tree root node for this attribute.
/** \brief Create a separate context tree root node for this attribute (deprecated).
*
* Useful for attributes that form overlapping hierarchies separate from
* the main region stack.
* the main region stack. No longer used.
*/
CALI_ATTR_NOMERGE = 2,
/** \brief Process-scope attribute. Shared between all threads. */
Expand Down
29 changes: 16 additions & 13 deletions src/caliper/Caliper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,26 +546,30 @@ constexpr cali_id_t UNALIGNED_KEY { 2 };
inline cali_id_t
get_blackboard_key(cali_id_t attr_id, int prop)
{
if ((prop & CALI_ATTR_ASVALUE) || (prop & CALI_ATTR_NOMERGE))
if (prop & CALI_ATTR_ASVALUE)
return attr_id;
if (prop & CALI_ATTR_UNALIGNED)
return UNALIGNED_KEY;

return REGION_KEY;
}

inline cali_id_t
get_blackboard_key_for_reference_entry(int prop)
{
return prop & CALI_ATTR_UNALIGNED ? UNALIGNED_KEY : REGION_KEY;
}

inline void
handle_begin(const Attribute& attr, const Variant& value, int prop, Blackboard& blackboard, MetadataTree& tree)
{
cali_id_t key = get_blackboard_key(attr.id(), prop);
Entry entry;

if (prop & CALI_ATTR_ASVALUE)
entry = Entry(attr, value);
else
entry = Entry(tree.get_child(attr, value, blackboard.get(key).node()));

blackboard.set(key, entry, !(prop & CALI_ATTR_HIDDEN));
if (prop & CALI_ATTR_ASVALUE) {
blackboard.set(attr.id(), Entry(attr, value), !(prop & CALI_ATTR_HIDDEN));
} else {
cali_id_t key = get_blackboard_key_for_reference_entry(prop);
Entry entry = Entry(tree.get_child(attr, value, blackboard.get(key).node()));
blackboard.set(key, entry, !(prop & CALI_ATTR_HIDDEN));
}
}

inline void
Expand All @@ -586,11 +590,10 @@ handle_end(const Attribute& attr, int prop, Entry merged_entry, cali_id_t key, B
inline void
handle_set(const Attribute& attr, const Variant& value, int prop, Blackboard& blackboard, MetadataTree& tree)
{
cali_id_t key = get_blackboard_key(attr.id(), prop);

if (prop & CALI_ATTR_ASVALUE)
blackboard.set(key, Entry(attr, value), !(prop & CALI_ATTR_HIDDEN));
blackboard.set(attr.id(), Entry(attr, value), !(prop & CALI_ATTR_HIDDEN));
else {
cali_id_t key = get_blackboard_key_for_reference_entry(prop);
Node* node = blackboard.get(key).node();
blackboard.set(key, tree.replace_first_in_path(node, attr, value), !(prop & CALI_ATTR_HIDDEN));
}
Expand Down
Loading

0 comments on commit 7b83cc5

Please sign in to comment.