-
Notifications
You must be signed in to change notification settings - Fork 13
Add thapi_start()/stop() for localized profiling
#326
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
Closed
Closed
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
dc6d2fc
Generate traces for thapi_start() and thapi_end()
thilinarmtb c090fc0
Call thapi_stop() if libtoggle is linked
thilinarmtb 6a51a9f
Rename toggle to ThapiProfiler
thilinarmtb a1b6fb1
Add `profiler_` to ThapiProfiler symbols
thilinarmtb 37167c1
Fix `make distcheck` failure
thilinarmtb af00b8d
Remove profiler from symbols
thilinarmtb aa67122
Use AX_GCC_FUNC_ATTRIBUTE to check constructor support
thilinarmtb 1003087
Install libThapi.so in lib instead of lib/thapi
thilinarmtb 74fb7ed
Add an integration test
thilinarmtb e13bf61
Minor changes in utils/thapi.[ch]
thilinarmtb a58427c
Fix the failing integration test
thilinarmtb db61de6
thapi.c->thapi_toggle.c & use toggle over profiler
thilinarmtb be8872c
Use constructor priority for thapi_stop()
thilinarmtb 866524b
Set minimum lttng-ust version
thilinarmtb bdb46e7
Check if the header is included by a CXX compiler
thilinarmtb a510655
Plugin to filter traces based on thapi_start/stop
thilinarmtb 1a11ace
Format utils/thapi_toggle.c
thilinarmtb 74ff796
Prefix files related to toggle with `thapi_toggle`
thilinarmtb 437edaa
Check hostname and vpid when using toggle
thilinarmtb 3ff315b
Install ThapiToggle plugin
thilinarmtb da4ba75
Add integration tests for ThapiToggle
thilinarmtb cf5da60
Add integration tests with np=2 for ThapiToggle
thilinarmtb cd3d6df
Fix typos and refactor toggle tests
thilinarmtb 7ab49a0
Move toggle tests into toggle.bats
thilinarmtb 6501841
Use babeltrace_thapi instead of babeltrace2
thilinarmtb 1ea06af
Simplify trace counting
thilinarmtb 7a27d24
Set and use the env vars from setup_suite.bash
thilinarmtb 2b92ce5
Rename the filter to `toggle`
thilinarmtb 4166e5b
Rename `thapi_toggle_* -> toggle_* in tests
thilinarmtb 912d444
Undo spliting LTTNNG_FLAGS
thilinarmtb 44ca184
Comment why lttng-ust version change is required
thilinarmtb 287066f
Install libThapiToggle.so in bt2 plugin dir
thilinarmtb 4695de1
Fix libThapiToggle.so flags
thilinarmtb 98e9e9e
Run filter.toggle.toggle during trace command
thilinarmtb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #!/usr/bin/env bats | ||
|
|
||
| teardown_file() { | ||
| rm -rf $THAPI_HOME/thapi-traces | ||
| } | ||
|
|
||
| get_unique_jobid() { | ||
| echo ${BATS_TEST_NAME}.${RANDOM} | ||
| } | ||
|
|
||
| @test "toggle_api" { | ||
| rm -rf toggle_traces 2> /dev/null | ||
|
|
||
| cc -I${THAPI_INC_DIR} ./integration_tests/toggle.c -o toggle \ | ||
| -Wl,-rpath,${THAPI_LIB_DIR} -L${THAPI_LIB_DIR} -lThapi | ||
|
|
||
| $IPROF --trace-output toggle_traces --no-analysis -- ./toggle | ||
| dir=$(ls -d -1 ./toggle_traces/*/) | ||
|
|
||
| start_count=`$BBT -c $dir | grep lttng_ust_toggle:start | wc -l` | ||
| [ "$start_count" -eq 1 ] | ||
|
|
||
| stop_count=`$BBT -c $dir | grep lttng_ust_toggle:stop | wc -l` | ||
| [ "$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=$($BBT ./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 -I${THAPI_INC_DIR} ./integration_tests/toggle_mpi.c -o toggle_mpi \ | ||
| -Wl,-rpath,${THAPI_LIB_DIR} -L${THAPI_LIB_DIR} -lThapi | ||
|
|
||
| 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 -I${THAPI_INC_DIR} ./integration_tests/toggle_mpi.c -o toggle_mpi \ | ||
| -Wl,-rpath,${THAPI_LIB_DIR} -L${THAPI_LIB_DIR} -lThapi | ||
|
|
||
| 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 ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #include <thapi.h> | ||
|
|
||
| int main(int argc, char *argv[]) { | ||
| thapi_start(); | ||
| thapi_stop(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
|
Comment on lines
+1
to
+30
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose we can merge it with the |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,242 @@ | ||
| # =========================================================================== | ||
| # https://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.html | ||
| # =========================================================================== | ||
| # | ||
| # SYNOPSIS | ||
| # | ||
| # AX_GCC_FUNC_ATTRIBUTE(ATTRIBUTE) | ||
| # | ||
| # DESCRIPTION | ||
| # | ||
| # This macro checks if the compiler supports one of GCC's function | ||
| # attributes; many other compilers also provide function attributes with | ||
| # the same syntax. Compiler warnings are used to detect supported | ||
| # attributes as unsupported ones are ignored by default so quieting | ||
| # warnings when using this macro will yield false positives. | ||
| # | ||
| # The ATTRIBUTE parameter holds the name of the attribute to be checked. | ||
| # | ||
| # If ATTRIBUTE is supported define HAVE_FUNC_ATTRIBUTE_<ATTRIBUTE>. | ||
| # | ||
| # The macro caches its result in the ax_cv_have_func_attribute_<attribute> | ||
| # variable. | ||
| # | ||
| # The macro currently supports the following function attributes: | ||
| # | ||
| # alias | ||
| # aligned | ||
| # alloc_size | ||
| # always_inline | ||
| # artificial | ||
| # cold | ||
| # const | ||
| # constructor | ||
| # constructor_priority for constructor attribute with priority | ||
| # deprecated | ||
| # destructor | ||
| # dllexport | ||
| # dllimport | ||
| # error | ||
| # externally_visible | ||
| # fallthrough | ||
| # flatten | ||
| # format | ||
| # format_arg | ||
| # gnu_format | ||
| # gnu_inline | ||
| # hot | ||
| # ifunc | ||
| # leaf | ||
| # malloc | ||
| # noclone | ||
| # noinline | ||
| # nonnull | ||
| # noreturn | ||
| # nothrow | ||
| # optimize | ||
| # pure | ||
| # sentinel | ||
| # sentinel_position | ||
| # unused | ||
| # used | ||
| # visibility | ||
| # warning | ||
| # warn_unused_result | ||
| # weak | ||
| # weakref | ||
| # | ||
| # Unsupported function attributes will be tested with a prototype | ||
| # returning an int and not accepting any arguments and the result of the | ||
| # check might be wrong or meaningless so use with care. | ||
| # | ||
| # LICENSE | ||
| # | ||
| # Copyright (c) 2013 Gabriele Svelto <gabriele.svelto@gmail.com> | ||
| # | ||
| # Copying and distribution of this file, with or without modification, are | ||
| # permitted in any medium without royalty provided the copyright notice | ||
| # and this notice are preserved. This file is offered as-is, without any | ||
| # warranty. | ||
|
|
||
| #serial 13 | ||
|
|
||
| AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [ | ||
| AS_VAR_PUSHDEF([ac_var], [ax_cv_have_func_attribute_$1]) | ||
|
|
||
| AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [ | ||
| AC_LINK_IFELSE([AC_LANG_PROGRAM([ | ||
| m4_case([$1], | ||
| [alias], [ | ||
| int foo( void ) { return 0; } | ||
| int bar( void ) __attribute__(($1("foo"))); | ||
| ], | ||
| [aligned], [ | ||
| int foo( void ) __attribute__(($1(32))); | ||
| ], | ||
| [alloc_size], [ | ||
| void *foo(int a) __attribute__(($1(1))); | ||
| ], | ||
| [always_inline], [ | ||
| inline __attribute__(($1)) int foo( void ) { return 0; } | ||
| ], | ||
| [artificial], [ | ||
| inline __attribute__(($1)) int foo( void ) { return 0; } | ||
| ], | ||
| [cold], [ | ||
| int foo( void ) __attribute__(($1)); | ||
| ], | ||
| [const], [ | ||
| int foo( void ) __attribute__(($1)); | ||
| ], | ||
| [constructor_priority], [ | ||
| int foo( void ) __attribute__((__constructor__(65535/2))); | ||
| ], | ||
| [constructor], [ | ||
| int foo( void ) __attribute__(($1)); | ||
| ], | ||
| [deprecated], [ | ||
| int foo( void ) __attribute__(($1(""))); | ||
| ], | ||
| [destructor], [ | ||
| int foo( void ) __attribute__(($1)); | ||
| ], | ||
| [dllexport], [ | ||
| __attribute__(($1)) int foo( void ) { return 0; } | ||
| ], | ||
| [dllimport], [ | ||
| int foo( void ) __attribute__(($1)); | ||
| ], | ||
| [error], [ | ||
| int foo( void ) __attribute__(($1(""))); | ||
| ], | ||
| [externally_visible], [ | ||
| int foo( void ) __attribute__(($1)); | ||
| ], | ||
| [fallthrough], [ | ||
| void foo( int x ) {switch (x) { case 1: __attribute__(($1)); case 2: break ; }}; | ||
| ], | ||
| [flatten], [ | ||
| int foo( void ) __attribute__(($1)); | ||
| ], | ||
| [format], [ | ||
| int foo(const char *p, ...) __attribute__(($1(printf, 1, 2))); | ||
| ], | ||
| [gnu_format], [ | ||
| int foo(const char *p, ...) __attribute__((format(gnu_printf, 1, 2))); | ||
| ], | ||
| [format_arg], [ | ||
| char *foo(const char *p) __attribute__(($1(1))); | ||
| ], | ||
| [gnu_inline], [ | ||
| inline __attribute__(($1)) int foo( void ) { return 0; } | ||
| ], | ||
| [hot], [ | ||
| int foo( void ) __attribute__(($1)); | ||
| ], | ||
| [ifunc], [ | ||
| int my_foo( void ) { return 0; } | ||
| static int (*resolve_foo(void))(void) { return my_foo; } | ||
| int foo( void ) __attribute__(($1("resolve_foo"))); | ||
| ], | ||
| [leaf], [ | ||
| __attribute__(($1)) int foo( void ) { return 0; } | ||
| ], | ||
| [malloc], [ | ||
| void *foo( void ) __attribute__(($1)); | ||
| ], | ||
| [noclone], [ | ||
| int foo( void ) __attribute__(($1)); | ||
| ], | ||
| [noinline], [ | ||
| __attribute__(($1)) int foo( void ) { return 0; } | ||
| ], | ||
| [nonnull], [ | ||
| int foo(char *p) __attribute__(($1(1))); | ||
| ], | ||
| [noreturn], [ | ||
| void foo( void ) __attribute__(($1)); | ||
| ], | ||
| [nothrow], [ | ||
| int foo( void ) __attribute__(($1)); | ||
| ], | ||
| [optimize], [ | ||
| __attribute__(($1(3))) int foo( void ) { return 0; } | ||
| ], | ||
| [pure], [ | ||
| int foo( void ) __attribute__(($1)); | ||
| ], | ||
| [sentinel], [ | ||
| int foo(void *p, ...) __attribute__(($1)); | ||
| ], | ||
| [sentinel_position], [ | ||
| int foo(void *p, ...) __attribute__(($1(1))); | ||
| ], | ||
| [returns_nonnull], [ | ||
| void *foo( void ) __attribute__(($1)); | ||
| ], | ||
| [unused], [ | ||
| int foo( void ) __attribute__(($1)); | ||
| ], | ||
| [used], [ | ||
| int foo( void ) __attribute__(($1)); | ||
| ], | ||
| [visibility], [ | ||
| int foo_def( void ) __attribute__(($1("default"))); | ||
| int foo_hid( void ) __attribute__(($1("hidden"))); | ||
| int foo_int( void ) __attribute__(($1("internal"))); | ||
| int foo_pro( void ) __attribute__(($1("protected"))); | ||
| ], | ||
| [warning], [ | ||
| int foo( void ) __attribute__(($1(""))); | ||
| ], | ||
| [warn_unused_result], [ | ||
| int foo( void ) __attribute__(($1)); | ||
| ], | ||
| [weak], [ | ||
| int foo( void ) __attribute__(($1)); | ||
| ], | ||
| [weakref], [ | ||
| static int foo( void ) { return 0; } | ||
| static int bar( void ) __attribute__(($1("foo"))); | ||
| ], | ||
| [ | ||
| m4_warn([syntax], [Unsupported attribute $1, the test may fail]) | ||
| int foo( void ) __attribute__(($1)); | ||
| ] | ||
| )], []) | ||
| ], | ||
| dnl GCC doesn't exit with an error if an unknown attribute is | ||
| dnl provided but only outputs a warning, so accept the attribute | ||
| dnl only if no warning were issued. | ||
| [AS_IF([grep -- -Wattributes conftest.err], | ||
| [AS_VAR_SET([ac_var], [no])], | ||
| [AS_VAR_SET([ac_var], [yes])])], | ||
| [AS_VAR_SET([ac_var], [no])]) | ||
| ]) | ||
|
|
||
| AS_IF([test yes = AS_VAR_GET([ac_var])], | ||
| [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_FUNC_ATTRIBUTE_$1), 1, | ||
| [Define to 1 if the system has the `$1' function attribute])], []) | ||
|
|
||
| AS_VAR_POPDEF([ac_var]) | ||
| ]) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? And if required can we do that in a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh maybe just a rebase issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the toggle integration tests, we need
THAPI_INC_DIRandTHAPI_LIB_DIR(to link againstlibThapiToogle.soand includethapi.h). I could set them up separately but I think it is easierto pass in the
THAPI_INSTALL_DIRand then use that to findTHAPI_INC_DIR, THAPI_LIB_DIRand
THAPI_BIN_DIR.