Skip to content

Commit

Permalink
removed redundant nvtx ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
MorkTheOrk committed Mar 12, 2024
1 parent c6a7a92 commit a8286da
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
11 changes: 8 additions & 3 deletions libvmaf/src/feature/cuda/integer_adm_cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
#include "picture_cuda.h"
#include <unistd.h>
#include <assert.h>
#ifdef HAVE_NVTX
#include "nvtx3/nvToolsExt.h"
#endif

#define RES_BUFFER_SIZE 4 * 3 * 2

Expand Down Expand Up @@ -642,7 +644,6 @@ typedef struct write_score_parameters_adm {

static int write_scores(write_score_parameters_adm* params)
{
nvtxRangePushA("write_scores ADM");
VmafFeatureCollector *feature_collector = params->feature_collector;
AdmStateCuda *s = params->s;
unsigned index = params->index;
Expand Down Expand Up @@ -717,7 +718,6 @@ static int write_scores(write_score_parameters_adm* params)

if (!s->debug) {

nvtxRangePop();
return err;
}

Expand Down Expand Up @@ -754,7 +754,6 @@ static int write_scores(write_score_parameters_adm* params)

err |= vmaf_feature_collector_append_with_dict(feature_collector,
s->feature_name_dict, "integer_adm_den_scale3", scores[7], index);
nvtxRangePop();
return err;
}

Expand Down Expand Up @@ -1233,11 +1232,17 @@ static int close_fex_cuda(VmafFeatureExtractor *fex)
static int flush_fex_cuda(VmafFeatureExtractor *fex,
VmafFeatureCollector *feature_collector)
{
#ifdef HAVE_NVTX
nvtxRangePushA("flush adm_cuda");
#endif
AdmStateCuda *s = fex->priv;
int ret = 0;
CHECK_CUDA(cuStreamSynchronize(s->str));
CHECK_CUDA(cuStreamSynchronize(s->host_stream));
CHECK_CUDA(cuEventSynchronize(s->scores_written));
#ifdef HAVE_NVTX
nvtxRangePop();
#endif
return (ret < 0) ? ret : !ret;
}

Expand Down
12 changes: 10 additions & 2 deletions libvmaf/src/feature/cuda/integer_motion_cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
#include "picture.h"
#include "picture_cuda.h"
#include "cuda_helper.cuh"
#ifdef HAVE_NVTX
#include "nvtx3/nvToolsExt.h"
#endif

typedef struct MotionStateCuda {
CUevent event, finished, scores_written;
Expand Down Expand Up @@ -212,7 +214,9 @@ static int init_fex_cuda(VmafFeatureExtractor *fex, enum VmafPixelFormat pix_fmt
static int flush_fex_cuda(VmafFeatureExtractor *fex,
VmafFeatureCollector *feature_collector)
{
nvtxRangePushA("FLUSH MOT");
#ifdef HAVE_NVTX
nvtxRangePushA("flush motion_cuda");
#endif

MotionStateCuda *s = fex->priv;
int ret = 0;
Expand All @@ -224,7 +228,7 @@ static int flush_fex_cuda(VmafFeatureExtractor *fex,
continue;
}
CHECK_CUDA(cuEventSynchronize(s->scores_written));
nvtxRangePop();

}
else {
if (s->index > 0 && !s->closed) {
Expand All @@ -235,6 +239,10 @@ static int flush_fex_cuda(VmafFeatureExtractor *fex,
s->closed = true;
}
s->flushed = true;

#ifdef HAVE_NVTX
nvtxRangePop();
#endif
return (ret < 0) ? ret : !ret;
}

Expand Down
18 changes: 9 additions & 9 deletions libvmaf/src/feature/cuda/integer_vif_cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
#include "cuda/integer_vif_cuda.h"
#include "picture_cuda.h"


#ifdef HAVE_NVTX
#include "nvtx3/nvToolsExt.h"
#endif

#if ARCH_X86
#include "x86/vif_avx2.h"
Expand Down Expand Up @@ -349,7 +350,6 @@ typedef struct VifScore {

static int write_scores(write_score_parameters_vif* data)
{
nvtxRangePushA("write_scoes VIF");
VmafFeatureCollector *feature_collector = data->feature_collector;
VifStateCuda *s = data->s;
unsigned index = data->index;
Expand Down Expand Up @@ -384,11 +384,7 @@ static int write_scores(write_score_parameters_vif* data)
s->feature_name_dict, "VMAF_integer_feature_vif_scale3_score",
vif.scale[3].num / vif.scale[3].den, index);

if (!s->debug) {

nvtxRangePop();
return err;
}
if (!s->debug) return err;

const double score_num =
(double)vif.scale[0].num + (double)vif.scale[1].num +
Expand Down Expand Up @@ -441,7 +437,7 @@ static int write_scores(write_score_parameters_vif* data)
err |= vmaf_feature_collector_append_with_dict(feature_collector,
s->feature_name_dict, "integer_vif_den_scale3", vif.scale[3].den,
index);
nvtxRangePop();

return err;
}

Expand Down Expand Up @@ -536,14 +532,18 @@ static int close_fex_cuda(VmafFeatureExtractor *fex)
static int flush_fex_cuda(VmafFeatureExtractor *fex,
VmafFeatureCollector *feature_collector)
{
nvtxRangePushA("flush VIF");
#ifdef HAVE_NVTX
nvtxRangePushA("flush vif_cuda");
#endif
VifStateCuda *s = fex->priv;

int ret = 0;
CHECK_CUDA(cuStreamSynchronize(s->str));
CHECK_CUDA(cuStreamSynchronize(s->host_stream));
CHECK_CUDA(cuEventSynchronize(s->scores_written));
#ifdef HAVE_NVTX
nvtxRangePop();
#endif

return (ret < 0) ? ret : !ret;
}
Expand Down

0 comments on commit a8286da

Please sign in to comment.