CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
138 lines
3.9 KiB
C++
138 lines
3.9 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include <hip_test_common.hh>
|
|
#include <hip_test_checkers.hh>
|
|
|
|
/**
|
|
* @addtogroup hipGraphLaunch hipGraphLaunch
|
|
* @{
|
|
* @ingroup GraphTest
|
|
* `hipGraphLaunch(hipGraphExec_t graphExec, hipStream_t stream)` -
|
|
* Launches an executable graph in a stream
|
|
*/
|
|
|
|
static void HostFunctionSetToZero(void* arg) {
|
|
int* test_number = (int*)arg;
|
|
(*test_number) = 0;
|
|
}
|
|
|
|
static void HostFunctionAddOne(void* arg) {
|
|
int* test_number = (int*)arg;
|
|
(*test_number) += 1;
|
|
}
|
|
|
|
/* create an executable graph that will set an integer pointed to by 'number' to one*/
|
|
static void CreateTestExecutableGraph(hipGraphExec_t* graph_exec, int* number) {
|
|
hipGraph_t graph;
|
|
hipGraphNode_t node_error;
|
|
|
|
hipGraphNode_t node_set_zero;
|
|
hipHostNodeParams params_set_to_zero = {HostFunctionSetToZero, number};
|
|
|
|
hipGraphNode_t node_add_one;
|
|
hipHostNodeParams params_set_add_one = {HostFunctionAddOne, number};
|
|
|
|
HIP_CHECK(hipGraphCreate(&graph, 0));
|
|
|
|
HIP_CHECK(hipGraphAddHostNode(&node_set_zero, graph, nullptr, 0, ¶ms_set_to_zero));
|
|
HIP_CHECK(hipGraphAddHostNode(&node_add_one, graph, &node_set_zero, 1, ¶ms_set_add_one));
|
|
|
|
HIP_CHECK(hipGraphInstantiate(graph_exec, graph, &node_error, nullptr, 0));
|
|
HIP_CHECK(hipGraphDestroy(graph));
|
|
}
|
|
|
|
static void HipGraphLaunch_Positive_Simple(hipStream_t stream) {
|
|
int number = 5;
|
|
|
|
hipGraphExec_t graph_exec;
|
|
CreateTestExecutableGraph(&graph_exec, &number);
|
|
|
|
HIP_CHECK(hipGraphLaunch(graph_exec, stream));
|
|
HIP_CHECK(hipStreamSynchronize(stream));
|
|
REQUIRE(number == 1);
|
|
|
|
HIP_CHECK(hipGraphExecDestroy(graph_exec));
|
|
}
|
|
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Basic positive test for hipGraphLaunch
|
|
* -# stream as a created stream
|
|
* -# with stream as hipStreamPerThread
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/graph/hipGraphLaunch.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_hipGraphLaunch_Positive) {
|
|
SECTION("stream as a created stream") {
|
|
hipStream_t stream;
|
|
HIP_CHECK(hipStreamCreate(&stream));
|
|
HipGraphLaunch_Positive_Simple(stream);
|
|
HIP_CHECK(hipStreamDestroy(stream));
|
|
}
|
|
|
|
SECTION("with stream as hipStreamPerThread") {
|
|
HipGraphLaunch_Positive_Simple(hipStreamPerThread);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Negative parameter test for hipGraphLaunch
|
|
* -# graphExec is nullptr and stream is a created stream
|
|
* -# graphExec is nullptr and stream is hipStreamPerThread
|
|
* -# graphExec is an empty object
|
|
* -# graphExec is destroyed before calling hipGraphLaunch
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/graph/hipGraphLaunch.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_hipGraphLaunch_Negative_Parameters) {
|
|
SECTION("graphExec is nullptr and stream is a created stream") {
|
|
hipStream_t stream;
|
|
hipError_t ret;
|
|
HIP_CHECK(hipStreamCreate(&stream));
|
|
ret = hipGraphLaunch(nullptr, stream);
|
|
HIP_CHECK(hipStreamDestroy(stream));
|
|
REQUIRE(ret == hipErrorInvalidValue);
|
|
}
|
|
|
|
SECTION("graphExec is nullptr and stream is hipStreamPerThread") {
|
|
HIP_CHECK_ERROR(hipGraphLaunch(nullptr, hipStreamPerThread), hipErrorInvalidValue);
|
|
}
|
|
|
|
SECTION("graphExec is an empty object") {
|
|
hipGraphExec_t graph_exec{};
|
|
HIP_CHECK_ERROR(hipGraphLaunch(graph_exec, hipStreamPerThread), hipErrorInvalidValue);
|
|
}
|
|
|
|
SECTION("graphExec is destroyed") {
|
|
int number = 5;
|
|
hipGraphExec_t graph_exec;
|
|
CreateTestExecutableGraph(&graph_exec, &number);
|
|
HIP_CHECK(hipGraphLaunch(graph_exec, hipStreamPerThread));
|
|
HIP_CHECK(hipStreamSynchronize(hipStreamPerThread));
|
|
REQUIRE(number == 1);
|
|
HIP_CHECK(hipGraphExecDestroy(graph_exec));
|
|
HIP_CHECK_ERROR(hipGraphLaunch(graph_exec, hipStreamPerThread), hipErrorInvalidValue);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* End doxygen group GraphTest.
|
|
* @}
|
|
*/
|