Update VTune handling in cmake.

This commit is contained in:
Ye Luo 2020-12-19 15:38:34 -06:00
parent 4277992596
commit 99257d9007
2 changed files with 44 additions and 47 deletions

View File

@ -262,6 +262,9 @@ SET(BUILD_FCIQMC 0 CACHE BOOL "Build with FCIQMC")
OPTION(QMC_BUILD_STATIC "Link to static libraries" OFF)
OPTION(ENABLE_TIMERS "Enable internal timers" ON)
OPTION(ENABLE_STACKTRACE "Enable use of boost::stacktrace" OFF)
OPTION(USE_VTUNE_API "Enable use of VTune ittnotify APIs" ON)
CMAKE_DEPENDENT_OPTION(USE_VTUNE_TASKS "USE VTune ittnotify task annotation" OFF "ENABLE_TIMERS AND USE_VTUNE_API" OFF)
CMAKE_DEPENDENT_OPTION(USE_NVTX_API "Enable/disable NVTX regions in CUDA code." OFF "ENABLE_TIMERS AND (QMC_CUDA OR ENABLE_CUDA)" OFF)
######################################################################
# Install options
@ -710,22 +713,22 @@ IF(QMC_CUDA OR ENABLE_CUDA)
SET(HAVE_CUDA 1)
MESSAGE(" CUDA_NVCC_FLAGS=${CUDA_NVCC_FLAGS}")
ELSE(QMC_CUDA OR ENABLE_CUDA)
MESSAGE(STATUS "Disabling CUDA")
MESSAGE(STATUS "CUDA disabled")
ENDIF(QMC_CUDA OR ENABLE_CUDA)
OPTION(USE_NVTX_API "Enable/disable NVTX regions in CUDA code." OFF)
IF(USE_NVTX_API)
IF(HAVE_CUDA OR ENABLE_OFFLOAD)
FIND_LIBRARY(NVTX_API_LIB
NAME nvToolsExt
HINTS ${CUDA_TOOLKIT_ROOT_DIR}
PATH_SUFFIXES lib lib64)
IF(NOT NVTX_API_LIB)
MESSAGE(FATAL_ERROR "USE_NVTX_API set but NVTX_API_LIB not found")
ENDIF(NOT NVTX_API_LIB)
MESSAGE("CUDA nvToolsExt library: ${NVTX_API_LIB}")
LINK_LIBRARIES(${NVTX_API_LIB})
ENDIF(HAVE_CUDA OR ENABLE_OFFLOAD)
MESSAGE(STATUS "Enabling use of CUDA NVTX APIs")
FIND_LIBRARY(NVTX_API_LIB
NAME nvToolsExt
HINTS ${CUDA_TOOLKIT_ROOT_DIR}
PATH_SUFFIXES lib lib64)
IF(NOT NVTX_API_LIB)
MESSAGE(FATAL_ERROR "USE_NVTX_API set but NVTX_API_LIB not found")
ENDIF(NOT NVTX_API_LIB)
MESSAGE("CUDA nvToolsExt library: ${NVTX_API_LIB}")
LINK_LIBRARIES(${NVTX_API_LIB})
ELSE()
MESSAGE(STATUS "CUDA NVTX APIs disabled")
ENDIF(USE_NVTX_API)
#-------------------------------------------------------------------
@ -763,25 +766,20 @@ ENDIF(ENABLE_HIP)
#include qmcpack/src build/src
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src)
IF (USE_VTUNE_TASKS)
IF (NOT ENABLE_TIMERS)
MESSAGE(FATAL_ERROR "USE_VTUNE_TASKS is set, but timers are not enabled. Set ENABLE_TIMERS=ON.")
ENDIF()
SET(USE_VTUNE_API 1)
ENDIF()
IF (USE_VTUNE_API)
include(CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX(ittnotify.h HAVE_ITTNOTIFY_H)
IF (NOT HAVE_ITTNOTIFY_H)
MESSAGE(FATAL_ERROR "USE_VTUNE_API is defined, but the ittnotify.h include file is not found. Check that the correct include directory is present in CMAKE_CXX_FLAGS.")
ENDIF()
MESSAGE(STATUS "Enabling use of VTune ittnotify APIs")
FIND_PATH(VTUNE_ITTNOTIFY_INCLUDE_DIR ittnotify.h HINTS ${VTUNE_ROOT} $ENV{VTUNE_ROOT} PATH_SUFFIXES include REQUIRED)
MESSAGE(STATUS "Found VTUNE_ITTNOTIFY_INCLUDE_DIR ${VTUNE_ITTNOTIFY_INCLUDE_DIR}")
FIND_LIBRARY(VTUNE_ITTNOTIFY_LIBRARY ittnotify HINTS ${VTUNE_ROOT} $ENV{VTUNE_ROOT} PATH_SUFFIXES lib64 lib REQUIRED)
MESSAGE(STATUS "Found VTUNE_ITTNOTIFY_LIBRARY ${VTUNE_ITTNOTIFY_LIBRARY}")
FIND_LIBRARY(VTUNE_ITTNOTIFY_LIBRARY ittnotify)
IF (NOT VTUNE_ITTNOTIFY_LIBRARY)
MESSAGE(FATAL_ERROR "USE_VTUNE_API is defined, but the ittnotify library is not found. Check that correct library path is present in CMAKE_LIBRARY_PATH.")
INCLUDE_DIRECTORIES(${VTUNE_ITTNOTIFY_INCLUDE_DIR})
LINK_LIBRARIES(${VTUNE_ITTNOTIFY_LIBRARY})
IF (USE_VTUNE_TASKS)
MESSAGE(STATUS "VTune ittnotify tasks enabled")
ENDIF()
LINK_LIBRARIES("${VTUNE_ITTNOTIFY_LIBRARY}")
ELSE()
MESSAGE(STATUS "VTune ittnotify APIs disabled")
ENDIF()
OPTION(QMC_EXP_THREADING "Experimental non openmp threading models" OFF)

View File

@ -30,29 +30,15 @@ VTune API
~~~~~~~~~
If the variable ``USE_VTUNE_API`` is set, QMCPACK will check that the
include file (``ittnotify.h``) and the library (``libittnotify.a``) can
be found.
To provide CMake with the VTune paths, add the include path to ``CMAKE_CXX_FLAGS`` and the library path to ``CMAKE_LIBRARY_PATH``.
include file (``ittnotify.h``) and the library (``libittnotify.a``) can be found.
To provide CMake with the VTune search paths, add ``VTUNE_ROOT`` which contains ``include`` and ``lib64`` sub-directories.
An example of options to be passed to CMake:
::
-DCMAKE_CXX_FLAGS=-I/opt/intel/vtune_amplifier_xe/include \
-DCMAKE_LIBRARY_PATH=/opt/intel/vtune_amplifier_xe/lib64
NVIDIA Tools Extensions
-----------------------
NVIDIA's Tools Extensions (NVTX) API enables programmers to annotate their source code when used with the NVIDIA profilers.
NVTX API
~~~~~~~~
If the variable ``USE_NVTX_API`` is set, QMCPACK will add the library (``libnvToolsExt.so``) to the QMCPACK target. To add NVTX annotations
to a function, it is necessary to include the ``nvToolsExt.h`` header file and then make the appropriate calls into the NVTX API. For more information
about the NVTX API, see https://docs.nvidia.com/cuda/profiler-users-guide/index.html#nvtx. Any additional calls to the NVTX API should be guarded by
the ``USE_NVTX_API`` compiler define.
-DUSE_VTUNE_API=ON \
-DVTUNE_ROOT=/opt/intel/vtune_amplifier_xe
Timers as Tasks
~~~~~~~~~~~~~~~
@ -71,6 +57,19 @@ For the command line, set the ``enable-user-tasks`` knob to ``true``. For exampl
Collection with the timers set at "fine" can generate too much task data in the profile.
Collection with the timers at "medium" collects a more reasonable amount of task data.
NVIDIA Tools Extensions
-----------------------
NVIDIA's Tools Extensions (NVTX) API enables programmers to annotate their source code when used with the NVIDIA profilers.
NVTX API
~~~~~~~~
If the variable ``USE_NVTX_API`` is set, QMCPACK will add the library (``libnvToolsExt.so``) to the QMCPACK target. To add NVTX annotations
to a function, it is necessary to include the ``nvToolsExt.h`` header file and then make the appropriate calls into the NVTX API. For more information
about the NVTX API, see https://docs.nvidia.com/cuda/profiler-users-guide/index.html#nvtx. Any additional calls to the NVTX API should be guarded by
the ``USE_NVTX_API`` compiler define.
Scitools Understand
-------------------