Skip to content

Commit

Permalink
conversion kernels: watch duration
Browse files Browse the repository at this point in the history
print a warning if consumes more than 10 ms

+ print the function name if DEBUG for elapsed time
  • Loading branch information
MartinPulec committed Aug 30, 2024
1 parent 930abe5 commit 1cb99cb
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/cuda_wrapper/kernels.cu
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@

#include "kernels.hpp"

#include <cstdint>
#include <cstdio>
#include <cuda_runtime_api.h>
#include <stdint.h>

/// modified vc_copylineRG48toR12L
__global__ void
Expand Down Expand Up @@ -175,7 +176,11 @@ kernel_rg48_to_r12l(uint8_t *in, uint8_t *out, unsigned size_x, unsigned size_y)
}

#ifdef DEBUG
#include <stdio.h>
#define D_PRINTF printf
#else
#define D_PRINTF(...)
#endif

#define MEASURE_KERNEL_DURATION_START(stream) \
cudaEvent_t t0, t1; \
cudaEventCreate(&t0); \
Expand All @@ -186,11 +191,13 @@ kernel_rg48_to_r12l(uint8_t *in, uint8_t *out, unsigned size_x, unsigned size_y)
cudaEventSynchronize(t1); \
float elapsedTime = NAN; \
cudaEventElapsedTime(&elapsedTime, t0, t1); \
printf("elapsed time: %f\n", elapsedTime);
#else
#define MEASURE_KERNEL_DURATION_START(stream)
#define MEASURE_KERNEL_DURATION_STOP(stream)
#endif
D_PRINTF("%s elapsed time: %f ms\n", __func__, elapsedTime); \
if (elapsedTime > 10.0) { \
fprintf( \
stderr, \
"Kernel in func %s duration %f > 10 ms, please report!\n", \
__func__, elapsedTime); \
}

/**
* @sa cmpto_j2k_dec_postprocessor_run_callback_cuda
Expand Down

0 comments on commit 1cb99cb

Please sign in to comment.