Files
opencv-MIRROR/modules/core/perf/perf_accel.cpp
Savya Sanchi Sharma c97ebe2b55 core: add ROCm 10 support and HIP backend plugin for the non-CPU HAL (#30925)
Adds the AMD/ROCm half:

ROCm detection, separate from HIP. ROCm 10.0 ships HIP 7.15, and HIP's major
version is 7 on both ROCm 7 and ROCm 10, so hip_VERSION cannot identify the
platform. Detection probes rocm-core, then the legacy version file, then
ROCm 10's core-<major>.<minor> directory.
GPU architecture selection via amdgpu-arch / rocm_agent_enumerator,
falling back to family-wide generic targets.
A standalone HIP backend plugin (hal/accel/hip/), loaded on first use.
No OpenCV module compiles HIP, and the main build does not depend on ROCm.
Implemented kernels: flip, transpose, setTo, and convertTo.
2026-11-25 14:23:05 +05:30

66 lines
1.8 KiB
C++

// 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) 2026, BigVision LLC, all rights reserved.
#include "perf_precomp.hpp"
#include "opencv2/core/accel.hpp"
namespace opencv_test { namespace {
using namespace perf;
#define ACCEL_SIZES sz1080p, sz2160p
#define ACCEL_TYPES CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC4
typedef perf::TestBaseWithParam<tuple<Size, MatType> > Accel_Size_MatType;
// the first device of the built-in CUDA backend, else of the HIP one; the tests are skipped without one
static accel::Device gpu()
{
accel::Device d = accel::Device::find("cuda");
if (d.empty())
d = accel::Device::find("hip");
if (d.empty())
throw SkipTestException("no CUDA or HIP device");
return d;
}
static UMat onDevice(const accel::Device& d, Size sz, int type)
{
Mat h(sz, type);
randu(h, 0, 255);
return h.upload(d);
}
PERF_TEST_P(Accel_Size_MatType, flip, testing::Combine(testing::Values(ACCEL_SIZES), testing::Values(ACCEL_TYPES)))
{
const accel::Device d = gpu();
UMat src = onDevice(d, get<0>(GetParam()), get<1>(GetParam())), dst;
cv::flip(src, dst, 1);
TEST_CYCLE()
{
cv::flip(src, dst, 1);
accel::synchronize(d);
}
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(Accel_Size_MatType, transpose, testing::Combine(testing::Values(ACCEL_SIZES), testing::Values(ACCEL_TYPES)))
{
const accel::Device d = gpu();
UMat src = onDevice(d, get<0>(GetParam()), get<1>(GetParam())), dst;
cv::transpose(src, dst);
TEST_CYCLE()
{
cv::transpose(src, dst);
accel::synchronize(d);
}
SANITY_CHECK_NOTHING();
}
}} // namespace opencv_test