Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding caliper annotations #213

Open
wants to merge 50 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
7b69bde
initial caliper annotations
Dec 27, 2024
478c570
adding caliper to cmake
Dec 28, 2024
69d0bdf
adding caliper import
Dec 28, 2024
3d991f2
changing lionk in cmake
Dec 28, 2024
b361d3a
changing cali enabled checks
Dec 28, 2024
d94b448
upsate cmake
Dec 28, 2024
d14d2d2
upsate cmake
Dec 28, 2024
aeb570a
moving caliper linking in cmake
Dec 28, 2024
c5a4117
changing linking again
Dec 28, 2024
a90f1aa
changing caliper link
Dec 28, 2024
3e911bc
ending cali function
Dec 28, 2024
8773347
changing to c++ annotations
Dec 30, 2024
f86e206
changing to c++ annotations
Dec 30, 2024
a65373c
adding caliSetup method
Dec 30, 2024
f0761c9
linker changes
Dec 30, 2024
8a8e45b
removed mpi check
Dec 30, 2024
bd932b8
changing cali configmgr
Dec 30, 2024
1ae448e
fix adiak link
Dec 30, 2024
422fb04
removing extra annotations
Dec 30, 2024
d5a08b7
turn on debug mode
Dec 30, 2024
02459e1
changing target name
Dec 30, 2024
1c2ea72
test
Dec 30, 2024
7ecf1a1
undoing changes
Dec 30, 2024
c9e58ae
fix
Dec 30, 2024
2715128
adding debug prints
Dec 30, 2024
2b2d8f7
more prints
Dec 30, 2024
e7cf4b5
fixing prints
Dec 30, 2024
0eb328a
adding extra definition
Dec 30, 2024
303c22d
changing setupCaliper
Dec 30, 2024
5f34ca0
fixing some caliper methods
Dec 30, 2024
ef0a28a
removing extra annotation
Dec 30, 2024
4491edd
removing print debug lines
Dec 30, 2024
91d0359
cleaning up indents
Jan 29, 2025
a299929
testing refactor
Feb 18, 2025
d9e2fc8
moving cali flush
Feb 19, 2025
6bbcb4f
moving return statements
Feb 19, 2025
ce7723b
changing return var names
Feb 19, 2025
2bace4c
updating typing
Feb 19, 2025
a2b62b0
adding instantiation
Feb 19, 2025
defb6cc
separating cases to reuse result var
Feb 19, 2025
40035ec
moving annotations
Feb 19, 2025
0381a4d
relabeling annotations
Feb 19, 2025
61a5500
relabeling annotations
Feb 19, 2025
cd3abd7
fixing typo
Feb 19, 2025
368649e
adding extra annotations
Feb 19, 2025
69202fa
fixing typo
Feb 19, 2025
7664f5f
label annotations by function
Feb 19, 2025
94bf35f
renaming array_init annotations
Feb 19, 2025
fe08548
removing trailing whitespaces
Feb 20, 2025
69dd220
removing trailing whitespaces
Feb 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ option(FETCH_TBB "Fetch (download) the oneTBB library for *supported* models. Th
FetchContent feature. Specify version by setting FETCH_TBB_VERSION" OFF)
set(FETCH_TBB_VERSION "v2021.10.0" CACHE STRING "Specify version of oneTBB to use if FETCH_TBB is ON")

option(ENABLE_CALIPER "Enable Caliper/Adiak support" FALSE)


if (FETCH_TBB)
FetchContent_Declare(
TBB
Expand Down Expand Up @@ -231,6 +234,14 @@ add_executable(${EXE_NAME} ${IMPL_SOURCES} src/main.cpp)
target_link_libraries(${EXE_NAME} PUBLIC ${LINK_LIBRARIES})
target_compile_definitions(${EXE_NAME} PUBLIC ${IMPL_DEFINITIONS})
target_include_directories(${EXE_NAME} PUBLIC ${IMPL_DIRECTORIES})
#add_executable(main ${IMPL_SOURCES} src/main.cpp)

if (ENABLE_CALIPER)
find_package(caliper REQUIRED)
find_package(adiak REQUIRED)
add_compile_definitions(ENABLE_CALIPER)
target_link_libraries(${EXE_NAME} PUBLIC caliper adiak::adiak)
endif()

if (CXX_EXTRA_LIBRARIES)
target_link_libraries(${EXE_NAME} PUBLIC ${CXX_EXTRA_LIBRARIES})
Expand Down
5 changes: 5 additions & 0 deletions src/Stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
#include <vector>
#include <string>

#ifdef ENABLE_CALIPER
#include <caliper/cali.h>
#include <adiak.h>
#endif

// Array values
#define startA (0.1)
#define startB (0.2)
Expand Down
46 changes: 46 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
#include "StreamModels.h"
#include "Unit.h"

#ifdef ENABLE_CALIPER
#include <caliper/cali.h>
#include <caliper/cali-mpi.h>
#include <caliper/cali-manager.h>
#include <adiak.hpp>
#endif

// Default size of 2^25
intptr_t ARRAY_SIZE = 33554432;
size_t num_times = 100;
Expand Down Expand Up @@ -83,6 +90,29 @@ void parseArguments(int argc, char *argv[]);

int main(int argc, char *argv[])
{
#ifdef ENABLE_CALIPER
cali::ConfigManager calimgr;

if (calimgr.error()){
std::cerr << "caliper config error: " << calimgr.error_msg() << std::endl;
}
calimgr.start();

cali_config_preset("CALI_LOG_VERBOSITY", "2");
cali_config_preset("CALI_CALIPER_ATTRIBUTE_DEFAULT_SCOPE", "process");

adiak::init(nullptr);
adiak::collect_all();

cali_config_set("CALI_CALIPER_ATTRIBUTE_DEFAULT_SCOPE", "process");

adiak::value("BABELSTREAM version", "4.0");
adiak::value("num_times", num_times);
adiak::value("elements", ARRAY_SIZE);

CALI_MARK_FUNCTION_BEGIN;
#endif

parseArguments(argc, argv);

if (!output_as_csv)
Expand All @@ -98,6 +128,10 @@ int main(int argc, char *argv[])
else
run<double>();

#ifdef ENABLE_CALIPER
adiak::fini();
calimgr.flush();
#endif
return EXIT_SUCCESS;
}

Expand Down Expand Up @@ -150,7 +184,13 @@ std::vector<std::vector<double>> run_all(std::unique_ptr<Stream<T>>& stream, T&
for (size_t k = 0; k < num_times; k++) {
for (size_t i = 0; i < num_benchmarks; ++i) {
if (!run_benchmark(bench[i])) continue;
#ifdef ENABLE_CALIPER
CALI_MARK_BEGIN(bench[i].label);
#endif
timings[i].push_back(dt(bench[i]));
#ifdef ENABLE_CALIPER
CALI_MARK_END(bench[i].label);
#endif
}
}
break;
Expand Down Expand Up @@ -256,7 +296,13 @@ void run()
}

std::unique_ptr<Stream<T>> stream = make_stream<T>(ARRAY_SIZE, deviceIndex);
#ifdef ENABLE_CALIPER
CALI_MARK_BEGIN("init_arrays");
#endif
auto initElapsedS = time([&] { stream->init_arrays(startA, startB, startC); });
#ifdef ENABLE_CALIPER
CALI_MARK_END("init_arrays");
#endif

// Result of the Dot kernel, if used.
T sum{};
Expand Down