Merge 'develop' into 'amd-staging'
Change-Id: I9ed9e4a3a7031f670ca2f7614097d05c4643447e
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
Copyright (c) 2022 - 2023 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
|
||||
@@ -232,8 +229,10 @@ TEST_CASE("Unit_hipGetDeviceAttribute_CheckAttrValues") {
|
||||
hipDeviceAttributeEccEnabled,
|
||||
props.ECCEnabled));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeTexturePitchAlignment,
|
||||
props.texturePitchAlignment));
|
||||
hipDeviceAttributeTexturePitchAlignment,
|
||||
props.texturePitchAlignment));
|
||||
HIP_CHECK(test_hipDeviceGetAttribute(deviceId,
|
||||
hipDeviceAttributeUnifiedAddressing, 1/*true*/));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -375,7 +374,7 @@ using AttributeToStringMap = std::array<std::pair<hipDeviceAttribute_t, const ch
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr AttributeToStringMap<56> kCommonAttributes{{
|
||||
constexpr AttributeToStringMap<57> kCommonAttributes{{
|
||||
{hipDeviceAttributeEccEnabled, "hipDeviceAttributeEccEnabled"},
|
||||
{hipDeviceAttributeCanMapHostMemory, "hipDeviceAttributeCanMapHostMemory"},
|
||||
{hipDeviceAttributeClockRate, "hipDeviceAttributeClockRate"},
|
||||
@@ -436,12 +435,13 @@ constexpr AttributeToStringMap<56> kCommonAttributes{{
|
||||
{hipDeviceAttributeTotalGlobalMem, "hipDeviceAttributeTotalGlobalMem"},
|
||||
{hipDeviceAttributeWarpSize, "hipDeviceAttributeWarpSize"},
|
||||
{hipDeviceAttributeMemoryPoolsSupported, "hipDeviceAttributeMemoryPoolsSupported"},
|
||||
{hipDeviceAttributeUnifiedAddressing, "hipDeviceAttributeUnifiedAddressing"},
|
||||
{hipDeviceAttributeVirtualMemoryManagementSupported,
|
||||
"hipDeviceAttributeVirtualMemoryManagementSupported"}
|
||||
}};
|
||||
|
||||
#if HT_NVIDIA
|
||||
constexpr AttributeToStringMap<34> kCudaOnlyAttributes{
|
||||
constexpr AttributeToStringMap<33> kCudaOnlyAttributes{
|
||||
{{hipDeviceAttributeAccessPolicyMaxWindowSize, "hipDeviceAttributeAccessPolicyMaxWindowSize"},
|
||||
{hipDeviceAttributeAsyncEngineCount, "hipDeviceAttributeAsyncEngineCount"},
|
||||
{hipDeviceAttributeCanUseHostPointerForRegisteredMem,
|
||||
@@ -476,7 +476,6 @@ constexpr AttributeToStringMap<34> kCudaOnlyAttributes{
|
||||
{hipDeviceAttributeStreamPrioritiesSupported, "hipDeviceAttributeStreamPrioritiesSupported"},
|
||||
{hipDeviceAttributeSurfaceAlignment, "hipDeviceAttributeSurfaceAlignment"},
|
||||
{hipDeviceAttributeTccDriver, "hipDeviceAttributeTccDriver"},
|
||||
{hipDeviceAttributeUnifiedAddressing, "hipDeviceAttributeUnifiedAddressing"},
|
||||
{hipDeviceAttributeUuid, "hipDeviceAttributeUuid"}}};
|
||||
#endif
|
||||
|
||||
@@ -555,4 +554,4 @@ TEST_CASE("Print_Out_Attributes") {
|
||||
#endif
|
||||
|
||||
std::flush(std::cout);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ set(TEST_SRC
|
||||
hipGraphDestroy.cc
|
||||
hipGraphExecDestroy.cc
|
||||
hipGraphUpload.cc
|
||||
hipGraphKernelNodeCopyAttributes.cc
|
||||
)
|
||||
|
||||
hip_add_exe_to_target(NAME GraphsTest
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
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 <hip_test_common.hh>
|
||||
#include <hip_test_checkers.hh>
|
||||
#include <hip_test_kernels.hh>
|
||||
|
||||
/**
|
||||
* Functional Test for API - hipGraphKernelNodeCopyAttributes
|
||||
- Create graph with 2 kernel node.
|
||||
Copy the attribute from 1st kernel node to 2nd kernel node.
|
||||
*/
|
||||
|
||||
TEST_CASE("Unit_hipGraphKernelNodeCopyAttributes_Functional") {
|
||||
constexpr size_t N = 1024;
|
||||
constexpr size_t Nbytes = N * sizeof(int);
|
||||
constexpr auto blocksPerCU = 6; // to hide latency
|
||||
constexpr auto threadsPerBlock = 256;
|
||||
hipGraph_t graph;
|
||||
hipGraphNode_t memcpyNode, kNode;
|
||||
hipKernelNodeParams kNodeParams{};
|
||||
hipStream_t stream;
|
||||
int *A_d, *B_d, *C_d;
|
||||
int *A_h, *B_h, *C_h;
|
||||
std::vector<hipGraphNode_t> dependencies;
|
||||
hipGraphExec_t graphExec;
|
||||
size_t NElem{N};
|
||||
|
||||
HIP_CHECK(hipStreamCreate(&stream));
|
||||
HipTest::initArrays(&A_d, &B_d, &C_d, &A_h, &B_h, &C_h, N, false);
|
||||
unsigned blocks = HipTest::setNumBlocks(blocksPerCU, threadsPerBlock, N);
|
||||
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
HIP_CHECK(hipGraphAddMemcpyNode1D(&memcpyNode, graph, nullptr, 0, A_d, A_h,
|
||||
Nbytes, hipMemcpyHostToDevice));
|
||||
dependencies.push_back(memcpyNode);
|
||||
HIP_CHECK(hipGraphAddMemcpyNode1D(&memcpyNode, graph, nullptr, 0, B_d, B_h,
|
||||
Nbytes, hipMemcpyHostToDevice));
|
||||
dependencies.push_back(memcpyNode);
|
||||
|
||||
void* kernelArgs[] = {&A_d, &B_d, &C_d, reinterpret_cast<void *>(&NElem)};
|
||||
kNodeParams.func = reinterpret_cast<void *>(HipTest::vectorADD<int>);
|
||||
kNodeParams.gridDim = dim3(blocks);
|
||||
kNodeParams.blockDim = dim3(threadsPerBlock);
|
||||
kNodeParams.sharedMemBytes = 0;
|
||||
kNodeParams.kernelParams = reinterpret_cast<void**>(kernelArgs);
|
||||
kNodeParams.extra = nullptr;
|
||||
HIP_CHECK(hipGraphAddKernelNode(&kNode, graph, dependencies.data(),
|
||||
dependencies.size(), &kNodeParams));
|
||||
dependencies.clear();
|
||||
dependencies.push_back(kNode);
|
||||
HIP_CHECK(hipGraphAddMemcpyNode1D(&memcpyNode, graph, dependencies.data(),
|
||||
dependencies.size(), C_h, C_d,
|
||||
Nbytes, hipMemcpyDeviceToHost));
|
||||
|
||||
hipGraphNode_t kNode2;
|
||||
|
||||
HIP_CHECK(hipGraphAddKernelNode(&kNode2, graph, nullptr, 0, &kNodeParams));
|
||||
HIP_CHECK(hipGraphKernelNodeCopyAttributes(kNode2, kNode));
|
||||
|
||||
// Instantiate and launch the graph
|
||||
HIP_CHECK(hipGraphInstantiate(&graphExec, graph, NULL, NULL, 0));
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
|
||||
// Verify graph execution result
|
||||
HipTest::checkVectorADD<int>(A_h, B_h, C_h, N);
|
||||
|
||||
HipTest::freeArrays(A_d, B_d, C_d, A_h, B_h, C_h, false);
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
}
|
||||
|
||||
/**
|
||||
Negative Test for API - hipGraphKernelNodeCopyAttributes
|
||||
1) Pass source kernel node as nullptr for copy attribute api
|
||||
2) Pass destination kernel node as nullptr for copy attribute api
|
||||
3) Pass source kernel node as Uninitialize for copy attribute api
|
||||
4) Pass dest kernel node as Uninitialize for copy attribute api
|
||||
*/
|
||||
|
||||
TEST_CASE("Unit_hipGraphKernelNodeCopyAttributes_Attribute_Negative") {
|
||||
constexpr size_t N = 1024;
|
||||
constexpr size_t Nbytes = N * sizeof(int);
|
||||
constexpr auto blocksPerCU = 6; // to hide latency
|
||||
constexpr auto threadsPerBlock = 256;
|
||||
hipGraph_t graph;
|
||||
hipGraphNode_t memcpyNode, kNode, kNode_2;
|
||||
hipKernelNodeParams kNodeParams{};
|
||||
hipStream_t streamForGraph;
|
||||
int *A_d, *B_d, *C_d;
|
||||
int *A_h, *B_h, *C_h;
|
||||
std::vector<hipGraphNode_t> dependencies;
|
||||
size_t NElem{N};
|
||||
hipError_t ret;
|
||||
|
||||
HIP_CHECK(hipStreamCreate(&streamForGraph));
|
||||
HipTest::initArrays(&A_d, &B_d, &C_d, &A_h, &B_h, &C_h, N, false);
|
||||
unsigned blocks = HipTest::setNumBlocks(blocksPerCU, threadsPerBlock, N);
|
||||
|
||||
HIP_CHECK(hipGraphCreate(&graph, 0));
|
||||
HIP_CHECK(hipGraphAddMemcpyNode1D(&memcpyNode, graph, nullptr, 0, A_d, A_h,
|
||||
Nbytes, hipMemcpyHostToDevice));
|
||||
dependencies.push_back(memcpyNode);
|
||||
HIP_CHECK(hipGraphAddMemcpyNode1D(&memcpyNode, graph, nullptr, 0, B_d, B_h,
|
||||
Nbytes, hipMemcpyHostToDevice));
|
||||
dependencies.push_back(memcpyNode);
|
||||
|
||||
void* kernelArgs[] = {&A_d, &B_d, &C_d, reinterpret_cast<void *>(&NElem)};
|
||||
kNodeParams.func = reinterpret_cast<void *>(HipTest::vectorADD<int>);
|
||||
kNodeParams.gridDim = dim3(blocks);
|
||||
kNodeParams.blockDim = dim3(threadsPerBlock);
|
||||
kNodeParams.sharedMemBytes = 0;
|
||||
kNodeParams.kernelParams = reinterpret_cast<void**>(kernelArgs);
|
||||
kNodeParams.extra = nullptr;
|
||||
HIP_CHECK(hipGraphAddKernelNode(&kNode, graph, dependencies.data(),
|
||||
dependencies.size(), &kNodeParams));
|
||||
dependencies.clear();
|
||||
dependencies.push_back(kNode);
|
||||
HIP_CHECK(hipGraphAddMemcpyNode1D(&memcpyNode, graph, dependencies.data(),
|
||||
dependencies.size(), C_h, C_d,
|
||||
Nbytes, hipMemcpyDeviceToHost));
|
||||
HIP_CHECK(hipGraphAddKernelNode(&kNode_2, graph, nullptr, 0, &kNodeParams));
|
||||
|
||||
SECTION("Pass source kernel node as nullptr for copy attribute api") {
|
||||
ret = hipGraphKernelNodeCopyAttributes(nullptr, kNode);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
SECTION("Pass destination kernel node as nullptr for copy attribute api") {
|
||||
ret = hipGraphKernelNodeCopyAttributes(kNode_2, nullptr);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
SECTION("Pass source kernel node as Uninitialize for copy attribute api") {
|
||||
hipGraphNode_t kNodeUninit{};
|
||||
ret = hipGraphKernelNodeCopyAttributes(kNodeUninit, kNode);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
SECTION("Pass dest kernel node as Uninitialize for copy attribute api") {
|
||||
hipGraphNode_t kNodeUninit{};
|
||||
ret = hipGraphKernelNodeCopyAttributes(kNode_2, kNodeUninit);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
|
||||
HipTest::freeArrays(A_d, B_d, C_d, A_h, B_h, C_h, false);
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
HIP_CHECK(hipStreamDestroy(streamForGraph));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Copyright (c) 2023 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
|
||||
@@ -156,20 +156,22 @@ TEST_CASE("Unit_hipGraphNodeGetEnabled_Functional_Basic") {
|
||||
Negative Functional Test for API - hipGraphNodeGetEnabled
|
||||
6) Pass hNode from different graph and verify
|
||||
7) Create graphExec and then add one more new node to the graph verify
|
||||
8) Pass hNode a deleted node from same graph where exec was created
|
||||
9) Create graphExec and then delete the graph and verify a node
|
||||
10) Create graphExec and then delete the graphExec and verify a node
|
||||
8) Pass hNode as clonedGraph node and exec as graphExec
|
||||
9) Pass graphExec as clonedGraphExec and hNode as graph node
|
||||
10) Pass hNode a deleted node from same graph where exec was created
|
||||
11) Create graphExec and then delete the graph and verify a node
|
||||
12) Create graphExec and then delete the graphExec and verify a node
|
||||
*/
|
||||
|
||||
TEST_CASE("Unit_hipGraphNodeGetEnabled_Negative_Functional") {
|
||||
constexpr size_t Nbytes = N * sizeof(int);
|
||||
constexpr auto blocksPerCU = 6; // to hide latency
|
||||
constexpr auto threadsPerBlock = 256;
|
||||
hipGraph_t graph, graph2;
|
||||
hipGraphNode_t memcpy_A, memcpy_B, memcpy_A2, memcpy_C, kNodeAdd;
|
||||
hipGraph_t graph, graph2, clonedGraph;
|
||||
hipGraphNode_t memcpy_A, memcpy_A_C, memcpy_B, memcpy_A2, memcpy_C, kNodeAdd;
|
||||
hipKernelNodeParams kNodeParams{};
|
||||
int *A_d, *B_d, *C_d, *A_h, *B_h, *C_h;
|
||||
hipGraphExec_t graphExec, graphExec2;
|
||||
hipGraphExec_t graphExec, graphExec2, clonedGraphExec;
|
||||
size_t NElem{N};
|
||||
unsigned int isEnabled;
|
||||
hipError_t ret;
|
||||
@@ -198,6 +200,11 @@ TEST_CASE("Unit_hipGraphNodeGetEnabled_Negative_Functional") {
|
||||
HIP_CHECK(hipGraphInstantiate(&graphExec, graph, NULL, NULL, 0));
|
||||
HIP_CHECK(hipGraphInstantiate(&graphExec2, graph, NULL, NULL, 0));
|
||||
|
||||
HIP_CHECK(hipGraphClone(&clonedGraph, graph));
|
||||
HIP_CHECK(hipGraphInstantiate(&clonedGraphExec, clonedGraph,
|
||||
nullptr, nullptr, 0));
|
||||
HIP_CHECK(hipGraphNodeFindInClone(&memcpy_A_C, memcpy_A, clonedGraph));
|
||||
|
||||
HIP_CHECK(hipGraphAddMemcpyNode1D(&memcpy_C, graph, nullptr, 0, C_h, C_d,
|
||||
Nbytes, hipMemcpyDeviceToHost));
|
||||
HIP_CHECK(hipGraphAddDependencies(graph, &kNodeAdd, &memcpy_C, 1));
|
||||
@@ -236,6 +243,14 @@ TEST_CASE("Unit_hipGraphNodeGetEnabled_Negative_Functional") {
|
||||
ret = hipGraphNodeGetEnabled(graphExec, memcpy_C, &isEnabled);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
SECTION("Pass hNode as clonedGraph node and exec as graphExec") {
|
||||
ret = hipGraphNodeGetEnabled(graphExec, memcpy_A_C, &isEnabled);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
SECTION("Pass graphExec as clonedGraphExec and hNode as graph node") {
|
||||
ret = hipGraphNodeGetEnabled(clonedGraphExec, memcpy_A, &isEnabled);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
SECTION("Pass hNode a deleted node from same graph where exec was created") {
|
||||
HIP_CHECK(hipGraphDestroyNode(memcpy_A));
|
||||
ret = hipGraphNodeGetEnabled(graphExec, memcpy_A, &isEnabled);
|
||||
@@ -253,5 +268,7 @@ TEST_CASE("Unit_hipGraphNodeGetEnabled_Negative_Functional") {
|
||||
}
|
||||
HipTest::freeArrays(A_d, B_d, C_d, A_h, B_h, C_h, false);
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
HIP_CHECK(hipGraphExecDestroy(clonedGraphExec));
|
||||
HIP_CHECK(hipGraphDestroy(clonedGraph));
|
||||
HIP_CHECK(hipGraphDestroy(graph2));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
|
||||
Copyright (c) 2023 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
|
||||
@@ -187,20 +187,22 @@ TEST_CASE("Unit_hipGraphNodeSetEnabled_Functional_Basic") {
|
||||
}
|
||||
|
||||
/* Functional Test for API - hipGraphNodeSetEnabled
|
||||
9) Add a Kernel node(Vector_Square) with functonally to the graph and than
|
||||
9) Add a Kernel node(Vector_Square) with functonallty to the graph and than
|
||||
Disable kernel node and verify the result and
|
||||
10) Enable Kernel node and verify the result */
|
||||
10) Enable Kernel node and verify the result
|
||||
11) Make ClonedGraph and disabled the kernel node in ClonedGraph and verify
|
||||
12) Enable the Kernel node in ClonedGraph and verify the result */
|
||||
|
||||
TEST_CASE("Unit_hipGraphNodeSetEnabled_Functional_KernelNode") {
|
||||
constexpr size_t Nbytes = N * sizeof(int);
|
||||
constexpr auto blocksPerCU = 6; // to hide latency
|
||||
constexpr auto threadsPerBlock = 256;
|
||||
hipGraph_t graph;
|
||||
hipGraph_t graph, clonedGraph;
|
||||
hipStream_t stream;
|
||||
hipGraphNode_t memcpy_A, memcpy_C, kNodeSquare;
|
||||
hipGraphNode_t memcpy_A, memcpy_C, kNodeSquare, kNodeSquare_C;
|
||||
hipKernelNodeParams kNodeParams{};
|
||||
int *A_d, *C_d, *A_h, *C_h;
|
||||
hipGraphExec_t graphExec;
|
||||
hipGraphExec_t graphExec, clonedGraphExec;
|
||||
size_t NElem{N};
|
||||
unsigned int setEnable = 0, getEnable = 0;
|
||||
|
||||
@@ -261,25 +263,69 @@ TEST_CASE("Unit_hipGraphNodeSetEnabled_Functional_KernelNode") {
|
||||
REQUIRE(true == verifyVectorSquare(A_h, C_h, N));
|
||||
}
|
||||
|
||||
// Code for cloned graph operations
|
||||
HIP_CHECK(hipGraphClone(&clonedGraph, graph));
|
||||
HIP_CHECK(hipGraphInstantiate(&clonedGraphExec, clonedGraph,
|
||||
nullptr, nullptr, 0));
|
||||
HIP_CHECK(hipGraphNodeFindInClone(&kNodeSquare_C, kNodeSquare, clonedGraph));
|
||||
|
||||
HIP_CHECK(hipGraphLaunch(clonedGraphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
|
||||
REQUIRE(true == verifyVectorSquare(A_h, C_h, N));
|
||||
|
||||
SECTION("After disabled kernel node in ClonedGraph & verify the result") {
|
||||
setEnable = 0; // for disabled a node
|
||||
HIP_CHECK(hipGraphNodeSetEnabled(clonedGraphExec,
|
||||
kNodeSquare_C, setEnable));
|
||||
HIP_CHECK(hipGraphNodeGetEnabled(clonedGraphExec,
|
||||
kNodeSquare_C, &getEnable));
|
||||
REQUIRE(setEnable == getEnable);
|
||||
|
||||
HIP_CHECK(hipMemset(C_d, 0, Nbytes));
|
||||
HIP_CHECK(hipGraphLaunch(clonedGraphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
|
||||
REQUIRE(true != verifyVectorSquare(A_h, C_h, N));
|
||||
}
|
||||
SECTION("Again enabled kernel node in ClonedGraph & verify the result") {
|
||||
setEnable = 1; // for enabled a node
|
||||
HIP_CHECK(hipGraphNodeSetEnabled(clonedGraphExec,
|
||||
kNodeSquare_C, setEnable));
|
||||
HIP_CHECK(hipGraphNodeGetEnabled(clonedGraphExec,
|
||||
kNodeSquare_C, &getEnable));
|
||||
REQUIRE(setEnable == getEnable);
|
||||
|
||||
HIP_CHECK(hipMemset(C_d, 0, Nbytes));
|
||||
HIP_CHECK(hipGraphLaunch(clonedGraphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
|
||||
REQUIRE(true == verifyVectorSquare(A_h, C_h, N));
|
||||
}
|
||||
|
||||
HipTest::freeArrays<int>(A_d, nullptr, C_d, A_h, nullptr, C_h, false);
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
HIP_CHECK(hipGraphExecDestroy(clonedGraphExec));
|
||||
HIP_CHECK(hipGraphDestroy(clonedGraph));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
}
|
||||
|
||||
/* Functional Test for API - hipGraphNodeSetEnabled
|
||||
11) Add a MemSet node with functonally to the graph and than
|
||||
13) Add a MemSet node with functonally to the graph and than
|
||||
Disable MemSet node and verify the result and
|
||||
12) Enable MemSet node and verify the result */
|
||||
14) Enable MemSet node and verify the result
|
||||
15) Make ClonedGraph and disabled the MemSet node in ClonedGraph and verify
|
||||
16) Enable the MemSet node in ClonedGraph and verify the result */
|
||||
|
||||
TEST_CASE("Unit_hipGraphNodeSetEnabled_Functional_MemSet") {
|
||||
constexpr size_t Nbytes = N * sizeof(char);
|
||||
constexpr size_t val = 9;
|
||||
hipGraph_t graph;
|
||||
hipGraphExec_t graphExec;
|
||||
hipGraph_t graph, clonedGraph;
|
||||
hipGraphExec_t graphExec, clonedGraphExec;
|
||||
hipStream_t stream;
|
||||
hipGraphNode_t memcpy_A, memcpy_AC, memcpy_C, memsetNode;
|
||||
int setEnable;
|
||||
hipGraphNode_t memcpy_A, memcpy_AC, memcpy_C, memsetNode, memsetNode_C;
|
||||
unsigned int setEnable = 0, getEnable = 0;
|
||||
char *A_d, *C_d, *A_h, *B_h, *C_h;
|
||||
|
||||
HipTest::initArrays<char>(&A_d, nullptr, &C_d, &A_h, &B_h, &C_h, N, false);
|
||||
@@ -313,15 +359,17 @@ TEST_CASE("Unit_hipGraphNodeSetEnabled_Functional_MemSet") {
|
||||
|
||||
HIP_CHECK(hipGraphInstantiate(&graphExec, graph, nullptr, nullptr, 0));
|
||||
|
||||
SECTION("Without disabling MemSet node and verify the execution result") {
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
// Verify the execution result - basic check 1st time
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
|
||||
REQUIRE(true == verifyArray(B_h, C_h, N));
|
||||
|
||||
REQUIRE(true == verifyArray(B_h, C_h, N));
|
||||
}
|
||||
SECTION("After disabled MemSet node and verify the execution result") {
|
||||
setEnable = 0; // for disabled
|
||||
setEnable = 0; // for disabled a node
|
||||
HIP_CHECK(hipGraphNodeSetEnabled(graphExec, memsetNode, setEnable));
|
||||
HIP_CHECK(hipGraphNodeGetEnabled(graphExec, memsetNode, &getEnable));
|
||||
REQUIRE(setEnable == getEnable);
|
||||
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
@@ -329,8 +377,10 @@ TEST_CASE("Unit_hipGraphNodeSetEnabled_Functional_MemSet") {
|
||||
REQUIRE(true == verifyArray(A_h, C_h, N));
|
||||
}
|
||||
SECTION("Again enabled MemSet node and verify the execution result") {
|
||||
setEnable = 1; // for enabled
|
||||
setEnable = 1; // for enabled a node
|
||||
HIP_CHECK(hipGraphNodeSetEnabled(graphExec, memsetNode, setEnable));
|
||||
HIP_CHECK(hipGraphNodeGetEnabled(graphExec, memsetNode, &getEnable));
|
||||
REQUIRE(setEnable == getEnable);
|
||||
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
@@ -338,29 +388,71 @@ TEST_CASE("Unit_hipGraphNodeSetEnabled_Functional_MemSet") {
|
||||
REQUIRE(true == verifyArray(B_h, C_h, N));
|
||||
}
|
||||
|
||||
// Code for cloned graph operations
|
||||
HIP_CHECK(hipGraphClone(&clonedGraph, graph));
|
||||
HIP_CHECK(hipGraphInstantiate(&clonedGraphExec, clonedGraph,
|
||||
nullptr, nullptr, 0));
|
||||
HIP_CHECK(hipGraphNodeFindInClone(&memsetNode_C, memsetNode, clonedGraph));
|
||||
|
||||
HIP_CHECK(hipGraphLaunch(clonedGraphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
|
||||
REQUIRE(true == verifyArray(B_h, C_h, N));
|
||||
|
||||
SECTION("After disabled MemSet node and verify the execution result") {
|
||||
setEnable = 0; // for disabled a node
|
||||
HIP_CHECK(hipGraphNodeSetEnabled(clonedGraphExec,
|
||||
memsetNode_C, setEnable));
|
||||
HIP_CHECK(hipGraphNodeGetEnabled(clonedGraphExec,
|
||||
memsetNode_C, &getEnable));
|
||||
REQUIRE(setEnable == getEnable);
|
||||
|
||||
HIP_CHECK(hipGraphLaunch(clonedGraphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
|
||||
REQUIRE(true == verifyArray(A_h, C_h, N));
|
||||
}
|
||||
SECTION("Again enabled MemSet node and verify the execution result") {
|
||||
setEnable = 1; // for enabled a node
|
||||
HIP_CHECK(hipGraphNodeSetEnabled(clonedGraphExec,
|
||||
memsetNode_C, setEnable));
|
||||
HIP_CHECK(hipGraphNodeGetEnabled(clonedGraphExec,
|
||||
memsetNode_C, &getEnable));
|
||||
REQUIRE(setEnable == getEnable);
|
||||
|
||||
HIP_CHECK(hipGraphLaunch(clonedGraphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
|
||||
REQUIRE(true == verifyArray(B_h, C_h, N));
|
||||
}
|
||||
|
||||
HipTest::freeArrays<char>(A_d, nullptr, C_d, A_h, B_h, C_h, false);
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
HIP_CHECK(hipGraphExecDestroy(clonedGraphExec));
|
||||
HIP_CHECK(hipGraphDestroy(clonedGraph));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
}
|
||||
|
||||
/* Functional Test for API - hipGraphNodeSetEnabled
|
||||
13) Add a MemCpy node with functonally to the graph and than
|
||||
17) Add a MemCpy node with functonally to the graph and than
|
||||
Disable MemCpy node and verify the result and
|
||||
14) Enable MemCpy node and verify the result */
|
||||
18) Enable MemCpy node and verify the result
|
||||
19) Make ClonedGraph and disabled the MemCpy node in ClonedGraph and verify
|
||||
20) Enable the MemCpy node in ClonedGraph and verify the result */
|
||||
|
||||
TEST_CASE("Unit_hipGraphNodeSetEnabled_Functional_MemCpy") {
|
||||
constexpr size_t Nbytes = N * sizeof(int);
|
||||
constexpr auto blocksPerCU = 6; // to hide latency
|
||||
constexpr auto threadsPerBlock = 256;
|
||||
hipGraph_t graph;
|
||||
hipGraph_t graph, clonedGraph;
|
||||
hipStream_t stream;
|
||||
hipGraphNode_t memcpy_A, memcpy_B, memcpy_C, kNodeSquare;
|
||||
hipGraphNode_t memcpy_A, memcpy_B, memcpy_C, kNodeSquare, memcpy_B_C;
|
||||
hipKernelNodeParams kNodeParams{};
|
||||
int *A_d, *C_d, *A_h, *B_h, *C_h;
|
||||
hipGraphExec_t graphExec;
|
||||
hipGraphExec_t graphExec, clonedGraphExec;
|
||||
size_t NElem{N};
|
||||
int setEnable;
|
||||
unsigned int setEnable = 0, getEnable = 0;
|
||||
|
||||
HipTest::initArrays<int>(&A_d, nullptr, &C_d, &A_h, &B_h, &C_h, N, false);
|
||||
unsigned blocks = HipTest::setNumBlocks(blocksPerCU, threadsPerBlock, N);
|
||||
@@ -391,15 +483,17 @@ TEST_CASE("Unit_hipGraphNodeSetEnabled_Functional_MemCpy") {
|
||||
|
||||
HIP_CHECK(hipGraphInstantiate(&graphExec, graph, nullptr, nullptr, 0));
|
||||
|
||||
SECTION("Without disabling MemCpy node and verify the execution result") {
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
// Verify the execution result - basic check 1st time
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
|
||||
REQUIRE(true == verifyVectorSquare(B_h, C_h, N));
|
||||
|
||||
REQUIRE(true == verifyVectorSquare(B_h, C_h, N));
|
||||
}
|
||||
SECTION("After disabled MemCpy node and verify the execution result") {
|
||||
setEnable = 0; // for disabled
|
||||
setEnable = 0; // for disabled a node
|
||||
HIP_CHECK(hipGraphNodeSetEnabled(graphExec, memcpy_B, setEnable));
|
||||
HIP_CHECK(hipGraphNodeGetEnabled(graphExec, memcpy_B, &getEnable));
|
||||
REQUIRE(setEnable == getEnable);
|
||||
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
@@ -407,16 +501,55 @@ TEST_CASE("Unit_hipGraphNodeSetEnabled_Functional_MemCpy") {
|
||||
REQUIRE(true == verifyVectorSquare(A_h, C_h, N));
|
||||
}
|
||||
SECTION("Again enabled MemCpy node and verify the execution result") {
|
||||
setEnable = 1; // for enabled
|
||||
setEnable = 1; // for enabled a node
|
||||
HIP_CHECK(hipGraphNodeSetEnabled(graphExec, memcpy_B, setEnable));
|
||||
HIP_CHECK(hipGraphNodeGetEnabled(graphExec, memcpy_B, &getEnable));
|
||||
REQUIRE(setEnable == getEnable);
|
||||
|
||||
HIP_CHECK(hipGraphLaunch(graphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
|
||||
REQUIRE(true == verifyVectorSquare(B_h, C_h, N));
|
||||
}
|
||||
|
||||
// Code for cloned graph operations
|
||||
HIP_CHECK(hipGraphClone(&clonedGraph, graph));
|
||||
HIP_CHECK(hipGraphInstantiate(&clonedGraphExec, clonedGraph,
|
||||
nullptr, nullptr, 0));
|
||||
HIP_CHECK(hipGraphNodeFindInClone(&memcpy_B_C, memcpy_B, clonedGraph));
|
||||
|
||||
HIP_CHECK(hipGraphLaunch(clonedGraphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
|
||||
REQUIRE(true == verifyVectorSquare(B_h, C_h, N));
|
||||
|
||||
SECTION("After disabled MemSet node and verify the execution result") {
|
||||
setEnable = 0; // for disabled a node
|
||||
HIP_CHECK(hipGraphNodeSetEnabled(clonedGraphExec, memcpy_B_C, setEnable));
|
||||
HIP_CHECK(hipGraphNodeGetEnabled(clonedGraphExec, memcpy_B_C, &getEnable));
|
||||
REQUIRE(setEnable == getEnable);
|
||||
|
||||
HIP_CHECK(hipGraphLaunch(clonedGraphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
|
||||
REQUIRE(true == verifyVectorSquare(A_h, C_h, N));
|
||||
}
|
||||
SECTION("Again enabled MemSet node and verify the execution result") {
|
||||
setEnable = 1; // for enabled a node
|
||||
HIP_CHECK(hipGraphNodeSetEnabled(clonedGraphExec, memcpy_B_C, setEnable));
|
||||
HIP_CHECK(hipGraphNodeGetEnabled(clonedGraphExec, memcpy_B_C, &getEnable));
|
||||
REQUIRE(setEnable == getEnable);
|
||||
|
||||
HIP_CHECK(hipGraphLaunch(clonedGraphExec, stream));
|
||||
HIP_CHECK(hipStreamSynchronize(stream));
|
||||
|
||||
REQUIRE(true == verifyVectorSquare(B_h, C_h, N));
|
||||
}
|
||||
|
||||
HipTest::freeArrays<int>(A_d, nullptr, C_d, A_h, B_h, C_h, false);
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
HIP_CHECK(hipGraphExecDestroy(clonedGraphExec));
|
||||
HIP_CHECK(hipGraphDestroy(clonedGraph));
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
HIP_CHECK(hipStreamDestroy(stream));
|
||||
}
|
||||
@@ -432,20 +565,22 @@ TEST_CASE("Unit_hipGraphNodeSetEnabled_Functional_MemCpy") {
|
||||
Negative Functional Test for API - hipGraphNodeSetEnabled
|
||||
6) Pass hNode from different graph and verify
|
||||
7) Create graphExec and then add one more new node to the graph verify
|
||||
8) Pass hNode a deleted node from same graph where exec was created
|
||||
9) Create graphExec and then delete the graph and verify a node
|
||||
10) Create graphExec and then delete the graphExec and verify a node
|
||||
8) Pass hNode as clonedGraph node and exec as graphExec
|
||||
9) Pass graphExec as clonedGraphExec and hNode as graph node
|
||||
10) Pass hNode a deleted node from same graph where exec was created
|
||||
11) Create graphExec and then delete the graph and verify a node
|
||||
12) Create graphExec and then delete the graphExec and verify a node
|
||||
*/
|
||||
|
||||
TEST_CASE("Unit_hipGraphNodeSetEnabled_Negative_Functional") {
|
||||
constexpr size_t Nbytes = N * sizeof(int);
|
||||
constexpr auto blocksPerCU = 6; // to hide latency
|
||||
constexpr auto threadsPerBlock = 256;
|
||||
hipGraph_t graph, graph2;
|
||||
hipGraphNode_t memcpy_A, memcpy_B, memcpy_C, memcpy_A2, kNodeAdd;
|
||||
hipGraph_t graph, graph2, clonedGraph;
|
||||
hipGraphNode_t memcpy_A, memcpy_A_C, memcpy_B, memcpy_C, memcpy_A2, kNodeAdd;
|
||||
hipKernelNodeParams kNodeParams{};
|
||||
int *A_d, *B_d, *C_d, *A_h, *B_h, *C_h;
|
||||
hipGraphExec_t graphExec;
|
||||
hipGraphExec_t graphExec, graphExec2, clonedGraphExec;
|
||||
size_t NElem{N};
|
||||
unsigned int setEnable = 1;
|
||||
hipError_t ret;
|
||||
@@ -472,6 +607,12 @@ TEST_CASE("Unit_hipGraphNodeSetEnabled_Negative_Functional") {
|
||||
HIP_CHECK(hipGraphAddDependencies(graph, &memcpy_B, &kNodeAdd, 1));
|
||||
|
||||
HIP_CHECK(hipGraphInstantiate(&graphExec, graph, nullptr, nullptr, 0));
|
||||
HIP_CHECK(hipGraphInstantiate(&graphExec2, graph, nullptr, nullptr, 0));
|
||||
|
||||
HIP_CHECK(hipGraphClone(&clonedGraph, graph));
|
||||
HIP_CHECK(hipGraphInstantiate(&clonedGraphExec, clonedGraph,
|
||||
nullptr, nullptr, 0));
|
||||
HIP_CHECK(hipGraphNodeFindInClone(&memcpy_A_C, memcpy_A, clonedGraph));
|
||||
|
||||
HIP_CHECK(hipGraphAddMemcpyNode1D(&memcpy_C, graph, nullptr, 0, C_h, C_d,
|
||||
Nbytes, hipMemcpyDeviceToHost));
|
||||
@@ -511,21 +652,33 @@ TEST_CASE("Unit_hipGraphNodeSetEnabled_Negative_Functional") {
|
||||
ret = hipGraphNodeSetEnabled(graphExec, memcpy_C, setEnable);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
SECTION("Pass hNode as clonedGraph node and exec as graphExec") {
|
||||
ret = hipGraphNodeSetEnabled(graphExec, memcpy_A_C, setEnable);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
SECTION("Pass graphExec as clonedGraphExec and hNode as graph node") {
|
||||
ret = hipGraphNodeSetEnabled(clonedGraphExec, memcpy_A, setEnable);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
SECTION("Pass hNode a deleted node from same graph where exec was created") {
|
||||
HIP_CHECK(hipGraphDestroyNode(memcpy_A));
|
||||
ret = hipGraphNodeSetEnabled(graphExec, memcpy_A, setEnable);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
SECTION("Create graphExec and then delete the graph and verify a node") {
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
ret = hipGraphNodeSetEnabled(graphExec, memcpy_B, setEnable);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec2));
|
||||
SECTION("Create graphExec and then delete the graphExec and verify a node") {
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
ret = hipGraphNodeSetEnabled(graphExec2, memcpy_B, setEnable);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
HIP_CHECK(hipGraphDestroy(graph));
|
||||
SECTION("Create graphExec and then delete the graph and verify a node") {
|
||||
ret = hipGraphNodeSetEnabled(graphExec, memcpy_B, setEnable);
|
||||
REQUIRE(hipErrorInvalidValue == ret);
|
||||
}
|
||||
|
||||
HipTest::freeArrays(A_d, B_d, C_d, A_h, B_h, C_h, false);
|
||||
HIP_CHECK(hipGraphExecDestroy(graphExec));
|
||||
HIP_CHECK(hipGraphExecDestroy(clonedGraphExec));
|
||||
HIP_CHECK(hipGraphDestroy(clonedGraph));
|
||||
HIP_CHECK(hipGraphDestroy(graph2));
|
||||
}
|
||||
|
||||
Viittaa uudesa ongelmassa
Block a user