forked from opencv/opencv
-
Notifications
You must be signed in to change notification settings - Fork 0
G-API: oneVPL (simplification) Add perf tests & Performance improve #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sivanov-work
wants to merge
8
commits into
vpl_source_final
Choose a base branch
from
vpl_source_final_perf
base: vpl_source_final
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
274a2d3
Add perf test
sivanov-work c0119af
Correct path to video
sivanov-work 00f7e68
Improve performance
sivanov-work 84b8c4b
Improve perf: add async pipeline
sivanov-work 79fe224
Improve perf: activate CachedPool & Fix decode error
sivanov-work 2adc372
Enable permanent CachedPool
sivanov-work 3903b00
Clear async engine code
sivanov-work 85da2d3
Move out Async engine to Legacy
sivanov-work File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
modules/gapi/perf/streaming/gapi_streaming_source_perf_tests.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // This file is part of OpenCV project. | ||
| // It is subject to the license terms in the LICENSE file found in the top-level directory | ||
| // of this distribution and at http://opencv.org/license.html. | ||
| // | ||
| // Copyright (C) 2021 Intel Corporation | ||
|
|
||
|
|
||
| #include "../perf_precomp.hpp" | ||
| #include "../../test/common/gapi_tests_common.hpp" | ||
| #include <opencv2/gapi/streaming/onevpl/onevpl_source.hpp> | ||
| #include <opencv2/gapi/streaming/cap.hpp> | ||
|
|
||
| namespace opencv_test | ||
| { | ||
| using namespace perf; | ||
|
|
||
| const std::string files[] = { | ||
| "highgui/video/big_buck_bunny.h265", | ||
| "highgui/video/big_buck_bunny.h264", | ||
| }; | ||
|
|
||
| const std::string codec[] = { | ||
| "MFX_CODEC_HEVC", | ||
| "MFX_CODEC_AVC" | ||
| }; | ||
|
|
||
| using source_t = std::string; | ||
| using codec_t = std::string; | ||
| using source_description_t = std::tuple<source_t, codec_t>; | ||
|
|
||
| class OneVPLSourcePerfTest : public TestPerfParams<source_description_t> {}; | ||
| class VideoCapSourcePerfTest : public TestPerfParams<source_t> {}; | ||
|
|
||
| PERF_TEST_P_(OneVPLSourcePerfTest, TestPerformance) | ||
| { | ||
| using namespace cv::gapi::wip; | ||
|
|
||
| const auto params = GetParam(); | ||
| source_t src = findDataFile(get<0>(params)); | ||
| codec_t type = get<1>(params); | ||
|
|
||
| std::vector<oneVPL_cfg_param> cfg_params { | ||
| oneVPL_cfg_param::create<std::string>("mfxImplDescription.Impl", "MFX_IMPL_TYPE_HARDWARE"), | ||
| oneVPL_cfg_param::create("mfxImplDescription.mfxDecoderDescription.decoder.CodecID", type), | ||
| }; | ||
|
|
||
| auto source_ptr = make_vpl_src(src, cfg_params); | ||
| Data out; | ||
| TEST_CYCLE() | ||
| { | ||
| source_ptr->pull(out); | ||
| } | ||
|
|
||
| SANITY_CHECK_NOTHING(); | ||
| } | ||
|
|
||
| PERF_TEST_P_(VideoCapSourcePerfTest, TestPerformance) | ||
| { | ||
| using namespace cv::gapi::wip; | ||
|
|
||
| source_t src = findDataFile(GetParam()); | ||
| auto source_ptr = make_src<GCaptureSource>(src); | ||
| Data out; | ||
| TEST_CYCLE() | ||
| { | ||
| source_ptr->pull(out); | ||
| } | ||
|
|
||
| SANITY_CHECK_NOTHING(); | ||
| } | ||
|
|
||
| INSTANTIATE_TEST_CASE_P(Streaming, OneVPLSourcePerfTest, | ||
| Values(source_description_t(files[0], codec[0]), | ||
| source_description_t(files[1], codec[1]))); | ||
|
|
||
| INSTANTIATE_TEST_CASE_P(Streaming, VideoCapSourcePerfTest, | ||
| Values(files[0], | ||
| files[1])); | ||
| } // namespace opencv_test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,7 +107,7 @@ VPLCPUAccelerationPolicy::create_surface_pool(size_t pool_size, size_t surface_s | |
|
|
||
| // remember pool by key | ||
| GAPI_LOG_INFO(nullptr, "New pool allocated, key: " << preallocated_pool_memory_ptr << | ||
| ", surface count: " << pool.size() << | ||
| ", surface count: " << pool.total_size() << | ||
| ", surface size bytes: " << surface_size_bytes); | ||
| try { | ||
| if (!pool_table.emplace(preallocated_pool_memory_ptr, std::move(pool)).second) { | ||
|
|
@@ -132,27 +132,7 @@ VPLCPUAccelerationPolicy::surface_weak_ptr_t VPLCPUAccelerationPolicy::get_free_ | |
| } | ||
|
|
||
| pool_t& requested_pool = pool_it->second; | ||
| #ifdef TEST_PERF | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, this macro is completely gone now? |
||
| return requested_pool.find_free(); | ||
| #else // TEST_PERF | ||
| auto it = | ||
| std::find_if(requested_pool.begin(), requested_pool.end(), | ||
| [](const surface_ptr_t& val) { | ||
| GAPI_DbgAssert(val && "Pool contains empty surface"); | ||
| return !val->get_locks_count(); | ||
| }); | ||
|
|
||
| // Limitation realloc pool might be a future extension | ||
| if (it == requested_pool.end()) { | ||
| std::stringstream ss; | ||
| ss << "cannot get free surface from pool, key: " << key << ", size: " << requested_pool.size(); | ||
| const std::string& str = ss.str(); | ||
| GAPI_LOG_WARNING(nullptr, str); | ||
| throw std::runtime_error(std::string(__FUNCTION__) + " - " + str); | ||
| } | ||
|
|
||
| return *it; | ||
| #endif // TEST_PERF | ||
| } | ||
|
|
||
| size_t VPLCPUAccelerationPolicy::get_free_surface_count(pool_key_t key) const { | ||
|
|
@@ -162,18 +142,8 @@ size_t VPLCPUAccelerationPolicy::get_free_surface_count(pool_key_t key) const { | |
| ", table size: " << pool_table.size()); | ||
| return 0; | ||
| } | ||
| #ifdef TEST_PERF | ||
| return 0; | ||
| #else // TEST_PERF | ||
| const pool_t& requested_pool = pool_it->second; | ||
| size_t free_surf_count = | ||
| std::count_if(requested_pool.begin(), requested_pool.end(), | ||
| [](const surface_ptr_t& val) { | ||
| GAPI_Assert(val && "Pool contains empty surface"); | ||
| return !val->get_locks_count(); | ||
| }); | ||
| return free_surf_count; | ||
| #endif // TEST_PERF | ||
| return requested_pool.available_size(); | ||
| } | ||
|
|
||
| size_t VPLCPUAccelerationPolicy::get_surface_count(pool_key_t key) const { | ||
|
|
@@ -183,11 +153,8 @@ size_t VPLCPUAccelerationPolicy::get_surface_count(pool_key_t key) const { | |
| ", table size: " << pool_table.size()); | ||
| return 0; | ||
| } | ||
| #ifdef TEST_PERF | ||
| return 0; | ||
| #else // TEST_PERF | ||
| return pool_it->second.size(); | ||
| #endif // TEST_PERF | ||
|
|
||
| return pool_it->second.total_size(); | ||
| } | ||
|
|
||
| cv::MediaFrame::AdapterPtr VPLCPUAccelerationPolicy::create_frame_adapter(pool_key_t key, | ||
|
|
@@ -202,28 +169,7 @@ cv::MediaFrame::AdapterPtr VPLCPUAccelerationPolicy::create_frame_adapter(pool_k | |
| } | ||
|
|
||
| pool_t& requested_pool = pool_it->second; | ||
| #ifdef TEST_PERF | ||
| return cv::MediaFrame::AdapterPtr{new VPLMediaFrameCPUAdapter(requested_pool.find_by_handle(surface))}; | ||
| #else // TEST_PERF | ||
| auto it = | ||
| std::find_if(requested_pool.begin(), requested_pool.end(), | ||
| [surface](const surface_ptr_t& val) { | ||
| GAPI_DbgAssert(val && "Pool contains empty surface"); | ||
| return val->get_handle() == surface; | ||
| }); | ||
|
|
||
| // Limitation realloc pool might be a future extension | ||
| if (it == requested_pool.end()) { | ||
| std::stringstream ss; | ||
| ss << "cannot get requested surface from pool, key: " << key << ", surf: " | ||
| << surface << ", pool size: " << requested_pool.size(); | ||
| const std::string& str = ss.str(); | ||
| GAPI_LOG_WARNING(nullptr, str); | ||
| throw std::runtime_error(std::string(__FUNCTION__) + " - " + str); | ||
| } | ||
|
|
||
| return cv::MediaFrame::AdapterPtr{new VPLMediaFrameCPUAdapter(*it)}; | ||
| #endif // TEST_PERF | ||
| } | ||
| } // namespace wip | ||
| } // namespace gapi | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did these changes get here?