CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
125 lines
3.9 KiB
C++
125 lines
3.9 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include "memcpy_performance_common.hh"
|
|
|
|
/**
|
|
* @addtogroup memcpy memcpy
|
|
* @{
|
|
* @ingroup PerformanceTestMemory
|
|
*/
|
|
|
|
class Memcpy2DFromArrayBenchmark : public Benchmark<Memcpy2DFromArrayBenchmark> {
|
|
public:
|
|
void operator()(void* dst, size_t dst_pitch, hipArray_const_t src, size_t width, size_t height,
|
|
hipMemcpyKind kind) {
|
|
TIMED_SECTION(kTimerTypeCpu) {
|
|
HIP_CHECK(hipMemcpy2DFromArray(dst, dst_pitch, src, 0, 0, width, height, kind));
|
|
}
|
|
}
|
|
};
|
|
|
|
static void RunBenchmark(size_t width, size_t height, hipMemcpyKind kind,
|
|
bool enable_peer_access = false) {
|
|
Memcpy2DFromArrayBenchmark benchmark;
|
|
benchmark.AddSectionName("(" + std::to_string(width) + ", " + std::to_string(height) + ")");
|
|
|
|
if (kind == hipMemcpyDeviceToHost) {
|
|
size_t allocation_size = width * height * sizeof(int);
|
|
LinearAllocGuard<int> host_allocation(LinearAllocs::hipHostMalloc, allocation_size);
|
|
ArrayAllocGuard<int> array_allocation(make_hipExtent(width, height, 0), hipArrayDefault);
|
|
benchmark.Run(host_allocation.ptr(), width * sizeof(int), array_allocation.ptr(),
|
|
width * sizeof(int), height, hipMemcpyDeviceToHost);
|
|
} else {
|
|
// hipMemcpyDeviceToDevice
|
|
int src_device = std::get<0>(GetDeviceIds(enable_peer_access));
|
|
int dst_device = std::get<1>(GetDeviceIds(enable_peer_access));
|
|
|
|
LinearAllocGuard2D<int> device_allocation(width, height);
|
|
HIP_CHECK(hipSetDevice(dst_device));
|
|
ArrayAllocGuard<int> array_allocation(make_hipExtent(width, height, 0), hipArrayDefault);
|
|
HIP_CHECK(hipSetDevice(src_device));
|
|
benchmark.Run(device_allocation.ptr(), device_allocation.pitch(), array_allocation.ptr(),
|
|
device_allocation.width(), device_allocation.height(), hipMemcpyDeviceToDevice);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Executes `hipMemcpy2DFromArray` from Device to Host:
|
|
* -# Allocation size
|
|
* - Small: 4 KB x 32 B
|
|
* - Medium: 8 KB x 32 B
|
|
* - Large: 16 KB x 32 B
|
|
* Test source
|
|
* ------------------------
|
|
* - performance/api/memcpy/hipMemcpy2DFromArray.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Performance_hipMemcpy2DFromArray_DeviceToHost) {
|
|
CHECK_IMAGE_SUPPORT
|
|
|
|
const auto width = GENERATE(4_KB, 8_KB, 16_KB);
|
|
RunBenchmark(width, 32, hipMemcpyDeviceToHost);
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Executes `hipMemcpy2DFromArray` from Device to Device with peer access disabled:
|
|
* -# Allocation size
|
|
* - Small: 4 KB x 32 B
|
|
* - Medium: 8 KB x 32 B
|
|
* - Large: 16 KB x 32 B
|
|
* Test source
|
|
* ------------------------
|
|
* - performance/api/memcpy/hipMemcpy2DFromArray.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Performance_hipMemcpy2DFromArray_DeviceToDevice_DisablePeerAccess) {
|
|
CHECK_IMAGE_SUPPORT
|
|
|
|
const auto width = GENERATE(4_KB, 8_KB, 16_KB);
|
|
RunBenchmark(width, 32, hipMemcpyDeviceToDevice);
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Executes `hipMemcpy2DFromArray` from Device to Device with peer access enabled:
|
|
* -# Allocation size
|
|
* - Small: 4 KB x 32 B
|
|
* - Medium: 8 KB x 32 B
|
|
* - Large: 16 KB x 32 B
|
|
* Test source
|
|
* ------------------------
|
|
* - performance/api/memcpy/hipMemcpy2DFromArray.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - Multi-device
|
|
* - Device supports Peer-to-Peer access
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Performance_hipMemcpy2DFromArray_DeviceToDevice_EnablePeerAccess) {
|
|
CHECK_IMAGE_SUPPORT
|
|
|
|
if (HipTest::getDeviceCount() < 2) {
|
|
HIP_SKIP_TEST(HipTest::SkipReason::kFewerThanTwoGpus);
|
|
}
|
|
const auto width = GENERATE(4_KB, 8_KB, 16_KB);
|
|
RunBenchmark(width, 32, hipMemcpyDeviceToDevice, true);
|
|
}
|
|
|
|
/**
|
|
* End doxygen group memcpy.
|
|
* @}
|
|
*/
|