Files
TheRock/rocm-systems/projects/hip-tests/catch/unit/graph/hipDrvGraphMemcpyNodeGetParams.cc
T
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

170 lines
5.7 KiB
C++

/*
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
*
* SPDX-License-Identifier: MIT
*/
#include <hip_test_common.hh>
#include <hip_test_defgroups.hh>
#include <memcpy3d_tests_common.hh>
#include <numeric>
/**
* @addtogroup hipDrvGraphMemcpyNodeGetParams hipDrvGraphMemcpyNodeGetParams
* @{
* @ingroup GraphTest
* `hipDrvGraphMemcpyNodeGetParams(hipGraphNode_t hNode, HIP_MEMCPY3D*
* nodeParams)` - Gets a memcpy node's parameters
* ________________________
* Test cases from other APIs:
* - @ref Unit_hipDrvGraphMemcpyNodeSetParams_Positive_Basic
*/
/**
* Test Description
* ------------------------
* - Verify API behaviour with invalid arguments:
* -# node is nullptr
* -# pNodeParams is nullptr
* -# node is destroyed
* Test source
* ------------------------
* - unit/graph/hipDrvGraphMemcpyNodeGetParams.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 6.0
*/
HIP_TEST_CASE(Unit_hipDrvGraphMemcpyNodeGetParams_Negative_Parameters) {
HIP_CHECK(hipInit(0));
hipDevice_t device;
hipCtx_t context;
HIP_CHECK(hipDeviceGet(&device, 0));
HIP_CHECK(hipCtxCreate(&context, 0, device));
constexpr hipExtent extent{128 * sizeof(int), 128, 8};
LinearAllocGuard3D<int> src_alloc(extent);
LinearAllocGuard3D<int> dst_alloc(extent);
auto params =
GetDrvMemcpy3DParms(dst_alloc.pitched_ptr(), make_hipPos(0, 0, 0), src_alloc.pitched_ptr(),
make_hipPos(0, 0, 0), dst_alloc.extent(), hipMemcpyDeviceToDevice);
hipGraph_t graph = nullptr;
hipGraphNode_t node = nullptr;
SECTION("node == nullptr") {
HIP_CHECK_ERROR(hipDrvGraphMemcpyNodeGetParams(nullptr, &params), hipErrorInvalidValue);
}
SECTION("pNodeParams == nullptr") {
HIP_CHECK(hipGraphCreate(&graph, 0));
HIP_CHECK(hipDrvGraphAddMemcpyNode(&node, graph, nullptr, 0, &params, context));
HIP_CHECK_ERROR(hipDrvGraphMemcpyNodeGetParams(node, nullptr), hipErrorInvalidValue);
HIP_CHECK(hipGraphDestroy(graph));
}
#if HT_AMD
SECTION("Node is destroyed") {
HIP_CHECK(hipGraphCreate(&graph, 0));
HIP_CHECK(hipDrvGraphAddMemcpyNode(&node, graph, nullptr, 0, &params, context));
HIP_CHECK(hipGraphDestroy(graph));
HIP_CHECK_ERROR(hipDrvGraphMemcpyNodeGetParams(node, &params), hipErrorInvalidValue);
}
#endif
HIP_CHECK(hipCtxPopCurrent(&context));
HIP_CHECK(hipCtxDestroy(context));
}
/**
* Test Description
* ------------------------
* - Create graph node with memcopy parameters and add to graph,
* get the parameters from the created graph node and compare
* the all the values.
* Test source
* ------------------------
* - unit/graph/hipDrvGraphMemcpyNodeGetParams.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 6.4
*/
HIP_TEST_CASE(Unit_hipDrvGraphMemcpyNodeGetParams_Positive) {
size_t size = 10;
size_t numW = size * sizeof(int);
// Host Vectors
std::vector<int> A_h(numW);
std::vector<int> B_h(numW);
hipCtx_t context;
// Initialization
std::iota(A_h.begin(), A_h.end(), 1);
std::fill_n(B_h.begin(), size, 0);
int deviceid = 0;
hipGraph_t graph;
hipStream_t streamForGraph;
hipGraphExec_t graphExec;
hipGraphNode_t node;
HIP_CHECK(hipGraphCreate(&graph, 0));
HIP_CHECK(hipSetDevice(deviceid));
HIP_CHECK(hipStreamCreate(&streamForGraph));
HIP_CHECK(hipCtxCreate(&context, 0, deviceid));
HIP_MEMCPY3D memCpy_params{};
memset(&memCpy_params, 0x0, sizeof(HIP_MEMCPY3D));
memCpy_params.srcXInBytes = 0;
memCpy_params.srcY = 0;
memCpy_params.srcZ = 0;
memCpy_params.dstXInBytes = 0;
memCpy_params.dstY = 0;
memCpy_params.dstZ = 0;
memCpy_params.WidthInBytes = numW;
memCpy_params.Height = 1;
memCpy_params.Depth = 1;
memCpy_params.srcMemoryType = hipMemoryTypeHost;
memCpy_params.dstMemoryType = hipMemoryTypeHost;
memCpy_params.srcHost = A_h.data();
memCpy_params.srcPitch = numW;
memCpy_params.srcHeight = 1;
memCpy_params.dstHost = B_h.data();
memCpy_params.dstPitch = numW;
memCpy_params.dstHeight = 1;
HIP_CHECK(hipDrvGraphAddMemcpyNode(&node, graph, nullptr, 0, &memCpy_params, context));
HIP_CHECK(hipGraphInstantiate(&graphExec, graph, nullptr, nullptr, 0));
HIP_CHECK(hipGraphLaunch(graphExec, streamForGraph));
HIP_CHECK(hipStreamSynchronize(streamForGraph));
REQUIRE(memcmp(A_h.data(), B_h.data(), numW) == 0);
HIP_MEMCPY3D memCpyGetParams{};
HIP_CHECK(hipDrvGraphMemcpyNodeGetParams(node, &memCpyGetParams));
REQUIRE(memCpy_params.srcXInBytes == memCpyGetParams.srcXInBytes);
REQUIRE(memCpy_params.srcY == memCpyGetParams.srcY);
REQUIRE(memCpy_params.srcZ == memCpyGetParams.srcZ);
REQUIRE(memCpy_params.dstXInBytes == memCpyGetParams.dstXInBytes);
REQUIRE(memCpy_params.dstY == memCpyGetParams.dstY);
REQUIRE(memCpy_params.dstZ == memCpyGetParams.dstZ);
REQUIRE(memCpy_params.WidthInBytes == memCpyGetParams.WidthInBytes);
REQUIRE(memCpy_params.Height == memCpyGetParams.Height);
REQUIRE(memCpy_params.Depth == memCpyGetParams.Depth);
REQUIRE(memCpy_params.srcMemoryType == memCpyGetParams.srcMemoryType);
REQUIRE(memCpy_params.dstMemoryType == memCpyGetParams.dstMemoryType);
REQUIRE(memCpy_params.srcHost == memCpyGetParams.srcHost);
REQUIRE(memCpy_params.srcPitch == memCpyGetParams.srcPitch);
REQUIRE(memCpy_params.srcHeight == memCpyGetParams.srcHeight);
REQUIRE(memCpy_params.dstHost == memCpyGetParams.dstHost);
REQUIRE(memCpy_params.dstPitch == memCpyGetParams.dstPitch);
REQUIRE(memCpy_params.dstHeight == memCpyGetParams.dstHeight);
HIP_CHECK(hipGraphDestroy(graph));
HIP_CHECK(hipGraphExecDestroy(graphExec));
HIP_CHECK(hipStreamDestroy(streamForGraph));
HIP_CHECK(hipCtxPopCurrent(&context));
HIP_CHECK(hipCtxDestroy(context));
}
/**
* End doxygen group GraphTest.
* @}
*/