Skip to content

Commit

Permalink
Add tests to check VCN activity tracing in perfetto output (#75)
Browse files Browse the repository at this point in the history
The test will run sampling on the example from the rocDecode repo:
https://github.com/ROCm/rocDecode/tree/develop/samples/videoDecodeBatch

Then, ensure that the Perfetto output captures VCN activity in the trace.
  • Loading branch information
sputhala-amd authored Jan 10, 2025
1 parent 4fef723 commit 98084e9
Show file tree
Hide file tree
Showing 16 changed files with 4,034 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/opensuse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
-DROCPROFSYS_PYTHON_ENVS="py3.6;py3.7;py3.8;py3.9;py3.10;py3.11"
-DROCPROFSYS_CI_MPI_RUN_AS_ROOT=ON
-DROCPROFSYS_MAX_THREADS=64
-DROCPROFSYS_DISABLE_EXAMPLES="transpose;rccl"
-DROCPROFSYS_DISABLE_EXAMPLES="transpose;rccl;videodecode"
-DROCPROFSYS_BUILD_NUMBER=${{ github.run_attempt }}

- name: Install
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ jobs:
ROCM_MAJOR=$(echo ${ROCM_VERSION} | sed 's/\./ /g' | awk '{print $1}')
ROCM_MINOR=$(echo ${ROCM_VERSION} | sed 's/\./ /g' | awk '{print $2}')
ROCM_VERSN=$(( (${ROCM_MAJOR}*10000)+(${ROCM_MINOR}*100) ))
if [ "${OS_VERSION_MAJOR}" -eq 8 ]; then PERL_REPO=powertools; else PERL_REPO=crb; fi && \
if [ "${OS_VERSION_MAJOR}" -eq 8 ]; then PERL_REPO=powertools; else PERL_REPO=crb; fi
dnf -y --enablerepo=${PERL_REPO} install perl-File-BaseDir
yum install -y https://repo.radeon.com/amdgpu-install/${{ matrix.rocm-version }}/rhel/${{ matrix.os-release }}/amdgpu-install-${ROCM_MAJOR}.${ROCM_MINOR}.${ROCM_VERSN}-1${RPM_TAG}.noarch.rpm
yum install -y rocm-dev rocm-smi-lib roctracer-dev rocprofiler-dev libpciaccess
yum install -y rocm-dev rocdecode-devel
if [ "${OS_VERSION_MAJOR}" -gt 8 ]; then dnf install -y libavcodec-free-devel libavformat-free-devel; fi
- name: Configure, Build, and Test
timeout-minutes: 115
Expand Down Expand Up @@ -120,7 +121,7 @@ jobs:
-DROCPROFSYS_DISABLE_EXAMPLES="transpose;rccl"
-DROCPROFSYS_BUILD_NUMBER=${{ github.run_attempt }}
--
-LE "transpose|rccl"
-LE "transpose|rccl|videodecode"

- name: Install
timeout-minutes: 10
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/ubuntu-focal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ jobs:
-DROCPROFSYS_PYTHON_PREFIX=/opt/conda/envs
-DROCPROFSYS_PYTHON_ENVS="py3.6;py3.7;py3.8;py3.9;py3.10;py3.11"
-DROCPROFSYS_MAX_THREADS=64
-DROCPROFSYS_DISABLE_EXAMPLES="transpose;rccl"
-DROCPROFSYS_DISABLE_EXAMPLES="transpose;rccl;videodecode"
-DROCPROFSYS_BUILD_NUMBER=${{ github.run_attempt }}
-DMPI_HEADERS_ALLOW_MPICH=OFF

Expand Down Expand Up @@ -248,7 +248,7 @@ jobs:
rocm-version: ['6.3']
mpi-headers: ['OFF']
build-jobs: ['3']
ctest-exclude: ['-LE "transpose"']
ctest-exclude: ['-LE "transpose|videodecode"']

env:
BUILD_TYPE: MinSizeRel
Expand All @@ -268,10 +268,16 @@ jobs:
command: |
apt-get update &&
apt-get install -y software-properties-common wget gnupg2 &&
wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - &&
echo "deb [arch=amd64] https://repo.radeon.com/rocm/apt/${{ matrix.rocm-version }}/ ubuntu main" | tee /etc/apt/sources.list.d/rocm.list &&
ROCM_VERSION=${{ matrix.rocm-version }} &&
ROCM_MAJOR=$(echo ${ROCM_VERSION} | sed 's/\./ /g' | awk '{print $1}') &&
ROCM_MINOR=$(echo ${ROCM_VERSION} | sed 's/\./ /g' | awk '{print $2}') &&
ROCM_VERSN=$(( (${ROCM_MAJOR}*10000)+(${ROCM_MINOR}*100) )) &&
echo "ROCM_MAJOR=${ROCM_MAJOR} ROCM_MINOR=${ROCM_MINOR} ROCM_VERSN=${ROCM_VERSN}" &&
wget -q https://repo.radeon.com/amdgpu-install/${{ matrix.rocm-version }}/ubuntu/focal/amdgpu-install_${ROCM_MAJOR}.${ROCM_MINOR}.${ROCM_VERSN}-1_all.deb &&
apt-get install -y ./amdgpu-install_${ROCM_MAJOR}.${ROCM_MINOR}.${ROCM_VERSN}-1_all.deb &&
apt-get update &&
apt-get install -y autoconf bison build-essential clang curl gettext libfabric-dev libnuma1 libomp-dev libopenmpi-dev libpapi-dev libtool libudev1 m4 openmpi-bin python3-pip rocm-dev texinfo &&
apt-get install -y rocdecode-dev libavformat-dev libavcodec-dev &&
wget https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v47.0/linux-amd64/trace_processor_shell -P /opt/trace_processor/bin &&
chmod +x /opt/trace_processor/bin/trace_processor_shell &&
python3 -m pip install --upgrade pip &&
Expand Down Expand Up @@ -483,7 +489,7 @@ jobs:
-DDYNINST_BUILD_STATIC_LIBS=OFF
-DDYNINST_ELFUTILS_DOWNLOAD_VERSION=${{ env.ELFUTILS_DOWNLOAD_VERSION }}
-DROCPROFSYS_MAX_THREADS=64
-DROCPROFSYS_DISABLE_EXAMPLES="transpose;rccl"
-DROCPROFSYS_DISABLE_EXAMPLES="transpose;rccl;videodecode"
-DROCPROFSYS_BUILD_NUMBER=${{ github.run_attempt }}
-DMPI_HEADERS_ALLOW_MPICH=ON

Expand Down Expand Up @@ -622,5 +628,5 @@ jobs:
-DROCPROFSYS_USE_ROCM=OFF
-DROCPROFSYS_USE_RCCL=OFF
-DROCPROFSYS_MAX_THREADS=64
-DROCPROFSYS_DISABLE_EXAMPLES="transpose;rccl"
-DROCPROFSYS_DISABLE_EXAMPLES="transpose;rccl;videodecode"
-DROCPROFSYS_BUILD_NUMBER=${{ github.run_attempt }}
14 changes: 10 additions & 4 deletions .github/workflows/ubuntu-jammy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,15 @@ jobs:
max_attempts: 5
shell: bash
command: |
wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add -
echo "deb [arch=amd64] https://repo.radeon.com/rocm/apt/${{ matrix.rocm-version }}/ jammy main" | tee /etc/apt/sources.list.d/rocm.list
ROCM_VERSION=${{ matrix.rocm-version }}
ROCM_MAJOR=$(echo ${ROCM_VERSION} | sed 's/\./ /g' | awk '{print $1}')
ROCM_MINOR=$(echo ${ROCM_VERSION} | sed 's/\./ /g' | awk '{print $2}')
ROCM_VERSN=$(( (${ROCM_MAJOR}*10000)+(${ROCM_MINOR}*100) ))
echo "ROCM_MAJOR=${ROCM_MAJOR} ROCM_MINOR=${ROCM_MINOR} ROCM_VERSN=${ROCM_VERSN}"
wget -q https://repo.radeon.com/amdgpu-install/${{ matrix.rocm-version }}/ubuntu/jammy/amdgpu-install_${ROCM_MAJOR}.${ROCM_MINOR}.${ROCM_VERSN}-1_all.deb
apt-get install -y ./amdgpu-install_${ROCM_MAJOR}.${ROCM_MINOR}.${ROCM_VERSN}-1_all.deb
apt-get update
ROCM_VERSION=$(apt-cache search rocm-dev[0-9] | awk '{print $1}' | sed 's/rocm-dev//g')
apt-get install -y {rocm-dev,hip-dev,roctracer-dev,rocprofiler-dev,rocm-smi-lib,rocminfo}${ROCM_VERSION}
apt-get install -y rocm-dev rocdecode-dev libavformat-dev libavcodec-dev
echo "/opt/rocm/bin" >> $GITHUB_PATH
echo "ROCM_PATH=/opt/rocm" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=/opt/rocm/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV
Expand Down Expand Up @@ -185,6 +189,8 @@ jobs:
-DROCPROFSYS_DISABLE_EXAMPLES="transpose;rccl"
-DROCPROFSYS_BUILD_NUMBER=${{ github.run_attempt }}
-DUSE_CLANG_OMP=OFF
--
-LE "transpose|rccl|videodecode"

- name: Install
timeout-minutes: 10
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu-noble.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
wget -q https://repo.radeon.com/amdgpu-install/${{ matrix.rocm-version }}/ubuntu/noble/amdgpu-install_${ROCM_MAJOR}.${ROCM_MINOR}.${ROCM_VERSN}-1_all.deb
apt-get install -y ./amdgpu-install_${ROCM_MAJOR}.${ROCM_MINOR}.${ROCM_VERSN}-1_all.deb
apt-get update
apt-get install -y rocm-dev
apt-get install -y rocm-dev rocdecode-dev libavformat-dev libavcodec-dev
- name: Configure
timeout-minutes: 30
Expand Down
3 changes: 3 additions & 0 deletions cmake/ConfigCPack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ if(ROCPROFSYS_USE_MPI)
list(APPEND _DEBIAN_PACKAGE_DEPENDS "libmpich-dev")
endif()
endif()
if(ROCPROFSYS_BUILD_TESTING)
list(APPEND _DEBIAN_PACKAGE_DEPENDS "rocdecode-test")
endif()
string(REPLACE ";" ", " _DEBIAN_PACKAGE_DEPENDS "${_DEBIAN_PACKAGE_DEPENDS}")
set(CPACK_DEBIAN_PACKAGE_DEPENDS
"${_DEBIAN_PACKAGE_DEPENDS}"
Expand Down
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ add_subdirectory(rewrite-caller)
add_subdirectory(causal)
add_subdirectory(trace-time-window)
add_subdirectory(fork)
add_subdirectory(videodecode)
160 changes: 160 additions & 0 deletions examples/videodecode/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
cmake_minimum_required(VERSION 3.18.4 FATAL_ERROR)

project(rocprofiler-systems-videodecode-example LANGUAGES CXX)

# This example requires hip and rocdecode.
find_package(HIP QUIET)

if(NOT HIP_FOUND)
message(WARNING "hip is not found. Skip videodecode example.")
return()
endif()

message(STATUS "hip found: ${hip_DIR}")

# Set AMD Clang as default compiler
if(NOT DEFINED CMAKE_CXX_COMPILER)
set(CMAKE_CXX_COMPILER ${ROCmVersion_DIR}/bin/amdclang++)
endif()

set(CMAKE_CXX_STANDARD 17)

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../cmake)
list(APPEND CMAKE_PREFIX_PATH ${ROCmVersion_DIR}/hip ${ROCmVersion_DIR})
list(APPEND CMAKE_MODULE_PATH ${ROCmVersion_DIR}/share/rocdecode/cmake)

set(CMAKE_BUILD_TYPE "RelWithDebInfo")
string(REPLACE " " ";" _FLAGS "${CMAKE_CXX_FLAGS_DEBUG}")

if(ROCPROFSYS_DISABLE_EXAMPLES)
get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME)

