Add session overhead functions & modify perf app (#366)
* add session overhead funcitons & modify perf app * remove class:: for function calls * add session overhead funcitons & modify perf app * remove class:: for function calls * review comments * fix comments * duration to double * update perf sample for thread_id for overhead * remove debug statements * revoew comments * return value chnage to double * remove session ID functions * check session id validity
This commit is contained in:
gecommit door
GitHub
bovenliggende
ac272886b1
commit
48b56de77a
@@ -52,9 +52,9 @@ void DecProc(RocVideoDecoder *p_dec, VideoDemuxer *demuxer, int *pn_frame, doubl
|
||||
|
||||
auto end_time = std::chrono::high_resolution_clock::now();
|
||||
auto time_per_decode = std::chrono::duration<double, std::milli>(end_time - start_time).count();
|
||||
|
||||
auto session_overhead = p_dec->GetDecoderSessionOverHead(std::this_thread::get_id());
|
||||
// Calculate average decoding time
|
||||
total_dec_time = time_per_decode;
|
||||
total_dec_time = time_per_decode - session_overhead;
|
||||
double average_decoding_time = total_dec_time / n_frame;
|
||||
double n_fps = 1000 / average_decoding_time;
|
||||
*pn_fps = n_fps;
|
||||
|
||||
@@ -52,6 +52,7 @@ RocVideoDecoder::RocVideoDecoder(int device_id, OutputSurfaceMemoryType out_mem_
|
||||
|
||||
|
||||
RocVideoDecoder::~RocVideoDecoder() {
|
||||
auto start_time = StartTimer();
|
||||
if (curr_sei_message_ptr_) {
|
||||
delete curr_sei_message_ptr_;
|
||||
curr_sei_message_ptr_ = nullptr;
|
||||
@@ -100,6 +101,8 @@ RocVideoDecoder::~RocVideoDecoder() {
|
||||
fp_out_ = nullptr;
|
||||
}
|
||||
|
||||
double elapsed_time = StopTimer(start_time);
|
||||
AddDecoderSessionOverHead(std::this_thread::get_id(), elapsed_time);
|
||||
}
|
||||
|
||||
static const char * GetVideoCodecString(rocDecVideoCodec e_codec) {
|
||||
@@ -247,6 +250,7 @@ static void GetSurfaceStrideInternal(rocDecVideoSurfaceFormat surface_format, ui
|
||||
* 0: fail, 1: succeeded, > 1: override dpb size of parser (set by CUVIDPARSERPARAMS::max_num_decode_surfaces while creating parser)
|
||||
*/
|
||||
int RocVideoDecoder::HandleVideoSequence(RocdecVideoFormat *p_video_format) {
|
||||
auto start_time = StartTimer();
|
||||
input_video_info_str_.str("");
|
||||
input_video_info_str_.clear();
|
||||
input_video_info_str_ << "Input Video Information" << std::endl
|
||||
@@ -415,6 +419,8 @@ int RocVideoDecoder::HandleVideoSequence(RocdecVideoFormat *p_video_format) {
|
||||
std::cout << input_video_info_str_.str();
|
||||
|
||||
ROCDEC_API_CALL(rocDecCreateDecoder(&roc_decoder_, &videoDecodeCreateInfo));
|
||||
double elapsed_time = StopTimer(start_time);
|
||||
AddDecoderSessionOverHead(std::this_thread::get_id(), elapsed_time);
|
||||
return num_decode_surfaces;
|
||||
}
|
||||
|
||||
@@ -587,7 +593,6 @@ int RocVideoDecoder::ReconfigureDecoder(RocdecVideoFormat *p_video_format) {
|
||||
std::cout << input_video_info_str_.str();
|
||||
|
||||
is_decoder_reconfigured_ = true;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1125,3 +1130,11 @@ bool RocVideoDecoder::InitHIP(int device_id) {
|
||||
HIP_API_CALL(hipStreamCreate(&hip_stream_));
|
||||
return true;
|
||||
}
|
||||
|
||||
std::chrono::_V2::system_clock::time_point RocVideoDecoder::StartTimer() {
|
||||
return std::chrono::_V2::system_clock::now();
|
||||
}
|
||||
|
||||
double RocVideoDecoder::StopTimer(const std::chrono::_V2::system_clock::time_point &start_time) {
|
||||
return std::chrono::duration<double, std::milli>(std::chrono::_V2::system_clock::now() - start_time).count();
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ THE SOFTWARE.
|
||||
#include <stdexcept>
|
||||
#include <exception>
|
||||
#include <cstring>
|
||||
#include <unordered_map>
|
||||
#include <chrono>
|
||||
#include <hip/hip_runtime.h>
|
||||
extern "C" {
|
||||
#include "libavutil/md5.h"
|
||||
@@ -76,7 +78,6 @@ typedef enum OutputSurfaceMemoryType_enum {
|
||||
#endif
|
||||
#define ERR(X) std::cerr << "[ERR] " << " {" << __func__ <<"} " << " " << X << std::endl;
|
||||
|
||||
|
||||
class RocVideoDecodeException : public std::exception {
|
||||
public:
|
||||
|
||||
@@ -357,8 +358,17 @@ class RocVideoDecoder {
|
||||
*/
|
||||
int32_t GetNumOfFlushedFrames() { return num_frames_flushed_during_reconfig_;}
|
||||
|
||||
// Session overhead refers to decoder initialization and deinitialization time
|
||||
void AddDecoderSessionOverHead(std::thread::id session_id, double duration) { session_overhead_[session_id] += duration; }
|
||||
double GetDecoderSessionOverHead(std::thread::id session_id) {
|
||||
if (session_overhead_.find(session_id) != session_overhead_.end()) {
|
||||
return session_overhead_[session_id];
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
int decoder_session_id_; // Decoder session identifier. Used to gather session level stats.
|
||||
/**
|
||||
* @brief Callback function to be registered for getting a callback when decoding of sequence starts
|
||||
*/
|
||||
@@ -420,6 +430,18 @@ class RocVideoDecoder {
|
||||
*/
|
||||
bool InitHIP(int device_id);
|
||||
|
||||
/**
|
||||
* @brief Function to get start time
|
||||
*
|
||||
*/
|
||||
std::chrono::_V2::system_clock::time_point StartTimer();
|
||||
|
||||
/**
|
||||
* @brief Function to get elapsed time
|
||||
*
|
||||
*/
|
||||
double StopTimer(const std::chrono::_V2::system_clock::time_point &start_time);
|
||||
|
||||
int num_devices_;
|
||||
int device_id_;
|
||||
RocdecVideoParser rocdec_parser_ = nullptr;
|
||||
@@ -469,4 +491,6 @@ class RocVideoDecoder {
|
||||
bool is_decoder_reconfigured_ = false;
|
||||
std::string current_output_filename = "";
|
||||
uint32_t extra_output_file_count_ = 0;
|
||||
std::thread::id decoder_session_id_; // Decoder session identifier. Used to gather session level stats.
|
||||
std::unordered_map<std::thread::id, double> session_overhead_; // Records session overhead of initialization+deinitialization time. Format is (thread id, duration)
|
||||
};
|
||||
Verwijs in nieuw issue
Block a user