Skip to content

Instantly share code, notes, and snippets.

@freme
Last active April 21, 2019 23:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freme/d3d7676d34b9d5d22ba6 to your computer and use it in GitHub Desktop.
Save freme/d3d7676d34b9d5d22ba6 to your computer and use it in GitHub Desktop.
CMAKE for VampirTrace
# Copyright (c) 2014, Felix Schmitt, Axel Huebl, Rene Widera
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the PIConGPU nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
################################################################################
# VampirTrace
################################################################################
option(VAMPIR_ENABLE "VampirTrace support" OFF)
# set filters: please do NOT use line breaks WITHIN the string!
set(VT_INST_FILE_FILTER
"stl,usr/include"
CACHE STRING "VampirTrace: Files to exclude from instrumentation")
set(VT_INST_FUNC_FILTER
"vector,Vector"
CACHE STRING "VampirTrace: Functions to exclude from instrumentation")
if(VAMPIR_ENABLE)
message(STATUS "Building with VampirTrace support")
set(VAMPIR_ROOT "$ENV{VT_ROOT}")
if(NOT VAMPIR_ROOT)
message(FATAL_ERROR "Environment variable VT_ROOT not set!")
endif(NOT VAMPIR_ROOT)
# compile flags
execute_process(COMMAND $ENV{VT_ROOT}/bin/vtc++ -vt:hyb -vt:showme-compile
OUTPUT_VARIABLE VT_COMPILEFLAGS
RESULT_VARIABLE VT_CONFIG_RETURN)
if(NOT VT_CONFIG_RETURN EQUAL 0)
message(FATAL_ERROR "Can NOT execute 'vtc++' at $ENV{VT_ROOT}/bin/vtc++ - check file permissions")
else()
# trim trailing newlines
string(REGEX REPLACE "(\r?\n)+$" "" VT_COMPILEFLAGS "${VT_COMPILEFLAGS}")
endif()
# link flags
execute_process(COMMAND $ENV{VT_ROOT}/bin/vtc++ -vt:hyb -vt:showme-link
OUTPUT_VARIABLE VT_LINKFLAGS)
string(REGEX REPLACE "(\r?\n)+$" "" VT_LINKFLAGS "${VT_LINKFLAGS}")
# bugfix showme
string(REPLACE "--as-needed" "--no-as-needed" VT_LINKFLAGS "${VT_LINKFLAGS}")
# modify our flags
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} ${VT_LINKFLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${VT_COMPILEFLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -finstrument-functions-exclude-file-list=${VT_INST_FILE_FILTER}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -finstrument-functions-exclude-function-list=${VT_INST_FUNC_FILTER}")
# nvcc flags (rly necessary?)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}
-Xcompiler=-finstrument-functions,-finstrument-functions-exclude-file-list=\\\"${VT_INST_FILE_FILTER}\\\"
-Xcompiler=-finstrument-functions-exclude-function-list=\\\"${VT_INST_FUNC_FILTER}\\\"
-Xcompiler=-DVTRACE -Xcompiler=-I\\\"${VT_ROOT}/include/vampirtrace\\\"
-v)
# for manual instrumentation and hints that vampir is enabled in our code
add_definitions(-DVTRACE)
# titan work around: currently (5.14.4) the -D defines are not provided by -vt:showme-compile
add_definitions(-DMPICH_IGNORE_CXX_SEEK)
endif(VAMPIR_ENABLE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment