Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
fe7705d
Generate traces for thapi_start() and thapi_end()
thilinarmtb Feb 28, 2025
8bfe33e
Call thapi_stop() if libtoggle is linked
thilinarmtb Mar 3, 2025
3d0cf51
Rename toggle to ThapiProfiler
thilinarmtb Mar 3, 2025
a066c98
Add `profiler_` to ThapiProfiler symbols
thilinarmtb Mar 3, 2025
c8aa8f6
Fix `make distcheck` failure
thilinarmtb Mar 6, 2025
736ffd5
Remove profiler from symbols
thilinarmtb Mar 6, 2025
a9432ef
Use AX_GCC_FUNC_ATTRIBUTE to check constructor support
thilinarmtb Mar 6, 2025
c9d3167
Install libThapi.so in lib instead of lib/thapi
thilinarmtb Mar 6, 2025
dc20cad
Add an integration test
thilinarmtb Mar 6, 2025
6127ca8
Minor changes in utils/thapi.[ch]
thilinarmtb Mar 6, 2025
fc11f1b
Fix the failing integration test
thilinarmtb Mar 18, 2025
f9ec28b
thapi.c->thapi_toggle.c & use toggle over profiler
thilinarmtb Mar 18, 2025
a0e4020
Use constructor priority for thapi_stop()
thilinarmtb Mar 18, 2025
19433f5
Set minimum lttng-ust version
thilinarmtb Mar 18, 2025
9806753
Check if the header is included by a CXX compiler
thilinarmtb Mar 25, 2025
b7338ab
Plugin to filter traces based on thapi_start/stop
thilinarmtb Apr 2, 2025
2c695ed
Format utils/thapi_toggle.c
thilinarmtb Apr 2, 2025
26d8822
Prefix files related to toggle with `thapi_toggle`
thilinarmtb Jun 24, 2025
8b48d04
Check hostname and vpid when using toggle
thilinarmtb Jun 24, 2025
1826c34
Install ThapiToggle plugin
thilinarmtb Jul 1, 2025
afcb851
Add integration tests for ThapiToggle
thilinarmtb Jul 1, 2025
677493e
Add integration tests with np=2 for ThapiToggle
thilinarmtb Jul 2, 2025
f00be3b
Fix typos and refactor toggle tests
thilinarmtb Jul 2, 2025
a18655e
Move toggle tests into toggle.bats
thilinarmtb Jul 3, 2025
fd77484
Use babeltrace_thapi instead of babeltrace2
thilinarmtb Jul 3, 2025
5008d21
Simplify trace counting
thilinarmtb Jul 3, 2025
277ea77
Set and use the env vars from setup_suite.bash
thilinarmtb Jul 14, 2025
b72687e
Rename the filter to `toggle`
thilinarmtb Jul 14, 2025
8db67db
Rename `thapi_toggle_* -> toggle_* in tests
thilinarmtb Jul 14, 2025
8f2fba3
Undo spliting LTTNNG_FLAGS
thilinarmtb Jul 15, 2025
f3de4af
Comment why lttng-ust version change is required
thilinarmtb Jul 15, 2025
f6e62cf
Install libThapiToggle.so in bt2 plugin dir
thilinarmtb Sep 29, 2025
c8e7cff
Fix libThapiToggle.so flags
thilinarmtb Oct 1, 2025
147c24a
Fix `shfmt` errors
thilinarmtb Jan 26, 2026
9fb306d
Add `Cflags` and `Libs` to `thapi.pc.in`
thilinarmtb Jan 26, 2026
0f96b47
Use `pkg-config` to find thapi include and ldflags
thilinarmtb Jan 26, 2026
3fef8a6
$IPROF -> iprof, $BBT -> babeltrace_thapi
thilinarmtb Jan 27, 2026
0594d60
Enable toggle events on iprof
thilinarmtb Jan 28, 2026
3334b62
$MPIRUN -> mpirun
thilinarmtb Jan 29, 2026
618e70b
Add `lttng_ust_toggle:auto_stop`
thilinarmtb Feb 1, 2026
635451f
Get rid of THAPI_HOME
thilinarmtb Feb 3, 2026
7ae17f3
Add a dlopen test for toggle traces
thilinarmtb Feb 2, 2026
62e0a30
Update the thapi babeltrace plugin
thilinarmtb Feb 5, 2026
d44105b
clang-format -i thapi_toggle*
thilinarmtb Feb 5, 2026
35a6aed
Fix compilation errors
thilinarmtb Feb 5, 2026
345e239
Minor fixes
thilinarmtb Mar 4, 2026
7e55899
Split toggle API tests into two tests
thilinarmtb Mar 4, 2026
a785e65
Add the toggle filter in babeltrace_thapi
thilinarmtb Mar 4, 2026
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
7 changes: 6 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ AC_SUBST([ENABLE_CLANG_PARSER])

PKG_CHECK_MODULES([LIBFFI], [libffi >= 3.2])
PKG_CHECK_MODULES([BABELTRACE2], [babeltrace2 >= 2.0])
PKG_CHECK_MODULES([LTTNG_UST], [lttng-ust >= 2.10])
# Use of __attribute__((constructor)) requires `lttng-ust >= 2.12.8` to work properly.
# Specifically, the following fix:
# https://github.com/lttng/lttng-ust/commit/a8fafb675a9f580f6a889223e26664ea11cb0c99.
PKG_CHECK_MODULES([LTTNG_UST], [lttng-ust >= 2.12.8])
PKG_CHECK_MODULES([PROTOBUF], [protobuf >= 3.0])

AX_RUBY_EXTENSION([cast-to-yaml], [yes])
Expand Down Expand Up @@ -137,6 +140,8 @@ AC_FUNC_MMAP
AC_FUNC_REALLOC
AC_CHECK_FUNCS([clock_gettime ftruncate memmove memset strdup strstr strtoull strlen strchr])

AX_GCC_FUNC_ATTRIBUTE(constructor)

# Required for configuring thapi.pc.in
PKG_PROG_PKG_CONFIG

Expand Down
3 changes: 3 additions & 0 deletions integration_tests/setup_suite.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
setup_suite() {
export MPIRUN=${MPIRUN:-mpirun}

# Set the path to find iprof, babeltrace_thapi, etc.
export PATH=$(pkg-config --variable=bindir thapi):${PATH}
# We need this for the toggle_api/toggle_dlopen test.
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$(pkg-config --variable=libdir thapi)

missing_tools=()

Expand Down
96 changes: 96 additions & 0 deletions integration_tests/toggle.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/usr/bin/env bats

setup_file() {
export THAPI_INCFLAGS="-I$(pkg-config --variable=includedir thapi)"
export THAPI_LDFLAGS="-Wl,-rpath,$(pkg-config --variable=libdir thapi) $(pkg-config --libs thapi)"
}

get_unique_jobid() {
echo ${BATS_TEST_NAME}.${RANDOM}
}

@test "toggle_api" {
rm -rf toggle_traces 2>/dev/null

cc ${THAPI_INCFLAGS} ./integration_tests/toggle.c -o toggle ${THAPI_LDFLAGS}
iprof --trace-output toggle_traces --no-analysis -- ./toggle

# Make sure auto_stop comes before stop.
babeltrace_thapi ./toggle_traces | awk 'BEGIN { seen_auto = 0 }
$0 ~ /lttng_ust_toggle:auto_stop/ { seen_auto = 1 }
$0 ~ /lttng_ust_toggle:stop/ { if (seen_auto == 1) { exit 0 } else { exit 1 } }
'

# Check expected trace counts.
dir=$(ls -d -1 ./toggle_traces/*/)
start_count=$(babeltrace_thapi -c $dir | grep lttng_ust_toggle:start | wc -l)
[ "$start_count" -eq 1 ]

stop_count=$(babeltrace_thapi -c $dir | grep lttng_ust_toggle:stop | wc -l)
[ "$stop_count" -eq 1 ]

auto_stop_count=$(babeltrace_thapi -c $dir | grep lttng_ust_toggle:auto_stop | wc -l)
[ "$auto_stop_count" -eq 1 ]
}

@test "toggle_api_dlopen" {
rm -rf toggle_traces 2>/dev/null

cc ./integration_tests/toggle_dlopen.c -o toggle_dlopen -ldl
iprof --trace-output toggle_traces --no-analysis -- ./toggle_dlopen

# Check expected trace counts.
dir=$(ls -d -1 ./toggle_traces/*/)
start_count=$(babeltrace_thapi -c $dir | grep lttng_ust_toggle:start | wc -l)
[ "$start_count" -eq 2 ]

stop_count=$(babeltrace_thapi -c $dir | grep lttng_ust_toggle:stop | wc -l)
[ "$stop_count" -eq 2 ]

auto_stop_count=$(babeltrace_thapi -c $dir | grep lttng_ust_toggle:auto_stop | wc -l)
[ "$auto_stop_count" -eq 2 ]
}

toggle_count_base() {
rm -rf toggle_traces 2>/dev/null

THAPI_SYNC_DAEMON=fs THAPI_JOBID=$(get_unique_jobid) timeout 40s mpirun -n $1 \
iprof --trace-output toggle_traces --no-analysis -- ./toggle_mpi $2

traces=$(babeltrace_thapi ./toggle_traces)

echo $traces
}

toggle_count_traces() {
traces=$(toggle_count_base $1 $2)
echo $traces | sed -e "s/ \[/\n[/g" | grep . | wc -l
}

@test "toggle_plugin_mpi_np_1" {
mpicc ${THAPI_INCFLAGS} ./integration_tests/toggle_mpi.c -o toggle_mpi ${THAPI_LDFLAGS}

count_0=$(toggle_count_traces 1 0)
count_1=$(toggle_count_traces 1 1)
count_2=$(toggle_count_traces 1 2)

[ "$count_2" -eq 0 ]
[ "$count_0" -gt "$count_1" ]
}

toggle_count_vpids() {
traces=$(toggle_count_base $1 $2)
echo $traces | sed -e "s/ - /, /g" | sed -e "s/,/\n/g" | grep vpid | sort | uniq | wc -l
}

@test "toggle_plugin_mpi_np_2" {
mpicc ${THAPI_INCFLAGS} ./integration_tests/toggle_mpi.c -o toggle_mpi ${THAPI_LDFLAGS}

count_0=$(toggle_count_vpids 2 0)
count_1=$(toggle_count_vpids 2 1)
count_2=$(toggle_count_vpids 2 2)

[ "$count_0" -eq 2 ]
[ "$count_1" -eq 1 ]
[ "$count_2" -eq 0 ]
}
7 changes: 7 additions & 0 deletions integration_tests/toggle.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <thapi.h>

int main(void) {
thapi_start();
thapi_stop();
return 0;
}
35 changes: 35 additions & 0 deletions integration_tests/toggle_dlopen.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>

#define check_error(ptr_) \
{ \
void *ptr = (void *)ptr_; \
if (!ptr) { \
fprintf(stderr, "%s:%d -- %s\n", __FILE__, __LINE__, dlerror()); \
return 1; \
} \
}

int main(void) {
dlerror();

for (int i = 0; i < 2; i++) {
void *thapi = dlopen("libThapi.so", RTLD_NOW | RTLD_LOCAL);
check_error(thapi);

void (*start)(void) = (void (*)(void))dlsym(thapi, "thapi_start");
check_error(start);

void (*stop)(void) = (void (*)(void))dlsym(thapi, "thapi_stop");
check_error(stop);

(*start)(), (*stop)();

dlclose(thapi);
}

return 0;
}

#undef check_error
30 changes: 30 additions & 0 deletions integration_tests/toggle_mpi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <stdlib.h>
#include <mpi.h>

#include <thapi.h>

int main(int argc, char *argv[]) {
int variant = (argc > 1) ? atoi(argv[1]) : 0;

MPI_Init(&argc, &argv);

int rank, size;

switch (variant) {
case 0:
thapi_start();
case 1:
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0) thapi_start();
MPI_Comm_size(MPI_COMM_WORLD, &size);
break;
default:
break;
}

thapi_stop();

MPI_Finalize();

return 0;
}
Loading
Loading