EXSWHTEC-171 - Hip graph creation and destruction tests (#35)

* EXSWHTEC-171 - Implement positive and negative unit tests for the following API's:
 - hipGraphCreate
 - hipGraphDestroy

[ROCm/hip-tests commit: 42ebc6cd10]
Этот коммит содержится в:
Marko Veniger
2023-03-06 12:26:24 +01:00
коммит произвёл GitHub
родитель f80f85f252
Коммит 9d19cc9a57
3 изменённых файлов: 85 добавлений и 71 удалений
+2
Просмотреть файл
@@ -89,6 +89,8 @@ set(TEST_SRC
hipGraphHostNodeGetParams.cc
hipGraphExecChildGraphNodeSetParams.cc
hipStreamGetCaptureInfo_v2.cc
hipGraphCreate.cc
hipGraphDestroy.cc
hipStreamUpdateCaptureDependencies.cc
hipThreadExchangeStreamCaptureMode.cc
hipLaunchHostFunc.cc
+45 -17
Просмотреть файл
@@ -20,25 +20,53 @@ THE SOFTWARE.
#include <hip_test_common.hh>
/**
Negative Testcase Scenarios :
1) Creating HipGraph with nullptr.
2) Creating hipGraph with non-zero mode.
*/
* @addtogroup hipGraphCreate hipGraphCreate
* @{
* @ingroup GraphTest
* `hipGraphCreate(hipGraph_t *pGraph, unsigned int flags)` -
* creates a graph
*/
TEST_CASE("Unit_hipGraphCreate_Negative") {
hipError_t ret;
SECTION("Creating HipGraph with nullptr") {
ret = hipGraphCreate(nullptr, 0);
REQUIRE(hipErrorInvalidValue == ret);
/**
* Test Description
* ------------------------
* - Negative parameter test for hipGraphCreate:
* -# Expected hipErrorInvalidValue when pGraph is null
* -# Expected hipErrorInvalidValue when flags is not 0
* Test source
* ------------------------
* - unit/graph/hipGraphCreate.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Unit_hipGraphCreate_Negative_Parameters") {
hipGraph_t graph = nullptr;
SECTION("pGraph is nullptr") {
HIP_CHECK_ERROR(hipGraphCreate(nullptr, 0), hipErrorInvalidValue);
}
SECTION("Creating hipGraph with non-zero mode") {
hipGraph_t graph{};
ret = hipGraphCreate(&graph, -1);
REQUIRE(hipErrorInvalidValue == ret);
ret = hipGraphCreate(nullptr, -1);
REQUIRE(hipErrorInvalidValue == ret);
}
SECTION("flags is not 0") { HIP_CHECK_ERROR(hipGraphCreate(&graph, 1), hipErrorInvalidValue); }
}
/**
* Test Description
* ------------------------
* - Basic positive test for hipGraphCreate
* - Create an emtpy graph
* Test source
* ------------------------
* - unit/graph/hipGraphCreate.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Unit_hipGraphCreate_Positive_Basic") {
hipGraph_t graph = nullptr;
HIP_CHECK(hipGraphCreate(&graph, 0));
REQUIRE(nullptr != graph);
HIP_CHECK(hipGraphDestroy(graph));
}
+38 -54
Просмотреть файл
@@ -20,62 +20,46 @@ THE SOFTWARE.
#include <hip_test_common.hh>
/**
Negative Testcase Scenarios :
1) Pass graph as nullptr and verify.
2) Destroy already destroyed graph and check api returns error code.
3) Destroy graph when is in use and make sure api handles it gracefully.
*/
* @addtogroup hipGraphDestroy hipGraphDestroy
* @{
* @ingroup GraphTest
* `hipGraphDestroy(hipGraph_t graph)` -
* Destroys a graph
*/
TEST_CASE("Unit_hipGraphDestroy_Negative") {
hipError_t ret;
SECTION("Deleting HipGraph with nullptr") {
ret = hipGraphDestroy(nullptr);
REQUIRE(hipErrorInvalidValue == ret);
}
#if HT_AMD
SECTION("Destroy already destroyed graph and check api returns error code") {
hipGraph_t graph;
HIP_CHECK(hipGraphCreate(&graph, 0));
HIP_CHECK(hipGraphDestroy(graph));
/**
* Test Description
* ------------------------
* - Basic positive test for hipGraphDestroy
* - Create an emtpy graph and then destroy it
* Test source
* ------------------------
* - unit/graph/hipGraphDestroy.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Unit_hipGraphDestroy_Positive_Basic") {
hipGraph_t graph = nullptr;
ret = hipGraphDestroy(graph);
REQUIRE(hipErrorIllegalState == ret);
}
#endif
SECTION("Destroy graph when is in use and make sure api handles"
" it gracefully.") {
hipGraph_t graph;
hipGraphExec_t graphExec;
hipStream_t streamForGraph;
hipGraphNode_t memsetNode;
HIP_CHECK(hipGraphCreate(&graph, 0));
REQUIRE(nullptr != graph);
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<void*>(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(hipGraphDestroy(graph));
HIP_CHECK(hipGraphLaunch(graphExec, streamForGraph));
HIP_CHECK(hipStreamSynchronize(streamForGraph));
HIP_CHECK(hipFree(devData));
HIP_CHECK(hipGraphExecDestroy(graphExec));
HIP_CHECK(hipStreamDestroy(streamForGraph));
}
HIP_CHECK(hipGraphDestroy(graph));
}
/**
* Test Description
* ------------------------
* - Basic negative parameter test for hipGraphDestroy
* -# Expected hipErrorInvalidValue when graph is invalid
* Test source
* ------------------------
* - unit/graph/hipGraphDestroy.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
TEST_CASE("Unit_hipGraphDestroy_Negative_Parameters") {
HIP_CHECK_ERROR(hipGraphDestroy(static_cast<hipGraph_t>(nullptr)), hipErrorInvalidValue);
}