SWDEV-1 - Merge github PRs to amd-staging
- https://github.com/ROCm/hip-tests/pull/119 - https://github.com/ROCm/hip-tests/pull/151 - https://github.com/ROCm/hip-tests/pull/57 - https://github.com/ROCm/hip-tests/pull/58 - https://github.com/ROCm/hip-tests/pull/59 - https://github.com/ROCm/hip-tests/pull/60 - https://github.com/ROCm/hip-tests/pull/99 - https://github.com/ROCm/hip-tests/pull/139 - https://github.com/ROCm/hip-tests/pull/152 - https://github.com/ROCm/hip-tests/pull/48 - https://github.com/ROCm/hip-tests/pull/54 - https://github.com/ROCm/hip-tests/pull/53 - https://github.com/ROCm/hip-tests/pull/24 - https://github.com/ROCm/hip-tests/pull/23 - https://github.com/ROCm/hip-tests/pull/22 - https://github.com/ROCm/hip-tests/pull/21 - https://github.com/ROCm/hip-tests/pull/20 - https://github.com/ROCm/hip-tests/pull/14 - https://github.com/ROCm/hip-tests/pull/8 Change-Id: I1eea54cd1436f3ddbfd5c1b3b2f672eb81d03cd4
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
/*
|
||||
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
|
||||
@@ -17,247 +20,248 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
Testcase Scenarios :
|
||||
Functional-
|
||||
1) Instantiate a graph with memcpy node, obtain executable graph and update the hipMemcpy3DParms node params with set. Make sure they are taking effect.
|
||||
Negative-
|
||||
1) Pass hGraphExec as nullptr and verify api returns error code.
|
||||
2) Pass node as nullptr and verify api returns error code.
|
||||
3) Pass pNodeParams as nullptr and verify api returns error code.
|
||||
4) Pass pNodeParams as empty structure object and verify api returns error code.
|
||||
5) API expects atleast one memcpy src pointer to be set. When hipMemcpy3DParms::srcArray and hipMemcpy3DParms::srcPtr.ptr both are nullptr, api expected to return error code.
|
||||
6) API expects atleast one memcpy dst pointer to be set. When hipMemcpy3DParms::dstArray and hipMemcpy3DParms::dstPtr.ptr both are nullptr, api expected to return error code.
|
||||
7) Passing different element size for hipMemcpy3DParms::srcArray and hipMemcpy3DParms::dstArray is expected to return error code.
|
||||
8) Pass node of different graph and verify api returns error code.
|
||||
*/
|
||||
#include <functional>
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip_test_checkers.hh>
|
||||
#include <hip_test_defgroups.hh>
|
||||
#include <memcpy1d_tests_common.hh>
|
||||
#include <memcpy3d_tests_common.hh>
|
||||
|
||||
/* Test verifies hipGraphExecMemcpyNodeSetParams API Negative scenarios.
|
||||
#include "graph_tests_common.hh"
|
||||
|
||||
/**
|
||||
* @addtogroup hipGraphExecMemcpyNodeSetParams hipGraphExecMemcpyNodeSetParams
|
||||
* @{
|
||||
* @ingroup GraphTest
|
||||
* `hipGraphExecMemcpyNodeSetParams(hipGraphExec_t hGraphExec, hipGraphNode_t node, hipMemcpy3DParms
|
||||
* *pNodeParams)` - Sets the parameters for a memcpy node in the given graphExec
|
||||
*/
|
||||
TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParams_Negative") {
|
||||
CHECK_IMAGE_SUPPORT
|
||||
|
||||
constexpr int width{10}, height{10}, depth{10};
|
||||
hipArray_t devArray, devArray2;
|
||||
hipChannelFormatKind formatKind = hipChannelFormatKindSigned;
|
||||
hipMemcpy3DParms myparms;
|
||||
hipError_t ret;
|
||||
int* hData;
|
||||
uint32_t size = width * height * depth * sizeof(int);
|
||||
hData = reinterpret_cast<int*>(malloc(size));
|
||||
REQUIRE(hData != nullptr);
|
||||
memset(hData, 0, size);
|
||||
for (int i = 0; i < depth; i++) {
|
||||
for (int j = 0; j < height; j++) {
|
||||
for (int k = 0; k < width; k++) {
|
||||
hData[i*width*height + j*width + k] = i*width*height + j*width + k;
|
||||
}
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Verify that node parameters get updated correctly by creating a node with valid but
|
||||
* incorrect parameters, and the setting them to the correct values in the executable graph. The
|
||||
* executable graph is run and the results of the memcpy verified. The test is run for all possible
|
||||
* memcpy directions, with both the corresponding memcpy kind and hipMemcpyDefault, as well as half
|
||||
* page and full page allocation sizes. Test source
|
||||
* ------------------------
|
||||
* - unit/graph/hipGraphExecMemcpyNodeSetParams.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 5.2
|
||||
*/
|
||||
TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParams_Positive_Basic") {
|
||||
constexpr auto f = [](void* dst, void* src, size_t count, hipMemcpyKind direction) {
|
||||
hipGraph_t graph = nullptr;
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
hipGraphNode_t node = nullptr;
|
||||
const auto offset_src = reinterpret_cast<uint8_t*>(src) + 1;
|
||||
const auto offset_dst = reinterpret_cast<uint8_t*>(dst) + 1;
|
||||
auto params =
|
||||
GetMemcpy3DParms(make_hipPitchedPtr(offset_dst, 0, count - 1, 0), make_hipPos(0, 0, 0),
|
||||
make_hipPitchedPtr(offset_src, 0, count - 1, 0), make_hipPos(0, 0, 0),
|
||||
make_hipExtent(count - 1, 1, 1), direction);
|
||||
HIP_CHECK(hipGraphAddMemcpyNode(&node, graph, nullptr, 0, ¶ms));
|
||||
hipGraphExec_t graph_exec = nullptr;
|
||||
HIP_CHECK(hipGraphInstantiate(&graph_exec, graph, nullptr, nullptr, 0));
|
||||
params = GetMemcpy3DParms(make_hipPitchedPtr(dst, 0, count, 0), make_hipPos(0, 0, 0),
|
||||
make_hipPitchedPtr(src, 0, count, 0), make_hipPos(0, 0, 0),
|
||||
make_hipExtent(count, 1, 1), direction);
|
||||
HIP_CHECK(hipGraphExecMemcpyNodeSetParams(graph_exec, node, ¶ms));
|
||||
HIP_CHECK(hipGraphLaunch(graph_exec, hipStreamPerThread));
|
||||
HIP_CHECK(hipStreamSynchronize(hipStreamPerThread));
|
||||
|
||||
HIP_CHECK(hipGraphExecDestroy(graph_exec));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
|
||||
return hipSuccess;
|
||||
};
|
||||
|
||||
#if HT_NVIDIA
|
||||
MemcpyWithDirectionCommonTests<false>(f);
|
||||
#else
|
||||
using namespace std::placeholders;
|
||||
|
||||
SECTION("Device to host") {
|
||||
MemcpyDeviceToHostShell<false>(std::bind(f, _1, _2, _3, hipMemcpyDeviceToHost));
|
||||
}
|
||||
|
||||
SECTION("Host to device") {
|
||||
MemcpyHostToDeviceShell<false>(std::bind(f, _1, _2, _3, hipMemcpyHostToDevice));
|
||||
}
|
||||
|
||||
SECTION("Device to device") {
|
||||
SECTION("Peer access enabled") {
|
||||
MemcpyDeviceToDeviceShell<false, true>(std::bind(f, _1, _2, _3, hipMemcpyDeviceToDevice));
|
||||
}
|
||||
SECTION("Peer access disabled") {
|
||||
MemcpyDeviceToDeviceShell<false, false>(std::bind(f, _1, _2, _3, hipMemcpyDeviceToDevice));
|
||||
}
|
||||
}
|
||||
hipChannelFormatDesc channelDesc = hipCreateChannelDesc(sizeof(int)*8,
|
||||
0, 0, 0, formatKind);
|
||||
HIP_CHECK(hipMalloc3DArray(&devArray, &channelDesc, make_hipExtent(width,
|
||||
height, depth), hipArrayDefault));
|
||||
HIP_CHECK(hipMalloc3DArray(&devArray2, &channelDesc, make_hipExtent(width+1,
|
||||
height+1, depth+1), hipArrayDefault));
|
||||
memset(&myparms, 0x0, sizeof(hipMemcpy3DParms));
|
||||
myparms.srcPos = make_hipPos(0, 0, 0);
|
||||
myparms.dstPos = make_hipPos(0, 0, 0);
|
||||
myparms.extent = make_hipExtent(width , height, depth);
|
||||
myparms.srcPtr = make_hipPitchedPtr(hData, width * sizeof(int),
|
||||
width, height);
|
||||
myparms.dstArray = devArray;
|
||||
myparms.kind = hipMemcpyHostToDevice;
|
||||
|
||||
hipGraph_t graph;
|
||||
hipGraphNode_t memcpyNode;
|
||||
hipGraphExec_t graphExec;
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
HIP_CHECK(hipGraphAddMemcpyNode(&memcpyNode, graph, NULL, 0, &myparms));
|
||||
|
||||
// Instantiate the graph
|
||||
HIP_CHECK(hipGraphInstantiate(&graphExec, graph, NULL, NULL, 0));
|
||||
SECTION("Pass hGraphExec as nullptr") {
|
||||
ret = hipGraphExecMemcpyNodeSetParams(nullptr, memcpyNode, &myparms);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
SECTION("Pass node as nullptr") {
|
||||
ret = hipGraphExecMemcpyNodeSetParams(graphExec, nullptr, &myparms);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
SECTION("Pass pNodeParams as nullptr") {
|
||||
ret = hipGraphExecMemcpyNodeSetParams(graphExec, memcpyNode, nullptr);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
SECTION("Pass pNodeParams as empty structure object") {
|
||||
hipMemcpy3DParms temp{};
|
||||
ret = hipGraphExecMemcpyNodeSetParams(graphExec, memcpyNode, &temp);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
SECTION("API expects atleast one memcpy src pointer to be set") {
|
||||
hipMemcpy3DParms temp;
|
||||
memset(&temp, 0x0, sizeof(hipMemcpy3DParms));
|
||||
temp.srcPos = make_hipPos(0, 0, 0);
|
||||
temp.dstPos = make_hipPos(0, 0, 0);
|
||||
temp.extent = make_hipExtent(width , height, depth);
|
||||
temp.dstArray = devArray;
|
||||
temp.kind = hipMemcpyHostToDevice;
|
||||
ret = hipGraphExecMemcpyNodeSetParams(graphExec, memcpyNode, &temp);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
SECTION("API expects atleast one memcpy dst pointer to be set") {
|
||||
hipMemcpy3DParms temp;
|
||||
memset(&temp, 0x0, sizeof(hipMemcpy3DParms));
|
||||
temp.srcPos = make_hipPos(0, 0, 0);
|
||||
temp.dstPos = make_hipPos(0, 0, 0);
|
||||
temp.extent = make_hipExtent(width , height, depth);
|
||||
temp.srcPtr = make_hipPitchedPtr(hData, width * sizeof(int),
|
||||
width, height);
|
||||
temp.kind = hipMemcpyHostToDevice;
|
||||
ret = hipGraphExecMemcpyNodeSetParams(graphExec, memcpyNode, &temp);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
SECTION("Passing different element size for hipMemcpy3DParms::srcArray"
|
||||
"and hipMemcpy3DParms::dstArray") {
|
||||
hipMemcpy3DParms temp;
|
||||
memset(&temp, 0x0, sizeof(hipMemcpy3DParms));
|
||||
temp.srcPos = make_hipPos(0, 0, 0);
|
||||
temp.dstPos = make_hipPos(0, 0, 0);
|
||||
temp.extent = make_hipExtent(width , height, depth);
|
||||
temp.srcPtr = make_hipPitchedPtr(hData, width * sizeof(int),
|
||||
width, height);
|
||||
temp.kind = hipMemcpyHostToDevice;
|
||||
temp.srcArray = devArray;
|
||||
temp.dstArray = devArray2;
|
||||
ret = hipGraphExecMemcpyNodeSetParams(graphExec, memcpyNode, &temp);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
SECTION("Check with other graph node") {
|
||||
hipGraph_t graph1;
|
||||
hipGraphNode_t memcpyNode1;
|
||||
HIP_CHECK(hipGraphCreate(&graph1, 0));
|
||||
HIP_CHECK(hipGraphAddMemcpyNode(&memcpyNode1, graph1, NULL, 0, &myparms));
|
||||
ret = hipGraphExecMemcpyNodeSetParams(graphExec, memcpyNode1, &myparms);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
HIP_CHECK(hipGraphDestroy(graph1));
|
||||
}
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
HIP_CHECK(hipFreeArray(devArray));
|
||||
HIP_CHECK(hipFreeArray(devArray2));
|
||||
free(hData);
|
||||
}
|
||||
|
||||
/* Test verifies hipGraphExecMemcpyNodeSetParams API Functional scenarios.
|
||||
*/
|
||||
TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParams_Functional") {
|
||||
CHECK_IMAGE_SUPPORT
|
||||
|
||||
constexpr int XSIZE = 1024;
|
||||
int harray1D[XSIZE]{};
|
||||
int harray1Dres[XSIZE]{};
|
||||
constexpr int width{XSIZE};
|
||||
hipArray_t devArray1, devArray2;
|
||||
hipChannelFormatKind formatKind = hipChannelFormatKindSigned;
|
||||
hipMemcpy3DParms myparams;
|
||||
hipGraph_t graph;
|
||||
hipGraphNode_t memcpyNode;
|
||||
std::vector<hipGraphNode_t> dependencies;
|
||||
hipStream_t streamForGraph;
|
||||
hipGraphExec_t graphExec;
|
||||
|
||||
HIP_CHECK(hipStreamCreate(&streamForGraph));
|
||||
// Initialize 1D object
|
||||
for (int i = 0; i < XSIZE; i++) {
|
||||
harray1D[i] = i + 1;
|
||||
}
|
||||
|
||||
hipChannelFormatDesc channelDesc = hipCreateChannelDesc(sizeof(int)*8,
|
||||
0, 0, 0, formatKind);
|
||||
// Allocate 1D device array by passing depth(0), height(0)
|
||||
HIP_CHECK(hipMalloc3DArray(&devArray1, &channelDesc,
|
||||
make_hipExtent(width, 0, 0), hipArrayDefault));
|
||||
HIP_CHECK(hipMalloc3DArray(&devArray2, &channelDesc,
|
||||
make_hipExtent(width, 0, 0), hipArrayDefault));
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
|
||||
// Host to Device
|
||||
memset(&myparams, 0x0, sizeof(hipMemcpy3DParms));
|
||||
myparams.srcPos = make_hipPos(0, 0, 0);
|
||||
myparams.dstPos = make_hipPos(0, 0, 0);
|
||||
myparams.extent = make_hipExtent(width, 1, 1);
|
||||
myparams.srcPtr = make_hipPitchedPtr(harray1D, width * sizeof(int),
|
||||
width, 1);
|
||||
myparams.dstArray = devArray1;
|
||||
myparams.kind = hipMemcpyHostToDevice;
|
||||
|
||||
HIP_CHECK(hipGraphAddMemcpyNode(&memcpyNode, graph, nullptr, 0, &myparams));
|
||||
dependencies.push_back(memcpyNode);
|
||||
|
||||
// Device to Device
|
||||
memset(&myparams, 0x0, sizeof(hipMemcpy3DParms));
|
||||
myparams.srcPos = make_hipPos(0, 0, 0);
|
||||
myparams.dstPos = make_hipPos(0, 0, 0);
|
||||
myparams.srcArray = devArray1;
|
||||
myparams.dstArray = devArray2;
|
||||
myparams.extent = make_hipExtent(width, 1, 1);
|
||||
myparams.kind = hipMemcpyDeviceToDevice;
|
||||
|
||||
HIP_CHECK(hipGraphAddMemcpyNode(&memcpyNode, graph, dependencies.data(),
|
||||
dependencies.size(), &myparams));
|
||||
dependencies.clear();
|
||||
dependencies.push_back(memcpyNode);
|
||||
|
||||
// Device to host
|
||||
memset(&myparams, 0x0, sizeof(hipMemcpy3DParms));
|
||||
myparams.srcPos = make_hipPos(0, 0, 0);
|
||||
myparams.dstPos = make_hipPos(0, 0, 0);
|
||||
myparams.extent = make_hipExtent(width, 1, 1);
|
||||
myparams.dstPtr = make_hipPitchedPtr(harray1Dres, width * sizeof(int),
|
||||
width, 1);
|
||||
myparams.srcArray = devArray2;
|
||||
myparams.kind = hipMemcpyDeviceToHost;
|
||||
|
||||
HIP_CHECK(hipGraphAddMemcpyNode(&memcpyNode, graph, dependencies.data(),
|
||||
dependencies.size(), &myparams));
|
||||
|
||||
// Instantiate the graph
|
||||
HIP_CHECK(hipGraphInstantiate(&graphExec, graph, nullptr, nullptr, 0));
|
||||
|
||||
int harray1Dupdate[XSIZE]{};
|
||||
hipArray_t devArray3;
|
||||
HIP_CHECK(hipMalloc3DArray(&devArray3, &channelDesc,
|
||||
make_hipExtent(width, 0, 0), hipArrayDefault));
|
||||
|
||||
// D2H updated with different pointer harray1Dres -> harray1Dupdate
|
||||
memset(&myparams, 0x0, sizeof(hipMemcpy3DParms));
|
||||
myparams.srcPos = make_hipPos(0, 0, 0);
|
||||
myparams.dstPos = make_hipPos(0, 0, 0);
|
||||
myparams.extent = make_hipExtent(width, 1, 1);
|
||||
myparams.dstPtr = make_hipPitchedPtr(harray1Dupdate, width * sizeof(int),
|
||||
width, 1);
|
||||
myparams.srcArray = devArray2;
|
||||
myparams.kind = hipMemcpyDeviceToHost;
|
||||
|
||||
HIP_CHECK(hipGraphExecMemcpyNodeSetParams(graphExec, memcpyNode, &myparams));
|
||||
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, streamForGraph));
|
||||
HIP_CHECK(hipStreamSynchronize(streamForGraph));
|
||||
|
||||
// Validate result
|
||||
for (int i = 0; i < XSIZE; i++) {
|
||||
if (harray1D[i] != harray1Dupdate[i]) {
|
||||
INFO("harray1D: " << harray1D[i] << " harray1Dupdate: " <<
|
||||
harray1Dupdate[i] << " mismatch at : " << i);
|
||||
REQUIRE(false);
|
||||
SECTION("Device to device with default kind") {
|
||||
SECTION("Peer access enabled") {
|
||||
MemcpyDeviceToDeviceShell<false, true>(std::bind(f, _1, _2, _3, hipMemcpyDefault));
|
||||
}
|
||||
SECTION("Peer access disabled") {
|
||||
MemcpyDeviceToDeviceShell<false, false>(std::bind(f, _1, _2, _3, hipMemcpyDefault));
|
||||
}
|
||||
}
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
HIP_CHECK(hipStreamDestroy(streamForGraph));
|
||||
HIP_CHECK(hipFreeArray(devArray1));
|
||||
HIP_CHECK(hipFreeArray(devArray2));
|
||||
|
||||
// Disabled on AMD due to defect - EXSWHTEC-209
|
||||
#if 0
|
||||
SECTION("Host to host") {
|
||||
MemcpyHostToHostShell<false>(std::bind(f, _1, _2, _3, hipMemcpyHostToHost));
|
||||
}
|
||||
|
||||
SECTION("Host to host with default kind") {
|
||||
MemcpyHostToHostShell<false>(std::bind(f, _1, _2, _3, hipMemcpyDefault));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Disabled on AMD due to defect - EXSWHTEC-210
|
||||
#if 0
|
||||
SECTION("Device to host with default kind") {
|
||||
MemcpyDeviceToHostShell<false>(std::bind(f, _1, _2, _3, hipMemcpyDefault));
|
||||
}
|
||||
|
||||
SECTION("Host to device with default kind") {
|
||||
MemcpyHostToDeviceShell<false>(std::bind(f, _1, _2, _3, hipMemcpyDefault));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Verify API behaviour with invalid arguments:
|
||||
* -# pGraphExec is nullptr
|
||||
* -# node is nullptr
|
||||
* -# graph is nullptr
|
||||
* -# pDependencies is nullptr when numDependencies is not zero
|
||||
* -# A node in pDependencies originates from a different graph
|
||||
* -# numDependencies is invalid
|
||||
* -# A node is duplicated in pDependencies
|
||||
* -# dst is nullptr
|
||||
* -# src is nullptr
|
||||
* -# kind is an invalid enum value
|
||||
* -# count is zero
|
||||
* -# count is larger than dst allocation size
|
||||
* -# count is larger than src allocation size
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/graph/hipGraphAddMemcpyNode.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 5.2
|
||||
*/
|
||||
TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParams_Negative_Parameters") {
|
||||
using namespace std::placeholders;
|
||||
hipGraph_t graph = nullptr;
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
|
||||
int src[2] = {}, dst[2] = {};
|
||||
|
||||
auto params = GetMemcpy3DParms(make_hipPitchedPtr(dst, 0, sizeof(dst), 0), make_hipPos(0, 0, 0),
|
||||
make_hipPitchedPtr(src, 0, sizeof(src), 0), make_hipPos(0, 0, 0),
|
||||
make_hipExtent(sizeof(dst), 1, 1), hipMemcpyDefault);
|
||||
|
||||
hipGraphNode_t node = nullptr;
|
||||
HIP_CHECK(hipGraphAddMemcpyNode(&node, graph, nullptr, 0, ¶ms));
|
||||
|
||||
hipGraphExec_t graph_exec = nullptr;
|
||||
HIP_CHECK(hipGraphInstantiate(&graph_exec, graph, nullptr, nullptr, 0));
|
||||
|
||||
SECTION("pGraphExec == nullptr") {
|
||||
HIP_CHECK_ERROR(hipGraphExecMemcpyNodeSetParams(nullptr, node, ¶ms), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("node == nullptr") {
|
||||
HIP_CHECK_ERROR(hipGraphExecMemcpyNodeSetParams(graph_exec, nullptr, ¶ms),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
auto f = [&](void* dst, void* src, size_t count, hipMemcpyKind kind) {
|
||||
auto params = GetMemcpy3DParms(make_hipPitchedPtr(dst, 0, sizeof(dst), 0), make_hipPos(0, 0, 0),
|
||||
make_hipPitchedPtr(src, 0, sizeof(src), 0), make_hipPos(0, 0, 0),
|
||||
make_hipExtent(count, 1, 1), kind);
|
||||
return hipGraphExecMemcpyNodeSetParams(graph_exec, node, ¶ms);
|
||||
};
|
||||
MemcpyWithDirectionCommonNegativeTests(f, dst, src, sizeof(dst), hipMemcpyDefault);
|
||||
|
||||
SECTION("count == 0") {
|
||||
HIP_CHECK_ERROR(
|
||||
hipGraphExecMemcpyNodeSetParams1D(graph_exec, node, dst, src, 0, hipMemcpyDefault),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("count larger than dst allocation size") {
|
||||
LinearAllocGuard<int> dev_dst(LinearAllocs::hipMalloc, sizeof(int));
|
||||
params.dstPtr = make_hipPitchedPtr(dev_dst.ptr(), 0, sizeof(int), 0);
|
||||
HIP_CHECK_ERROR(hipGraphExecMemcpyNodeSetParams(graph_exec, node, ¶ms),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("count larger than src allocation size") {
|
||||
LinearAllocGuard<int> dev_src(LinearAllocs::hipMalloc, sizeof(int));
|
||||
params.dstPtr = make_hipPitchedPtr(dev_src.ptr(), 0, sizeof(int), 0);
|
||||
HIP_CHECK_ERROR(hipGraphExecMemcpyNodeSetParams(graph_exec, node, ¶ms),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
HIP_CHECK(hipGraphExecDestroy(graph_exec));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Verify that memcpy direction cannot be altered in an executable graph. The test is run for
|
||||
* all memcpy directions with appropriate memory allocations.
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/graph/hipGraphExecMemcpyNodeSetParams.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 5.2
|
||||
*/
|
||||
TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParams_Negative_Changing_Memcpy_Direction") {
|
||||
int host;
|
||||
LinearAllocGuard<int> dev(LinearAllocs::hipMalloc, sizeof(int));
|
||||
|
||||
const auto [dir, src, dst] =
|
||||
GENERATE_REF(std::make_tuple(hipMemcpyHostToHost, &host, &host),
|
||||
std::make_tuple(hipMemcpyHostToDevice, &host, dev.ptr()),
|
||||
std::make_tuple(hipMemcpyDeviceToHost, dev.ptr(), &host),
|
||||
std::make_tuple(hipMemcpyDeviceToDevice, dev.ptr(), dev.ptr()));
|
||||
|
||||
hipGraph_t graph = nullptr;
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
|
||||
auto params = GetMemcpy3DParms(make_hipPitchedPtr(dst, 0, sizeof(int), 0), make_hipPos(0, 0, 0),
|
||||
make_hipPitchedPtr(src, 0, sizeof(int), 0), make_hipPos(0, 0, 0),
|
||||
make_hipExtent(sizeof(int), 1, 1), dir);
|
||||
|
||||
hipGraphNode_t node = nullptr;
|
||||
HIP_CHECK(hipGraphAddMemcpyNode(&node, graph, nullptr, 0, ¶ms));
|
||||
|
||||
hipGraphExec_t graph_exec = nullptr;
|
||||
HIP_CHECK(hipGraphInstantiate(&graph_exec, graph, nullptr, nullptr, 0));
|
||||
|
||||
const auto set_dir = GENERATE(hipMemcpyHostToHost, hipMemcpyHostToDevice, hipMemcpyDeviceToHost,
|
||||
hipMemcpyDeviceToDevice, hipMemcpyDefault);
|
||||
if (dir == set_dir) {
|
||||
HIP_CHECK(hipGraphExecDestroy(graph_exec));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
return;
|
||||
}
|
||||
|
||||
params.kind = set_dir;
|
||||
HIP_CHECK_ERROR(hipGraphExecMemcpyNodeSetParams(graph_exec, node, ¶ms), hipErrorInvalidValue);
|
||||
|
||||
HIP_CHECK(hipGraphExecDestroy(graph_exec));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
}
|
||||
مرجع در شماره جدید
Block a user