Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/rocprofiler-sdk-code_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down
107 changes: 93 additions & 14 deletions projects/rocprofiler-sdk/tests/bin/rocdecode/rocdecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,76 @@ THE SOFTWARE.
#include <cstring>
#include <iostream>

// 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;
Expand Down Expand Up @@ -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;
}
10 changes: 10 additions & 0 deletions projects/rocprofiler-sdk/tests/rocdecode/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 2 additions & 4 deletions projects/rocprofiler-sdk/tests/rocjpeg/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down
Loading