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
138 lines
4.5 KiB
C++
138 lines
4.5 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include "array_memcpy_tests_common.hh"
|
|
|
|
#include <hip/hip_runtime_api.h>
|
|
#include <hip_test_common.hh>
|
|
#include <resource_guards.hh>
|
|
#include <utils.hh>
|
|
|
|
HIP_TEST_CASE(Unit_hipMemcpyAtoH_Positive_Default) {
|
|
CHECK_IMAGE_SUPPORT
|
|
|
|
using namespace std::placeholders;
|
|
|
|
const auto width = GENERATE(512, 1024, 2048);
|
|
const auto allocation_size = width * sizeof(int);
|
|
|
|
MemcpyAtoHShell<false, int>(std::bind(hipMemcpyAtoH, _1, _2, 0, allocation_size), width);
|
|
}
|
|
|
|
HIP_TEST_CASE(Unit_hipMemcpyAtoH_Positive_Synchronization_Behavior) {
|
|
CHECK_IMAGE_SUPPORT
|
|
|
|
using namespace std::placeholders;
|
|
|
|
const auto width = GENERATE(512, 1024, 2048);
|
|
const auto height = 0;
|
|
const auto allocation_size = width * sizeof(int);
|
|
|
|
MemcpyAtoHPageableSyncBehavior(std::bind(hipMemcpyAtoH, _1, _2, 0, allocation_size), width,
|
|
height, true);
|
|
MemcpyAtoHPinnedSyncBehavior(std::bind(hipMemcpyAtoH, _1, _2, 0, allocation_size), width, height,
|
|
true);
|
|
}
|
|
|
|
/*
|
|
This testcase verifies size 0 check of hipMemcpyAtoH API
|
|
Excluded the testcase for amd,as there is already a bug raised
|
|
SWDEV-274683
|
|
*/
|
|
#if HT_NVIDIA
|
|
HIP_TEST_CASE(Unit_hipMemcpyAtoH_Positive_ZeroCount) {
|
|
CHECK_IMAGE_SUPPORT
|
|
|
|
const auto width = 1024;
|
|
const auto height = 0;
|
|
const auto allocation_size = width * sizeof(int);
|
|
|
|
const unsigned int flag = hipArrayDefault;
|
|
|
|
ArrayAllocGuard<int> array_alloc(make_hipExtent(width, height, 0), flag);
|
|
LinearAllocGuard<uint8_t> host_alloc(LinearAllocs::hipHostMalloc, allocation_size);
|
|
|
|
int fill_value = 42;
|
|
std::fill_n(host_alloc.host_ptr(), width, fill_value);
|
|
HIP_CHECK(hipMemcpy2DToArray(array_alloc.ptr(), 0, 0, host_alloc.host_ptr(), sizeof(int) * width,
|
|
sizeof(int) * width, 1, hipMemcpyHostToDevice));
|
|
fill_value = 41;
|
|
std::fill_n(host_alloc.host_ptr(), width, fill_value);
|
|
|
|
hipError_t memcpy_err = hipSuccess;
|
|
BEGIN_CAPTURE_SYNC(memcpy_err, false);
|
|
HIP_CHECK_ERROR(hipMemcpyAtoH(host_alloc.ptr(), array_alloc.ptr(), 0, 0), memcpy_err);
|
|
END_CAPTURE_SYNC(memcpy_err);
|
|
if (memcpy_err == hipErrorStreamCaptureImplicit) {
|
|
return;
|
|
}
|
|
|
|
ArrayFindIfNot(host_alloc.host_ptr(), static_cast<uint8_t>(fill_value), width);
|
|
}
|
|
#endif
|
|
|
|
HIP_TEST_CASE(Unit_hipMemcpyAtoH_Negative_Parameters) {
|
|
CHECK_IMAGE_SUPPORT
|
|
|
|
using namespace std::placeholders;
|
|
|
|
const auto width = 1024;
|
|
const auto height = 0;
|
|
const auto allocation_size = width * sizeof(int);
|
|
|
|
const unsigned int flag = hipArrayDefault;
|
|
|
|
ArrayAllocGuard<int> array_alloc(make_hipExtent(width, height, 0), flag);
|
|
LinearAllocGuard<int> host_alloc(LinearAllocs::hipHostMalloc, allocation_size);
|
|
|
|
SECTION("dst == nullptr") {
|
|
HIP_CHECK_ERROR(hipMemcpyAtoH(nullptr, array_alloc.ptr(), 0, allocation_size),
|
|
hipErrorInvalidValue);
|
|
}
|
|
SECTION("src == nullptr") {
|
|
HIP_CHECK_ERROR(hipMemcpyAtoH(host_alloc.ptr(), nullptr, 0, allocation_size),
|
|
hipErrorInvalidValue);
|
|
}
|
|
SECTION("Offset is greater than allocated size") {
|
|
HIP_CHECK_ERROR(
|
|
hipMemcpyAtoH(host_alloc.ptr(), array_alloc.ptr(), allocation_size + 10, allocation_size),
|
|
hipErrorInvalidValue);
|
|
}
|
|
SECTION("Count is greater than allocated size") {
|
|
HIP_CHECK_ERROR(hipMemcpyAtoH(host_alloc.ptr(), array_alloc.ptr(), 0, allocation_size + 10),
|
|
hipErrorInvalidValue);
|
|
}
|
|
SECTION("2D array is allocated") {
|
|
const auto width_2d = 32;
|
|
const auto height_2d = width_2d;
|
|
const auto allocation_size_2d = width_2d * height_2d * sizeof(int);
|
|
|
|
ArrayAllocGuard<int> array_alloc_2d(make_hipExtent(width_2d, height_2d, 0), flag);
|
|
LinearAllocGuard<int> host_alloc_2d(LinearAllocs::hipHostMalloc, allocation_size_2d);
|
|
HIP_CHECK_ERROR(hipMemcpyAtoH(host_alloc_2d.ptr(), array_alloc_2d.ptr(), 0, allocation_size_2d),
|
|
hipErrorInvalidValue);
|
|
}
|
|
}
|
|
|
|
HIP_TEST_CASE(Unit_hipMemcpyAtoH_Capture) {
|
|
CHECK_IMAGE_SUPPORT
|
|
|
|
const auto width = 1024;
|
|
const auto height = 0;
|
|
const auto allocation_size = width * sizeof(int);
|
|
|
|
const unsigned int flag = hipArrayDefault;
|
|
|
|
ArrayAllocGuard<int> array_alloc(make_hipExtent(width, height, 0), flag);
|
|
LinearAllocGuard<int> host_alloc(LinearAllocs::hipHostMalloc, allocation_size);
|
|
|
|
hipError_t memcpy_err = hipSuccess;
|
|
BEGIN_CAPTURE_SYNC(memcpy_err, false);
|
|
HIP_CHECK_ERROR(hipMemcpyAtoH(host_alloc.ptr(), array_alloc.ptr(), 0, allocation_size),
|
|
memcpy_err);
|
|
END_CAPTURE_SYNC(memcpy_err);
|
|
}
|