From 021e32bc218bf7b8a00dd0893bdc6fc0ae472133 Mon Sep 17 00:00:00 2001 From: Kiriti Gowda Date: Wed, 2 Oct 2024 14:35:56 -0700 Subject: [PATCH] Find rocDecode - Support added (#428) * Find rocDecode - Support added * Find rocDecode - Updates * Find rocDecode - Version fix * Find rocDecode - Version Var * Minor cleanup * Test - Find package updates * CTest - Upgrades * CTest - Enhancements --------- Co-authored-by: Aryan Salmanpour [ROCm/rocdecode commit: befc6f6562e325a5b02e529e491d9a3080fa434d] --- projects/rocdecode/cmake/FindrocDecode.cmake | 77 +++++++++++++++++++ .../samples/videoDecode/CMakeLists.txt | 8 +- .../samples/videoDecodeBatch/CMakeLists.txt | 9 +-- .../samples/videoDecodeMem/CMakeLists.txt | 8 +- .../videoDecodeMultiFiles/CMakeLists.txt | 8 +- .../samples/videoDecodePerf/CMakeLists.txt | 8 +- .../samples/videoDecodeRGB/CMakeLists.txt | 8 +- .../samples/videoToSequence/CMakeLists.txt | 8 +- projects/rocdecode/test/CMakeLists.txt | 34 ++++---- 9 files changed, 104 insertions(+), 64 deletions(-) create mode 100644 projects/rocdecode/cmake/FindrocDecode.cmake diff --git a/projects/rocdecode/cmake/FindrocDecode.cmake b/projects/rocdecode/cmake/FindrocDecode.cmake new file mode 100644 index 0000000000..dbd29e1780 --- /dev/null +++ b/projects/rocdecode/cmake/FindrocDecode.cmake @@ -0,0 +1,77 @@ +################################################################################ +# Copyright (c) 2023 - 2024 Advanced Micro Devices, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +################################################################################ + +# ROCM Path +if(ROCM_PATH) + message("-- ${White}FindrocDecode: ROCM_PATH Set -- ${ROCM_PATH}${ColourReset}") +else() + set(ROCM_PATH /opt/rocm CACHE PATH "Default ROCm installation path") +endif() + +# find rocDecode - library and headers +find_path(ROCDECODE_INCLUDE_DIR NAMES rocdecode.h PATHS ${ROCM_PATH}/include/rocdecode) +find_library(ROCDECODE_LIBRARY NAMES rocdecode HINTS ${ROCM_PATH}/lib) +mark_as_advanced(ROCDECODE_INCLUDE_DIR) +mark_as_advanced(ROCDECODE_LIBRARY) + +if(ROCDECODE_INCLUDE_DIR AND ROCDECODE_LIBRARY) + message("-- ${White}FindrocDecode -- Using rocDecode: \n\tIncludes:${ROCDECODE_INCLUDE_DIR}\n\tLib:${ROCDECODE_LIBRARY}${ColourReset}") + set(ROCDECODE_FOUND TRUE) +else() + if(rocDecode_FIND_REQUIRED) + message(FATAL_ERROR "FindrocDecode -- Failed to find rocDecode Library") + endif() + message( "-- ${Yellow}NOTE: FindrocDecode failed to find rocDecode -- INSTALL rocDecode${ColourReset}" ) +endif() + +if(ROCDECODE_FOUND) + # Find rocDecode Version + file(READ "${ROCDECODE_INCLUDE_DIR}/rocdecode_version.h" ROCDECODE_VERSION_FILE) + string(REGEX MATCH "ROCDECODE_MAJOR_VERSION ([0-9]*)" _ ${ROCDECODE_VERSION_FILE}) + set(ROCDECODE_VER_MAJOR ${CMAKE_MATCH_1}) + string(REGEX MATCH "ROCDECODE_MINOR_VERSION ([0-9]*)" _ ${ROCDECODE_VERSION_FILE}) + set(ROCDECODE_VER_MINOR ${CMAKE_MATCH_1}) + string(REGEX MATCH "ROCDECODE_MICRO_VERSION ([0-9]*)" _ ${ROCDECODE_VERSION_FILE}) + set(ROCDECODE_VER_MICRO ${CMAKE_MATCH_1}) + message("-- ${White}Found rocDecode Version: ${ROCDECODE_VER_MAJOR}.${ROCDECODE_VER_MINOR}.${ROCDECODE_VER_MICRO}${ColourReset}") + mark_as_advanced(ROCDECODE_VER_MAJOR) + mark_as_advanced(ROCDECODE_VER_MINOR) + mark_as_advanced(ROCDECODE_VER_MICRO) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + rocDecode + FOUND_VAR + ROCDECODE_FOUND + REQUIRED_VARS + ROCDECODE_INCLUDE_DIR + ROCDECODE_LIBRARY +) + +set(ROCDECODE_FOUND ${ROCDECODE_FOUND} CACHE INTERNAL "") +set(ROCDECODE_INCLUDE_DIR ${ROCDECODE_INCLUDE_DIR} CACHE INTERNAL "") +set(ROCDECODE_LIBRARY ${ROCDECODE_LIBRARY} CACHE INTERNAL "") +set(ROCDECODE_VER_MAJOR ${ROCDECODE_VER_MAJOR} CACHE INTERNAL "") +set(ROCDECODE_VER_MINOR ${ROCDECODE_VER_MINOR} CACHE INTERNAL "") +set(ROCDECODE_VER_MICRO ${ROCDECODE_VER_MICRO} CACHE INTERNAL "") diff --git a/projects/rocdecode/samples/videoDecode/CMakeLists.txt b/projects/rocdecode/samples/videoDecode/CMakeLists.txt index 668472e8be..0f40f91044 100644 --- a/projects/rocdecode/samples/videoDecode/CMakeLists.txt +++ b/projects/rocdecode/samples/videoDecode/CMakeLists.txt @@ -58,13 +58,7 @@ endif() find_package(HIP QUIET) find_package(FFmpeg QUIET) -# find rocDecode -find_library(ROCDECODE_LIBRARY NAMES rocdecode HINTS ${ROCM_PATH}/lib) -find_path(ROCDECODE_INCLUDE_DIR NAMES rocdecode.h PATHS /opt/rocm/include/rocdecode ${ROCM_PATH}/include/rocdecode) -if(ROCDECODE_LIBRARY AND ROCDECODE_INCLUDE_DIR) - set(ROCDECODE_FOUND TRUE) - message("-- ${White}${PROJECT_NAME}: Using rocDecode -- \n\tLibraries:${ROCDECODE_LIBRARY} \n\tIncludes:${ROCDECODE_INCLUDE_DIR}${ColourReset}") -endif() +find_package(rocDecode QUIET) if(HIP_FOUND AND FFMPEG_FOUND AND ROCDECODE_FOUND) # HIP diff --git a/projects/rocdecode/samples/videoDecodeBatch/CMakeLists.txt b/projects/rocdecode/samples/videoDecodeBatch/CMakeLists.txt index 00b340b3de..322112a52f 100644 --- a/projects/rocdecode/samples/videoDecodeBatch/CMakeLists.txt +++ b/projects/rocdecode/samples/videoDecodeBatch/CMakeLists.txt @@ -58,14 +58,7 @@ endif() find_package(HIP QUIET) find_package(FFmpeg QUIET) -# find rocDecode -find_library(ROCDECODE_LIBRARY NAMES rocdecode HINTS ${ROCM_PATH}/lib) -find_path(ROCDECODE_INCLUDE_DIR NAMES rocdecode.h PATHS /opt/rocm/include/rocdecode ${ROCM_PATH}/include/rocdecode) - -if(ROCDECODE_LIBRARY AND ROCDECODE_INCLUDE_DIR) - set(ROCDECODE_FOUND TRUE) - message("-- ${White}${PROJECT_NAME}: Using rocDecode -- \n\tLibraries:${ROCDECODE_LIBRARY} \n\tIncludes:${ROCDECODE_INCLUDE_DIR}${ColourReset}") -endif() +find_package(rocDecode QUIET) if(HIP_FOUND AND FFMPEG_FOUND AND ROCDECODE_FOUND) # HIP diff --git a/projects/rocdecode/samples/videoDecodeMem/CMakeLists.txt b/projects/rocdecode/samples/videoDecodeMem/CMakeLists.txt index 06ebaa29e2..bf576f5205 100644 --- a/projects/rocdecode/samples/videoDecodeMem/CMakeLists.txt +++ b/projects/rocdecode/samples/videoDecodeMem/CMakeLists.txt @@ -58,13 +58,7 @@ endif() find_package(HIP QUIET) find_package(FFmpeg QUIET) -# find rocDecode -find_library(ROCDECODE_LIBRARY NAMES rocdecode HINTS ${ROCM_PATH}/lib) -find_path(ROCDECODE_INCLUDE_DIR NAMES rocdecode.h PATHS /opt/rocm/include/rocdecode ${ROCM_PATH}/include/rocdecode) -if(ROCDECODE_LIBRARY AND ROCDECODE_INCLUDE_DIR) - set(ROCDECODE_FOUND TRUE) - message("-- ${White}${PROJECT_NAME}: Using rocDecode -- \n\tLibraries:${ROCDECODE_LIBRARY} \n\tIncludes:${ROCDECODE_INCLUDE_DIR}${ColourReset}") -endif() +find_package(rocDecode QUIET) if(HIP_FOUND AND FFMPEG_FOUND AND ROCDECODE_FOUND) # HIP diff --git a/projects/rocdecode/samples/videoDecodeMultiFiles/CMakeLists.txt b/projects/rocdecode/samples/videoDecodeMultiFiles/CMakeLists.txt index 488c7ed5c3..d24770cfb1 100644 --- a/projects/rocdecode/samples/videoDecodeMultiFiles/CMakeLists.txt +++ b/projects/rocdecode/samples/videoDecodeMultiFiles/CMakeLists.txt @@ -58,13 +58,7 @@ endif() find_package(HIP QUIET) find_package(FFmpeg QUIET) -# find rocDecode -find_library(ROCDECODE_LIBRARY NAMES rocdecode HINTS ${ROCM_PATH}/lib) -find_path(ROCDECODE_INCLUDE_DIR NAMES rocdecode.h PATHS /opt/rocm/include/rocdecode ${ROCM_PATH}/include/rocdecode) -if(ROCDECODE_LIBRARY AND ROCDECODE_INCLUDE_DIR) - set(ROCDECODE_FOUND TRUE) - message("-- ${White}${PROJECT_NAME}: Using rocDecode -- \n\tLibraries:${ROCDECODE_LIBRARY} \n\tIncludes:${ROCDECODE_INCLUDE_DIR}${ColourReset}") -endif() +find_package(rocDecode QUIET) if(HIP_FOUND AND FFMPEG_FOUND AND ROCDECODE_FOUND) # HIP diff --git a/projects/rocdecode/samples/videoDecodePerf/CMakeLists.txt b/projects/rocdecode/samples/videoDecodePerf/CMakeLists.txt index 4e66dd4e84..c5cf40f3f7 100644 --- a/projects/rocdecode/samples/videoDecodePerf/CMakeLists.txt +++ b/projects/rocdecode/samples/videoDecodePerf/CMakeLists.txt @@ -58,13 +58,7 @@ endif() find_package(HIP QUIET) find_package(FFmpeg QUIET) -# find rocDecode -find_library(ROCDECODE_LIBRARY NAMES rocdecode HINTS ${ROCM_PATH}/lib) -find_path(ROCDECODE_INCLUDE_DIR NAMES rocdecode.h PATHS /opt/rocm/include/rocdecode ${ROCM_PATH}/include/rocdecode) -if(ROCDECODE_LIBRARY AND ROCDECODE_INCLUDE_DIR) - set(ROCDECODE_FOUND TRUE) - message("-- ${White}${PROJECT_NAME}: Using rocDecode -- \n\tLibraries:${ROCDECODE_LIBRARY} \n\tIncludes:${ROCDECODE_INCLUDE_DIR}${ColourReset}") -endif() +find_package(rocDecode QUIET) if(HIP_FOUND AND FFMPEG_FOUND AND ROCDECODE_FOUND AND Threads_FOUND) # HIP diff --git a/projects/rocdecode/samples/videoDecodeRGB/CMakeLists.txt b/projects/rocdecode/samples/videoDecodeRGB/CMakeLists.txt index 232194d696..6610382a37 100644 --- a/projects/rocdecode/samples/videoDecodeRGB/CMakeLists.txt +++ b/projects/rocdecode/samples/videoDecodeRGB/CMakeLists.txt @@ -71,13 +71,7 @@ message("-- ${White}${PROJECT_NAME} -- AMDGPU_TARGETS: ${AMDGPU_TARGETS}${Colour find_package(HIP QUIET) find_package(FFmpeg QUIET) -# find rocDecode -find_library(ROCDECODE_LIBRARY NAMES rocdecode HINTS ${ROCM_PATH}/lib) -find_path(ROCDECODE_INCLUDE_DIR NAMES rocdecode.h PATHS /opt/rocm/include/rocdecode ${ROCM_PATH}/include/rocdecode) -if(ROCDECODE_LIBRARY AND ROCDECODE_INCLUDE_DIR) - set(ROCDECODE_FOUND TRUE) - message("-- ${White}${PROJECT_NAME}: Using rocDecode -- \n\tLibraries:${ROCDECODE_LIBRARY} \n\tIncludes:${ROCDECODE_INCLUDE_DIR}${ColourReset}") -endif() +find_package(rocDecode QUIET) if(HIP_FOUND AND FFMPEG_FOUND AND ROCDECODE_FOUND) # HIP diff --git a/projects/rocdecode/samples/videoToSequence/CMakeLists.txt b/projects/rocdecode/samples/videoToSequence/CMakeLists.txt index 56b42e1d19..09964f1e1d 100644 --- a/projects/rocdecode/samples/videoToSequence/CMakeLists.txt +++ b/projects/rocdecode/samples/videoToSequence/CMakeLists.txt @@ -58,13 +58,7 @@ endif() find_package(HIP QUIET) find_package(FFmpeg QUIET) -# find rocDecode -find_library(ROCDECODE_LIBRARY NAMES rocdecode HINTS ${ROCM_PATH}/lib) -find_path(ROCDECODE_INCLUDE_DIR NAMES rocdecode.h PATHS /opt/rocm/include/rocdecode ${ROCM_PATH}/include/rocdecode) -if(ROCDECODE_LIBRARY AND ROCDECODE_INCLUDE_DIR) - set(ROCDECODE_FOUND TRUE) - message("-- ${White}${PROJECT_NAME}: Using rocDecode -- \n\tLibraries:${ROCDECODE_LIBRARY} \n\tIncludes:${ROCDECODE_INCLUDE_DIR}${ColourReset}") -endif() +find_package(rocDecode QUIET) if(HIP_FOUND AND FFMPEG_FOUND AND ROCDECODE_FOUND) # HIP diff --git a/projects/rocdecode/test/CMakeLists.txt b/projects/rocdecode/test/CMakeLists.txt index 561afde6d1..88325e1f5a 100644 --- a/projects/rocdecode/test/CMakeLists.txt +++ b/projects/rocdecode/test/CMakeLists.txt @@ -28,6 +28,15 @@ project(rocdecode-test) enable_testing() include(CTest) +if(NOT DEFINED ENHANCED_MESSAGE) + string(ASCII 27 Esc) + set(ColourReset "${Esc}[m") + set(Red "${Esc}[31m") + set(Green "${Esc}[32m") + set(Yellow "${Esc}[33m") + set(White "${Esc}[37m") +endif() + # ROCM Path if(DEFINED ENV{ROCM_PATH}) set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "${White}${PROJECT_NAME}: Default ROCm installation path${ColourReset}") @@ -37,20 +46,17 @@ else() set(ROCM_PATH /opt/rocm CACHE PATH "${White}${PROJECT_NAME}: Default ROCm installation path${ColourReset}") endif() -# find rocDecode -find_library(ROCDECODE_LIBRARY NAMES rocdecode HINTS ${ROCM_PATH}/lib) -find_path(ROCDECODE_INCLUDE_DIR NAMES rocdecode.h PATHS /opt/rocm/include/rocdecode ${ROCM_PATH}/include/rocdecode) +# add find modules +list(APPEND CMAKE_MODULE_PATH ${ROCM_PATH}/share/rocdecode/cmake) -if(ROCDECODE_LIBRARY AND ROCDECODE_INCLUDE_DIR) - set(ROCDECODE_FOUND TRUE) - message("-- ${White}Using rocDecode -- \n\tLibraries:${ROCDECODE_LIBRARY} \n\tIncludes:${ROCDECODE_INCLUDE_DIR}${ColourReset}") -endif() +# find rocDecode +find_package(rocDecode QUIET) if(NOT ROCDECODE_FOUND) message("-- ${Yellow}${PROJECT_NAME} requires rocDecode. Install rocDecode before running CTests") endif() -# videoDecode +# 1 - videoDecode add_test( NAME video_decode-H265 @@ -63,7 +69,7 @@ add_test( -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H265.mp4 ) -# videoDecodeMem +# 2 - videoDecodeMem add_test( NAME video_decodeMem-H265 @@ -76,7 +82,7 @@ add_test( -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H265.mp4 ) -# videoDecodePerf +# 3 - videoDecodePerf add_test( NAME video_decodePerf-H265 @@ -89,7 +95,7 @@ add_test( -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H265.mp4 ) -# videoDecodeRGB +# 4 - videoDecodeRGB add_test( NAME video_decodeRGB-H265 @@ -102,7 +108,7 @@ add_test( -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H265.mp4 -of rgb ) -# videoDecode H264 +# 5 - videoDecode H264 add_test( NAME video_decode-H264 @@ -115,7 +121,7 @@ add_test( -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H264.mp4 ) -# videoDecodeBatch +# 6 - videoDecodeBatch add_test( NAME video_decodeBatch @@ -128,7 +134,7 @@ add_test( -i ${ROCM_PATH}/share/rocdecode/video/ -t 2 ) -# videoDecode AV1 +# 7 - videoDecode AV1 add_test( NAME video_decode-AV1