if(${PROJECT_NAME} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES OR ${_DIR} IN_LIST
ROCPROFSYS_DISABLE_EXAMPLES)
return()
endif()
endif()

function(videodecode_message _MSG_TYPE)
if("${CMAKE_PROJECT_NAME}" STREQUAL "rocprofiler-systems"
AND "$ENV{ROCPROFSYS_CI}"
AND "${_MSG_TYPE}" MATCHES "WARNING")
set(_MSG_TYPE STATUS) # don't generate warnings during CI
endif()
if("${CMAKE_PROJECT_NAME}" STREQUAL "rocprofiler-systems")
rocprofiler_systems_message(${_MSG_TYPE} ${ARGN})
else()
message(${_MSG_TYPE} ${ARGN})
endif()
endfunction()

# Find RocDecode
find_package(rocDecode REQUIRED)
if(NOT ROCDECODE_FOUND)
videodecode_message(AUTHOR_WARNING "${PROJECT_NAME} skipped. Missing RocDecode...")
return()
endif()

find_path(
ROCDECODE_INCLUDE_DIR
NAMES rocdecode.h
PATHS ${ROCmVersion_DIR}/include/rocdecode)
find_library(
ROCDECODE_LIBRARY
NAMES rocdecode
HINTS ${ROCmVersion_DIR}/lib)

