diff --git a/.github/workflows/rocprofiler-sdk-code_coverage.yml b/.github/workflows/rocprofiler-sdk-code_coverage.yml index 7956075747..35451648c0 100644 --- a/.github/workflows/rocprofiler-sdk-code_coverage.yml +++ b/.github/workflows/rocprofiler-sdk-code_coverage.yml @@ -107,6 +107,7 @@ jobs: git config --global --add safe.directory '*' apt-get update apt-get install -y build-essential cmake python3-pip gcovr wkhtmltopdf xvfb xfonts-base xfonts-75dpi xfonts-100dpi xfonts-utils xfonts-encodings libfontconfig libdw-dev libsqlite3-dev + apt-get install -y rccl-dev rccl-unittests rocjpeg-dev rocjpeg-test rocdecode-dev rocdecode-test python3 -m pip install -U --user -r requirements.txt rm -rf /opt/rocm/lib/*rocprofiler-sdk* /opt/rocm/lib/cmake/*rocprofiler-sdk* /opt/rocm/share/*rocprofiler-sdk* /opt/rocm/libexec/*rocprofiler-sdk* diff --git a/projects/rocprofiler-sdk/tests/bin/rocdecode/rocdecode.cpp b/projects/rocprofiler-sdk/tests/bin/rocdecode/rocdecode.cpp index 8ef8fa1ffb..99d6318e92 100644 --- a/projects/rocprofiler-sdk/tests/bin/rocdecode/rocdecode.cpp +++ b/projects/rocprofiler-sdk/tests/bin/rocdecode/rocdecode.cpp @@ -26,28 +26,76 @@ THE SOFTWARE. #include #include +// Call rocDecode API with nullptrs to test rocDecode trace +// Eventually should replace with functional calls, but this requires +// finding and linking several FFmpeg and AV.. libraries (AVUTIL, AVCODEC, AVFORMAT) +// Additionally, some rocdecode/share files like ffmpeg_video_dec.cpp would need +// to be updated to resolve compiler warnings to compile with rocprofiler-sdk int -main(int argc, char** argv) +test_rocdecode_decoder() { - // Get input file - std::string input_file_path{}; - for(int i = 1; i < argc; i++) + rocDecStatus rocdecode_status = rocDecCreateDecoder(nullptr, nullptr); + if(rocdecode_status != ROCDEC_INVALID_PARAMETER) { - if(!strcmp(argv[i], "-i")) - { - if(++i == argc) - { - std::cerr << "Provide path to input file" << std::endl; - } - input_file_path = argv[i]; - continue; - } + std::cerr << "Expected ROCDEC_INVALID_PARAMETER\n"; + return 1; } + if(rocDecGetErrorName(rocdecode_status) == nullptr) + { + std::cerr << "Expected error name to not be null\n"; + return 1; + } + if(rocDecCreateVideoParser(nullptr, nullptr) != ROCDEC_INVALID_PARAMETER) + { + std::cerr << "Expected ROCDEC_INVALID_PARAMETER\n"; + return 1; + } + if(rocDecParseVideoData(nullptr, nullptr) != ROCDEC_INVALID_PARAMETER) + { + std::cerr << "Expected ROCDEC_INVALID_PARAMETER\n"; + return 1; + } + if(rocDecDestroyVideoParser(nullptr) != ROCDEC_INVALID_PARAMETER) + { + std::cerr << "Expected ROCDEC_INVALID_PARAMETER\n"; + return 1; + } + if(rocDecDestroyDecoder(nullptr) != ROCDEC_INVALID_PARAMETER) + { + std::cerr << "Expected ROCDEC_INVALID_PARAMETER\n"; + return 1; + } + if(rocDecGetDecoderCaps(nullptr) != ROCDEC_INVALID_PARAMETER) + { + std::cerr << "Expected ROCDEC_INVALID_PARAMETER\n"; + return 1; + } + if(rocDecGetDecodeStatus(nullptr, 0, nullptr) != ROCDEC_INVALID_PARAMETER) + { + std::cerr << "Expected ROCDEC_INVALID_PARAMETER\n"; + return 1; + } + if(rocDecReconfigureDecoder(nullptr, nullptr) != ROCDEC_INVALID_PARAMETER) + { + std::cerr << "Expected ROCDEC_INVALID_PARAMETER\n"; + return 1; + } + if(rocDecGetVideoFrame(nullptr, 0, nullptr, nullptr, nullptr) != ROCDEC_INVALID_PARAMETER) + { + std::cerr << "Expected ROCDEC_INVALID_PARAMETER\n"; + return 1; + } + return 0; +} + +int +test_rocdecode_bitstream_reader(const std::string& input_file) +{ // Set up bitstreamreader RocdecBitstreamReader bs_reader = nullptr; rocDecVideoCodec rocdec_codec_id{}; int bit_depth{}; - if(rocDecCreateBitstreamReader(&bs_reader, input_file_path.c_str()) != ROCDEC_SUCCESS) + if(rocDecCreateBitstreamReader(&bs_reader, input_file.c_str()) != ROCDEC_SUCCESS) { std::cerr << "Failed to create the bitstream reader." << std::endl; return 1; @@ -131,4 +179,35 @@ main(int argc, char** argv) { rocDecDestroyBitstreamReader(bs_reader); } + return 0; +} + +int +main(int argc, char** argv) +{ + // Get input file + std::string input_file_path{}; + for(int i = 1; i < argc; i++) + { + if(!strcmp(argv[i], "-i")) + { + if(++i == argc) + { + std::cerr << "Provide path to input file" << std::endl; + } + input_file_path = argv[i]; + continue; + } + } + if(test_rocdecode_bitstream_reader(input_file_path) != 0) + { + std::cerr << "rocDecode bitsream reader test failed\n"; + return 1; + } + if(test_rocdecode_decoder() != 0) + { + std::cerr << "rocDecode decoder test failed\n"; + return 1; + } + return 0; } diff --git a/projects/rocprofiler-sdk/tests/rocdecode/validate.py b/projects/rocprofiler-sdk/tests/rocdecode/validate.py index 04ffbaa87f..c65a23840b 100644 --- a/projects/rocprofiler-sdk/tests/rocdecode/validate.py +++ b/projects/rocprofiler-sdk/tests/rocdecode/validate.py @@ -177,6 +177,16 @@ def test_rocdecode_traces(input_data): "rocDecGetVideoFrame", "rocDecGetDecodeStatus", "rocDecDestroyBitstreamReader", + "rocDecCreateDecoder", + "rocDecGetErrorName", + "rocDecCreateVideoParser", + "rocDecParseVideoData", + "rocDecDestroyVideoParser", + "rocDecDestroyDecoder", + "rocDecGetDecoderCaps", + "rocDecGetDecodeStatus", + "rocDecReconfigureDecoder", + "rocDecGetVideoFrame", ]: assert call in api_calls diff --git a/projects/rocprofiler-sdk/tests/rocjpeg/validate.py b/projects/rocprofiler-sdk/tests/rocjpeg/validate.py index dbf6a3bd65..b06e465a89 100644 --- a/projects/rocprofiler-sdk/tests/rocjpeg/validate.py +++ b/projects/rocprofiler-sdk/tests/rocjpeg/validate.py @@ -53,12 +53,10 @@ def test_data_structure(input_data): node_exists("buffer_records", sdk_data) node_exists("names", sdk_data["callback_records"]) - # Uncomment once mainline rocprofiler register supports rocJPEG - # node_exists("rocjpeg_api_traces", sdk_data["callback_records"]) + node_exists("rocjpeg_api_traces", sdk_data["callback_records"]) node_exists("names", sdk_data["buffer_records"]) - # Uncomment once mainline rocprofiler register supports rocJPEG - # node_exists("rocjpeg_api_traces", sdk_data["buffer_records"]) + node_exists("rocjpeg_api_traces", sdk_data["buffer_records"]) def test_size_entries(input_data): diff --git a/projects/rocprofiler-sdk/tests/rocprofv3/rocdecode-trace/validate.py b/projects/rocprofiler-sdk/tests/rocprofv3/rocdecode-trace/validate.py index 76b94b4b26..30198f320e 100755 --- a/projects/rocprofiler-sdk/tests/rocprofv3/rocdecode-trace/validate.py +++ b/projects/rocprofiler-sdk/tests/rocprofv3/rocdecode-trace/validate.py @@ -123,6 +123,16 @@ def test_csv_data(csv_data): "rocDecGetVideoFrame", "rocDecGetDecodeStatus", "rocDecDestroyBitstreamReader", + "rocDecCreateDecoder", + "rocDecGetErrorName", + "rocDecCreateVideoParser", + "rocDecParseVideoData", + "rocDecDestroyVideoParser", + "rocDecDestroyDecoder", + "rocDecGetDecoderCaps", + "rocDecGetDecodeStatus", + "rocDecReconfigureDecoder", + "rocDecGetVideoFrame", ]: assert call in api_calls diff --git a/projects/rocprofiler-sdk/tests/rocprofv3/rocjpeg-trace/CMakeLists.txt b/projects/rocprofiler-sdk/tests/rocprofv3/rocjpeg-trace/CMakeLists.txt index f81a4f8a22..fbc555354d 100644 --- a/projects/rocprofiler-sdk/tests/rocprofv3/rocjpeg-trace/CMakeLists.txt +++ b/projects/rocprofiler-sdk/tests/rocprofv3/rocjpeg-trace/CMakeLists.txt @@ -77,10 +77,10 @@ add_test( NAME rocprofv3-test-rocjpeg-tracing-validate COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py --json-input - ${CMAKE_CURRENT_BINARY_DIR}/rocjpeg-trace/out_results.json --otf2-input - ${CMAKE_CURRENT_BINARY_DIR}/rocjpeg-trace/out_results.otf2 --pftrace-input - ${CMAKE_CURRENT_BINARY_DIR}/rocjpeg-trace/out_results.pftrace --csv-input - ${CMAKE_CURRENT_BINARY_DIR}/rocjpeg-trace/out_rocjpeg_api_trace.csv) + ${CMAKE_CURRENT_BINARY_DIR}/rocjpeg-demo-trace/out_results.json --otf2-input + ${CMAKE_CURRENT_BINARY_DIR}/rocjpeg-demo-trace/out_results.otf2 --pftrace-input + ${CMAKE_CURRENT_BINARY_DIR}/rocjpeg-demo-trace/out_results.pftrace --csv-input + ${CMAKE_CURRENT_BINARY_DIR}/rocjpeg-demo-trace/out_rocjpeg_api_trace.csv) set_tests_properties( rocprofv3-test-rocjpeg-tracing-validate diff --git a/projects/rocprofiler-sdk/tests/rocprofv3/rocjpeg-trace/validate.py b/projects/rocprofiler-sdk/tests/rocprofv3/rocjpeg-trace/validate.py index 16659056a3..b6fcdea4da 100755 --- a/projects/rocprofiler-sdk/tests/rocprofv3/rocjpeg-trace/validate.py +++ b/projects/rocprofiler-sdk/tests/rocprofv3/rocjpeg-trace/validate.py @@ -90,7 +90,6 @@ def test_csv_data(csv_data): # If rocJPEG tracing is not supported, end early if len(csv_data) <= 2: return pytest.skip("rocjpeg tracing unavailable") - assert len(csv_data) > 0, "Expected non-empty csv data" api_calls = [] @@ -140,10 +139,7 @@ def test_perfetto_data(pftrace_data, json_data): import rocprofiler_sdk.tests.rocprofv3 as rocprofv3 # If rocJPEG tracing is not supported, end early - if ( - pftrace_data == None - or len(json_data["rocprofiler-sdk-tool"]["buffer_records"]["rocjpeg_api"]) == 0 - ): + if len(json_data["rocprofiler-sdk-tool"]["buffer_records"]["rocjpeg_api"]) == 0: return pytest.skip("rocjpeg tracing unavailable") rocprofv3.test_perfetto_data( @@ -157,10 +153,7 @@ def test_otf2_data(otf2_data, json_data): import rocprofiler_sdk.tests.rocprofv3 as rocprofv3 # If rocJPEG tracing is not supported, end early - if ( - otf2_data == None - or len(json_data["rocprofiler-sdk-tool"]["buffer_records"]["rocjpeg_api"]) == 0 - ): + if len(json_data["rocprofiler-sdk-tool"]["buffer_records"]["rocjpeg_api"]) == 0: return pytest.skip("rocjpeg tracing unavailable") rocprofv3.test_otf2_data(