EXSWHTEC-178 - Implement tests for Graph Event Node APIs #44

Change-Id: Id3f569d94d347af2f5e27513fa01c5a1e8e30fd9
Tento commit je obsažen v:
Nives Vukovic
2023-11-24 21:42:07 +05:30
odevzdal Maneesh Gupta
rodič 133521b22f
revize 575e4cc93e
8 změnil soubory, kde provedl 472 přidání a 441 odebrání
+25 -22
Zobrazit soubor
@@ -26,11 +26,12 @@ with the event set in hipGraphAddEventRecordNode.
- Output event is a nullptr.
- Input node is an empty node.
- Input node is a memset node.
- Input node is event wait node
- Input node is an uninitialized node.
*/
#include <hip_test_common.hh>
#include <hip_test_checkers.hh>
#include <hip_test_common.hh>
#include <hip_test_kernels.hh>
/**
@@ -42,8 +43,7 @@ static void validateEventRecordNodeGetEvent(unsigned flag) {
hipEvent_t event, event_out;
HIP_CHECK(hipEventCreateWithFlags(&event, flag));
hipGraphNode_t eventrec;
HIP_CHECK(hipGraphAddEventRecordNode(&eventrec, graph, nullptr, 0,
event));
HIP_CHECK(hipGraphAddEventRecordNode(&eventrec, graph, nullptr, 0, event));
HIP_CHECK(hipGraphEventRecordNodeGetEvent(eventrec, &event_out));
// validate set event and get event are same
REQUIRE(event == event_out);
@@ -77,31 +77,32 @@ TEST_CASE("Unit_hipGraphEventRecordNodeGetEvent_Functional") {
TEST_CASE("Unit_hipGraphEventRecordNodeGetEvent_Negative") {
hipGraph_t graph;
HIP_CHECK(hipGraphCreate(&graph, 0));
hipEvent_t event, event_out;
HIP_CHECK(hipEventCreate(&event));
hipGraphNode_t eventrec;
HIP_CHECK(hipGraphAddEventRecordNode(&eventrec, graph, nullptr, 0,
event));
hipEvent_t event_out;
hipEvent_t event1, event2;
HIP_CHECK(hipEventCreate(&event1));
HIP_CHECK(hipEventCreate(&event2));
hipGraphNode_t eventrec, eventwait;
HIP_CHECK(hipGraphAddEventRecordNode(&eventrec, graph, nullptr, 0, event1));
HIP_CHECK(hipGraphAddEventWaitNode(&eventwait, graph, nullptr, 0, event2));
SECTION("node = nullptr") {
REQUIRE(hipErrorInvalidValue == hipGraphEventRecordNodeGetEvent(nullptr,
&event_out));
HIP_CHECK_ERROR(hipGraphEventRecordNodeGetEvent(nullptr, &event_out), hipErrorInvalidValue);
}
SECTION("event_out = nullptr") {
REQUIRE(hipErrorInvalidValue == hipGraphEventRecordNodeGetEvent(eventrec,
nullptr));
HIP_CHECK_ERROR(hipGraphEventRecordNodeGetEvent(eventrec, nullptr), hipErrorInvalidValue);
}
SECTION("input node is empty node") {
hipGraphNode_t EmptyGraphNode;
HIP_CHECK(hipGraphAddEmptyNode(&EmptyGraphNode, graph, nullptr, 0));
REQUIRE(hipErrorInvalidValue ==
hipGraphEventRecordNodeGetEvent(EmptyGraphNode, &event_out));
HIP_CHECK_ERROR(hipGraphEventRecordNodeGetEvent(EmptyGraphNode, &event_out),
hipErrorInvalidValue);
}
SECTION("input node is memset node") {
constexpr size_t Nbytes = 1024;
char *A_d;
char* A_d;
hipGraphNode_t memset_A;
hipMemsetParams memsetParams{};
HIP_CHECK(hipMalloc(&A_d, Nbytes));
@@ -112,19 +113,21 @@ TEST_CASE("Unit_hipGraphEventRecordNodeGetEvent_Negative") {
memsetParams.elementSize = sizeof(char);
memsetParams.width = Nbytes;
memsetParams.height = 1;
HIP_CHECK(hipGraphAddMemsetNode(&memset_A, graph, nullptr, 0,
&memsetParams));
REQUIRE(hipErrorInvalidValue ==
hipGraphEventRecordNodeGetEvent(memset_A, &event_out));
HIP_CHECK(hipGraphAddMemsetNode(&memset_A, graph, nullptr, 0, &memsetParams));
HIP_CHECK_ERROR(hipGraphEventRecordNodeGetEvent(memset_A, &event_out), hipErrorInvalidValue);
HIP_CHECK(hipFree(A_d));
}
SECTION("input node is event wait node") {
HIP_CHECK_ERROR(hipGraphEventRecordNodeGetEvent(eventwait, &event_out), hipErrorInvalidValue);
}
SECTION("input node is uninitialized node") {
hipGraphNode_t node_unit{};
REQUIRE(hipErrorInvalidValue ==
hipGraphEventRecordNodeGetEvent(node_unit, &event_out));
HIP_CHECK_ERROR(hipGraphEventRecordNodeGetEvent(node_unit, &event_out), hipErrorInvalidValue);
}
HIP_CHECK(hipGraphDestroy(graph));
HIP_CHECK(hipEventDestroy(event));
HIP_CHECK(hipEventDestroy(event1));
HIP_CHECK(hipEventDestroy(event2));
}