From a4d0f06eb79f92acba0bb8e63283763e33e865fd Mon Sep 17 00:00:00 2001 From: sumanthtg <90063301+sumanthtg@users.noreply.github.com> Date: Fri, 26 Nov 2021 07:19:49 +0530 Subject: [PATCH] SWDEV-306122 - [catch2][dtest] hipGraph functional tests for hipGraphAddEmptyNode (#2411) Change-Id: I93139c195e4621d33d9330413b6eedaf714c72d8 [ROCm/hip commit: 02ac5137f580b0b2ad6401e8e228bfde3b22feab] --- .../hip/tests/catch/unit/graph/CMakeLists.txt | 1 + .../catch/unit/graph/hipGraphAddEmptyNode.cc | 57 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 projects/hip/tests/catch/unit/graph/hipGraphAddEmptyNode.cc diff --git a/projects/hip/tests/catch/unit/graph/CMakeLists.txt b/projects/hip/tests/catch/unit/graph/CMakeLists.txt index 058b45e1c6..80fb448618 100644 --- a/projects/hip/tests/catch/unit/graph/CMakeLists.txt +++ b/projects/hip/tests/catch/unit/graph/CMakeLists.txt @@ -20,6 +20,7 @@ # Common Tests - Test independent of all platforms set(TEST_SRC + hipGraphAddEmptyNode.cc hipGraphAddDependencies.cc hipGraph.cc hipSimpleGraphWithKernel.cc diff --git a/projects/hip/tests/catch/unit/graph/hipGraphAddEmptyNode.cc b/projects/hip/tests/catch/unit/graph/hipGraphAddEmptyNode.cc new file mode 100644 index 0000000000..5e30c1a07b --- /dev/null +++ b/projects/hip/tests/catch/unit/graph/hipGraphAddEmptyNode.cc @@ -0,0 +1,57 @@ +/* +Copyright (c) 2021 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 WARRANNTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNNESS 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 INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/** +Testcase Scenarios : + 1) Create and add empty node to graph and verify addition is successful. +*/ + +#include + +/** + * Functional Test to add empty node with dependencies + */ +TEST_CASE("Unit_hipGraphAddEmptyNode_Functional") { + char *pOutBuff_d{}; + constexpr size_t size = 1024; + hipGraph_t graph{}; + hipGraphNode_t memsetNode{}, emptyNode{}; + std::vector dependencies; + + HIP_CHECK(hipMalloc(&pOutBuff_d, size)); + hipMemsetParams memsetParams{}; + memsetParams.dst = reinterpret_cast(pOutBuff_d); + memsetParams.value = 0; + memsetParams.pitch = 0; + memsetParams.elementSize = sizeof(char); + memsetParams.width = size * sizeof(char); + memsetParams.height = 1; + HIP_CHECK(hipGraphCreate(&graph, 0)); + HIP_CHECK(hipGraphAddMemsetNode(&memsetNode, graph, nullptr, 0, + &memsetParams)); + dependencies.push_back(memsetNode); + + // Create emptyNode and add it to graph with dependency + HIP_CHECK(hipGraphAddEmptyNode(&emptyNode, graph, dependencies.data(), + dependencies.size())); + + REQUIRE(emptyNode != nullptr); + HIP_CHECK(hipFree(pOutBuff_d)); + HIP_CHECK(hipGraphDestroy(graph)); +}