mark_as_advanced(ROCDECODE_INCLUDE_DIR ROCDECODE_LIBRARY)

if(ROCDECODE_INCLUDE_DIR AND ROCDECODE_LIBRARY)
set(ROCDECODE_FOUND TRUE)
else()
videodecode_message(AUTHOR_WARNING "${PROJECT_NAME} skipped. Missing RocDecode ...")
endif()

# Find FFMPEG
find_package(FFmpeg)
if(NOT FFMPEG_FOUND)
videodecode_message(AUTHOR_WARNING "${PROJECT_NAME} skipped. Missing FFMPEG...")
return()
endif()

message(STATUS "FFMPEG libraries: ${FFMPEG_LIBRARIES}")
message(STATUS "FFMPEG AVFORMAT version: ${_FFMPEG_AVFORMAT_VERSION}")
message(STATUS "FFMPEG AVCODEC version: ${_FFMPEG_AVCODEC_VERSION}")
message(STATUS "FFMPEG AVUTIL version: ${_FFMPEG_AVUTIL_VERSION}")

find_path(
FFMPEG_INCLUDE_DIR
NAMES libavcodec/avcodec.h libavformat/avformat.h libavutil/avutil.h
PATHS ${FFMPEG_INCLUDE_DIRS}
PATH_SUFFIXES ffmpeg libav)
find_library(
AVCODEC_LIBRARY
NAMES avcodec
PATHS ${FFMPEG_LIBRARY_DIRS})
find_library(
AVFORMAT_LIBRARY
NAMES avformat
PATHS ${FFMPEG_LIBRARY_DIRS})
find_library(
AVUTIL_LIBRARY
NAMES avutil
PATHS ${FFMPEG_LIBRARY_DIRS})

