Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions projects/hip-tests/catch/unit/graph/hipGraph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ static void hipWithoutGraphs(float* inputVec_h, float* inputVec_d, double* outpu
outputVec_d, result_d);
HIP_CHECK(hipMemcpyAsync(&result_h, result_d, sizeof(double), hipMemcpyDefault, stream1));
HIP_CHECK(hipStreamSynchronize(stream1));
HIP_CHECK(hipStreamSynchronize(stream2));
HIP_CHECK(hipStreamSynchronize(stream3));
}
auto stop = std::chrono::high_resolution_clock::now();
auto result = std::chrono::duration<double, std::milli>(stop - start);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ TEST_CASE("Unit_hipGraphAddChildGraphNode_Negative") {
REQUIRE(hipGraphAddChildGraphNode(&childGraphNode1, graph, nullptr, 10, childgraph1) ==
hipErrorInvalidValue);
}

HIP_CHECK(hipGraphDestroy(graph));
HIP_CHECK(hipGraphDestroy(childgraph1));
HipTest::freeArrays<int>(A_d, B_d, nullptr, A_h, B_h, nullptr, false);
}

/*
Expand Down Expand Up @@ -218,7 +222,6 @@ TEST_CASE("Unit_hipGraphAddChildGraphNode_CloneChildGraph") {
HipTest::initArrays<int>(&A_d, &B_d, nullptr, &A_h, &B_h, nullptr, N, false);

HIP_CHECK(hipGraphCreate(&graph, 0));
HIP_CHECK(hipGraphCreate(&clonedgraph, 0));
hipGraphNode_t memcpyH2D_A, memcpyH2D_B, childGraphNode1;
hipStream_t streamForGraph;
HIP_CHECK(hipStreamCreate(&streamForGraph));
Expand Down Expand Up @@ -252,6 +255,7 @@ TEST_CASE("Unit_hipGraphAddChildGraphNode_CloneChildGraph") {
HIP_CHECK(hipGraphExecDestroy(graphExec));
HIP_CHECK(hipGraphDestroy(childgraph1));
HIP_CHECK(hipGraphDestroy(graph));
HIP_CHECK(hipGraphDestroy(clonedgraph));
HIP_CHECK(hipStreamDestroy(streamForGraph));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,6 @@ TEST_CASE("Unit_hipGraphChildGraphNodeGetGraph_Negative") {
}
#endif
HipTest::freeArrays(A_d, B_d, C_d, A_h, B_h, C_h, false);
HIP_CHECK(hipGraphDestroy(graph));
HIP_CHECK(hipGraphDestroy(childgraph1));
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ TEST_CASE("Unit_hipGraphDestroyNode_BasicFunctionality") {
HIP_CHECK(hipGraphCreate(&graph, 0));
HIP_CHECK(hipGraphAddMemsetNode(&memsetNode, graph, nullptr, 0, &memsetParams));
REQUIRE(hipGraphDestroyNode(memsetNode) == hipSuccess);
HIP_CHECK(hipGraphDestroy(graph));
HIP_CHECK(hipFree(pOutBuff_d));
}

Expand Down Expand Up @@ -201,7 +202,6 @@ TEST_CASE("Unit_hipGraphDestroyNode_Complx_ChkNumOfNodesNDep_ClonedGrph") {
hipGraphNode_t kernelnode[NUM_OF_DUMMY_NODES];
hipKernelNodeParams kernelNodeParams[NUM_OF_DUMMY_NODES];
HIP_CHECK(hipGraphCreate(&graph, 0));
HIP_CHECK(hipGraphCreate(&clonedgraph, 0));
// Create graph with no dependencies
for (int i = 0; i < NUM_OF_DUMMY_NODES; i++) {
void* kernelArgs[] = {nullptr};
Expand Down
2 changes: 2 additions & 0 deletions projects/hip-tests/catch/unit/graph/hipGraphExecGetFlags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ TEST_CASE("Unit_hipGraphExecGetFlags_Negative") {
HIP_CHECK(
hipGraphInstantiateWithFlags(&graphExec, graph, hipGraphInstantiateFlagAutoFreeOnLaunch));
HIP_CHECK_ERROR(hipGraphExecGetFlags(nullptr, &flags), hipErrorInvalidValue);
HIP_CHECK(hipGraphExecDestroy(graphExec));
HIP_CHECK(hipGraphDestroy(graph));
}

Expand Down Expand Up @@ -136,6 +137,7 @@ TEST_CASE("Unit_hipGraphExecGetFlags_positive") {
REQUIRE(flags == hipGraphInstantiateFlagUseNodePriority);
}
#endif
HIP_CHECK(hipGraphExecDestroy(graphExec));
HIP_CHECK(hipGraphDestroy(graph));
}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,12 @@ TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParams_Negative_Changing_Memcpy_Directi

const auto set_dir = GENERATE(hipMemcpyHostToHost, hipMemcpyHostToDevice, hipMemcpyDeviceToHost,
hipMemcpyDeviceToDevice, hipMemcpyDefault);
if (dir == set_dir) {
HIP_CHECK(hipGraphExecDestroy(graph_exec));
HIP_CHECK(hipGraphDestroy(graph));
return;
if (dir != set_dir) {
params.kind = set_dir;
HIP_CHECK_ERROR(hipGraphExecMemcpyNodeSetParams(graph_exec, node, &params),
hipErrorInvalidValue);
}

params.kind = set_dir;
HIP_CHECK_ERROR(hipGraphExecMemcpyNodeSetParams(graph_exec, node, &params), hipErrorInvalidValue);
HIP_CHECK(hipGraphExecDestroy(graph_exec));
HIP_CHECK(hipGraphDestroy(graph));
HIP_CHECK(hipHostFree(host));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,12 @@ TEST_CASE("Unit_hipGraphExecMemcpyNodeSetParams1D_Negative_Changing_Memcpy_Direc

const auto set_dir = GENERATE(hipMemcpyHostToHost, hipMemcpyHostToDevice, hipMemcpyDeviceToHost,
hipMemcpyDeviceToDevice, hipMemcpyDefault);
if (dir == set_dir) {
HIP_CHECK(hipGraphExecDestroy(graph_exec));
HIP_CHECK(hipGraphDestroy(graph));
return;
if (dir != set_dir) {
HIP_CHECK_ERROR(
hipGraphExecMemcpyNodeSetParams1D(graph_exec, node, dst, src, sizeof(int), set_dir),
hipErrorInvalidValue);
}

HIP_CHECK_ERROR(
hipGraphExecMemcpyNodeSetParams1D(graph_exec, node, dst, src, sizeof(int), set_dir),
hipErrorInvalidValue);

HIP_CHECK(hipGraphExecDestroy(graph_exec));
HIP_CHECK(hipGraphDestroy(graph));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ TEST_CASE("Unit_hipGraphExecUpdate_Negative_TypeChange") {
HIP_CHECK(hipGraphDestroy(graph));
HIP_CHECK(hipGraphDestroy(graph2));
HIP_CHECK(hipStreamDestroy(streamForGraph));
HipTest::freeArrays<int>(A_d, nullptr, nullptr, A_h, nullptr, nullptr, false);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ TEST_CASE("Unit_hipGraphGetNodes_ParamValidation") {
HIP_CHECK(hipGraphCreate(&emptyGraph, 0));
HIP_CHECK(hipGraphGetNodes(emptyGraph, nullptr, &numNodes));
REQUIRE(numNodes == 0);
HIP_CHECK(hipGraphDestroy(emptyGraph));
}

SECTION("numNodes less than actual number of nodes") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ TEST_CASE("Unit_hipGraphGetRootNodes_ParamValidation") {
HIP_CHECK(hipGraphCreate(&emptyGraph, 0));
HIP_CHECK(hipGraphGetRootNodes(emptyGraph, nullptr, &numRootNodes));
REQUIRE(numRootNodes == 0);
HIP_CHECK(hipGraphDestroy(emptyGraph));
}

SECTION("numRootNodes less than actual number of nodes") {
Expand Down Expand Up @@ -394,7 +395,6 @@ TEST_CASE("Unit_hipGraphGetRootNodes_Complx_NumRootNodes_ClonedGrph") {
hipGraphNode_t kernelnode[NUM_OF_DUMMY_NODES];
hipKernelNodeParams kernelNodeParams[NUM_OF_DUMMY_NODES];
HIP_CHECK(hipGraphCreate(&graph, 0));
HIP_CHECK(hipGraphCreate(&clonedgraph, 0));
// Create graph with no dependencies
for (int i = 0; i < NUM_OF_DUMMY_NODES; i++) {
void* kernelArgs[] = {nullptr};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ TEST_CASE("Unit_hipGraphHostNodeSetParams_ClonedGraphWithHostNode") {
HipTest::freeArrays<int>(A_d, nullptr, C_d, A_h, nullptr, C_h, false);
HIP_CHECK(hipGraphExecDestroy(graphExec));
HIP_CHECK(hipGraphDestroy(graph));
HIP_CHECK(hipGraphDestroy(clonedgraph));
HIP_CHECK(hipStreamDestroy(streamForGraph));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ TEST_CASE("Unit_hipGraphInstantiate_Negative") {
SECTION("Pass pGraphExec as un-initialize") {
ret = hipGraphInstantiate(&gExec, graph, nullptr, nullptr, 0);
REQUIRE(hipSuccess == ret);
HIP_CHECK(hipGraphExecDestroy(gExec));
}
HIP_CHECK(hipGraphDestroy(graph));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ TEST_CASE("Unit_hipGraphInstantiateWithFlags_Negative") {
hipGraph_t graph;
HIP_CHECK(hipGraphCreate(&graph, 0));
REQUIRE(hipGraphInstantiateWithFlags(nullptr, graph, 0) == hipErrorInvalidValue);
HIP_CHECK(hipGraphDestroy(graph));
}

SECTION("Passing nullptr to graph") {
Expand All @@ -82,6 +83,7 @@ TEST_CASE("Unit_hipGraphInstantiateWithFlags_Negative") {
HIP_CHECK(hipGraphCreate(&graph, 0));
hipGraphExec_t graphExec;
REQUIRE(hipGraphInstantiateWithFlags(&graphExec, graph, 10) != hipSuccess);
HIP_CHECK(hipGraphDestroy(graph));
}
}
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ TEST_CASE("Unit_hipGraphInstantiateWithParams_Negative") {
hipGraphInstantiateParams params;
HIP_CHECK(hipGraphCreate(&graph, 0));
REQUIRE(hipGraphInstantiateWithParams(nullptr, graph, &params) == hipErrorInvalidValue);
HIP_CHECK(hipGraphDestroy(graph));
}

SECTION("Passing nullptr to graph") {
Expand All @@ -70,6 +71,7 @@ TEST_CASE("Unit_hipGraphInstantiateWithParams_Negative") {
HIP_CHECK(hipGraphCreate(&graph, 0));
hipGraphExec_t graphExec;
REQUIRE(hipGraphInstantiateWithParams(&graphExec, graph, nullptr) == hipErrorInvalidValue);
HIP_CHECK(hipGraphDestroy(graph));
}

SECTION("Passing invalid flag") {
Expand All @@ -80,6 +82,7 @@ TEST_CASE("Unit_hipGraphInstantiateWithParams_Negative") {
params.flags = 10;
REQUIRE(hipGraphInstantiateWithParams(&graphExec, graph, &params) == hipErrorInvalidValue);
REQUIRE(params.result_out == hipGraphInstantiateError);
HIP_CHECK(hipGraphDestroy(graph));
}
}

Expand Down Expand Up @@ -194,17 +197,15 @@ void GraphInstantiateWithParams_StreamCapture() {
HIP_CHECK(hipMalloc(&C_d, Nbytes));
REQUIRE(A_d != nullptr);
REQUIRE(C_d != nullptr);
HIP_CHECK(hipGraphCreate(&graph, 0));


HIP_CHECK(hipStreamCreate(&stream));
constexpr unsigned blocks = 512;
constexpr unsigned threadsPerBlock = 256;

HIP_CHECK(hipStreamBeginCapture(stream, hipStreamCaptureModeGlobal));
HIP_CHECK(hipMemcpyAsync(A_d, A_h, Nbytes, hipMemcpyHostToDevice, stream));

HIP_CHECK(hipMemcpyAsync(A_d, A_h, Nbytes, hipMemcpyHostToDevice, stream));
HIP_CHECK(hipMemsetAsync(C_d, 0, Nbytes, stream));

constexpr unsigned blocks = 512;
constexpr unsigned threadsPerBlock = 256;
hipLaunchKernelGGL(HipTest::vector_square, dim3(blocks), dim3(threadsPerBlock), 0, stream, A_d,
C_d, N);
HIP_CHECK(hipMemcpyAsync(C_h, C_d, Nbytes, hipMemcpyDeviceToHost, stream));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ void hipGraphNodeFindInClone_Func(bool ModifyOrigGraph = false) {
HIP_CHECK(hipGraphAddDependencies(graph, &kernel_vecAdd, &memcpyD2H_C, 1));

if (ModifyOrigGraph) {
// Cloned the graph
HIP_CHECK(hipGraphClone(&clonedgraph, graph));
// Modify Original graph by adding new dependency
HIP_CHECK(hipGraphAddMemcpyNode1D(&memcpyD2D_C, graph, nullptr, 0, C_d, B_d, Nbytes,
hipMemcpyDeviceToHost));
Expand Down Expand Up @@ -259,6 +257,10 @@ void hipGraphNodeFindInClone_DoubleClone(bool ModifyOrigGraph = false) {
hipGraphNode_t clonedgraphnode;
REQUIRE(hipGraphNodeFindInClone(&clonedgraphnode, memcpyH2D_A, clonedgraph_1) ==
hipErrorInvalidValue);
HIP_CHECK(hipGraphDestroy(clonedgraph_1));
HIP_CHECK(hipGraphDestroy(clonedgraph));
HIP_CHECK(hipGraphDestroy(graph));
HipTest::freeArrays(A_d, B_d, C_d, A_h, B_h, C_h, false);
}
/**
* Test Description
Expand Down
7 changes: 7 additions & 0 deletions projects/hip-tests/catch/unit/graph/hipGraphNodeGetType.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ TEST_CASE("Unit_hipGraphNodeGetType_Negative") {
HIP_CHECK(hipGraphCreate(&graph, 0));
HIP_CHECK(hipGraphAddEmptyNode(&memcpyNode, graph, nullptr, 0));
REQUIRE(hipGraphNodeGetType(memcpyNode, nullptr) == hipErrorInvalidValue);
HIP_CHECK(hipGraphDestroy(graph));
}

SECTION("Pass invalid node") {
Expand Down Expand Up @@ -114,8 +115,11 @@ TEST_CASE("Unit_hipGraphNodeGetType_Functional") {
HIP_CHECK(hipGraphNodeGetType(waiteventNode, &nodeType));
REQUIRE(nodeType == hipGraphNodeTypeEmpty);
}

HIP_CHECK(hipGraphDestroy(graph));
HIP_CHECK(hipStreamDestroy(stream));
HIP_CHECK(hipEventDestroy(event));
HipTest::freeArrays(A_d, B_d, C_d, A_h, B_h, C_h, false);
}
/**
* Functional Test for hipGraphNodeGetType API
Expand Down Expand Up @@ -397,6 +401,7 @@ TEST_CASE("Unit_hipGraphNodeGetType_NodeTypeOfClonedGraph_NodeTypeInThread") {
SECTION("Cloned Graph Node Type") {
HIP_CHECK(hipGraphClone(&clonedGraph, graph));
ChkNodeType(clonedGraph, &numNode);
HIP_CHECK(hipGraphDestroy(clonedGraph));
}
// Thread
SECTION("Node Type In The Thread") {
Expand Down Expand Up @@ -515,6 +520,7 @@ TEST_CASE("Unit_hipGraphNodeGetType_NodeTypeOfChildGraph") {
HIP_CHECK(hipGraphChildGraphNodeGetGraph(childGraphNode, &getGraph));
ChkNodeType(getGraph, &numNodeChild);

HIP_CHECK(hipStreamSynchronize(stream2));
HIP_CHECK(hipStreamDestroy(stream1));
HIP_CHECK(hipEventDestroy(event1));
HIP_CHECK(hipStreamDestroy(stream2));
Expand Down Expand Up @@ -638,6 +644,7 @@ TEST_CASE("Unit_hipGraphNodeGetType_ClonedGraph_InThread_WithDependencies") {
SECTION("Cloned Graph Node Type") {
HIP_CHECK(hipGraphClone(&clonedGraph, graph));
ChkNodeTypeWithDependency(clonedGraph, Parent);
HIP_CHECK(hipGraphDestroy(clonedGraph));
}
// Thread
SECTION("Node Type In The Thread") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ TEST_CASE("Unit_hipGraphNodeSetParams_Negative_Parameters") {

HIP_CHECK(hipGraphExecDestroy(graphExec));
HIP_CHECK(hipGraphDestroy(graph));
HIP_CHECK(hipFree(A_d));
free(A_h);
}

/**
Expand Down Expand Up @@ -130,6 +132,7 @@ TEST_CASE("Unit_hipGraphNodeSetParams_Positive") {
for (int i = 0; i < N; i++) {
REQUIRE(A_h[i] == 99);
}
HIP_CHECK(hipGraphExecDestroy(graphExec));

hipGraphNodeParams node_params2 = {};
node_params2.type = hipGraphNodeTypeMemset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ TEST_CASE("Unit_hipGraphRemoveDependencies_Func_StrmCapture") {
HIP_CHECK(hipStreamDestroy(stream1));
HIP_CHECK(hipStreamDestroy(stream2));
HIP_CHECK(hipStreamDestroy(stream3));
HIP_CHECK(hipEventDestroy(forkStreamEvent));
HIP_CHECK(hipEventDestroy(memsetEvent1));
HIP_CHECK(hipEventDestroy(memsetEvent2));
HipTest::freeArrays(A_d, B_d, C_d, A_h, B_h, C_h, false);
}

Expand Down
Loading