Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

Commit

Permalink
Properly enable itt (vtune) support
Browse files Browse the repository at this point in the history
Fixes: #22

Signed-off-by: Dmitry Rogozhkin <[email protected]>
  • Loading branch information
dvrogozh authored and Oleg Nabiullin committed Jun 21, 2018
1 parent 73c4251 commit 5e6b710
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 45 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ if( CMAKE_SYSTEM_NAME MATCHES Linux )
option( ENABLE_WAYLAND "Build WAYLAND versions of the targets?" OFF )
endif()

option( ENABLE_ITT "Build targets with ITT instrumentation support (requires VTune)?" OFF )

include( ${BUILDER_ROOT}/FindOpenCL.cmake )
include( ${BUILDER_ROOT}/FindFunctions.cmake )
include( ${BUILDER_ROOT}/FindGlobals.cmake )
include( ${BUILDER_ROOT}/FindMFX.cmake )
include( ${BUILDER_ROOT}/FindPackages.cmake )
include( ${BUILDER_ROOT}/FindInternals.cmake )
include( ${BUILDER_ROOT}/FindITT.cmake )
include( ${BUILDER_ROOT}/FindTrace.cmake )
include( ${BUILDER_ROOT}/FindGTest.cmake )

Expand Down Expand Up @@ -108,4 +111,5 @@ if( CMAKE_SYSTEM_NAME MATCHES Linux )
message(" ENABLE_X11_DRI3 : ${ENABLE_X11_DRI3}")
message(" ENABLE_WAYLAND : ${ENABLE_WAYLAND}")
endif()
message(" ENABLE_ITT : ${ENABLE_ITT}")
message("*****************************************************************************")
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ You can find answers for the most frequently asked questions [here](https://soft
* [System requirements](#system-requirements)
* [How to build](#how-to-build)
* [Build steps](#build-steps)
* [Enabling Instrumentation and Tracing Technology](#enabling-instrumentation-and-tracing-technology)
* [Enabling Instrumentation and Tracing Technology (ITT)](#enabling-instrumentation-and-tracing-technology-itt)
* [Recommendations](#recommendations)
* [See also](#see-also)

Expand Down Expand Up @@ -86,11 +86,27 @@ Media SDK depends on a number of packages which are identified and checked for t
| ENABLE_OPENCL | ON\|OFF | Enable OpenCL dependent code to be built (default: ON) |
| ENABLE_X11_DRI3 | ON\|OFF | Enable X11 DRI3 dependent code to be built (default: OFF) |
| ENABLE_WAYLAND | ON\|OFF | Enable Wayland dependent code to be built (default: OFF) |
| ENABLE_ITT | ON\|OFF | Enable ITT (VTune) instrumentation support (default: OFF) |

## Enabling Instrumentation and Tracing Technology
To enable the Instrumentation and Tracing Technology API you need either Intel® VTune™ Amplifier installed or to manually build an open source version. You can get ITT source files from [GitHub](https://github.com/01org/IntelSEAPI/tree/master/ittnotify) and build it on your own.
The following cmake settings can be used to adjust search path locations for some components Media SDK build may depend on:

**Please note** that auto detection of the Intel VTune Amplifier configuration is not supported. The next step is mandatory if you want to use this feature: set `$ITT_PATH` so `$ITT_PATH/include/ittnotify.h` and `$ITT_PATH/libittnotify64.a` will be valid paths. MSDK build system will automatically detect it.
| Setting | Values | Description |
| ------- | ------ | ----------- |
| CMAKE_ITT_HOME | Valid system path | Location of ITT installation, takes precendence over CMAKE_VTUNE_HOME (by default not defined) |
| CMAKE_VTUNE_HOME | Valid system path | Location of VTune installation (default: /opt/intel/vtune_amplifier) |

## Enabling Instrumentation and Tracing Technology (ITT)

To enable the Instrumentation and Tracing Technology (ITT) API you need to:
* Either install [Intel® VTune™ Amplifier](https://software.intel.com/en-us/intel-vtune-amplifier-xe)
* Or manually build an open source version (see [GitHub](https://github.com/01org/IntelSEAPI/tree/master/ittnotify) for details

and configure Media SDK with the -DENABLE_ITT=ON. In case of VTune it will be searched in the default location (/opt/intel/vtune_amplifier). You can adjust ITT search path with either CMAKE_ITT_HOME or CMAKE_VTUNE_HOME.

Once Media SDK was built with ITT support, enable it in a runtime creating per-user configuration file ($HOME/.mfx_trace) or a system wide configuration file (/etc/mfx_trace) with the following content:
```sh
Output=0x10
```

# Recommendations

Expand Down
3 changes: 2 additions & 1 deletion _studio/hevc_fei/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ endforeach()
umc
vm
vm_plus
${ITT_LIBS}
mfx_trace
${ITT_LIBRARIES}
pthread
dl
)
Expand Down
3 changes: 2 additions & 1 deletion _studio/hevce_hw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ list( APPEND LIBS
umc
vm
vm_plus
${ITT_LIBS}
mfx_trace
${ITT_LIBRARIES}
pthread
dl
)
Expand Down
3 changes: 2 additions & 1 deletion _studio/mfx_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ list( APPEND LIBS
vc1_common
vc1_dec_hw
umc_h265_hw
${ITT_LIBS}
mfx_trace
${ITT_LIBRARIES}
pthread
dl
)
Expand Down
12 changes: 8 additions & 4 deletions _studio/mfx_lib/plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ if( DEFINED HEVC_DECODER_HW_GUID )
umc
vm
vm_plus
${ITT_LIBS}
mfx_trace
${ITT_LIBRARIES}
pthread
dl
)
Expand Down Expand Up @@ -262,7 +263,8 @@ if( DEFINED H264LA_ENCODER_GUID )
vm
vm_plus
asc
${ITT_LIBS}
mfx_trace
${ITT_LIBRARIES}
pthread
dl
)
Expand Down Expand Up @@ -336,7 +338,8 @@ if( DEFINED VP8_DECODER_HW_GUID )
vm_plus
va
umc_va_hw
${ITT_LIBS}
mfx_trace
${ITT_LIBRARIES}
pthread
dl
)
Expand Down Expand Up @@ -422,7 +425,8 @@ if( DEFINED VP9_DECODER_HW_GUID )
vm_plus
va
umc_va_hw
${ITT_LIBS}
mfx_trace
${ITT_LIBRARIES}
pthread
dl
)
Expand Down
59 changes: 32 additions & 27 deletions builder/FindVTune.cmake → builder/FindITT.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2017 Intel Corporation
# Copyright (c) 2017-2018 Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,35 +18,40 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

if(__ITT)
if( ENABLE_ITT )


if( Linux )
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set( arch "64" )
elseif()
set( arch "32" )
# VTune is a source of ITT library
if( NOT CMAKE_VTUNE_HOME )
set( CMAKE_VTUNE_HOME /opt/intel/vtune_amplifier )
endif()

find_path( ITT_INCLUDE ittnotify.h PATHS $ENV{ITT_PATH}/include )
find_path( ITT_LIB libittnotify${arch}.a PATHS $ENV{ITT_PATH} )
if(NOT ITT_INCLUDE MATCHES NOTFOUND AND NOT ITT_LIB MATCHES NOTFOUND)
set( VTUNE_FOUND TRUE )
message( STATUS "ITT_PATH is set to $ENV{ITT_PATH}" )

include_directories( $ENV{ITT_PATH}/include )
link_directories( $ENV{ITT_PATH}/ )

append("-DMFX_TRACE_ENABLE_ITT" CMAKE_C_FLAGS)
append("-DMFX_TRACE_ENABLE_ITT" CMAKE_CXX_FLAGS)

set( ITT_LIBS "" )
list( APPEND ITT_LIBS
mfx_trace
ittnotify${arch}
dl
)
else()
set( ITT_LIBS mfx_trace )
set( VTUNE_FOUND FALSE )
find_path( ITT_INCLUDE_DIRS ittnotify.h
PATHS ${CMAKE_ITT_HOME} ${CMAKE_VTUNE_HOME}
PATH_SUFFIXES include )
find_path( ITT_LIBRARY_DIRS libittnotify.a
PATHS ${CMAKE_ITT_HOME} ${CMAKE_VTUNE_HOME}
PATH_SUFFIXES lib64 )

if(NOT ITT_INCLUDE_DIRS MATCHES NOTFOUND AND
NOT ITT_LIBRARY_DIRS MATCHES NOTFOUND)

message( STATUS "itt header is in ${ITT_INCLUDE_DIRS}" )
message( STATUS "itt lib is in ${ITT_LIBRARY_DIRS}" )

include_directories( ${ITT_INCLUDE_DIRS} )
link_directories( ${ITT_LIBRARY_DIRS} )

set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMFX_TRACE_ENABLE_ITT" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMFX_TRACE_ENABLE_ITT" )

set( ITT_LIBRARIES "ittnotify" )
set( ITT_FOUND TRUE )
endif()
endif()

if (NOT ITT_FOUND)
message( FATAL_ERROR "Failed to find ITT library" )
endif()
endif()
6 changes: 1 addition & 5 deletions builder/FindTrace.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2017 Intel Corporation
# Copyright (c) 2017-2018 Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -22,10 +22,6 @@ if(__TRACE)
message( STATUS "Enabled tracing: ${__TRACE}" )
endif()

# ITT instrumentation is enabled by default to make VTune working out of the box
set(__ITT TRUE)
include ($ENV{MFX_HOME}/builder/FindVTune.cmake)

if(__TRACE MATCHES all)
append("-DMFX_TRACE_ENABLE_TEXTLOG -DMFX_TRACE_ENABLE_STAT" CMAKE_C_FLAGS)
append("-DMFX_TRACE_ENABLE_TEXTLOG -DMFX_TRACE_ENABLE_STAT" CMAKE_CXX_FLAGS)
Expand Down
5 changes: 3 additions & 2 deletions tools/builder/build_mfx.pl
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ sub get_cmake_target {
push @cmake_target, $config{'comp'} if $config{'comp'} ne 'gcc';

if ($config{'trace'} eq 'itt') {
push @cmake_target, ".$config{'trace'}";
push @cmake_target, "$config{'trace'}";
} elsif ($config{'trace'}) {
push @cmake_target, ".trace_$config{'trace'}";
push @cmake_target, "trace_$config{'trace'}";
}
return join('.', @cmake_target);
}
Expand Down Expand Up @@ -131,6 +131,7 @@ sub get_cmake_gen_cmd {
push @cmake_cmd_gen, "-D__TARGET_PLATFORM:STRING=$config{'target'}";

push @cmake_cmd_gen, "-D__TRACE:STRING=$config{'trace'}" if $config{'trace'};
push @cmake_cmd_gen, "-DENABLE_ITT=ON" if $config{'trace'} eq 'itt';
push @cmake_cmd_gen, "-DCMAKE_C_COMPILER:STRING=$config{'cc'}" if $config{'cc'};
push @cmake_cmd_gen, "-DCMAKE_CXX_COMPILER:STRING=$config{'cxx'}" if $config{'cxx'};
push @cmake_cmd_gen, "-DCMAKE_TOOLCHAIN_FILE=$config{'toolchain'}" if $config{'toolchain'};
Expand Down

0 comments on commit 5e6b710

Please sign in to comment.