Skip to content

Commit

Permalink
Make caliper-tools-util private
Browse files Browse the repository at this point in the history
  • Loading branch information
daboehme committed Oct 30, 2024
1 parent bc408e2 commit 893cdc5
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 74 deletions.
14 changes: 7 additions & 7 deletions examples/apps/cali-memtracking-macros.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) 2019, Lawrence Livermore National Security, LLC.
// See top-level LICENSE file for details.

#include "caliper/tools-util/Args.h"

#include <caliper/cali.h>
#include <caliper/cali_datatracker.h>

#include "../../src/tools/util/Args.h"

#include <numeric>

size_t row_major(size_t x, size_t y, size_t width)
Expand Down Expand Up @@ -67,9 +67,9 @@ void do_work(size_t M, size_t W, size_t N)
CALI_MARK_END("sum");
CALI_MARK_BEGIN("free");

CALI_DATATRACKER_FREE(matA);
CALI_DATATRACKER_FREE(matB);
CALI_DATATRACKER_FREE(matC);
CALI_DATATRACKER_UNTRACK(matA);
CALI_DATATRACKER_UNTRACK(matB);
CALI_DATATRACKER_UNTRACK(matC);

CALI_MARK_END("free");
}
Expand All @@ -84,15 +84,15 @@ int main(int argc, const char* argv[])
{ "n_size", "n_size", 'n', true, "Height of input matrix B", "elements" },
{ "iterations", "iterations", 'i', true, "Number of iterations", "iterations" },

util::Args::Table::Terminator
util::Args::Terminator
};

util::Args args(option_table);

int lastarg = args.parse(argc, argv);

if (lastarg < argc) {
std::cerr << "cali-throughput-thread: unknown option: " << argv[lastarg] << '\n' << " Available options: ";
std::cerr << "cali-memtracking-macros: unknown option: " << argv[lastarg] << '\n' << " Available options: ";

args.print_available_options(std::cerr);

Expand Down
69 changes: 35 additions & 34 deletions examples/apps/cali-memtracking.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Copyright (c) 2019, Lawrence Livermore National Security, LLC.
// See top-level LICENSE file for details.

#include "caliper/tools-util/Args.h"
#include <caliper/cali.h>
#include <caliper/cali_datatracker.h>

#include "caliper/cali_datatracker.h"

#include <caliper/Annotation.h>
#include <caliper/Caliper.h>
#include "../../src/tools/util/Args.h"

#include <numeric>

Expand All @@ -19,18 +17,22 @@ void do_work(size_t M, size_t W, size_t N)
{
size_t i, j, k;

cali::Annotation alloc_phase(cali::Annotation("phase").begin("allocate"));

const size_t dimA[] = { M, W };
const size_t dimB[] = { W, N };
const size_t dimC[] = { M, N };

double* matA = (double*) cali_datatracker_allocate_dimensional("A", sizeof(double), dimA, 2);
double* matB = (double*) cali_datatracker_allocate_dimensional("B", sizeof(double), dimB, 2);
double* matC = (double*) cali_datatracker_allocate_dimensional("C", sizeof(double), dimC, 2);
CALI_MARK_BEGIN("allocate");

double* matA = new double[dimA[0]*dimA[1]];
double* matB = new double[dimB[0]*dimB[1]];
double* matC = new double[dimC[0]*dimC[1]];

alloc_phase.end();
cali::Annotation init_phase(cali::Annotation("phase").begin("initialize_values"));
cali_datatracker_track_dimensional(matA, "A", sizeof(double), dimA, 2);
cali_datatracker_track_dimensional(matB, "B", sizeof(double), dimB, 2);
cali_datatracker_track_dimensional(matC, "C", sizeof(double), dimC, 2);

CALI_MARK_END("allocate");
CALI_MARK_BEGIN("initialize_values");

// Initialize A and B randomly
for (i = 0; i < M; i++)
Expand All @@ -41,17 +43,17 @@ void do_work(size_t M, size_t W, size_t N)
for (j = 0; j < N; j++)
matB[row_major(k, j, W)] = rand();

init_phase.end();
cali::Annotation mul_phase(cali::Annotation("phase").begin("multiply"));
CALI_MARK_END("initialize_values");
CALI_MARK_BEGIN("multiply");

// AB = C
for (i = 0; i < M; i++)
for (j = 0; j < N; j++)
for (k = 0; k < W; k++)
matC[row_major(i, j, M)] += matA[row_major(i, k, M)] * matB[row_major(k, j, W)];

mul_phase.end();
cali::Annotation sum_phase(cali::Annotation("phase").begin("sum"));
CALI_MARK_END("multiply");
CALI_MARK_BEGIN("sum");

// Print sum of elems in C
double cSum = 0;
Expand All @@ -61,18 +63,24 @@ void do_work(size_t M, size_t W, size_t N)

std::cout << "cSum = " << cSum << std::endl;

sum_phase.end();
cali::Annotation free_phase(cali::Annotation("phase").begin("free"));
CALI_MARK_END("sum");
CALI_MARK_BEGIN("free");

cali_datatracker_untrack(matA);
cali_datatracker_untrack(matB);
cali_datatracker_untrack(matC);

cali_datatracker_free(matA);
cali_datatracker_free(matB);
cali_datatracker_free(matC);
delete[] matA;
delete[] matB;
delete[] matC;

free_phase.end();
CALI_MARK_END("free");
}

int main(int argc, const char* argv[])
{
CALI_CXX_MARK_FUNCTION;

// parse command line arguments

const util::Args::Table option_table[] = {
Expand All @@ -81,18 +89,16 @@ int main(int argc, const char* argv[])
{ "n_size", "n_size", 'n', true, "Height of input matrix B", "elements" },
{ "iterations", "iterations", 'i', true, "Number of iterations", "iterations" },

util::Args::Table::Terminator
util::Args::Terminator
};

util::Args args(option_table);

int lastarg = args.parse(argc, argv);

if (lastarg < argc) {
std::cerr << "cali-throughput-thread: unknown option: " << argv[lastarg] << '\n' << " Available options: ";

std::cerr << "cali-memtracking: unknown option: " << argv[lastarg] << '\n' << " Available options: ";
args.print_available_options(std::cerr);

return -1;
}

Expand All @@ -101,15 +107,10 @@ int main(int argc, const char* argv[])
size_t n_size = std::stoul(args.get("n_size", "512"));
size_t num_iterations = std::stoul(args.get("iterations", "4"));

cali::Annotation phase_annotation("phase", CALI_ATTR_SCOPE_PROCESS);

phase_annotation.begin("benchmark");

cali::Loop loop("loop");
CALI_CXX_MARK_LOOP_BEGIN(loop, "loop");
for (size_t i = 0; i < num_iterations; i++) {
cali::Loop::Iteration iteration(loop.iteration((int) i));
CALI_CXX_MARK_LOOP_ITERATION(loop, i);
do_work(m_size, w_size, n_size);
}

phase_annotation.end();
CALI_CXX_MARK_LOOP_END(loop);
}
8 changes: 2 additions & 6 deletions src/tools/cali-query/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
include_directories ("../../common")
include_directories ("../../reader")
include_directories ("../util")
include_directories ("../../caliper")

set(CALIPER_QUERY_COMMON_SOURCES
query_common.cpp)

Expand All @@ -15,9 +10,10 @@ target_compile_features(query-common PUBLIC cxx_std_11)

add_executable(cali-query
$<TARGET_OBJECTS:query-common>
$<TARGET_OBJECTS:caliper-tools-util>
${CALIPER_QUERY_SOURCES})

target_link_libraries(cali-query caliper-tools-util caliper)
target_link_libraries(cali-query caliper)
target_link_libraries(cali-query Threads::Threads)

install(TARGETS cali-query DESTINATION ${CMAKE_INSTALL_BINDIR})
2 changes: 1 addition & 1 deletion src/tools/cali-query/cali-query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "AttributeExtract.h"
#include "query_common.h"

#include "caliper/tools-util/Args.h"
#include "../util/Args.h"

#include "caliper/cali.h"
#include "caliper/cali-manager.h"
Expand Down
2 changes: 1 addition & 1 deletion src/tools/cali-query/query_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "caliper/reader/Preprocessor.h"
#include "caliper/reader/RecordSelector.h"

#include "caliper/tools-util/Args.h"
#include "../util/Args.h"

#include "caliper/common/Log.h"

Expand Down
2 changes: 1 addition & 1 deletion src/tools/cali-stat/cali-stat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "caliper/Annotation.h"

#include "caliper/tools-util/Args.h"
#include "../util/Args.h"

#include "caliper/reader/Aggregator.h"
#include "caliper/reader/CaliReader.h"
Expand Down
4 changes: 2 additions & 2 deletions src/tools/mpi-caliquery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ include_directories(${MPI_CXX_INCLUDE_PATH})

add_executable(mpi-caliquery
$<TARGET_OBJECTS:query-common>
$<TARGET_OBJECTS:caliper-tools-util>
mpi-caliquery.cpp)

target_link_libraries(mpi-caliquery caliper caliper-tools-util)
target_link_libraries(mpi-caliquery ${MPI_CXX_LIBRARIES})
target_link_libraries(mpi-caliquery caliper ${MPI_CXX_LIBRARIES})

install(TARGETS mpi-caliquery DESTINATION ${CMAKE_INSTALL_BINDIR})
2 changes: 1 addition & 1 deletion src/tools/mpi-caliquery/mpi-caliquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "caliper/cali.h"
#include "caliper/cali-manager.h"

#include "caliper/tools-util/Args.h"
#include "../util/Args.h"

#include "caliper/reader/Aggregator.h"
#include "caliper/reader/CaliReader.h"
Expand Down
2 changes: 1 addition & 1 deletion src/tools/util/Args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
///@file Args.cpp
/// Argument parsing implementation

#include "caliper/tools-util/Args.h"
#include "Args.h"

#include <cstring>
#include <map>
Expand Down
File renamed without changes.
19 changes: 1 addition & 18 deletions src/tools/util/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
set(CALIPER_TOOLS_UTIL_SOURCES
Args.cpp)

add_library(caliper-tools-util ${CALIPER_TOOLS_UTIL_SOURCES})

add_library(caliper-tools-util OBJECT ${CALIPER_TOOLS_UTIL_SOURCES})
target_compile_features(caliper-tools-util PUBLIC cxx_std_11)

set_target_properties(caliper-tools-util PROPERTIES SOVERSION ${CALIPER_MAJOR_VERSION})
set_target_properties(caliper-tools-util PROPERTIES VERSION ${CALIPER_VERSION})

install(
TARGETS
caliper-tools-util
EXPORT
caliper-targets
ARCHIVE DESTINATION
${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION
${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}
)
3 changes: 2 additions & 1 deletion test/cali-annotation-perftest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
#include <caliper/common/RuntimeConfig.h>

#include <caliper/cali.h>
#include <caliper/tools-util/Args.h>

#include "../src/tools/util/Args.h"

#include <chrono>
#include <iostream>
Expand Down
3 changes: 2 additions & 1 deletion test/cali-flush-perftest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#include <caliper/Caliper.h>

#include <caliper/cali.h>
#include <caliper/tools-util/Args.h>

#include "../src/tools/util/Args.h"

#include <chrono>
#include <iostream>
Expand Down

0 comments on commit 893cdc5

Please sign in to comment.