set(FFMPEG_LIBRARIES ${AVCODEC_LIBRARY} ${AVFORMAT_LIBRARY} ${AVUTIL_LIBRARY})
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIR})

mark_as_advanced(FFMPEG_INCLUDE_DIR AVCODEC_LIBRARY AVFORMAT_LIBRARY AVUTIL_LIBRARY)

if(FFMPEG_FOUND AND ROCDECODE_FOUND)
# HIP
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} hip::host)

# FFMPEG
include_directories(${FFMPEG_INCLUDE_DIR})
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} ${FFMPEG_LIBRARIES})

# filesystem: c++ compilers less than equal to 8.5 need explicit link with stdc++fs
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS_EQUAL "8.5")
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} stdc++fs)
endif()

# rocDecode
include_directories(${ROCDECODE_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..)
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} ${ROCDECODE_LIBRARY})

# Threads
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set(LINK_LIBRARY_LIST ${LINK_LIBRARY_LIST} Threads::Threads)

add_executable(videodecode videodecodebatch.cpp roc_video_dec.cpp)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++17")
target_link_libraries(videodecode ${LINK_LIBRARY_LIST})
target_compile_options(videodecode PRIVATE ${_FLAGS})

# FFMPEG multi-version support
if(_FFMPEG_AVCODEC_VERSION VERSION_LESS_EQUAL 58.134.100)
target_compile_definitions(videodecode PUBLIC USE_AVCODEC_GREATER_THAN_58_134=0)
else()
target_compile_definitions(videodecode PUBLIC USE_AVCODEC_GREATER_THAN_58_134=1)
endif()

if(ROCPROFSYS_INSTALL_EXAMPLES)
install(
TARGETS videodecode
DESTINATION bin
COMPONENT rocprofiler-systems-examples)
endif()
else()
message(
"-- ERROR!: videodecode excluded! please install all the dependencies and try again!"
)
if(NOT FFMPEG_FOUND)
message(FATAL_ERROR "-- ERROR!: FFMPEG Not Found! - please install FFMPEG!")
endif()
if(NOT ROCDECODE_FOUND)
message(FATAL_ERROR "-- ERROR!: rocDecode Not Found! - please install rocDecode!")
endif()
endif()
Loading

0 comments on commit 98084e9

Please sign in to comment.