/* * Copyright (c) Advanced Micro Devices, Inc., or its affiliates. * * SPDX-License-Identifier: MIT */ #include #include #include #include #include // hipMemcpyDtoH HIP_TEST_CASE(Unit_hipMemcpyDtoH_Positive_Basic) { MemcpyDeviceToHostShell([](void* dst, void* src, size_t count) { return hipMemcpyDtoH(dst, reinterpret_cast(src), count); }); } HIP_TEST_CASE(Unit_hipMemcpyDtoH_Positive_Synchronization_Behavior) { const auto f = [](void* dst, void* src, size_t count) { return hipMemcpyDtoH(dst, reinterpret_cast(src), count); }; MemcpyDtoHPageableSyncBehavior(f, true); MemcpyDtoHPinnedSyncBehavior(f, true); } HIP_TEST_CASE(Unit_hipMemcpyDtoH_Negative_Parameters) { using namespace std::placeholders; LinearAllocGuard device_alloc(LinearAllocs::hipMalloc, kPageSize); LinearAllocGuard host_alloc(LinearAllocs::hipHostMalloc, kPageSize); MemcpyCommonNegativeTests( [](void* dst, void* src, size_t count) { return hipMemcpyDtoH(dst, reinterpret_cast(src), count); }, host_alloc.ptr(), device_alloc.ptr(), kPageSize); } // hipMemcpyHtoD HIP_TEST_CASE(Unit_hipMemcpyHtoD_Positive_Basic) { MemcpyHostToDeviceShell([](void* dst, void* src, size_t count) { return hipMemcpyHtoD(reinterpret_cast(dst), src, count); }); } HIP_TEST_CASE(Unit_hipMemcpyHtoD_Positive_Synchronization_Behavior) { MemcpyHPageabletoDSyncBehavior( [](void* dst, void* src, size_t count) { return hipMemcpyHtoD(reinterpret_cast(dst), src, count); }, true); } HIP_TEST_CASE(Unit_hipMemcpyHtoD_Negative_Parameters) { using namespace std::placeholders; LinearAllocGuard device_alloc(LinearAllocs::hipMalloc, kPageSize); LinearAllocGuard host_alloc(LinearAllocs::hipHostMalloc, kPageSize); MemcpyCommonNegativeTests( [](void* dst, void* src, size_t count) { return hipMemcpyHtoD(reinterpret_cast(dst), src, count); }, device_alloc.ptr(), host_alloc.ptr(), kPageSize); } // hipMemcpyDtoD HIP_TEST_CASE(Unit_hipMemcpyDtoD_Positive_Basic) { const auto f = [](void* dst, void* src, size_t count) { return hipMemcpyDtoD(reinterpret_cast(dst), reinterpret_cast(src), count); }; SECTION("Peer access enabled") { MemcpyDeviceToDeviceShell(f); } SECTION("Peer access disabled") { MemcpyDeviceToDeviceShell(f); } } HIP_TEST_CASE(Unit_hipMemcpyDtoD_Positive_Synchronization_Behavior) { // This behavior differs on NVIDIA and AMD, on AMD the hipMemcpy calls is synchronous with // respect to the host #if HT_AMD HIP_SKIP_TEST( "EXSWCPHIPT-127 - Memcpy from device to device memory behavior differs on AMD and Nvidia"); #endif MemcpyDtoDSyncBehavior( [](void* dst, void* src, size_t count) { return hipMemcpyDtoD(reinterpret_cast(dst), reinterpret_cast(src), count); }, false); } HIP_TEST_CASE(Unit_hipMemcpyDtoD_Negative_Parameters) { using namespace std::placeholders; LinearAllocGuard src_alloc(LinearAllocs::hipMalloc, kPageSize); LinearAllocGuard dst_alloc(LinearAllocs::hipMalloc, kPageSize); MemcpyCommonNegativeTests( [](void* dst, void* src, size_t count) { return hipMemcpyDtoD(reinterpret_cast(dst), reinterpret_cast(src), count); }, dst_alloc.ptr(), src_alloc.ptr(), kPageSize); }