|
| 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