Skip to content

Commit 5241da4

Browse files
committed
configure support for NVTX annotations
1 parent b3b65a8 commit 5241da4

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

m4/libmesh_optional_packages.m4

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,13 @@ AS_IF([test "$enabletrilinos" = yes],
303303
# -------------------------------------------------------------
304304
305305
306+
# -------------------------------------------------------------
307+
# NVTX -- enabled by default
308+
# -------------------------------------------------------------
309+
CONFIGURE_NVTX
310+
# --------------------------------------------------------------
311+
312+
306313
# -------------------------------------------------------------
307314
# Choose between TBB, OpenMP, and pthreads thread models.
308315
# The user can control this by configuring with

m4/nvtx.m4

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
dnl -------------------------------------------------------------
2+
dnl NVIDIA Tools Extension Library (NVTX)
3+
dnl -------------------------------------------------------------
4+
AC_DEFUN([CONFIGURE_NVTX],
5+
[
6+
AC_ARG_ENABLE(nvtx,
7+
AS_HELP_STRING([--disable-nvtx],
8+
[build without annotation support via NVTX]),
9+
[AS_CASE("${enableval}",
10+
[yes], [enablenvtx=yes],
11+
[no], [enablenvtx=no],
12+
[AC_MSG_ERROR(bad value ${enableval} for --enable-nvtx)])],
13+
[enablenvtx=$enableoptional])
14+
15+
AS_IF([test "x$enablenvtx" = "xyes"],
16+
[
17+
AC_ARG_WITH(nvtx,
18+
AS_HELP_STRING([--with-nvtx=PATH],[Specify the path where NVTX is installed]),
19+
withnvtx=$withval,
20+
withnvtx=$NVTX_DIR)
21+
22+
AS_IF([test "$withnvtx" != no],
23+
[
24+
AS_IF([test "x$withnvtx" = "x"], [withnvtx=/usr])
25+
AC_CHECK_HEADER($withnvtx/include/nvtx3/nvtx3.hpp, NVTX_INCLUDE_PATH=$withnvtx/include)
26+
])
27+
28+
AS_IF([test -r $NVTX_INCLUDE_PATH/nvtx3/nvtx3.hpp],
29+
[
30+
NVTX_INCLUDE=-I$NVTX_INCLUDE_PATH
31+
],
32+
[enablenvtx=no])
33+
34+
dnl If NVTX is still enabled at this point, make sure we can compile
35+
dnl a test code which uses nvtx3::mark
36+
AS_IF([test "x$enablenvtx" != "xno"],
37+
[
38+
AC_MSG_CHECKING(for nvtx3::mark support)
39+
AC_LANG_PUSH([C++])
40+
41+
dnl Add NVTX headers to CXXFLAGS, which will be used by AC_COMPILE_IFELSE.
42+
saveCXXFLAGS="$CXXFLAGS"
43+
CXXFLAGS="$saveCXXFLAGS $NVTX_INCLUDE"
44+
45+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
46+
@%:@include <nvtx3/nvtx3.hpp>
47+
],
48+
[
49+
nvtx3::mark("Hello world!");
50+
])],
51+
[
52+
AC_MSG_RESULT(yes)
53+
enablenvtx=yes
54+
],
55+
[
56+
AC_MSG_RESULT(no)
57+
enablenvtx=no
58+
])
59+
60+
dnl Restore original flags
61+
CXXFLAGS=$saveCXXFLAGS
62+
63+
AC_LANG_POP([C++])
64+
])
65+
66+
dnl If NVTX is still enabled at this point, set the necessary define and print
67+
dnl a success message.
68+
AS_IF([test "x$enablenvtx" != "xno"],
69+
[
70+
AC_SUBST(NVTX_INCLUDE)
71+
AC_DEFINE(HAVE_NVTX_API, 1, [Flag indicating whether the library shall be compiled to use NVTX annotations])
72+
AC_MSG_RESULT(<<< Configuring library with NVTX annotation support >>>)
73+
])
74+
])
75+
])

0 commit comments

Comments
 (0)