Skip to content
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
edf6a11
Generate traces for thapi_start() and thapi_end()
thilinarmtb Feb 28, 2025
7cc18ff
Call thapi_stop() if libtoggle is linked
thilinarmtb Mar 3, 2025
249e658
Rename toggle to ThapiProfiler
thilinarmtb Mar 3, 2025
ad7f791
Add `profiler_` to ThapiProfiler symbols
thilinarmtb Mar 3, 2025
ad512cb
Fix `make distcheck` failure
thilinarmtb Mar 6, 2025
b7bd6e8
Remove profiler from symbols
thilinarmtb Mar 6, 2025
a042d54
Use AX_GCC_FUNC_ATTRIBUTE to check constructor support
thilinarmtb Mar 6, 2025
1eb6f82
Install libThapi.so in lib instead of lib/thapi
thilinarmtb Mar 6, 2025
df1fdf2
Add an integration test
thilinarmtb Mar 6, 2025
8454059
Minor changes in utils/thapi.[ch]
thilinarmtb Mar 6, 2025
b4ef608
Fix the failing integration test
thilinarmtb Mar 18, 2025
fe83fb2
thapi.c->thapi_toggle.c & use toggle over profiler
thilinarmtb Mar 18, 2025
9405c85
Use constructor priority for thapi_stop()
thilinarmtb Mar 18, 2025
755cc11
Set minimum lttng-ust version
thilinarmtb Mar 18, 2025
330adde
Check if the header is included by a CXX compiler
thilinarmtb Mar 25, 2025
0002be1
Plugin to filter traces based on thapi_start/stop
thilinarmtb Apr 2, 2025
f51326b
Format utils/thapi_toggle.c
thilinarmtb Apr 2, 2025
225f479
Prefix files related to toggle with `thapi_toggle`
thilinarmtb Jun 24, 2025
69fad87
Check hostname and vpid when using toggle
thilinarmtb Jun 24, 2025
704a412
Install ThapiToggle plugin
thilinarmtb Jul 1, 2025
99545c7
Add integration tests for ThapiToggle
thilinarmtb Jul 1, 2025
6d7d381
Add integration tests with np=2 for ThapiToggle
thilinarmtb Jul 2, 2025
8a6646d
Fix typos and refactor toggle tests
thilinarmtb Jul 2, 2025
ecb0f5f
Move toggle tests into toggle.bats
thilinarmtb Jul 3, 2025
8afc694
Use babeltrace_thapi instead of babeltrace2
thilinarmtb Jul 3, 2025
2445208
Simplify trace counting
thilinarmtb Jul 3, 2025
9848f64
Set and use the env vars from setup_suite.bash
thilinarmtb Jul 14, 2025
4e95849
Rename the filter to `toggle`
thilinarmtb Jul 14, 2025
18c63b2
Rename `thapi_toggle_* -> toggle_* in tests
thilinarmtb Jul 14, 2025
2ad525f
Undo spliting LTTNNG_FLAGS
thilinarmtb Jul 15, 2025
d41846b
Comment why lttng-ust version change is required
thilinarmtb Jul 15, 2025
496484a
Install libThapiToggle.so in bt2 plugin dir
thilinarmtb Sep 29, 2025
af1ac4d
Fix libThapiToggle.so flags
thilinarmtb Oct 1, 2025
dbf3284
Fix `shfmt` errors
thilinarmtb Jan 26, 2026
b0aaf18
Add `Cflags` and `Libs` to `thapi.pc.in`
thilinarmtb Jan 26, 2026
81c7d00
Use `pkg-config` to find thapi include and ldflags
thilinarmtb Jan 26, 2026
bbcbbd1
$IPROF -> iprof, $BBT -> babeltrace_thapi
thilinarmtb Jan 27, 2026
f69dc19
Enable toggle events on iprof
thilinarmtb Jan 28, 2026
7c3d4b0
$MPIRUN -> mpirun
thilinarmtb Jan 29, 2026
00eecb0
Add `lttng_ust_toggle:auto_stop`
thilinarmtb Feb 1, 2026
a709e48
Get rid of THAPI_HOME
thilinarmtb Feb 3, 2026
b1b37e3
Add a dlopen test for toggle traces
thilinarmtb Feb 2, 2026
5f7c654
Update the thapi babeltrace plugin
thilinarmtb Feb 5, 2026
f457ccb
clang-format -i thapi_toggle*
thilinarmtb Feb 5, 2026
8fa54e9
Fix compilation errors
thilinarmtb Feb 5, 2026
fe34785
Minor fixes
thilinarmtb Mar 4, 2026
9e80994
Split toggle API tests into two tests
thilinarmtb Mar 4, 2026
25d58a1
Add the toggle filter in babeltrace_thapi
thilinarmtb Mar 4, 2026
b5e2ff0
Remove redundant code due to a bad rebase
thilinarmtb Jul 14, 2026
df169a6
Fix linting errors
thilinarmtb Jul 14, 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 @@ -104,7 +104,10 @@ AX_COMPARE_VERSION([$H2YAML_VERSION], [ge], [$H2YAML_MIN_VERSION],

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([nokogiri], [yes])
Expand Down Expand Up @@ -138,6 +141,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
31 changes: 31 additions & 0 deletions integration_tests/toggle_mpi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <mpi.h>
#include <stdlib.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