From f6537beee32cba89c567caf0f2fbca5b4210f135 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Tue, 17 Jan 2023 21:54:27 +0530 Subject: [PATCH] Fix merge issues in memory unit tests (#123) [ROCm/hip-tests commit: 75bb521e18035086f09a9622af72924bca7efd14] --- .../catch/unit/memory/CMakeLists.txt | 2 - .../unit/memory/hipMemGetAddressRange.cc | 2 +- .../catch/unit/memory/hipMemPrefetchAsync.cc | 4 +- .../hip-tests/catch/unit/memory/hipMemcpy.cc | 101 ------------------ .../unit/memory/hipMemcpy2DFromArrayAsync.cc | 2 + .../unit/memory/hipMemcpy2DToArrayAsync.cc | 2 + 6 files changed, 7 insertions(+), 106 deletions(-) delete mode 100644 projects/hip-tests/catch/unit/memory/hipMemcpy.cc diff --git a/projects/hip-tests/catch/unit/memory/CMakeLists.txt b/projects/hip-tests/catch/unit/memory/CMakeLists.txt index 0fbb7b7ce5..ecb2411180 100644 --- a/projects/hip-tests/catch/unit/memory/CMakeLists.txt +++ b/projects/hip-tests/catch/unit/memory/CMakeLists.txt @@ -85,7 +85,6 @@ set(TEST_SRC hipMemcpyDtoDAsync.cc hipHostMalloc.cc hipMemcpy_old.cc - hipMemcpy.cc hipMemcpy_derivatives.cc hipMemcpyAsync.cc hipMemsetFunctional.cc @@ -179,7 +178,6 @@ set(TEST_SRC hipMemcpyDtoDAsync.cc hipHostMalloc.cc hipMemcpy_old.cc - hipMemcpy.cc hipMemcpy_derivatives.cc hipMemcpyAsync.cc hipMemsetFunctional.cc diff --git a/projects/hip-tests/catch/unit/memory/hipMemGetAddressRange.cc b/projects/hip-tests/catch/unit/memory/hipMemGetAddressRange.cc index 7491163bda..d63433c696 100644 --- a/projects/hip-tests/catch/unit/memory/hipMemGetAddressRange.cc +++ b/projects/hip-tests/catch/unit/memory/hipMemGetAddressRange.cc @@ -74,7 +74,7 @@ TEST_CASE("Unit_hipMemGetAddressRange_Negative") { const int offset = kPageSize; LinearAllocGuard host_alloc(LinearAllocs::hipHostMalloc, allocation_size); - hipDeviceptr_t dummy_ptr; + hipDeviceptr_t dummy_ptr = NULL; SECTION("Device pointer is invalid") { HIP_CHECK_ERROR(hipMemGetAddressRange(&base_ptr, &mem_size, dummy_ptr), hipErrorNotFound); diff --git a/projects/hip-tests/catch/unit/memory/hipMemPrefetchAsync.cc b/projects/hip-tests/catch/unit/memory/hipMemPrefetchAsync.cc index 8ff869d56f..6bdd027942 100644 --- a/projects/hip-tests/catch/unit/memory/hipMemPrefetchAsync.cc +++ b/projects/hip-tests/catch/unit/memory/hipMemPrefetchAsync.cc @@ -116,11 +116,11 @@ TEST_CASE("Unit_hipMemPrefetchAsync_Rounding_Behavior") { HIP_CHECK(hipMemRangeGetAttribute(&attribute, sizeof(attribute), hipMemRangeAttributeLastPrefetchLocation, reinterpret_cast(base), rounded_up)); - REQUIRE(device == attribute); + REQUIRE(device == static_cast(attribute)); HIP_CHECK(hipMemRangeGetAttribute(&attribute, sizeof(attribute), hipMemRangeAttributeLastPrefetchLocation, alloc.ptr(), 3 * kPageSize)); - REQUIRE((rounded_up == 3 * kPageSize ? device : hipInvalidDeviceId) == attribute); + REQUIRE((rounded_up == 3 * kPageSize ? device : hipInvalidDeviceId) == static_cast(attribute)); } TEST_CASE("Unit_hipMemPrefetchAsync_Negative_Parameters") { diff --git a/projects/hip-tests/catch/unit/memory/hipMemcpy.cc b/projects/hip-tests/catch/unit/memory/hipMemcpy.cc deleted file mode 100644 index 24e11c25f3..0000000000 --- a/projects/hip-tests/catch/unit/memory/hipMemcpy.cc +++ /dev/null @@ -1,101 +0,0 @@ -/* -Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#include -#include -#include -#include -#include - -TEST_CASE("Unit_hipMemcpy_Positive_Basic") { MemcpyWithDirectionCommonTests(hipMemcpy); } - -TEST_CASE("Unit_hipMemcpy_Positive_Synchronization_Behavior") { - using namespace std::placeholders; - HIP_CHECK(hipDeviceSynchronize()); - - // For transfers from pageable host memory to device memory, a stream sync is performed before - // the copy is initiated. The function will return once the pageable buffer has been copied to - // the staging memory for DMA transfer to device memory, but the DMA to final destination may - // not have completed. - // For transfers from pinned host memory to device memory, the function is synchronous with - // respect to the host - SECTION("Host memory to device memory") { - MemcpyHtoDSyncBehavior(std::bind(hipMemcpy, _1, _2, _3, hipMemcpyHostToDevice), true); - } - - // For transfers from device to either pageable or pinned host memory, the function returns only - // once the copy has completed - SECTION("Device memory to host memory") { - const auto f = std::bind(hipMemcpy, _1, _2, _3, hipMemcpyDeviceToHost); - MemcpyDtoHPageableSyncBehavior(f, true); - MemcpyDtoHPinnedSyncBehavior(f, true); - } - - // For transfers from device memory to device memory, no host-side synchronization is performed. - SECTION("Device memory to device memory") { - // This behavior differs on NVIDIA and AMD, on AMD the hipMemcpy calls is synchronous with - // respect to the host -#if HT_AMD - HipTest::HIP_SKIP_TEST( - "EXSWCPHIPT-127 - Memcpy from device to device memory behavior differs on AMD and Nvidia"); - return; -#endif - MemcpyDtoDSyncBehavior(std::bind(hipMemcpy, _1, _2, _3, hipMemcpyDeviceToDevice), false); - } - - // For transfers from any host memory to any host memory, the function is fully synchronous with - // respect to the host - SECTION("Host memory to host memory") { - MemcpyHtoHSyncBehavior(std::bind(hipMemcpy, _1, _2, _3, hipMemcpyHostToHost), true); - } -} - -TEST_CASE("Unit_hipMemcpy_Negative_Parameters") { - using namespace std::placeholders; - - SECTION("Host to device") { - LinearAllocGuard device_alloc(LinearAllocs::hipMalloc, kPageSize); - LinearAllocGuard host_alloc(LinearAllocs::hipHostMalloc, kPageSize); - MemcpyWithDirectionCommonNegativeTests(hipMemcpy, device_alloc.ptr(), host_alloc.ptr(), - kPageSize, hipMemcpyHostToDevice); - } - - SECTION("Device to host") { - LinearAllocGuard device_alloc(LinearAllocs::hipMalloc, kPageSize); - LinearAllocGuard host_alloc(LinearAllocs::hipHostMalloc, kPageSize); - MemcpyWithDirectionCommonNegativeTests(hipMemcpy, host_alloc.ptr(), device_alloc.ptr(), - kPageSize, hipMemcpyDeviceToHost); - } - - SECTION("Host to host") { - LinearAllocGuard src_alloc(LinearAllocs::hipHostMalloc, kPageSize); - LinearAllocGuard dst_alloc(LinearAllocs::hipHostMalloc, kPageSize); - MemcpyWithDirectionCommonNegativeTests(hipMemcpy, dst_alloc.ptr(), src_alloc.ptr(), kPageSize, - hipMemcpyHostToHost); - } - - SECTION("Device to device") { - LinearAllocGuard src_alloc(LinearAllocs::hipMalloc, kPageSize); - LinearAllocGuard dst_alloc(LinearAllocs::hipMalloc, kPageSize); - MemcpyWithDirectionCommonNegativeTests(hipMemcpy, dst_alloc.ptr(), src_alloc.ptr(), kPageSize, - hipMemcpyDeviceToDevice); - } -} diff --git a/projects/hip-tests/catch/unit/memory/hipMemcpy2DFromArrayAsync.cc b/projects/hip-tests/catch/unit/memory/hipMemcpy2DFromArrayAsync.cc index 5dcd4085c6..35cb11a566 100644 --- a/projects/hip-tests/catch/unit/memory/hipMemcpy2DFromArrayAsync.cc +++ b/projects/hip-tests/catch/unit/memory/hipMemcpy2DFromArrayAsync.cc @@ -165,10 +165,12 @@ TEST_CASE("Unit_hipMemcpy2DFromArrayAsync_Negative_Parameters") { const unsigned int flag = hipArrayDefault; +#if HT_NVIDIA constexpr auto InvalidStream = [] { StreamGuard sg(Streams::created); return sg.stream(); }; +#endif ArrayAllocGuard array_alloc(make_hipExtent(width, height, 0), flag); LinearAllocGuard2D device_alloc(width, height); diff --git a/projects/hip-tests/catch/unit/memory/hipMemcpy2DToArrayAsync.cc b/projects/hip-tests/catch/unit/memory/hipMemcpy2DToArrayAsync.cc index 2cf02a3e01..7e3414e184 100644 --- a/projects/hip-tests/catch/unit/memory/hipMemcpy2DToArrayAsync.cc +++ b/projects/hip-tests/catch/unit/memory/hipMemcpy2DToArrayAsync.cc @@ -160,10 +160,12 @@ TEST_CASE("Unit_hipMemcpy2DToArrayAsync_Negative_Parameters") { const unsigned int flag = hipArrayDefault; +#if HT_NVIDIA constexpr auto InvalidStream = [] { StreamGuard sg(Streams::created); return sg.stream(); }; +#endif ArrayAllocGuard array_alloc(make_hipExtent(width, height, 0), flag); LinearAllocGuard2D device_alloc(width, height);