/* * Copyright (c) Advanced Micro Devices, Inc., or its affiliates. * * SPDX-License-Identifier: MIT */ #include /** * @addtogroup hipGraphExecDestroy hipGraphExecDestroy * @{ * @ingroup GraphTest * `hipGraphExecDestroy(hipGraphExec_t graphExec)` - * Destroys an executable graph */ /** * Test Description * ------------------------ * - Test to verify API behavior with invalid arguments: * -# GraphExec is nullptr * -# GraphExec is uninitialized * Test source * ------------------------ * - unit/graph/hipGraphExecDestroy.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ HIP_TEST_CASE(Unit_hipGraphExecDestroy_Negative_Parameters) { SECTION("Pass hipGraphExecDestroy with nullptr") { HIP_CHECK_ERROR(hipGraphExecDestroy(nullptr), hipErrorInvalidValue); } SECTION("Pass hipGraphExecDestroy with un-initilze structure") { hipGraphExec_t graph_exec{}; HIP_CHECK_ERROR(hipGraphExecDestroy(graph_exec), hipErrorInvalidValue); } } /** * Test Description * ------------------------ * - Basic positive test for hipGraphExecDestroy * - create an executable graph and then destroy it * Test source * ------------------------ * - unit/graph/hipGraphExecDestroy.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ HIP_TEST_CASE(Unit_hipGraphExecDestroy_Positive_Basic) { hipGraph_t graph; hipGraphExec_t graphExec; hipStream_t streamForGraph; hipGraphNode_t memsetNode; HIP_CHECK(hipGraphCreate(&graph, 0)); HIP_CHECK(hipStreamCreate(&streamForGraph)); char* devData; HIP_CHECK(hipMalloc(&devData, 1024)); hipMemsetParams memsetParams{}; memset(&memsetParams, 0, sizeof(memsetParams)); memsetParams.dst = reinterpret_cast(devData); memsetParams.value = 0; memsetParams.pitch = 0; memsetParams.elementSize = sizeof(char); memsetParams.width = 1024; memsetParams.height = 1; HIP_CHECK(hipGraphAddMemsetNode(&memsetNode, graph, nullptr, 0, &memsetParams)); HIP_CHECK(hipGraphInstantiate(&graphExec, graph, nullptr, nullptr, 0)); REQUIRE(graphExec != nullptr); HIP_CHECK(hipGraphLaunch(graphExec, streamForGraph)); HIP_CHECK(hipStreamSynchronize(streamForGraph)); HIP_CHECK(hipFree(devData)); HIP_CHECK(hipGraphDestroy(graph)); HIP_CHECK(hipGraphExecDestroy(graphExec)); HIP_CHECK(hipStreamDestroy(streamForGraph)); } /** * End doxygen group GraphTest. * @} */