SWDEV-491363 - [catch2][dtest] Added test cases for missed graph APIs
Change-Id: Ic740c52992b8d0a325f09b1db0adf599561e1a1d
[ROCm/hip-tests commit: e9177bd83b]
This commit is contained in:
@@ -85,13 +85,19 @@ set(TEST_SRC
|
||||
hipGraphAsyncUserObj.cc
|
||||
hipGraphExecBatchMemOpNodeSetParams.cc
|
||||
hipGraphAddBatchMemOpNode.cc
|
||||
hipGraphBatchMemOpNodeSetParams.cc)
|
||||
hipGraphBatchMemOpNodeSetParams.cc
|
||||
hipDrvGraphExecMemcpyNodeSetParams.cc
|
||||
hipDrvGraphAddMemFreeNode.cc)
|
||||
|
||||
if(HIP_PLATFORM MATCHES "amd")
|
||||
set(AMD_SRC
|
||||
hipStreamCaptureExtModuleLaunchKernel.cc
|
||||
hipStreamBeginCaptureToGraph.cc
|
||||
hipGetProcAddressGraphApis.cc
|
||||
# Below files are disbled in NVIDIA as PSDB builds are failing due to lower CUDA version.
|
||||
hipGraphExecNodeSetParams.cc
|
||||
hipGraphNodeSetParams.cc
|
||||
hipGraphExecGetFlags.cc
|
||||
)
|
||||
set(TEST_SRC ${TEST_SRC} ${AMD_SRC})
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
Copyright (c) 2024 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 <hip_test_common.hh>
|
||||
#include <resource_guards.hh>
|
||||
|
||||
/**
|
||||
* @addtogroup hipDrvGraphAddMemFreeNode hipDrvGraphAddMemFreeNode
|
||||
* @{
|
||||
* @ingroup GraphTest
|
||||
* `hipDrvGraphAddMemFreeNode ( hipGraphNode_t * phGraphNode,
|
||||
* hipGraph_t hGraph, const hipGraphNode_t * dependencies,
|
||||
* size_t numDependencies, hipDeviceptr_t dptr)'-
|
||||
* Creates a memory free node and adds it to a graph.
|
||||
*/
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Test to verify hipDrvGraphAddMemFreeNode behavior with invalid arguments:
|
||||
* -# Null graph node
|
||||
* -# Null graph
|
||||
* -# Invalid numDependencies for null list of dependencies
|
||||
* -# Invalid numDependencies and valid list for dependencies
|
||||
* -# Null dev_ptr
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - /unit/graph/hipDrvGraphAddMemFreeNode.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 6.4
|
||||
*/
|
||||
TEST_CASE("Unit_hipDrvGraphAddMemFreeNode_Negative_Params") {
|
||||
constexpr size_t N = 1024;
|
||||
hipGraph_t graph;
|
||||
hipGraphNode_t alloc_node, free_node;
|
||||
std::vector<hipGraphNode_t> dependencies;
|
||||
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
|
||||
hipMemAllocNodeParams alloc_param;
|
||||
memset(&alloc_param, 0, sizeof(alloc_param));
|
||||
alloc_param.bytesize = N;
|
||||
alloc_param.poolProps.allocType = hipMemAllocationTypePinned;
|
||||
alloc_param.poolProps.location.id = 0;
|
||||
alloc_param.poolProps.location.type = hipMemLocationTypeDevice;
|
||||
|
||||
HIP_CHECK(hipGraphAddMemAllocNode(&alloc_node, graph, nullptr,
|
||||
0, &alloc_param));
|
||||
REQUIRE(alloc_param.dptr != nullptr);
|
||||
|
||||
SECTION("Passing nullptr to graph node") {
|
||||
HIP_CHECK_ERROR(hipDrvGraphAddMemFreeNode(nullptr, graph,
|
||||
&alloc_node, 1, (hipDeviceptr_t)alloc_param.dptr),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("Passing nullptr to graph") {
|
||||
HIP_CHECK_ERROR(hipDrvGraphAddMemFreeNode(&free_node, nullptr,
|
||||
&alloc_node, 1, (hipDeviceptr_t)alloc_param.dptr),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("Pass invalid numDependencies") {
|
||||
HIP_CHECK_ERROR(hipDrvGraphAddMemFreeNode(&free_node, graph, nullptr,
|
||||
5, (hipDeviceptr_t)alloc_param.dptr),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("Pass invalid numDependencies and valid list for dependencies") {
|
||||
dependencies.push_back(alloc_node);
|
||||
HIP_CHECK_ERROR(hipDrvGraphAddMemFreeNode(&free_node, graph,
|
||||
dependencies.data(), dependencies.size() + 1,
|
||||
(hipDeviceptr_t)alloc_param.dptr),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("Passing nullptr to dev_ptr") {
|
||||
HIP_CHECK_ERROR(hipDrvGraphAddMemFreeNode(&alloc_node, graph,
|
||||
&alloc_node, 1, 0), hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
}
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - It will create memory alloation node and add to the graph then it
|
||||
* will create memory free node to free allocated memory and add to the graph.
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - /unit/graph/hipDrvGraphAddMemFreeNode.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 6.4
|
||||
*/
|
||||
TEST_CASE("Unit_hipDrvGraphAddMemFreeNode_Positive") {
|
||||
constexpr size_t N = 1024;
|
||||
hipGraph_t graph;
|
||||
hipGraphExec_t graphExec;
|
||||
hipCtx_t context;
|
||||
hipStream_t streamForGraph;
|
||||
int deviceid = 0;
|
||||
hipGraphNode_t node = nullptr, memFreeNode = nullptr;
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
HIP_CHECK(hipSetDevice(deviceid));
|
||||
HIP_CHECK(hipStreamCreate(&streamForGraph));
|
||||
HIP_CHECK(hipCtxCreate(&context, 0, deviceid));
|
||||
|
||||
hipMemAllocNodeParams alloc_param;
|
||||
memset(&alloc_param, 0, sizeof(alloc_param));
|
||||
alloc_param.bytesize = N;
|
||||
alloc_param.poolProps.allocType = hipMemAllocationTypePinned;
|
||||
alloc_param.poolProps.location.id = 0;
|
||||
alloc_param.poolProps.location.type = hipMemLocationTypeDevice;
|
||||
HIP_CHECK(hipGraphAddMemAllocNode(&node, graph, nullptr, 0, &alloc_param));
|
||||
REQUIRE(alloc_param.dptr != nullptr);
|
||||
|
||||
HIP_CHECK(hipDrvGraphAddMemFreeNode(&memFreeNode, graph, &node, 1,
|
||||
(hipDeviceptr_t)alloc_param.dptr));
|
||||
HIP_CHECK(hipGraphInstantiate(&graphExec, graph, nullptr, nullptr, 0));
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, 0));
|
||||
HIP_CHECK(hipStreamSynchronize(streamForGraph));
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
HIP_CHECK(hipStreamDestroy(streamForGraph));
|
||||
HIP_CHECK(hipCtxDestroy(context));
|
||||
}
|
||||
/**
|
||||
* End doxygen group GraphTest.
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
Copyright (c) 2024 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 <hip_test_common.hh>
|
||||
#include <numeric>
|
||||
|
||||
/**
|
||||
* @addtogroup hipDrvGraphExecMemcpyNodeSetParams hipDrvGraphExecMemcpyNodeSetParams
|
||||
* @{
|
||||
* @ingroup GraphTest
|
||||
* `hipDrvGraphExecMemcpyNodeSetParams((hipGraphExec_t hGraphExec,
|
||||
* hipGraphNode_t hNode, const HIP_MEMCPY3D *copyParams, hipCt_t ctx)` -
|
||||
* Sets the parameters for a memcpy node in the given graphExec
|
||||
*/
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Verify API behavior with invalid arguments:
|
||||
* -# graphExec is nullptr
|
||||
* -# node is nullptr
|
||||
*
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - /unit/graph/hipDrvGraphExecMemcpyNodeSetParams.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 6.4
|
||||
*/
|
||||
TEST_CASE("Unit_hipDrvGraphExecMemcpyNodeSetParams_Negative") {
|
||||
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, 2);
|
||||
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));
|
||||
SECTION("graphExec is nullptr") {
|
||||
HIP_CHECK_ERROR(hipDrvGraphExecMemcpyNodeSetParams(nullptr, node,
|
||||
&memCpy_params, context), hipErrorInvalidValue);
|
||||
}
|
||||
SECTION("node is nullptr") {
|
||||
HIP_CHECK_ERROR(hipDrvGraphExecMemcpyNodeSetParams(graphExec, nullptr,
|
||||
&memCpy_params, context), hipErrorInvalidValue);
|
||||
}
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
HIP_CHECK(hipStreamDestroy(streamForGraph));
|
||||
HIP_CHECK(hipCtxDestroy(context));
|
||||
}
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - It will verify soure data is copied destionation
|
||||
* after adding new memcpy node.
|
||||
* First will create and add mem copy node to graph.
|
||||
* Create another mem copy param node with new source data and
|
||||
* add to the graphExec using hipDrvGraphExecMemcpyNodeSetParams API and
|
||||
* lauch the graph. Compare soure and destination data.
|
||||
*
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - /unit/graph/hipDrvGraphExecMemcpyNodeSetParams.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 6.4
|
||||
*/
|
||||
|
||||
TEST_CASE("Unit_hipDrvGraphExecMemcpyNodeSetParams_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);
|
||||
// Host Vectors for source
|
||||
std::vector<int> C_h(numW);
|
||||
std::iota(C_h.begin(), C_h.end(), 10);
|
||||
|
||||
HIP_MEMCPY3D memCpy_params2{};
|
||||
memset(&memCpy_params2, 0x0, sizeof(HIP_MEMCPY3D));
|
||||
memCpy_params2.srcXInBytes = 0;
|
||||
memCpy_params2.srcY = 0;
|
||||
memCpy_params2.srcZ = 0;
|
||||
memCpy_params2.dstXInBytes = 0;
|
||||
memCpy_params2.dstY = 0;
|
||||
memCpy_params2.dstZ = 0;
|
||||
memCpy_params2.WidthInBytes = numW;
|
||||
memCpy_params2.Height = 1;
|
||||
memCpy_params2.Depth = 1;
|
||||
memCpy_params2.srcMemoryType = hipMemoryTypeHost;
|
||||
memCpy_params2.dstMemoryType = hipMemoryTypeHost;
|
||||
memCpy_params2.srcHost = C_h.data();
|
||||
memCpy_params2.srcPitch = numW;
|
||||
memCpy_params2.srcHeight = 1;
|
||||
memCpy_params2.dstHost = B_h.data();
|
||||
memCpy_params2.dstPitch = numW;
|
||||
memCpy_params2.dstHeight = 1;
|
||||
|
||||
HIP_CHECK(hipDrvGraphExecMemcpyNodeSetParams(graphExec, node,
|
||||
&memCpy_params2, context));
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, streamForGraph));
|
||||
HIP_CHECK(hipStreamSynchronize(streamForGraph));
|
||||
|
||||
REQUIRE(memcmp(C_h.data(), B_h.data(), numW) == 0);
|
||||
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
HIP_CHECK(hipStreamDestroy(streamForGraph));
|
||||
HIP_CHECK(hipCtxDestroy(context));
|
||||
}
|
||||
/**
|
||||
* End doxygen group GraphTest.
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -20,18 +20,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <hip_test_defgroups.hh>
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip_test_defgroups.hh>
|
||||
#include <memcpy3d_tests_common.hh>
|
||||
#include <numeric>
|
||||
|
||||
// hipDrvGraphAddMemcpyNode API is yet to be implemented in HIP runtime.
|
||||
#if 0
|
||||
/**
|
||||
* @addtogroup hipDrvGraphMemcpyNodeGetParams hipDrvGraphMemcpyNodeGetParams
|
||||
* @{
|
||||
* @ingroup GraphTest
|
||||
* `hipDrvGraphMemcpyNodeGetParams(hipGraphNode_t hNode, HIP_MEMCPY3D* nodeParams)` -
|
||||
* Gets a memcpy node's parameters
|
||||
* `hipDrvGraphMemcpyNodeGetParams(hipGraphNode_t hNode, HIP_MEMCPY3D*
|
||||
* nodeParams)` - Gets a memcpy node's parameters
|
||||
* ________________________
|
||||
* Test cases from other APIs:
|
||||
* - @ref Unit_hipDrvGraphMemcpyNodeSetParams_Positive_Basic
|
||||
@@ -63,37 +62,129 @@ TEST_CASE("Unit_hipDrvGraphMemcpyNodeGetParams_Negative_Parameters") {
|
||||
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);
|
||||
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, ¶ms), hipErrorInvalidValue);
|
||||
HIP_CHECK_ERROR(hipDrvGraphMemcpyNodeGetParams(nullptr, ¶ms),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("pNodeParams == nullptr") {
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
HIP_CHECK(hipDrvGraphAddMemcpyNode(&node, graph, nullptr, 0, ¶ms, context));
|
||||
HIP_CHECK_ERROR(hipDrvGraphMemcpyNodeGetParams(node, nullptr), hipErrorInvalidValue);
|
||||
HIP_CHECK(
|
||||
hipDrvGraphAddMemcpyNode(&node, graph, nullptr, 0, ¶ms, 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, ¶ms, context));
|
||||
HIP_CHECK(
|
||||
hipDrvGraphAddMemcpyNode(&node, graph, nullptr, 0, ¶ms, context));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
HIP_CHECK_ERROR(hipDrvGraphMemcpyNodeGetParams(node, ¶ms), hipErrorInvalidValue);
|
||||
HIP_CHECK_ERROR(hipDrvGraphMemcpyNodeGetParams(node, ¶ms),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
#endif
|
||||
|
||||
HIP_CHECK(hipCtxPopCurrent(&context));
|
||||
HIP_CHECK(hipCtxDestroy(context));
|
||||
}
|
||||
#endif // if 0
|
||||
|
||||
/**
|
||||
* End doxygen group GraphTest.
|
||||
* @}
|
||||
*/
|
||||
* 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
|
||||
*/
|
||||
|
||||
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(hipStreamDestroy(streamForGraph));
|
||||
HIP_CHECK(hipCtxPopCurrent(&context));
|
||||
HIP_CHECK(hipCtxDestroy(context));
|
||||
}
|
||||
/**
|
||||
* End doxygen group GraphTest.
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
Copyright (c) 2024 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 <hip_test_common.hh>
|
||||
#include <hip_test_checkers.hh>
|
||||
/**
|
||||
* @addtogroup hipGraphExecGetFlags hipGraphExecGetFlags
|
||||
* @{
|
||||
* @ingroup GraphTest
|
||||
* `hipGraphExecGetFlags(hipGraphExec_t graphExec,
|
||||
* unsigned long long *flags)` -
|
||||
* Return the flags on executable graph
|
||||
*/
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Verify API behavior with invalid arguments:
|
||||
* -# graphExec is nullptr
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/graph/hipGraphExecGetFlags.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 6.4
|
||||
*/
|
||||
TEST_CASE("Unit_hipGraphExecGetFlags_Negative") {
|
||||
hipGraphExec_t graphExec;
|
||||
unsigned long long flags; // NOLINT
|
||||
constexpr size_t Nbytes = 10 * sizeof(int);
|
||||
|
||||
hipGraphNode_t allocNodeA;
|
||||
hipMemAllocNodeParams allocParam;
|
||||
|
||||
hipGraph_t graph;
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
|
||||
memset(&allocParam, 0, sizeof(allocParam));
|
||||
allocParam.bytesize = Nbytes;
|
||||
allocParam.poolProps.allocType = hipMemAllocationTypePinned;
|
||||
allocParam.poolProps.location.id = 0;
|
||||
allocParam.poolProps.location.type = hipMemLocationTypeDevice;
|
||||
HIP_CHECK(hipGraphAddMemAllocNode(&allocNodeA, graph, nullptr,
|
||||
0, &allocParam));
|
||||
REQUIRE(allocParam.dptr != nullptr);
|
||||
|
||||
HIP_CHECK(hipGraphInstantiateWithFlags(&graphExec, graph,
|
||||
hipGraphInstantiateFlagAutoFreeOnLaunch));
|
||||
HIP_CHECK_ERROR(hipGraphExecGetFlags(nullptr, &flags),
|
||||
hipErrorInvalidValue);
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - This test will verify the flags what we set while initiating
|
||||
* graph will be matching with flags values getting from
|
||||
* the hipGraphExecGetFlags API call.
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/graph/hipGraphExecGetFlags.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 6.4
|
||||
*/
|
||||
TEST_CASE("Unit_hipGraphExecGetFlags_positive") {
|
||||
hipGraphExec_t graphExec;
|
||||
unsigned long long flags; // NOLINT
|
||||
hipGraph_t graph;
|
||||
constexpr size_t Nbytes = 10 * sizeof(int);
|
||||
|
||||
hipGraphNode_t allocNodeA;
|
||||
hipMemAllocNodeParams allocParam;
|
||||
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
|
||||
memset(&allocParam, 0, sizeof(allocParam));
|
||||
allocParam.bytesize = Nbytes;
|
||||
allocParam.poolProps.allocType = hipMemAllocationTypePinned;
|
||||
allocParam.poolProps.location.id = 0;
|
||||
allocParam.poolProps.location.type = hipMemLocationTypeDevice;
|
||||
|
||||
HIP_CHECK(hipGraphAddMemAllocNode(&allocNodeA, graph, nullptr,
|
||||
0, &allocParam));
|
||||
REQUIRE(allocParam.dptr != nullptr);
|
||||
|
||||
SECTION("flag is 0") {
|
||||
HIP_CHECK(hipGraphInstantiateWithFlags(&graphExec, graph,
|
||||
0));
|
||||
|
||||
HIP_CHECK(hipGraphExecGetFlags(graphExec, &flags));
|
||||
REQUIRE(flags == 0);
|
||||
}
|
||||
SECTION("flag is hipGraphInstantiateFlagAutoFreeOnLaunch") {
|
||||
HIP_CHECK(hipGraphInstantiateWithFlags(&graphExec, graph,
|
||||
hipGraphInstantiateFlagAutoFreeOnLaunch));
|
||||
|
||||
HIP_CHECK(hipGraphExecGetFlags(graphExec, &flags));
|
||||
REQUIRE(flags == hipGraphInstantiateFlagAutoFreeOnLaunch);
|
||||
}
|
||||
|
||||
// The below feature flags are not implemented
|
||||
// hipGraphInstantiateFlagUpload
|
||||
// hipGraphInstantiateFlagDeviceLaunch
|
||||
// hipGraphInstantiateFlagUseNodePriority
|
||||
#if 0
|
||||
SECTION("flag is hipGraphInstantiateFlagUpload") {
|
||||
HIP_CHECK(hipGraphInstantiateWithFlags(&graphExec, graph,
|
||||
hipGraphInstantiateFlagUpload));
|
||||
|
||||
HIP_CHECK(hipGraphExecGetFlags(graphExec, &flags));
|
||||
REQUIRE(flags == hipGraphInstantiateFlagUpload);
|
||||
}
|
||||
|
||||
SECTION("flag is hipGraphInstantiateFlagDeviceLaunch") {
|
||||
HIP_CHECK(hipGraphInstantiateWithFlags(&graphExec, graph,
|
||||
hipGraphInstantiateFlagDeviceLaunch));
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, 0));
|
||||
REQUIRE(flags == hipGraphInstantiateFlagDeviceLaunch);
|
||||
}
|
||||
SECTION("flag is hipGraphInstantiateFlagUseNodePriority") {
|
||||
HIP_CHECK(hipGraphInstantiateWithFlags(&graphExec, graph,
|
||||
hipGraphInstantiateFlagUseNodePriority));
|
||||
HIP_CHECK(hipGraphExecGetFlags(graphExec, &flags));
|
||||
REQUIRE(flags == hipGraphInstantiateFlagUseNodePriority);
|
||||
}
|
||||
#endif
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
}
|
||||
/**
|
||||
* End doxygen group GraphTest.
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -19,12 +19,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <hip_test_checkers.hh>
|
||||
#include <hip_test_common.hh>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
#include <hip_test_common.hh>
|
||||
#include <hip_test_checkers.hh>
|
||||
|
||||
#include "graph_memcpy_to_from_symbol_common.hh"
|
||||
|
||||
HIP_GRAPH_MEMCPY_FROM_SYMBOL_NODE_DEFINE_GLOBALS(char)
|
||||
@@ -38,24 +36,27 @@ HIP_GRAPH_MEMCPY_FROM_SYMBOL_NODE_DEFINE_ALTERNATE_GLOBALS(float)
|
||||
HIP_GRAPH_MEMCPY_FROM_SYMBOL_NODE_DEFINE_ALTERNATE_GLOBALS(double)
|
||||
|
||||
template <typename T>
|
||||
void GraphExecMemcpyToSymbolSetParamsShell(const void* symbol, const void* alt_symbol,
|
||||
size_t offset, const std::vector<T> set_values) {
|
||||
const auto f = [alt_symbol, is_arr = set_values.size() > 1](const void* symbol, void* src,
|
||||
size_t count, size_t offset,
|
||||
hipMemcpyKind direction) {
|
||||
void GraphExecMemcpyToSymbolSetParamsShell(const void *symbol,
|
||||
const void *alt_symbol,
|
||||
size_t offset,
|
||||
const std::vector<T> set_values) {
|
||||
const auto f = [alt_symbol, is_arr = set_values.size() > 1](
|
||||
const void *symbol, void *src, size_t count, size_t offset,
|
||||
hipMemcpyKind direction) {
|
||||
hipGraph_t graph = nullptr;
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
|
||||
hipGraphNode_t node = nullptr;
|
||||
HIP_CHECK(hipGraphAddMemcpyNodeToSymbol(
|
||||
&node, graph, nullptr, 0, alt_symbol, reinterpret_cast<T*>(src) + is_arr,
|
||||
count - is_arr * sizeof(T), offset + is_arr * sizeof(T), direction));
|
||||
&node, graph, nullptr, 0, alt_symbol,
|
||||
reinterpret_cast<T *>(src) + is_arr, count - is_arr * sizeof(T),
|
||||
offset + is_arr * sizeof(T), direction));
|
||||
|
||||
hipGraphExec_t graph_exec = nullptr;
|
||||
HIP_CHECK(hipGraphInstantiate(&graph_exec, graph, nullptr, nullptr, 0));
|
||||
|
||||
HIP_CHECK(hipGraphExecMemcpyNodeSetParamsToSymbol(graph_exec, node, symbol, src, count, offset,
|
||||
direction));
|
||||
HIP_CHECK(hipGraphExecMemcpyNodeSetParamsToSymbol(
|
||||
graph_exec, node, symbol, src, count, offset, direction));
|
||||
|
||||
HIP_CHECK(hipGraphLaunch(graph_exec, hipStreamPerThread));
|
||||
HIP_CHECK(hipStreamSynchronize(hipStreamPerThread));
|
||||
@@ -70,26 +71,30 @@ void GraphExecMemcpyToSymbolSetParamsShell(const void* symbol, const void* alt_s
|
||||
}
|
||||
|
||||
/**
|
||||
* @addtogroup hipGraphExecMemcpyNodeSetParamsToSymbol hipGraphExecMemcpyNodeSetParamsToSymbol
|
||||
* @addtogroup hipGraphExecMemcpyNodeSetParamsToSymbol
|
||||
* hipGraphExecMemcpyNodeSetParamsToSymbol
|
||||
* @{
|
||||
* @ingroup GraphTest
|
||||
* `hipGraphExecMemcpyNodeSetParamsToSymbol(hipGraphExec_t hGraphExec, hipGraphNode_t node,
|
||||
* const void *symbol, void *src, size_t count, size_t offset, hipMemcpyKind kind)` -
|
||||
* Sets the parameters for a memcpy node in the given graphExec to copy to a symbol on the device
|
||||
* `hipGraphExecMemcpyNodeSetParamsToSymbol(hipGraphExec_t hGraphExec,
|
||||
* hipGraphNode_t node, const void *symbol, void *src, size_t count, size_t
|
||||
* offset, hipMemcpyKind kind)` - Sets the parameters for a memcpy node in the
|
||||
* given graphExec to copy to a symbol on the device
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Verify that data is correctly copied to a symbol after node parameters are set following
|
||||
* node addition. A graph is constructed to which a MemcpyToSymbol node is added with valid but
|
||||
* incorrect parameters. After the graph is instantiated the parameters are updated to correct
|
||||
* values and the graph executed. After graph execution, a MemcpyFromSymbol is performed and the
|
||||
* copied values are compared against values known to have been copied to symbol memory previously.
|
||||
* The test is run for scalar, const scalar, array, and const array symbols of types char, int,
|
||||
* float and double. For array symbols, the test is repeated for zero and non-zero offset values.
|
||||
* Verification is performed for destination memory allocated on host and device.
|
||||
* Test source
|
||||
* - Verify that data is correctly copied to a symbol after node parameters
|
||||
* are set following node addition. A graph is constructed to which a
|
||||
* MemcpyToSymbol node is added with valid but incorrect parameters. After the
|
||||
* graph is instantiated the parameters are updated to correct values and the
|
||||
* graph executed. After graph execution, a MemcpyFromSymbol is performed and
|
||||
* the copied values are compared against values known to have been copied to
|
||||
* symbol memory previously. The test is run for scalar, const scalar, array,
|
||||
* and const array symbols of types char, int, float and double. For array
|
||||
* symbols, the test is repeated for zero and non-zero offset values.
|
||||
* Verification is performed for destination memory allocated on host and
|
||||
* device. Test source
|
||||
* ------------------------
|
||||
* - unit/graph/hipGraphExecMemcpyNodeSetParamsToSymbol.cc
|
||||
* Test requirements
|
||||
@@ -98,23 +103,23 @@ void GraphExecMemcpyToSymbolSetParamsShell(const void* symbol, const void* alt_s
|
||||
*/
|
||||
TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParamsToSymbol_Positive_Basic") {
|
||||
SECTION("char") {
|
||||
HIP_GRAPH_MEMCPY_NODE_SET_PARAMS_TO_FROM_SYMBOL_TEST(GraphExecMemcpyToSymbolSetParamsShell, 10,
|
||||
char);
|
||||
HIP_GRAPH_MEMCPY_NODE_SET_PARAMS_TO_FROM_SYMBOL_TEST(
|
||||
GraphExecMemcpyToSymbolSetParamsShell, 10, char);
|
||||
}
|
||||
|
||||
SECTION("int") {
|
||||
HIP_GRAPH_MEMCPY_NODE_SET_PARAMS_TO_FROM_SYMBOL_TEST(GraphExecMemcpyToSymbolSetParamsShell, 10,
|
||||
int);
|
||||
HIP_GRAPH_MEMCPY_NODE_SET_PARAMS_TO_FROM_SYMBOL_TEST(
|
||||
GraphExecMemcpyToSymbolSetParamsShell, 10, int);
|
||||
}
|
||||
|
||||
SECTION("float") {
|
||||
HIP_GRAPH_MEMCPY_NODE_SET_PARAMS_TO_FROM_SYMBOL_TEST(GraphExecMemcpyToSymbolSetParamsShell, 10,
|
||||
float);
|
||||
HIP_GRAPH_MEMCPY_NODE_SET_PARAMS_TO_FROM_SYMBOL_TEST(
|
||||
GraphExecMemcpyToSymbolSetParamsShell, 10, float);
|
||||
}
|
||||
|
||||
SECTION("double") {
|
||||
HIP_GRAPH_MEMCPY_NODE_SET_PARAMS_TO_FROM_SYMBOL_TEST(GraphExecMemcpyToSymbolSetParamsShell, 10,
|
||||
double);
|
||||
HIP_GRAPH_MEMCPY_NODE_SET_PARAMS_TO_FROM_SYMBOL_TEST(
|
||||
GraphExecMemcpyToSymbolSetParamsShell, 10, double);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,8 +137,8 @@ TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParamsToSymbol_Positive_Basic") {
|
||||
* -# kind is illogical (hipMemcpyDeviceToHost)
|
||||
* -# kind is an invalid enum value
|
||||
* -# Changing memcpy direction
|
||||
* -# Changing src to memory allocated on a different device than the original src
|
||||
* Test source
|
||||
* -# Changing src to memory allocated on a different device than the
|
||||
* original src Test source
|
||||
* ------------------------
|
||||
* - unit/graph/hipGraphExecMemcpyNodeSetParamsToSymbol.cc
|
||||
* Test requirements
|
||||
@@ -147,35 +152,37 @@ TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParamsToSymbol_Negative_Parameters") {
|
||||
|
||||
LinearAllocGuard<int> var(LinearAllocs::hipMalloc, sizeof(int));
|
||||
hipGraphNode_t node = nullptr;
|
||||
HIP_CHECK(hipGraphAddMemcpyNodeToSymbol(&node, graph, nullptr, 0, SYMBOL(int_device_var),
|
||||
var.ptr(), sizeof(*var.ptr()), 0, hipMemcpyDefault));
|
||||
HIP_CHECK(hipGraphAddMemcpyNodeToSymbol(
|
||||
&node, graph, nullptr, 0, SYMBOL(int_device_var), var.ptr(),
|
||||
sizeof(*var.ptr()), 0, hipMemcpyDefault));
|
||||
|
||||
hipGraphExec_t graph_exec = nullptr;
|
||||
HIP_CHECK(hipGraphInstantiate(&graph_exec, graph, nullptr, nullptr, 0));
|
||||
|
||||
SECTION("hGraphExec == nullptr") {
|
||||
HIP_CHECK_ERROR(
|
||||
hipGraphExecMemcpyNodeSetParamsToSymbol(nullptr, node, SYMBOL(int_device_var), var.ptr(),
|
||||
sizeof(*var.ptr()), 0, hipMemcpyDefault),
|
||||
hipErrorInvalidValue);
|
||||
HIP_CHECK_ERROR(hipGraphExecMemcpyNodeSetParamsToSymbol(
|
||||
nullptr, node, SYMBOL(int_device_var), var.ptr(),
|
||||
sizeof(*var.ptr()), 0, hipMemcpyDefault),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("node == nullptr") {
|
||||
HIP_CHECK_ERROR(
|
||||
hipGraphExecMemcpyNodeSetParamsToSymbol(graph_exec, nullptr, SYMBOL(int_device_var),
|
||||
var.ptr(), sizeof(*var.ptr()), 0, hipMemcpyDefault),
|
||||
hipErrorInvalidValue);
|
||||
HIP_CHECK_ERROR(hipGraphExecMemcpyNodeSetParamsToSymbol(
|
||||
graph_exec, nullptr, SYMBOL(int_device_var), var.ptr(),
|
||||
sizeof(*var.ptr()), 0, hipMemcpyDefault),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
MemcpyToSymbolCommonNegative(
|
||||
std::bind(hipGraphExecMemcpyNodeSetParamsToSymbol, graph_exec, node, _1, _2, _3, _4, _5),
|
||||
std::bind(hipGraphExecMemcpyNodeSetParamsToSymbol, graph_exec, node, _1,
|
||||
_2, _3, _4, _5),
|
||||
SYMBOL(int_device_var), var.ptr(), sizeof(*var.ptr()));
|
||||
|
||||
SECTION("Changing memcpy direction") {
|
||||
HIP_CHECK_ERROR(
|
||||
hipGraphExecMemcpyNodeSetParamsToSymbol(graph_exec, node, SYMBOL(int_device_var), var.ptr(),
|
||||
sizeof(*var.ptr()), 0, hipMemcpyHostToDevice),
|
||||
hipErrorInvalidValue);
|
||||
HIP_CHECK_ERROR(hipGraphExecMemcpyNodeSetParamsToSymbol(
|
||||
graph_exec, node, SYMBOL(int_device_var), var.ptr(),
|
||||
sizeof(*var.ptr()), 0, hipMemcpyHostToDevice),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("Changing src allocation device") {
|
||||
@@ -185,9 +192,9 @@ TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParamsToSymbol_Negative_Parameters") {
|
||||
HIP_CHECK(hipSetDevice(1));
|
||||
LinearAllocGuard<int> new_var(LinearAllocs::hipMalloc, sizeof(int));
|
||||
HIP_CHECK_ERROR(hipGraphExecMemcpyNodeSetParamsToSymbol(
|
||||
graph_exec, node, SYMBOL(int_device_var), new_var.ptr(),
|
||||
sizeof(*new_var.ptr()), 0, static_cast<hipMemcpyKind>(-1)),
|
||||
hipErrorInvalidValue);
|
||||
graph_exec, node, SYMBOL(int_device_var),
|
||||
new_var.ptr(), sizeof(*new_var.ptr()),
|
||||
0, hipMemcpyDefault), hipErrorInvalidValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,6 +203,6 @@ TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParamsToSymbol_Negative_Parameters") {
|
||||
}
|
||||
|
||||
/**
|
||||
* End doxygen group GraphTest.
|
||||
* @}
|
||||
*/
|
||||
* End doxygen group GraphTest.
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
Copyright (c) 2024 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 <hip_test_checkers.hh>
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
/**
|
||||
* @addtogroup hipGraphExecNodeSetParams hipGraphExecNodeSetParams
|
||||
* @{
|
||||
* @ingroup GraphTest
|
||||
* `hipGraphExecNodeSetParams(hipGraphExec_t graphExec, hipGraphNode_t node,
|
||||
* hipGraphNodeParams *nodeParams)` -
|
||||
* Updates parameters of a created node on executable graph
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Verify API behavior with invalid arguments:
|
||||
* -# gGraphExec is nullptr
|
||||
* -# node is nullptr
|
||||
* -# nodeParams is nullptr
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/graph/hipGraphExecNodeSetParams.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 6.4
|
||||
*/
|
||||
TEST_CASE("Unit_hipGraphExecNodeSetParams_Negative_Parameters") {
|
||||
hipGraph_t graph;
|
||||
hipGraphExec_t graphExec;
|
||||
hipGraphNode_t node;
|
||||
hipGraphNodeParams node_params = {};
|
||||
char *A_d;
|
||||
size_t Nbytes = 10 * sizeof(char);
|
||||
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
HIP_CHECK(hipMalloc(&A_d, Nbytes));
|
||||
node_params.type = hipGraphNodeTypeMemset;
|
||||
node_params.memset.dst = A_d;
|
||||
node_params.memset.elementSize = sizeof(char);
|
||||
node_params.memset.width = 10;
|
||||
node_params.memset.height = 1;
|
||||
node_params.memset.pitch = 10;
|
||||
node_params.memset.value = 99;
|
||||
|
||||
HIP_CHECK(hipGraphAddNode(&node, graph, nullptr, 0, &node_params));
|
||||
HIP_CHECK(hipGraphInstantiate(&graphExec, graph, nullptr, nullptr, 0));
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, 0));
|
||||
|
||||
SECTION("hGraphExec == nullptr") {
|
||||
HIP_CHECK_ERROR(
|
||||
hipGraphExecNodeSetParams(nullptr, node, &node_params),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("node == nullptr") {
|
||||
HIP_CHECK_ERROR(
|
||||
hipGraphExecNodeSetParams(graphExec, nullptr, &node_params),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("node params == nullptr") {
|
||||
HIP_CHECK_ERROR(hipGraphExecNodeSetParams(graphExec, node, nullptr),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
HIP_CHECK(hipFree(A_d));
|
||||
}
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - This will verify the new node param values are successfully
|
||||
* copied to graph node, after launching graphExec
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/graph/hipGraphExecNodeSetParams.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 6.4
|
||||
*/
|
||||
TEST_CASE("Unit_hipGraphExecNodeSetParams_Positive") {
|
||||
hipGraph_t graph;
|
||||
hipGraphExec_t graphExec;
|
||||
hipGraphNode_t node;
|
||||
hipGraphNodeParams node_params = {};
|
||||
char *A_d = nullptr, *A_h = nullptr;
|
||||
size_t Nbytes = 10 * sizeof(char);
|
||||
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
HIP_CHECK(hipMalloc(&A_d, Nbytes));
|
||||
node_params.type = hipGraphNodeTypeMemset;
|
||||
node_params.memset.dst = A_d;
|
||||
node_params.memset.elementSize = sizeof(char);
|
||||
node_params.memset.width = 10;
|
||||
node_params.memset.height = 1;
|
||||
node_params.memset.pitch = 10;
|
||||
node_params.memset.value = 99;
|
||||
|
||||
HIP_CHECK(hipGraphAddNode(&node, graph, nullptr, 0, &node_params));
|
||||
HIP_CHECK(hipGraphInstantiate(&graphExec, graph, nullptr, nullptr, 0));
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, 0));
|
||||
HIP_CHECK(hipStreamSynchronize(0));
|
||||
A_h = reinterpret_cast<char*>(malloc(Nbytes));
|
||||
HIP_CHECK(hipMemcpy(A_h, A_d, Nbytes, hipMemcpyDeviceToHost));
|
||||
for (int i = 0; i < 10; i++) {
|
||||
REQUIRE(A_h[i] == 99);
|
||||
}
|
||||
|
||||
hipGraphNodeParams node_params2 = {};
|
||||
node_params2.type = hipGraphNodeTypeMemset;
|
||||
node_params2.memset.dst = A_d;
|
||||
node_params2.memset.elementSize = sizeof(char);
|
||||
node_params2.memset.width = 10;
|
||||
node_params2.memset.height = 1;
|
||||
node_params2.memset.pitch = 10;
|
||||
node_params2.memset.value = 110;
|
||||
|
||||
HIP_CHECK(hipGraphExecNodeSetParams(graphExec, node, &node_params2));
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, 0));
|
||||
HIP_CHECK(hipStreamSynchronize(0));
|
||||
HIP_CHECK(hipMemcpy(A_h, A_d, Nbytes, hipMemcpyDeviceToHost));
|
||||
for (int i = 0; i < 10; i++) {
|
||||
REQUIRE(A_h[i] == 110);
|
||||
}
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
HIP_CHECK(hipFree(A_d));
|
||||
free(A_h);
|
||||
}
|
||||
/**
|
||||
* End doxygen group GraphTest.
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
Copyright (c) 2024 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 <hip_test_checkers.hh>
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
/**
|
||||
* @addtogroup hipGraphNodeSetParams hipGraphNodeSetParams
|
||||
* @{
|
||||
* @ingroup GraphTest
|
||||
* `hipGraphNodeSetParams(hipGraphNode_t node,
|
||||
* hipGraphNodeParams *nodeParams)` -
|
||||
* Updates parameters of a graph’s node
|
||||
*/
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - Verify API behavior with invalid arguments:
|
||||
* -# node is nullptr
|
||||
* -# nodeParams is nullptr
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/graph/hipGraphNodeSetParams.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 6.4
|
||||
*/
|
||||
TEST_CASE("Unit_hipGraphNodeSetParams_Negative_Parameters") {
|
||||
hipGraph_t graph;
|
||||
hipGraphExec_t graphExec;
|
||||
hipGraphNode_t node;
|
||||
hipGraphNodeParams node_params = {};
|
||||
char *A_d;
|
||||
char *A_h;
|
||||
size_t N = 10;
|
||||
size_t Nbytes = N * sizeof(char);
|
||||
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
HIP_CHECK(hipMalloc(&A_d, Nbytes));
|
||||
node_params.type = hipGraphNodeTypeMemset;
|
||||
node_params.memset.dst = A_d;
|
||||
node_params.memset.elementSize = sizeof(char);
|
||||
node_params.memset.width = N;
|
||||
node_params.memset.height = 1;
|
||||
node_params.memset.pitch = N;
|
||||
node_params.memset.value = 99;
|
||||
|
||||
HIP_CHECK(hipGraphAddNode(&node, graph, nullptr, 0, &node_params));
|
||||
HIP_CHECK(hipGraphInstantiate(&graphExec, graph, nullptr, nullptr, 0));
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, 0));
|
||||
A_h = reinterpret_cast<char *>(malloc(Nbytes));
|
||||
HIP_CHECK(hipMemcpy(A_h, A_d, Nbytes, hipMemcpyDeviceToHost));
|
||||
hipGraphNodeParams node_params2 = {};
|
||||
node_params2.type = hipGraphNodeTypeMemset;
|
||||
node_params2.memset.dst = A_d;
|
||||
node_params2.memset.elementSize = sizeof(char);
|
||||
node_params2.memset.width = N;
|
||||
node_params2.memset.height = 1;
|
||||
node_params2.memset.pitch = N;
|
||||
node_params2.memset.value = 110;
|
||||
|
||||
SECTION("node == nullptr") {
|
||||
HIP_CHECK_ERROR(hipGraphNodeSetParams(nullptr, &node_params2),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
SECTION("nodeParams == nullptr") {
|
||||
HIP_CHECK_ERROR(hipGraphNodeSetParams(node, nullptr),
|
||||
hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Description
|
||||
* ------------------------
|
||||
* - This will verify the new node param values are successfully
|
||||
* copied to graph node
|
||||
* Test source
|
||||
* ------------------------
|
||||
* - unit/graph/hipGraphNodeSetParams.cc
|
||||
* Test requirements
|
||||
* ------------------------
|
||||
* - HIP_VERSION >= 6.4
|
||||
*/
|
||||
TEST_CASE("Unit_hipGraphNodeSetParams_Positive") {
|
||||
hipGraph_t graph;
|
||||
hipGraphExec_t graphExec;
|
||||
hipGraphNode_t node;
|
||||
hipGraphNodeParams node_params = {};
|
||||
char *A_d, *A_h = nullptr;
|
||||
size_t N = 10;
|
||||
size_t Nbytes = N * sizeof(char);
|
||||
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
HIP_CHECK(hipMalloc(&A_d, Nbytes));
|
||||
node_params.type = hipGraphNodeTypeMemset;
|
||||
node_params.memset.dst = A_d;
|
||||
node_params.memset.elementSize = sizeof(char);
|
||||
node_params.memset.width = N;
|
||||
node_params.memset.height = 1;
|
||||
node_params.memset.pitch = N;
|
||||
node_params.memset.value = 99;
|
||||
|
||||
HIP_CHECK(hipGraphAddNode(&node, graph, nullptr, 0, &node_params));
|
||||
HIP_CHECK(hipGraphInstantiate(&graphExec, graph, nullptr, nullptr, 0));
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, 0));
|
||||
HIP_CHECK(hipStreamSynchronize(0));
|
||||
A_h = reinterpret_cast<char*>(malloc(Nbytes));
|
||||
HIP_CHECK(hipMemcpy(A_h, A_d, Nbytes, hipMemcpyDeviceToHost));
|
||||
for (int i = 0; i < N; i++) {
|
||||
REQUIRE(A_h[i] == 99);
|
||||
}
|
||||
|
||||
hipGraphNodeParams node_params2 = {};
|
||||
node_params2.type = hipGraphNodeTypeMemset;
|
||||
node_params2.memset.dst = A_d;
|
||||
node_params2.memset.elementSize = sizeof(char);
|
||||
node_params2.memset.width = N;
|
||||
node_params2.memset.height = 1;
|
||||
node_params2.memset.pitch = N;
|
||||
node_params2.memset.value = 110;
|
||||
|
||||
HIP_CHECK(hipGraphNodeSetParams(node, &node_params2));
|
||||
HIP_CHECK(hipGraphInstantiate(&graphExec, graph, nullptr, nullptr, 0));
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, 0));
|
||||
HIP_CHECK(hipStreamSynchronize(0));
|
||||
HIP_CHECK(hipMemcpy(A_h, A_d, Nbytes, hipMemcpyDeviceToHost));
|
||||
for (int i = 0; i < N; i++) {
|
||||
REQUIRE(A_h[i] == 110);
|
||||
}
|
||||
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
HIP_CHECK(hipFree(A_d));
|
||||
free(A_h);
|
||||
}
|
||||
|
||||
/**
|
||||
* End doxygen group GraphTest.
|
||||
* @}
|
||||
*/
|
||||
Reference in New Issue
Block a user